瀏覽代碼

Merge branch 'sheep_develop' of 10.8.230.114:xmy_android/small_sheep_android into sheep_develop

hanjing 7 年之前
父節點
當前提交
24fa1f544f

+ 30 - 1
app/src/main/java/com/sheep/gamegroup/absBase/BaseActivity.java

@@ -18,11 +18,13 @@ import com.r0adkll.slidr.Slidr;
 import com.r0adkll.slidr.model.SlidrConfig;
 import com.r0adkll.slidr.model.SlidrListener;
 import com.r0adkll.slidr.model.SlidrPosition;
+import com.sheep.gamegroup.model.api.BackHandleInterface;
 import com.sheep.gamegroup.util.ActionUtil;
 import com.sheep.gamegroup.util.LogUtil;
 import com.sheep.gamegroup.util.TestUtil;
 import com.sheep.gamegroup.view.dialog.DialogLoading;
 import com.sheep.jiuyan.samllsheep.R;
+import com.sheep.jiuyan.samllsheep.base.BaseFragment;
 import com.trello.rxlifecycle2.components.support.RxAppCompatActivity;
 
 import org.greenrobot.eventbus.EventBus;
@@ -41,7 +43,7 @@ import io.reactivex.schedulers.Schedulers;
  * Created by kemllor on 2017/12/15.
  */
 
