From 51d0a6790833692e9061243f61bb99c49b1f53a2 Mon Sep 17 00:00:00 2001 From: Jobobby04 Date: Tue, 11 Aug 2020 15:20:11 -0400 Subject: [PATCH] Account for custom delegated image requests, fixes Hitomi pages --- .../main/java/exh/source/DelegatedHttpSource.kt | 16 ++++++++++++++++ .../main/java/exh/source/EnhancedHttpSource.kt | 7 +++++++ 2 files changed, 23 insertions(+) diff --git a/app/src/main/java/exh/source/DelegatedHttpSource.kt b/app/src/main/java/exh/source/DelegatedHttpSource.kt index 9b7ea856f..43818428d 100644 --- a/app/src/main/java/exh/source/DelegatedHttpSource.kt +++ b/app/src/main/java/exh/source/DelegatedHttpSource.kt @@ -99,6 +99,12 @@ abstract class DelegatedHttpSource(val delegate: HttpSource) : HttpSource() { */ override val baseUrl get() = delegate.baseUrl + /** + * Version id used to generate the source id. If the site completely changes and urls are + * incompatible, you may increase this value and it'll be considered as a new source. + */ + override val versionId get() = delegate.versionId + /** * Whether the source has support for latest updates. */ @@ -221,6 +227,16 @@ abstract class DelegatedHttpSource(val delegate: HttpSource) : HttpSource() { return delegate.fetchImageUrl(page) } + /** + * Returns an observable with the response of the source image. + * + * @param page the page whose source image has to be downloaded. + */ + override fun fetchImage(page: Page): Observable { + ensureDelegateCompatible() + return delegate.fetchImage(page) + } + /** * Called before inserting a new chapter into database. Use it if you need to override chapter * fields, like the title or the chapter number. Do not change anything to [manga]. diff --git a/app/src/main/java/exh/source/EnhancedHttpSource.kt b/app/src/main/java/exh/source/EnhancedHttpSource.kt index 03c846a32..c95860d44 100644 --- a/app/src/main/java/exh/source/EnhancedHttpSource.kt +++ b/app/src/main/java/exh/source/EnhancedHttpSource.kt @@ -200,6 +200,13 @@ class EnhancedHttpSource( */ override fun fetchImageUrl(page: Page) = source().fetchImageUrl(page) + /** + * Returns an observable with the response of the source image. + * + * @param page the page whose source image has to be downloaded. + */ + override fun fetchImage(page: Page) = source().fetchImage(page) + /** * Called before inserting a new chapter into database. Use it if you need to override chapter * fields, like the title or the chapter number. Do not change anything to [manga].