This is a great library indeed. Thanks to you @hudomju. I'm using this library, it worked great. I used it in viewpager's fragments and they are working with no issues but, when i try to use the same in an activity in same project, it is not working at all. SwipeToDismissTouchListener, no events are logged, whereas recyclerView.addOnItemTouchListener's events are logged. If someone have landed in same issue and have figured a way to make it work, pls do let me know. Thanks in advance.
here is the code for SwipeToDismissTouchListener I have used in fragment:
final SwipeToDismissTouchListener<RecyclerViewAdapter> touchListener =
new SwipeToDismissTouchListener<>(
new RecyclerViewAdapter(recyclerview),
new SwipeToDismissTouchListener.DismissCallbacks<RecyclerViewAdapter>() {
@Override
public boolean canDismiss(int position) {
return true;
}
@Override
public void onPendingDismiss(RecyclerViewAdapter recyclerView, int position) {
}
@Override
public void onDismiss(RecyclerViewAdapter view, int position) {
mAdapter.remove(position);
}
});
touchListener.setDismissDelay(TIME_TO_AUTOMATICALLY_DISMISS_ITEM);
recyclerview.setOnTouchListener(touchListener);
recyclerview.addOnScrollListener((RecyclerView.OnScrollListener) touchListener.makeScrollListener());
recyclerview.addOnItemTouchListener(new SwipeableItemClickListener(getActivity(),
new OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
if (view.getId() == R.id.txt_delete) {
touchListener.processPendingDismisses();
} else if (view.getId() == R.id.txt_undo) {
touchListener.undoPendingDismiss();
} else {
}
}
}));
Same code i have used in Activity but failed to achieve same as in fragment
This is a great library indeed. Thanks to you @hudomju. I'm using this library, it worked great. I used it in viewpager's fragments and they are working with no issues but, when i try to use the same in an activity in same project, it is not working at all. SwipeToDismissTouchListener, no events are logged, whereas recyclerView.addOnItemTouchListener's events are logged. If someone have landed in same issue and have figured a way to make it work, pls do let me know. Thanks in advance.
here is the code for SwipeToDismissTouchListener I have used in fragment:
Same code i have used in Activity but failed to achieve same as in fragment