- // 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.
+ // Get the bottom app bar status from the arguments.
+ val bottomAppBar = requireArguments().getBoolean(BOTTOM_APP_BAR)
+
+ // Inflate the tab's WebView according to the app bar position. Setting false at the end of inflater.inflate does not attach the inflated layout as a child of container.
+ // The fragment will take care of attaching the root automatically.
+ val newPageView = if (bottomAppBar)
+ layoutInflater.inflate(R.layout.webview_framelayout_bottom_appbar, container, false)
+ else
+ layoutInflater.inflate(R.layout.webview_framelayout_top_appbar, container, false)
+
+ // Get handles for the views.
+ nestedScrollWebView = newPageView.findViewById(R.id.nestedscroll_webview)
+ val progressBar = newPageView.findViewById<ProgressBar>(R.id.progress_bar)
+
+ // Store the WebView fragment ID in the nested scroll WebView.
+ nestedScrollWebView.webViewFragmentId = fragmentId
+
+ // 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.