Add MangaDetailActivity with two fragments, info and chapters

This commit is contained in:
inorichi
2015-10-17 13:51:54 +02:00
parent 07395892a0
commit 0e52c81970
16 changed files with 508 additions and 81 deletions
@@ -0,0 +1,36 @@
package eu.kanade.mangafeed.presenter;
import javax.inject.Inject;
import eu.kanade.mangafeed.data.helpers.DatabaseHelper;
import eu.kanade.mangafeed.ui.fragment.MangaInfoFragment;
import rx.Observable;
import rx.Subscription;
import rx.android.schedulers.AndroidSchedulers;
public class MangaInfoPresenter extends BasePresenter2<MangaInfoFragment> {
@Inject DatabaseHelper db;
private Subscription mangaInfoSubscription;
@Override
protected void onTakeView(MangaInfoFragment view) {
super.onTakeView(view);
getMangaInfo(view);
}
private void getMangaInfo(MangaInfoFragment view) {
if (mangaInfoSubscription != null)
remove(mangaInfoSubscription);
mangaInfoSubscription = db.getManga(view.getMangaId())
.observeOn(AndroidSchedulers.mainThread())
.take(1)
.flatMap(Observable::from)
.subscribe(view::setMangaInfo);
add(mangaInfoSubscription);
}
}