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));
}
}
});
}
Aggregations