Search in sources :

Example 66 with UserJid

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

the class BlockedListAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    final BlockListItemViewHolder viewHolder = (BlockListItemViewHolder) holder;
    final UserJid contact = blockedContacts.get(position);
    final AbstractContact rosterContact = RosterManager.getInstance().getBestContact(account, contact);
    if (viewHolder.avatar != null) {
        viewHolder.avatar.setImageDrawable(rosterContact.getAvatar());
    }
    viewHolder.name.setText(rosterContact.getName());
    viewHolder.name.setVisibility(View.VISIBLE);
    viewHolder.checkBox.setChecked(checkedContacts.contains(contact));
}
Also used : UserJid(com.xabber.android.data.entity.UserJid) AbstractContact(com.xabber.android.data.roster.AbstractContact)

Example 67 with UserJid

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

the class ContactListActivity 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(UserJid user, String text) {
    UserJid bareAddress = user.getBareUserJid();
    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();
    Collection<AccountJid> enabledAccounts = AccountManager.getInstance().getEnabledAccounts();
    RosterManager rosterManager = RosterManager.getInstance();
    for (AccountJid accountJid : enabledAccounts) {
        RosterContact rosterContact = rosterManager.getRosterContact(accountJid, user);
        if (rosterContact != null && rosterContact.isEnabled()) {
            entities.add(rosterContact);
        }
    }
    if (entities.size() == 1) {
        openChat(entities.get(0), text);
        return;
    }
    if (enabledAccounts.isEmpty()) {
        return;
    }
    if (enabledAccounts.size() == 1) {
        openChat(rosterManager.getBestContact(enabledAccounts.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) AccountJid(com.xabber.android.data.entity.AccountJid) BaseEntity(com.xabber.android.data.entity.BaseEntity) ArrayList(java.util.ArrayList) UserJid(com.xabber.android.data.entity.UserJid) RosterManager(com.xabber.android.data.roster.RosterManager)

Aggregations

UserJid (com.xabber.android.data.entity.UserJid)67 AccountJid (com.xabber.android.data.entity.AccountJid)43 AbstractChat (com.xabber.android.data.message.AbstractChat)15 ArrayList (java.util.ArrayList)15 Intent (android.content.Intent)9 Jid (org.jxmpp.jid.Jid)9 Presence (org.jivesoftware.smack.packet.Presence)8 XmppStringprepException (org.jxmpp.stringprep.XmppStringprepException)8 AccountItem (com.xabber.android.data.account.AccountItem)7 AbstractContact (com.xabber.android.data.roster.AbstractContact)6 Message (org.jivesoftware.smack.packet.Message)6 Resourcepart (org.jxmpp.jid.parts.Resourcepart)6 NetworkException (com.xabber.android.data.NetworkException)5 IFlexible (eu.davidea.flexibleadapter.items.IFlexible)5 SmackException (org.jivesoftware.smack.SmackException)5 Uri (android.net.Uri)4 ContactVO (com.xabber.android.presentation.ui.contactlist.viewobjects.ContactVO)4 DomainBareJid (org.jxmpp.jid.DomainBareJid)4 TextView (android.widget.TextView)3 MessageItem (com.xabber.android.data.database.messagerealm.MessageItem)3