From cbb88109494ffc7916f6639c20ce05c0cec941a9 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 07 四月 2021 15:07:45 +0800
Subject: [PATCH] 3.9.1bug修复

---
 BuWanVideo/src/com/weikou/beibeivideo/util/browser/BWJavaInterface.java |  115 +++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 103 insertions(+), 12 deletions(-)

diff --git a/BuWanVideo/src/com/weikou/beibeivideo/util/browser/BWJavaInterface.java b/BuWanVideo/src/com/weikou/beibeivideo/util/browser/BWJavaInterface.java
index 2912411..9359e6d 100644
--- a/BuWanVideo/src/com/weikou/beibeivideo/util/browser/BWJavaInterface.java
+++ b/BuWanVideo/src/com/weikou/beibeivideo/util/browser/BWJavaInterface.java
@@ -1,6 +1,7 @@
 package com.weikou.beibeivideo.util.browser;
 
 import android.app.Activity;
+import android.app.Dialog;
 import android.content.Intent;
 import android.content.pm.PackageManager;
 import android.support.v4.content.ContextCompat;
@@ -8,8 +9,13 @@
 import android.widget.ImageView;
 import android.widget.TextView;
 
+import com.alibaba.fastjson.JSON;
 import com.lcjian.library.util.common.StringUtils;
 import com.tencent.smtt.sdk.WebView;
+import com.weikou.beibeivideo.entity.JumpDetail;
+import com.weikou.beibeivideo.ui.dialog.LoadingDialogUtil;
+import com.weikou.beibeivideo.ui.login.LoginActivity;
+import com.weikou.beibeivideo.ui.login.PhoneLoginActivity;
 import com.weikou.beibeivideo.util.AlibcTradeUtil;
 import com.weikou.beibeivideo.util.JumpActivityUtil;
 
@@ -24,14 +30,15 @@
     TextView tv_top_bar_middle, tv_top_bar_left2, tv_top_bar_right;
     ImageView iv_right;
     WebView webview;
-    private boolean boo = false;
+    private Dialog loadingDialog;
 
     public BWJavaInterface(Activity activity, WebView webview) {
         super(activity);
         mContext = activity;
         this.webview = webview;
-        boo = true;
+        loadingDialog = LoadingDialogUtil.getLoadingDialog(activity, "");
     }
+
 
     public BWJavaInterface(Activity activity, TextView tv_top_bar_middle
             , TextView tv_top_bar_left2, TextView tv_top_bar_right
@@ -43,12 +50,39 @@
         this.tv_top_bar_right = tv_top_bar_right;
         this.iv_right = iv_right;
         this.webview = webview;
+        loadingDialog = LoadingDialogUtil.getLoadingDialog(activity, "");
+    }
+
+
+    @JavascriptInterface
+    public void showLoading() {
+        if (loadingDialog != null && !loadingDialog.isShowing() && mContext != null) {
+
+            mContext.runOnUiThread(new Runnable() {
+                @Override
+                public void run() {
+                    loadingDialog.show();
+                }
+            });
+        }
+    }
+
+    @JavascriptInterface
+    public void hideLoading() {
+        if (loadingDialog != null && loadingDialog.isShowing() && mContext != null) {
+            mContext.runOnUiThread(new Runnable() {
+                @Override
+                public void run() {
+                    loadingDialog.dismiss();
+                }
+            });
+        }
     }
 
     @JavascriptInterface
     public void setTitle(final String title) {
 //            tv_top_bar_middle.setText(title);
-        if (!boo)
+        if (tv_top_bar_middle != null)
             tv_top_bar_middle.post(new Runnable() {
                 @Override
                 public void run() {
@@ -92,19 +126,29 @@
             }
         }
         mContext.startActivity(intent);
-        if (!boo)
-            mContext.finish();
+        mContext.finish();
     }
 
     @JavascriptInterface
     public void finishPage() {
-        if (!boo)
-            iv_right.post(new Runnable() {
-                @Override
-                public void run() {
-                    mContext.finish();
-                }
-            });
+        mContext.runOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                mContext.finish();
+            }
+        });
+    }
+
+
+    @JavascriptInterface
+    public void finishPageWithResultOK() {
+        mContext.runOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                mContext.setResult(Activity.RESULT_OK);
+                mContext.finish();
+            }
+        });
     }
 
     /**
@@ -117,6 +161,51 @@
         if (StringUtils.isEmpty(url))
             return;
         AlibcTradeUtil.openAuthLink(mContext, url);
+    }
+
+    /**
+     * 鐧诲綍
+     */
+    @JavascriptInterface
+    public void login() {
+        Intent intent = new Intent(mContext, LoginActivity.class);
+        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        mContext.startActivity(intent);
+    }
+
+
+    @JavascriptInterface
+    public void jumpWeb() {
+        Intent intent = new Intent(mContext, LoginActivity.class);
+        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        mContext.startActivity(intent);
+    }
+
+    /**
+     * 鐢佃瘽鍙风爜缁戝畾
+     */
+    @JavascriptInterface
+    public void bindPhone() {
+        Intent intent = new Intent(mContext, PhoneLoginActivity.class);
+        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        intent.putExtra("login", false);
+        mContext.startActivity(intent);
+    }
+
+    /**
+     * 璺宠浆寰俊灏忕▼搴�
+     *
+     * @param userName
+     * @param path
+     */
+    @JavascriptInterface
+    public void jumpWXXCX(String userName, String path) {
+        JumpDetail jumpDetail = new JumpDetail();
+        jumpDetail.setType("wxxcx");
+        com.alibaba.fastjson.JSONObject params = new com.alibaba.fastjson.JSONObject();
+        params.put("userName", userName);
+        params.put("path", path);
+        JumpActivityUtil.jumpPage(mContext, jumpDetail, params);
     }
 
     // 鍒ゆ柇鏉冮檺闆嗗悎 鏄惁鎺堟潈 false鎺堟潈 true鏈巿鏉�
@@ -134,4 +223,6 @@
         //鏉冮檺鏈巿鏉�
         return ContextCompat.checkSelfPermission(mContext, permission) == PackageManager.PERMISSION_DENIED;
     }
+
+
 }

--
Gitblit v1.8.0