diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt index c16b8c702f..fcd2c2a8f3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt @@ -336,7 +336,7 @@ class ReaderActivity : BaseRxActivity(), chapters_bottom_sheet.sheetBehavior?.isHideable = !menuVisible if (!menuVisible) chapters_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_HIDDEN - reader_menu.doOnApplyWindowInsets { v, insets, _ -> + reader_layout.doOnApplyWindowInsets { v, insets, _ -> sheetManageNavColor = when { insets.isBottomTappable() -> { window.navigationBarColor = Color.TRANSPARENT @@ -372,7 +372,7 @@ class ReaderActivity : BaseRxActivity(), if (visible) { snackbar?.dismiss() systemUi?.show() - reader_menu.visibility = View.VISIBLE + toolbar.visibility = View.VISIBLE if (chapters_bottom_sheet.sheetBehavior?.state == BottomSheetBehavior.STATE_EXPANDED) { chapters_bottom_sheet.sheetBehavior?.isHideable = false @@ -399,14 +399,14 @@ class ReaderActivity : BaseRxActivity(), val toolbarAnimation = AnimationUtils.loadAnimation(this, R.anim.exit_to_top) toolbarAnimation.setAnimationListener(object : SimpleAnimationListener() { override fun onAnimationEnd(animation: Animation) { - reader_menu.visibility = View.GONE + toolbar.visibility = View.GONE } }) appbar.startAnimation(toolbarAnimation) BottomSheetBehavior.from(chapters_bottom_sheet).isHideable = true BottomSheetBehavior.from(chapters_bottom_sheet).state = BottomSheetBehavior.STATE_HIDDEN } else { - reader_menu.visibility = View.GONE + toolbar.visibility = View.GONE } } menuStickyVisible = false @@ -661,7 +661,7 @@ class ReaderActivity : BaseRxActivity(), } } if (sheetManageNavColor) window.navigationBarColor = getResourceColor(R.attr.colorSecondary) - reader_menu.visibility = View.VISIBLE + toolbar.visibility = View.VISIBLE val toolbarAnimation = AnimationUtils.loadAnimation(this, R.anim.enter_from_top) toolbarAnimation.setAnimationListener(object : SimpleAnimationListener() { override fun onAnimationStart(animation: Animation) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt index 1a93e2ea0c..a026fc80cd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt @@ -262,7 +262,7 @@ class PagerPageHolder( context )) { imageView.setImage(ImageSource.inputStream(openStream!!)) - imageView.background = page.bg + background = page.bg } // if the user switches to automatic when pages are already cached, the bg needs to be loaded else { @@ -280,15 +280,15 @@ class PagerPageHolder( } else { val imageView = initSubsamplingImageView() imageView.setImage(ImageSource.inputStream(openStream!!)) - imageView.background = ColorDrawable(ThemeUtil.readerBackgroundColor(viewer.config.readerTheme)) + background = ColorDrawable(ThemeUtil.readerBackgroundColor(viewer.config.readerTheme)) } } else { val imageView = initImageView() imageView.setImage(openStream!!) if (viewer.config.readerTheme >= 2 && page.bg != null) { - imageView.background = page.bg + background = page.bg } else if (viewer.config.readerTheme < 2) { - imageView.background = + background = ColorDrawable(ThemeUtil.readerBackgroundColor(viewer.config.readerTheme)) } } 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 1c7fa5f42b..e61b3afd80 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 @@ -12,6 +12,7 @@ import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition import eu.kanade.tachiyomi.ui.reader.model.ReaderPage import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters import eu.kanade.tachiyomi.ui.reader.viewer.BaseViewer +import eu.kanade.tachiyomi.util.view.visible import rx.subscriptions.CompositeSubscription import timber.log.Timber import kotlin.math.max @@ -126,10 +127,10 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr private fun checkAllowPreload(page: ReaderPage?): Boolean { // Page is transition page - preload allowed - page == null ?: return true + page ?: return true // Initial opening - preload allowed - currentPage == null ?: return true + currentPage ?: return true val nextItem = adapter.items.getOrNull(adapter.items.count() - 1) val nextChapter = (nextItem as? ChapterTransition.Next)?.to ?: (nextItem as? ReaderPage)?.chapter @@ -137,7 +138,7 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr // Allow preload for // 1. Going between pages of same chapter // 2. Next chapter page - return when (page!!.chapter) { + return when (page.chapter) { (currentPage as? ReaderPage)?.chapter -> true nextChapter -> true else -> false @@ -156,7 +157,6 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr */ override fun destroy() { super.destroy() - config.unsubscribe() subscriptions.unsubscribe() } @@ -165,12 +165,12 @@ 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 - Timber.d("onPageSelected: ${page.number}/${pages.size}") activity.onPageSelected(page) - // Preload next chapter once we're within the last 3 pages of the current chapter - val inPreloadRange = pages.size - page.number < 3 + val pages = page.chapter.pages ?: return + Timber.d("onReaderPageSelected: ${page.number}/${pages.size}") + // Preload next chapter once we're within the last 5 pages of the current chapter + val inPreloadRange = pages.size - page.number < 5 if (inPreloadRange && allowPreload && page.chapter == adapter.currentChapter) { Timber.d("Request preload next chapter because we're at page ${page.number} of ${pages.size}") val nextItem = adapter.items.getOrNull(adapter.items.size - 1) @@ -210,7 +210,7 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr Timber.d("Recycler first layout") val pages = chapters.currChapter.pages ?: return moveToPage(pages[chapters.currChapter.requestedPage]) - recycler.visibility = View.VISIBLE + recycler.visible() } } diff --git a/app/src/main/res/layout/reader_activity.xml b/app/src/main/res/layout/reader_activity.xml index 5948439b41..704166eb76 100644 --- a/app/src/main/res/layout/reader_activity.xml +++ b/app/src/main/res/layout/reader_activity.xml @@ -1,4 +1,4 @@ - @@ -34,13 +35,11 @@ - + android:visibility="gone" /> - - - + - - - +