use of com.example.jingbin.cloudreader.bean.HotMovieBean in project CloudReader by youlookwhat.
the class OneFragment method loadHotMovie.
private void loadHotMovie() {
Subscription subscription = HttpClient.Builder.getDouBanService().getHotMovie().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<HotMovieBean>() {
@Override
public void onCompleted() {
showContentView();
}
@Override
public void onError(Throwable e) {
showContentView();
if (oneAdapter != null && oneAdapter.getItemCount() == 0) {
showError();
}
}
@Override
public void onNext(HotMovieBean hotMovieBean) {
if (hotMovieBean != null) {
aCache.remove(Constants.ONE_HOT_MOVIE);
// 保存12个小时
aCache.put(Constants.ONE_HOT_MOVIE, hotMovieBean, 43200);
setAdapter(hotMovieBean);
// 保存请求的日期
SPUtils.putString("one_data", TimeUtil.getData());
// 刷新结束
mIsLoading = false;
}
//构造器中,第一个参数表示列数或者行数,第二个参数表示滑动方向,瀑布流
// bindingContentView.listOne.setLayoutManager(new StaggeredGridLayoutManager(4,StaggeredGridLayoutManager.VERTICAL));
// GridView
// bindingContentView.listOne.setLayoutManager(new GridLayoutManager(getActivity(), 2));
}
});
addSubscription(subscription);
}
use of com.example.jingbin.cloudreader.bean.HotMovieBean in project CloudReader by youlookwhat.
the class DoubanTopActivity method loadDouBanTop250.
private void loadDouBanTop250() {
Subscription get = HttpClient.Builder.getDouBanService().getMovieTop250(mStart, mCount).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<HotMovieBean>() {
@Override
public void onCompleted() {
showContentView();
}
@Override
public void onError(Throwable e) {
bindingView.xrvTop.refreshComplete();
if (mDouBanTopAdapter.getItemCount() == 0) {
showError();
}
}
@Override
public void onNext(HotMovieBean hotMovieBean) {
if (mStart == 0) {
if (hotMovieBean != null && hotMovieBean.getSubjects() != null && hotMovieBean.getSubjects().size() > 0) {
mDouBanTopAdapter.clear();
mDouBanTopAdapter.addAll(hotMovieBean.getSubjects());
//构造器中,第一个参数表示列数或者行数,第二个参数表示滑动方向,瀑布流
bindingView.xrvTop.setLayoutManager(new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL));
bindingView.xrvTop.setAdapter(mDouBanTopAdapter);
bindingView.xrvTop.setPullRefreshEnabled(false);
bindingView.xrvTop.clearHeader();
bindingView.xrvTop.setLoadingMoreEnabled(true);
mDouBanTopAdapter.notifyDataSetChanged();
} else {
bindingView.xrvTop.setVisibility(View.GONE);
}
} else {
if (hotMovieBean != null && hotMovieBean.getSubjects() != null && hotMovieBean.getSubjects().size() > 0) {
bindingView.xrvTop.refreshComplete();
mDouBanTopAdapter.addAll(hotMovieBean.getSubjects());
mDouBanTopAdapter.notifyDataSetChanged();
} else {
bindingView.xrvTop.noMoreLoading();
}
}
}
});
addSubscription(get);
}
use of com.example.jingbin.cloudreader.bean.HotMovieBean in project CloudReader by youlookwhat.
the class OneViewModel method getComingSoon.
public MutableLiveData<HotMovieBean> getComingSoon() {
final MutableLiveData<HotMovieBean> data = new MutableLiveData<>();
Disposable subscribe = HttpClient.Builder.getDouBanService().getComingSoon(mStart, mCount).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer<HotMovieBean>() {
@Override
public void accept(HotMovieBean hotMovieBean) throws Exception {
data.setValue(hotMovieBean);
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
data.setValue(null);
}
});
addDisposable(subscribe);
return data;
}
Aggregations