use of com.xabber.android.data.roster.ShowOfflineMode in project xabber-android by redsolution.
the class GroupedContactAdapter method getAccountView.
private View getAccountView(int position, View convertView, ViewGroup parent) {
final View view;
final ContactListAccountItemViewHolder viewHolder;
if (convertView == null) {
view = layoutInflater.inflate(R.layout.contact_list_account_group_item, parent, false);
viewHolder = new ContactListAccountItemViewHolder(view);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
view.setElevation(accountElevation);
}
view.setTag(viewHolder);
} else {
view = convertView;
viewHolder = (ContactListAccountItemViewHolder) view.getTag();
}
final AccountConfiguration configuration = (AccountConfiguration) getItem(position);
final String account = configuration.getAccount();
viewHolder.statusIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onClickListener.onAccountMenuClick(v, account);
}
});
final int level = AccountManager.getInstance().getColorLevel(account);
view.setBackgroundDrawable(new ColorDrawable(accountGroupColors[level]));
viewHolder.name.setText(GroupManager.getInstance().getGroupName(account, configuration.getUser()));
viewHolder.smallRightText.setText(configuration.getOnline() + "/" + configuration.getTotal());
AccountItem accountItem = AccountManager.getInstance().getAccount(account);
String statusText = accountItem.getStatusText().trim();
if (statusText.isEmpty()) {
statusText = activity.getString(accountItem.getDisplayStatusMode().getStringID());
}
viewHolder.secondLineMessage.setText(statusText);
if (SettingsManager.contactsShowAvatars()) {
viewHolder.avatar.setVisibility(View.VISIBLE);
viewHolder.avatar.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
} else {
viewHolder.avatar.setVisibility(View.GONE);
}
viewHolder.avatar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
activity.startActivity(AccountViewer.createAccountInfoIntent(activity, account));
}
});
viewHolder.statusIcon.setImageLevel(accountItem.getDisplayStatusMode().getStatusLevel());
ShowOfflineMode showOfflineMode = configuration.getShowOfflineMode();
if (showOfflineMode == ShowOfflineMode.normal) {
if (SettingsManager.contactsShowOffline()) {
showOfflineMode = ShowOfflineMode.always;
} else {
showOfflineMode = ShowOfflineMode.never;
}
}
viewHolder.smallRightIcon.setImageLevel(showOfflineMode.ordinal());
StatusMode statusMode = AccountManager.getInstance().getAccount(configuration.getAccount()).getDisplayStatusMode();
if (statusMode == StatusMode.unavailable || statusMode == StatusMode.connection) {
viewHolder.offlineShadow.setVisibility(View.VISIBLE);
} else {
viewHolder.offlineShadow.setVisibility(View.GONE);
}
return view;
}
Aggregations