hanjing лет назад: 6
Родитель
Сommit
6d0724c634

+ 0 - 4
app/src/main/AndroidManifest.xml

@@ -457,10 +457,6 @@
             android:screenOrientation="portrait"
             android:theme="@style/AppActionTheme" />
         <activity
-            android:name="com.sheep.gamegroup.view.activity.ActWeb"
-            android:screenOrientation="portrait"
-            android:theme="@style/AppActionTheme" />
-        <activity
             android:name="com.sheep.gamegroup.view.activity.ActWebX5YF"
             android:screenOrientation="portrait"
             android:theme="@style/AppActionTheme" >

+ 9 - 4
app/src/main/java/com/sheep/gamegroup/module/webview/fragment/FgtWeb.java

@@ -38,6 +38,7 @@ import com.sheep.gamegroup.util.SysAppUtil;
 import com.sheep.gamegroup.util.TestUtil;
 import com.sheep.gamegroup.util.ViewUtil;
 import com.sheep.gamegroup.util.js.KFZSJs;
+import com.sheep.gamegroup.view.activity.ActMain;
 import com.sheep.gamegroup.view.activity.MiddleSchemeAct;
 import com.sheep.jiuyan.samllsheep.BuildConfig;
 import com.sheep.jiuyan.samllsheep.Config;
@@ -45,6 +46,7 @@ import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.utils.G;
 import com.sheep.jiuyan.samllsheep.utils.SpUtils;
+import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
 import com.yalantis.ucrop.util.FileUtils;
 import com.zhy.http.okhttp.OkHttpUtils;
 import com.zhy.http.okhttp.callback.StringCallback;
