Search in sources :

Example 1 with DashboardAdapter

use of com.android.settings.dashboard.DashboardAdapter in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ConditionAdapterUtils method addDismiss.

public static void addDismiss(final RecyclerView recyclerView) {
    ItemTouchHelper.SimpleCallback callback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.START | ItemTouchHelper.END) {

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

        @Override
        public int getSwipeDirs(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
            return viewHolder.getItemViewType() == R.layout.condition_card ? super.getSwipeDirs(recyclerView, viewHolder) : 0;
        }

        @Override
        public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
            DashboardAdapter adapter = (DashboardAdapter) recyclerView.getAdapter();
            Object item = adapter.getItem(viewHolder.getItemId());
            if (item instanceof Condition) {
                ((Condition) item).silence();
            }
        }
    };
    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(callback);
    itemTouchHelper.attachToRecyclerView(recyclerView);
}
Also used : ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) RecyclerView(android.support.v7.widget.RecyclerView) DashboardAdapter(com.android.settings.dashboard.DashboardAdapter)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)1 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)1 DashboardAdapter (com.android.settings.dashboard.DashboardAdapter)1