use of com.xabber.android.data.extension.muc.Occupant in project xabber-android by redsolution.
the class OccupantListAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final View view;
if (convertView == null) {
view = activity.getLayoutInflater().inflate(R.layout.item_occupant, parent, false);
} else {
view = convertView;
}
final Occupant occupant = (Occupant) getItem(position);
final ImageView avatarView = (ImageView) view.findViewById(R.id.ivAvatar);
avatarView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent;
try {
intent = ContactActivity.createIntent(activity, account, UserJid.from(JidCreate.domainFullFrom(room.asDomainBareJid(), occupant.getNickname())));
activity.startActivity(intent);
} catch (UserJid.UserJidCreateException e) {
LogManager.exception(this, e);
}
}
});
final ImageView affilationView = (ImageView) view.findViewById(R.id.affilation);
final TextView nameView = (TextView) view.findViewById(R.id.name);
final TextView statusTextView = (TextView) view.findViewById(R.id.status);
final ImageView statusModeView = (ImageView) view.findViewById(R.id.ivStatus);
// avatar
Resourcepart nickname = occupant.getNickname();
if (nickname != null && MUCManager.getInstance().getNickname(account, room).equals(nickname)) {
avatarView.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
} else {
String nick = occupant.getJid().getResourceOrEmpty().toString();
UserJid userJid = null;
try {
userJid = UserJid.from(occupant.getJid());
avatarView.setImageDrawable(AvatarManager.getInstance().getOccupantAvatar(userJid, nick));
} catch (UserJid.UserJidCreateException e) {
LogManager.exception(this, e);
avatarView.setImageDrawable(AvatarManager.getInstance().generateDefaultAvatar(nick, nick));
}
}
affilationView.setImageLevel(occupant.getAffiliation().ordinal());
nameView.setText(occupant.getNickname());
String status;
if (occupant.getRole() == MUCRole.moderator)
status = activity.getString(R.string.muc_role_moderator);
else if (occupant.getRole() == MUCRole.participant)
status = activity.getString(R.string.muc_role_participant);
else
status = activity.getString(R.string.muc_role_visitor);
String statusText = occupant.getStatusText();
if (statusText != null && !statusText.isEmpty())
status = status + " • " + statusText;
statusTextView.setText(status);
statusModeView.setImageLevel(occupant.getStatusMode().getStatusLevel());
return view;
}
use of com.xabber.android.data.extension.muc.Occupant in project xabber-android by redsolution.
the class PresenceManager method getStatusText.
public String getStatusText(AccountJid account, UserJid bareAddress) {
final Occupant occupant = getOccupant(account, bareAddress);
if (occupant != null) {
return occupant.getStatusText();
}
final Presence presence = RosterManager.getInstance().getPresence(account, bareAddress);
if (presence == null) {
return null;
} else {
return presence.getStatus();
}
}
use of com.xabber.android.data.extension.muc.Occupant in project xabber-android by redsolution.
the class PresenceManager method getStatusText.
public String getStatusText(String account, String bareAddress) {
final Occupant occupant = getOccupant(account, bareAddress);
if (occupant != null) {
return occupant.getStatusText();
}
final Presence presence = RosterManager.getInstance().getPresence(account, bareAddress);
if (presence == null) {
return null;
} else {
return presence.getStatus();
}
}
use of com.xabber.android.data.extension.muc.Occupant in project xabber-android by redsolution.
the class PresenceManager method getOccupant.
/**
* if contact is private MUC chat
*/
@Nullable
private Occupant getOccupant(AccountJid account, UserJid user) {
EntityBareJid userEntityBareJid = user.getJid().asEntityBareJidIfPossible();
if (userEntityBareJid == null) {
return null;
}
Resourcepart resourcepart = user.getJid().getResourceOrNull();
if (resourcepart == null) {
return null;
}
if (MUCManager.getInstance().hasRoom(account, userEntityBareJid)) {
final Collection<Occupant> occupants = MUCManager.getInstance().getOccupants(account, userEntityBareJid);
for (Occupant occupant : occupants) {
if (occupant.getNickname().equals(resourcepart)) {
return occupant;
}
}
}
return null;
}
Aggregations