Add aggressive page loading

This commit is contained in:
NerdNumber9 2019-04-19 03:02:30 -04:00
parent ea7ff432b2
commit 2a60c828d7
4 changed files with 24 additions and 2 deletions

View File

@ -192,4 +192,6 @@ object PreferenceKeys {
const val eh_autoUpdateRestrictions = "eh_auto_update_restrictions"
const val eh_autoUpdateStats = "eh_auto_update_stats"
const val eh_aggressivePageLoading = "eh_aggressive_page_loading"
}

View File

@ -265,4 +265,6 @@ class PreferencesHelper(val context: Context) {
fun eh_autoUpdateRequirements() = prefs.getStringSet(Keys.eh_autoUpdateRestrictions, emptySet())
fun eh_autoUpdateStats() = rxPrefs.getString(Keys.eh_autoUpdateStats, "")
fun eh_aggressivePageLoading() = rxPrefs.getBoolean(Keys.eh_aggressivePageLoading, false)
}

View File

@ -52,7 +52,11 @@ class HttpPageLoader(
// EXH <--
subscriptions += Observable.defer { Observable.just(queue.take().page) }
.filter { it.status == Page.QUEUE }
.concatMap { source.fetchImageFromCacheThenNet(it) }
.concatMap {
source.fetchImageFromCacheThenNet(it).doOnNext {
XLog.d("Downloaded page: ${it.number}!")
}
}
.repeat()
.subscribeOn(Schedulers.io())
.subscribe({
@ -98,9 +102,17 @@ class HttpPageLoader(
.getPageListFromCache(chapter.chapter)
.onErrorResumeNext { source.fetchPageList(chapter.chapter) }
.map { pages ->
pages.mapIndexed { index, page -> // Don't trust sources and use our own indexing
val rp = pages.mapIndexed { index, page -> // Don't trust sources and use our own indexing
ReaderPage(index, page.url, page.imageUrl)
}
if(prefs.eh_aggressivePageLoading().getOrDefault()) {
rp.mapNotNull {
if (it.status == Page.QUEUE) {
PriorityPage(it, 0)
} else null
}.forEach { queue.offer(it) }
}
rp
}
}

View File

@ -100,6 +100,12 @@ class SettingsReaderController : SettingsController() {
defaultValue = "2"
summary = "Higher values can speed up image downloading significantly, but can also trigger bans. Recommended value is 2 or 3. Current value is: %s"
}
switchPreference {
key = Keys.eh_aggressivePageLoading
title = "Aggressively load pages"
summary = "Slowly download the entire gallery while reading instead of just loading the pages you are viewing."
defaultValue = true
}
switchPreference {
key = Keys.eh_readerInstantRetry
title = "Skip queue on retry"