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=1e41ca201686b4a502ddcf904b3ff11c20dd8bae;hp=de608492aade9b22fe3e09a62d0b1990155dc7df;hb=b664d689b9757ffd1fd224c85a9659d2f4df1204;hpb=83b0beda5a1374f43e0ea07b7fad4adee9365ea9 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 de608492..1e41ca20 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt @@ -4207,11 +4207,14 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook // Close the find on page bar if it is open. closeFindOnPage(null) - // Select the same page in the view pager. - webViewViewPager2.currentItem = tab.position + // Update the view pager when it has quiesced. Otherwise, if a page launched by a new intent on restart has not yet been created, the view pager will not be updated to match the tab layout. + webViewViewPager2.post { + // Select the same page in the view pager. + webViewViewPager2.currentItem = tab.position - // Set the current WebView. - setCurrentWebView(tab.position) + // Set the current WebView. + setCurrentWebView(tab.position) + } } override fun onTabUnselected(tab: TabLayout.Tab) {} @@ -4223,8 +4226,8 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook // Calculate the milliseconds since the last restart. This can be replaced by the simpler LocalDateTime once the minimum API >= 26. val millisecondsSinceLastRestart = Date().time - restartTime.time - // Only display the SSL certificate dialog if it has been at least 2 seconds since the last restart as deep restarts sometimes end up selecting a tab twice. - if (millisecondsSinceLastRestart > 2000) { + // Only display the SSL certificate dialog if it has been at least 3 seconds since the last restart as deep restarts sometimes end up selecting a tab twice. + if (millisecondsSinceLastRestart > 3000) { // Instantiate the View SSL Certificate dialog. val viewSslCertificateDialogFragment: DialogFragment = ViewSslCertificateDialog.displayDialog(currentWebView!!.webViewFragmentId, currentWebView!!.getFavoriteIcon())