Fix crashes

This commit is contained in:
Koitharu
2025-10-19 14:53:31 +03:00
parent 90bd9023d5
commit 8ca3bece5d
3 changed files with 25 additions and 7 deletions

View File

@@ -1,6 +1,7 @@
package org.koitharu.kotatsu.core.network.webview
import android.content.Context
import android.util.AndroidRuntimeException
import android.webkit.WebSettings
import android.webkit.WebView
import android.webkit.WebViewClient
@@ -41,7 +42,13 @@ class WebViewExecutor @Inject constructor(
private val mutex = Mutex()
val defaultUserAgent: String? by lazy {
WebSettings.getDefaultUserAgent(context)
try {
WebSettings.getDefaultUserAgent(context)
} catch (e: AndroidRuntimeException) {
e.printStackTraceDebug()
// Probably WebView is not available
null
}
}
suspend fun evaluateJs(baseUrl: String?, script: String): String? = mutex.withLock {

View File

@@ -3,6 +3,7 @@ package org.koitharu.kotatsu.details.ui.pager.chapters
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.widget.Toast
import androidx.appcompat.view.ActionMode
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.snackbar.Snackbar
@@ -11,6 +12,7 @@ import org.koitharu.kotatsu.core.model.LocalMangaSource
import org.koitharu.kotatsu.core.nav.AppRouter
import org.koitharu.kotatsu.core.ui.list.BaseListSelectionCallback
import org.koitharu.kotatsu.core.ui.list.ListSelectionController
import org.koitharu.kotatsu.core.util.ext.printStackTraceDebug
import org.koitharu.kotatsu.core.util.ext.toCollection
import org.koitharu.kotatsu.core.util.ext.toSet
import org.koitharu.kotatsu.details.ui.pager.ChaptersPagesViewModel
@@ -78,11 +80,20 @@ class ChaptersSelectionCallback(
ids.size == manga.chapters?.size -> viewModel.deleteLocal()
else -> {
LocalChaptersRemoveService.start(recyclerView.context, manga, ids.toSet())
Snackbar.make(
recyclerView,
R.string.chapters_will_removed_background,
Snackbar.LENGTH_LONG,
).show()
try {
Snackbar.make(
recyclerView,
R.string.chapters_will_removed_background,
Snackbar.LENGTH_LONG,
).show()
} catch (e: IllegalArgumentException) {
e.printStackTraceDebug()
Toast.makeText(
recyclerView.context,
R.string.chapters_will_removed_background,
Toast.LENGTH_SHORT,
).show()
}
}
}
mode?.finish()

View File

@@ -137,7 +137,7 @@ class AppUpdateActivity : BaseActivity<ActivityAppUpdateBinding>(), View.OnClick
viewModel.installIntent.value?.let { intent ->
try {
startActivity(intent)
} catch (e: ActivityNotFoundException) {
} catch (e: Exception) {
onError(e)
}
return