Search in sources :

Example 1 with TreeBean

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

the class WanFindFragment method initRxBus.

/**
 * 知识体系页更改发现页内容
 */
private void initRxBus() {
    Disposable subscribe = RxBus.getDefault().toObservable(RxCodeConstants.FIND_CUSTOM, Integer.class).subscribe(new Consumer<Integer>() {

        @Override
        public void accept(Integer integer) throws Exception {
            if (integer != null) {
                if (!mIsFirst) {
                    TreeBean treeData = DataUtil.getTreeData(activity);
                    if (viewModel.handleCustomData(treeData, integer)) {
                        ToastUtil.showToastLong("发现页内容已改为\"" + treeData.getData().get(integer).getName() + "\"");
                    }
                } else {
                    ToastUtil.showToastLong("发现页内容已更改,请打开查看~");
                }
            }
        }
    });
    addSubscription(subscribe);
}
Also used : Disposable(io.reactivex.disposables.Disposable) TreeBean(com.example.jingbin.cloudreader.bean.wanandroid.TreeBean)

Example 2 with TreeBean

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

the class TreeViewModel method getTree.

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

        @Override
        public void accept(TreeBean treeBean) throws Exception {
            data.setValue(treeBean);
        }
    }, new Consumer<Throwable>() {

        @Override
        public void accept(Throwable throwable) throws Exception {
            data.setValue(null);
        }
    });
    addDisposable(subscribe);
    return data;
}
Also used : Disposable(io.reactivex.disposables.Disposable) MutableLiveData(androidx.lifecycle.MutableLiveData) TreeBean(com.example.jingbin.cloudreader.bean.wanandroid.TreeBean)

Aggregations

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