Skip to content

Clear the refresh spinner when an article fails to load (closes #197)#198

Open
jim-daf wants to merge 1 commit into
manmal:masterfrom
jim-daf:fix/article-reader-stuck-spinner
Open

Clear the refresh spinner when an article fails to load (closes #197)#198
jim-daf wants to merge 1 commit into
manmal:masterfrom
jim-daf:fix/article-reader-stuck-spinner

Conversation

@jim-daf
Copy link
Copy Markdown

@jim-daf jim-daf commented May 20, 2026

Closes #197

What this does

Adds an onReceivedError(view, errorCode, description, failingUrl) override to HNReaderWebViewClient in ArticleReaderActivity.java. The override does the same teardown as onPageFinished. It calls setShowRefreshing(false), sets mWebViewIsLoading = false, and logs the error code, description and failing URL via Log.w. Adds one private TAG constant on the inner class.

Why

Today, when the WebView fails to load the article (network down, DNS failure, captive portal, ...), Android fires onReceivedError and does not fire onPageFinished. The spinner is only cleared in onPageFinished, so the reader sits there with the spinner running until the user backs out. After this change the spinner clears as soon as the load fails and the failure shows up in logcat.

No new UI, no new strings, no behaviour change in the happy path.

Note on the signature

The deprecated 4-arg form was kept on purpose. The new (WebView, WebResourceRequest, WebResourceError) overload only dispatches on API 23 plus, and the framework still dispatches the deprecated form for every supported API level when nothing else is overridden. One override therefore covers all users instead of needing an SDK_INT guard. Happy to switch to the new signature gated on Build.VERSION.SDK_INT >= M if you would prefer that style.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Article reader spinner stays on forever when the article fails to load

1 participant