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);
}
}
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;
}
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);
}
}
Aggregations