mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
fixed minor crashes
This commit is contained in:
parent
36115b524d
commit
d992d63c5f
3 changed files with 135 additions and 119 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue