Search in sources :

Example 1 with ItemWelfareBinding

use of com.example.jingbin.cloudreader.databinding.ItemWelfareBinding in project CloudReader by youlookwhat.

the class WelfareFragment method initRecycleView.

private void initRecycleView() {
    int width = (DensityUtil.getDisplayWidth() - 36) / 2;
    mWelfareAdapter = new BaseBindingAdapter<GankIoDataBean.ResultBean, ItemWelfareBinding>(R.layout.item_welfare) {

        @Override
        protected void bindView(BaseBindingHolder holder, GankIoDataBean.ResultBean bean, ItemWelfareBinding binding, int position) {
            DensityUtil.setWidthHeight(binding.ivWelfare, width, 852 / 1280f);
            DensityUtil.setWidthHeight(binding.viewMask, width, 852 / 1280f);
            binding.setBean(bean);
        }
    };
    RefreshHelper.initStaggeredGrid(bindingView.xrvWelfare, 2, 12);
    bindingView.xrvWelfare.setAdapter(mWelfareAdapter);
    bindingView.xrvWelfare.setOnLoadMoreListener(new ByRecyclerView.OnLoadMoreListener() {

        @Override
        public void onLoadMore() {
            int page = viewModel.getPage();
            page++;
            viewModel.setPage(page);
            loadWelfareData();
        }
    }, 300);
    bindingView.xrvWelfare.setOnItemClickListener(new OnItemFilterClickListener() {

        @Override
        public void onSingleClick(View v, int position) {
            ViewBigImageActivity.startImageList(getContext(), position, imgList, imgTitleList);
        }
    });
    viewModel.getImageAndTitle().observe(getViewLifecycleOwner(), new Observer<ArrayList<ArrayList<String>>>() {

        @Override
        public void onChanged(@Nullable ArrayList<ArrayList<String>> arrayLists) {
            if (arrayLists != null && arrayLists.size() == 2) {
                imgList.addAll(arrayLists.get(0));
                imgTitleList.addAll(arrayLists.get(1));
            }
        }
    });
}
Also used : ByRecyclerView(me.jingbin.library.ByRecyclerView) OnItemFilterClickListener(me.jingbin.library.view.OnItemFilterClickListener) ArrayList(java.util.ArrayList) ByRecyclerView(me.jingbin.library.ByRecyclerView) View(android.view.View) GankIoDataBean(com.example.jingbin.cloudreader.bean.GankIoDataBean) ItemWelfareBinding(com.example.jingbin.cloudreader.databinding.ItemWelfareBinding) BaseBindingHolder(me.jingbin.bymvvm.adapter.BaseBindingHolder)

Aggregations

View (android.view.View)1 GankIoDataBean (com.example.jingbin.cloudreader.bean.GankIoDataBean)1 ItemWelfareBinding (com.example.jingbin.cloudreader.databinding.ItemWelfareBinding)1 ArrayList (java.util.ArrayList)1 BaseBindingHolder (me.jingbin.bymvvm.adapter.BaseBindingHolder)1 ByRecyclerView (me.jingbin.library.ByRecyclerView)1 OnItemFilterClickListener (me.jingbin.library.view.OnItemFilterClickListener)1