use of com.example.jingbin.cloudreader.http.RequestImpl in project CloudReader by youlookwhat.
the class WelfareViewModel method loadWelfareData.
public MutableLiveData<GankIoDataBean> loadWelfareData() {
final MutableLiveData<GankIoDataBean> data = new MutableLiveData<>();
mModel.setData("Girl", "Girl", mPage, 20);
mModel.getGankIoData(new RequestImpl() {
@Override
public void loadSuccess(Object object) {
GankIoDataBean gankIoDataBean = (GankIoDataBean) object;
handleImageList(gankIoDataBean);
data.setValue(gankIoDataBean);
}
@Override
public void loadFailed() {
if (mPage > 1) {
mPage--;
}
data.setValue(null);
}
@Override
public void addSubscription(Disposable disposable) {
addDisposable(disposable);
}
});
return data;
}
use of com.example.jingbin.cloudreader.http.RequestImpl in project CloudReader by youlookwhat.
the class WelfareFragment method loadWelfareData.
private void loadWelfareData() {
mModel.setData("福利", mPage, HttpUtils.per_page_more);
mModel.getGankIoData(new RequestImpl() {
@Override
public void loadSuccess(Object object) {
showContentView();
GankIoDataBean gankIoDataBean = (GankIoDataBean) object;
if (mPage == 1) {
if (gankIoDataBean != null && gankIoDataBean.getResults() != null && gankIoDataBean.getResults().size() > 0) {
imgList.clear();
for (int i = 0; i < gankIoDataBean.getResults().size(); i++) {
imgList.add(gankIoDataBean.getResults().get(i).getUrl());
}
setAdapter(gankIoDataBean);
aCache.remove(Constants.GANK_MEIZI);
aCache.put(Constants.GANK_MEIZI, gankIoDataBean, 30000);
}
} else {
if (gankIoDataBean != null && gankIoDataBean.getResults() != null && gankIoDataBean.getResults().size() > 0) {
bindingView.xrvWelfare.refreshComplete();
mWelfareAdapter.addAll(gankIoDataBean.getResults());
mWelfareAdapter.notifyDataSetChanged();
for (int i = 0; i < gankIoDataBean.getResults().size(); i++) {
imgList.add(gankIoDataBean.getResults().get(i).getUrl());
}
} else {
bindingView.xrvWelfare.noMoreLoading();
}
}
}
@Override
public void loadFailed() {
bindingView.xrvWelfare.refreshComplete();
if (mWelfareAdapter.getItemCount() == 0) {
showError();
}
if (mPage > 1) {
mPage--;
}
}
@Override
public void addSubscription(Subscription subscription) {
WelfareFragment.this.addSubscription(subscription);
}
});
}
use of com.example.jingbin.cloudreader.http.RequestImpl in project CloudReader by youlookwhat.
the class AndroidFragment method loadAndroidData.
private void loadAndroidData() {
mModel.setData(mType, mPage, HttpUtils.per_page_more);
mModel.getGankIoData(new RequestImpl() {
@Override
public void loadSuccess(Object object) {
showContentView();
GankIoDataBean gankIoDataBean = (GankIoDataBean) object;
if (mPage == 1) {
if (gankIoDataBean != null && gankIoDataBean.getResults() != null && gankIoDataBean.getResults().size() > 0) {
setAdapter(gankIoDataBean);
mACache.remove(Constants.GANK_ANDROID);
// 缓存50分钟
mACache.put(Constants.GANK_ANDROID, gankIoDataBean, 30000);
}
} else {
if (gankIoDataBean != null && gankIoDataBean.getResults() != null && gankIoDataBean.getResults().size() > 0) {
bindingView.xrvAndroid.refreshComplete();
mAndroidAdapter.addAll(gankIoDataBean.getResults());
mAndroidAdapter.notifyDataSetChanged();
} else {
bindingView.xrvAndroid.noMoreLoading();
}
}
}
@Override
public void loadFailed() {
bindingView.xrvAndroid.refreshComplete();
// 注意:这里不能写成 mPage == 1,否则会一直显示错误页面
if (mAndroidAdapter.getItemCount() == 0) {
showError();
}
if (mPage > 1) {
mPage--;
}
}
@Override
public void addSubscription(Subscription subscription) {
AndroidFragment.this.addSubscription(subscription);
}
});
}
use of com.example.jingbin.cloudreader.http.RequestImpl in project CloudReader by youlookwhat.
the class CustomFragment method loadCustomData.
private void loadCustomData() {
mModel.setData(mType, mPage, HttpUtils.per_page_more);
mModel.getGankIoData(new RequestImpl() {
@Override
public void loadSuccess(Object object) {
showContentView();
GankIoDataBean gankIoDataBean = (GankIoDataBean) object;
if (mPage == 1) {
if (gankIoDataBean != null && gankIoDataBean.getResults() != null && gankIoDataBean.getResults().size() > 0) {
setAdapter(gankIoDataBean);
mACache.remove(Constants.GANK_CUSTOM);
// 缓存50分钟
mACache.put(Constants.GANK_CUSTOM, gankIoDataBean, 30000);
}
} else {
if (gankIoDataBean != null && gankIoDataBean.getResults() != null && gankIoDataBean.getResults().size() > 0) {
bindingView.xrvCustom.refreshComplete();
mAndroidAdapter.addAll(gankIoDataBean.getResults());
mAndroidAdapter.notifyDataSetChanged();
} else {
bindingView.xrvCustom.noMoreLoading();
}
}
}
@Override
public void loadFailed() {
showContentView();
bindingView.xrvCustom.refreshComplete();
if (mAndroidAdapter.getItemCount() == 0) {
showError();
}
if (mPage > 1) {
mPage--;
}
}
@Override
public void addSubscription(Subscription subscription) {
CustomFragment.this.addSubscription(subscription);
}
});
}
use of com.example.jingbin.cloudreader.http.RequestImpl in project CloudReader by youlookwhat.
the class GankViewModel method loadGankData.
public MutableLiveData<GankIoDataBean> loadGankData() {
final MutableLiveData<GankIoDataBean> data = new MutableLiveData<>();
mModel.setData("GanHuo", mType, mPage, 20);
mModel.getGankIoData(new RequestImpl() {
@Override
public void loadSuccess(Object object) {
data.setValue(DataUtil.getTrueData((GankIoDataBean) object));
}
@Override
public void loadFailed() {
if (mPage > 1) {
mPage--;
}
data.setValue(null);
}
@Override
public void addSubscription(Disposable disposable) {
addDisposable(disposable);
}
});
return data;
}
Aggregations