android.webkit.WebView#getParent ( )源码实例Demo

下面列出了android.webkit.WebView#getParent ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: sealrtc-android   文件: CallActivity.java
public void destroyWebView(WebView mWebView) {
    if (mWebView != null) {
        try {
            ViewParent parent = mWebView.getParent();
            if (parent != null) {
                ((ViewGroup) parent).removeView(mWebView);
            }
            mWebView.stopLoading();
            mWebView.getSettings().setJavaScriptEnabled(false);
            mWebView.clearHistory();
            mWebView.clearView();
            mWebView.removeAllViews();

            mWebView.destroy();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
源代码2 项目: AgentWeb   文件: AgentWebUtils.java
static final void clearWebView(WebView m) {
	if (m == null) {
		return;
	}
	if (Looper.myLooper() != Looper.getMainLooper()) {
		return;
	}
	m.loadUrl("about:blank");
	m.stopLoading();
	if (m.getHandler() != null) {
		m.getHandler().removeCallbacksAndMessages(null);
	}
	m.removeAllViews();
	ViewGroup mViewGroup = null;
	if ((mViewGroup = ((ViewGroup) m.getParent())) != null) {
		mViewGroup.removeView(m);
	}
	m.setWebChromeClient(null);
	m.setWebViewClient(null);
	m.setTag(null);
	m.clearHistory();
	m.destroy();
	m = null;
}
 
源代码3 项目: turbolinks-android   文件: TurbolinksView.java
/**
 * <p>Attach the swipeRefreshLayout, which contains the shared webView, to the TurbolinksView.</p>
 *
 * @param webView              The shared webView.
 * @param screenshotsEnabled   Indicates whether screenshots are enabled for the current session.
 * @param pullToRefreshEnabled Indicates whether pull to refresh is enabled for the current session.
 * @return True if the webView has been attached to a new parent, otherwise false
 */
boolean attachWebView(WebView webView, boolean screenshotsEnabled, boolean pullToRefreshEnabled) {
    if (webView.getParent() == refreshLayout) return false;

    refreshLayout.setEnabled(pullToRefreshEnabled);

    if (webView.getParent() instanceof TurbolinksSwipeRefreshLayout) {
        TurbolinksSwipeRefreshLayout previousRefreshLayout = (TurbolinksSwipeRefreshLayout) webView.getParent();
        TurbolinksView previousTurbolinksView = (TurbolinksView) previousRefreshLayout.getParent();

        if (screenshotsEnabled) previousTurbolinksView.screenshotView();

        try {
            // This is an admittedly hacky workaround, but it buys us some time as we investigate
            // a potential bug with Chrome 64, which is currently throwing an IllegalStateException
            // when accessibility services (like Talkback or 1password) are enabled.
            // We're tracking this bug on the Chromium issue tracker:
            // https://bugs.chromium.org/p/chromium/issues/detail?id=806108
            previousRefreshLayout.removeView(webView);
        } catch (Exception e) {
            previousRefreshLayout.removeView(webView);
        }
    }

    // Set the webview background to match the container background
    if (getBackground() instanceof ColorDrawable) {
        webView.setBackgroundColor(((ColorDrawable) getBackground()).getColor());
    }

    refreshLayout.addView(webView);
    return true;
}
 
源代码4 项目: tysq-android   文件: WebViewCache.java
/**
 * 存储webview
 * @param webView
 */
public void saveWebView(WebView webView){
    ViewGroup parent = (ViewGroup) webView.getParent();
    parent.removeView(webView);
    mWebViewList.add(webView);
}