Search in sources :

Example 1 with RollPagerView

use of com.jude.rollviewpager.RollPagerView in project EasyRecyclerView by Jude95.

the class CollapsingActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_collapsing);
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    recyclerView = (EasyRecyclerView) findViewById(R.id.recyclerView);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(adapter = new PersonAdapter(this));
    adapter.setMore(R.layout.view_more, new RecyclerArrayAdapter.OnLoadMoreListener() {

        @Override
        public void onLoadMore() {
            handler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    adapter.addAll(DataProvider.getPersonList(0));
                }
            }, 1000);
        }
    });
    adapter.addAll(DataProvider.getPersonList(0));
    RollPagerView rollPagerView = (RollPagerView) findViewById(R.id.rollPagerView);
    rollPagerView.setHintView(new ColorPointHintView(this, Color.YELLOW, Color.GRAY));
    rollPagerView.setAdapter(new BannerAdapter());
}
Also used : ColorPointHintView(com.jude.rollviewpager.hintview.ColorPointHintView) PersonAdapter(com.jude.dome.loadmore.PersonAdapter) RecyclerArrayAdapter(com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RollPagerView(com.jude.rollviewpager.RollPagerView)

Example 2 with RollPagerView

use of com.jude.rollviewpager.RollPagerView 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)

Example 3 with RollPagerView

use of com.jude.rollviewpager.RollPagerView in project EasyRecyclerView by Jude95.

the class HeaderFooterActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_recyclerview);
    recyclerView = (EasyRecyclerView) findViewById(R.id.recyclerView);
    recyclerView.setAdapter(adapter = new PersonAdapter(this));
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    DividerDecoration itemDecoration = new DividerDecoration(Color.GRAY, Util.dip2px(this, 0.5f), Util.dip2px(this, 72), 0);
    itemDecoration.setDrawLastItem(true);
    itemDecoration.setDrawHeaderFooter(true);
    recyclerView.addItemDecoration(itemDecoration);
    recyclerView.setRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

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

                @Override
                public void run() {
                    adapter.clear();
                    adapter.addAll(DataProvider.getPersonList(0));
                }
            }, 1500);
        }
    });
    adapter.addHeader(new RecyclerArrayAdapter.ItemView() {

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

        @Override
        public void onBindView(View headerView) {
        }
    });
    adapter.addHeader(new RecyclerArrayAdapter.ItemView() {

        @Override
        public View onCreateView(ViewGroup parent) {
            RecyclerView recyclerView = new RecyclerView(parent.getContext()) {

                // 为了不打扰横向RecyclerView的滑动操作,可以这样处理
                @Override
                public boolean onTouchEvent(MotionEvent event) {
                    super.onTouchEvent(event);
                    return true;
                }
            };
            recyclerView.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) Utils.convertDpToPixel(300, HeaderFooterActivity.this)));
            final NarrowImageAdapter adapter;
            recyclerView.setAdapter(adapter = new NarrowImageAdapter(parent.getContext()));
            recyclerView.setLayoutManager(new LinearLayoutManager(parent.getContext(), LinearLayoutManager.HORIZONTAL, false));
            recyclerView.addItemDecoration(new SpaceDecoration((int) Utils.convertDpToPixel(8, parent.getContext())));
            adapter.setMore(R.layout.view_more_horizontal, new RecyclerArrayAdapter.OnLoadMoreListener() {

                @Override
                public void onLoadMore() {
                    new Handler().postDelayed(new Runnable() {

                        @Override
                        public void run() {
                            adapter.addAll(DataProvider.getNarrowImage(0));
                        }
                    }, 1000);
                }
            });
            adapter.addAll(DataProvider.getNarrowImage(0));
            return recyclerView;
        }

        @Override
        public void onBindView(View headerView) {
            // 这里的处理别忘了
            ((ViewGroup) headerView).requestDisallowInterceptTouchEvent(true);
        }
    });
    adapter.addFooter(new RecyclerArrayAdapter.ItemView() {

        @Override
        public View onCreateView(ViewGroup parent) {
            TextView tv = new TextView(HeaderFooterActivity.this);
            tv.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) Utils.convertDpToPixel(56, HeaderFooterActivity.this)));
            tv.setGravity(Gravity.CENTER);
            tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
            tv.setText("(-_-)/~~~死宅真是恶心");
            return tv;
        }

        @Override
        public void onBindView(View headerView) {
        }
    });
    adapter.addAll(DataProvider.getPersonList(0));
}
Also used : DividerDecoration(com.jude.easyrecyclerview.decoration.DividerDecoration) NarrowImageAdapter(com.jude.dome.horizontal.NarrowImageAdapter) ViewGroup(android.view.ViewGroup) SpaceDecoration(com.jude.easyrecyclerview.decoration.SpaceDecoration) Handler(android.os.Handler) PersonAdapter(com.jude.dome.loadmore.PersonAdapter) RecyclerArrayAdapter(com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) ColorPointHintView(com.jude.rollviewpager.hintview.ColorPointHintView) RollPagerView(com.jude.rollviewpager.RollPagerView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) EasyRecyclerView(com.jude.easyrecyclerview.EasyRecyclerView) MotionEvent(android.view.MotionEvent) ColorPointHintView(com.jude.rollviewpager.hintview.ColorPointHintView) RecyclerView(android.support.v7.widget.RecyclerView) EasyRecyclerView(com.jude.easyrecyclerview.EasyRecyclerView) TextView(android.widget.TextView) RollPagerView(com.jude.rollviewpager.RollPagerView)

Aggregations

RecyclerArrayAdapter (com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter)3 RollPagerView (com.jude.rollviewpager.RollPagerView)3 ColorPointHintView (com.jude.rollviewpager.hintview.ColorPointHintView)3 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 RecyclerView (android.support.v7.widget.RecyclerView)2 View (android.view.View)2 ViewGroup (android.view.ViewGroup)2 PersonAdapter (com.jude.dome.loadmore.PersonAdapter)2 EasyRecyclerView (com.jude.easyrecyclerview.EasyRecyclerView)2 SpaceDecoration (com.jude.easyrecyclerview.decoration.SpaceDecoration)2 Handler (android.os.Handler)1 GridLayoutManager (android.support.v7.widget.GridLayoutManager)1 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)1 MotionEvent (android.view.MotionEvent)1 TextView (android.widget.TextView)1 BannerAdapter (com.jude.dome.header.BannerAdapter)1 NarrowImageAdapter (com.jude.dome.horizontal.NarrowImageAdapter)1 DividerDecoration (com.jude.easyrecyclerview.decoration.DividerDecoration)1