Procházet zdrojové kódy

fixed viewpager & h5 banner gesture conflict

hanjing před 7 roky
rodič
revize
6ceb334b24

+ 7 - 5
app/src/main/java/com/sheep/gamegroup/model/api/IWeb.java

@@ -8,15 +8,15 @@ import com.sheep.gamegroup.model.entity.TaskEty;
  */
 public interface IWeb {
 
-    public abstract boolean isResponseBack();
+    boolean isResponseBack();
 
-    public abstract void setResponseBack(boolean responseBack);
+    void setResponseBack(boolean responseBack);
 
-    public abstract void clearWebView();
+    void clearWebView();
 
-    public abstract void loadJs(String js);
+    void loadJs(String js);
 
-    public abstract void showTitleBar(boolean isShow);
+    void showTitleBar(boolean isShow);
 
     void onClickDownloadBtn();
 
@@ -27,4 +27,6 @@ public interface IWeb {
     void setH5Type(String h5Type);
 
     void superFinish();
+
+    void setNonTouchArea(float height);
 }

+ 35 - 7
app/src/main/java/com/sheep/gamegroup/module/webview/fragment/FgtWebX5.java

@@ -12,7 +12,9 @@ import android.provider.MediaStore;
 import android.support.v7.app.ActionBar;
 import android.support.v7.app.AlertDialog;
 import android.text.TextUtils;
+import android.util.Log;
 import android.view.LayoutInflater;
+import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.animation.Animation;
@@ -61,6 +63,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 import butterknife.BindView;
+import cn.modificator.waterwave_progress.WidgetUtil;
 import okhttp3.Call;
 import ren.yale.android.cachewebviewlib.WebViewCacheInterceptorInst;
 
@@ -94,7 +97,7 @@ public class FgtWebX5 extends BaseFgtWeb {
     public void initView() {
         ViewUtil.setImage(act_web_loading_iv, R.drawable.gif_sheep_loading);
 
-        if(webParams == null){
+        if (webParams == null) {
             LogUtil.println("程序出错了 没有初始化webParams");
             //程序出错了
             return;
@@ -154,8 +157,9 @@ public class FgtWebX5 extends BaseFgtWeb {
 
     //忽略 添加有范商城快捷入口
     public static final String KEY_IGNORE_ADD_YOU_FAN_LAUNCHER = "ignore_add_you_fan_launcher";
+
     private void checkWebParams(WebParams webParams) {
-        if(webParams.getUrl().startsWith(Config.YF_SHOP_HOME_SHEEP.split("\\?")[0]) || webParams.getUrl().startsWith(Config.YF_SHOP_HOME_SHEEP_TEST.split("\\?")[0])) {//检测是否是有范商城地址
+        if (webParams.getUrl().startsWith(Config.YF_SHOP_HOME_SHEEP.split("\\?")[0]) || webParams.getUrl().startsWith(Config.YF_SHOP_HOME_SHEEP_TEST.split("\\?")[0])) {//检测是否是有范商城地址
             boolean isIgnore = SpUtils.getAsBoolean(KEY_IGNORE_ADD_YOU_FAN_LAUNCHER, false);
             boolean hasShortcut = SysAppUtil.hasShortcut(SheepApp.getInstance(), Config.YF_SHOP_NAME);
             boolean isShow = !hasShortcut && !isIgnore && !CommonUtil.getInstance().hasYouFanLauncher();//未忽略并且没有添加有范商品入口
@@ -352,7 +356,7 @@ public class FgtWebX5 extends BaseFgtWeb {
         mWebView.setWebViewClient(new WebViewClient() {
             @Override
             public WebResourceResponse shouldInterceptRequest(WebView webView, String s) {
-                if(TestUtil.isDev()){
+                if (TestUtil.isDev()) {
                     return super.shouldInterceptRequest(webView, s);
                 }
                 if (s.contains("ssnocache=1")) return null;
@@ -362,7 +366,7 @@ public class FgtWebX5 extends BaseFgtWeb {
 
             @Override
             public WebResourceResponse shouldInterceptRequest(WebView webView, WebResourceRequest webResourceRequest) {
-                if(TestUtil.isDev()){
+                if (TestUtil.isDev()) {
                     return super.shouldInterceptRequest(webView, webResourceRequest);
                 }
                 if (url.contains("ssnocache=1")) return null;
@@ -498,13 +502,14 @@ public class FgtWebX5 extends BaseFgtWeb {
     }
 
     private int onResumeCount = 0;
+
     @Override
     public void onResume() {
         super.onResume();
-        if(onResumeCount > 0 && mWebView != null && webParams.isRefreshClick()){
+        if (onResumeCount > 0 && mWebView != null && webParams.isRefreshClick()) {
             loadJs("refreshClick()");
         }
-        onResumeCount ++;
+        onResumeCount++;
     }
 
     @Override
@@ -586,9 +591,32 @@ public class FgtWebX5 extends BaseFgtWeb {
             ActionBar actionBar = ((BaseActivity) SheepApp.getInstance().getCurrentActivity()).getSupportActionBar();
             if (actionBar != null)
                 actionBar.hide();
-        } catch (Exception e){
+        } catch (Exception e) {
             e.printStackTrace();
         }
     }
 
+    @Override
+    public void setNonTouchArea(float height) {
+        mWebView.setOnTouchListener((v, event) -> {
+            float y = event.getY();
+            int yy = WidgetUtil.Px2Dp(getContext(), y);
+            Log.e("compare", yy + " : " + height);
+            switch (event.getAction()) {
+                case MotionEvent.ACTION_DOWN:
+                    if (yy < height) {
+                        mWebView.requestDisallowInterceptTouchEvent(true);
+                    } else {
+                        mWebView.requestDisallowInterceptTouchEvent(false);
+                    }
+                    break;
+                case MotionEvent.ACTION_UP:
+                    break;
+                case MotionEvent.ACTION_MOVE:
+                    break;
+            }
+            return false;
+        });
+    }
+
 }

+ 11 - 0
app/src/main/java/com/sheep/gamegroup/util/js/KFZSJs.java

@@ -4,6 +4,7 @@ import android.app.Activity;
 import android.content.Intent;
 import android.provider.MediaStore;
 import android.text.TextUtils;
+import android.util.Log;
 import android.view.View;
 import android.webkit.JavascriptInterface;
 
@@ -500,4 +501,14 @@ public class KFZSJs {
     public void finishActivity() {
         activity.finish();
     }
+
+    @JavascriptInterface
+    public void setNonTouchArea(String h) {
+        try {
+            int height = Integer.valueOf(h.replaceAll("px", ""));
+            iWeb.setNonTouchArea(height);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
 }

+ 5 - 0
app/src/main/java/com/sheep/gamegroup/view/activity/ActWebX5.java

@@ -588,4 +588,9 @@ public class ActWebX5 extends BaseActWeb {
             actionBar.hide();
     }
 
+    @Override
+    public void setNonTouchArea(float height) {
+
+    }
+
 }