forked from recloudstream/cloudstream
Fixed webview exiting properly
This commit is contained in:
parent
66a99a2624
commit
5b5f5e1482
2 changed files with 8 additions and 5 deletions
|
@ -28,12 +28,12 @@ class CloudflareKiller : Interceptor {
|
|||
override fun intercept(chain: Interceptor.Chain): Response = runBlocking {
|
||||
val request = chain.request()
|
||||
if (savedCookies[request.url.host] == null) {
|
||||
bypassCloudflare(request).also {
|
||||
debugWarning({ it == null }) { "Failed cloudflare at: ${request.url}" }
|
||||
}?.let {
|
||||
bypassCloudflare(request)?.let {
|
||||
Log.d(TAG, "Succeeded bypassing cloudflare: ${request.url}")
|
||||
return@runBlocking it
|
||||
}
|
||||
}
|
||||
debugWarning({ true }) { "Failed cloudflare at: ${request.url}" }
|
||||
return@runBlocking chain.proceed(request)
|
||||
}
|
||||
|
||||
|
|
|
@ -82,12 +82,15 @@ class WebViewResolver(
|
|||
val headers = request.headers
|
||||
println("Initial web-view request: $url")
|
||||
var webView: WebView? = null
|
||||
// Extra assurance it exits as it should.
|
||||
var shouldExit = false
|
||||
|
||||
fun destroyWebView() {
|
||||
main {
|
||||
webView?.stopLoading()
|
||||
webView?.destroy()
|
||||
webView = null
|
||||
shouldExit = true
|
||||
println("Destroyed webview")
|
||||
}
|
||||
}
|
||||
|
@ -234,7 +237,7 @@ class WebViewResolver(
|
|||
val delayTime = 100L
|
||||
|
||||
// A bit sloppy, but couldn't find a better way
|
||||
while (loop < totalTime / delayTime) {
|
||||
while (loop < totalTime / delayTime && !shouldExit) {
|
||||
if (fixedRequest != null) return fixedRequest to extraRequestList
|
||||
delay(delayTime)
|
||||
loop += 1
|
||||
|
@ -242,7 +245,7 @@ class WebViewResolver(
|
|||
|
||||
println("Web-view timeout after ${totalTime / 1000}s")
|
||||
destroyWebView()
|
||||
return null to extraRequestList
|
||||
return fixedRequest to extraRequestList
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue