mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-21 15:31:49 +01:00
Avoid crashes when fetching assist content URL in ReaderActivity
This commit is contained in:
parent
4cd01428ed
commit
e265b929a1
@ -122,6 +122,7 @@ class ReaderActivity : BaseActivity() {
|
||||
lateinit var binding: ReaderActivityBinding
|
||||
|
||||
val viewModel by viewModels<ReaderViewModel>()
|
||||
private var assistUrl: String? = null
|
||||
|
||||
val hasCutout by lazy { hasDisplayCutout() }
|
||||
|
||||
@ -301,9 +302,7 @@ class ReaderActivity : BaseActivity() {
|
||||
|
||||
override fun onProvideAssistContent(outContent: AssistContent) {
|
||||
super.onProvideAssistContent(outContent)
|
||||
viewModel.getChapterUrl()?.let { url ->
|
||||
outContent.webUri = url.toUri()
|
||||
}
|
||||
assistUrl?.let { outContent.webUri = it.toUri() }
|
||||
}
|
||||
|
||||
/**
|
||||
@ -764,6 +763,12 @@ class ReaderActivity : BaseActivity() {
|
||||
|
||||
// Invalidate menu to show proper chapter bookmark state
|
||||
invalidateOptionsMenu()
|
||||
|
||||
lifecycleScope.launchIO {
|
||||
viewModel.getChapterUrl()?.let { url ->
|
||||
assistUrl = url
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -796,7 +801,7 @@ class ReaderActivity : BaseActivity() {
|
||||
* Moves the viewer to the given page [index]. It does nothing if the viewer is null or the
|
||||
* page is not found.
|
||||
*/
|
||||
fun moveToPageIndex(index: Int) {
|
||||
private fun moveToPageIndex(index: Int) {
|
||||
val viewer = viewer ?: return
|
||||
val currentChapter = viewModel.getCurrentChapter() ?: return
|
||||
val page = currentChapter.pages?.getOrNull(index) ?: return
|
||||
|
Loading…
Reference in New Issue
Block a user