From 1981dee5aec45793d3c4ebdbc4e637528c71b3c5 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期三, 03 二月 2021 19:20:47 +0800 Subject: [PATCH] 'PPTV' --- BuWanVideo/src/com/weikou/beibeivideo/util/browser/BWJavaInterface.java | 86 ++++++++++++++++++++++++++++++++++-------- 1 files changed, 69 insertions(+), 17 deletions(-) diff --git a/BuWanVideo/src/com/weikou/beibeivideo/util/browser/BWJavaInterface.java b/BuWanVideo/src/com/weikou/beibeivideo/util/browser/BWJavaInterface.java index 20a376f..5e92578 100644 --- a/BuWanVideo/src/com/weikou/beibeivideo/util/browser/BWJavaInterface.java +++ b/BuWanVideo/src/com/weikou/beibeivideo/util/browser/BWJavaInterface.java @@ -1,18 +1,21 @@ 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; import android.webkit.JavascriptInterface; -import android.webkit.WebView; import android.widget.ImageView; import android.widget.TextView; import com.lcjian.library.util.common.StringUtils; +import com.tencent.smtt.sdk.WebView; +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; -import com.weikou.beibeivideo.util.x5.X5WebView; import org.json.JSONException; import org.json.JSONObject; @@ -24,19 +27,20 @@ Activity mContext; TextView tv_top_bar_middle, tv_top_bar_left2, tv_top_bar_right; ImageView iv_right; - X5WebView webview; - private boolean boo = false; + WebView webview; + private Dialog loadingDialog; - public BWJavaInterface(Activity activity, X5WebView webview) { + 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 - , ImageView iv_right, X5WebView webview) { + , ImageView iv_right, WebView webview) { super(activity); mContext = activity; this.tv_top_bar_middle = tv_top_bar_middle; @@ -44,12 +48,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() { @@ -93,19 +124,17 @@ } } 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(); + } + }); } /** @@ -118,6 +147,27 @@ 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 bindPhone() { + Intent intent = new Intent(mContext, PhoneLoginActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent.putExtra("login", false); + mContext.startActivity(intent); } // 鍒ゆ柇鏉冮檺闆嗗悎 鏄惁鎺堟潈 false鎺堟潈 true鏈巿鏉� @@ -135,4 +185,6 @@ //鏉冮檺鏈巿鏉� return ContextCompat.checkSelfPermission(mContext, permission) == PackageManager.PERMISSION_DENIED; } + + } -- Gitblit v1.8.0