forked from github/wulkanowy-mirror
Fix very rare crash in login recovery (#1231)
This commit is contained in:
@ -9,6 +9,7 @@ import android.view.View.VISIBLE
|
||||
import android.webkit.JavascriptInterface
|
||||
import android.webkit.WebView
|
||||
import android.webkit.WebViewClient
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.widget.doOnTextChanged
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import io.github.wulkanowy.R
|
||||
@ -42,10 +43,12 @@ class LoginRecoverFragment :
|
||||
private lateinit var hostSymbols: Array<String>
|
||||
|
||||
override val recoverHostValue: String
|
||||
get() = hostValues.getOrNull(hostKeys.indexOf(bindingLocal.loginRecoverHost.text.toString())).orEmpty()
|
||||
get() = hostValues.getOrNull(hostKeys.indexOf(bindingLocal.loginRecoverHost.text.toString()))
|
||||
.orEmpty()
|
||||
|
||||
override val formHostSymbol: String
|
||||
get() = hostSymbols.getOrNull(hostKeys.indexOf(bindingLocal.loginRecoverHost.text.toString())).orEmpty()
|
||||
get() = hostSymbols.getOrNull(hostKeys.indexOf(bindingLocal.loginRecoverHost.text.toString()))
|
||||
.orEmpty()
|
||||
|
||||
override val recoverNameValue: String
|
||||
get() = bindingLocal.loginRecoverName.text.toString().trim()
|
||||
@ -82,7 +85,9 @@ class LoginRecoverFragment :
|
||||
|
||||
with(bindingLocal.loginRecoverHost) {
|
||||
setText(hostKeys.getOrNull(0).orEmpty())
|
||||
setAdapter(LoginSymbolAdapter(context, R.layout.support_simple_spinner_dropdown_item, hostKeys))
|
||||
setAdapter(
|
||||
LoginSymbolAdapter(context, R.layout.support_simple_spinner_dropdown_item, hostKeys)
|
||||
)
|
||||
setOnClickListener { if (bindingLocal.loginRecoverFormContainer.visibility == GONE) dismissDropDown() }
|
||||
}
|
||||
}
|
||||
@ -127,6 +132,7 @@ class LoginRecoverFragment :
|
||||
|
||||
override fun showErrorView(show: Boolean) {
|
||||
bindingLocal.loginRecoverError.visibility = if (show) VISIBLE else GONE
|
||||
bindingLocal.loginRecoverErrorDetails.isVisible = true
|
||||
}
|
||||
|
||||
override fun setErrorDetails(message: String) {
|
||||
@ -166,7 +172,7 @@ class LoginRecoverFragment :
|
||||
with(bindingLocal.loginRecoverWebView) {
|
||||
settings.javaScriptEnabled = true
|
||||
webViewClient = object : WebViewClient() {
|
||||
private var recoverWebViewSuccess: Boolean = true
|
||||
private var recoverWebViewSuccess = true
|
||||
|
||||
override fun onPageFinished(view: WebView?, url: String?) {
|
||||
if (recoverWebViewSuccess) {
|
||||
@ -175,10 +181,16 @@ class LoginRecoverFragment :
|
||||
} else {
|
||||
showProgress(false)
|
||||
showErrorView(true)
|
||||
bindingLocal.loginRecoverErrorDetails.isVisible = false
|
||||
}
|
||||
}
|
||||
|
||||
override fun onReceivedError(view: WebView, errorCode: Int, description: String, failingUrl: String) {
|
||||
override fun onReceivedError(
|
||||
view: WebView,
|
||||
errorCode: Int,
|
||||
description: String,
|
||||
failingUrl: String
|
||||
) {
|
||||
recoverWebViewSuccess = false
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user