mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 12:01:52 +01:00
Recover manga activity status when the process restarts
This commit is contained in:
parent
e7f8d4d2c2
commit
a571bb5637
@ -8,6 +8,7 @@ import de.greenrobot.event.EventBus;
|
|||||||
import eu.kanade.mangafeed.data.database.DatabaseHelper;
|
import eu.kanade.mangafeed.data.database.DatabaseHelper;
|
||||||
import eu.kanade.mangafeed.data.database.models.Manga;
|
import eu.kanade.mangafeed.data.database.models.Manga;
|
||||||
import eu.kanade.mangafeed.ui.base.presenter.BasePresenter;
|
import eu.kanade.mangafeed.ui.base.presenter.BasePresenter;
|
||||||
|
import icepick.State;
|
||||||
import rx.Observable;
|
import rx.Observable;
|
||||||
import rx.android.schedulers.AndroidSchedulers;
|
import rx.android.schedulers.AndroidSchedulers;
|
||||||
import rx.schedulers.Schedulers;
|
import rx.schedulers.Schedulers;
|
||||||
@ -16,7 +17,7 @@ public class MangaPresenter extends BasePresenter<MangaActivity> {
|
|||||||
|
|
||||||
@Inject DatabaseHelper db;
|
@Inject DatabaseHelper db;
|
||||||
|
|
||||||
private long mangaId;
|
@State long mangaId;
|
||||||
|
|
||||||
private static final int DB_MANGA = 1;
|
private static final int DB_MANGA = 1;
|
||||||
|
|
||||||
|
@ -52,6 +52,10 @@ public class ChaptersPresenter extends BasePresenter<ChaptersFragment> {
|
|||||||
protected void onCreate(Bundle savedState) {
|
protected void onCreate(Bundle savedState) {
|
||||||
super.onCreate(savedState);
|
super.onCreate(savedState);
|
||||||
|
|
||||||
|
if (savedState != null) {
|
||||||
|
onProcessRestart();
|
||||||
|
}
|
||||||
|
|
||||||
chaptersSubject = PublishSubject.create();
|
chaptersSubject = PublishSubject.create();
|
||||||
|
|
||||||
restartableLatestCache(DB_CHAPTERS,
|
restartableLatestCache(DB_CHAPTERS,
|
||||||
@ -71,6 +75,12 @@ public class ChaptersPresenter extends BasePresenter<ChaptersFragment> {
|
|||||||
registerForStickyEvents();
|
registerForStickyEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onProcessRestart() {
|
||||||
|
stop(DB_CHAPTERS);
|
||||||
|
stop(FETCH_CHAPTERS);
|
||||||
|
stop(CHAPTER_STATUS_CHANGES);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
unregisterForEvents();
|
unregisterForEvents();
|
||||||
|
@ -36,6 +36,10 @@ public class MangaInfoPresenter extends BasePresenter<MangaInfoFragment> {
|
|||||||
protected void onCreate(Bundle savedState) {
|
protected void onCreate(Bundle savedState) {
|
||||||
super.onCreate(savedState);
|
super.onCreate(savedState);
|
||||||
|
|
||||||
|
if (savedState != null) {
|
||||||
|
onProcessRestart();
|
||||||
|
}
|
||||||
|
|
||||||
restartableLatestCache(GET_MANGA,
|
restartableLatestCache(GET_MANGA,
|
||||||
() -> Observable.just(manga),
|
() -> Observable.just(manga),
|
||||||
MangaInfoFragment::onNextManga);
|
MangaInfoFragment::onNextManga);
|
||||||
@ -52,6 +56,12 @@ public class MangaInfoPresenter extends BasePresenter<MangaInfoFragment> {
|
|||||||
registerForStickyEvents();
|
registerForStickyEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onProcessRestart() {
|
||||||
|
stop(GET_MANGA);
|
||||||
|
stop(GET_CHAPTER_COUNT);
|
||||||
|
stop(FETCH_MANGA_INFO);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
unregisterForEvents();
|
unregisterForEvents();
|
||||||
|
Loading…
Reference in New Issue
Block a user