-public abstract class BaseActivity extends RxAppCompatActivity {
+public abstract class BaseActivity extends RxAppCompatActivity implements BackHandleInterface {
 
     protected DialogLoading dialogLoading;
     public Unbinder unbinder;
@@ -361,4 +363,31 @@ public abstract class BaseActivity extends RxAppCompatActivity {
         super.setRequestedOrientation(requestedOrientation);
     }
 
+
+    private BaseFragment backHandleFragment;
+
+    @Override
+    public void onSelectedFragment(BaseFragment backHandleFragment) {
+        this.backHandleFragment = backHandleFragment;
+    }
+
+    @Override
+    public void onBackPressed() {
+        if(checkBackPressed()){
+            super.onBackPressed();
+        }
+    }
+
+    public boolean checkBackPressed() {
+        //if判断里面就调用了来自Fragment的onBackPressed()
+        //一样!!,如果onBackPressed是返回false,就会进入条件内进行默认的操作
+        if(backHandleFragment == null || !backHandleFragment.onBackPressed()){
+            if(getSupportFragmentManager().getBackStackEntryCount() == 0){
+                return true;
+            }else{
+                getSupportFragmentManager().popBackStack();
+            }
+        }
+        return false;
+    }
 }

+ 15 - 15
app/src/main/java/com/sheep/gamegroup/greendao/download/DaoMaster.java

@@ -21,26 +21,26 @@ public class DaoMaster extends AbstractDaoMaster {
 
     /** Creates underlying database table using DAOs. */
     public static void createAllTables(Database db, boolean ifNotExists) {
-        ProcessRecordDao.createTable(db, ifNotExists);
-        AppdownloadBeanDao.createTable(db, ifNotExists);
-        SdkLoginUserDao.createTable(db, ifNotExists);
-        ScreenShotRecordDao.createTable(db, ifNotExists);
         AcceptTaskRecordDao.createTable(db, ifNotExists);
         AccountDao.createTable(db, ifNotExists);
-        SearchRecordDao.createTable(db, ifNotExists);
+        AppdownloadBeanDao.createTable(db, ifNotExists);
         DownLoadInfoDao.createTable(db, ifNotExists);
+        ProcessRecordDao.createTable(db, ifNotExists);
+        ScreenShotRecordDao.createTable(db, ifNotExists);
+        SdkLoginUserDao.createTable(db, ifNotExists);
+        SearchRecordDao.createTable(db, ifNotExists);
     }
 
     /** Drops underlying database table using DAOs. */
     public static void dropAllTables(Database db, boolean ifExists) {
-        ProcessRecordDao.dropTable(db, ifExists);
-        AppdownloadBeanDao.dropTable(db, ifExists);
-        SdkLoginUserDao.dropTable(db, ifExists);
-        ScreenShotRecordDao.dropTable(db, ifExists);
         AcceptTaskRecordDao.dropTable(db, ifExists);
         AccountDao.dropTable(db, ifExists);
-        SearchRecordDao.dropTable(db, ifExists);
+        AppdownloadBeanDao.dropTable(db, ifExists);
         DownLoadInfoDao.dropTable(db, ifExists);
+        ProcessRecordDao.dropTable(db, ifExists);
+        ScreenShotRecordDao.dropTable(db, ifExists);
+        SdkLoginUserDao.dropTable(db, ifExists);
+        SearchRecordDao.dropTable(db, ifExists);
     }
 
     /**
@@ -59,14 +59,14 @@ public class DaoMaster extends AbstractDaoMaster {
 
     public DaoMaster(Database db) {
         super(db, SCHEMA_VERSION);
-        registerDaoClass(ProcessRecordDao.class);
-        registerDaoClass(AppdownloadBeanDao.class);
-        registerDaoClass(SdkLoginUserDao.class);
-        registerDaoClass(ScreenShotRecordDao.class);
         registerDaoClass(AcceptTaskRecordDao.class);
         registerDaoClass(AccountDao.class);
-        registerDaoClass(SearchRecordDao.class);
+        registerDaoClass(AppdownloadBeanDao.class);
         registerDaoClass(DownLoadInfoDao.class);
+        registerDaoClass(ProcessRecordDao.class);
+        registerDaoClass(ScreenShotRecordDao.class);
+        registerDaoClass(SdkLoginUserDao.class);
+        registerDaoClass(SearchRecordDao.class);
     }
 
     public DaoSession newSession() {

+ 61 - 61
app/src/main/java/com/sheep/gamegroup/greendao/download/DaoSession.java

@@ -8,23 +8,23 @@ import org.greenrobot.greendao.database.Database;
 import org.greenrobot.greendao.identityscope.IdentityScopeType;
 import org.greenrobot.greendao.internal.DaoConfig;
 
-import com.sheep.gamegroup.greendao.download.ProcessRecord;
-import com.sheep.gamegroup.greendao.download.AppdownloadBean;
-import com.sheep.gamegroup.greendao.download.SdkLoginUser;
-import com.sheep.gamegroup.greendao.download.ScreenShotRecord;
 import com.sheep.gamegroup.greendao.download.AcceptTaskRecord;
 import com.sheep.gamegroup.greendao.download.Account;
-import com.sheep.gamegroup.greendao.download.SearchRecord;
+import com.sheep.gamegroup.greendao.download.AppdownloadBean;
 import com.sheep.gamegroup.greendao.download.DownLoadInfo;
+import com.sheep.gamegroup.greendao.download.ProcessRecord;
+import com.sheep.gamegroup.greendao.download.ScreenShotRecord;
+import com.sheep.gamegroup.greendao.download.SdkLoginUser;
+import com.sheep.gamegroup.greendao.download.SearchRecord;
 
-import com.sheep.gamegroup.greendao.download.ProcessRecordDao;
-import com.sheep.gamegroup.greendao.download.AppdownloadBeanDao;
-import com.sheep.gamegroup.greendao.download.SdkLoginUserDao;
-import com.sheep.gamegroup.greendao.download.ScreenShotRecordDao;
 import com.sheep.gamegroup.greendao.download.AcceptTaskRecordDao;
 import com.sheep.gamegroup.greendao.download.AccountDao;
-import com.sheep.gamegroup.greendao.download.SearchRecordDao;
+import com.sheep.gamegroup.greendao.download.AppdownloadBeanDao;
 import com.sheep.gamegroup.greendao.download.DownLoadInfoDao;
+import com.sheep.gamegroup.greendao.download.ProcessRecordDao;
+import com.sheep.gamegroup.greendao.download.ScreenShotRecordDao;
+import com.sheep.gamegroup.greendao.download.SdkLoginUserDao;
+import com.sheep.gamegroup.greendao.download.SearchRecordDao;
 
 // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
 
@@ -35,112 +35,112 @@ import com.sheep.gamegroup.greendao.download.DownLoadInfoDao;
  */
 public class DaoSession extends AbstractDaoSession {
 
-    private final DaoConfig processRecordDaoConfig;
-    private final DaoConfig appdownloadBeanDaoConfig;
-    private final DaoConfig sdkLoginUserDaoConfig;
-    private final DaoConfig screenShotRecordDaoConfig;
     private final DaoConfig acceptTaskRecordDaoConfig;
     private final DaoConfig accountDaoConfig;
-    private final DaoConfig searchRecordDaoConfig;
+    private final DaoConfig appdownloadBeanDaoConfig;
     private final DaoConfig downLoadInfoDaoConfig;
+    private final DaoConfig processRecordDaoConfig;
+    private final DaoConfig screenShotRecordDaoConfig;
+    private final DaoConfig sdkLoginUserDaoConfig;
+    private final DaoConfig searchRecordDaoConfig;
 
-    private final ProcessRecordDao processRecordDao;
-    private final AppdownloadBeanDao appdownloadBeanDao;
-    private final SdkLoginUserDao sdkLoginUserDao;
-    private final ScreenShotRecordDao screenShotRecordDao;
     private final AcceptTaskRecordDao acceptTaskRecordDao;
     private final AccountDao accountDao;
-    private final SearchRecordDao searchRecordDao;
+    private final AppdownloadBeanDao appdownloadBeanDao;
     private final DownLoadInfoDao downLoadInfoDao;
+    private final ProcessRecordDao processRecordDao;
+    private final ScreenShotRecordDao screenShotRecordDao;
+    private final SdkLoginUserDao sdkLoginUserDao;
+    private final SearchRecordDao searchRecordDao;
 
     public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig>
             daoConfigMap) {
         super(db);
 
-        processRecordDaoConfig = daoConfigMap.get(ProcessRecordDao.class).clone();
-        processRecordDaoConfig.initIdentityScope(type);
+        acceptTaskRecordDaoConfig = daoConfigMap.get(AcceptTaskRecordDao.class).clone();
+        acceptTaskRecordDaoConfig.initIdentityScope(type);
+
+        accountDaoConfig = daoConfigMap.get(AccountDao.class).clone();
+        accountDaoConfig.initIdentityScope(type);
 
         appdownloadBeanDaoConfig = daoConfigMap.get(AppdownloadBeanDao.class).clone();
         appdownloadBeanDaoConfig.initIdentityScope(type);
 
-        sdkLoginUserDaoConfig = daoConfigMap.get(SdkLoginUserDao.class).clone();
-        sdkLoginUserDaoConfig.initIdentityScope(type);
+        downLoadInfoDaoConfig = daoConfigMap.get(DownLoadInfoDao.class).clone();
+        downLoadInfoDaoConfig.initIdentityScope(type);
+
+        processRecordDaoConfig = daoConfigMap.get(ProcessRecordDao.class).clone();
+        processRecordDaoConfig.initIdentityScope(type);
 
         screenShotRecordDaoConfig = daoConfigMap.get(ScreenShotRecordDao.class).clone();
         screenShotRecordDaoConfig.initIdentityScope(type);
 
-        acceptTaskRecordDaoConfig = daoConfigMap.get(AcceptTaskRecordDao.class).clone();
-        acceptTaskRecordDaoConfig.initIdentityScope(type);
-
-        accountDaoConfig = daoConfigMap.get(AccountDao.class).clone();
-        accountDaoConfig.initIdentityScope(type);
+        sdkLoginUserDaoConfig = daoConfigMap.get(SdkLoginUserDao.class).clone();
+        sdkLoginUserDaoConfig.initIdentityScope(type);
 
         searchRecordDaoConfig = daoConfigMap.get(SearchRecordDao.class).clone();
         searchRecordDaoConfig.initIdentityScope(type);
 
-        downLoadInfoDaoConfig = daoConfigMap.get(DownLoadInfoDao.class).clone();
-        downLoadInfoDaoConfig.initIdentityScope(type);
-
-        processRecordDao = new ProcessRecordDao(processRecordDaoConfig, this);
-        appdownloadBeanDao = new AppdownloadBeanDao(appdownloadBeanDaoConfig, this);
-        sdkLoginUserDao = new SdkLoginUserDao(sdkLoginUserDaoConfig, this);
-        screenShotRecordDao = new ScreenShotRecordDao(screenShotRecordDaoConfig, this);
         acceptTaskRecordDao = new AcceptTaskRecordDao(acceptTaskRecordDaoConfig, this);
         accountDao = new AccountDao(accountDaoConfig, this);
-        searchRecordDao = new SearchRecordDao(searchRecordDaoConfig, this);
+        appdownloadBeanDao = new AppdownloadBeanDao(appdownloadBeanDaoConfig, this);
         downLoadInfoDao = new DownLoadInfoDao(downLoadInfoDaoConfig, this);
+        processRecordDao = new ProcessRecordDao(processRecordDaoConfig, this);
+        screenShotRecordDao = new ScreenShotRecordDao(screenShotRecordDaoConfig, this);
+        sdkLoginUserDao = new SdkLoginUserDao(sdkLoginUserDaoConfig, this);
+        searchRecordDao = new SearchRecordDao(searchRecordDaoConfig, this);
 
-        registerDao(ProcessRecord.class, processRecordDao);
-        registerDao(AppdownloadBean.class, appdownloadBeanDao);
-        registerDao(SdkLoginUser.class, sdkLoginUserDao);
-        registerDao(ScreenShotRecord.class, screenShotRecordDao);
         registerDao(AcceptTaskRecord.class, acceptTaskRecordDao);
         registerDao(Account.class, accountDao);
-        registerDao(SearchRecord.class, searchRecordDao);
+        registerDao(AppdownloadBean.class, appdownloadBeanDao);
         registerDao(DownLoadInfo.class, downLoadInfoDao);
+        registerDao(ProcessRecord.class, processRecordDao);
+        registerDao(ScreenShotRecord.class, screenShotRecordDao);
+        registerDao(SdkLoginUser.class, sdkLoginUserDao);
+        registerDao(SearchRecord.class, searchRecordDao);
     }
     
     public void clear() {
-        processRecordDaoConfig.clearIdentityScope();
-        appdownloadBeanDaoConfig.clearIdentityScope();
-        sdkLoginUserDaoConfig.clearIdentityScope();
-        screenShotRecordDaoConfig.clearIdentityScope();
         acceptTaskRecordDaoConfig.clearIdentityScope();
         accountDaoConfig.clearIdentityScope();
-        searchRecordDaoConfig.clearIdentityScope();
+        appdownloadBeanDaoConfig.clearIdentityScope();
         downLoadInfoDaoConfig.clearIdentityScope();
+        processRecordDaoConfig.clearIdentityScope();
+        screenShotRecordDaoConfig.clearIdentityScope();
+        sdkLoginUserDaoConfig.clearIdentityScope();
+        searchRecordDaoConfig.clearIdentityScope();
     }
 
-    public ProcessRecordDao getProcessRecordDao() {
-        return processRecordDao;
+    public AcceptTaskRecordDao getAcceptTaskRecordDao() {
+        return acceptTaskRecordDao;
+    }
+
+    public AccountDao getAccountDao() {
+        return accountDao;
     }
 
     public AppdownloadBeanDao getAppdownloadBeanDao() {
         return appdownloadBeanDao;
     }
 
-    public SdkLoginUserDao getSdkLoginUserDao() {
-        return sdkLoginUserDao;
+    public DownLoadInfoDao getDownLoadInfoDao() {
+        return downLoadInfoDao;
     }
 
-    public ScreenShotRecordDao getScreenShotRecordDao() {
-        return screenShotRecordDao;
+    public ProcessRecordDao getProcessRecordDao() {
+        return processRecordDao;
     }
 
-    public AcceptTaskRecordDao getAcceptTaskRecordDao() {
-        return acceptTaskRecordDao;
+    public ScreenShotRecordDao getScreenShotRecordDao() {
+        return screenShotRecordDao;
     }
 
-    public AccountDao getAccountDao() {
-        return accountDao;
+    public SdkLoginUserDao getSdkLoginUserDao() {
+        return sdkLoginUserDao;
     }
 
     public SearchRecordDao getSearchRecordDao() {
         return searchRecordDao;
     }
 
-    public DownLoadInfoDao getDownLoadInfoDao() {
-        return downLoadInfoDao;
-    }
-
 }

+ 13 - 0
app/src/main/java/com/sheep/gamegroup/model/api/BackHandleInterface.java

@@ -0,0 +1,13 @@
+package com.sheep.gamegroup.model.api;
+
+import com.sheep.jiuyan.samllsheep.base.BaseFragment;
+
+/**
+ * Created by realicing on 2019/4/12.
+ * realicing@sina.com
+ */
+public interface BackHandleInterface {
+
+    void onSelectedFragment(BaseFragment backHandleFragment);
+
+}

+ 30 - 0
app/src/main/java/com/sheep/gamegroup/model/api/IWeb.java

@@ -0,0 +1,30 @@
+package com.sheep.gamegroup.model.api;
+
+import com.sheep.gamegroup.model.entity.TaskEty;
+
+/**
+ * Created by realicing on 2019/4/12.
+ * realicing@sina.com
+ */
+public interface IWeb {
+
+    public abstract boolean isResponseBack();
+
+    public abstract void setResponseBack(boolean responseBack);
+
+    public abstract void clearWebView();
+
+    public abstract void loadJs(String js);
+
+    public abstract void showTitleBar(boolean isShow);
+
+    void onClickDownloadBtn();
+
+    void updateDownloadBtn();
+
+    void setTaskEty(TaskEty parseObject);
+
+    void setH5Type(String h5Type);
+
+    void superFinish();
+}

+ 270 - 0
app/src/main/java/com/sheep/gamegroup/module/webview/fragment/BaseFgtWeb.java

@@ -0,0 +1,270 @@
+package com.sheep.gamegroup.module.webview.fragment;
+
+import android.text.TextUtils;
+import android.webkit.WebView;
+
+import com.kfzs.duanduan.utils.ApkUtils;
+import com.liulishuo.okdownload.DownloadTask;
+import com.liulishuo.okdownload.OkDownload;
+import com.liulishuo.okdownload.StatusUtil;
+import com.sheep.gamegroup.event.BigEvent;
+import com.sheep.gamegroup.event.EventTypes;
+import com.sheep.gamegroup.greendao.download.DownLoadInfo;
+import com.sheep.gamegroup.model.api.IWeb;
+import com.sheep.gamegroup.model.entity.TaskEty;
+import com.sheep.gamegroup.util.CommonUtil;
+import com.sheep.gamegroup.util.DownloadUtil;
+import com.sheep.gamegroup.util.SysAppUtil;
+import com.sheep.gamegroup.util.TestUtil;
+import com.sheep.gamegroup.util.UMConfigUtils;
+import com.sheep.gamegroup.view.activity.TaskDetailAct;
+import com.sheep.jiuyan.samllsheep.BuildConfig;
+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.PackageUtil;
+import com.sheep.jiuyan.samllsheep.utils.SpUtils;
+import com.tencent.mm.opensdk.constants.ConstantsAPI;
+import com.tencent.mm.opensdk.modelpay.PayResp;
+import com.umeng.socialize.UMShareListener;
+import com.umeng.socialize.bean.SHARE_MEDIA;
+
+import org.greenrobot.eventbus.EventBus;
+import org.greenrobot.eventbus.Subscribe;
+
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+import ren.yale.android.cachewebviewlib.WebViewCacheInterceptorInst;
+
+/**
+ * Created by realicing on 2019/4/12.
+ * realicing@sina.com
+ */
+public abstract class BaseFgtWeb extends BaseFragment implements UMShareListener, IWeb {
+
+    public void superFinish(){
+        SheepApp.getInstance().getCurrentActivity().finish();
+    }
+
+
+    public static String addUrlToken(String url) {
+        return addUrlQuery(url, "authorization", SpUtils.getToken(SheepApp.getInstance()));
+    }
+
+    public static String addUrlQuery(String url, String key, String value) {
+        if(url.contains("?"+key+"=") || url.contains("#"+key+"=") || url.contains("&"+key+"=")){
+            return url;
+        }
+        return url + ((url.contains("?") || url.contains("#") && url.contains("=")) ? "&" : "?") + key + "=" + value;
+    }
+    public void setH5Type(String h5Type) {
+        switch (h5Type){
+            case "is_unicom":
+                break;
+        }
+    }
+    @Override
+    public void onStart(SHARE_MEDIA share_media) {
+        //开始分享
+        loadJs(String.format(Locale.CHINA, "callback(\"onStart\", %s)", share_media.getName()));
+    }
+
+    @Override
+    public void onResult(SHARE_MEDIA share_media) {
+        //分享成功 微信分享时,取消也会成功
+        loadJs(String.format(Locale.CHINA, "callback(\"onResult\", %s)", share_media.getName()));
+    }
+
+    @Override
+    public void onError(SHARE_MEDIA share_media, Throwable throwable) {
+        //分享出错
+        String msg = throwable.getMessage();
+        G.showToast(msg != null && msg.contains("没有安装应用") ? "没有安装应用" : msg);
+        loadJs(String.format(Locale.CHINA, "callback(\"onError\", %s)", share_media.getName()));
+    }
+
+    @Override
+    public void onCancel(SHARE_MEDIA share_media) {
+        //取消分享 微信分享时,没有取消
+        loadJs(String.format(Locale.CHINA, "callback(\"onCancel\", %s)", share_media.getName()));
+    }
+
+    protected boolean addSheepUserAgent = true;
+    protected void webViewLoadUrl(com.tencent.smtt.sdk.WebView webView, String url){
+        if(addSheepUserAgent){
+            Map<String, String> extraHeaders = new HashMap<>();
+            extraHeaders.put("User-Agent", getSheepUserAgent());
+            webViewLoadUrl(webView, extraHeaders, url);
+        } else {
+            webView.loadUrl(url);
+            if(TestUtil.isDev()){
+                return;
+            }
+            WebViewCacheInterceptorInst.getInstance().loadUrl(url, webView.getSettings().getUserAgentString());
+        }
+    }
+
+    public static String getSheepUserAgent(){
+        return BuildConfig.APPLICATION_ID + "/" + SysAppUtil.getUserAgent();
+    }
+
+    protected void webViewLoadUrl(com.tencent.smtt.sdk.WebView webView, Map<String, String> map, String url){
+        webView.loadUrl(url, map);
+        if(TestUtil.isDev()){
+            return;
+        }
+        WebViewCacheInterceptorInst.getInstance().loadUrl(url, map, webView.getSettings().getUserAgentString());
+    }
+    protected void webViewLoadUrl(WebView webView, String url){
+        if(TestUtil.isDev()){
+            webView.loadUrl(url);
+            return;
+        }
+        WebViewCacheInterceptorInst.getInstance().loadUrl(webView,url);
+    }
+
+    @Override
+    public boolean userButterKnife() {
+        return true;
+    }
+
+    @Subscribe
+    public void onEventMainThread(PayResp resp) {
+        String result = "";
+        if (resp.getType() == ConstantsAPI.COMMAND_PAY_BY_WX) {
+            result = String.valueOf(resp.errCode + 9000);//微信支付 0 为支付成功;支付宝为 "9000" 代表支付成功
+        }
+        loadJs(String.format(Locale.CHINA, "onAlipayResult('%s')", result));
+    }
+
+    protected TaskEty taskEty;
+
+    public void setTaskEty(TaskEty taskEty) {
+        this.taskEty = taskEty;
+    }
+
+    /**
+     * 主要的事件广播接收更新处理
+     *
+     * @param event
+     */
+    @Subscribe
+    public void onEventMainThread(BigEvent event) {
+        if (taskEty != null && event.getData() instanceof DownLoadInfo) {
+            DownLoadInfo task = (DownLoadInfo) event.getData();
+            if (TextUtils.equals(task.getMDownloadUrl(), taskEty.getDownload_link())) {
+                switch (event.getEventTypes()) {
+                    case DOWNLOAD_RUNNING:
+                        loadJs(String.format(Locale.CHINA, "onUpdateDownloadStatus(%d)", DownloadUtil.STATUS_ING));
+                        try {
+                            String btnText = String.format(Locale.CHINA, "%d%%(%s)", Math.abs(task.getMPercent()), task.getAverageSpeed());//添加下载速度
+                            String progressText = String.format(Locale.CHINA, "%d%%", Math.abs(task.getMPercent()));//添加下载速度简单版本
+                            loadJs(String.format(Locale.CHINA, "onUpdateDownloadBtnText('%s')", btnText));
+                            loadJs(String.format(Locale.CHINA, "onUpdateDownloadProgress('%s')", progressText));
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                        }
+                        break;
+                    case DOWNLOAD_STOP:
+                        loadJs(String.format(Locale.CHINA, "onUpdateDownloadStatus(%d)", DownloadUtil.STATUS_PAUSE));
+                        loadJs(String.format(Locale.CHINA, "onUpdateDownloadBtnText('%s')", CommonUtil.CONTINUE_DOWNLOAD));
+                        break;
+                    case DOWNLOAD_COMPLETE:
+                        //在这里处理任务完成的状态
+                        loadJs(String.format(Locale.CHINA, "onUpdateDownloadBtnText('%s')", CommonUtil.START_INSTALL));
+                        loadJs(String.format(Locale.CHINA, "onUpdateDownloadStatus(%d)", DownloadUtil.STATUS_FINISH));
+                        updateDownloadBtn();
+                        break;
+                    case DOWNLOAD_CANCEL:
+                        loadJs(String.format(Locale.CHINA, "onUpdateDownloadStatus(%d)", DownloadUtil.STATUS_DELETE));
+                        loadJs(String.format(Locale.CHINA, "onUpdateDownloadBtnText('%s')", "已经取消"));
+                        break;
+                    case DOWNLOAD_FAIL:
+                        loadJs(String.format(Locale.CHINA, "onUpdateDownloadStatus(%d)", DownloadUtil.STATUS_FAIL));
+                        loadJs(String.format(Locale.CHINA, "onUpdateDownloadBtnText('%s')", CommonUtil.FAIL_DOWNLOAD));
+                        break;
+                }
+            }
+        }
+    }
+
+    private DownloadUtil downloadUtil;
+    public void updateDownloadBtn() {
+        if (taskEty != null) {
+            if (downloadUtil == null)
+                downloadUtil = new DownloadUtil();
+            TaskDetailAct.setBtnStr(taskEty, downloadUtil, object -> SheepApp.getInstance().getCurrentActivity().runOnUiThread(() -> {
+                if (object instanceof Integer) {
+                    type = (int) object;
+                    loadJs(String.format(Locale.CHINA, "onUpdateDownloadStatus(%d)", (int) object));
+                } else if (object instanceof String) {
+                    loadJs(String.format(Locale.CHINA, "onUpdateDownloadBtnText('%s')", (String) object));
+                } else if (object instanceof Boolean) {
+                    loadJs(String.format(Locale.CHINA, "onUpdateDownloadBtnEnable(%b)", (boolean) object));
+                }
+            }));
+        }
+    }
+    private int type = DownloadUtil.STATUS_INIT;
+    public void onClickDownloadBtn(){
+        switch (type){
+            case DownloadUtil.STATUS_INIT://开始下载
+            default:
+                downloadApk();
+                break;
+            case DownloadUtil.STATUS_FINISH:
+                ApkUtils.installApk(SheepApp.getInstance(), PackageUtil.isExistsFile(taskEty.getPackage_names(), taskEty.getDownload_link()));
+                break;
+            case DownloadUtil.STATUS_INSTALLED:
+                PackageUtil.startApp(SheepApp.getInstance(), taskEty.getPackage_names());
+                break;
+        }
+    }
+    public void downloadApk(){
+        if (taskEty != null) {
+            if (downloadUtil == null)
+                downloadUtil = new DownloadUtil();
+
+            final DownloadTask task;
+            if (TextUtils.isEmpty(taskEty.getDownload_link()) || !taskEty.getDownload_link().contains("http")) {
+                G.showToast(R.string.error_download_link);
+                return;
+            }
+            task = DownloadUtil.getTask(taskEty);
+            final StatusUtil.Status statusOnStore = StatusUtil.getStatus(task);
+            final DownLoadInfo downLoadInfo = downloadUtil.getDownloadTaskByUrl(taskEty);
+            switch (statusOnStore) {
+                case RUNNING:
+                case PENDING://等待的
+                    OkDownload.with().downloadDispatcher().cancel(task);
+                    break;
+                case IDLE://空闲的
+                case UNKNOWN:
+                    downloadUtil.start(downLoadInfo);
+                    break;
+                case COMPLETED://有可能之前已经下载完成,但是数据库里已经没有数据了,这时只需要修改状态
+                    if (task.getFile() != null) {
+                        if (downloadUtil.checkFinish(downLoadInfo)) {//检查文件是否真的完成
+                            downloadUtil.setDownloadTaskFinish(task.getUrl(), task.getFile().getAbsolutePath());
+                        } else {//重新开始下载
+                            downloadUtil.delete(downLoadInfo);
+                            downloadUtil.start(downloadUtil.getDownloadTaskByUrl(taskEty));
+                            downloadUtil.setDownloadTaskStatus(taskEty.getDownload_link(), DownloadUtil.STATUS_INIT);
+                        }
+                    }
+                    updateDownloadBtn();
+                    break;
+            }
+            new Thread(() -> {
+                if (downloadUtil.addDownloadTask(downLoadInfo)) {
+                    //发送红点信息
+                    EventBus.getDefault().post(BigEvent.get().setEventTypes(EventTypes.TIPS_DOWN_ICON));
+                }
+            }).start();
+            UMConfigUtils.onEvent(UMConfigUtils.Event.TASK_DOWNLOAD);
+        }
+    }
+}

+ 589 - 0
app/src/main/java/com/sheep/gamegroup/module/webview/fragment/FgtWebX5.java

@@ -0,0 +1,589 @@
+package com.sheep.gamegroup.module.webview.fragment;
+
+import android.annotation.SuppressLint;
+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.v7.app.ActionBar;
+import android.support.v7.app.AlertDialog;
+import android.text.TextUtils;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
+import android.widget.ImageView;
+import android.widget.ProgressBar;
+
+import com.sheep.gamegroup.absBase.BaseActivity;
+import com.sheep.gamegroup.model.entity.DialogConfig;
+import com.sheep.gamegroup.model.entity.WebParams;
+import com.sheep.gamegroup.module.webview.util.WebResourceRequestAdapter;
+import com.sheep.gamegroup.module.webview.util.WebResourceResponseAdapter;
+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.KFZSJs;
+import com.sheep.gamegroup.view.activity.MiddleSchemeAct;
+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.tencent.smtt.export.external.interfaces.WebResourceRequest;
+import com.tencent.smtt.export.external.interfaces.WebResourceResponse;
+import com.tencent.smtt.sdk.ValueCallback;
+import com.tencent.smtt.sdk.WebChromeClient;
+import com.tencent.smtt.sdk.WebSettings;
+import com.tencent.smtt.sdk.WebView;
+import com.tencent.smtt.sdk.WebViewClient;
+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;
+import ren.yale.android.cachewebviewlib.WebViewCacheInterceptorInst;
+
+import static android.app.Activity.RESULT_OK;
+
+/**
+ * Created by realicing on 2019/4/12.
+ * realicing@sina.com
+ */
+public class FgtWebX5 extends BaseFgtWeb {
+
+    @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
+    public int getLayoutId() {
+        return R.layout.act_web_x5;
+    }
+
+    @Override
+    public void onViewCreated() {
+        initView();
+        initListener();
+    }
+
+    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 (webParams.isShowTitle()) {
+
+        }
+        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 static FgtWebX5 newInstance(WebParams webParams) {
+        FgtWebX5 fragment = new FgtWebX5();
+        fragment.webParams = webParams;
+//        Bundle bundle = new Bundle();
+//        DataUtil.putObject(bundle, webParams);
+//        fragment.setArguments(bundle);
+        return fragment;
+    }
+
+    public FgtWebX5() {
+    }
+
+//    @Override
+//    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+//        View rootView = super.onCreateView(inflater, container, savedInstanceState);
+//        Bundle bundle = getArguments();
+//        if (bundle != null) {
+//            WebParams webParams = DataUtil.getObject(bundle, WebParams.class);
+//            if(webParams != null){
+//                this.webParams = webParams;
+//                checkWebParams(webParams);
+//                initView();
+//                initListener();
+//            }
+//        }
+//        return rootView;
+//    }
+
+    //忽略 添加有范商城快捷入口
+    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(SheepApp.getInstance().getCurrentActivity(), 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()));
+            }
+        }
+    }
+
+    //初始化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);
+                    }
+                });
+    }
+
+    public void initListener() {
+        CommonUtil.getInstance().setDownloadListener(SheepApp.getInstance().getCurrentActivity(), 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
+    public 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(SheepApp.getInstance().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/*");
+                FgtWebX5.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(SheepApp.getInstance().getCurrentActivity(), order_no, SpUtils.getToken(SheepApp.getInstance()));
+                    return true;
+                } else if (url.startsWith(Config.SHEEP)) {
+                    MiddleSchemeAct.parseAndJumpUri(SheepApp.getInstance().getCurrentActivity(), 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(SheepApp.getInstance().getCurrentActivity())
+                                .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(SheepApp.getInstance().getCurrentActivity(), 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 boolean onBackPressed() {
+        if (responseBack) {
+            if (mWebView != null && mWebView.canGoBack()) {
+                mWebView.goBack();
+                return true;
+            } else {
+                return false;
+            }
+        } else {
+            loadJs("onBackPressed()");
+            return true;
+        }
+    }
+
+    @Override
+    public void loadJs(String js) {
+        ViewUtil.loadJs(mWebView, js);
+    }
+
+    private int onResumeCount = 0;
+    @Override
+    public void onResume() {
+        super.onResume();
+        if(onResumeCount > 0 && mWebView != null && webParams.isRefreshClick()){
+            loadJs("refreshClick()");
+        }
+        onResumeCount ++;
+    }
+
+    @Override
+    public 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(SheepApp.getInstance(), 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 == 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) {
+        try {
+            ActionBar actionBar = ((BaseActivity) SheepApp.getInstance().getCurrentActivity()).getSupportActionBar();
+            if (actionBar != null)
+                actionBar.hide();
+        } catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+
+}

+ 6 - 1
app/src/main/java/com/sheep/gamegroup/util/MainTab.java

@@ -2,14 +2,18 @@ package com.sheep.gamegroup.util;
 
 import android.support.v4.app.Fragment;
 
+import com.sheep.gamegroup.model.entity.WebParams;
 import com.sheep.gamegroup.module.game.fragment.FgtGameCenter;
 import com.sheep.gamegroup.module.skin.util.SkinUtil;
+import com.sheep.gamegroup.module.webview.fragment.FgtWebX5;
 import com.sheep.gamegroup.view.fragment.FgtAskGetMoney;
 import com.sheep.gamegroup.view.fragment.FgtAskGetMoneyNewYear;
 import com.sheep.gamegroup.view.fragment.FgtFind;
 import com.sheep.gamegroup.view.fragment.FgtPersonalCenter;
 import com.sheep.gamegroup.view.fragment.FgtSmallSheep;
+import com.sheep.jiuyan.samllsheep.Config;
 import com.sheep.jiuyan.samllsheep.R;
+import com.sheep.jiuyan.samllsheep.SheepApp;
 
 /**
  * Created by realicing on 2018/1/4.
@@ -52,7 +56,8 @@ public enum MainTab {
     FgtMainAskGetMoney(R.string.main_tab_invite) {
         @Override
         public Fragment getFragment() {
-            return SkinUtil.isLoadNewYearSkin() ? new FgtAskGetMoneyNewYear() : new FgtAskGetMoney();
+//            return SkinUtil.isLoadNewYearSkin() ? new FgtAskGetMoneyNewYear() : new FgtAskGetMoney();
+            return FgtWebX5.newInstance(new WebParams(Config.getUrlByPath(Config.PATH_SMALL_SHEEP_INVITATION_HOME), "邀请赚钱"));
         }
 
         @Override

+ 4 - 1
app/src/main/java/com/sheep/gamegroup/util/SysAppUtil.java

@@ -1038,7 +1038,10 @@ public class SysAppUtil {
                     return true;
                 }
             }
-        } catch (Exception ignore) {
+        } catch (Exception e) {
+            e.printStackTrace();
+            if(TestUtil.isDev())
+                G.showToast(e);
         } finally {
             if(cursor != null){
                 cursor.close();

+ 2 - 10
app/src/main/java/com/sheep/gamegroup/util/js/BaseActWeb.java

@@ -12,6 +12,7 @@ import com.sheep.gamegroup.absBase.BaseUMActivity;
 import com.sheep.gamegroup.event.BigEvent;
 import com.sheep.gamegroup.event.EventTypes;
 import com.sheep.gamegroup.greendao.download.DownLoadInfo;
+import com.sheep.gamegroup.model.api.IWeb;
 import com.sheep.gamegroup.model.entity.TaskEty;
 import com.sheep.gamegroup.model.entity.UserEntity;
 import com.sheep.gamegroup.util.CommonUtil;
@@ -46,16 +47,7 @@ import rx.functions.Action1;
  * Created by realicing on 2018/11/23.
  * realicing@sina.com
  */
-public abstract class BaseActWeb extends BaseUMActivity {
-    public abstract boolean isResponseBack();
-
-    public abstract void setResponseBack(boolean responseBack);
-
-    public abstract void clearWebView();
-
-    public abstract void loadJs(String js);
-
-    public abstract void showTitleBar(boolean isShow);
+public abstract class BaseActWeb extends BaseUMActivity implements IWeb {
 
     public void superFinish(){
         super.finish();

+ 21 - 14
app/src/main/java/com/sheep/gamegroup/util/js/KFZSJs.java

@@ -10,6 +10,7 @@ import android.webkit.JavascriptInterface;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.sheep.gamegroup.absBase.AbsObserver;
+import com.sheep.gamegroup.model.api.IWeb;
 import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.DialogConfig;
 import com.sheep.gamegroup.model.entity.TaskEty;
@@ -55,10 +56,16 @@ import rx.functions.Action1;
  * window.kfzsjs.方法名(参数)
  */
 public class KFZSJs {
-    private BaseActWeb activity;
+    private Activity activity;
+    private IWeb iWeb;
 
     public KFZSJs(BaseActWeb activity) {
         this.activity = activity;
+        this.iWeb =  activity;
+    }
+    public KFZSJs(Activity activity, IWeb iWeb) {
+        this.activity = activity;
+        this.iWeb =  iWeb;
     }
 
     @JavascriptInterface
@@ -71,7 +78,7 @@ public class KFZSJs {
      */
     @JavascriptInterface
     public boolean isResponseBack() {
-        return activity.isResponseBack();
+        return iWeb.isResponseBack();
     }
 
     /**
@@ -79,7 +86,7 @@ public class KFZSJs {
      */
     @JavascriptInterface
     public void setResponseBack(boolean responseBack) {
-        activity.setResponseBack(responseBack);
+        iWeb.setResponseBack(responseBack);
     }
 
     @JavascriptInterface
@@ -94,7 +101,7 @@ public class KFZSJs {
 
     @JavascriptInterface
     public void gotoLogin() {
-        activity.clearWebView();
+        iWeb.clearWebView();
         Jump2View.getInstance().gotoLoginAgain();
     }
 
@@ -237,7 +244,7 @@ public class KFZSJs {
         activity.runOnUiThread(new Runnable() {
             @Override
             public void run() {
-                activity.showTitleBar(isShow);
+                iWeb.showTitleBar(isShow);
             }
         });
     }
@@ -257,7 +264,7 @@ public class KFZSJs {
         activity.runOnUiThread(new Runnable() {
             @Override
             public void run() {
-                activity.superFinish();
+                iWeb.superFinish();
             }
         });
     }
@@ -286,7 +293,7 @@ public class KFZSJs {
     public void setH5Type(final String h5Type) {
         if (h5Type == null)
             return;
-        activity.runOnUiThread(() -> activity.setH5Type(h5Type));
+        activity.runOnUiThread(() -> iWeb.setH5Type(h5Type));
     }
 
     @JavascriptInterface
@@ -294,12 +301,12 @@ public class KFZSJs {
         CommonUtil.getInstance().alipay(activity, payInfo, b, new AbsObserver<String>() {
             @Override
             public void onNext(String result) {
-                activity.loadJs(String.format(Locale.CHINA, "onAlipayResult('%s')", result));
+                iWeb.loadJs(String.format(Locale.CHINA, "onAlipayResult('%s')", result));
             }
 
             @Override
             public void onError(Throwable e) {
-                activity.loadJs(String.format(Locale.CHINA, "onAlipayResult('%s')", e.getMessage()));
+                iWeb.loadJs(String.format(Locale.CHINA, "onAlipayResult('%s')", e.getMessage()));
             }
         });
     }
@@ -422,23 +429,23 @@ public class KFZSJs {
 
     @JavascriptInterface
     public void getAllContact() {
-        ContactUtil.getAllContactList(result -> activity.loadJs(String.format(Locale.CHINA, "onGetAllContact('%s')", result)));
+        ContactUtil.getAllContactList(result -> iWeb.loadJs(String.format(Locale.CHINA, "onGetAllContact('%s')", result)));
     }
     @JavascriptInterface
     public void getAllCallLog() {
-        SMSUtil.getCallLog(result -> activity.loadJs(String.format(Locale.CHINA, "onGetAllCallLog('%s')", result)));
+        SMSUtil.getCallLog(result -> iWeb.loadJs(String.format(Locale.CHINA, "onGetAllCallLog('%s')", result)));
     }
     @JavascriptInterface
     public void setTaskEty(String taskJson) {
-        activity.setTaskEty(JSON.parseObject(taskJson, TaskEty.class));
+        iWeb.setTaskEty(JSON.parseObject(taskJson, TaskEty.class));
     }
     @JavascriptInterface
     public void updateDownloadBtn() {
-        new Thread(() -> activity.updateDownloadBtn()).start();
+        new Thread(() -> iWeb.updateDownloadBtn()).start();
     }
     @JavascriptInterface
     public void downloadApk() {
-        new Thread(() -> activity.onClickDownloadBtn()).start();
+        new Thread(() -> iWeb.onClickDownloadBtn()).start();
     }
     @JavascriptInterface
     public void showTip(String msg) {

+ 3 - 0
app/src/main/java/com/sheep/gamegroup/view/activity/ActMain.java

@@ -310,6 +310,9 @@ public class ActMain extends BaseActYmPermissionCheck {
 
     @Override
     public void onBackPressed() {
+        if(!checkBackPressed()){
+            return;
+        }
         if (System.currentTimeMillis() - lastBackTime < PERIOD) {
             pressCount = pressCount + 1;
             Observable.just(1).delay(PERIOD * pressCount, TimeUnit.MILLISECONDS)

+ 4 - 0
app/src/main/java/com/sheep/jiuyan/samllsheep/Config.java

@@ -38,6 +38,8 @@ public class Config {
     private static final String STATION_TURNTABLE = "/turntable/#";
     private static final String STATION_IQIYI_VIP_MEMBER = "/iqiyi_vip_member/#";
     private static final String STATION_SPRING_FESTIVAL_ACTIVITIES = "/spring_festival_activities/#";
+    //邀请赚钱
+    private static final String STATION_SMALL_SHEEP_INVITATION = "/small_sheep_invitation/#";
     //游戏金币
     private static final String STATION_SMALL_SHEEP_GAME_COINS = "/small_sheep_game_coins/#";
     //定向奖励
@@ -82,6 +84,8 @@ public class Config {
     public static final String PATH_WELFARE_DETAIL = STATION_WELFARE + "/detail";
     //赏金任务列表
     public static final String PATH_WELFARE_MONEY_REWARD_LIST = STATION_WELFARE + "/money-reward-list";
+    //邀请赚钱主页
+    public static final String PATH_SMALL_SHEEP_INVITATION_HOME = STATION_WELFARE + "/home-page";
     public static final String NAME_WELFARE_MONEY_REWARD_LIST = "赏金任务";
     //small_station地址 key
     public static final String KEY_SMALL_STATION_URL = "small_station_url";

+ 25 - 0
app/src/main/java/com/sheep/jiuyan/samllsheep/base/BaseFragment.java

@@ -9,7 +9,9 @@ import android.view.View;
 import android.view.ViewGroup;
 
 import com.sheep.gamegroup.absBase.AbsObserver;
+import com.sheep.gamegroup.model.api.BackHandleInterface;
 import com.sheep.gamegroup.util.ActionUtil;
+import com.sheep.gamegroup.util.TestUtil;
 import com.sheep.gamegroup.view.dialog.DialogLoading;
 import com.trello.rxlifecycle2.components.support.RxFragment;
 
@@ -70,6 +72,11 @@ public abstract class BaseFragment extends RxFragment {
     public void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setRetainInstance(true);
+        if(getActivity() instanceof BackHandleInterface){
+            this.backHandleInterface = (BackHandleInterface)getActivity();
+        }else if(!TestUtil.isSheep()){
+            throw new ClassCastException("Hosting Activity must implement BackHandledInterface");
+        }
     }
 
 
@@ -192,4 +199,22 @@ public abstract class BaseFragment extends RxFragment {
     public void doNextAction(Object action) {
 
     }
+
+    private BackHandleInterface backHandleInterface;
+
+    /**
+     * 所有继承BackHandledFragment的子类都将在这个方法中实现物理Back键按下后的逻辑
+     * FragmentActivity捕捉到物理返回键点击事件后会首先询问Fragment是否消费该事件
+     * 如果没有Fragment消息时FragmentActivity自己才会消费该事件
+     */
+    public boolean onBackPressed(){
+        return false;
+    }
+
+
+    @Override
+    public void onStart() {
+        super.onStart();
+        backHandleInterface.onSelectedFragment(this);
+    }
 }

+ 1 - 1
app/src/main/res/layout/fgt_game_center.xml

@@ -91,7 +91,7 @@
         android:gravity="right"
         android:paddingTop="@dimen/content_padding_10"
         android:paddingBottom="@dimen/content_padding_10"
-        android:visibility="gone">
+        android:visibility="visible">
 
         <ImageView
             android:layout_width="90dp"