Search in sources :

Example 1 with BannerAdapter

use of com.jude.dome.header.BannerAdapter in project EasyRecyclerView by Jude95.

the class StaggeredGridActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_recyclerview);
    recyclerView = (EasyRecyclerView) findViewById(R.id.recyclerView);
    recyclerView.setLayoutManager(new StaggeredGridLayoutManager(4, StaggeredGridLayoutManager.VERTICAL));
    recyclerView.setAdapter(adapter = new ImageAdapter(this));
    GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 4);
    gridLayoutManager.setSpanSizeLookup(adapter.obtainGridSpanSizeLookUp(4));
    recyclerView.setLayoutManager(gridLayoutManager);
    adapter.addHeader(new RecyclerArrayAdapter.ItemView() {

        @Override
        public View onCreateView(ViewGroup parent) {
            RollPagerView header = new RollPagerView(StaggeredGridActivity.this);
            header.setHintView(new ColorPointHintView(StaggeredGridActivity.this, Color.YELLOW, Color.GRAY));
            header.setHintPadding(0, 0, 0, (int) Utils.convertDpToPixel(8, StaggeredGridActivity.this));
            header.setPlayDelay(2000);
            header.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) Utils.convertDpToPixel(200, StaggeredGridActivity.this)));
            header.setAdapter(new BannerAdapter(StaggeredGridActivity.this));
            return header;
        }

        @Override
        public void onBindView(View headerView) {
        }
    });
    SpaceDecoration itemDecoration = new SpaceDecoration((int) Utils.convertDpToPixel(8, this));
    itemDecoration.setPaddingEdgeSide(true);
    itemDecoration.setPaddingStart(true);
    itemDecoration.setPaddingHeaderFooter(true);
    recyclerView.addItemDecoration(itemDecoration);
    adapter.setMore(R.layout.view_more, new RecyclerArrayAdapter.OnMoreListener() {

        @Override
        public void onMoreShow() {
            addData();
        }

        @Override
        public void onMoreClick() {
        }
    });
    adapter.setNoMore(R.layout.view_nomore);
    recyclerView.setRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            recyclerView.postDelayed(new Runnable() {

                @Override
                public void run() {
                    adapter.clear();
                    adapter.addAll(DataProvider.getPictures(0));
                }
            }, 1000);
        }
    });
    addData();
}
Also used : ViewGroup(android.view.ViewGroup) SpaceDecoration(com.jude.easyrecyclerview.decoration.SpaceDecoration) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) RecyclerArrayAdapter(com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter) ColorPointHintView(com.jude.rollviewpager.hintview.ColorPointHintView) RecyclerView(android.support.v7.widget.RecyclerView) EasyRecyclerView(com.jude.easyrecyclerview.EasyRecyclerView) RollPagerView(com.jude.rollviewpager.RollPagerView) View(android.view.View) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) GridLayoutManager(android.support.v7.widget.GridLayoutManager) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) BannerAdapter(com.jude.dome.header.BannerAdapter) ColorPointHintView(com.jude.rollviewpager.hintview.ColorPointHintView) RollPagerView(com.jude.rollviewpager.RollPagerView)

Aggregations

SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 GridLayoutManager (android.support.v7.widget.GridLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 BannerAdapter (com.jude.dome.header.BannerAdapter)1 EasyRecyclerView (com.jude.easyrecyclerview.EasyRecyclerView)1 RecyclerArrayAdapter (com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter)1 SpaceDecoration (com.jude.easyrecyclerview.decoration.SpaceDecoration)1 RollPagerView (com.jude.rollviewpager.RollPagerView)1 ColorPointHintView (com.jude.rollviewpager.hintview.ColorPointHintView)1