mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2025-01-02 15:01:54 +01:00
Avoid crashes when opening WebView from reader
Also ensure WebViewActivity has an Assistant URL when it first opens with a URL.
This commit is contained in:
parent
a42be4a833
commit
425e48bec6
@ -67,6 +67,7 @@ import eu.kanade.tachiyomi.ui.reader.viewer.ReaderProgressIndicator
|
|||||||
import eu.kanade.tachiyomi.ui.reader.viewer.pager.R2LPagerViewer
|
import eu.kanade.tachiyomi.ui.reader.viewer.pager.R2LPagerViewer
|
||||||
import eu.kanade.tachiyomi.ui.webview.WebViewActivity
|
import eu.kanade.tachiyomi.ui.webview.WebViewActivity
|
||||||
import eu.kanade.tachiyomi.util.Constants
|
import eu.kanade.tachiyomi.util.Constants
|
||||||
|
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||||
import eu.kanade.tachiyomi.util.lang.launchNonCancellable
|
import eu.kanade.tachiyomi.util.lang.launchNonCancellable
|
||||||
import eu.kanade.tachiyomi.util.lang.withUIContext
|
import eu.kanade.tachiyomi.util.lang.withUIContext
|
||||||
import eu.kanade.tachiyomi.util.preference.toggle
|
import eu.kanade.tachiyomi.util.preference.toggle
|
||||||
@ -716,10 +717,12 @@ class ReaderActivity : BaseActivity() {
|
|||||||
private fun openChapterInWebview() {
|
private fun openChapterInWebview() {
|
||||||
val manga = viewModel.manga ?: return
|
val manga = viewModel.manga ?: return
|
||||||
val source = viewModel.getSource() ?: return
|
val source = viewModel.getSource() ?: return
|
||||||
val url = viewModel.getChapterUrl() ?: return
|
lifecycleScope.launchIO {
|
||||||
|
viewModel.getChapterUrl()?.let { url ->
|
||||||
val intent = WebViewActivity.newIntent(this, url, source.id, manga.title)
|
val intent = WebViewActivity.newIntent(this@ReaderActivity, url, source.id, manga.title)
|
||||||
startActivity(intent)
|
withUIContext { startActivity(intent) }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showReadingModeToast(mode: Int) {
|
private fun showReadingModeToast(mode: Int) {
|
||||||
|
@ -42,10 +42,11 @@ class WebViewActivity : BaseActivity() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val url = intent.extras!!.getString(URL_KEY) ?: return
|
val url = intent.extras?.getString(URL_KEY) ?: return
|
||||||
|
assistUrl = url
|
||||||
|
|
||||||
var headers = mutableMapOf<String, String>()
|
var headers = mutableMapOf<String, String>()
|
||||||
val source = sourceManager.get(intent.extras!!.getLong(SOURCE_KEY)) as? HttpSource
|
(sourceManager.get(intent.extras!!.getLong(SOURCE_KEY)) as? HttpSource)?.let { source ->
|
||||||
if (source != null) {
|
|
||||||
headers = source.headers.toMultimap().mapValues { it.value.getOrNull(0) ?: "" }.toMutableMap()
|
headers = source.headers.toMultimap().mapValues { it.value.getOrNull(0) ?: "" }.toMutableMap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user