mirror of
https://github.com/mihonapp/mihon.git
synced 2025-06-26 19:17:51 +02:00
Add retry all and boost page
This commit is contained in:
@ -118,12 +118,27 @@ class ChapterLoader(
|
||||
}
|
||||
}
|
||||
|
||||
fun loadPage(page: Page) {
|
||||
queue.offer(PriorityPage(page, 0))
|
||||
}
|
||||
|
||||
fun loadPriorizedPage(page: Page) {
|
||||
queue.offer(PriorityPage(page, 1))
|
||||
}
|
||||
|
||||
fun retryPage(page: Page) {
|
||||
if(source is HttpSource && prefs.eh_readerInstantRetry().getOrDefault())
|
||||
// --> EH
|
||||
if(prefs.eh_readerInstantRetry().getOrDefault())
|
||||
boostPage(page)
|
||||
else
|
||||
// <-- EH
|
||||
queue.offer(PriorityPage(page, 2))
|
||||
}
|
||||
|
||||
|
||||
// --> EH
|
||||
fun boostPage(page: Page) {
|
||||
if(source is HttpSource && page.status == Page.QUEUE)
|
||||
subscriptions += Observable.just(page)
|
||||
.concatMap { source.fetchImageFromCacheThenNet(it) }
|
||||
.subscribeOn(Schedulers.io())
|
||||
@ -133,10 +148,8 @@ class ChapterLoader(
|
||||
Timber.e(error)
|
||||
}
|
||||
})
|
||||
else
|
||||
queue.offer(PriorityPage(page, 2))
|
||||
}
|
||||
|
||||
// <-- EH
|
||||
|
||||
|
||||
private data class PriorityPage(val page: Page, val priority: Int): Comparable<PriorityPage> {
|
||||
|
@ -23,6 +23,7 @@ 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.source.model.Page
|
||||
import eu.kanade.tachiyomi.source.online.all.EHentai
|
||||
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
|
||||
@ -201,6 +202,63 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||
.positiveText("Ok")
|
||||
.show()
|
||||
}
|
||||
|
||||
subscriptions += eh_retry_all.clicks().subscribe {
|
||||
viewer?.pages?.forEachIndexed { index, page ->
|
||||
if(page.status == Page.ERROR)
|
||||
page.status = Page.QUEUE
|
||||
else
|
||||
return@forEachIndexed
|
||||
|
||||
//If we are using EHentai/ExHentai, get a new image URL
|
||||
if(presenter.source is EHentai)
|
||||
page.imageUrl = null
|
||||
|
||||
if(viewer?.currentPage == index)
|
||||
presenter.loader.loadPriorizedPage(page)
|
||||
else
|
||||
presenter.loader.loadPage(page)
|
||||
}
|
||||
|
||||
toast("Retrying all failed pages...")
|
||||
}
|
||||
|
||||
subscriptions += eh_retry_all_help.clicks().subscribe {
|
||||
MaterialDialog.Builder(this)
|
||||
.title("Retry all help")
|
||||
.content("Re-add all failed pages to the download queue.")
|
||||
.positiveText("Ok")
|
||||
.show()
|
||||
}
|
||||
|
||||
subscriptions += eh_boost_page.clicks().subscribe {
|
||||
viewer?.let { viewer ->
|
||||
val curPage = viewer.pages.getOrNull(viewer.currentPage)
|
||||
?: run {
|
||||
toast("Cannot find current page!")
|
||||
return@let
|
||||
}
|
||||
|
||||
if(curPage.status == Page.ERROR) {
|
||||
toast("Page failed to load, press the retry button instead!")
|
||||
} else if(curPage.status == Page.LOAD_PAGE || curPage.status == Page.DOWNLOAD_IMAGE) {
|
||||
toast("This page is already downloading!")
|
||||
} else if(curPage.status == Page.READY) {
|
||||
toast("This page has already been downloaded!")
|
||||
} else {
|
||||
presenter.loader.boostPage(curPage)
|
||||
toast("Boosted current page!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
subscriptions += eh_boost_page_help.clicks().subscribe {
|
||||
MaterialDialog.Builder(this)
|
||||
.title("Boost page help")
|
||||
.content("Normally the downloader can only download a specific amount of pages at the same time. This means you can be waiting for a page to download but the downloader will not start downloading the page until it has a free download slot. Pressing 'Boost page' will force the downloader to begin downloading the current page, regardless of whether or not there is an available slot.")
|
||||
.positiveText("Ok")
|
||||
.show()
|
||||
}
|
||||
// <-- EH
|
||||
}
|
||||
|
||||
@ -630,7 +688,10 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||
header.startAnimation(toolbarAnimation)
|
||||
|
||||
val bottomMenuAnimation = AnimationUtils.loadAnimation(this, R.anim.enter_from_bottom)
|
||||
// --> EH
|
||||
// toolbar.startAnimation(bottomMenuAnimation)
|
||||
reader_menu_bottom.startAnimation(bottomMenuAnimation)
|
||||
// <-- EH
|
||||
}
|
||||
} else {
|
||||
systemUi?.hide()
|
||||
@ -645,7 +706,10 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||
header.startAnimation(toolbarAnimation)
|
||||
|
||||
val bottomMenuAnimation = AnimationUtils.loadAnimation(this, R.anim.exit_to_bottom)
|
||||
// --> EH
|
||||
// toolbar.startAnimation(bottomMenuAnimation)
|
||||
reader_menu_bottom.startAnimation(bottomMenuAnimation)
|
||||
// <-- EH
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -691,7 +755,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||
|
||||
// --> EH
|
||||
private fun setupAutoscroll(interval: Float) {
|
||||
autoscrollSubscription?.unsubscribe()
|
||||
subscriptions.remove(autoscrollSubscription)
|
||||
autoscrollSubscription = null
|
||||
|
||||
if(interval == -1f) return
|
||||
|
@ -75,7 +75,7 @@ class ReaderPresenter(
|
||||
/**
|
||||
* Source of the manga.
|
||||
*/
|
||||
private val source by lazy { sourceManager.get(manga.source)!! }
|
||||
/* private */ val source by lazy { sourceManager.get(manga.source)!! }
|
||||
|
||||
/**
|
||||
* Chapter list for the active manga. It's retrieved lazily and should be accessed for the first
|
||||
@ -106,7 +106,7 @@ class ReaderPresenter(
|
||||
/**
|
||||
* Chapter loader whose job is to obtain the chapter list and initialize every page.
|
||||
*/
|
||||
private val loader by lazy { ChapterLoader(downloadManager, manga, source) }
|
||||
/* private */ val loader by lazy { ChapterLoader(downloadManager, manga, source) }
|
||||
|
||||
/**
|
||||
* Subscription for appending a chapter to the reader (seamless mode).
|
||||
@ -334,9 +334,11 @@ class ReaderPresenter(
|
||||
chapterCache.removeFileFromCache(key)
|
||||
}
|
||||
|
||||
// --> EH
|
||||
//If we are using EHentai/ExHentai, get a new image URL
|
||||
if(source is EHentai)
|
||||
page.imageUrl = null
|
||||
// <-- EH
|
||||
|
||||
loader.retryPage(page)
|
||||
}
|
||||
|
@ -94,6 +94,44 @@
|
||||
android:text="\?" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/eh_retry_all"
|
||||
style="?android:attr/borderlessButtonStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Retry all" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/eh_retry_all_help"
|
||||
style="?android:attr/borderlessButtonStyle"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="\?" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/eh_boost_page"
|
||||
style="?android:attr/borderlessButtonStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Boost page" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/eh_boost_page_help"
|
||||
style="?android:attr/borderlessButtonStyle"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="\?" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageButton
|
||||
|
Reference in New Issue
Block a user