@@ -248,10 +250,13 @@ public class FgtWeb extends BaseFgtWeb {
             @Override
             public void onReceivedTitle(WebView view, String title) {
                 super.onReceivedTitle(view, title);
-//                if (webParams.isShowTitle())
-//                    TitleBarUtils
-//                            .getInstance()
-//                            .setTitle(ActWebX5.this, title);
+                if (webParams.isShowTitle()) {
+                    if (!(getActivity() instanceof ActMain)) {
+                        TitleBarUtils
+                                .getInstance()
+                                .setTitle(getActivity(), title);
+                    }
+                }
             }
 
             @Override

+ 17 - 12
app/src/main/java/com/sheep/gamegroup/module/webview/fragment/FgtWebX5.java

@@ -35,6 +35,7 @@ import com.sheep.gamegroup.util.SysAppUtil;
 import com.sheep.gamegroup.util.TestUtil;
 import com.sheep.gamegroup.util.ViewUtil;
 import com.sheep.gamegroup.util.js.KFZSJs;
+import com.sheep.gamegroup.view.activity.ActMain;
 import com.sheep.gamegroup.view.activity.MiddleSchemeAct;
 import com.sheep.jiuyan.samllsheep.BuildConfig;
 import com.sheep.jiuyan.samllsheep.Config;
@@ -42,6 +43,7 @@ import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.utils.G;
 import com.sheep.jiuyan.samllsheep.utils.SpUtils;
+import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
 import com.tencent.smtt.export.external.interfaces.WebResourceRequest;
 import com.tencent.smtt.export.external.interfaces.WebResourceResponse;
 import com.tencent.smtt.sdk.ValueCallback;
@@ -253,10 +255,13 @@ public class FgtWebX5 extends BaseFgtWebX5 {
             @Override
             public void onReceivedTitle(WebView view, String title) {
                 super.onReceivedTitle(view, title);
-//                if (webParams.isShowTitle())
-//                    TitleBarUtils
-//                            .getInstance()
-//                            .setTitle(ActWebX5.this, title);
+                if (webParams.isShowTitle()) {
+                    if (!(getActivity() instanceof ActMain)) {
+                        TitleBarUtils
+                                .getInstance()
+                                .setTitle(getActivity(), title);
+                    }
+                }
             }
 
             @Override
@@ -322,7 +327,7 @@ public class FgtWebX5 extends BaseFgtWebX5 {
 
             @Override
             public void onProgressChanged(WebView view, int newProgress) {
-                LogUtil.println("ActWeb", "onProgressChanged", newProgress);
+                LogUtil.println("ActWebX5", "onProgressChanged", newProgress);
                 if (newProgress == 100 && ViewUtil.isVisible(act_web_loading_iv)) {
                     Animation animation = AnimationUtils.loadAnimation(SheepApp.getInstance(), R.anim.anim_alpha_1_0);
                     animation.setAnimationListener(new Animation.AnimationListener() {
@@ -356,7 +361,7 @@ public class FgtWebX5 extends BaseFgtWebX5 {
                     return super.shouldInterceptRequest(webView, s);
                 }
                 if (s.contains("ssnocache=1")) return null;
-                LogUtil.println("ActWeb", "shouldInterceptRequest from cache", url);
+                LogUtil.println("ActWebX5", "shouldInterceptRequest from cache", url);
                 return WebResourceResponseAdapter.adapter(WebViewCacheInterceptorInst.getInstance().interceptRequest(s));
             }
 
@@ -366,13 +371,13 @@ public class FgtWebX5 extends BaseFgtWebX5 {
                     return super.shouldInterceptRequest(webView, webResourceRequest);
                 }
                 if (url.contains("ssnocache=1")) return null;
-                LogUtil.println("ActWeb", "shouldInterceptRequest from cache", url);
+                LogUtil.println("ActWebX5", "shouldInterceptRequest from cache", url);
                 return WebResourceResponseAdapter.adapter(WebViewCacheInterceptorInst.getInstance().interceptRequest(WebResourceRequestAdapter.adapter(webResourceRequest)));
             }
 
             @Override
             public boolean shouldOverrideUrlLoading(WebView view, String url) {
-                LogUtil.println("ActWeb", "shouldOverrideUrlLoading", url);
+                LogUtil.println("ActWebX5", "shouldOverrideUrlLoading", url);
                 //微信H5支付核心代码
                 if (url.startsWith(Config.SHEEP_PAY)) {
                     String order_no = StringUtils.getQueryParameter(url, Config.YF_SHOP_ORDER_NUMBER_KEY);
@@ -424,13 +429,13 @@ public class FgtWebX5 extends BaseFgtWebX5 {
 
             @Override
             public void onPageStarted(WebView view, String url, Bitmap favicon) {
-                LogUtil.println("ActWeb", "onPageStarted", url);
+                LogUtil.println("ActWebX5", "onPageStarted", url);
                 super.onPageStarted(view, url, favicon);
             }
 
             @Override
             public void onPageFinished(WebView view, String url) {
-                LogUtil.println("ActWeb", "onPageFinished", url);
+                LogUtil.println("ActWebX5", "onPageFinished", url);
                 super.onPageFinished(view, url);
                 loadJs();
             }
@@ -448,7 +453,7 @@ public class FgtWebX5 extends BaseFgtWebX5 {
                 loadUrl = addUrlQuery(loadUrl, "device_id", DeviceUtil.getDeviceId(SheepApp.getInstance()));
             }
             loadUrl = addUrlQuery(loadUrl, webParams.getInvitationCodeKey(), DataUtil.getInstance().getInvitationCode());
-            LogUtil.println("ActWeb loadUrl = " + loadUrl);
+            LogUtil.println("ActWebX5 loadUrl = " + loadUrl);
             webViewLoadUrl(mWebView, loadUrl);
         } else {
             webViewLoadUrl(mWebView, url);
@@ -556,7 +561,7 @@ public class FgtWebX5 extends BaseFgtWebX5 {
         if (TextUtils.isEmpty(js))
             return;
         ViewUtil.loadJs(mWebView, getJs());
-        LogUtil.println("ActWeb", "loadJs", js);
+        LogUtil.println("ActWebX5", "loadJs", js);
     }
 
     private String js;

+ 1 - 7
app/src/main/java/com/sheep/gamegroup/util/Jump2View.java

@@ -134,7 +134,6 @@ import com.sheep.gamegroup.view.activity.ActUserLabelList;
 import com.sheep.gamegroup.view.activity.ActUserNoviceGuidance;
 import com.sheep.gamegroup.view.activity.ActVideoComment;
 import com.sheep.gamegroup.view.activity.ActVideoDetail;
-import com.sheep.gamegroup.view.activity.ActWeb;
 import com.sheep.gamegroup.view.activity.ActWebX5;
 import com.sheep.gamegroup.view.activity.ActXianWanWeb;
 import com.sheep.gamegroup.view.activity.ActXiaomiGame;
@@ -1023,12 +1022,7 @@ public class Jump2View {
             goActPlayVideo(url, webParams.getTitle());
             return;
         }
-        Intent intent = null;
-        if (EmulatorDetectUtil.isEmulator()) {
-            intent = new Intent(context, ActWeb.class);
-        } else {
-            intent = new Intent(context, ActWebX5.class);
-        }
+        Intent intent = new Intent(context, ActWebX5.class);
         intent.putExtra(WebParams.class.getSimpleName(), webParams);
         if (webParams.isForResult()) {
             ((Activity) context).startActivityForResult(intent, webParams.getAction());

+ 0 - 588
app/src/main/java/com/sheep/gamegroup/view/activity/ActWeb.java

@@ -1,588 +0,0 @@
-package com.sheep.gamegroup.view.activity;
-
-import android.annotation.SuppressLint;
-import android.app.Activity;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.graphics.Bitmap;
-import android.net.Uri;
-import android.os.Build;
-import android.os.Bundle;
-import android.os.Environment;
-import android.provider.MediaStore;
-import android.support.annotation.Nullable;
-import android.support.annotation.RequiresApi;
-import android.support.v7.app.ActionBar;
-import android.support.v7.app.AlertDialog;
-import android.text.TextUtils;
-import android.view.View;
-import android.view.animation.Animation;
-import android.view.animation.AnimationUtils;
-import android.webkit.ValueCallback;
-import android.webkit.WebChromeClient;
-import android.webkit.WebSettings;
-import android.webkit.WebView;
-import android.webkit.WebViewClient;
-import android.widget.ImageView;
-import android.widget.ProgressBar;
-
-import com.sheep.gamegroup.model.entity.WebParams;
-import com.sheep.gamegroup.util.CommonUtil;
-import com.sheep.gamegroup.util.Constant;
-import com.sheep.gamegroup.util.DataUtil;
-import com.sheep.gamegroup.util.DeviceUtil;
-import com.sheep.gamegroup.util.Jump2View;
-import com.sheep.gamegroup.util.LogUtil;
-import com.sheep.gamegroup.util.NetUtil;
-import com.sheep.gamegroup.util.StringUtils;
-import com.sheep.gamegroup.util.SysAppUtil;
-import com.sheep.gamegroup.util.TestUtil;
-import com.sheep.gamegroup.util.ViewUtil;
-import com.sheep.gamegroup.util.js.BaseActWeb;
-import com.sheep.gamegroup.util.js.BaseActWebX5;
-import com.sheep.gamegroup.util.js.KFZSJs;
-import com.sheep.jiuyan.samllsheep.BuildConfig;
-import com.sheep.jiuyan.samllsheep.Config;
-import com.sheep.jiuyan.samllsheep.R;
-import com.sheep.jiuyan.samllsheep.SheepApp;
-import com.sheep.jiuyan.samllsheep.utils.G;
-import com.sheep.jiuyan.samllsheep.utils.SpUtils;
-import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
-import com.yalantis.ucrop.util.FileUtils;
-import com.zhy.http.okhttp.OkHttpUtils;
-import com.zhy.http.okhttp.callback.StringCallback;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import butterknife.BindView;
-import okhttp3.Call;
-
-
-/**
- * web页面--含有所有js及url后添加authorization
- * Created by zengjiebin on 2018/4/27.
- */
-public class ActWeb extends BaseActWeb {
-
-    @BindView(R.id.webview)
-    WebView mWebView;
-    @BindView(R.id.act_web_loading_pb)
-    ProgressBar act_web_loading_pb;
-    @BindView(R.id.act_web_loading_iv)
-    ImageView act_web_loading_iv;
-    protected WebParams webParams;
-
-    @Override
-    protected void onCreate(@Nullable Bundle savedInstanceState) {
-        initWebParams();
-        super.onCreate(savedInstanceState);
-    }
-
-    @Override
-    protected int getTitleLayoutId() {
-        if(checkWebParams(webParams)){
-            return R.layout.title_yf;
-        }
-        return super.getTitleLayoutId();
-    }
-
-    @Override
-    protected int getLayoutId() {
-        return R.layout.act_web;
-    }
-
-    @RequiresApi(api = Build.VERSION_CODES.KITKAT)
-    @Override
-    public void initView() {
-        ViewUtil.setImage(act_web_loading_iv, R.drawable.gif_sheep_loading);
-
-        String url = webParams.getUrl();
-        String jsUrl = webParams.getJsUrl();
-        if (!TextUtils.isEmpty(url)) {
-            url = url.trim();
-        }
-        if(checkWebParams(webParams)){
-            TitleBarUtils
-                    .getInstance()
-                    .setShowOrHide(this, true)
-                    .setTitle(this, webParams.getTitle())
-                    .setRightSecondBtn(this, R.mipmap.tianjtb, view -> SysAppUtil.addShortcut(this))
-                    .setRightImgBotton(this, R.mipmap.guanb, view -> super.finish())
-                    .setTitleFinish(this);
-        } else if (webParams.isShowTitle()) {
-            TitleBarUtils
-                    .getInstance()
-                    .setShowOrHide(this, true)
-                    .setTitle(this, webParams.getTitle())
-                    .setRightImgBotton(this, R.drawable.ic_edit_text_delete, view -> super.finish())
-                    .setTitleFinish(this);
-        }
-        initWebViewSettings(mWebView);
-        try {
-            if (TestUtil.isTest())
-                WebView.setWebContentsDebuggingEnabled(true);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
-//            webViewSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
-        }
-        if (TextUtils.isEmpty(jsUrl)) {
-            loadUrl(url);
-        } else {
-            initJsData(url, jsUrl);
-        }
-    }
-
-    public void initWebParams() {
-        Intent intent = getIntent();
-        webParams = (WebParams) intent.getSerializableExtra(WebParams.class.getSimpleName());
-    }
-
-//    //忽略 添加有范商城快捷入口
-//    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])) {//检测是否是有范商城地址
-//            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();//未忽略并且没有添加有范商品入口
-////            boolean isShow = !isIgnore && !SysAppUtil.isEnableComponentYf();
-//            if (isShow) {
-//                ViewUtil.showMsgDialog(this, new DialogConfig().setTitle("温馨提示")
-//                        .setMsg("亲,喜欢的话,就添加一个商城的桌面快捷入口吧!(点击否将不再提示)")
-//                        .setBtnLeftText("否").setBtnLeftOnClickListener(view -> SpUtils.putAsBoolean(KEY_IGNORE_ADD_YOU_FAN_LAUNCHER, true))
-//                        .setBtnRightText("是").setBtnRightOnClickListener(view -> CommonUtil.getInstance().addYouFanLauncher()));
-////                        .setBtnRightText("是").setBtnRightOnClickListener(view -> SysAppUtil.enableComponentYf()));
-//            }
-//        }
-//    }
-    private boolean checkWebParams(WebParams webParams) {
-        return webParams.getUrl().startsWith(Config.YF_SHOP_HOME_SHEEP.split("\\?")[0]) || webParams.getUrl().startsWith(Config.YF_SHOP_HOME_SHEEP_TEST.split("\\?")[0]);//检测是否是有范商城地址
-    }
-
-    //初始化js代码数据
-    private void initJsData(final String url, String jsUrl) {
-        OkHttpUtils.get()
-                .url(jsUrl)
-                .build()
-                .execute(new StringCallback() {
-                    @Override
-                    public void onError(Call call, Exception e, int id) {
-                        G.showToast(R.string.service_data_error);
-                    }
-
-                    @Override
-                    public void onResponse(String response, int id) {
-                        js = response;
-                        loadUrl(url);
-                    }
-                });
-    }
-
-    @Override
-    public void initListener() {
-        CommonUtil.getInstance().setDownloadListener(this, mWebView);
-    }
-
-    public static void initWebViewSettings(WebView webView) {
-        webView.setClickable(true);
-        WebSettings webSetting = webView.getSettings();
-        webSetting.setJavaScriptEnabled(true);
-        webSetting.setJavaScriptCanOpenWindowsAutomatically(true);
-        webSetting.setAllowFileAccess(true);
-        webSetting.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
-//        webSetting.setSupportZoom(true);
-//        webSetting.setBuiltInZoomControls(true);
-        webSetting.setUseWideViewPort(true);
-        webSetting.setSupportMultipleWindows(true);
-        // webSetting.setLoadWithOverviewMode(true);
-        webSetting.setAppCacheEnabled(true);
-        // webSetting.setDatabaseEnabled(true);
-        webSetting.setDomStorageEnabled(true);
-        webSetting.setGeolocationEnabled(true);
-        webSetting.setAppCacheMaxSize(Long.MAX_VALUE);
-        // webSetting.setPageCacheCapacity(IX5WebSettings.DEFAULT_CACHE_CAPACITY);
-        webSetting.setPluginState(WebSettings.PluginState.ON_DEMAND);
-        // webSetting.setRenderPriority(WebSettings.RenderPriority.HIGH);
-        webSetting.setCacheMode(NetUtil.CAN_CONNECT_SERVICE ? WebSettings.LOAD_DEFAULT : WebSettings.LOAD_CACHE_ELSE_NETWORK);
-
-        // this.getSettingsExtension().setPageCacheCapacity(IX5WebSettings.DEFAULT_CACHE_CAPACITY);//extension
-        // settings 的设计
-        webSetting.setUserAgentString(getSheepUserAgent());
-    }
-
-    @Override
-    protected void onDestroy() {
-        if (act_web_loading_iv != null) {
-            try {
-                act_web_loading_iv.clearAnimation();
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-        }
-        if (mWebView != null) {
-            mWebView.setVisibility(View.GONE);
-            mWebView.removeAllViews();
-            mWebView.destroy();
-        }
-        super.onDestroy();
-    }
-
-    /**
-     *
-     */
-    public static final int INPUT_FILE_REQUEST_CODE = 1;
-    private ValueCallback<Uri> mUploadMessage;
-    private final static int FILECHOOSER_RESULTCODE = 2;
-    private ValueCallback<Uri[]> mFilePathCallback;
-
-    private String mCameraPhotoPath;
-
-    private void loadUrl(final String url) {
-
-        mWebView.setWebChromeClient(new WebChromeClient() {
-            @Override
-            public void onReceivedTitle(WebView view, String title) {
-                super.onReceivedTitle(view, title);
-                if (webParams.isShowTitle())
-                    TitleBarUtils
-                            .getInstance()
-                            .setTitle(ActWeb.this, title);
-            }
-
-            @Override
-            public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) {
-                if (mFilePathCallback != null) {
-                    mFilePathCallback.onReceiveValue(null);
-                }
-                mFilePathCallback = filePathCallback;
-
-                /*PhotoPicker.builder()
-                        .setPhotoCount(1)
-                        .setShowCamera(true)
-                        .setShowGif(false)
-                        .setPreviewEnabled(true)
-                        .start(ActWeb.this, PhotoPicker.REQUEST_CODE);*/
-                Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
-                if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
-                    // Create the File where the photo should go
-                    File photoFile;
-                    photoFile = createImageFile();
-                    takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath);
-
-                    // Continue only if the File was successfully created
-                    if (photoFile != null) {
-                        mCameraPhotoPath = "file:" + photoFile.getAbsolutePath();
-                        takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
-                                Uri.fromFile(photoFile));
-                    } else {
-                    }
-                }
-
-                Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
-                contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
-                contentSelectionIntent.setType("image/*");
-
-                Intent[] intentArray;
-                takePictureIntent = null;//步调用相机
-                if (takePictureIntent != null) {
-                    intentArray = new Intent[]{takePictureIntent};
-                } else {
-                    intentArray = new Intent[0];
-                }
-
-                Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
-                chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
-                chooserIntent.putExtra(Intent.EXTRA_TITLE, "图片选择");
-                chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);
-
-                startActivityForResult(chooserIntent, INPUT_FILE_REQUEST_CODE);
-
-                return /*super.onShowFileChooser(webView, filePathCallback, fileChooserParams)*/true;
-            }
-
-            //For Android 4.1
-            public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
-                mUploadMessage = uploadMsg;
-                Intent i = new Intent(Intent.ACTION_GET_CONTENT);
-                i.addCategory(Intent.CATEGORY_OPENABLE);
-                i.setType("image/*");
-                ActWeb.this.startActivityForResult(Intent.createChooser(i, "Image Chooser"), FILECHOOSER_RESULTCODE);
-
-            }
-
-            @Override
-            public void onProgressChanged(WebView view, int newProgress) {
-                LogUtil.println("ActWeb", "onProgressChanged", newProgress);
-                if (newProgress == 100 && ViewUtil.isVisible(act_web_loading_iv)) {
-                    Animation animation = AnimationUtils.loadAnimation(SheepApp.getInstance(), R.anim.anim_alpha_1_0);
-                    animation.setAnimationListener(new Animation.AnimationListener() {
-                        @Override
-                        public void onAnimationStart(Animation animation) {
-
-                        }
-
-                        @Override
-                        public void onAnimationEnd(Animation animation) {
-                            ViewUtil.setVisibility(act_web_loading_iv, false);
-                        }
-
-                        @Override
-                        public void onAnimationRepeat(Animation animation) {
-
-                        }
-                    });
-                    act_web_loading_iv.startAnimation(animation);
-                }
-                ViewUtil.setVisibility(act_web_loading_pb, newProgress != 100);
-                if (act_web_loading_pb != null)
-                    act_web_loading_pb.setProgress(newProgress);
-                super.onProgressChanged(view, newProgress);
-            }
-        });
-        mWebView.setWebViewClient(new WebViewClient() {
-//            @Override
-//            public WebResourceResponse shouldInterceptRequest(WebView webView, String s) {
-//                if(TestUtil.isDev()){
-//                    return super.shouldInterceptRequest(webView, s);
-//                }
-//                if (s.contains("ssnocache=1")) return null;
-//                LogUtil.println("ActWeb", "shouldInterceptRequest from cache", url);
-//                return WebResourceResponseAdapter.adapter(WebViewCacheInterceptorInst.getInstance().interceptRequest(s));
-//            }
-//
-//            @Override
-//            public WebResourceResponse shouldInterceptRequest(WebView webView, WebResourceRequest webResourceRequest) {
-//                if(TestUtil.isDev()){
-//                    return super.shouldInterceptRequest(webView, webResourceRequest);
-//                }
-//                if (url.contains("ssnocache=1")) return null;
-//                LogUtil.println("ActWeb", "shouldInterceptRequest from cache", url);
-//                return WebResourceResponseAdapter.adapter(WebViewCacheInterceptorInst.getInstance().interceptRequest(WebResourceRequestAdapter.adapter(webResourceRequest)));
-//            }
-
-            @Override
-            public boolean shouldOverrideUrlLoading(WebView view, String url) {
-                LogUtil.println("ActWeb", "shouldOverrideUrlLoading", url);
-                //微信H5支付核心代码
-                if (url.startsWith(Config.SHEEP_PAY)) {
-                    String order_no = StringUtils.getQueryParameter(url, Config.YF_SHOP_ORDER_NUMBER_KEY);
-                    Jump2View.getInstance().goActPay(ActWeb.this, order_no, SpUtils.getToken(SheepApp.getInstance()));
-                    return true;
-                } else if (url.startsWith(Config.SHEEP)) {
-                    MiddleSchemeAct.parseAndJumpUri(ActWeb.this, Uri.parse(url));
-                    return true;
-                } else if (url.startsWith("weixin://wap/pay?")) {
-                    try {
-                        Intent intent = new Intent();
-                        intent.setAction(Intent.ACTION_VIEW);
-                        intent.setData(Uri.parse(url));
-                        startActivity(intent);
-                    } catch (Exception e) {
-                        e.printStackTrace();
-                    }
-                    return true;
-                } else if (url.startsWith("alipays:") || url.startsWith("alipay")) {
-                    try {
-                        startActivity(new Intent("android.intent.action.VIEW", Uri.parse(url)));
-                    } catch (Exception e) {
-                        new AlertDialog.Builder(ActWeb.this)
-                                .setMessage("未检测到支付宝客户端,请安装后重试。")
-                                .setPositiveButton("立即安装", new DialogInterface.OnClickListener() {
-
-                                    @Override
-                                    public void onClick(DialogInterface dialog, int which) {
-                                        Uri alipayUrl = Uri.parse("https://d.alipay.com");
-                                        startActivity(new Intent("android.intent.action.VIEW", alipayUrl));
-                                    }
-                                }).setNegativeButton("取消", null).show();
-                    }
-                    return true;
-                } else if (url.startsWith("https://wx.tenpay.com")) {
-                    Map<String, String> extraHeaders = new HashMap<>();
-                    extraHeaders.put("Referer", "http://17xmy.com");
-                    webViewLoadUrl(view, extraHeaders, url);
-                    return true;
-                } else if (url.contains("kfzs.com") || (url.startsWith("http://10.8.") && TestUtil.isDev())) {
-                    Map<String, String> extraHeaders = new HashMap<>();
-                    extraHeaders.put("Referer", "http://kfzs.com");
-                    webViewLoadUrl(view, extraHeaders, url);
-                    return true;
-                } else {
-                    return false;
-                }
-            }
-
-            @Override
-            public void onPageStarted(WebView view, String url, Bitmap favicon) {
-                LogUtil.println("ActWeb", "onPageStarted", url);
-                super.onPageStarted(view, url, favicon);
-            }
-
-            @Override
-            public void onPageFinished(WebView view, String url) {
-                LogUtil.println("ActWeb", "onPageFinished", url);
-                super.onPageFinished(view, url);
-                loadJs();
-            }
-        });
-
-        if (webParams.isNeedJsInteract()) {
-            mWebView.addJavascriptInterface(new KFZSJs(this), "kfzsjs");
-            String loadUrl = url;
-            if (webParams.getTokenKey() != null) {
-                if (url.startsWith(Config.YF_SHOP_HOME)) {
-                    webParams.tokenFirstUpperCase();
-                }
-                loadUrl = addUrlQuery(url, webParams.getTokenKey(), SpUtils.getToken(SheepApp.getInstance()));
-                loadUrl = addUrlQuery(loadUrl, "pf", Config.YF_SHOP_PLATFORM);
-                loadUrl = addUrlQuery(loadUrl, "device_id", DeviceUtil.getDeviceId(SheepApp.getInstance()));
-            }
-            loadUrl = addUrlQuery(loadUrl, webParams.getInvitationCodeKey(), DataUtil.getInstance().getInvitationCode());
-            LogUtil.println("ActWeb loadUrl = " + loadUrl);
-            webViewLoadUrl(mWebView, loadUrl);
-        } else {
-            webViewLoadUrl(mWebView, url);
-        }
-    }
-
-    //在sdcard卡创建缩略图
-    //createImageFileInSdcard
-    @SuppressLint("SdCardPath")
-    private File createImageFile() {
-        //mCameraPhotoPath="/mnt/sdcard/tmp.png";
-        File file = new File(Environment.getExternalStorageDirectory() + "/", "tmp.png");
-        mCameraPhotoPath = file.getAbsolutePath();
-        if (!file.exists()) {
-            try {
-                file.createNewFile();
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-        return file;
-    }
-
-    /**
-     * 是否响应返回键
-     */
-    private boolean responseBack = true;
-
-    @Override
-    public void onBackPressed() {
-        if (responseBack) {
-            if (mWebView != null && mWebView.canGoBack()) {
-                mWebView.goBack();
-
-            } else {
-                super.onBackPressed();
-            }
-        } else {
-            loadJs("onBackPressed()");
-        }
-    }
-
-    @Override
-    public void loadJs(String js) {
-        ViewUtil.loadJs(mWebView, js);
-    }
-
-    private int onResumeCount = 0;
-    @Override
-    protected void onResume() {
-        super.onResume();
-        if(onResumeCount > 0 && mWebView != null && webParams.isRefreshClick()){
-            loadJs("refreshClick()");
-        }
-        onResumeCount ++;
-    }
-
-    @Override
-    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
-        if (requestCode == FILECHOOSER_RESULTCODE) {
-            if (null == mUploadMessage) return;
-            Uri result = data == null || resultCode != RESULT_OK ? null
-                    : data.getData();
-            if (result != null) {
-                String imagePath = FileUtils.getPath(this, result);
-                if (!TextUtils.isEmpty(imagePath)) {
-                    result = Uri.parse("file:///" + imagePath);
-                }
-            }
-            mUploadMessage.onReceiveValue(result);
-            mUploadMessage = null;
-        } else if (requestCode == INPUT_FILE_REQUEST_CODE && mFilePathCallback != null) {
-            // 5.0的回调
-            Uri[] results = null;
-
-            // Check that the response is a good one
-            if (resultCode == Activity.RESULT_OK) {
-                if (data == null) {
-                    // If there is not data, then we may have taken a photo
-                    if (mCameraPhotoPath != null) {
-                        results = new Uri[]{Uri.parse(mCameraPhotoPath)};
-                    }
-                } else {
-                    String dataString = data.getDataString();
-                    if (dataString != null) {
-                        results = new Uri[]{Uri.parse(dataString)};
-                    }
-                }
-            }
-
-            mFilePathCallback.onReceiveValue(results);
-            mFilePathCallback = null;
-        } else if (Constant.INTENT_RECHARGE == requestCode) {
-            mWebView.reload();
-        } else {
-            super.onActivityResult(requestCode, resultCode, data);
-            return;
-        }
-    }
-
-    // 注入js函数监听
-    public void loadJs() {
-        if (TextUtils.isEmpty(js))
-            return;
-        ViewUtil.loadJs(mWebView, getJs());
-        LogUtil.println("ActWeb", "loadJs", js);
-    }
-
-    private String js;
-
-    private String getJs() {
-        String testJsStart = "alert('成功注入');";
-        return BuildConfig.DEBUG ? testJsStart + "\n" + js : js;
-    }
-
-    @Override
-    public boolean isResponseBack() {
-        return responseBack;
-    }
-
-    @Override
-    public void setResponseBack(boolean responseBack) {
-        this.responseBack = responseBack;
-    }
-
-    @Override
-    public void clearWebView() {
-        mWebView = null;
-    }
-
-    @Override
-    public void showTitleBar(boolean isShow) {
-        ActionBar actionBar = getSupportActionBar();
-        if (actionBar != null)
-            actionBar.hide();
-    }
-
-    @Override
-    public void setNonTouchArea(float height) {
-
-    }
-
-}

+ 17 - 488
app/src/main/java/com/sheep/gamegroup/view/activity/ActWebX5.java

@@ -12,6 +12,7 @@ import android.os.Environment;
 import android.provider.MediaStore;
 import android.support.annotation.Nullable;
 import android.support.annotation.RequiresApi;
+import android.support.v4.app.Fragment;
 import android.support.v7.app.ActionBar;
 import android.support.v7.app.AlertDialog;
 import android.text.TextUtils;
@@ -21,7 +22,10 @@ import android.view.animation.AnimationUtils;
 import android.widget.ImageView;
 import android.widget.ProgressBar;
 
+import com.sheep.gamegroup.absBase.BaseContainerActivity;
 import com.sheep.gamegroup.model.entity.WebParams;
+import com.sheep.gamegroup.module.webview.fragment.FgtWeb;
+import com.sheep.gamegroup.module.webview.fragment.FgtWebX5;
 import com.sheep.gamegroup.module.webview.util.WebResourceRequestAdapter;
 import com.sheep.gamegroup.module.webview.util.WebResourceResponseAdapter;
 import com.sheep.gamegroup.util.CommonUtil;
@@ -41,9 +45,11 @@ import com.sheep.jiuyan.samllsheep.BuildConfig;
 import com.sheep.jiuyan.samllsheep.Config;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
+import com.sheep.jiuyan.samllsheep.base.BaseFragment;
 import com.sheep.jiuyan.samllsheep.utils.G;
 import com.sheep.jiuyan.samllsheep.utils.SpUtils;
 import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
+import com.snail.antifake.jni.EmulatorDetectUtil;
 import com.tencent.smtt.export.external.interfaces.WebResourceRequest;
 import com.tencent.smtt.export.external.interfaces.WebResourceResponse;
 import com.tencent.smtt.sdk.ValueCallback;
@@ -69,76 +75,21 @@ import ren.yale.android.cachewebviewlib.WebViewCacheInterceptorInst;
  * web页面--含有所有js及url后添加authorization
  * Created by zengjiebin on 2018/4/27.
  */
-public class ActWebX5 extends BaseActWebX5 {
+public class ActWebX5 extends BaseContainerActivity {
 
-    @BindView(R.id.webview)
-    WebView mWebView;
-    @BindView(R.id.act_web_loading_pb)
-    ProgressBar act_web_loading_pb;
-    @BindView(R.id.act_web_loading_iv)
-    ImageView act_web_loading_iv;
     protected WebParams webParams;
 
-    @Override
-    protected void onCreate(@Nullable Bundle savedInstanceState) {
-        initWebParams();
-        super.onCreate(savedInstanceState);
-    }
-
-    @Override
-    protected int getTitleLayoutId() {
-        if(checkWebParams(webParams)){
-            return R.layout.title_yf;
-        }
-        return super.getTitleLayoutId();
-    }
-
-    @Override
-    protected int getLayoutId() {
-        return R.layout.act_web_x5;
-    }
+    private BaseFragment fragment;
 
-    @RequiresApi(api = Build.VERSION_CODES.KITKAT)
     @Override
-    public void initView() {
-        ViewUtil.setImage(act_web_loading_iv, R.drawable.gif_sheep_loading);
-
-        String url = webParams.getUrl();
-        String jsUrl = webParams.getJsUrl();
-        if (!TextUtils.isEmpty(url)) {
-            url = url.trim();
-        }
-        if(checkWebParams(webParams)){
-            TitleBarUtils
-                    .getInstance()
-                    .setShowOrHide(this, true)
-                    .setTitle(this, webParams.getTitle())
-                    .setRightSecondBtn(this, R.mipmap.tianjtb, view -> SysAppUtil.addShortcut(this))
-                    .setRightImgBotton(this, R.mipmap.guanb, view -> super.finish())
-                    .setTitleFinish(this);
-        } else if (webParams.isShowTitle()) {
-            TitleBarUtils
-                    .getInstance()
-                    .setShowOrHide(this, true)
-                    .setTitle(this, webParams.getTitle())
-                    .setRightImgBotton(this, R.drawable.ic_edit_text_delete, view -> super.finish())
-                    .setTitleFinish(this);
-        }
-        initWebViewSettings(mWebView);
-        try {
-            if (TestUtil.isTest())
-                WebView.setWebContentsDebuggingEnabled(true);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
-//            webViewSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
-        }
-        if (TextUtils.isEmpty(jsUrl)) {
-            loadUrl(url);
+    protected Fragment initFragment() {
+        initWebParams();
+        if (EmulatorDetectUtil.isEmulator()) {
+            fragment = FgtWeb.newInstance(webParams);
         } else {
-            initJsData(url, jsUrl);
+            fragment = FgtWebX5.newInstance(webParams);
         }
+        return fragment;
     }
 
     public void initWebParams() {
@@ -146,447 +97,25 @@ public class ActWebX5 extends BaseActWebX5 {
         webParams = (WebParams) intent.getSerializableExtra(WebParams.class.getSimpleName());
     }
 
-//    //忽略 添加有范商城快捷入口
-//    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])) {//检测是否是有范商城地址
-//            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();//未忽略并且没有添加有范商品入口
-////            boolean isShow = !isIgnore && !SysAppUtil.isEnableComponentYf();
-//            if (isShow) {
-//                ViewUtil.showMsgDialog(this, new DialogConfig().setTitle("温馨提示")
-//                        .setMsg("亲,喜欢的话,就添加一个商城的桌面快捷入口吧!(点击否将不再提示)")
-//                        .setBtnLeftText("否").setBtnLeftOnClickListener(view -> SpUtils.putAsBoolean(KEY_IGNORE_ADD_YOU_FAN_LAUNCHER, true))
-//                        .setBtnRightText("是").setBtnRightOnClickListener(view -> CommonUtil.getInstance().addYouFanLauncher()));
-////                        .setBtnRightText("是").setBtnRightOnClickListener(view -> SysAppUtil.enableComponentYf()));
-//            }
-//        }
-//    }
-    private boolean checkWebParams(WebParams webParams) {
-        return webParams.getUrl().startsWith(Config.YF_SHOP_HOME_SHEEP.split("\\?")[0]) || webParams.getUrl().startsWith(Config.YF_SHOP_HOME_SHEEP_TEST.split("\\?")[0]);//检测是否是有范商城地址
-    }
-
-    //初始化js代码数据
-    private void initJsData(final String url, String jsUrl) {
-        OkHttpUtils.get()
-                .url(jsUrl)
-                .build()
-                .execute(new StringCallback() {
-                    @Override
-                    public void onError(Call call, Exception e, int id) {
-                        G.showToast(R.string.service_data_error);
-                    }
-
-                    @Override
-                    public void onResponse(String response, int id) {
-                        js = response;
-                        loadUrl(url);
-                    }
-                });
-    }
-
-    @Override
-    public void initListener() {
-        CommonUtil.getInstance().setDownloadListener(this, mWebView);
-    }
-
-    public static void initWebViewSettings(WebView webView) {
-        webView.setClickable(true);
-        WebSettings webSetting = webView.getSettings();
-        webSetting.setJavaScriptEnabled(true);
-        webSetting.setJavaScriptCanOpenWindowsAutomatically(true);
-        webSetting.setAllowFileAccess(true);
-        webSetting.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
-//        webSetting.setSupportZoom(true);
-//        webSetting.setBuiltInZoomControls(true);
-        webSetting.setUseWideViewPort(true);
-        webSetting.setSupportMultipleWindows(true);
-        // webSetting.setLoadWithOverviewMode(true);
-        webSetting.setAppCacheEnabled(true);
-        // webSetting.setDatabaseEnabled(true);
-        webSetting.setDomStorageEnabled(true);
-        webSetting.setGeolocationEnabled(true);
-        webSetting.setAppCacheMaxSize(Long.MAX_VALUE);
-        // webSetting.setPageCacheCapacity(IX5WebSettings.DEFAULT_CACHE_CAPACITY);
-        webSetting.setPluginState(WebSettings.PluginState.ON_DEMAND);
-        // webSetting.setRenderPriority(WebSettings.RenderPriority.HIGH);
-        webSetting.setCacheMode(NetUtil.CAN_CONNECT_SERVICE ? WebSettings.LOAD_DEFAULT : WebSettings.LOAD_CACHE_ELSE_NETWORK);
-
-        // this.getSettingsExtension().setPageCacheCapacity(IX5WebSettings.DEFAULT_CACHE_CAPACITY);//extension
-        // settings 的设计
-        webSetting.setUserAgentString(getSheepUserAgent());
-    }
-
     @Override
     protected void onDestroy() {
-        if (act_web_loading_iv != null) {
-            try {
-                act_web_loading_iv.clearAnimation();
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-        }
-        if (mWebView != null) {
-            mWebView.setVisibility(View.GONE);
-            mWebView.removeAllViews();
-            mWebView.destroy();
-        }
         super.onDestroy();
     }
 
-    /**
-     *
-     */
-    public static final int INPUT_FILE_REQUEST_CODE = 1;
-    private ValueCallback<Uri> mUploadMessage;
-    private final static int FILECHOOSER_RESULTCODE = 2;
-    private ValueCallback<Uri[]> mFilePathCallback;
-
-    private String mCameraPhotoPath;
-
-    private void loadUrl(final String url) {
-
-        mWebView.setWebChromeClient(new WebChromeClient() {
-            @Override
-            public void onReceivedTitle(WebView view, String title) {
-                super.onReceivedTitle(view, title);
-                if (webParams.isShowTitle())
-                    TitleBarUtils
-                            .getInstance()
-                            .setTitle(ActWebX5.this, title);
-            }
-
-            @Override
-            public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) {
-                if (mFilePathCallback != null) {
-                    mFilePathCallback.onReceiveValue(null);
-                }
-                mFilePathCallback = filePathCallback;
-
-                /*PhotoPicker.builder()
-                        .setPhotoCount(1)
-                        .setShowCamera(true)
-                        .setShowGif(false)
-                        .setPreviewEnabled(true)
-                        .start(ActWeb.this, PhotoPicker.REQUEST_CODE);*/
-                Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
-                if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
-                    // Create the File where the photo should go
-                    File photoFile;
-                    photoFile = createImageFile();
-                    takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath);
-
-                    // Continue only if the File was successfully created
-                    if (photoFile != null) {
-                        mCameraPhotoPath = "file:" + photoFile.getAbsolutePath();
-                        takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
-                                Uri.fromFile(photoFile));
-                    } else {
-                    }
-                }
-
-                Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
-                contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
-                contentSelectionIntent.setType("image/*");
-
-                Intent[] intentArray;
-                takePictureIntent = null;//步调用相机
-                if (takePictureIntent != null) {
-                    intentArray = new Intent[]{takePictureIntent};
-                } else {
-                    intentArray = new Intent[0];
-                }
-
-                Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
-                chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
-                chooserIntent.putExtra(Intent.EXTRA_TITLE, "图片选择");
-                chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);
-
-                startActivityForResult(chooserIntent, INPUT_FILE_REQUEST_CODE);
-
-                return /*super.onShowFileChooser(webView, filePathCallback, fileChooserParams)*/true;
-            }
-
-            //For Android 4.1
-            public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
-                mUploadMessage = uploadMsg;
-                Intent i = new Intent(Intent.ACTION_GET_CONTENT);
-                i.addCategory(Intent.CATEGORY_OPENABLE);
-                i.setType("image/*");
-                ActWebX5.this.startActivityForResult(Intent.createChooser(i, "Image Chooser"), FILECHOOSER_RESULTCODE);
-
-            }
-
-            @Override
-            public void onProgressChanged(WebView view, int newProgress) {
-                LogUtil.println("ActWeb", "onProgressChanged", newProgress);
-                if (newProgress == 100 && ViewUtil.isVisible(act_web_loading_iv)) {
-                    Animation animation = AnimationUtils.loadAnimation(SheepApp.getInstance(), R.anim.anim_alpha_1_0);
-                    animation.setAnimationListener(new Animation.AnimationListener() {
-                        @Override
-                        public void onAnimationStart(Animation animation) {
-
-                        }
-
-                        @Override
-                        public void onAnimationEnd(Animation animation) {
-                            ViewUtil.setVisibility(act_web_loading_iv, false);
-                        }
-
-                        @Override
-                        public void onAnimationRepeat(Animation animation) {
-
-                        }
-                    });
-                    act_web_loading_iv.startAnimation(animation);
-                }
-                ViewUtil.setVisibility(act_web_loading_pb, newProgress != 100);
-                if (act_web_loading_pb != null)
-                    act_web_loading_pb.setProgress(newProgress);
-                super.onProgressChanged(view, newProgress);
-            }
-        });
-        mWebView.setWebViewClient(new WebViewClient() {
-            @Override
-            public WebResourceResponse shouldInterceptRequest(WebView webView, String s) {
-                if(TestUtil.isDev()){
-                    return super.shouldInterceptRequest(webView, s);
-                }
-                if (s.contains("ssnocache=1")) return null;
-                LogUtil.println("ActWeb", "shouldInterceptRequest from cache", url);
-                return WebResourceResponseAdapter.adapter(WebViewCacheInterceptorInst.getInstance().interceptRequest(s));
-            }
-
-            @Override
-            public WebResourceResponse shouldInterceptRequest(WebView webView, WebResourceRequest webResourceRequest) {
-                if(TestUtil.isDev()){
-                    return super.shouldInterceptRequest(webView, webResourceRequest);
-                }
-                if (url.contains("ssnocache=1")) return null;
-                LogUtil.println("ActWeb", "shouldInterceptRequest from cache", url);
-                return WebResourceResponseAdapter.adapter(WebViewCacheInterceptorInst.getInstance().interceptRequest(WebResourceRequestAdapter.adapter(webResourceRequest)));
-            }
-
-            @Override
-            public boolean shouldOverrideUrlLoading(WebView view, String url) {
-                LogUtil.println("ActWeb", "shouldOverrideUrlLoading", url);
-                //微信H5支付核心代码
-                if (url.startsWith(Config.SHEEP_PAY)) {
-                    String order_no = StringUtils.getQueryParameter(url, Config.YF_SHOP_ORDER_NUMBER_KEY);
-                    Jump2View.getInstance().goActPay(ActWebX5.this, order_no, SpUtils.getToken(SheepApp.getInstance()));
-                    return true;
-                } else if (url.startsWith(Config.SHEEP)) {
-                    MiddleSchemeAct.parseAndJumpUri(ActWebX5.this, Uri.parse(url));
-                    return true;
-                } else if (url.startsWith("weixin://wap/pay?")) {
-                    try {
-                        Intent intent = new Intent();
-                        intent.setAction(Intent.ACTION_VIEW);
-                        intent.setData(Uri.parse(url));
-                        startActivity(intent);
-                    } catch (Exception e) {
-                        e.printStackTrace();
-                    }
-                    return true;
-                } else if (url.startsWith("alipays:") || url.startsWith("alipay")) {
-                    try {
-                        startActivity(new Intent("android.intent.action.VIEW", Uri.parse(url)));
-                    } catch (Exception e) {
-                        new AlertDialog.Builder(ActWebX5.this)
-                                .setMessage("未检测到支付宝客户端,请安装后重试。")
-                                .setPositiveButton("立即安装", new DialogInterface.OnClickListener() {
-
-                                    @Override
-                                    public void onClick(DialogInterface dialog, int which) {
-                                        Uri alipayUrl = Uri.parse("https://d.alipay.com");
-                                        startActivity(new Intent("android.intent.action.VIEW", alipayUrl));
-                                    }
-                                }).setNegativeButton("取消", null).show();
-                    }
-                    return true;
-                } else if (url.startsWith("https://wx.tenpay.com")) {
-                    Map<String, String> extraHeaders = new HashMap<>();
-                    extraHeaders.put("Referer", "http://17xmy.com");
-                    webViewLoadUrl(view, extraHeaders, url);
-                    return true;
-                } else if (url.contains("kfzs.com") || (url.startsWith("http://10.8.") && TestUtil.isDev())) {
-                    Map<String, String> extraHeaders = new HashMap<>();
-                    extraHeaders.put("Referer", "http://kfzs.com");
-                    webViewLoadUrl(view, extraHeaders, url);
-                    return true;
-                } else {
-                    return false;
-                }
-            }
-
-            @Override
-            public void onPageStarted(WebView view, String url, Bitmap favicon) {
-                LogUtil.println("ActWeb", "onPageStarted", url);
-                super.onPageStarted(view, url, favicon);
-            }
-
-            @Override
-            public void onPageFinished(WebView view, String url) {
-                LogUtil.println("ActWeb", "onPageFinished", url);
-                super.onPageFinished(view, url);
-                loadJs();
-            }
-        });
-
-        if (webParams.isNeedJsInteract()) {
-            mWebView.addJavascriptInterface(new KFZSJs(this), "kfzsjs");
-            String loadUrl = url;
-            if (webParams.getTokenKey() != null) {
-                if (url.startsWith(Config.YF_SHOP_HOME)) {
-                    webParams.tokenFirstUpperCase();
-                }
-                loadUrl = addUrlQuery(url, webParams.getTokenKey(), SpUtils.getToken(SheepApp.getInstance()));
-                loadUrl = addUrlQuery(loadUrl, "pf", Config.YF_SHOP_PLATFORM);
-                loadUrl = addUrlQuery(loadUrl, "device_id", DeviceUtil.getDeviceId(SheepApp.getInstance()));
-            }
-            loadUrl = addUrlQuery(loadUrl, webParams.getInvitationCodeKey(), DataUtil.getInstance().getInvitationCode());
-            LogUtil.println("ActWeb loadUrl = " + loadUrl);
-            webViewLoadUrl(mWebView, loadUrl);
-        } else {
-            webViewLoadUrl(mWebView, url);
-        }
-    }
-
-    //在sdcard卡创建缩略图
-    //createImageFileInSdcard
-    @SuppressLint("SdCardPath")
-    private File createImageFile() {
-        //mCameraPhotoPath="/mnt/sdcard/tmp.png";
-        File file = new File(Environment.getExternalStorageDirectory() + "/", "tmp.png");
-        mCameraPhotoPath = file.getAbsolutePath();
-        if (!file.exists()) {
-            try {
-                file.createNewFile();
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-        return file;
-    }
-
-    /**
-     * 是否响应返回键
-     */
-    private boolean responseBack = true;
-
     @Override
     public void onBackPressed() {
-        if (responseBack) {
-            if (mWebView != null && mWebView.canGoBack()) {
-                mWebView.goBack();
-
-            } else {
-                super.onBackPressed();
-            }
-        } else {
-            loadJs("onBackPressed()");
-        }
+        fragment.onBackPressed();
     }
 
     @Override
-    public void loadJs(String js) {
-        ViewUtil.loadJs(mWebView, js);
-    }
-
-    private int onResumeCount = 0;
-    @Override
     protected void onResume() {
         super.onResume();
-        if(onResumeCount > 0 && mWebView != null && webParams.isRefreshClick()){
-            loadJs("refreshClick()");
-        }
-        onResumeCount ++;
     }
 
     @Override
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
-        if (requestCode == FILECHOOSER_RESULTCODE) {
-            if (null == mUploadMessage) return;
-            Uri result = data == null || resultCode != RESULT_OK ? null
-                    : data.getData();
-            if (result != null) {
-                String imagePath = FileUtils.getPath(this, result);
-                if (!TextUtils.isEmpty(imagePath)) {
-                    result = Uri.parse("file:///" + imagePath);
-                }
-            }
-            mUploadMessage.onReceiveValue(result);
-            mUploadMessage = null;
-        } else if (requestCode == INPUT_FILE_REQUEST_CODE && mFilePathCallback != null) {
-            // 5.0的回调
-            Uri[] results = null;
-
-            // Check that the response is a good one
-            if (resultCode == Activity.RESULT_OK) {
-                if (data == null) {
-                    // If there is not data, then we may have taken a photo
-                    if (mCameraPhotoPath != null) {
-                        results = new Uri[]{Uri.parse(mCameraPhotoPath)};
-                    }
-                } else {
-                    String dataString = data.getDataString();
-                    if (dataString != null) {
-                        results = new Uri[]{Uri.parse(dataString)};
-                    }
-                }
-            }
-
-            mFilePathCallback.onReceiveValue(results);
-            mFilePathCallback = null;
-        } else if (Constant.INTENT_RECHARGE == requestCode) {
-            mWebView.reload();
-        } else {
-            super.onActivityResult(requestCode, resultCode, data);
-            return;
-        }
-    }
-
-    // 注入js函数监听
-    public void loadJs() {
-        if (TextUtils.isEmpty(js))
-            return;
-        ViewUtil.loadJs(mWebView, getJs());
-        LogUtil.println("ActWeb", "loadJs", js);
-    }
-
-    private String js;
-
-    private String getJs() {
-        String testJsStart = "alert('成功注入');";
-        return BuildConfig.DEBUG ? testJsStart + "\n" + js : js;
-    }
-
-    @Override
-    public boolean isResponseBack() {
-        return responseBack;
-    }
-
-    @Override
-    public void setResponseBack(boolean responseBack) {
-        this.responseBack = responseBack;
-    }
-
-    @Override
-    public void clearWebView() {
-        mWebView = null;
-    }
-
-    @Override
-    public void showTitleBar(boolean isShow) {
-        ActionBar actionBar = getSupportActionBar();
-        if (actionBar != null)
-            actionBar.hide();
-    }
-
-    @Override
-    public void setNonTouchArea(float height) {
-
+        super.onActivityResult(requestCode, resultCode, data);
+        fragment.onActivityResult(requestCode, resultCode, data);
     }
 
 }