@Override public void onChildDrawOver( Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) { super.onChildDrawOver(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive); if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) { View itemView = viewHolder.itemView; c.save(); if (dX > 0) { c.clipRect( itemView.getLeft(), itemView.getTop(), itemView.getLeft() + dX, itemView.getBottom()); c.translate(itemView.getLeft(), itemView.getTop()); } else { c.clipRect( itemView.getRight() + dX, itemView.getTop(), itemView.getRight(), itemView.getBottom()); c.translate(itemView.getRight() + dX, itemView.getTop()); } mAdapter.onItemSwiping(c, viewHolder, dX, dY, isCurrentlyActive); c.restore(); } }
@Override public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) { if (actionState != ItemTouchHelper.ACTION_STATE_IDLE) { ItemTouchHelperViewHolder itemViewHolder = (ItemTouchHelperViewHolder) viewHolder; itemViewHolder.onItemSelected(); } super.onSelectedChanged(viewHolder, actionState); }
@Override public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) { if (actionState == ItemTouchHelper.ACTION_STATE_DRAG) { mAdapter.onItemDragStart(viewHolder); viewHolder.itemView.setTag(R.id.BaseQuickAdapter_dragging_support, true); } else if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) { mAdapter.onItemSwipeStart(viewHolder); viewHolder.itemView.setTag(R.id.BaseQuickAdapter_swiping_support, true); } super.onSelectedChanged(viewHolder, actionState); }
@Override public void onChildDraw( Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) { super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive); }
@Override public void onMoved( RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, int fromPos, RecyclerView.ViewHolder target, int toPos, int x, int y) { super.onMoved(recyclerView, viewHolder, fromPos, target, toPos, x, y); }
@Override public void clearView(final RecyclerView recyclerView, final RecyclerView.ViewHolder viewHolder) { super.clearView(recyclerView, viewHolder); viewHolder.itemView.setAlpha(ALPHA_FULL); if (viewHolder instanceof ItemTouchHelperViewHolder) { // Tell the view holder it's time to restore the idle state ItemTouchHelperViewHolder itemViewHolder = (ItemTouchHelperViewHolder) viewHolder; itemViewHolder.onItemClear(); } }
@Override public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { super.clearView(recyclerView, viewHolder); if (viewHolder.itemView.getTag(R.id.BaseQuickAdapter_dragging_support) != null && (Boolean) viewHolder.itemView.getTag(R.id.BaseQuickAdapter_dragging_support)) { mAdapter.onItemDragEnd(viewHolder); viewHolder.itemView.setTag(R.id.BaseQuickAdapter_dragging_support, false); } if (viewHolder.itemView.getTag(R.id.BaseQuickAdapter_swiping_support) != null && (Boolean) viewHolder.itemView.getTag(R.id.BaseQuickAdapter_swiping_support)) { mAdapter.onItemSwipeClear(viewHolder); viewHolder.itemView.setTag(R.id.BaseQuickAdapter_swiping_support, false); } }
@Override public void onSelectedChanged(final RecyclerView.ViewHolder viewHolder, final int actionState) { // We only want the active item to change if (actionState != ItemTouchHelper.ACTION_STATE_IDLE) { if (viewHolder instanceof ItemTouchHelperViewHolder) { // Let the view holder know that this item is being moved or dragged ItemTouchHelperViewHolder itemViewHolder = (ItemTouchHelperViewHolder) viewHolder; itemViewHolder.onItemSelected(); } } super.onSelectedChanged(viewHolder, actionState); }
@Override public void onChildDraw( final Canvas c, final RecyclerView recyclerView, final RecyclerView.ViewHolder viewHolder, final float dX, final float dY, final int actionState, final boolean isCurrentlyActive) { if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) { final float alpha = ALPHA_FULL - Math.abs(dX) / (float) viewHolder.itemView.getWidth(); viewHolder.itemView.setAlpha(alpha); viewHolder.itemView.setTranslationX(dX); } else { super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive); } }
@Override public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { super.clearView(recyclerView, viewHolder); ItemTouchHelperViewHolder itemViewHolder = (ItemTouchHelperViewHolder) viewHolder; itemViewHolder.onItemClear(); }