diff --git a/common/src/main/java/com/yunbao/common/activity/WebViewActivity.java b/common/src/main/java/com/yunbao/common/activity/WebViewActivity.java index 604bb9feb..c124caad8 100644 --- a/common/src/main/java/com/yunbao/common/activity/WebViewActivity.java +++ b/common/src/main/java/com/yunbao/common/activity/WebViewActivity.java @@ -139,7 +139,7 @@ public class WebViewActivity extends AbsActivity { } }); - mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, mWebView).setPageClose(true).setLiveZhuangBana(false), "androidObject"); + mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, mWebView).setPageClose(true).setLiveZhuangBana(false), "androidObject"); mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口 mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setDomStorageEnabled(true); diff --git a/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java b/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java index 006eec22f..a1a3200a4 100644 --- a/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java +++ b/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java @@ -40,6 +40,7 @@ public class JavascriptInterfaceUtils { private boolean dialogClose = false; //同名activity跳转问题 private boolean LiveZhuangBana = true; + private static JavascriptInterfaceUtils sInstance; public JavascriptInterfaceUtils setPageClose(boolean pageClose) { this.pageClose = pageClose; @@ -56,9 +57,21 @@ public class JavascriptInterfaceUtils { return this; } - public JavascriptInterfaceUtils(Activity mContext, WebView mWebView) { + public JavascriptInterfaceUtils setmContext(Activity mContext, WebView mWebView) { this.mContext = mContext; this.mWebView = mWebView; + return this; + } + + public static JavascriptInterfaceUtils getInstance() { + if (sInstance == null) { + synchronized (CityUtil.class) { + if (sInstance == null) { + sInstance = new JavascriptInterfaceUtils(); + } + } + } + return sInstance; } @@ -453,6 +466,7 @@ public class JavascriptInterfaceUtils { .setData(json)); } + @JavascriptInterface public void setHeight(String height, String width) { if ("0".equals(height)) { diff --git a/live/src/main/java/com/yunbao/live/activity/WebViewActivityMedal.java b/live/src/main/java/com/yunbao/live/activity/WebViewActivityMedal.java index e92136c1e..880ac0262 100644 --- a/live/src/main/java/com/yunbao/live/activity/WebViewActivityMedal.java +++ b/live/src/main/java/com/yunbao/live/activity/WebViewActivityMedal.java @@ -140,7 +140,7 @@ public class WebViewActivityMedal extends AbsActivity { } }); - mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, mWebView), "androidObject"); + mWebView.addJavascriptInterface( JavascriptInterfaceUtils.getInstance().setmContext(mContext, mWebView), "androidObject"); mWebView.getSettings().setJavaScriptEnabled(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); diff --git a/live/src/main/java/com/yunbao/live/activity/ZhuangBanActivity.java b/live/src/main/java/com/yunbao/live/activity/ZhuangBanActivity.java index c71978e9d..f5fc8f859 100644 --- a/live/src/main/java/com/yunbao/live/activity/ZhuangBanActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/ZhuangBanActivity.java @@ -199,7 +199,7 @@ public class ZhuangBanActivity extends AbsActivity { } }); - mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, mWebView) + mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, mWebView) .setPageClose(true) .setLiveZhuangBana(true), "androidObject"); mWebView.getSettings().setJavaScriptEnabled(true); diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveFansFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveFansFragment.java index f9859630f..513c094ce 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveFansFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveFansFragment.java @@ -95,7 +95,7 @@ public class LiveFansFragment extends AbsDialogFragment { }); mWebView.getSettings().setJavaScriptEnabled(true); // 是否开启JS支持 - mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, mWebView).setPageClose(false), "androidObject"); + mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, mWebView).setPageClose(false), "androidObject"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); } diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveGameDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveGameDialogFragment.java index 15b6078a2..46699371b 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveGameDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveGameDialogFragment.java @@ -159,7 +159,7 @@ public class LiveGameDialogFragment extends AbsDialogFragment { mWebView = (WebView) findViewById(R.id.rlWebview); tabLayout = (TabLayout) findViewById(R.id.tabLayout); layout = (LinearLayout) findViewById(R.id.bg_layout); - mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(getActivity(), mWebView) + mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(getActivity(), mWebView) .setLiveZhuangBana(true). setDialogClose(true). setPageClose(false), "androidObject"); diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java index 4cfe62d2c..389575861 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java @@ -146,7 +146,7 @@ public class LiveHDDialogFragment extends AbsDialogFragment { mWebView = (WebView) findViewById(R.id.rlWebview); htmlError = (TextView) findViewById(R.id.html_error); findViewById(R.id.btn_back).setOnClickListener(v -> dismiss()); - mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(getActivity(), mWebView) + mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(getActivity(), mWebView) .setLiveZhuangBana(true). setDialogClose(true). setPageClose(false), "androidObject"); diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveOneDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveOneDialogFragment.java index a7601e236..4bc11689f 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveOneDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveOneDialogFragment.java @@ -76,7 +76,7 @@ public class LiveOneDialogFragment extends AbsDialogFragment { public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mWebView = (WebView) findViewById(R.id.rlWebview); - mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, mWebView), "androidObject"); + mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, mWebView), "androidObject"); mWebView.getSettings().setJavaScriptEnabled(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); diff --git a/live/src/main/java/com/yunbao/live/views/TurnTableWebViewHolder.java b/live/src/main/java/com/yunbao/live/views/TurnTableWebViewHolder.java index a077b38af..74dd4981b 100644 --- a/live/src/main/java/com/yunbao/live/views/TurnTableWebViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/TurnTableWebViewHolder.java @@ -75,7 +75,7 @@ public class TurnTableWebViewHolder extends AbsLivePageViewHolder implements Vie }); - mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, mWebView), "androidObject"); + mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, mWebView), "androidObject"); mWebView.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { diff --git a/live/src/main/java/com/yunbao/live/views/WishlistWebViewHolder.java b/live/src/main/java/com/yunbao/live/views/WishlistWebViewHolder.java index 2202af9d1..8d5cd7e3e 100644 --- a/live/src/main/java/com/yunbao/live/views/WishlistWebViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/WishlistWebViewHolder.java @@ -97,7 +97,7 @@ public class WishlistWebViewHolder extends AbsLivePageViewHolder implements View // 自适应 屏幕大小界面 webSettings.setLoadWithOverviewMode(true); - mWebView.addJavascriptInterface(new JavascriptInterfaceUtils((Activity) mContext, mWebView).setPageClose(false), "androidObject"); + mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext((Activity) mContext, mWebView).setPageClose(false), "androidObject"); mWebView.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { diff --git a/main/src/main/java/com/yunbao/main/activity/GoogleFragment.java b/main/src/main/java/com/yunbao/main/activity/GoogleFragment.java index 46329371f..a987649b1 100644 --- a/main/src/main/java/com/yunbao/main/activity/GoogleFragment.java +++ b/main/src/main/java/com/yunbao/main/activity/GoogleFragment.java @@ -6,18 +6,17 @@ import static com.yunbao.common.CommonAppContext.mFirebaseAnalytics; import static com.yunbao.main.activity.MyWalletActivity.dis; import android.annotation.SuppressLint; -import android.app.Activity; +import android.app.ProgressDialog; import android.os.Bundle; import android.os.Handler; -import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.webkit.JavascriptInterface; import android.webkit.WebSettings; import android.webkit.WebView; -import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import com.adjust.sdk.Adjust; @@ -28,19 +27,13 @@ import com.google.android.gms.ads.identifier.AdvertisingIdClient; import com.google.android.gms.common.GooglePlayServicesNotAvailableException; import com.google.android.gms.common.GooglePlayServicesRepairableException; import com.yunbao.common.CommonAppConfig; -import com.yunbao.common.event.JavascriptInterfaceEvent; import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.HttpCallback; -import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.GoogleBillingUtilNew; -import com.yunbao.common.utils.JavascriptInterfaceUtils; import com.yunbao.common.utils.ToastUtil; import com.yunbao.main.R; import com.yunbao.main.views.TestWebViewClient; -import org.greenrobot.eventbus.Subscribe; -import org.greenrobot.eventbus.ThreadMode; - import java.io.IOException; import java.util.List; @@ -54,24 +47,11 @@ public class GoogleFragment extends Fragment { private WebView rlWebview; private String url; String adid = null; - private Activity mContext; @SuppressLint("ValidFragment") - public GoogleFragment(Activity context, String urls) { + public GoogleFragment(String urls) { url = urls; - mContext = context; - } - - @Override - public void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - Bus.getOn(this); - } - - @Override - public void onDetach() { - super.onDetach(); - Bus.getOff(this); + Log.e("google", "111aa"); } @Override @@ -114,7 +94,7 @@ public class GoogleFragment extends Fragment { webSettings.setBuiltInZoomControls(true); // 是否支持缩放变焦,前提是支持缩放 - rlWebview.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, rlWebview).setPageClose(true), "androidObject"); + rlWebview.addJavascriptInterface(new JsInteration(), "androidObject"); TestWebViewClient testWebViewClient = new TestWebViewClient(getActivity(), rlWebview); @@ -131,106 +111,122 @@ public class GoogleFragment extends Fragment { } + private Handler payHandler = new Handler(); + //js调用原生 + public class JsInteration { + + + @JavascriptInterface + public void androidNewGoToGooglePay(String ProductId, String OrderNumber, String MoneyUsd) { + Log.e(TAG, "ProductId" + ProductId + "OrderNumber" + OrderNumber + "MoneyUsd" + MoneyUsd); + mProductId = ProductId; + mOrderid = OrderNumber; + MoneyUsds = MoneyUsd; +// googleBillingUtil.purchaseInApp(getActivity(), mProductId); + GoogleBillingUtilNew.getInstance().setBillingListener(new GoogleBillingUtilNew.GoogleBillingListener() { + @Override + public void onPaySuccess(List list) { + for (Purchase purchase : list) { + for (int i = 0; i < list.size(); i++) { + int finalI = i; + payHandler.post(new Runnable() { + @Override + public void run() { + CommonHttpUtil.notifyGoogle(list.get(finalI).getPurchaseToken(), list.get(finalI).getOrderId(), mProductId, mOrderid, adid, new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0) { + Bundle params = new Bundle(); + params.putString("currency", "HKD"); + params.putString("money", MoneyUsds); + logger.logEvent("FB_iap_Play", params); + + + Bundle fb_params = new Bundle(); + fb_params.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, "HKD"); + fb_params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_ID, mProductId); + + //fb官方事件记录充值 + logger.logEvent(AppEventsConstants.EVENT_NAME_PURCHASED, + Double.parseDouble(MoneyUsds), + fb_params); + + //Google官方充值通知 + Bundle google_params = new Bundle(); + google_params.putString("currency", "HKD"); + google_params.putString("product_id", mProductId); + google_params.putString("transaction_id", mOrderid); + google_params.putString("value", MoneyUsds); + google_params.putString("price", MoneyUsds); + google_params.putString("quantity", "1"); + + mFirebaseAnalytics.logEvent("FS_iap_Play", google_params); + + + AdjustEvent adjustEvent1 = new AdjustEvent("cgssol"); + Adjust.trackEvent(adjustEvent1); + CommonHttpUtil.setAdvertisingChannels("cgssol", new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0) { + logger.logEvent("FB_iap_users", null); + mFirebaseAnalytics.logEvent("FS_iap_users", null); + } + } + }); + + AdjustEvent adjustEvent2 = new AdjustEvent("tr8lb9"); + adjustEvent2.setRevenue(Double.parseDouble(MoneyUsds),"HKD"); + adjustEvent2.addCallbackParameter("GOrderid",purchase.getOrderId()); + adjustEvent2.addCallbackParameter("POrderid",mOrderid); + adjustEvent2.addCallbackParameter("Uid", CommonAppConfig.getInstance().getUid()); + adjustEvent2.addCallbackParameter("GADid",adid); + adjustEvent2.setOrderId(mOrderid); + Adjust.trackEvent(adjustEvent2); + + dis(); + ToastUtil.show("支付成功"); + } + } + }); + } + }); + } + Log.e("谷歌支付", purchase.toString()); + } + } + + @Override + public void onPayFailed(int code, String msg) { + + } + }).checkSku(ProductId) + ; + //下单 + Bundle params = new Bundle(); + params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_ID, mProductId); + params.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, "HKD"); + logger.logEvent(AppEventsConstants.EVENT_NAME_INITIATED_CHECKOUT, Double.parseDouble(MoneyUsds), + params); + + } + + @JavascriptInterface + public void androidMethodBack() { + getActivity().onBackPressed(); + + } + + @JavascriptInterface + public void androidGoBack() { + getActivity().onBackPressed(); + } + } public void release() { } - - @Subscribe(threadMode = ThreadMode.MAIN) - public void onJavascriptInterfaceEvent(JavascriptInterfaceEvent event) { - if (!TextUtils.isEmpty(event.getMethod())) { - if (TextUtils.equals(event.getMethod(), "androidNewGoToGooglePay")) { - mProductId = event.getProductId(); - mOrderid = event.getOrderNumber(); - MoneyUsds = event.getMoneyUsd(); - GoogleBillingUtilNew.getInstance().setBillingListener(new GoogleBillingUtilNew.GoogleBillingListener() { - @Override - public void onPaySuccess(List list) { - for (Purchase purchase : list) { - for (int i = 0; i < list.size(); i++) { - int finalI = i; - payHandler.post(new Runnable() { - @Override - public void run() { - CommonHttpUtil.notifyGoogle(list.get(finalI).getPurchaseToken(), list.get(finalI).getOrderId(), mProductId, mOrderid, adid, new HttpCallback() { - @Override - public void onSuccess(int code, String msg, String[] info) { - if (code == 0) { - Bundle params = new Bundle(); - params.putString("currency", "HKD"); - params.putString("money", MoneyUsds); - logger.logEvent("FB_iap_Play", params); - - - Bundle fb_params = new Bundle(); - fb_params.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, "HKD"); - fb_params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_ID, mProductId); - - //fb官方事件记录充值 - logger.logEvent(AppEventsConstants.EVENT_NAME_PURCHASED, - Double.parseDouble(MoneyUsds), - fb_params); - - //Google官方充值通知 - Bundle google_params = new Bundle(); - google_params.putString("currency", "HKD"); - google_params.putString("product_id", mProductId); - google_params.putString("transaction_id", mOrderid); - google_params.putString("value", MoneyUsds); - google_params.putString("price", MoneyUsds); - google_params.putString("quantity", "1"); - - mFirebaseAnalytics.logEvent("FS_iap_Play", google_params); - - - AdjustEvent adjustEvent1 = new AdjustEvent("cgssol"); - Adjust.trackEvent(adjustEvent1); - CommonHttpUtil.setAdvertisingChannels("cgssol", new HttpCallback() { - @Override - public void onSuccess(int code, String msg, String[] info) { - if (code == 0) { - logger.logEvent("FB_iap_users", null); - mFirebaseAnalytics.logEvent("FS_iap_users", null); - } - } - }); - - AdjustEvent adjustEvent2 = new AdjustEvent("tr8lb9"); - adjustEvent2.setRevenue(Double.parseDouble(MoneyUsds), "HKD"); - adjustEvent2.addCallbackParameter("GOrderid", purchase.getOrderId()); - adjustEvent2.addCallbackParameter("POrderid", mOrderid); - adjustEvent2.addCallbackParameter("Uid", CommonAppConfig.getInstance().getUid()); - adjustEvent2.addCallbackParameter("GADid", adid); - adjustEvent2.setOrderId(mOrderid); - Adjust.trackEvent(adjustEvent2); - - dis(); - ToastUtil.show("支付成功"); - } - } - }); - } - }); - } - Log.e("谷歌支付", purchase.toString()); - } - } - - @Override - public void onPayFailed(int code, String msg) { - Log.e("谷歌支付",code+msg); - } - }).checkSku(event.getProductId()) - ; - //下单 - Bundle params = new Bundle(); - params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_ID, mProductId); - params.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, "HKD"); - logger.logEvent(AppEventsConstants.EVENT_NAME_INITIATED_CHECKOUT, Double.parseDouble(MoneyUsds), - params); - } - } - } } + diff --git a/main/src/main/java/com/yunbao/main/activity/MyWalletActivity.java b/main/src/main/java/com/yunbao/main/activity/MyWalletActivity.java index 0317e9bd5..4253f67ba 100644 --- a/main/src/main/java/com/yunbao/main/activity/MyWalletActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MyWalletActivity.java @@ -121,26 +121,26 @@ public class MyWalletActivity extends AbsActivity { Log.i("tss", "首充"); if (CommonAppConfig.IS_GOOGLE_PLAY == false) { //链接版本 - fragments = new Fragment[]{new GoogleFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&first_page=1&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), - new GoogleFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), + fragments = new Fragment[]{new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&first_page=1&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), + new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), new WalletFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd")}; } else { rView.setVisibility(View.VISIBLE); - fragments = new Fragment[]{new GoogleFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), - new GoogleFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaygole&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), + fragments = new Fragment[]{new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), + new GoogleFragment( CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaygole&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), new WalletFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken())}; } } else { if (CommonAppConfig.IS_GOOGLE_PLAY == false) { Log.i("tss", "不是首充"); //链接版本 - fragments = new Fragment[]{new GoogleFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), - new GoogleFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), + fragments = new Fragment[]{new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), + new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), new WalletFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd")}; } else { rView.setVisibility(View.VISIBLE); - fragments = new Fragment[]{new GoogleFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), - new GoogleFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaygole&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), + fragments = new Fragment[]{new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), + new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaygole&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), new WalletFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken())}; } } diff --git a/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity.java b/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity.java index dc4157cc8..630d9812c 100644 --- a/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity.java @@ -200,7 +200,7 @@ public class MyWebViewActivity extends AbsActivity { } }); - mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, mWebView).setPageClose(true), "androidObject"); + mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, mWebView).setPageClose(true), "androidObject"); mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口 mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setDomStorageEnabled(true); diff --git a/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity2.java b/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity2.java index 441458fb6..f3d0539df 100644 --- a/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity2.java +++ b/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity2.java @@ -172,7 +172,7 @@ public class MyWebViewActivity2 extends AbsActivity { } }); - mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, mWebView) + mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, mWebView) .setPageClose(true) .setLiveZhuangBana(false), "androidObject"); mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口 diff --git a/main/src/main/java/com/yunbao/main/activity/RechargeActivity.java b/main/src/main/java/com/yunbao/main/activity/RechargeActivity.java index bf8986c3d..23d607c06 100644 --- a/main/src/main/java/com/yunbao/main/activity/RechargeActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/RechargeActivity.java @@ -32,7 +32,7 @@ public class RechargeActivity extends AbsActivity { webSettings.setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口 - rlWebview.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, rlWebview).setPageClose(true), "androidObject"); + rlWebview.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, rlWebview).setPageClose(true), "androidObject"); TestWebViewClient testWebViewClient = new TestWebViewClient(this, rlWebview); diff --git a/main/src/main/java/com/yunbao/main/activity/RewardActivity.java b/main/src/main/java/com/yunbao/main/activity/RewardActivity.java index d10fac9f3..80d252171 100644 --- a/main/src/main/java/com/yunbao/main/activity/RewardActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/RewardActivity.java @@ -153,7 +153,7 @@ public class RewardActivity extends AbsActivity { }); mWebView.getSettings().setJavaScriptEnabled(true); // 是否开启JS支持 mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口 - mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, mWebView) + mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, mWebView) .setPageClose(true) .setLiveZhuangBana(false), "androidObject"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { diff --git a/main/src/main/java/com/yunbao/main/activity/WalletFragment.java b/main/src/main/java/com/yunbao/main/activity/WalletFragment.java index 2c15d7f44..09c3be902 100644 --- a/main/src/main/java/com/yunbao/main/activity/WalletFragment.java +++ b/main/src/main/java/com/yunbao/main/activity/WalletFragment.java @@ -53,7 +53,7 @@ public class WalletFragment extends Fragment { webSettings.setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口 - rlWebview.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, rlWebview).setPageClose(true), "androidObject"); + rlWebview.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, rlWebview).setPageClose(true), "androidObject"); TestWebViewClient testWebViewClient = new TestWebViewClient(getActivity(), rlWebview); diff --git a/main/src/main/java/com/yunbao/main/activity/WeekWebViewActivity.java b/main/src/main/java/com/yunbao/main/activity/WeekWebViewActivity.java index ab9955c7d..396c397d8 100644 --- a/main/src/main/java/com/yunbao/main/activity/WeekWebViewActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/WeekWebViewActivity.java @@ -135,7 +135,7 @@ public class WeekWebViewActivity extends AbsActivity { } }); - mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, mWebView).setPageClose(true), "androidObject"); + mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, mWebView).setPageClose(true), "androidObject"); mWebView.getSettings().setJavaScriptEnabled(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); diff --git a/main/src/main/java/com/yunbao/main/activity/ZhuangBanActivity.java b/main/src/main/java/com/yunbao/main/activity/ZhuangBanActivity.java index bc3d116c8..eabfcd4c7 100644 --- a/main/src/main/java/com/yunbao/main/activity/ZhuangBanActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/ZhuangBanActivity.java @@ -175,7 +175,7 @@ public class ZhuangBanActivity extends AbsActivity { mWebView.getSettings().setJavaScriptEnabled(true); // 是否开启JS支持 mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口 mWebView.getSettings().setDomStorageEnabled(true); - mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, mWebView) + mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, mWebView) .setPageClose(true) .setLiveZhuangBana(false), "androidObject"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeCommunityViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeCommunityViewHolder.java index eb76f5283..b5c4924f5 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeCommunityViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeCommunityViewHolder.java @@ -111,7 +111,7 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);// 不加载缓存内容 mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口 - mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(nowMainActivity, mWebView), "androidObject"); + mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(nowMainActivity, mWebView), "androidObject"); rootView.addView(mWebView);