mirror of
https://github.com/mihonapp/mihon.git
synced 2024-12-26 19:08:25 +01:00
Avoid crashes if headers can't be built for usage in WebView
This commit is contained in:
parent
3f7911235c
commit
ec49411bee
@ -17,6 +17,7 @@ import eu.kanade.tachiyomi.util.system.openInBrowser
|
|||||||
import eu.kanade.tachiyomi.util.system.toShareIntent
|
import eu.kanade.tachiyomi.util.system.toShareIntent
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
import eu.kanade.tachiyomi.util.view.setComposeContent
|
import eu.kanade.tachiyomi.util.view.setComposeContent
|
||||||
|
import logcat.LogPriority
|
||||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||||
import tachiyomi.core.util.system.logcat
|
import tachiyomi.core.util.system.logcat
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
@ -47,7 +48,11 @@ class WebViewActivity : BaseActivity() {
|
|||||||
|
|
||||||
var headers = emptyMap<String, String>()
|
var headers = emptyMap<String, String>()
|
||||||
(sourceManager.get(intent.extras!!.getLong(SOURCE_KEY)) as? HttpSource)?.let { source ->
|
(sourceManager.get(intent.extras!!.getLong(SOURCE_KEY)) as? HttpSource)?.let { source ->
|
||||||
|
try {
|
||||||
headers = source.headers.toMultimap().mapValues { it.value.getOrNull(0) ?: "" }
|
headers = source.headers.toMultimap().mapValues { it.value.getOrNull(0) ?: "" }
|
||||||
|
} catch (e: Exception) {
|
||||||
|
logcat(LogPriority.ERROR, e) { "Failed to build headers" }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setComposeContent {
|
setComposeContent {
|
||||||
|
@ -10,6 +10,7 @@ import eu.kanade.tachiyomi.source.online.HttpSource
|
|||||||
import eu.kanade.tachiyomi.util.system.openInBrowser
|
import eu.kanade.tachiyomi.util.system.openInBrowser
|
||||||
import eu.kanade.tachiyomi.util.system.toShareIntent
|
import eu.kanade.tachiyomi.util.system.toShareIntent
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
|
import logcat.LogPriority
|
||||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||||
import tachiyomi.core.util.system.logcat
|
import tachiyomi.core.util.system.logcat
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
@ -25,7 +26,11 @@ class WebViewScreenModel(
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
sourceId?.let { sourceManager.get(it) as? HttpSource }?.let { source ->
|
sourceId?.let { sourceManager.get(it) as? HttpSource }?.let { source ->
|
||||||
|
try {
|
||||||
headers = source.headers.toMultimap().mapValues { it.value.getOrNull(0) ?: "" }
|
headers = source.headers.toMultimap().mapValues { it.value.getOrNull(0) ?: "" }
|
||||||
|
} catch (e: Exception) {
|
||||||
|
logcat(LogPriority.ERROR, e) { "Failed to build headers" }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user