X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Factivities%2FMainWebViewActivity.java;h=b54b3d05805e4edea9cf035699eb50cd7e8eba25;hp=cbf7c1e82e4720370c1fd09dba52242aa9648103;hb=d2c46729a14917017e48d88abc870909ba805700;hpb=3dff6df834d582f932795c72f6bdcf6f655ac593 diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java index cbf7c1e8..b54b3d05 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java @@ -189,10 +189,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // The WebView pager adapter is accessed from `HttpAuthenticationDialog`, `PinnedMismatchDialog`, and `SslCertificateErrorDialog`. It is also used in `onCreate()`, `onResume()`, and `addTab()`. public static WebViewPagerAdapter webViewPagerAdapter; - // The load URL on restart variables are public static so they can be accessed from `BookmarksActivity`. They are used in `onRestart()`. - public static boolean loadUrlOnRestart; - public static String urlToLoadOnRestart; - // `restartFromBookmarksActivity` is public static so it can be accessed from `BookmarksActivity`. It is also used in `onRestart()`. public static boolean restartFromBookmarksActivity; @@ -556,15 +552,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook } } - // Load the URL on restart (used when loading a bookmark). - if (loadUrlOnRestart) { - // Load the specified URL. - loadUrl(currentWebView, urlToLoadOnRestart); - - // Reset the load on restart tracker. - loadUrlOnRestart = false; - } - // Update the bookmarks drawer if returning from the Bookmarks activity. if (restartFromBookmarksActivity) { // Close the bookmarks drawer. @@ -3346,11 +3333,8 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Select the corresponding tab if it does not match the currently selected page. This will happen if the page was scrolled by creating a new tab. if (tabLayout.getSelectedTabPosition() != position) { - // Create a handler to select the tab. - Handler selectTabHandler = new Handler(); - - // Create a runnable to select the tab. - Runnable selectTabRunnable = () -> { + // Wait until the new tab has been created. + tabLayout.post(() -> { // Get a handle for the tab. TabLayout.Tab tab = tabLayout.getTabAt(position); @@ -3359,10 +3343,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Select the tab. tab.select(); - }; - - // Select the tab layout after 150 milliseconds, which leaves enough time for a new tab to be inflated. TODO. - selectTabHandler.postDelayed(selectTabRunnable, 150); + }); } }