use of com.xabber.android.ui.activity.ChatActivity in project xabber-android by redsolution.
the class RecentChatFragment method onItemSwipe.
@Override
public void onItemSwipe(int position, int direction) {
Object itemAtPosition = adapter.getItem(position);
if (itemAtPosition != null && itemAtPosition instanceof ChatVO) {
// backup of removed item for undo purpose
final ChatVO deletedItem = (ChatVO) itemAtPosition;
// update value
setChatArchived(deletedItem, !(deletedItem).isArchived());
deletedItem.setArchived(!(deletedItem).isArchived());
// remove the item from recycler view
adapter.removeItem(position);
if (((ChatActivity) getActivity()).isShowArchived())
adapter.addItem(position, deletedItem);
// showing snackbar with Undo option
showSnackbar(deletedItem, position);
}
}
Aggregations