mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-11-04 08:08:55 +01:00 
			
		
		
		
	Avoid crashes when fetching assist content URL in ReaderActivity
This commit is contained in:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user