Search in sources :

Example 41 with RecyclerView

use of android.support.v7.widget.RecyclerView in project smooth-app-bar-layout by henrytao-me.

the class SmoothSwipeRefreshLayoutActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_smooth_swipe_refresh_layout);
    ButterKnife.bind(this);
    setSupportActionBar(vToolbar);
    vToolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
    mAdapter = new DynamicAdapter<>(Utils.getSampleData());
    RecyclerView.Adapter adapter = new SimpleRecyclerViewAdapter(mAdapter) {

        @Override
        public RecyclerView.ViewHolder onCreateFooterViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
            return null;
        }

        @Override
        public RecyclerView.ViewHolder onCreateHeaderViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
            return new HeaderHolder(layoutInflater, viewGroup, R.layout.item_header_spacing);
        }
    };
    vRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    vRecyclerView.setAdapter(adapter);
    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.RIGHT) {

        @Override
        public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
            return false;
        }

        @Override
        public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
            mAdapter.remove((int) viewHolder.itemView.getTag(R.id.tag_position));
        }
    });
    itemTouchHelper.attachToRecyclerView(vRecyclerView);
    // set progress view offset
    int actionBarSize = ResourceUtils.getActionBarSize(this);
    int progressViewStart = getResources().getDimensionPixelSize(R.dimen.app_bar_height) - actionBarSize;
    int progressViewEnd = progressViewStart + (int) (actionBarSize * 1.5f);
    vSwipeRefreshLayout.setProgressViewOffset(true, progressViewStart, progressViewEnd);
    mHandler = new Handler();
    mCallback = new Runnable() {

        @Override
        public void run() {
            if (!isFinishing()) {
                vSwipeRefreshLayout.setRefreshing(false);
            }
        }
    };
    vSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            mHandler.postDelayed(mCallback, 2000);
        }
    });
}
Also used : ViewGroup(android.view.ViewGroup) Handler(android.os.Handler) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) HeaderHolder(me.henrytao.recyclerview.holder.HeaderHolder) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) SimpleRecyclerViewAdapter(me.henrytao.recyclerview.SimpleRecyclerViewAdapter) LayoutInflater(android.view.LayoutInflater) RecyclerView(android.support.v7.widget.RecyclerView)

Example 42 with RecyclerView

use of android.support.v7.widget.RecyclerView in project smooth-app-bar-layout by henrytao-me.

the class SmoothPreScrollActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_smooth_scroll_exit_until_collapsed);
    ButterKnife.bind(this);
    setSupportActionBar(vToolbar);
    vToolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
    mAdapter = new DynamicAdapter<>(me.henrytao.smoothappbarlayoutdemo.util.Utils.getSampleData());
    RecyclerView.Adapter adapter = new SimpleRecyclerViewAdapter(mAdapter) {

        @Override
        public RecyclerView.ViewHolder onCreateFooterViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
            return null;
        }

        @Override
        public RecyclerView.ViewHolder onCreateHeaderViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
            return new HeaderHolder(layoutInflater, viewGroup, R.layout.item_header_spacing);
        }
    };
    vRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    vRecyclerView.setAdapter(adapter);
    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.RIGHT) {

        @Override
        public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
            return false;
        }

        @Override
        public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
            mAdapter.remove((int) viewHolder.itemView.getTag(R.id.tag_position));
        }
    });
    itemTouchHelper.attachToRecyclerView(vRecyclerView);
    Utils.intPreScroll(vSmoothAppBarLayout, vRecyclerView, 300);
}
Also used : ViewGroup(android.view.ViewGroup) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) HeaderHolder(me.henrytao.recyclerview.holder.HeaderHolder) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) SimpleRecyclerViewAdapter(me.henrytao.recyclerview.SimpleRecyclerViewAdapter) LayoutInflater(android.view.LayoutInflater) RecyclerView(android.support.v7.widget.RecyclerView)

Example 43 with RecyclerView

use of android.support.v7.widget.RecyclerView in project smooth-app-bar-layout by henrytao-me.

