Skip to content

Instantly share code, notes, and snippets.

@MostafaGazar
Last active June 19, 2018 04:12
Show Gist options
  • Save MostafaGazar/4f0afb8b7e28802b3004a5d4feb3747b to your computer and use it in GitHub Desktop.
Save MostafaGazar/4f0afb8b7e28802b3004a5d4feb3747b to your computer and use it in GitHub Desktop.
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(
new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT) {
private final Paint underlayPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG | Paint.FILTER_BITMAP_FLAG);
@Override
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
return false;
}
@Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
switch (direction) {
case ItemTouchHelper.LEFT:
// TODO :: Do something.
break;
}
}
@Override
public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
View itemView = viewHolder.itemView;
underlayPaint.setColor(Color.RED);
c.drawRect((float) itemView.getLeft(), (float) itemView.getTop(), dX, (float) itemView.getBottom(), underlayPaint);
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
}
});
itemTouchHelper.attachToRecyclerView(recyclerView);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment