Ver código fonte

修复有些手机无法剪切视频的bug

zengjiebin 7 anos atrás
pai
commit
16ed076bcf

+ 5 - 0
app/src/main/java/com/sheep/gamegroup/model/api/ApiService.java

@@ -808,6 +808,11 @@ public interface ApiService {
      */
     @GET("app/find/applications")
     Observable<BaseMessage> getAppDetail(@Query("id") int id);
+    /**
+     * 获取app_id
+     */
+    @GET("app/find/get/app_id")
+    Observable<BaseMessage> getAppId(@Query("game_id") int game_id);
 
     /**
      * 应用 各评分人数

+ 15 - 8
app/src/main/java/com/sheep/gamegroup/util/CommonUtil.java

@@ -14,6 +14,7 @@ import android.support.design.widget.TabLayout;
 import android.support.v7.app.AlertDialog;
 import android.text.Html;
 import android.text.TextUtils;
+import android.util.Patterns;
 import android.util.TypedValue;
 import android.view.View;
 import android.view.ViewGroup;
@@ -103,6 +104,7 @@ import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
+import java.util.regex.Matcher;
 
 import io.reactivex.Observable;
 import io.reactivex.ObservableEmitter;
@@ -2600,14 +2602,9 @@ public class CommonUtil {
             String textString = text.toString();
             View.OnClickListener closeListener = view -> DataUtil.putAsString(Config.KEY_USED_COPY_TEXT, textString);
             DialogConfig dialogConfig = new DialogConfig().setTitle("小绵羊提示").setBtnCloseOnClickListener(closeListener);
-            if (textString.startsWith("http://") || textString.startsWith("https://")) {//如果是链接,直接跳转外部浏览器
-                dialogConfig.setMsg("已经复制如下内容:\n" + textString + "\n,是否访问该链接?")
-                        .setBtnLeftText("确定").setBtnLeftOnClickListener(view -> Jump2View.getInstance().goWeb(SheepApp.getInstance().getCurrentActivity(), textString))
-                        .setBtnRightText("仅一次").setBtnRightOnClickListener(view -> {
-                    closeListener.onClick(view);
-                    Jump2View.getInstance().goWeb(SheepApp.getInstance().getCurrentActivity(), textString);
-                });
-                ViewUtil.showMsgDialog(SheepApp.getInstance().getCurrentActivity(), dialogConfig);
+            Matcher matcher = Patterns.WEB_URL.matcher(text);
+            if (matcher.find()) {//如果是链接,直接跳转外部浏览器
+                shoGoWebDialog(dialogConfig, closeListener, textString, matcher.group());
             } else if (textString.contains("://")) {
                 dialogConfig.setMsg("已经复制如下内容:\n" + textString + "\n,是否尝试跳转?")
                         .setBtnLeftText("确定").setBtnLeftOnClickListener(view -> Jump2View.getInstance().tryGotoDeepLink(textString))
@@ -2630,4 +2627,14 @@ public class CommonUtil {
             }
         }
     }
+
+    private void shoGoWebDialog(DialogConfig dialogConfig, View.OnClickListener closeListener, String textString, String url) {
+        dialogConfig.setMsg("已经复制如下内容:\n" + textString + "\n,是否访问该链接?")
+                .setBtnLeftText("确定").setBtnLeftOnClickListener(view -> Jump2View.getInstance().goWeb(SheepApp.getInstance().getCurrentActivity(), url))
+                .setBtnRightText("仅一次").setBtnRightOnClickListener(view -> {
+            closeListener.onClick(view);
+            Jump2View.getInstance().goWeb(SheepApp.getInstance().getCurrentActivity(), url);
+        });
+        ViewUtil.showMsgDialog(SheepApp.getInstance().getCurrentActivity(), dialogConfig);
+    }
 }

+ 3 - 3
media/app/src/main/java/com/kfzs/cfyl/media/util/VideoUtil.java

@@ -182,11 +182,10 @@ public class VideoUtil {
     }
 
     private static final String TAG = VideoUtil.class.getSimpleName();
-    public static void tryCutVideoByMedia(final String filePath, long clipPoint, final long clipDuration, final Action1<Object> action1) {
+    public static void tryCutVideoByMedia(final String filePath, final long clipPoint, final long clipDuration, final Action1<Object> action1) {
         final Video video = new Video();
         if (clipPoint < 0) {
             Log.e(TAG, "clipPoint is error! but reset clipPoint " + clipPoint + "0 ");
-            clipPoint = 0;
         }
         LogUtil.println(TAG, filePath, clipPoint, clipDuration);
         String outFilePath = getCutVideoFilePath(filePath, clipPoint, clipDuration);
@@ -207,7 +206,8 @@ public class VideoUtil {
 
             @Override
             public void onFailure() {
-                action1.call(new Throwable("剪切失败"));
+//                action1.call(new Throwable("剪切失败"));
+                tryCutVideo(filePath, clipPoint, clipDuration, action1);
             }
 
             @Override