mirror of
https://github.com/mihonapp/mihon.git
synced 2024-12-24 18:08:24 +01:00
Fix NPE when the process restarts in the reader for downloaded chapters and save page list before killing the process.
This commit is contained in:
parent
3c87b4cba9
commit
9a117f0969
@ -1,6 +1,7 @@
|
|||||||
package eu.kanade.mangafeed.ui.reader;
|
package eu.kanade.mangafeed.ui.reader;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -65,6 +66,22 @@ public class ReaderPresenter extends BasePresenter<ReaderActivity> {
|
|||||||
|
|
||||||
retryPageSubject = PublishSubject.create();
|
retryPageSubject = PublishSubject.create();
|
||||||
|
|
||||||
|
restartableLatestCache(PRELOAD_NEXT_CHAPTER,
|
||||||
|
this::getPreloadNextChapterObservable,
|
||||||
|
(view, pages) -> {},
|
||||||
|
(view, error) -> Timber.e("An error occurred while preloading a chapter"));
|
||||||
|
|
||||||
|
restartableReplay(GET_PAGE_IMAGES,
|
||||||
|
() -> getPageImagesObservable()
|
||||||
|
.doOnCompleted(this::preloadNextChapter),
|
||||||
|
(view, page) -> {},
|
||||||
|
(view, error) -> Timber.e("An error occurred while downloading an image"));
|
||||||
|
|
||||||
|
restartableLatestCache(RETRY_IMAGES,
|
||||||
|
this::getRetryPageObservable,
|
||||||
|
(view, page) -> {},
|
||||||
|
(view, error) -> Timber.e("An error occurred while downloading an image"));
|
||||||
|
|
||||||
restartableLatestCache(GET_PAGE_LIST,
|
restartableLatestCache(GET_PAGE_LIST,
|
||||||
() -> getPageListObservable()
|
() -> getPageListObservable()
|
||||||
.doOnNext(pages -> pageList = pages)
|
.doOnNext(pages -> pageList = pages)
|
||||||
@ -80,22 +97,6 @@ public class ReaderPresenter extends BasePresenter<ReaderActivity> {
|
|||||||
},
|
},
|
||||||
(view, error) -> view.onChapterError());
|
(view, error) -> view.onChapterError());
|
||||||
|
|
||||||
restartableReplay(GET_PAGE_IMAGES,
|
|
||||||
() -> getPageImagesObservable()
|
|
||||||
.doOnCompleted(this::preloadNextChapter),
|
|
||||||
(view, page) -> {},
|
|
||||||
(view, error) -> Timber.e("An error occurred while downloading an image"));
|
|
||||||
|
|
||||||
restartableLatestCache(RETRY_IMAGES,
|
|
||||||
this::getRetryPageObservable,
|
|
||||||
(view, page) -> {},
|
|
||||||
(view, error) -> Timber.e("An error occurred while downloading an image"));
|
|
||||||
|
|
||||||
restartableLatestCache(PRELOAD_NEXT_CHAPTER,
|
|
||||||
this::getPreloadNextChapterObservable,
|
|
||||||
(view, pages) -> {},
|
|
||||||
(view, error) -> Timber.e("An error occurred while preloading a chapter"));
|
|
||||||
|
|
||||||
registerForStickyEvents();
|
registerForStickyEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,6 +108,14 @@ public class ReaderPresenter extends BasePresenter<ReaderActivity> {
|
|||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSave(@NonNull Bundle state) {
|
||||||
|
if (pageList != null && !isDownloaded)
|
||||||
|
source.savePageList(chapter.url, pageList);
|
||||||
|
|
||||||
|
super.onSave(state);
|
||||||
|
}
|
||||||
|
|
||||||
private void onProcessRestart() {
|
private void onProcessRestart() {
|
||||||
source = sourceManager.get(sourceId);
|
source = sourceManager.get(sourceId);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user