Search in sources :

Example 1 with SearchTagBean

use of com.example.jingbin.cloudreader.bean.wanandroid.SearchTagBean 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;
}
Also used : Disposable(io.reactivex.disposables.Disposable) SearchTagBean(com.example.jingbin.cloudreader.bean.wanandroid.SearchTagBean) MutableLiveData(androidx.lifecycle.MutableLiveData) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

MutableLiveData (androidx.lifecycle.MutableLiveData)1 SearchTagBean (com.example.jingbin.cloudreader.bean.wanandroid.SearchTagBean)1 Disposable (io.reactivex.disposables.Disposable)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1