Search in sources :

Example 11 with BaseEntity

use of com.xabber.android.data.entity.BaseEntity in project xabber-android by redsolution.

the class ChatViewer method getInitialChatFromIntent.

private void getInitialChatFromIntent() {
    Intent intent = getIntent();
    String account = getAccount(intent);
    String user = getUser(intent);
    if (account != null && user != null) {
        initialChat = new BaseEntity(account, user);
    }
}
Also used : BaseEntity(com.xabber.android.data.entity.BaseEntity) Intent(android.content.Intent)

Example 12 with BaseEntity

use of com.xabber.android.data.entity.BaseEntity 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)

Example 13 with BaseEntity

use of com.xabber.android.data.entity.BaseEntity in project xabber-android by redsolution.

the class ContactListFragment method onCreateContextMenu.

@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    BaseEntity baseEntity = (BaseEntity) listView.getItemAtPosition(info.position);
    if (baseEntity instanceof AbstractContact) {
        ContextMenuHelper.createContactContextMenu(getActivity(), adapter, (AbstractContact) baseEntity, menu);
    } else if (baseEntity instanceof AccountConfiguration) {
        ContextMenuHelper.createAccountContextMenu(getActivity(), adapter, baseEntity.getAccount(), menu);
    } else if (baseEntity instanceof GroupConfiguration) {
        ContextMenuHelper.createGroupContextMenu(getActivity(), adapter, baseEntity.getAccount(), baseEntity.getUser(), menu);
    } else {
        throw new IllegalStateException();
    }
}
Also used : AdapterContextMenuInfo(android.widget.AdapterView.AdapterContextMenuInfo) BaseEntity(com.xabber.android.data.entity.BaseEntity) AccountConfiguration(com.xabber.android.ui.adapter.AccountConfiguration) GroupConfiguration(com.xabber.android.ui.adapter.GroupConfiguration) AbstractContact(com.xabber.android.data.roster.AbstractContact)

Example 14 with BaseEntity

use of com.xabber.android.data.entity.BaseEntity in project xabber-android by redsolution.

the class ContactListFragment method scrollTo.

/**
     * Scroll contact list to specified account.
     *
     * @param account
     */
void scrollTo(String account) {
    long count = listView.getCount();
    for (int position = 0; position < (int) count; position++) {
        BaseEntity baseEntity = (BaseEntity) listView.getItemAtPosition(position);
        if (baseEntity != null && baseEntity instanceof AccountConfiguration && baseEntity.getAccount().equals(account)) {
            stopMovement();
            listView.setSelection(position);
            break;
        }
    }
}
Also used : BaseEntity(com.xabber.android.data.entity.BaseEntity) AccountConfiguration(com.xabber.android.ui.adapter.AccountConfiguration)

Aggregations

BaseEntity (com.xabber.android.data.entity.BaseEntity)14 ArrayList (java.util.ArrayList)6 Intent (android.content.Intent)2 NestedMap (com.xabber.android.data.entity.NestedMap)2 AbstractChat (com.xabber.android.data.message.AbstractChat)2 RosterContact (com.xabber.android.data.roster.RosterContact)2 AccountConfiguration (com.xabber.android.ui.adapter.AccountConfiguration)2 Cursor (android.database.Cursor)1 Uri (android.net.Uri)1 AdapterContextMenuInfo (android.widget.AdapterView.AdapterContextMenuInfo)1 ChatsShowStatusChange (com.xabber.android.data.SettingsManager.ChatsShowStatusChange)1 AccountItem (com.xabber.android.data.account.AccountItem)1 AccountJid (com.xabber.android.data.entity.AccountJid)1 UserJid (com.xabber.android.data.entity.UserJid)1 RoomChat (com.xabber.android.data.extension.muc.RoomChat)1 AbstractContact (com.xabber.android.data.roster.AbstractContact)1 RosterManager (com.xabber.android.data.roster.RosterManager)1 GroupConfiguration (com.xabber.android.ui.adapter.GroupConfiguration)1 ChatViewerFragment (com.xabber.android.ui.fragment.ChatViewerFragment)1 HashSet (java.util.HashSet)1