fix preload never being restricted (#3012)

Fix preload never being restricted
This commit is contained in:
Gennadiy Stas 2020-05-02 01:03:27 +03:00 committed by GitHub
parent 33e0a34916
commit e29fb68375
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View file

@ -132,16 +132,16 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
private fun checkAllowPreload(page: ReaderPage?): Boolean { private fun checkAllowPreload(page: ReaderPage?): Boolean {
// Page is transition page - preload allowed // Page is transition page - preload allowed
page == null ?: return true page ?: return true
// Initial opening - preload allowed // Initial opening - preload allowed
currentPage == null ?: return true currentPage ?: return true
// Allow preload for // Allow preload for
// 1. Going to next chapter from chapter transition // 1. Going to next chapter from chapter transition
// 2. Going between pages of same chapter // 2. Going between pages of same chapter
// 3. Next chapter page // 3. Next chapter page
return when (page!!.chapter) { return when (page.chapter) {
(currentPage as? ChapterTransition.Next)?.to -> true (currentPage as? ChapterTransition.Next)?.to -> true
(currentPage as? ReaderPage)?.chapter -> true (currentPage as? ReaderPage)?.chapter -> true
adapter.nextTransition?.to -> true adapter.nextTransition?.to -> true

View file

@ -125,10 +125,10 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
private fun checkAllowPreload(page: ReaderPage?): Boolean { private fun checkAllowPreload(page: ReaderPage?): Boolean {
// Page is transition page - preload allowed // Page is transition page - preload allowed
page == null ?: return true page ?: return true
// Initial opening - preload allowed // Initial opening - preload allowed
currentPage == null ?: return true currentPage ?: return true
val nextItem = adapter.items.getOrNull(adapter.items.count() - 1) val nextItem = adapter.items.getOrNull(adapter.items.count() - 1)
val nextChapter = (nextItem as? ChapterTransition.Next)?.to ?: (nextItem as? ReaderPage)?.chapter val nextChapter = (nextItem as? ChapterTransition.Next)?.to ?: (nextItem as? ReaderPage)?.chapter
@ -136,7 +136,7 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
// Allow preload for // Allow preload for
// 1. Going between pages of same chapter // 1. Going between pages of same chapter
// 2. Next chapter page // 2. Next chapter page
return when (page!!.chapter) { return when (page.chapter) {
(currentPage as? ReaderPage)?.chapter -> true (currentPage as? ReaderPage)?.chapter -> true
nextChapter -> true nextChapter -> true
else -> false else -> false