I am trying to add functionality of swipe to delete as well as to show bottom sheet pop-up if RecyclerView item is long pressed. I am using ItemTouchHelper.SimpleCallback
for swipe to delete and ItemTouchListener
for showing pop-up on long press of item.
Problem is that when I am swiping the item to delete its also detecting long press.
What I want is that it should ignore long press when item is being swiped.
I have ItemTouchHelper class which extends Simplecallback for swipe to delete. Following is the code to attach recyclerview for swipe to delete.
ItemTouchHelper.SimpleCallback itemTouchHelperCallback = new RecyclerItemTouchHelper(0, ItemTouchHelper.LEFT, this);
new ItemTouchHelper(itemTouchHelperCallback).attachToRecyclerView(recyclerView);
Follwing is code to add listener for long click event.
recyclerView.addOnItemTouchListener(new NotesRecyclerTouchListener(getApplicationContext(), recyclerView, new NotesRecyclerTouchListener.ClickListener() {
@Override
public void onLongClick(View view, int position) {
Note note = notesList.get(position);
Toast.makeText(getApplicationContext(), note.getTitle() + " is log pressed!", Toast.LENGTH_SHORT).show();
View sheetView = MainActivity.this.getLayoutInflater().inflate(R.layout.view_bottom_sheet_dialog, null);
BottomSheetDialog dialog = new BottomSheetDialog(MainActivity.this);
dialog.setContentView(sheetView);
dialog.show();
}
}));