Search in sources :

Example 1 with MenuTintDelegate

use of io.github.hidroh.materialistic.MenuTintDelegate in project materialistic by hidroh.

the class FavoriteRecyclerViewAdapter method onAttachedToRecyclerView.

@Override
public void onAttachedToRecyclerView(final RecyclerView recyclerView) {
    super.onAttachedToRecyclerView(recyclerView);
    mMenuTintDelegate = new MenuTintDelegate();
    mMenuTintDelegate.onActivityCreated(mContext);
    mItemTouchHelper = new ItemTouchHelper(new ItemTouchHelperCallback(mContext) {

        @Override
        public int getSwipeDirs(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
            if (mActionModeDelegate != null && mActionModeDelegate.isInActionMode()) {
                return 0;
            }
            return super.getSwipeDirs(recyclerView, viewHolder);
        }

        @Override
        public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
            dismiss(viewHolder.getAdapterPosition());
        }
    });
    mItemTouchHelper.attachToRecyclerView(recyclerView);
}
Also used : ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) MenuTintDelegate(io.github.hidroh.materialistic.MenuTintDelegate) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)1 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)1 MenuTintDelegate (io.github.hidroh.materialistic.MenuTintDelegate)1