mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-31 06:17:57 +01:00 
			
		
		
		
	Fix some crashes
This commit is contained in:
		| @@ -81,15 +81,15 @@ fun WebViewScreenContent( | ||||
|                                 ), | ||||
|                                 AppBar.OverflowAction( | ||||
|                                     title = stringResource(R.string.action_share), | ||||
|                                     onClick = { onShare(state.lastLoadedUrl!!) }, | ||||
|                                     onClick = { onShare(state.lastLoadedUrl ?: url) }, | ||||
|                                 ), | ||||
|                                 AppBar.OverflowAction( | ||||
|                                     title = stringResource(R.string.action_open_in_browser), | ||||
|                                     onClick = { onOpenInBrowser(state.lastLoadedUrl!!) }, | ||||
|                                     onClick = { onOpenInBrowser(state.lastLoadedUrl ?: url) }, | ||||
|                                 ), | ||||
|                                 AppBar.OverflowAction( | ||||
|                                     title = stringResource(R.string.pref_clear_cookies), | ||||
|                                     onClick = { onClearCookies(state.lastLoadedUrl!!) }, | ||||
|                                     onClick = { onClearCookies(state.lastLoadedUrl ?: url) }, | ||||
|                                 ), | ||||
|                             ), | ||||
|                         ) | ||||
|   | ||||
| @@ -25,10 +25,12 @@ import kotlinx.coroutines.flow.collectLatest | ||||
| import kotlinx.coroutines.launch | ||||
| import kotlinx.coroutines.supervisorScope | ||||
| import kotlinx.coroutines.suspendCancellableCoroutine | ||||
| import logcat.LogPriority | ||||
| import tachiyomi.core.util.lang.launchIO | ||||
| import tachiyomi.core.util.lang.withIOContext | ||||
| import tachiyomi.core.util.lang.withUIContext | ||||
| import tachiyomi.core.util.system.ImageUtil | ||||
| import tachiyomi.core.util.system.logcat | ||||
| import java.io.BufferedInputStream | ||||
| import java.io.InputStream | ||||
|  | ||||
| @@ -234,19 +236,24 @@ class WebtoonPageHolder( | ||||
|     } | ||||
|  | ||||
|     private fun onStripSplit(imageStream: BufferedInputStream): InputStream { | ||||
|         // If we have reached this point [page] and its stream shouldn't be null | ||||
|         val page = page!! | ||||
|         val stream = page.stream!! | ||||
|         val splitData = ImageUtil.getSplitDataForStream(imageStream).toMutableList() | ||||
|         val currentSplitData = splitData.removeFirst() | ||||
|         val newPages = splitData.map { | ||||
|             StencilPage(page) { ImageUtil.splitStrip(it, stream) } | ||||
|         } | ||||
|         return ImageUtil.splitStrip(currentSplitData) { imageStream } | ||||
|             .also { | ||||
|                 // Running [onLongStripSplit] first results in issues with splitting | ||||
|                 viewer.onLongStripSplit(page, newPages) | ||||
|         try { | ||||
|             // If we have reached this point [page] and its stream shouldn't be null | ||||
|             val page = page!! | ||||
|             val stream = page.stream!! | ||||
|             val splitData = ImageUtil.getSplitDataForStream(imageStream).toMutableList() | ||||
|             val currentSplitData = splitData.removeFirst() | ||||
|             val newPages = splitData.map { | ||||
|                 StencilPage(page) { ImageUtil.splitStrip(it, stream) } | ||||
|             } | ||||
|             return ImageUtil.splitStrip(currentSplitData) { imageStream } | ||||
|                 .also { | ||||
|                     // Running [onLongStripSplit] first results in issues with splitting | ||||
|                     viewer.onLongStripSplit(page, newPages) | ||||
|                 } | ||||
|         } catch (e: Exception) { | ||||
|             logcat(LogPriority.ERROR, e) { "Failed to split image" } | ||||
|             return imageStream | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|   | ||||
		Reference in New Issue
	
	Block a user