Search in sources :

Example 1 with ChatVO

use of com.xabber.android.presentation.ui.contactlist.viewobjects.ChatVO 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)

Example 2 with ChatVO

use of com.xabber.android.presentation.ui.contactlist.viewobjects.ChatVO in project xabber-android by redsolution.

the class RecentChatFragment method onItemClick.

@Override
public boolean onItemClick(int position) {
    ChatVO chat = (ChatVO) adapter.getItem(position);
    if (listener != null && chat != null) {
        AbstractChat abstractChat = MessageManager.getInstance().getOrCreateChat(chat.getAccountJid(), chat.getUserJid());
        if (abstractChat != null)
            abstractChat.resetUnreadMessageCount();
        listener.onChatSelected(chat.getAccountJid(), chat.getUserJid());
    }
    return true;
}
Also used : AbstractChat(com.xabber.android.data.message.AbstractChat) ChatVO(com.xabber.android.presentation.ui.contactlist.viewobjects.ChatVO)

Example 3 with ChatVO

use of com.xabber.android.presentation.ui.contactlist.viewobjects.ChatVO in project xabber-android by redsolution.

the class ContactListFragment 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());
        // remove the item from recycler view
        adapter.removeItem(position);
        // update end of list
        if (presenter.getCurrentChatsState() == ContactListPresenter.ChatListState.recent) {
            ArrayList<IFlexible> items = presenter.getTwoNextRecentChat();
            if (items != null && items.size() == 2) {
                adapter.addItem(MAX_RECENT_ITEMS - 1, items.get(0));
                adapter.updateItem(MAX_RECENT_ITEMS, items.get(1), null);
            }
        }
        // showing snackbar with Undo option
        showSnackbar(deletedItem, position);
    }
}
Also used : IFlexible(eu.davidea.flexibleadapter.items.IFlexible) ChatVO(com.xabber.android.presentation.ui.contactlist.viewobjects.ChatVO)

Aggregations

ChatVO (com.xabber.android.presentation.ui.contactlist.viewobjects.ChatVO)3 AbstractChat (com.xabber.android.data.message.AbstractChat)1 ChatActivity (com.xabber.android.ui.activity.ChatActivity)1 IFlexible (eu.davidea.flexibleadapter.items.IFlexible)1