X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Factivities%2FMainWebViewActivity.kt;h=0dab90f19e458e0414bb153bf1eeaf182930867e;hp=8614ec7b8969eeb049b0227d2a4c7a17c37a78eb;hb=feca0fdd5129f23c694c00ef171d40c65f68ffce;hpb=bc1692b6c9d99726e7c6b7cf6a5c24f67f042b18 diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt index 8614ec7b..0dab90f1 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt @@ -3968,8 +3968,17 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook // Set the first page as the current WebView. setCurrentWebView(0) } else { // The first tab is not selected. - // Move to the selected tab. - webViewViewPager2.currentItem = savedTabPosition + // Create a handler move to the page. + val setCurrentPageHandler = Handler(Looper.getMainLooper()) + + // Create a runnable to move to the page. + val setCurrentPageRunnable = Runnable { + // Move to the page. + webViewViewPager2.currentItem = savedTabPosition + } + + // Move to the page after 50 milliseconds, which should be enough time to for the WebView state adapter to populate the restored pages. + setCurrentPageHandler.postDelayed(setCurrentPageRunnable, 50) } // Get the intent that started the app.