fixed minor crashes

This commit is contained in:
LagradOst 2022-02-18 22:20:35 +01:00
parent 36115b524d
commit d992d63c5f
3 changed files with 135 additions and 119 deletions

View file

@ -6,6 +6,7 @@ import android.webkit.*
import com.lagradost.cloudstream3.AcraApplication
import com.lagradost.cloudstream3.USER_AGENT
import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.mvvm.logError
import com.lagradost.cloudstream3.utils.Coroutines.main
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
@ -60,6 +61,7 @@ class WebViewResolver(val interceptUrl: Regex, val additionalUrls: List<Regex> =
main {
// Useful for debugging
// WebView.setWebContentsDebuggingEnabled(true)
try {
webView = WebView(
AcraApplication.context
?: throw RuntimeException("No base context in WebViewResolver")
@ -159,7 +161,10 @@ class WebViewResolver(val interceptUrl: Regex, val additionalUrls: List<Regex> =
webViewUrl,
headers = request.requestHeaders
).response.toWebResourceResponse()
else -> return@runBlocking super.shouldInterceptRequest(view, request)
else -> return@runBlocking super.shouldInterceptRequest(
view,
request
)
}
} catch (e: Exception) {
null
@ -175,6 +180,9 @@ class WebViewResolver(val interceptUrl: Regex, val additionalUrls: List<Regex> =
}
}
webView?.loadUrl(url, headers.toMap())
} catch (e: Exception) {
logError(e)
}
}
var loop = 0

View file

@ -142,6 +142,7 @@ class GeneratorPlayer : FullScreenPlayer() {
}
private fun openSubPicker() {
try {
subsPathPicker.launch(
arrayOf(
"text/plain",
@ -155,6 +156,9 @@ class GeneratorPlayer : FullScreenPlayer() {
MimeTypes.APPLICATION_SUBRIP,
)
)
} catch (e : Exception) {
logError(e)
}
}
// Open file picker

View file

@ -375,7 +375,11 @@ class SettingsFragment : PreferenceFragmentCompat() {
{}) {
// Last = custom
if (it == dirs.size) {
try {
pathPicker.launch(Uri.EMPTY)
} catch (e : Exception) {
logError(e)
}
} else {
// Sets both visual and actual paths.
// key = used path