Search in sources :

Example 1 with ChatsShowStatusChange

use of com.xabber.android.data.SettingsManager.ChatsShowStatusChange in project xabber-android by redsolution.

the class MessageManager method onSettingsChanged.

/**
     * Called on action settings change.
     */
public void onSettingsChanged() {
    ChatsShowStatusChange showStatusChange = SettingsManager.chatsShowStatusChange();
    Collection<BaseEntity> changedEntities = new ArrayList<>();
    for (AbstractChat chat : chats.values()) {
        if ((chat instanceof RegularChat && showStatusChange != ChatsShowStatusChange.always) || (chat instanceof RoomChat && showStatusChange == ChatsShowStatusChange.never)) {
            // Remove actions with status change.
            ArrayList<MessageItem> remove = new ArrayList<>();
            for (MessageItem messageItem : chat.getMessages()) {
                if (messageItem.getAction() != null && messageItem.getAction().isStatusChage()) {
                    remove.add(messageItem);
                }
            }
            if (remove.isEmpty()) {
                continue;
            }
            for (MessageItem messageItem : remove) {
                chat.removeMessage(messageItem);
            }
            changedEntities.add(chat);
        }
    }
    RosterManager.getInstance().onContactsChanged(changedEntities);
}
Also used : ChatsShowStatusChange(com.xabber.android.data.SettingsManager.ChatsShowStatusChange) ArrayList(java.util.ArrayList) BaseEntity(com.xabber.android.data.entity.BaseEntity) RoomChat(com.xabber.android.data.extension.muc.RoomChat)

Aggregations

ChatsShowStatusChange (com.xabber.android.data.SettingsManager.ChatsShowStatusChange)1 BaseEntity (com.xabber.android.data.entity.BaseEntity)1 RoomChat (com.xabber.android.data.extension.muc.RoomChat)1 ArrayList (java.util.ArrayList)1