Search in sources :

Example 1 with GankIoDayBean

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

the class EverydayModel method showRecyclerViewData.

/**
     * 显示RecyclerView数据
     */
public void showRecyclerViewData(final RequestImpl listener) {
    SPUtils.putString(HOME_ONE, "");
    SPUtils.putString(HOME_TWO, "");
    SPUtils.putString(HOME_SIX, "");
    Func1<GankIoDayBean, Observable<List<List<AndroidBean>>>> func1 = new Func1<GankIoDayBean, Observable<List<List<AndroidBean>>>>() {

        @Override
        public Observable<List<List<AndroidBean>>> call(GankIoDayBean gankIoDayBean) {
            List<List<AndroidBean>> lists = new ArrayList<>();
            GankIoDayBean.ResultsBean results = gankIoDayBean.getResults();
            if (results.getAndroid() != null && results.getAndroid().size() > 0) {
                addUrlList(lists, results.getAndroid(), "Android");
            }
            if (results.getWelfare() != null && results.getWelfare().size() > 0) {
                addUrlList(lists, results.getWelfare(), "福利");
            }
            if (results.getiOS() != null && results.getiOS().size() > 0) {
                addUrlList(lists, results.getiOS(), "IOS");
            }
            if (results.getRestMovie() != null && results.getRestMovie().size() > 0) {
                addUrlList(lists, results.getRestMovie(), "休息视频");
            }
            if (results.getResource() != null && results.getResource().size() > 0) {
                addUrlList(lists, results.getResource(), "拓展资源");
            }
            if (results.getRecommend() != null && results.getRecommend().size() > 0) {
                addUrlList(lists, results.getRecommend(), "瞎推荐");
            }
            if (results.getFront() != null && results.getFront().size() > 0) {
                addUrlList(lists, results.getFront(), "前端");
            }
            if (results.getApp() != null && results.getApp().size() > 0) {
                addUrlList(lists, results.getApp(), "App");
            }
            return Observable.just(lists);
        }
    };
    Observer<List<List<AndroidBean>>> observer = new Observer<List<List<AndroidBean>>>() {

        @Override
        public void onCompleted() {
        }

        @Override
        public void onError(Throwable e) {
            listener.loadFailed();
        }

        @Override
        public void onNext(List<List<AndroidBean>> lists) {
            listener.loadSuccess(lists);
        }
    };
    Subscription subscription = HttpClient.Builder.getGankIOServer().getGankIoDay(year, month, day).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).flatMap(func1).subscribe(observer);
    listener.addSubscription(subscription);
}
Also used : ArrayList(java.util.ArrayList) Observable(rx.Observable) GankIoDayBean(com.example.jingbin.cloudreader.bean.GankIoDayBean) Observer(rx.Observer) ArrayList(java.util.ArrayList) List(java.util.List) Func1(rx.functions.Func1) Subscription(rx.Subscription) AndroidBean(com.example.jingbin.cloudreader.bean.AndroidBean)

Aggregations

AndroidBean (com.example.jingbin.cloudreader.bean.AndroidBean)1 GankIoDayBean (com.example.jingbin.cloudreader.bean.GankIoDayBean)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Observable (rx.Observable)1 Observer (rx.Observer)1 Subscription (rx.Subscription)1 Func1 (rx.functions.Func1)1