the class SmoothQuickReturnActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_smooth_quick_return);
    ButterKnife.bind(this);
    setSupportActionBar(vToolbar);
    vToolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
    mAdapter = new DynamicAdapter<>(Utils.getSampleData());
    RecyclerView.Adapter adapter = new SimpleRecyclerViewAdapter(mAdapter) {

        @Override
        public RecyclerView.ViewHolder onCreateFooterViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
            return null;
        }

        @Override
        public RecyclerView.ViewHolder onCreateHeaderViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
            return new HeaderHolder(layoutInflater, viewGroup, R.layout.item_header_spacing);
        }
    };
    vRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    vRecyclerView.setAdapter(adapter);
    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.RIGHT) {

        @Override
        public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
            return false;
        }

        @Override
        public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
            mAdapter.remove((int) viewHolder.itemView.getTag(R.id.tag_position));
        }
    });
    itemTouchHelper.attachToRecyclerView(vRecyclerView);
}
Also used : ViewGroup(android.view.ViewGroup) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) HeaderHolder(me.henrytao.recyclerview.holder.HeaderHolder) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) SimpleRecyclerViewAdapter(me.henrytao.recyclerview.SimpleRecyclerViewAdapter) LayoutInflater(android.view.LayoutInflater) RecyclerView(android.support.v7.widget.RecyclerView)

Example 44 with RecyclerView

use of android.support.v7.widget.RecyclerView in project smooth-app-bar-layout by henrytao-me.

the class SmoothScrollActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_smooth_scroll);
    ButterKnife.bind(this);
    setSupportActionBar(vToolbar);
    vToolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
    mAdapter = new DynamicAdapter<>(Utils.getSampleData());
    RecyclerView.Adapter adapter = new SimpleRecyclerViewAdapter(mAdapter) {

        @Override
        public RecyclerView.ViewHolder onCreateFooterViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
            return null;
        }

        @Override
        public RecyclerView.ViewHolder onCreateHeaderViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
            return new HeaderHolder(layoutInflater, viewGroup, R.layout.item_header_spacing);
        }
    };
    vRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    vRecyclerView.setAdapter(adapter);
    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.RIGHT) {

        @Override
        public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
            return false;
        }

        @Override
        public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
            mAdapter.remove((int) viewHolder.itemView.getTag(R.id.tag_position));
        }
    });
    itemTouchHelper.attachToRecyclerView(vRecyclerView);
}
Also used : ViewGroup(android.view.ViewGroup) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) HeaderHolder(me.henrytao.recyclerview.holder.HeaderHolder) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) SimpleRecyclerViewAdapter(me.henrytao.recyclerview.SimpleRecyclerViewAdapter) LayoutInflater(android.view.LayoutInflater) RecyclerView(android.support.v7.widget.RecyclerView)

Example 45 with RecyclerView

use of android.support.v7.widget.RecyclerView in project smooth-app-bar-layout by henrytao-me.

the class SmoothScrollExitUntilCollapsedActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_smooth_scroll_exit_until_collapsed);
    ButterKnife.bind(this);
    setSupportActionBar(vToolbar);
    vToolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
    mAdapter = new DynamicAdapter<>(Utils.getSampleData());
    RecyclerView.Adapter adapter = new SimpleRecyclerViewAdapter(mAdapter) {

        @Override
        public RecyclerView.ViewHolder onCreateFooterViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
            return null;
        }

        @Override
        public RecyclerView.ViewHolder onCreateHeaderViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
            return new HeaderHolder(layoutInflater, viewGroup, R.layout.item_header_spacing);
        }
    };
    vRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    vRecyclerView.setAdapter(adapter);
    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.RIGHT) {

        @Override
        public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
            return false;
        }

        @Override
        public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
            mAdapter.remove((int) viewHolder.itemView.getTag(R.id.tag_position));
        }
    });
    itemTouchHelper.attachToRecyclerView(vRecyclerView);
}
Also used : ViewGroup(android.view.ViewGroup) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) HeaderHolder(me.henrytao.recyclerview.holder.HeaderHolder) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) SimpleRecyclerViewAdapter(me.henrytao.recyclerview.SimpleRecyclerViewAdapter) LayoutInflater(android.view.LayoutInflater) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)978 View (android.view.View)671 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)574 TextView (android.widget.TextView)213 GridLayoutManager (android.support.v7.widget.GridLayoutManager)143 ImageView (android.widget.ImageView)128 ArrayList (java.util.ArrayList)100 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)73 Toolbar (android.support.v7.widget.Toolbar)68 ViewGroup (android.view.ViewGroup)66 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)61 Intent (android.content.Intent)54 Bundle (android.os.Bundle)50 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)49 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)49 Context (android.content.Context)46 Nullable (android.support.annotation.Nullable)45 Rect (android.graphics.Rect)41 Handler (android.os.Handler)39 LayoutInflater (android.view.LayoutInflater)38