From 399ac289f80b7a40aa4210341db6b447cacdcf14 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 09 八月 2022 17:42:33 +0800
Subject: [PATCH] 广告升级,隐私政策整改

---
 app/src/main/java/com/tejia/lijin/app/util/web/RebateJavaInterfaceBS.java |  161 +++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 136 insertions(+), 25 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 d33a6c6..9d4100b 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);
             }
         }
     }
@@ -242,15 +291,30 @@
     }
 
 
+    /**
+     * 璺宠浆涓夋柟骞冲彴
+     *
+     * @param args
+     * @throws JSONException
+     */
     @JavascriptInterface
-    public void hiddenTopMenuCloseBtn() {
+    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()));
+    }
+
+
+    @JavascriptInterface
+    public void hiddenTopMenuCloseBtn(Object obj) {
         if (!boo)
             tv_top_bar_left2.setVisibility(View.GONE);
     }
 
 
     @JavascriptInterface
-    public void hideLoading() {
+    public void hideLoading(Object obj) {
         if (!boo)
             iv_right.post(new Runnable() {
                 @Override
@@ -263,7 +327,7 @@
     }
 
     @JavascriptInterface
-    public void showLoading() {
+    public void showLoading(Object obj) {
         if (!boo)
             iv_right.post(new Runnable() {
                 @Override
@@ -278,7 +342,7 @@
     }
 
     @JavascriptInterface
-    public void finishPage() {
+    public void finishPage(Object obj) {
         if (!boo)
             iv_right.post(new Runnable() {
                 @Override
@@ -325,7 +389,7 @@
 
 
     @JavascriptInterface
-    public void showSharePanel() {
+    public void showSharePanel(Object obj) {
         webShareDesc.setShare();
     }
 
@@ -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 {
@@ -479,8 +542,6 @@
                 TTAdNative mTTAdNative = TTAdSdk.getAdManager().createAdNative(mContext);
                 AdSlot adSlot = new AdSlot.Builder()
                         .setCodeId(pid)
-                        .setRewardName("閲戝竵") //濂栧姳鐨勫悕绉� 閫夊~
-                        .setRewardAmount(3)  //濂栧姳鐨勬暟閲� 閫夊~
 //                        .setUserID("tag123")//tag_id
                         .setMediaExtra("media_extra") //闄勫姞鍙傛暟
                         .setOrientation(TTAdConstant.VERTICAL) //蹇呭~鍙傛暟锛屾湡鏈涜棰戠殑鎾斁鏂瑰悜锛歍TAdConstant.HORIZONTAL 鎴� TTAdConstant.VERTICAL
@@ -490,6 +551,7 @@
                     //璇锋眰骞垮憡澶辫触
                     @Override
                     public void onError(int code, String message) {
+                        com.alibaba.fastjson.JSONObject result = new com.alibaba.fastjson.JSONObject();
                         result.put("code", 1);
                         result.put("msg", message);
                         handler.complete(result);
@@ -498,11 +560,26 @@
                     //瑙嗛骞垮憡鍔犺浇鍚庯紝瑙嗛璧勬簮缂撳瓨鍒版湰鍦扮殑鍥炶皟锛屽湪姝ゅ洖璋冨悗锛屾挱鏀炬湰鍦拌棰戯紝娴佺晠涓嶉樆濉炪��
                     @Override
                     public void onRewardVideoCached() {
+
                         //寮�鍙戣�呭仛涓�涓爣璇�
                         if (mttRewardVideoAd != null) {
                             mttRewardVideoAd.showRewardVideoAd(mContext, TTAdConstant.RitScenes.CUSTOMIZE_SCENES, "scenes_test");
                             mttRewardVideoAd = null;
                         }
+                        com.alibaba.fastjson.JSONObject result = new com.alibaba.fastjson.JSONObject();
+                        result.put("code", 100);
+                        result.put("msg", "缂撳瓨鎴愬姛");
+                        handler.setProgressData(result);
+                    }
+
+                    @Override
+                    public void onRewardVideoCached(TTRewardVideoAd ttRewardVideoAd) {
+                        mttRewardVideoAd=ttRewardVideoAd;
+                        //寮�鍙戣�呭仛涓�涓爣璇�
+                        com.alibaba.fastjson.JSONObject result = new com.alibaba.fastjson.JSONObject();
+                        result.put("code", 100);
+                        result.put("msg", "缂撳瓨鎴愬姛");
+                        handler.setProgressData(result);
                     }
 
                     //瑙嗛骞垮憡鐨勭礌鏉愬姞杞藉畬姣曪紝姣斿瑙嗛url绛夛紝鍦ㄦ鍥炶皟鍚庯紝鍙互鎾斁鍦ㄧ嚎瑙嗛锛岀綉缁滀笉濂藉彲鑳藉嚭鐜板姞杞界紦鍐诧紝褰卞搷浣撻獙銆�
@@ -513,7 +590,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
@@ -533,6 +613,7 @@
 
                             @Override
                             public void onVideoError() {
+                                com.alibaba.fastjson.JSONObject result = new com.alibaba.fastjson.JSONObject();
                                 result.put("code", 2);
                                 result.put("msg", "瑙嗛鍑洪敊");
                                 handler.complete(result);
@@ -540,9 +621,15 @@
 
                             @Override
                             public void onRewardVerify(boolean b, int i, String s, int i1, String s1) {
+                                com.alibaba.fastjson.JSONObject result = new com.alibaba.fastjson.JSONObject();
                                 result.put("code", 0);
                                 result.put("msg", "骞垮憡灞曠ず瀹屾垚");
                                 handler.complete(result);
+                            }
+
+                            @Override
+                            public void onRewardArrived(boolean b, int i, Bundle bundle) {
+
                             }
 
                             @Override
@@ -579,13 +666,36 @@
             @Override
             public void run() {
                 View view = LayoutInflater.from(mContext).inflate(R.layout.item_reward_ad_fail, null);
-                LinearLayout.LayoutParams params=new LinearLayout.LayoutParams(DimenUtils.getScreenWidth(mContext)*4/5,LinearLayout.LayoutParams.WRAP_CONTENT);
+                LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(DimenUtils.getScreenWidth(mContext) * 4 / 5, LinearLayout.LayoutParams.WRAP_CONTENT);
                 view.setLayoutParams(params);
                 TextView tv_content = view.findViewById(R.id.tv_content);
                 tv_content.setText(msg + "");
                 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);//寮哄埗妫�娴嬫洿鏂�
     }
 
 
@@ -657,7 +767,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<>();
@@ -667,13 +777,13 @@
         }
 
         if (urlList.size() > 0) {
-            showLoading();
+            showLoading(null);
             shareTempImgEntity = new ArrayList<>();
             //鍘讳笅杞�
             new DownLoadFile().downloadMultiImages(urlList, filePathList, mContext, new DownLoadFile.FileDownLoadListener() {
                 @Override
                 public void finish(List<File> fileList) {
-                    hideLoading();
+                    hideLoading(null);
                     //瀹屾垚涓嬭浇
 
                     if (fileList != null)
@@ -702,7 +812,7 @@
                 }
             });
         } else {
-            hideLoading();
+            hideLoading(null);
             if (type == 1)
                 shareHandler.sendEmptyMessage(platform);
             else {
@@ -766,9 +876,9 @@
 
                     ArrayList<Uri> uriList = new ArrayList<Uri>();
                     if (imageList != null)
-                        for (ShareImageEntity entity : imageList)
+                        for (ShareImageEntity entity : imageList) {
                             uriList.add(Tools.getImageContentUri(mContext, new File(entity.getFilePath())));
-
+                        }
                     if (platfrom == 1) {
                         ShareImageUtil.shareWXPictureByIntent(mContext, uriList);
                     } else if (platfrom == 2) {
@@ -871,4 +981,5 @@
     public void requestPermissionsFail() {
 //        Toast.makeText(this, "浣犱互鎷掔粷鏉冮檺", Toast.LENGTH_SHORT).show();
     }
+
 }

--
Gitblit v1.8.0