Search in sources :

Example 1 with PagerAdapter

use of me.yokeyword.sample.demo_flow.adapter.PagerAdapter in project Fragmentation by YoKeyword.

the class RecyclerSwipeBackFragment method initView.

private void initView(View view) {
    mRecy = (RecyclerView) view.findViewById(R.id.recy);
    mToolbar = (Toolbar) view.findViewById(R.id.toolbar);
    _initToolbar(mToolbar);
    mAdapter = new PagerAdapter(_mActivity);
    LinearLayoutManager manager = new LinearLayoutManager(_mActivity);
    mRecy.setLayoutManager(manager);
    mRecy.setAdapter(mAdapter);
    mAdapter.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(int position, View view) {
            start(FirstSwipeBackFragment.newInstance());
        }
    });
    // Init Datas
    List<String> items = new ArrayList<>();
    for (int i = 0; i < 20; i++) {
        String item;
        item = getString(R.string.favorite) + " " + i;
        items.add(item);
    }
    mAdapter.setDatas(items);
}
Also used : OnItemClickListener(me.yokeyword.sample.demo_flow.listener.OnItemClickListener) ArrayList(java.util.ArrayList) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) PagerAdapter(me.yokeyword.sample.demo_flow.adapter.PagerAdapter)

Example 2 with PagerAdapter

use of me.yokeyword.sample.demo_flow.adapter.PagerAdapter in project Fragmentation by YoKeyword.

the class PagerChildFragment method initView.

private void initView(View view) {
    mRecy = (RecyclerView) view.findViewById(R.id.recy);
    mAdapter = new PagerAdapter(_mActivity);
    LinearLayoutManager manager = new LinearLayoutManager(_mActivity);
    mRecy.setLayoutManager(manager);
    mRecy.setAdapter(mAdapter);
    mAdapter.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(int position, View view) {
            if (getParentFragment() instanceof DiscoverFragment) {
                ((DiscoverFragment) getParentFragment()).start(CycleFragment.newInstance(1));
            }
        }
    });
    mRecy.post(new Runnable() {

        @Override
        public void run() {
            // Init Datas
            List<String> items = new ArrayList<>();
            for (int i = 0; i < 20; i++) {
                String item;
                if (mFrom == 0) {
                    item = getString(R.string.recommend) + " " + i;
                } else if (mFrom == 1) {
                    item = getString(R.string.hot) + " " + i;
                } else {
                    item = getString(R.string.favorite) + " " + i;
                }
                items.add(item);
            }
            mAdapter.setDatas(items);
        }
    });
}
Also used : OnItemClickListener(me.yokeyword.sample.demo_flow.listener.OnItemClickListener) ArrayList(java.util.ArrayList) List(java.util.List) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) PagerAdapter(me.yokeyword.sample.demo_flow.adapter.PagerAdapter)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 RecyclerView (android.support.v7.widget.RecyclerView)2 View (android.view.View)2 ArrayList (java.util.ArrayList)2 PagerAdapter (me.yokeyword.sample.demo_flow.adapter.PagerAdapter)2 OnItemClickListener (me.yokeyword.sample.demo_flow.listener.OnItemClickListener)2 List (java.util.List)1