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 {
|
override fun intercept(chain: Interceptor.Chain): Response = runBlocking {
|
||||||
val request = chain.request()
|
val request = chain.request()
|
||||||
if (savedCookies[request.url.host] == null) {
|
if (savedCookies[request.url.host] == null) {
|
||||||
bypassCloudflare(request).also {
|
bypassCloudflare(request)?.let {
|
||||||
debugWarning({ it == null }) { "Failed cloudflare at: ${request.url}" }
|
Log.d(TAG, "Succeeded bypassing cloudflare: ${request.url}")
|
||||||
}?.let {
|
|
||||||
return@runBlocking it
|
return@runBlocking it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
debugWarning({ true }) { "Failed cloudflare at: ${request.url}" }
|
||||||
return@runBlocking chain.proceed(request)
|
return@runBlocking chain.proceed(request)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,12 +82,15 @@ class WebViewResolver(
|
||||||
val headers = request.headers
|
val headers = request.headers
|
||||||
println("Initial web-view request: $url")
|
println("Initial web-view request: $url")
|
||||||
var webView: WebView? = null
|
var webView: WebView? = null
|
||||||
|
// Extra assurance it exits as it should.
|
||||||
|
var shouldExit = false
|
||||||
|
|
||||||
fun destroyWebView() {
|
fun destroyWebView() {
|
||||||
main {
|
main {
|
||||||
webView?.stopLoading()
|
webView?.stopLoading()
|
||||||
webView?.destroy()
|
webView?.destroy()
|
||||||
webView = null
|
webView = null
|
||||||
|
shouldExit = true
|
||||||
println("Destroyed webview")
|
println("Destroyed webview")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -234,7 +237,7 @@ class WebViewResolver(
|
||||||
val delayTime = 100L
|
val delayTime = 100L
|
||||||
|
|
||||||
// A bit sloppy, but couldn't find a better way
|
// 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
|
if (fixedRequest != null) return fixedRequest to extraRequestList
|
||||||
delay(delayTime)
|
delay(delayTime)
|
||||||
loop += 1
|
loop += 1
|
||||||
|
@ -242,7 +245,7 @@ class WebViewResolver(
|
||||||
|
|
||||||
println("Web-view timeout after ${totalTime / 1000}s")
|
println("Web-view timeout after ${totalTime / 1000}s")
|
||||||
destroyWebView()
|
destroyWebView()
|
||||||
return null to extraRequestList
|
return fixedRequest to extraRequestList
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue