Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package io.github.landwarderer.futon.browser
import android.annotation.SuppressLint
import android.graphics.Bitmap
import android.os.Looper
import android.webkit.WebResourceError
import android.webkit.WebResourceRequest
import android.webkit.WebResourceResponse
import android.webkit.WebView
Expand Down Expand Up @@ -33,6 +34,21 @@ open class BrowserClient(
callback.onLoadingStateChanged(isLoading = true)
}

override fun onReceivedError(
view: WebView?,
request: WebResourceRequest?,
error: WebResourceError?,
) {
super.onReceivedError(view, request, error)
// Drop the spinner on main-frame failures (DNS, certificate, offline,
// 4xx/5xx) too, since onPageFinished does not always fire after an
// error and the BrowserCallback would otherwise stay stuck on
// isLoading = true.
if (request?.isForMainFrame == true) {
callback.onLoadingStateChanged(isLoading = false)
}
}

override fun onPageCommitVisible(view: WebView, url: String) {
super.onPageCommitVisible(view, url)
callback.onTitleChanged(view.title.orEmpty(), url)
Expand Down
Loading