Search in sources :

Example 1 with CollectUrlBean

use of com.example.jingbin.cloudreader.bean.CollectUrlBean in project CloudReader by youlookwhat.

the class CollectLinkModel method getCollectUrlList.

public MutableLiveData<CollectUrlBean> getCollectUrlList() {
    final MutableLiveData<CollectUrlBean> data = new MutableLiveData<>();
    Disposable subscribe = HttpClient.Builder.getWanAndroidServer().getCollectUrlList().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer<CollectUrlBean>() {

        @Override
        public void accept(CollectUrlBean collectUrlBean) throws Exception {
            if (collectUrlBean != null && collectUrlBean.getData() != null && collectUrlBean.getData().size() > 0) {
                // 对集合中的数据进行倒叙排序
                Collections.reverse(collectUrlBean.getData());
                data.setValue(collectUrlBean);
            } else {
                data.setValue(collectUrlBean);
            }
        }
    }, throwable -> data.setValue(null));
    addDisposable(subscribe);
    return data;
}
Also used : Disposable(io.reactivex.disposables.Disposable) CollectUrlBean(com.example.jingbin.cloudreader.bean.CollectUrlBean) MutableLiveData(androidx.lifecycle.MutableLiveData)

Aggregations

MutableLiveData (androidx.lifecycle.MutableLiveData)1 CollectUrlBean (com.example.jingbin.cloudreader.bean.CollectUrlBean)1 Disposable (io.reactivex.disposables.Disposable)1