Reader fixes and minor changes

This commit is contained in:
len
2016-06-02 14:11:10 +02:00
parent 18cdddf433
commit 1ac8ef5341
6 changed files with 70 additions and 35 deletions

View File

@@ -226,19 +226,24 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
// Ignore
}
fun onChapterReady(manga: Manga, chapter: Chapter, currentPage: Page?) {
val activePage = currentPage ?: chapter.pages.last()
fun onMangaOpen(manga: Manga) {
if (viewer == null) {
viewer = getOrCreateViewer(manga)
}
viewer?.onPageListReady(chapter, activePage)
if (viewer is RightToLeftReader && page_seekbar.rotation != 180f) {
// Invert the seekbar for the right to left reader
page_seekbar.rotation = 180f
}
setToolbarTitle(manga.title)
please_wait.visibility = View.VISIBLE
please_wait.startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_in_long))
}
fun onChapterReady(manga: Manga, chapter: Chapter, currentPage: Page?) {
please_wait.visibility = View.GONE
val activePage = currentPage ?: chapter.pages.last()
viewer?.onPageListReady(chapter, activePage)
setActiveChapter(chapter, activePage.pageNumber)
}

View File

@@ -57,10 +57,11 @@ class ReaderPresenter : BasePresenter<ReaderActivity>() {
private var appenderSubscription: Subscription? = null
private val GET_PAGE_LIST = 1
private val GET_ADJACENT_CHAPTERS = 2
private val GET_MANGA_SYNC = 3
private val PRELOAD_NEXT_CHAPTER = 4
private val PREPARE_READER = 1
private val GET_PAGE_LIST = 2
private val GET_ADJACENT_CHAPTERS = 3
private val GET_MANGA_SYNC = 4
private val PRELOAD_NEXT_CHAPTER = 5
private val MANGA_KEY = "manga_key"
private val CHAPTER_KEY = "chapter_key"
@@ -83,6 +84,10 @@ class ReaderPresenter : BasePresenter<ReaderActivity>() {
initializeSubjects()
restartableLatestCache(PREPARE_READER,
{ Observable.just(manga) },
{ view, manga -> view.onMangaOpen(manga) })
startableLatestCache(GET_ADJACENT_CHAPTERS,
{ getAdjacentChaptersObservable() },
{ view, pair -> view.onAdjacentChapters(pair.first, pair.second) })
@@ -102,6 +107,7 @@ class ReaderPresenter : BasePresenter<ReaderActivity>() {
{ view, error -> view.onChapterError(error) })
if (savedState == null) {
start(PREPARE_READER)
loadChapter(chapter)
if (prefs.autoUpdateMangaSync()) {
start(GET_MANGA_SYNC)

View File

@@ -98,7 +98,11 @@ class WebtoonReader : BaseReader() {
.doOnNext { setDecoderClass(it) }
.skip(1)
.distinctUntilChanged()
.subscribe { recycler.adapter = adapter })
.subscribe {
val activePage = layoutManager.findFirstVisibleItemPosition()
recycler.adapter = adapter
setActivePage(activePage)
})
setPagesOnAdapter()
return recycler