Skip to content

Instantly share code, notes, and snippets.

@Tarelochkin
Created September 23, 2017 07:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tarelochkin/31304d2e00f6bfdcc47194f2e5497651 to your computer and use it in GitHub Desktop.
Save Tarelochkin/31304d2e00f6bfdcc47194f2e5497651 to your computer and use it in GitHub Desktop.
new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {
@Override
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
return false;
}
// Called when a user swipes left or right on a ViewHolder
@Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int swipeDir) {
// Here is where you'll implement swipe to delete
// TODO (1) Use getTag (from the adapter code) to get the id of the swiped item
// TODO (2) Delete a single row of data in your database
// TODO (3) Restart the loader to re-query for all items after a deletion
}
}).attachToRecyclerView(mRecyclerView);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment