mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-14 06:22:49 +01:00
Make active page nullable. Fixes #326
This commit is contained in:
parent
0714fdc7e6
commit
728ab18017
@ -117,7 +117,10 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
|||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
viewer?.let {
|
viewer?.let {
|
||||||
presenter.currentPage = it.getActivePage()
|
val activePage = it.getActivePage()
|
||||||
|
if (activePage != null) {
|
||||||
|
presenter.currentPage = activePage
|
||||||
|
}
|
||||||
}
|
}
|
||||||
super.onPause()
|
super.onPause()
|
||||||
}
|
}
|
||||||
@ -318,9 +321,13 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
|||||||
|
|
||||||
fun gotoPageInCurrentChapter(pageIndex: Int) {
|
fun gotoPageInCurrentChapter(pageIndex: Int) {
|
||||||
viewer?.let {
|
viewer?.let {
|
||||||
val requestedPage = it.getActivePage().chapter.pages[pageIndex]
|
val activePage = it.getActivePage()
|
||||||
|
if (activePage != null) {
|
||||||
|
val requestedPage = activePage.chapter.pages[pageIndex]
|
||||||
it.setActivePage(requestedPage)
|
it.setActivePage(requestedPage)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toggleMenu() {
|
fun toggleMenu() {
|
||||||
|
@ -71,14 +71,16 @@ abstract class BaseReader : BaseFragment() {
|
|||||||
*/
|
*/
|
||||||
fun updatePageNumber() {
|
fun updatePageNumber() {
|
||||||
val activePage = getActivePage()
|
val activePage = getActivePage()
|
||||||
|
if (activePage != null) {
|
||||||
readerActivity.onPageChanged(activePage.pageNumber, activePage.chapter.pages.size)
|
readerActivity.onPageChanged(activePage.pageNumber, activePage.chapter.pages.size)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the active page.
|
* Returns the active page.
|
||||||
*/
|
*/
|
||||||
fun getActivePage(): Page {
|
fun getActivePage(): Page? {
|
||||||
return pages.getOrElse(currentPage) { pages[0] }
|
return pages.getOrNull(currentPage)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user