From 1764c1784a4cf1a6afd25fcf1a0eef6187a84218 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期四, 08 七月 2021 17:14:58 +0800 Subject: [PATCH] 1.1.3完善 --- app/src/main/java/com/tejia/lijin/app/util/web/RebateJavaInterfaceBS.java | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 104 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/tejia/lijin/app/util/web/RebateJavaInterfaceBS.java b/app/src/main/java/com/tejia/lijin/app/util/web/RebateJavaInterfaceBS.java index f7fb93e..6f7727d 100644 --- a/app/src/main/java/com/tejia/lijin/app/util/web/RebateJavaInterfaceBS.java +++ b/app/src/main/java/com/tejia/lijin/app/util/web/RebateJavaInterfaceBS.java @@ -40,9 +40,11 @@ import com.tejia.lijin.app.callBack.GeneralBackCallback; import com.tejia.lijin.app.callBack.PermissionInterface; import com.tejia.lijin.app.entity.ImgText; +import com.tejia.lijin.app.entity.JumpDetail; 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 +131,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 +147,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); } } } @@ -239,6 +288,21 @@ mContext.startActivity(intent); if (!boo) mContext.finish(); + } + + + /** + * 璺宠浆涓夋柟骞冲彴 + * + * @param args + * @throws JSONException + */ + @JavascriptInterface + public void jumpThirdPlatform(Object args) throws JSONException { + JSONObject json = new JSONObject(args.toString()); + JumpDetail jumpDetail = new JumpDetail(); + jumpDetail.setType("thirdPlatform"); + JumpActivityUtil.jumpPage(mContext, jumpDetail, com.alibaba.fastjson.JSONObject.parseObject(json.toString())); } @@ -357,11 +421,10 @@ int type = json.optInt("type"); final String url = json.optString("url"); - //妫�娴嬫潈闄� - String[] str = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, - Manifest.permission.WRITE_EXTERNAL_STORAGE}; - if (lacksPermissions(str)) {//缂哄皯鏉冮檺 - generalBackCallback.onSuccess(type, url); + if (mPermissionsChecker == null) + mPermissionsChecker = new PermissionHelper(mContext, this); + if (mPermissionsChecker.lacksPermissions(getPermissions())) { //瀛樺偍鏉冮檺鏈紑鍚� + mPermissionsChecker.showNormalDialog(); } else { this.type = type; this.imgurl = url; @@ -392,10 +455,10 @@ final String urls = json.optString("urls"); - String[] str = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, - Manifest.permission.WRITE_EXTERNAL_STORAGE}; - if (lacksPermissions(str)) {//缂哄皯鏉冮檺 - generalBackCallback.onSuccess(type, null); + if (mPermissionsChecker == null) + mPermissionsChecker = new PermissionHelper(mContext, this); + if (mPermissionsChecker.lacksPermissions(getPermissions())) { //瀛樺偍鏉冮檺鏈紑鍚� + mPermissionsChecker.showNormalDialog(); } else { List<String> urlList = new ArrayList<>(); try { @@ -519,7 +582,10 @@ mttRewardVideoAd.setRewardAdInteractionListener(new TTRewardVideoAd.RewardAdInteractionListener() { @Override public void onAdShow() { - + com.alibaba.fastjson.JSONObject result = new com.alibaba.fastjson.JSONObject(); + result.put("code", 201); + result.put("msg", "骞垮憡寮�濮嬪睍绀�"); + handler.setProgressData(result); } @Override @@ -539,7 +605,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 +613,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); @@ -594,6 +660,29 @@ ToastUtil.showToast(view, view.getContext(), Toast.LENGTH_SHORT, Gravity.CENTER); } }); + } + + + @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);//寮哄埗妫�娴嬫洿鏂� } @@ -665,7 +754,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<>(); @@ -879,4 +968,5 @@ public void requestPermissionsFail() { // Toast.makeText(this, "浣犱互鎷掔粷鏉冮檺", Toast.LENGTH_SHORT).show(); } + } -- Gitblit v1.8.0