美文网首页
Android好轮子-封装很好的库

Android好轮子-封装很好的库

作者: 码农朱同学 | 来源:发表于2018-06-22 07:24 被阅读0次

    1,简单好用的RecyclerAdapter
    先上地址:
    https://github.com/CymChad/BaseRecyclerViewAdapterHelper
    对各种情况的封装都很简洁全面,隔壁的Android小伙伴都馋哭了

    先看下有多简洁

            //添加分割线
            DividerItemDecoration itemDecoration = new DividerItemDecoration(this, DividerItemDecoration.HORIZONTAL_LIST, 20, getResColor(R.color.white));
            dataListView.addItemDecoration(itemDecoration);
    
            LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
            dataListView.setLayoutManager(linearLayoutManager);
    
            listAdapter = new ListAdapter();
            listAdapter.setEnableLoadMore(true);
            listAdapter.setLoadMoreView(new ProgressDrawableLoadingView());
            listAdapter.setOnLoadMoreListener(() -> {
                requestSignRecords(minboundaryid);
            }, dataListView);
            listAdapter.disableLoadMoreIfNotFullPage();
    
    
            initHeaderView();
            listAdapter.setEmptyView(R.layout.bull_bao_coupon_empty, dataListView);
            listAdapter.setHeaderAndEmpty(true);
    
            dataListView.setAdapter(listAdapter);
    
        private class ListAdapter extends BaseMultiItemQuickAdapter<BullBaoItemData, BaseViewHolder> {
    
            public ListAdapter() {
                super(dataList);
                addItemType(BullBaoItemData.RECORD_TYPE_SIGN, R.layout.item_bull_bao_record_sign);
                addItemType(BullBaoItemData.RECORD_TYPE_GUESS, R.layout.item_bull_bao_record_guess);
            }
    
            @Override
            protected int getDefItemViewType(int position) {
    
                BullBaoItemData itemData = dataList.get(position);
                return itemData.getType();
            }
    

    但是也有一些小坑和容易忽略的地方

                        listAdapter.setNewData(invalidateCouponList);
    
                    listAdapter.disableLoadMoreIfNotFullPage(); 需要在setNewData之后配置
    
    
                        //listAdapter.addData(data.getCouponlist());  // 会自动帮你add,手动add的话相当与重复了
    

    2,ConvenientBanner

    https://github.com/Bigkoo/Android-ConvenientBanner

    布局轮播

    3,待续

    相关文章

      网友评论

          本文标题:Android好轮子-封装很好的库

          本文链接:https://www.haomeiwen.com/subject/eomhyftx.html