]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java
Fix a crash when opening a drawer while restarting. https://redmine.stoutner.com...
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / activities / MainWebViewActivity.java
index 16dfcaaf3e20164e325af872dfa4864d99d24772..38fae2ed2702872414432600b6e744418a2c6e9d 100644 (file)
@@ -454,10 +454,8 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
         tabLayout = findViewById(R.id.tablayout);
         swipeRefreshLayout = findViewById(R.id.swiperefreshlayout);
         webViewPager = findViewById(R.id.webviewpager);
-        fullScreenVideoFrameLayout = findViewById(R.id.full_screen_video_framelayout);
-
-        // Get a handle for the navigation view.
         NavigationView navigationView = findViewById(R.id.navigationview);
+        fullScreenVideoFrameLayout = findViewById(R.id.full_screen_video_framelayout);
 
         // Get a handle for the navigation menu.
         Menu navigationMenu = navigationView.getMenu();
@@ -3561,9 +3559,14 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook
                         inputMethodManager.hideSoftInputFromWindow(currentWebView.getWindowToken(), 0);
                     }
 
-                    // Clear the focus from from the URL text box and the WebView.  This removes any text selection markers and context menus, which otherwise draw above the open drawers.
+                    // Clear the focus from from the URL text box.  This removes any text selection markers and context menus, which otherwise draw above the open drawers.
                     urlEditText.clearFocus();
-                    currentWebView.clearFocus();
+
+                    // Clear the focus from from the WebView if it is not null, which can happen if a user opens a drawer while the browser is being resumed.
+                    if (currentWebView != null) {
+                        // Clearing the focus from the WebView removes any text selection markers and context menus, which otherwise draw above the open drawers.
+                        currentWebView.clearFocus();
+                    }
                 }
             }
         });