From 4880741b8ba6186b0bd9cd59cca960e92ef2ba2f Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 13 Dec 2020 17:18:28 -0500 Subject: [PATCH] More crash fixes --- .../eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt | 2 +- .../kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt | 2 +- .../kanade/tachiyomi/ui/setting/search/SettingsSearchHelper.kt | 2 +- .../java/eu/kanade/tachiyomi/ui/webview/BaseWebViewActivity.kt | 2 ++ 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt index 50285aa530..30411aa5be 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt @@ -185,7 +185,7 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer { * activity of the change and requests the preload of the next chapter if this is the last page. */ private fun onReaderPageSelected(page: ReaderPage, allowPreload: Boolean) { - val pages = page.chapter.pages!! // Won't be null because it's the loaded chapter + val pages = page.chapter.pages ?: return Timber.d("onReaderPageSelected: ${page.number}/${pages.size}") activity.onPageSelected(page) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt index 776af6202e..dfbfb96f12 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt @@ -185,7 +185,7 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr * activity of the change and requests the preload of the next chapter if this is the last page. */ private fun onPageSelected(page: ReaderPage, allowPreload: Boolean) { - val pages = page.chapter.pages!! // Won't be null because it's the loaded chapter + val pages = page.chapter.pages ?: return Timber.d("onPageSelected: ${page.number}/${pages.size}") activity.onPageSelected(page) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/search/SettingsSearchHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/search/SettingsSearchHelper.kt index a28c0bb191..54a3624109 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/search/SettingsSearchHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/search/SettingsSearchHelper.kt @@ -101,7 +101,7 @@ object SettingsSearchHelper { (pref.title != null) -> { // Is an actual preference val title = pref.title.toString() - val summary = if (pref.summary != null) pref.summary.toString() else "" + val summary = pref.summary?.toString() ?: "" val breadcrumbsStr = addLocalizedBreadcrumb(breadcrumbs, "${pref.title}") prefSearchResultList.add( diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/webview/BaseWebViewActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/webview/BaseWebViewActivity.kt index 37feae6b66..c8bbdceeb6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/webview/BaseWebViewActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/webview/BaseWebViewActivity.kt @@ -31,6 +31,7 @@ open class BaseWebViewActivity : BaseActivity() { if (!WebViewUtil.supportsWebView(this)) { toast(R.string.information_webview_required, Toast.LENGTH_LONG) finish() + return } try { @@ -40,6 +41,7 @@ open class BaseWebViewActivity : BaseActivity() { // Potentially throws errors like "Error inflating class android.webkit.WebView" toast(R.string.information_webview_required, Toast.LENGTH_LONG) finish() + return } title = intent.extras?.getString(TITLE_KEY)