Remove PageBundle class

This commit is contained in:
inorichi 2015-12-26 00:08:28 +01:00
parent 4900284c48
commit 043ab7eca9
3 changed files with 8 additions and 20 deletions

View File

@ -6,6 +6,7 @@ import android.os.Bundle;
import android.support.v7.widget.SearchView; import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Pair;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
@ -30,7 +31,6 @@ import eu.kanade.mangafeed.data.source.base.Source;
import eu.kanade.mangafeed.ui.base.fragment.BaseRxFragment; import eu.kanade.mangafeed.ui.base.fragment.BaseRxFragment;
import eu.kanade.mangafeed.ui.main.MainActivity; import eu.kanade.mangafeed.ui.main.MainActivity;
import eu.kanade.mangafeed.ui.manga.MangaActivity; import eu.kanade.mangafeed.ui.manga.MangaActivity;
import eu.kanade.mangafeed.util.PageBundle;
import eu.kanade.mangafeed.util.ToastUtil; import eu.kanade.mangafeed.util.ToastUtil;
import eu.kanade.mangafeed.widget.EndlessScrollListener; import eu.kanade.mangafeed.widget.EndlessScrollListener;
import icepick.Icepick; import icepick.Icepick;
@ -214,13 +214,13 @@ public class CatalogueFragment extends BaseRxFragment<CataloguePresenter> {
} }
} }
public void onAddPage(PageBundle<List<Manga>> page) { public void onAddPage(Pair<Integer, List<Manga>> pair) {
hideProgressBar(); hideProgressBar();
if (page.page == 0) { if (pair.first == 0) {
adapter.clear(); adapter.clear();
scrollListener.resetScroll(); scrollListener.resetScroll();
} }
adapter.addAll(page.data); adapter.addAll(pair.second);
} }
public void onAddPageError() { public void onAddPageError() {

View File

@ -2,6 +2,7 @@ package eu.kanade.mangafeed.ui.catalogue;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Pair;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.pushtorefresh.storio.sqlite.operations.put.PutResult; import com.pushtorefresh.storio.sqlite.operations.put.PutResult;
@ -18,7 +19,6 @@ import eu.kanade.mangafeed.data.source.SourceManager;
import eu.kanade.mangafeed.data.source.base.Source; import eu.kanade.mangafeed.data.source.base.Source;
import eu.kanade.mangafeed.data.source.model.MangasPage; import eu.kanade.mangafeed.data.source.model.MangasPage;
import eu.kanade.mangafeed.ui.base.presenter.BasePresenter; import eu.kanade.mangafeed.ui.base.presenter.BasePresenter;
import eu.kanade.mangafeed.util.PageBundle;
import eu.kanade.mangafeed.util.RxPager; import eu.kanade.mangafeed.util.RxPager;
import rx.Observable; import rx.Observable;
import rx.android.schedulers.AndroidSchedulers; import rx.android.schedulers.AndroidSchedulers;
@ -57,14 +57,14 @@ public class CataloguePresenter extends BasePresenter<CatalogueFragment> {
mangaDetailSubject = PublishSubject.create(); mangaDetailSubject = PublishSubject.create();
restartableReplay(GET_MANGA_LIST, restartableReplay(GET_MANGA_LIST,
() -> pager.pages().<PageBundle<List<Manga>>>concatMap( () -> pager.pages().concatMap(
page -> getMangaObs(page + 1) page -> getMangaObs(page + 1)
.map(mangas -> new PageBundle<>(page, mangas)) .map(mangas -> Pair.create(page, mangas))
.observeOn(AndroidSchedulers.mainThread())), .observeOn(AndroidSchedulers.mainThread())),
(view, page) -> { (view, page) -> {
view.onAddPage(page); view.onAddPage(page);
if (mangaDetailSubject != null) if (mangaDetailSubject != null)
mangaDetailSubject.onNext(page.data); mangaDetailSubject.onNext(page.second);
}, },
(view, error) -> { (view, error) -> {
view.onAddPageError(); view.onAddPageError();

View File

@ -1,12 +0,0 @@
package eu.kanade.mangafeed.util;
public class PageBundle<T> {
public final int page;
public final T data;
public PageBundle(int page, T data) {
this.page = page;
this.data = data;
}
}