X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Ffragments%2FWebViewTabFragment.kt;h=6f48043870f19683e8c3af2e29c7497e3142ad8f;hb=12042264a50769030361cf51b0ac197050209f0f;hp=5d37613c3427040d48c4a9cf61347ef26a9756ff;hpb=f3a2827543d388de53b27a124663c5f84af764c9;p=PrivacyBrowserAndroid.git diff --git a/app/src/main/java/com/stoutner/privacybrowser/fragments/WebViewTabFragment.kt b/app/src/main/java/com/stoutner/privacybrowser/fragments/WebViewTabFragment.kt index 5d37613c..6f480438 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/fragments/WebViewTabFragment.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/fragments/WebViewTabFragment.kt @@ -1,5 +1,5 @@ /* - * Copyright © 2019-2020,2022 Soren Stoutner . + * Copyright © 2019-2020,2022-2023 Soren Stoutner . * * This file is part of Privacy Browser Android . * @@ -43,7 +43,6 @@ private const val SAVED_NESTED_SCROLL_WEBVIEW_STATE = "saved_nested_scroll_webvi class WebViewTabFragment : Fragment() { // Define the public variables. - @JvmField // TODO. `@JvmField` can be removed once the entire project has been converted to Kotlin. var fragmentId = Calendar.getInstance().timeInMillis // The public interface is used to send information back to the parent activity. @@ -59,7 +58,6 @@ class WebViewTabFragment : Fragment() { private lateinit var nestedScrollWebView: NestedScrollWebView companion object { - @JvmStatic // TODO. `@JvmStatic` can be removed once the entire project has been converted to Kotlin. fun createPage(pageNumber: Int, url: String?): WebViewTabFragment { // Create an arguments bundle. val argumentsBundle = Bundle() @@ -79,8 +77,7 @@ class WebViewTabFragment : Fragment() { return webViewTabFragment } - @JvmStatic // TODO. `@JvmStatic` can be removed once the entire project has been converted to Kotlin. - fun restorePage(savedState: Bundle?, savedNestedScrollWebViewState: Bundle?): WebViewTabFragment { + fun restorePage(savedState: Bundle, savedNestedScrollWebViewState: Bundle): WebViewTabFragment { // Create an arguments bundle val argumentsBundle = Bundle() @@ -108,8 +105,8 @@ class WebViewTabFragment : Fragment() { } override fun onCreateView(layoutInflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { - // Check to see if the fragment is being restarted. - return if (savedInstanceState == null) { // The fragment is not being restarted. Load and configure a new fragment. + // Check to see if the fragment is being restarted without the app being killed. + return if (savedInstanceState == null) { // The fragment is not being restarted. It is either new or is being restored after the app was killed. // Check to see if a new page is being created. if (requireArguments().getBoolean(CREATE_NEW_PAGE)) { // A new page is being created. // Get the variables from the arguments @@ -132,9 +129,9 @@ class WebViewTabFragment : Fragment() { // Return the new page view. newPageView - } else { // A page is being restored. + } else { // A page is being restored after the app was killed. // Get the saved states from the arguments. - val savedState = requireArguments().getBundle(SAVED_STATE) + val savedState = requireArguments().getBundle(SAVED_STATE)!! val savedNestedScrollWebViewState = requireArguments().getBundle(SAVED_NESTED_SCROLL_WEBVIEW_STATE)!! // Inflate the tab's WebView. Setting false at the end of inflater.inflate does not attach the inflated layout as a child of container. @@ -152,7 +149,7 @@ class WebViewTabFragment : Fragment() { nestedScrollWebView.restoreNestedScrollWebViewState(savedNestedScrollWebViewState) // Restore the WebView state. - nestedScrollWebView.restoreState(savedState!!) + nestedScrollWebView.restoreState(savedState) // Initialize the WebView. newTabListener.initializeWebView(nestedScrollWebView, 0, progressBar, "", true) @@ -165,4 +162,4 @@ class WebViewTabFragment : Fragment() { null } } -} \ No newline at end of file +}