Search in sources :

Example 1 with DividerDecoration

use of com.jude.easyrecyclerview.decoration.DividerDecoration in project EasyRecyclerView by Jude95.

the class MultiStyleActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_recyclerview);
    recyclerView = (EasyRecyclerView) findViewById(R.id.recyclerView);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setProgressView(R.layout.view_progress);
    DividerDecoration itemDecoration = new DividerDecoration(Color.GRAY, Util.dip2px(this, 0.5f), Util.dip2px(this, 72), 0);
    recyclerView.addItemDecoration(itemDecoration);
    adapter = new PersonWithAdAdapter(this);
    adapter.addAll(DataProvider.getPersonWithAds(0));
    recyclerView.setAdapterWithProgress(adapter);
}
Also used : DividerDecoration(com.jude.easyrecyclerview.decoration.DividerDecoration) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 2 with DividerDecoration

use of com.jude.easyrecyclerview.decoration.DividerDecoration in project EasyRecyclerView by Jude95.

the class StickyHeaderActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_loadmore);
    top = (FloatingActionButton) findViewById(R.id.top);
    recyclerView = (EasyRecyclerView) findViewById(R.id.recyclerView);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    DividerDecoration itemDecoration = new DividerDecoration(Color.GRAY, Util.dip2px(this, 0.5f), Util.dip2px(this, 72), 0);
    itemDecoration.setDrawLastItem(false);
    recyclerView.addItemDecoration(itemDecoration);
    recyclerView.setAdapterWithProgress(adapter = new RecyclerArrayAdapter<Person>(this) {

        @Override
        public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
            return new PersonViewHolder(parent);
        }
    });
    adapter.setMore(R.layout.view_more, this);
    adapter.setNoMore(R.layout.view_nomore, new RecyclerArrayAdapter.OnNoMoreListener() {

        @Override
        public void onNoMoreShow() {
            adapter.resumeMore();
        }

        @Override
        public void onNoMoreClick() {
            adapter.resumeMore();
        }
    });
    adapter.setOnItemLongClickListener(new RecyclerArrayAdapter.OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(int position) {
            adapter.remove(position);
            return true;
        }
    });
    adapter.setError(R.layout.view_error, new RecyclerArrayAdapter.OnErrorListener() {

        @Override
        public void onErrorShow() {
            adapter.resumeMore();
        }

        @Override
        public void onErrorClick() {
            adapter.resumeMore();
        }
    });
    // StickyHeader
    StickyHeaderDecoration decoration = new StickyHeaderDecoration(new StickyHeaderAdapter(this));
    decoration.setIncludeHeader(false);
    recyclerView.addItemDecoration(decoration);
    top.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            recyclerView.scrollToPosition(0);
        }
    });
    recyclerView.setRefreshListener(this);
    onRefresh();
}
Also used : DividerDecoration(com.jude.easyrecyclerview.decoration.DividerDecoration) ViewGroup(android.view.ViewGroup) StickyHeaderDecoration(com.jude.easyrecyclerview.decoration.StickyHeaderDecoration) RecyclerArrayAdapter(com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) EasyRecyclerView(com.jude.easyrecyclerview.EasyRecyclerView) View(android.view.View) PersonViewHolder(com.jude.dome.viewholder.PersonViewHolder)

Example 3 with DividerDecoration

use of com.jude.easyrecyclerview.decoration.DividerDecoration 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)

Example 4 with DividerDecoration

use of com.jude.easyrecyclerview.decoration.DividerDecoration in project EasyRecyclerView by Jude95.

the class InsertActivity 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 LinearLayoutManager(this));
    DividerDecoration itemDecoration = new DividerDecoration(Color.GRAY, Util.dip2px(this, 0.5f), Util.dip2px(this, 72), 0);
    itemDecoration.setDrawLastItem(false);
    recyclerView.addItemDecoration(itemDecoration);
    recyclerView.setAdapterWithProgress(adapter = new PersonAdapter(this));
    List<Person> persons = DataProvider.getPersonList(0);
    adapter.addAll(persons.subList(0, 3));
    recyclerView.setItemAnimator(new DefaultItemAnimator());
}
Also used : DividerDecoration(com.jude.easyrecyclerview.decoration.DividerDecoration) PersonAdapter(com.jude.dome.loadmore.PersonAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Person(com.jude.dome.entites.Person) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Example 5 with DividerDecoration

use of com.jude.easyrecyclerview.decoration.DividerDecoration in project EasyRecyclerView by Jude95.

the class RefreshAndMoreActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_loadmore);
    top = (FloatingActionButton) findViewById(R.id.top);
    recyclerView = (EasyRecyclerView) findViewById(R.id.recyclerView);
    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(layoutManager);
    DividerDecoration itemDecoration = new DividerDecoration(Color.GRAY, Util.dip2px(this, 0.5f), Util.dip2px(this, 72), 0);
    itemDecoration.setDrawLastItem(false);
    recyclerView.addItemDecoration(itemDecoration);
    recyclerView.setAdapterWithProgress(adapter = new RecyclerArrayAdapter<Person>(this) {

        @Override
        public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
            return new PersonViewHolder(parent);
        }
    });
    adapter.setMore(R.layout.view_more, this);
    adapter.setNoMore(R.layout.view_nomore, new RecyclerArrayAdapter.OnNoMoreListener() {

        @Override
        public void onNoMoreShow() {
            adapter.resumeMore();
        }

        @Override
        public void onNoMoreClick() {
            adapter.resumeMore();
        }
    });
    adapter.setOnItemLongClickListener(new RecyclerArrayAdapter.OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(int position) {
            adapter.remove(position);
            return true;
        }
    });
    adapter.setError(R.layout.view_error, new RecyclerArrayAdapter.OnErrorListener() {

        @Override
        public void onErrorShow() {
            adapter.resumeMore();
        }

        @Override
        public void onErrorClick() {
            adapter.resumeMore();
        }
    });
    top.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            recyclerView.scrollToPosition(0);
        }
    });
    recyclerView.setRefreshListener(this);
    onRefresh();
}
Also used : DividerDecoration(com.jude.easyrecyclerview.decoration.DividerDecoration) PersonViewHolder(com.jude.dome.viewholder.PersonViewHolder) ViewGroup(android.view.ViewGroup) RecyclerArrayAdapter(com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) EasyRecyclerView(com.jude.easyrecyclerview.EasyRecyclerView) View(android.view.View)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)5 DividerDecoration (com.jude.easyrecyclerview.decoration.DividerDecoration)5 View (android.view.View)3 ViewGroup (android.view.ViewGroup)3 EasyRecyclerView (com.jude.easyrecyclerview.EasyRecyclerView)3 RecyclerArrayAdapter (com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter)3 PersonAdapter (com.jude.dome.loadmore.PersonAdapter)2 PersonViewHolder (com.jude.dome.viewholder.PersonViewHolder)2 Handler (android.os.Handler)1 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)1 RecyclerView (android.support.v7.widget.RecyclerView)1 MotionEvent (android.view.MotionEvent)1 TextView (android.widget.TextView)1 Person (com.jude.dome.entites.Person)1 NarrowImageAdapter (com.jude.dome.horizontal.NarrowImageAdapter)1 SpaceDecoration (com.jude.easyrecyclerview.decoration.SpaceDecoration)1 StickyHeaderDecoration (com.jude.easyrecyclerview.decoration.StickyHeaderDecoration)1 RollPagerView (com.jude.rollviewpager.RollPagerView)1 ColorPointHintView (com.jude.rollviewpager.hintview.ColorPointHintView)1