mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-13 14:17:30 +01:00
Download the first image of the next chapter
This commit is contained in:
parent
aada373a0c
commit
6aa07dd17e
1 changed files with 17 additions and 6 deletions
|
@ -30,6 +30,7 @@ import rx.Observable;
|
||||||
import rx.android.schedulers.AndroidSchedulers;
|
import rx.android.schedulers.AndroidSchedulers;
|
||||||
import rx.schedulers.Schedulers;
|
import rx.schedulers.Schedulers;
|
||||||
import rx.subjects.PublishSubject;
|
import rx.subjects.PublishSubject;
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
public class ReaderPresenter extends BasePresenter<ReaderActivity> {
|
public class ReaderPresenter extends BasePresenter<ReaderActivity> {
|
||||||
|
|
||||||
|
@ -70,9 +71,16 @@ public class ReaderPresenter extends BasePresenter<ReaderActivity> {
|
||||||
|
|
||||||
retryPageSubject = PublishSubject.create();
|
retryPageSubject = PublishSubject.create();
|
||||||
|
|
||||||
startable(PRELOAD_NEXT_CHAPTER, this::getPreloadNextChapterObservable);
|
startable(PRELOAD_NEXT_CHAPTER, this::getPreloadNextChapterObservable,
|
||||||
startable(GET_PAGE_IMAGES, this::getPageImagesObservable);
|
next -> {},
|
||||||
|
error -> Timber.e("Error preloading chapter"));
|
||||||
|
|
||||||
|
startable(GET_PAGE_IMAGES, this::getPageImagesObservable,
|
||||||
|
next -> {},
|
||||||
|
error -> Timber.e("Error fetching images"));
|
||||||
|
|
||||||
startable(GET_ADJACENT_CHAPTERS, this::getAdjacentChaptersObservable);
|
startable(GET_ADJACENT_CHAPTERS, this::getAdjacentChaptersObservable);
|
||||||
|
|
||||||
startable(RETRY_IMAGES, this::getRetryPageObservable);
|
startable(RETRY_IMAGES, this::getRetryPageObservable);
|
||||||
|
|
||||||
restartable(GET_MANGA_SYNC, () -> getMangaSyncObservable().subscribe());
|
restartable(GET_MANGA_SYNC, () -> getMangaSyncObservable().subscribe());
|
||||||
|
@ -151,8 +159,7 @@ public class ReaderPresenter extends BasePresenter<ReaderActivity> {
|
||||||
.doOnNext(pair -> {
|
.doOnNext(pair -> {
|
||||||
previousChapter = pair.first;
|
previousChapter = pair.first;
|
||||||
nextChapter = pair.second;
|
nextChapter = pair.second;
|
||||||
})
|
});
|
||||||
.observeOn(AndroidSchedulers.mainThread());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Listen for retry page events
|
// Listen for retry page events
|
||||||
|
@ -162,8 +169,7 @@ public class ReaderPresenter extends BasePresenter<ReaderActivity> {
|
||||||
.flatMap(page -> page.getImageUrl() == null ?
|
.flatMap(page -> page.getImageUrl() == null ?
|
||||||
source.getImageUrlFromPage(page) :
|
source.getImageUrlFromPage(page) :
|
||||||
Observable.just(page))
|
Observable.just(page))
|
||||||
.flatMap(source::getCachedImage)
|
.flatMap(source::getCachedImage);
|
||||||
.observeOn(AndroidSchedulers.mainThread());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preload the first pages of the next chapter
|
// Preload the first pages of the next chapter
|
||||||
|
@ -175,9 +181,14 @@ public class ReaderPresenter extends BasePresenter<ReaderActivity> {
|
||||||
int pagesToPreload = Math.min(pages.size(), 5);
|
int pagesToPreload = Math.min(pages.size(), 5);
|
||||||
return Observable.from(pages).take(pagesToPreload);
|
return Observable.from(pages).take(pagesToPreload);
|
||||||
})
|
})
|
||||||
|
// Preload up to 5 images
|
||||||
.concatMap(page -> page.getImageUrl() == null ?
|
.concatMap(page -> page.getImageUrl() == null ?
|
||||||
source.getImageUrlFromPage(page) :
|
source.getImageUrlFromPage(page) :
|
||||||
Observable.just(page))
|
Observable.just(page))
|
||||||
|
// Download the first image
|
||||||
|
.concatMap(page -> page.getPageNumber() == 0 ?
|
||||||
|
source.getCachedImage(page) :
|
||||||
|
Observable.just(page))
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.doOnCompleted(this::stopPreloadingNextChapter);
|
.doOnCompleted(this::stopPreloadingNextChapter);
|
||||||
|
|
Loading…
Reference in a new issue