Search in sources :

Example 1 with ChatActivity

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);
    }
}
Also used : ChatActivity(com.xabber.android.ui.activity.ChatActivity) ChatVO(com.xabber.android.presentation.ui.contactlist.viewobjects.ChatVO)

Aggregations

ChatVO (com.xabber.android.presentation.ui.contactlist.viewobjects.ChatVO)1 ChatActivity (com.xabber.android.ui.activity.ChatActivity)1