FAB doesn't reappear when using RecyclerView's swipe functionality
manvis opened this issue · 1 comments
manvis commented
Since the release of a recent update, RecyclerView natively supports swipe functionality (e.g. swipe to delete) with the help of ItemTouchHelper. It's set up like this:
ItemTouchHelper.SimpleCallback simpleItemTouchCallback =
new ItemTouchHelper
.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {
@Override
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder,
RecyclerView.ViewHolder viewHolder1) {
return false;
}
@Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int i) {
getActivity().getContentResolver()
.delete(Uri.withAppendedPath(AppContentProvider.CONTENT_URI,
String.valueOf(viewHolder.getItemId())), null, null);
}
};
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(simpleItemTouchCallback);
itemTouchHelper.attachToRecyclerView(recyclerView);
Unfortunately, if FAB is hidden and rows are swiped away to the point when scroll bar disappears, it becomes impossible to recover it without switching orientation or restarting the app.
dekaru commented
You could always use fab.show() method to restore the button's visibility after a finished swippe.