Search in sources :

Example 1 with AndroidBean

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

the class EverydayModel method getAndroidBean.

private AndroidBean getAndroidBean(List<AndroidBean> arrayList, int i, int androidSize) {
    AndroidBean androidBean = new AndroidBean();
    // 标题
    androidBean.setDesc(arrayList.get(i).getDesc());
    // 类型
    androidBean.setType(arrayList.get(i).getType());
    // 跳转链接
    androidBean.setUrl(arrayList.get(i).getUrl());
    // 随机图的url
    if (i < 3) {
        // 三小图
        androidBean.setimageUrl(ConstantsImageUrl.HOME_SIX_URLS[getRandom(3)]);
    } else if (androidSize == 4) {
        // 一图
        androidBean.setimageUrl(ConstantsImageUrl.HOME_ONE_URLS[getRandom(1)]);
    } else if (androidSize == 5) {
        // 两图
        androidBean.setimageUrl(ConstantsImageUrl.HOME_TWO_URLS[getRandom(2)]);
    } else if (androidSize >= 6) {
        // 三小图
        androidBean.setimageUrl(ConstantsImageUrl.HOME_SIX_URLS[getRandom(3)]);
    }
    return androidBean;
}
Also used : AndroidBean(com.example.jingbin.cloudreader.bean.AndroidBean)

Example 2 with AndroidBean

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

the class EverydayModel method addUrlList.

// subList没有实现序列化!缓存时会出错!
private void addUrlList(List<List<AndroidBean>> lists, List<AndroidBean> arrayList, String typeTitle) {
    // title
    AndroidBean bean = new AndroidBean();
    bean.setType_title(typeTitle);
    ArrayList<AndroidBean> androidBeen = new ArrayList<>();
    androidBeen.add(bean);
    lists.add(androidBeen);
    int androidSize = arrayList.size();
    if (androidSize > 0 && androidSize < 4) {
        lists.add(addUrlList(arrayList, androidSize));
    } else if (androidSize >= 4) {
        ArrayList<AndroidBean> list1 = new ArrayList<>();
        ArrayList<AndroidBean> list2 = new ArrayList<>();
        for (int i = 0; i < androidSize; i++) {
            if (i < 3) {
                list1.add(getAndroidBean(arrayList, i, androidSize));
            } else if (i < 6) {
                list2.add(getAndroidBean(arrayList, i, androidSize));
            }
        }
        lists.add(list1);
        lists.add(list2);
    }
}
Also used : ArrayList(java.util.ArrayList) AndroidBean(com.example.jingbin.cloudreader.bean.AndroidBean)

Example 3 with AndroidBean

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

the class EverydayModel method addUrlList.

private List<AndroidBean> addUrlList(List<AndroidBean> arrayList, int androidSize) {
    List<AndroidBean> tempList = new ArrayList<>();
    for (int i = 0; i < androidSize; i++) {
        AndroidBean androidBean = new AndroidBean();
        // 标题
        androidBean.setDesc(arrayList.get(i).getDesc());
        // 类型
        androidBean.setType(arrayList.get(i).getType());
        // 跳转链接
        androidBean.setUrl(arrayList.get(i).getUrl());
        // 随机图的url
        if (androidSize == 1) {
            //一图
            androidBean.setImage_url(ConstantsImageUrl.HOME_ONE_URLS[getRandom(1)]);
        } else if (androidSize == 2) {
            //两图
            androidBean.setImage_url(ConstantsImageUrl.HOME_TWO_URLS[getRandom(2)]);
        } else if (androidSize == 3) {
            //三图
            androidBean.setImage_url(ConstantsImageUrl.HOME_SIX_URLS[getRandom(3)]);
        }
        tempList.add(androidBean);
    }
    return tempList;
}
Also used : ArrayList(java.util.ArrayList) AndroidBean(com.example.jingbin.cloudreader.bean.AndroidBean)

Example 4 with AndroidBean

use of com.example.jingbin.cloudreader.bean.AndroidBean 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)

Example 5 with AndroidBean

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

the class EverydayModel method getAndroidBean.

private AndroidBean getAndroidBean(List<AndroidBean> arrayList, int i, int androidSize) {
    AndroidBean androidBean = new AndroidBean();
    // 标题
    androidBean.setDesc(arrayList.get(i).getDesc());
    // 类型
    androidBean.setType(arrayList.get(i).getType());
    // 跳转链接
    androidBean.setUrl(arrayList.get(i).getUrl());
    // 随机图的url
    if (i < 3) {
        //三小图
        androidBean.setImage_url(ConstantsImageUrl.HOME_SIX_URLS[getRandom(3)]);
    } else if (androidSize == 4) {
        //一图
        androidBean.setImage_url(ConstantsImageUrl.HOME_ONE_URLS[getRandom(1)]);
    } else if (androidSize == 5) {
        //两图
        androidBean.setImage_url(ConstantsImageUrl.HOME_TWO_URLS[getRandom(2)]);
    } else if (androidSize >= 6) {
        //三小图
        androidBean.setImage_url(ConstantsImageUrl.HOME_SIX_URLS[getRandom(3)]);
    }
    return androidBean;
}
Also used : AndroidBean(com.example.jingbin.cloudreader.bean.AndroidBean)

Aggregations

AndroidBean (com.example.jingbin.cloudreader.bean.AndroidBean)9 ArrayList (java.util.ArrayList)7 Context (android.content.Context)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 GankIoDayBean (com.example.jingbin.cloudreader.bean.GankIoDayBean)1 EverydayViewModel (com.example.jingbin.cloudreader.viewmodel.gank.EverydayViewModel)1 List (java.util.List)1 OnBannerClickListener (me.jingbin.banner.config.OnBannerClickListener)1 ByBannerViewHolder (me.jingbin.banner.holder.ByBannerViewHolder)1 Observable (rx.Observable)1 Observer (rx.Observer)1 Subscription (rx.Subscription)1 Func1 (rx.functions.Func1)1