Notify first page change
This commit is contained in:
parent
24bdee626f
commit
7c3cd10696
@ -20,6 +20,7 @@ import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
import eu.kanade.tachiyomi.data.source.model.Page
|
||||
import eu.kanade.tachiyomi.ui.base.activity.BaseRxActivity
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.base.BaseReader
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.pager.horizontal.LeftToRightReader
|
||||
@ -308,15 +309,18 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||
return fragment
|
||||
}
|
||||
|
||||
fun onPageChanged(currentPageIndex: Int, totalPages: Int) {
|
||||
val page = currentPageIndex + 1
|
||||
page_number.text = "$page/$totalPages"
|
||||
fun onPageChanged(page: Page) {
|
||||
presenter.onPageChanged(page)
|
||||
|
||||
val pageNumber = page.pageNumber + 1
|
||||
val pageCount = page.chapter.pages!!.size
|
||||
page_number.text = "$pageNumber/$pageCount"
|
||||
if (page_seekbar.rotation != 180f) {
|
||||
left_page_text.text = "$page"
|
||||
left_page_text.text = "$pageNumber"
|
||||
} else {
|
||||
right_page_text.text = "$page"
|
||||
right_page_text.text = "$pageNumber"
|
||||
}
|
||||
page_seekbar.progress = currentPageIndex
|
||||
page_seekbar.progress = page.pageNumber
|
||||
}
|
||||
|
||||
fun gotoPageInCurrentChapter(pageIndex: Int) {
|
||||
@ -326,7 +330,6 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||
val requestedPage = activePage.chapter.pages!![pageIndex]
|
||||
it.setActivePage(requestedPage)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,16 +66,6 @@ abstract class BaseReader : BaseFragment() {
|
||||
*/
|
||||
private var hasRequestedNextChapter: Boolean = false
|
||||
|
||||
/**
|
||||
* Updates the reader activity with the active page.
|
||||
*/
|
||||
fun updatePageNumber() {
|
||||
val activePage = getActivePage()
|
||||
if (activePage != null) {
|
||||
readerActivity.onPageChanged(activePage.pageNumber, activePage.chapter.pages!!.size)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the active page.
|
||||
*/
|
||||
@ -91,11 +81,13 @@ abstract class BaseReader : BaseFragment() {
|
||||
fun onPageChanged(position: Int) {
|
||||
val oldPage = pages[currentPage]
|
||||
val newPage = pages[position]
|
||||
readerActivity.presenter.onPageChanged(newPage)
|
||||
|
||||
val oldChapter = oldPage.chapter
|
||||
val newChapter = newPage.chapter
|
||||
|
||||
// Update page indicator and seekbar
|
||||
readerActivity.onPageChanged(newPage)
|
||||
|
||||
// Active chapter has changed.
|
||||
if (oldChapter.id != newChapter.id) {
|
||||
readerActivity.onEnterChapter(newPage.chapter, newPage.pageNumber)
|
||||
@ -108,7 +100,6 @@ abstract class BaseReader : BaseFragment() {
|
||||
}
|
||||
|
||||
currentPage = position
|
||||
updatePageNumber()
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -219,8 +219,11 @@ abstract class PagerReader : BaseReader() {
|
||||
protected fun setPagesOnAdapter() {
|
||||
if (pages.isNotEmpty()) {
|
||||
adapter.pages = pages
|
||||
if (currentPage == pager.currentItem) {
|
||||
onPageChanged(currentPage)
|
||||
} else {
|
||||
setActivePage(currentPage)
|
||||
updatePageNumber()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,7 @@ class WebtoonReader : BaseReader() {
|
||||
if (pages.isNotEmpty()) {
|
||||
adapter.pages = pages
|
||||
recycler.adapter = adapter
|
||||
updatePageNumber()
|
||||
onPageChanged(currentPage)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user