}
private void addNewTab(String url, boolean moveToTab) {
+ // Clear the focus from the URL edit text, so that it will be populated with the information from the new tab.
+ urlEditText.clearFocus();
+
// Get the new page number. The page numbers are 0 indexed, so the new page number will match the current count.
int newTabNumber = tabLayout.getTabCount();
// Get the WebView tab fragment.
WebViewTabFragment webViewTabFragment = webViewPagerAdapter.getPageFragment(i);
- // Get the fragment view.
- View fragmentView = webViewTabFragment.getView();
+ // Get the WebView frame layout.
+ FrameLayout webViewFrameLayout = (FrameLayout) webViewTabFragment.getView();
// Only wipe out the WebView if it exists.
- if (fragmentView != null) {
+ if (webViewFrameLayout != null) {
// Get the nested scroll WebView from the tab fragment.
- NestedScrollWebView nestedScrollWebView = fragmentView.findViewById(R.id.nestedscroll_webview);
+ NestedScrollWebView nestedScrollWebView = webViewFrameLayout.findViewById(R.id.nestedscroll_webview);
// Clear SSL certificate preferences for this WebView.
nestedScrollWebView.clearSslPreferences();
// Clear the back/forward history for this WebView.
nestedScrollWebView.clearHistory();
+ // Remove all the views from the frame layout.
+ webViewFrameLayout.removeAllViews();
+
// Destroy the internal state of the WebView.
nestedScrollWebView.destroy();
}