+
+ // Get the current page position.
+ val currentPagePosition = webViewStateAdapter!!.getPositionForId(nestedScrollWebView.webViewFragmentId)
+
+ // Get the corresponding tab.
+ val tab = tabLayout.getTabAt(currentPagePosition)!!
+
+ // Get the tab custom view.
+ val tabCustomView = tab.customView!!
+
+ // Get the tab views.
+ val tabFavoriteIconImageView = tabCustomView.findViewById<ImageView>(R.id.favorite_icon_imageview)
+ val tabTitleTextView = tabCustomView.findViewById<TextView>(R.id.title_textview)
+
+ // Restore the previous webpage favorite icon and title if the title is currently set to `Loading...`.
+ if (tabTitleTextView.text.toString() == getString(R.string.loading)) {
+ // Restore the previous webpage title text.
+ tabTitleTextView.text = nestedScrollWebView.previousWebpageTitle
+
+ // Restore the previous webpage favorite icon if it is not null.
+ if (nestedScrollWebView.previousFavoriteIconDrawable != null)
+ tabFavoriteIconImageView.setImageDrawable(nestedScrollWebView.previousFavoriteIconDrawable)
+ }