use of com.example.jingbin.cloudreader.bean.wanandroid.BaseResultBean in project CloudReader by youlookwhat.
the class CoinListViewModel method getCoinRank.
/**
* 积分排行榜
*/
public MutableLiveData<CoinBean> getCoinRank() {
final MutableLiveData<CoinBean> data = new MutableLiveData<>();
Disposable subscribe = HttpClient.Builder.getWanAndroidServer().getCoinRank(mPage).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer<BaseResultBean<CoinBean>>() {
@Override
public void accept(BaseResultBean<CoinBean> bean) throws Exception {
if (bean != null && bean.getData() != null) {
data.setValue(bean.getData());
} else {
data.setValue(null);
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
if (mPage > 1) {
mPage--;
}
data.setValue(null);
}
});
addDisposable(subscribe);
return data;
}
use of com.example.jingbin.cloudreader.bean.wanandroid.BaseResultBean in project CloudReader by youlookwhat.
the class CoinListViewModel method getCoinLog.
/**
* 我的积分
*/
public MutableLiveData<CoinBean> getCoinLog() {
final MutableLiveData<CoinBean> data = new MutableLiveData<>();
Disposable subscribe = HttpClient.Builder.getWanAndroidServer().getCoinLog(mPage).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer<BaseResultBean<CoinBean>>() {
@Override
public void accept(BaseResultBean<CoinBean> bean) throws Exception {
if (bean != null && bean.getData() != null) {
data.setValue(bean.getData());
} else {
data.setValue(null);
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
if (mPage > 1) {
mPage--;
}
data.setValue(null);
}
});
addDisposable(subscribe);
return data;
}
use of com.example.jingbin.cloudreader.bean.wanandroid.BaseResultBean in project CloudReader by youlookwhat.
the class MainViewModel method getUserInfo.
public void getUserInfo() {
UserUtil.getUserInfo(new OnUserInfoListener() {
@Override
public void onSuccess(User user) {
if (user != null) {
execute(HttpClient.Builder.getWanAndroidServer().getCoinUserInfo(), new Observer<BaseResultBean<CoinUserInfoBean>>() {
@Override
public void onSubscribe(Disposable d) {
addDisposable(d);
}
@Override
public void onNext(BaseResultBean<CoinUserInfoBean> bean) {
if (bean != null && bean.getData() != null) {
CoinUserInfoBean infoBean = bean.getData();
infoBean.setUsername(user.getUsername());
coin.setValue(infoBean);
UserUtil.getUserInfo(new OnUserInfoListener() {
@Override
public void onSuccess(User user) {
if (user != null) {
user.setCoinCount(infoBean.getCoinCount());
user.setRank(infoBean.getRank());
UserUtil.setUserInfo(user);
}
}
});
}
}
@Override
public void onError(Throwable e) {
coin.setValue(null);
}
@Override
public void onComplete() {
}
});
} else {
coin.setValue(null);
}
}
});
}
use of com.example.jingbin.cloudreader.bean.wanandroid.BaseResultBean in project CloudReader by youlookwhat.
the class WanFindViewModel method getWxArticle.
public void getWxArticle() {
Disposable subscribe = HttpClient.Builder.getWanAndroidServer().getWxarticle().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer<BaseResultBean<List<WxarticleItemBean>>>() {
@Override
public void accept(BaseResultBean<List<WxarticleItemBean>> naviJsonBean) throws Exception {
if (naviJsonBean != null && naviJsonBean.getData() != null && naviJsonBean.getData().size() > 0) {
// title
dataTitle.setValue(naviJsonBean.getData());
} else {
dataTitle.setValue(null);
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
dataTitle.setValue(null);
}
});
addDisposable(subscribe);
}
use of com.example.jingbin.cloudreader.bean.wanandroid.BaseResultBean in project CloudReader by youlookwhat.
the class WanFindViewModel method getWxarticleDetail.
public void getWxarticleDetail(int id) {
Disposable subscribe = HttpClient.Builder.getWanAndroidServer().getWxarticleDetail(id, mPage).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer<BaseResultBean<WxarticleDetailItemBean>>() {
@Override
public void accept(BaseResultBean<WxarticleDetailItemBean> naviJsonBean) throws Exception {
if (naviJsonBean != null && naviJsonBean.getData() != null && naviJsonBean.getData().getDatas() != null && naviJsonBean.getData().getDatas().size() > 0) {
// detail
data.setValue(naviJsonBean.getData().getDatas());
} else {
data.setValue(null);
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
data.setValue(null);
}
});
addDisposable(subscribe);
}
Aggregations