Search in sources :

Example 1 with InjectedChromeClient

use of cn.pedant.SafeWebViewBridge.InjectedChromeClient in project 91Pop by DanteAndroid.

the class Browse91PornActivity method onCreate.

@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_browse91_porn);
    ButterKnife.bind(this);
    initAppBar();
    isNightModel = dataManager.isOpenNightMode();
    historyIdStack = new Stack<>();
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setAppCacheEnabled(true);
    webSettings.setAppCachePath(AppCacheUtils.getRxCacheDir(context).getAbsolutePath());
    mWebView.setWebChromeClient(new InjectedChromeClient("HostApp", HostJsScope.class));
    mWebView.setBackgroundColor(0);
    mWebView.setBackgroundResource(0);
    mWebView.setVisibility(View.INVISIBLE);
    mWebView.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (url.contains("tid=")) {
                int starIndex = url.indexOf("tid=");
                String tidStr = StringUtils.subString(url, starIndex + 4, starIndex + 10);
                if (!TextUtils.isEmpty(tidStr) && TextUtils.isDigitsOnly(tidStr)) {
                    Long id = Long.parseLong(tidStr);
                    presenter.loadContent(id, isNightModel);
                    historyIdStack.push(id);
                } else {
                    Logger.t(TAG).d(tidStr);
                    showMessage("暂不支持直接打开此链接", TastyToast.INFO);
                }
            }
            return true;
        }
    });
    AppUtils.setColorSchemeColors(context, swipeLayout);
    forum91PronItem = (Forum91PronItem) getIntent().getSerializableExtra(Keys.KEY_INTENT_BROWSE_FORUM_91_PORN_ITEM);
    presenter.loadContent(forum91PronItem.getTid(), isNightModel);
    historyIdStack.push(forum91PronItem.getTid());
    imageList = new ArrayList<>();
    boolean needShowTip = dataManager.isViewPorn91ForumContentShowTip();
    if (needShowTip) {
    // showTipDialog();
    }
    fabFunction.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showOpenNewForum();
        }
    });
}
Also used : BindView(butterknife.BindView) View(android.view.View) WebView(android.webkit.WebView) InjectedChromeClient(cn.pedant.SafeWebViewBridge.InjectedChromeClient) WebSettings(android.webkit.WebSettings) HostJsScope(com.dante.data.model.HostJsScope) WebView(android.webkit.WebView) WebViewClient(android.webkit.WebViewClient) SuppressLint(android.annotation.SuppressLint)

Aggregations

SuppressLint (android.annotation.SuppressLint)1 View (android.view.View)1 WebSettings (android.webkit.WebSettings)1 WebView (android.webkit.WebView)1 WebViewClient (android.webkit.WebViewClient)1 BindView (butterknife.BindView)1 InjectedChromeClient (cn.pedant.SafeWebViewBridge.InjectedChromeClient)1 HostJsScope (com.dante.data.model.HostJsScope)1