diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaImpl.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaImpl.kt index 82dfcefd36..2c229a6486 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaImpl.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaImpl.kt @@ -64,7 +64,8 @@ open class MangaImpl : Manga { } override fun hashCode(): Int { - return url.hashCode() + if (::url.isInitialized) return url.hashCode() + else return (id ?: 0L).hashCode() } companion object { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt index 43b63a6970..3c181fb353 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt @@ -163,7 +163,7 @@ class LibraryController( activeCategory = order if (presenter.categories.size > 1 && dy != 0) { val headerItem = getHeader() ?: return - val view = fast_scroller.getChildAt(0) ?: return + val view = fast_scroller?.getChildAt(0) ?: return val index = adapter.headerItems.indexOf(headerItem) textAnim?.cancel() textAnim = text_view_m.animate().alpha(0f).setDuration(250L).setStartDelay(2000) @@ -186,12 +186,12 @@ class LibraryController( when (newState) { RecyclerView.SCROLL_STATE_DRAGGING -> { scrollAnim?.cancel() - if (fast_scroller.translationX != 0f) { - fast_scroller.show() + if (fast_scroller?.translationX != 0f) { + fast_scroller?.show() } } RecyclerView.SCROLL_STATE_IDLE -> { - scrollAnim = fast_scroller.hide() + scrollAnim = fast_scroller?.hide() } } } @@ -299,7 +299,7 @@ class LibraryController( activity!!.theme.resolveAttribute(R.attr.actionBarTintColor, tv, true) swipe_refresh.setStyle() scrollViewWith(recycler, swipeRefreshLayout = swipe_refresh, afterInsets = { insets -> - fast_scroller.updateLayoutParams { + fast_scroller?.updateLayoutParams { topMargin = insets.systemWindowInsetTop } }) @@ -405,11 +405,11 @@ class LibraryController( fun updateShowScrollbar(show: Boolean) { alwaysShowScroller = show - fast_scroller.setBackground(!show) + fast_scroller?.setBackground(!show) if (libraryLayout == 0) reattachAdapter() scrollAnim?.cancel() - if (show) fast_scroller.translationX = 0f - else scrollAnim = fast_scroller.hide() + if (show) fast_scroller?.translationX = 0f + else scrollAnim = fast_scroller?.hide() setRecyclerLayout() } @@ -503,9 +503,9 @@ class LibraryController( if (justStarted && freshStart) { scrollToHeader(activeCategory) if (!alwaysShowScroller) { - fast_scroller.show(false) + fast_scroller?.show(false) view?.post { - scrollAnim = fast_scroller.hide(2000) + scrollAnim = fast_scroller?.hide(2000) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/SearchActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/SearchActivity.kt index 1846133fe0..556074ac34 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/SearchActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/SearchActivity.kt @@ -6,8 +6,8 @@ import android.os.Bundle import com.bluelinelabs.conductor.Controller import eu.kanade.tachiyomi.data.notification.NotificationReceiver import eu.kanade.tachiyomi.ui.base.controller.DialogController -import eu.kanade.tachiyomi.ui.source.global_search.SourceSearchController import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate +import eu.kanade.tachiyomi.ui.source.global_search.SourceSearchController import eu.kanade.tachiyomi.util.view.gone import eu.kanade.tachiyomi.util.view.withFadeTransaction import kotlinx.android.synthetic.main.main_activity.* @@ -16,8 +16,8 @@ class SearchActivity : MainActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - toolbar.navigationIcon = drawerArrow - toolbar.setNavigationOnClickListener { + toolbar?.navigationIcon = drawerArrow + toolbar?.setNavigationOnClickListener { popToRoot() } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt index d424a5561c..321fdce21b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt @@ -477,7 +477,9 @@ class MangaDetailsPresenter( updateChapters() withContext(Dispatchers.Main) { controller.updateChapters(this@MangaDetailsPresenter.chapters) } } catch (e: java.lang.Exception) { - controller.showError(trimException(e)) + withContext(Dispatchers.Main) { + controller.showError(trimException(e)) + } } } } 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 001f043624..0a9b6bd9e8 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 @@ -140,10 +140,10 @@ 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) { - val pages = page.chapter.pages!! // Won't be null because it's the loaded chapter - Timber.d("onReaderPageSelected: ${page.number}/${pages.size}") activity.onPageSelected(page) + val pages = page.chapter.pages ?: return + Timber.d("onReaderPageSelected: ${page.number}/${pages.size}") // Preload next chapter once we're within the last 3 pages of the current chapter val inPreloadRange = pages.size - page.number < 3 if (inPreloadRange) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt index e1686872a1..48bb9001f9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt @@ -253,6 +253,7 @@ class RecentsController(bundle: Bundle? = null) : BaseController(bundle), fun refresh() = presenter.getRecents() fun showLists(recents: List) { + if (view == null) return swipe_refresh.isRefreshing = LibraryUpdateService.isRunning() adapter.updateItems(recents) adapter.removeAllScrollableHeaders()