Fix some crashes
This commit is contained in:
parent
dfd38db7e3
commit
46efd4c134
4 changed files with 23 additions and 18 deletions
|
@ -81,15 +81,15 @@ fun WebViewScreenContent(
|
||||||
),
|
),
|
||||||
AppBar.OverflowAction(
|
AppBar.OverflowAction(
|
||||||
title = stringResource(R.string.action_share),
|
title = stringResource(R.string.action_share),
|
||||||
onClick = { onShare(state.lastLoadedUrl!!) },
|
onClick = { onShare(state.lastLoadedUrl ?: url) },
|
||||||
),
|
),
|
||||||
AppBar.OverflowAction(
|
AppBar.OverflowAction(
|
||||||
title = stringResource(R.string.action_open_in_browser),
|
title = stringResource(R.string.action_open_in_browser),
|
||||||
onClick = { onOpenInBrowser(state.lastLoadedUrl!!) },
|
onClick = { onOpenInBrowser(state.lastLoadedUrl ?: url) },
|
||||||
),
|
),
|
||||||
AppBar.OverflowAction(
|
AppBar.OverflowAction(
|
||||||
title = stringResource(R.string.pref_clear_cookies),
|
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.launch
|
||||||
import kotlinx.coroutines.supervisorScope
|
import kotlinx.coroutines.supervisorScope
|
||||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||||
|
import logcat.LogPriority
|
||||||
import tachiyomi.core.util.lang.launchIO
|
import tachiyomi.core.util.lang.launchIO
|
||||||
import tachiyomi.core.util.lang.withIOContext
|
import tachiyomi.core.util.lang.withIOContext
|
||||||
import tachiyomi.core.util.lang.withUIContext
|
import tachiyomi.core.util.lang.withUIContext
|
||||||
import tachiyomi.core.util.system.ImageUtil
|
import tachiyomi.core.util.system.ImageUtil
|
||||||
|
import tachiyomi.core.util.system.logcat
|
||||||
import java.io.BufferedInputStream
|
import java.io.BufferedInputStream
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
|
|
||||||
|
@ -234,6 +236,7 @@ class WebtoonPageHolder(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onStripSplit(imageStream: BufferedInputStream): InputStream {
|
private fun onStripSplit(imageStream: BufferedInputStream): InputStream {
|
||||||
|
try {
|
||||||
// If we have reached this point [page] and its stream shouldn't be null
|
// If we have reached this point [page] and its stream shouldn't be null
|
||||||
val page = page!!
|
val page = page!!
|
||||||
val stream = page.stream!!
|
val stream = page.stream!!
|
||||||
|
@ -247,6 +250,10 @@ class WebtoonPageHolder(
|
||||||
// Running [onLongStripSplit] first results in issues with splitting
|
// Running [onLongStripSplit] first results in issues with splitting
|
||||||
viewer.onLongStripSplit(page, newPages)
|
viewer.onLongStripSplit(page, newPages)
|
||||||
}
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
logcat(LogPriority.ERROR, e) { "Failed to split image" }
|
||||||
|
return imageStream
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -298,9 +298,8 @@ object ImageUtil {
|
||||||
"splitHeight=${splitData.splitHeight} bottomOffset=${splitData.bottomOffset}"
|
"splitHeight=${splitData.splitHeight} bottomOffset=${splitData.bottomOffset}"
|
||||||
}
|
}
|
||||||
|
|
||||||
val region = Rect(0, splitData.topOffset, splitData.splitWidth, splitData.bottomOffset)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
val region = Rect(0, splitData.topOffset, splitData.splitWidth, splitData.bottomOffset)
|
||||||
val splitBitmap = bitmapRegionDecoder.decodeRegion(region, null)
|
val splitBitmap = bitmapRegionDecoder.decodeRegion(region, null)
|
||||||
val outputStream = ByteArrayOutputStream()
|
val outputStream = ByteArrayOutputStream()
|
||||||
splitBitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream)
|
splitBitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream)
|
||||||
|
|
|
@ -5,7 +5,6 @@ import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.derivedStateOf
|
import androidx.compose.runtime.derivedStateOf
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableIntStateOf
|
import androidx.compose.runtime.mutableIntStateOf
|
||||||
import androidx.compose.runtime.mutableStateOf
|
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
|
|
||||||
|
|
Reference in a new issue