admin
2021-06-05 ddff7888bf7e754d12fb5fc85a58f3012f456490
app/src/main/java/com/tejia/lijin/app/util/web/RebateJavaInterfaceBS.java
@@ -43,6 +43,7 @@
import com.tejia.lijin.app.entity.share.ShareImageEntity;
import com.tejia.lijin.app.ui.dialog.ShapeLoadingDialog;
import com.tejia.lijin.app.ui.invite.ShareBrowserActivity;
import com.tejia.lijin.app.updateApp.UpdateApp;
import com.tejia.lijin.app.util.JumpActivityUtil;
import com.tejia.lijin.app.util.PermissionHelper;
import com.tejia.lijin.app.util.ToastUtil;
@@ -129,7 +130,7 @@
        } else {//存储权限已开
            String md5 = MD5Utils.getMD532(url.toString());
            String path = com.wpc.library.util.Environment.getExternalStorageDirectory()
                    + "/blksapp";
                    + "/tejiaapp";
            File file = new File(path + "/" + md5 + ".jpg");
            if (!file.exists()) {
                try {
@@ -145,6 +146,53 @@
            } else {
                Toast.makeText(mContext, "图片已经保存!", Toast.LENGTH_LONG).show();
            }
        }
    }
    /**
     * 异步保存图片
     *
     * @param args
     * @param handler
     * @throws JSONException
     */
    public void savePictureAsync(Object args, final CompletionHandler handler) throws JSONException {
        JSONObject jsonObject = new JSONObject(args.toString());
        String url = jsonObject.optString("url");
        if (mPermissionsChecker == null)
            mPermissionsChecker = new PermissionHelper(mContext, this);
        if (mPermissionsChecker.lacksPermissions(getPermissions())) { //存储权限未开启
            mPermissionsChecker.showNormalDialog();
        } else {//存储权限已开
            String md5 = MD5Utils.getMD532(url);
            String path = com.wpc.library.util.Environment.getExternalStorageDirectory()
                    + "/tejiaapp";
            File file = new File(path + "/" + md5 + ".jpg");
            if (!file.exists()) {
                try {
                    File resultFile = Tools.saveImageFromPathToSdCard(mContext, url, path, md5 + ".jpg");
                    if (resultFile != null) {
                        JSONObject result = new JSONObject();
                        result.put("code", 0);
                        result.put("msg", "保存成功");
                        handler.complete(result);
                    }
                } catch (Exception e) {
                    JSONObject result = new JSONObject();
                    result.put("code", 1);
                    result.put("msg", "图片保存失败");
                    handler.complete(result);
                    if (file.exists())
                        file.delete();
                }
            } else {
                JSONObject result = new JSONObject();
                result.put("code", 2);
                result.put("msg", "图片已经保存");
                handler.complete(result);
            }
        }
    }
@@ -539,7 +587,7 @@
                            @Override
                            public void onVideoError() {
                                com.alibaba.fastjson.JSONObject  result = new com.alibaba.fastjson.JSONObject();
                                com.alibaba.fastjson.JSONObject result = new com.alibaba.fastjson.JSONObject();
                                result.put("code", 2);
                                result.put("msg", "视频出错");
                                handler.complete(result);
@@ -547,7 +595,7 @@
                            @Override
                            public void onRewardVerify(boolean b, int i, String s, int i1, String s1) {
                                com.alibaba.fastjson.JSONObject  result = new com.alibaba.fastjson.JSONObject();
                                com.alibaba.fastjson.JSONObject result = new com.alibaba.fastjson.JSONObject();
                                result.put("code", 0);
                                result.put("msg", "广告展示完成");
                                handler.complete(result);
@@ -595,6 +643,31 @@
            }
        });
    }
    @JavascriptInterface
    public void checkUpdate(Object obj) {
        UpdateApp app = new UpdateApp(mContext,mContext.getResources().getString(R.string.update_key));
        app.getUpdateInfo(new UpdateApp.UpdateJudgeCallback() {
            @Override
            public void onSuccess(boolean show) {
            }
            @Override
            public void closeUpdate(boolean close) {
            }
            @Override
            public void onFinish() {
            }
        }, true);//强制检测更新
    }
    int type;
@@ -665,7 +738,7 @@
                    + "/rebateshare";
        } else if (type == 2) {
            path = com.wpc.library.util.Environment.getExternalStorageDirectory()
                    + "/blksapp";
                    + "/tejiaapp";
        }
        final File storageDir = new File(path);
        List<String> filePathList = new ArrayList<>();