mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 06:01:49 +01:00
Unsubscribe subscriptions
This commit is contained in:
parent
4e795b69e5
commit
e386257d34
@ -11,6 +11,7 @@ import eu.kanade.mangafeed.data.models.Manga;
|
|||||||
import eu.kanade.mangafeed.ui.activity.MangaDetailActivity;
|
import eu.kanade.mangafeed.ui.activity.MangaDetailActivity;
|
||||||
import eu.kanade.mangafeed.ui.adapter.LibraryAdapter;
|
import eu.kanade.mangafeed.ui.adapter.LibraryAdapter;
|
||||||
import eu.kanade.mangafeed.view.LibraryView;
|
import eu.kanade.mangafeed.view.LibraryView;
|
||||||
|
import rx.Subscription;
|
||||||
|
|
||||||
import static rx.android.schedulers.AndroidSchedulers.mainThread;
|
import static rx.android.schedulers.AndroidSchedulers.mainThread;
|
||||||
|
|
||||||
@ -22,6 +23,7 @@ public class LibraryPresenter extends BasePresenter {
|
|||||||
@Inject PreferencesHelper prefs;
|
@Inject PreferencesHelper prefs;
|
||||||
|
|
||||||
LibraryAdapter<Manga> adapter;
|
LibraryAdapter<Manga> adapter;
|
||||||
|
private Subscription mangaListSubscription;
|
||||||
|
|
||||||
public LibraryPresenter(LibraryView view) {
|
public LibraryPresenter(LibraryView view) {
|
||||||
this.view = view;
|
this.view = view;
|
||||||
@ -45,7 +47,7 @@ public class LibraryPresenter extends BasePresenter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void initializeMangas() {
|
public void initializeMangas() {
|
||||||
db.manga.getWithUnread()
|
mangaListSubscription = db.manga.getWithUnread()
|
||||||
.observeOn(mainThread())
|
.observeOn(mainThread())
|
||||||
.subscribe(mangas -> {
|
.subscribe(mangas -> {
|
||||||
adapter = new LibraryAdapter<>(view.getActivity(), mangas);
|
adapter = new LibraryAdapter<>(view.getActivity(), mangas);
|
||||||
@ -57,4 +59,10 @@ public class LibraryPresenter extends BasePresenter {
|
|||||||
adapter.getFilter().filter(query);
|
adapter.getFilter().filter(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void destroySubscriptions() {
|
||||||
|
if (mangaListSubscription != null) {
|
||||||
|
mangaListSubscription.unsubscribe();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,13 @@ public class LibraryFragment extends BaseFragment implements LibraryView {
|
|||||||
presenter.initializeMangas();
|
presenter.initializeMangas();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
|
||||||
|
presenter.destroySubscriptions();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
inflater.inflate(R.menu.library, menu);
|
inflater.inflate(R.menu.library, menu);
|
||||||
|
Loading…
Reference in New Issue
Block a user