Search in sources :

Example 1 with MutableLiveData

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;
}
Also used : Disposable(io.reactivex.disposables.Disposable) GankIoDataBean(com.example.jingbin.cloudreader.bean.GankIoDataBean) MutableLiveData(androidx.lifecycle.MutableLiveData) RequestImpl(com.example.jingbin.cloudreader.http.RequestImpl)

Example 2 with MutableLiveData

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;
}
Also used : Disposable(io.reactivex.disposables.Disposable) BaseResultBean(com.example.jingbin.cloudreader.bean.wanandroid.BaseResultBean) MutableLiveData(androidx.lifecycle.MutableLiveData) CoinBean(com.example.jingbin.cloudreader.bean.CoinBean)

Example 3 with MutableLiveData

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;
}
Also used : Disposable(io.reactivex.disposables.Disposable) BaseResultBean(com.example.jingbin.cloudreader.bean.wanandroid.BaseResultBean) MutableLiveData(androidx.lifecycle.MutableLiveData) CoinBean(com.example.jingbin.cloudreader.bean.CoinBean)

Example 4 with MutableLiveData

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;
}
Also used : Disposable(io.reactivex.disposables.Disposable) HomeListBean(com.example.jingbin.cloudreader.bean.wanandroid.HomeListBean) MutableLiveData(androidx.lifecycle.MutableLiveData)

Example 5 with MutableLiveData

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;
}
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)23 Disposable (io.reactivex.disposables.Disposable)14 Test (org.junit.Test)6 GankIoDataBean (com.example.jingbin.cloudreader.bean.GankIoDataBean)3 AudioButton (org.odk.collect.android.audio.AudioButton)3 AudioVideoImageTextLabel (org.odk.collect.android.formentry.questions.AudioVideoImageTextLabel)3 RecordingSession (org.odk.collect.audiorecorder.recording.RecordingSession)3 Pair (android.util.Pair)2 CoinBean (com.example.jingbin.cloudreader.bean.CoinBean)2 BaseResultBean (com.example.jingbin.cloudreader.bean.wanandroid.BaseResultBean)2 HomeListBean (com.example.jingbin.cloudreader.bean.wanandroid.HomeListBean)2 RequestImpl (com.example.jingbin.cloudreader.http.RequestImpl)2 File (java.io.File)2 FormEntryPrompt (org.javarosa.form.api.FormEntryPrompt)2 Handler (android.os.Handler)1 CollectUrlBean (com.example.jingbin.cloudreader.bean.CollectUrlBean)1 ComingFilmBean (com.example.jingbin.cloudreader.bean.ComingFilmBean)1 HotMovieBean (com.example.jingbin.cloudreader.bean.HotMovieBean)1 MtimeFilmeBean (com.example.jingbin.cloudreader.bean.MtimeFilmeBean)1 SearchTagBean (com.example.jingbin.cloudreader.bean.wanandroid.SearchTagBean)1