From 300e2c4bc2c52c2f6c8107c4a05ea1b5f13c77bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Mon, 24 Aug 2020 18:16:47 +0200 Subject: [PATCH] [API/Librus] Fix doubled sync on reCaptcha timeout. --- .../data/api/edziennik/librus/LibrusRecaptchaHelper.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/LibrusRecaptchaHelper.kt b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/LibrusRecaptchaHelper.kt index 94ab5ed1..3652f18a 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/LibrusRecaptchaHelper.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/data/api/edziennik/librus/LibrusRecaptchaHelper.kt @@ -36,11 +36,14 @@ class LibrusRecaptchaHelper( } private var timeout: Job? = null + private var timedOut = false inner class WebViewClient : android.webkit.WebViewClient() { override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean { timeout?.cancel() - onSuccess(url) + if (!timedOut) { + onSuccess(url) + } return true } } @@ -50,6 +53,7 @@ class LibrusRecaptchaHelper( webView.loadDataWithBaseURL(url, html, "text/html", "UTF-8", null) } timeout = startCoroutineTimer(delayMillis = 10000L) { + timedOut = true onTimeout() } }