Ver código fonte

返回之前的版本,压缩方案有问题

zengjiebin 7 anos atrás
pai
commit
a03fed3465

+ 38 - 43
app/src/main/java/com/sheep/gamegroup/view/activity/ActPublishArticle.java

@@ -179,52 +179,47 @@ public class ActPublishArticle extends BaseActivity {
     private void uploadFile() {
         final DialogProgress dialogProgress = DialogProgress.showDialog(this);
         uploadType = UPLOAD_TYPE_START;
-        QiNiuUploadUtil.getInstance().uploadFile(video.getFilePath()/*, QiNiuUploadUtil.TAG_VIDEO*/, new UpCompletionHandler() {
-            @Override
-            public void complete(String key, ResponseInfo info, JSONObject response) {
-                LogUtil.println("qiniu", key, info, response);
-                if (info == null) {
-                    ViewUtil.setText(dialogProgress.getTextView(), "上传失败");
-                    ViewUtil.dismiss(dialogProgress, 1);
-                    uploadType = UPLOAD_TYPE_FAIL;
-                    return;
+        QiNiuUploadUtil.getInstance().uploadFile(video.getFilePath()/*, QiNiuUploadUtil.TAG_VIDEO*/, (key, info, response) -> {
+            LogUtil.println("qiniu", key, info, response);
+            if (info == null) {
+                ViewUtil.setText(dialogProgress.getTextView(), "上传失败");
+                ViewUtil.dismiss(dialogProgress, 1);
+                uploadType = UPLOAD_TYPE_FAIL;
+                return;
+            }
+            //res包含hash、key等信息,具体字段取决于上传策略的设置
+            if (info.isOK()) {
+                ViewUtil.setText(dialogProgress.getTextView(), "上传成功");
+                uploadType = UPLOAD_TYPE_SUCCESS;
+                String url = null;
+                try {
+                    url = QiNiuUploadUtil.BASE_URL + response.getString("key");
+                } catch (JSONException e) {
+                    e.printStackTrace();
                 }
-                //res包含hash、key等信息,具体字段取决于上传策略的设置
-                if (info.isOK()) {
-                    ViewUtil.setText(dialogProgress.getTextView(), "上传成功");
-                    uploadType = UPLOAD_TYPE_SUCCESS;
-                    String url = null;
-                    try {
-                        url = QiNiuUploadUtil.BASE_URL + response.getString("key");
-                    } catch (JSONException e) {
-                        e.printStackTrace();
-                    }
-                    jsonObject.put("resource", url);
-                    int a = video.getWidth();
-                    int b = video.getHeight();
-                    switch (video.getOrientation()) {
-                        case 90:
-                        case 270:
-                            a = video.getHeight();
-                            b = video.getWidth();
-                            break;
-                    }
-                    int rotate = 360 - Math.max(0, video.getOrientation());
-                    jsonObject.put("cover", String.format(Locale.CHINA, "%s?vframe/jpg/offset/0/rotate/%d&w=%d&h=%d", url, rotate, a, b));
-                    publishArticle(dialogProgress);
-                } else {
-                    ViewUtil.setText(dialogProgress.getTextView(), "上传失败");
-                    ViewUtil.dismiss(dialogProgress, 1);
-                    uploadType = UPLOAD_TYPE_FAIL;
-                    //如果失败,这里可以把info信息上报自己的服务器,便于后面分析上传错误原因
+                jsonObject.put("resource", url);
+                int a = video.getWidth();
+                int b = video.getHeight();
+                switch (video.getOrientation()) {
+                    case 90:
+                    case 270:
+                        a = video.getHeight();
+                        b = video.getWidth();
+                        break;
                 }
-                LogUtil.println("qiniu", key + ",\r\n " + info + ",\r\n " + response);
-            }
-        }, new UpProgressHandler() {
-            public void progress(String key, double percent) {
-                LogUtil.println("qiniu", key + ": " + percent);
-                ViewUtil.setText(dialogProgress.getTextView(), String.format(Locale.CHINA, "%d%%", (int) (percent * 100)));
+                int rotate = 360 - Math.max(0, video.getOrientation());
+                jsonObject.put("cover", String.format(Locale.CHINA, "%s?vframe/jpg/offset/0/rotate/%d&w=%d&h=%d", url, rotate, a, b));
+                publishArticle(dialogProgress);
+            } else {
+                ViewUtil.setText(dialogProgress.getTextView(), "上传失败");
+                ViewUtil.dismiss(dialogProgress, 1);
+                uploadType = UPLOAD_TYPE_FAIL;
+                //如果失败,这里可以把info信息上报自己的服务器,便于后面分析上传错误原因
             }
+            LogUtil.println("qiniu", key + ",\r\n " + info + ",\r\n " + response);
+        }, (key, percent) -> {
+            LogUtil.println("qiniu", key + ": " + percent);
+            ViewUtil.setText(dialogProgress.getTextView(), String.format(Locale.CHINA, "%d%%", (int) (percent * 100)));
         });
     }