Skip to content

Commit

Permalink
Issue #51 fixed - Crash in Wiktionary page load
Browse files Browse the repository at this point in the history
  • Loading branch information
manimaran96 committed Apr 6, 2022
1 parent a431674 commit 3aa58cf
Showing 1 changed file with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,27 +122,33 @@ class WebViewFragment : Fragment() {
override fun onPageStarted(view: WebView, url: String, favicon: Bitmap?) {
super.onPageStarted(view, url, favicon)
isWebPageNotFound = false
loadingVisibility(View.VISIBLE)
activity?.invalidateOptionsMenu()
if (isAdded) {
loadingVisibility(View.VISIBLE)
activity?.invalidateOptionsMenu()
}
}

override fun onPageFinished(view: WebView, url: String) {
// super.onPageFinished(view, url)
if (isWiktionaryWord) {
hideDivListForWiktionaryWebPage.forEach { divClass ->
webView.loadUrl("javascript:(function() { document.getElementsByClassName('${divClass}')[0].style.display='none'; })()")
if (isAdded) {
if (isWiktionaryWord) {
hideDivListForWiktionaryWebPage.forEach { divClass ->
webView?.loadUrl("javascript:(function() { document.getElementsByClassName('${divClass}')[0].style.display='none'; })()")
}
}
if (!isWebPageNotFound)
loadingVisibility(View.GONE)
activity?.invalidateOptionsMenu()
}
if (!isWebPageNotFound)
loadingVisibility(View.GONE)
activity?.invalidateOptionsMenu()
}

override fun onReceivedError(view: WebView, request: WebResourceRequest, error: WebResourceError) {
super.onReceivedError(view, request, error)
isWebPageNotFound = true
showPageNotFound()
activity?.invalidateOptionsMenu()
if (isAdded) {
showPageNotFound()
activity?.invalidateOptionsMenu()
}
}
}
}
Expand Down

0 comments on commit 3aa58cf

Please sign in to comment.