Fix crashes

devel
Koitharu 6 months ago
parent 90bd9023d5
commit 8ca3bece5d
Signed by: Koitharu
GPG Key ID: 676DEE768C17A9D7

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

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

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

Loading…
Cancel
Save