mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-08-17 21:49:11 +02:00
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.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
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.base.activity.BaseRxActivity
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.base.BaseReader
|
import eu.kanade.tachiyomi.ui.reader.viewer.base.BaseReader
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.pager.horizontal.LeftToRightReader
|
import eu.kanade.tachiyomi.ui.reader.viewer.pager.horizontal.LeftToRightReader
|
||||||
@ -308,15 +309,18 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
|||||||
return fragment
|
return fragment
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onPageChanged(currentPageIndex: Int, totalPages: Int) {
|
fun onPageChanged(page: Page) {
|
||||||
val page = currentPageIndex + 1
|
presenter.onPageChanged(page)
|
||||||
page_number.text = "$page/$totalPages"
|
|
||||||
|
val pageNumber = page.pageNumber + 1
|
||||||
|
val pageCount = page.chapter.pages!!.size
|
||||||
|
page_number.text = "$pageNumber/$pageCount"
|
||||||
if (page_seekbar.rotation != 180f) {
|
if (page_seekbar.rotation != 180f) {
|
||||||
left_page_text.text = "$page"
|
left_page_text.text = "$pageNumber"
|
||||||
} else {
|
} else {
|
||||||
right_page_text.text = "$page"
|
right_page_text.text = "$pageNumber"
|
||||||
}
|
}
|
||||||
page_seekbar.progress = currentPageIndex
|
page_seekbar.progress = page.pageNumber
|
||||||
}
|
}
|
||||||
|
|
||||||
fun gotoPageInCurrentChapter(pageIndex: Int) {
|
fun gotoPageInCurrentChapter(pageIndex: Int) {
|
||||||
@ -326,7 +330,6 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
|||||||
val requestedPage = activePage.chapter.pages!![pageIndex]
|
val requestedPage = activePage.chapter.pages!![pageIndex]
|
||||||
it.setActivePage(requestedPage)
|
it.setActivePage(requestedPage)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,16 +66,6 @@ abstract class BaseReader : BaseFragment() {
|
|||||||
*/
|
*/
|
||||||
private var hasRequestedNextChapter: Boolean = false
|
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.
|
* Returns the active page.
|
||||||
*/
|
*/
|
||||||
@ -91,11 +81,13 @@ abstract class BaseReader : BaseFragment() {
|
|||||||
fun onPageChanged(position: Int) {
|
fun onPageChanged(position: Int) {
|
||||||
val oldPage = pages[currentPage]
|
val oldPage = pages[currentPage]
|
||||||
val newPage = pages[position]
|
val newPage = pages[position]
|
||||||
readerActivity.presenter.onPageChanged(newPage)
|
|
||||||
|
|
||||||
val oldChapter = oldPage.chapter
|
val oldChapter = oldPage.chapter
|
||||||
val newChapter = newPage.chapter
|
val newChapter = newPage.chapter
|
||||||
|
|
||||||
|
// Update page indicator and seekbar
|
||||||
|
readerActivity.onPageChanged(newPage)
|
||||||
|
|
||||||
// Active chapter has changed.
|
// Active chapter has changed.
|
||||||
if (oldChapter.id != newChapter.id) {
|
if (oldChapter.id != newChapter.id) {
|
||||||
readerActivity.onEnterChapter(newPage.chapter, newPage.pageNumber)
|
readerActivity.onEnterChapter(newPage.chapter, newPage.pageNumber)
|
||||||
@ -108,7 +100,6 @@ abstract class BaseReader : BaseFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
currentPage = position
|
currentPage = position
|
||||||
updatePageNumber()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -219,8 +219,11 @@ abstract class PagerReader : BaseReader() {
|
|||||||
protected fun setPagesOnAdapter() {
|
protected fun setPagesOnAdapter() {
|
||||||
if (pages.isNotEmpty()) {
|
if (pages.isNotEmpty()) {
|
||||||
adapter.pages = pages
|
adapter.pages = pages
|
||||||
|
if (currentPage == pager.currentItem) {
|
||||||
|
onPageChanged(currentPage)
|
||||||
|
} else {
|
||||||
setActivePage(currentPage)
|
setActivePage(currentPage)
|
||||||
updatePageNumber()
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ class WebtoonReader : BaseReader() {
|
|||||||
if (pages.isNotEmpty()) {
|
if (pages.isNotEmpty()) {
|
||||||
adapter.pages = pages
|
adapter.pages = pages
|
||||||
recycler.adapter = adapter
|
recycler.adapter = adapter
|
||||||
updatePageNumber()
|
onPageChanged(currentPage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user