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