mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-21 20:47:03 -05:00
Avoid crashes when fetching assist content URL in ReaderActivity
This commit is contained in:
parent
4cd01428ed
commit
e265b929a1
2 changed files with 9 additions and 4 deletions
|
@ -122,6 +122,7 @@ class ReaderActivity : BaseActivity() {
|
||||||
lateinit var binding: ReaderActivityBinding
|
lateinit var binding: ReaderActivityBinding
|
||||||
|
|
||||||
val viewModel by viewModels<ReaderViewModel>()
|
val viewModel by viewModels<ReaderViewModel>()
|
||||||
|
private var assistUrl: String? = null
|
||||||
|
|
||||||
val hasCutout by lazy { hasDisplayCutout() }
|
val hasCutout by lazy { hasDisplayCutout() }
|
||||||
|
|
||||||
|
@ -301,9 +302,7 @@ class ReaderActivity : BaseActivity() {
|
||||||
|
|
||||||
override fun onProvideAssistContent(outContent: AssistContent) {
|
override fun onProvideAssistContent(outContent: AssistContent) {
|
||||||
super.onProvideAssistContent(outContent)
|
super.onProvideAssistContent(outContent)
|
||||||
viewModel.getChapterUrl()?.let { url ->
|
assistUrl?.let { outContent.webUri = it.toUri() }
|
||||||
outContent.webUri = url.toUri()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -764,6 +763,12 @@ class ReaderActivity : BaseActivity() {
|
||||||
|
|
||||||
// Invalidate menu to show proper chapter bookmark state
|
// Invalidate menu to show proper chapter bookmark state
|
||||||
invalidateOptionsMenu()
|
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
|
* Moves the viewer to the given page [index]. It does nothing if the viewer is null or the
|
||||||
* page is not found.
|
* page is not found.
|
||||||
*/
|
*/
|
||||||
fun moveToPageIndex(index: Int) {
|
private fun moveToPageIndex(index: Int) {
|
||||||
val viewer = viewer ?: return
|
val viewer = viewer ?: return
|
||||||
val currentChapter = viewModel.getCurrentChapter() ?: return
|
val currentChapter = viewModel.getCurrentChapter() ?: return
|
||||||
val page = currentChapter.pages?.getOrNull(index) ?: return
|
val page = currentChapter.pages?.getOrNull(index) ?: return
|
||||||
|
|
Loading…
Reference in a new issue