Skip to content

Commit

Permalink
Fixed: latency in showing whether a bookmark is added in the toggle b…
Browse files Browse the repository at this point in the history
…utton.

* Previously, we are checking the bookmark is added or not when a page is fully loaded in the webView. In the meantime previously set bookmark toggle is showing e.g. if the previous page is added as a bookmark then until the page is fully loaded the toggle is showing that the current is added as a bookmark. However, this new page is not added as a bookmark.
* To fix this latency, we moved our `updateUrlProcessor()` method to the `webViewProgressChanged` method to update the bookmark toggle when a page starts loading in the webView. This fixes the latency in updating the bookmark toggle.
  • Loading branch information
MohitMaliDeveloper committed Jul 1, 2024
1 parent ad9e7e6 commit 5f9ef86
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2116,7 +2116,6 @@ abstract class CoreReaderFragment :
}
updateTableOfContents()
tabsAdapter?.notifyDataSetChanged()
updateUrlProcessor()
updateBottomToolbarArrowsAlpha()
val zimFileReader = zimReaderContainer?.zimFileReader
if (hasValidFileAndUrl(getCurrentWebView()?.url, zimFileReader)) {
Expand Down Expand Up @@ -2150,13 +2149,18 @@ abstract class CoreReaderFragment :

override fun webViewFailedLoading(url: String) {
if (isAdded) {
// If a URL fails to load, update the bookmark toggle.
// This fixes the scenario where the previous page is bookmarked and the next
// page fails to load, ensuring the bookmark toggle is unset correctly.
updateUrlProcessor()
Log.d(TAG_KIWIX, String.format(getString(R.string.error_article_url_not_found), url))
}
}

@Suppress("MagicNumber")
override fun webViewProgressChanged(progress: Int, webView: WebView) {
if (isAdded) {
updateUrlProcessor()
progressBar?.apply {
visibility = View.VISIBLE
show()
Expand Down

0 comments on commit 5f9ef86

Please sign in to comment.