Search in sources :

Example 6 with BaseEntity

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

the class RosterManager method onContactChanged.

/**
     * Notifies registered {@link OnContactChangedListener}.
     */
public static void onContactChanged(String account, String bareAddress) {
    final ArrayList<BaseEntity> entities = new ArrayList<>();
    entities.add(new BaseEntity(account, bareAddress));
    onContactsChanged(entities);
}
Also used : ArrayList(java.util.ArrayList) BaseEntity(com.xabber.android.data.entity.BaseEntity)

Example 7 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 8 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)

Example 9 with BaseEntity

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

the class ContactList method openChat.

/**
     * Open chat with specified contact.
     * <p/>
     * Show dialog to choose account if necessary.
     *
     * @param user
     * @param text can be <code>null</code>.
     */
private void openChat(String user, String text) {
    String bareAddress = Jid.getBareAddress(user);
    ArrayList<BaseEntity> entities = new ArrayList<>();
    for (AbstractChat check : MessageManager.getInstance().getChats()) {
        if (check.isActive() && check.getUser().equals(bareAddress)) {
            entities.add(check);
        }
    }
    if (entities.size() == 1) {
        openChat(entities.get(0), text);
        return;
    }
    entities.clear();
    for (RosterContact check : RosterManager.getInstance().getContacts()) {
        if (check.isEnabled() && check.getUser().equals(bareAddress)) {
            entities.add(check);
        }
    }
    if (entities.size() == 1) {
        openChat(entities.get(0), text);
        return;
    }
    Collection<String> accounts = AccountManager.getInstance().getAccounts();
    if (accounts.isEmpty()) {
        return;
    }
    if (accounts.size() == 1) {
        openChat(new BaseEntity(accounts.iterator().next(), bareAddress), text);
        return;
    }
    AccountChooseDialogFragment.newInstance(bareAddress, text).show(getFragmentManager(), "OPEN_WITH_ACCOUNT");
}
Also used : RosterContact(com.xabber.android.data.roster.RosterContact) AbstractChat(com.xabber.android.data.message.AbstractChat) ArrayList(java.util.ArrayList) BaseEntity(com.xabber.android.data.entity.BaseEntity)

Example 10 with BaseEntity

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

the class ChatViewer method restoreInstanceState.

private void restoreInstanceState(Bundle savedInstanceState) {
    isRecentChatsSelected = savedInstanceState.getBoolean(SAVED_IS_RECENT_CHATS_SELECTED);
    if (isRecentChatsSelected) {
        selectedChat = null;
    } else {
        selectedChat = new BaseEntity(savedInstanceState.getString(SAVED_SELECTED_ACCOUNT), savedInstanceState.getString(SAVED_SELECTED_USER));
    }
    exitOnSend = savedInstanceState.getBoolean(SAVED_EXIT_ON_SEND);
    String initialAccount = savedInstanceState.getString(SAVED_INITIAL_ACCOUNT);
    String initialUser = savedInstanceState.getString(SAVED_INITIAL_USER);
    if (initialAccount != null && initialUser != null) {
        initialChat = new BaseEntity(initialAccount, initialUser);
    }
}
Also used : BaseEntity(com.xabber.android.data.entity.BaseEntity)

Aggregations

BaseEntity (com.xabber.android.data.entity.BaseEntity)14 ArrayList (java.util.ArrayList)5 Intent (android.content.Intent)2 Cursor (android.database.Cursor)2 NestedMap (com.xabber.android.data.entity.NestedMap)2 AccountConfiguration (com.xabber.android.ui.adapter.AccountConfiguration)2 HashSet (java.util.HashSet)2 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 RoomChat (com.xabber.android.data.extension.muc.RoomChat)1 AbstractChat (com.xabber.android.data.message.AbstractChat)1 AbstractContact (com.xabber.android.data.roster.AbstractContact)1 RosterContact (com.xabber.android.data.roster.RosterContact)1 GroupConfiguration (com.xabber.android.ui.adapter.GroupConfiguration)1 ChatViewerFragment (com.xabber.android.ui.fragment.ChatViewerFragment)1 IQ (org.jivesoftware.smack.packet.IQ)1 DiscoverInfo (org.jivesoftware.smackx.disco.packet.DiscoverInfo)1