diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/network/webview/WebViewExecutor.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/network/webview/WebViewExecutor.kt index 8adf12432..9656972e1 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/network/webview/WebViewExecutor.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/network/webview/WebViewExecutor.kt @@ -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 { diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/pager/chapters/ChaptersSelectionCallback.kt b/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/pager/chapters/ChaptersSelectionCallback.kt index fea035a47..2a652a18f 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/pager/chapters/ChaptersSelectionCallback.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/pager/chapters/ChaptersSelectionCallback.kt @@ -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() diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/settings/about/AppUpdateActivity.kt b/app/src/main/kotlin/org/koitharu/kotatsu/settings/about/AppUpdateActivity.kt index 89594d563..812260e9d 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/settings/about/AppUpdateActivity.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/settings/about/AppUpdateActivity.kt @@ -137,7 +137,7 @@ class AppUpdateActivity : BaseActivity(), View.OnClick viewModel.installIntent.value?.let { intent -> try { startActivity(intent) - } catch (e: ActivityNotFoundException) { + } catch (e: Exception) { onError(e) } return