use of androidx.lifecycle.MutableLiveData 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 androidx.lifecycle.MutableLiveData 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 androidx.lifecycle.MutableLiveData 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 androidx.lifecycle.MutableLiveData in project CloudReader by youlookwhat.
the class SearchViewModel method searchWan.
/**
* 搜索
*/
public MutableLiveData<HomeListBean> searchWan(String keyWord) {
final MutableLiveData<HomeListBean> data = new MutableLiveData<>();
Disposable subscribe = HttpClient.Builder.getWanAndroidServer().searchWan(mPage, keyWord).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer<HomeListBean>() {
@Override
public void accept(HomeListBean bean) throws Exception {
if (bean == null || bean.getData() == null || bean.getData().getDatas() == null || bean.getData().getDatas().size() <= 0) {
data.setValue(null);
} else {
data.setValue(bean);
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
if (mPage > 0) {
mPage--;
}
data.setValue(null);
}
});
addDisposable(subscribe);
return data;
}
use of androidx.lifecycle.MutableLiveData in project CloudReader by youlookwhat.
the class SearchViewModel method getHotkey.
public MutableLiveData<List<SearchTagBean.DataBean>> getHotkey() {
final MutableLiveData<List<SearchTagBean.DataBean>> data = new MutableLiveData<>();
Disposable subscribe = HttpClient.Builder.getWanAndroidServer().getHotkey().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer<SearchTagBean>() {
@Override
public void accept(SearchTagBean bean) throws Exception {
if (bean == null || bean.getData() == null || bean.getData().size() <= 0) {
data.setValue(null);
} else {
data.setValue(bean.getData());
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
if (mPage > 1) {
mPage--;
}
data.setValue(null);
}
});
addDisposable(subscribe);
return data;
}
Aggregations