@Override public void onRefresh() { super.onRefresh(); page = 1; GetImagelistModel.getImageList(tab, page) .subscribe( new Observer<NetImage[]>() { @Override public void onCompleted() { JUtils.Log("onCompleted"); } @Override public void onError(Throwable e) { JUtils.Log("onError"); getRefreshSubscriber().onError(e); } @Override public void onNext(NetImage[] imgs) { netImages.clear(); netImages.addAll(Arrays.asList(imgs)); getRefreshSubscriber().onNext(netImages); page++; getAdapter().setOnItemClickListener(NetImgListPresenter.this); } }); }
@Override protected void onCreateView(NetImgFragment view) { super.onCreateView(view); tab = view.getResources().getStringArray(R.array.search_tab)[view.getArguments().getInt("tab")]; view.getListView() .setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL)); netImages = new ArrayList<NetImage>(); onRefresh(); }
@Override public void onLoadMore() { super.onLoadMore(); GetImagelistModel.getImageList(tab, page) .subscribe( new Subscriber<NetImage[]>() { @Override public void onCompleted() {} @Override public void onError(Throwable e) { getMoreSubscriber().onError(e); } @Override public void onNext(NetImage[] imgs) { netImages.addAll(Arrays.asList(imgs)); getMoreSubscriber().onNext(Arrays.asList(imgs)); page++; } }); }
@Override protected void onCreate(ActionFragment view, Bundle savedState) { super.onCreate(view, savedState); onRefresh(); }