use of com.hyphenate.easeui.domain.EaseUser in project SmartCampus by Vegen.
the class EaseContactAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
holder = new ViewHolder();
if (res == 0)
convertView = layoutInflater.inflate(R.layout.ease_row_contact, parent, false);
else
convertView = layoutInflater.inflate(res, null);
holder.avatar = (ImageView) convertView.findViewById(R.id.avatar);
holder.nameView = (TextView) convertView.findViewById(R.id.name);
holder.headerView = (TextView) convertView.findViewById(R.id.header);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
EaseUser user = getItem(position);
if (user == null)
Log.d("ContactAdapter", position + "");
String username = user.getUsername();
String header = user.getInitialLetter();
if (position == 0 || header != null && !header.equals(getItem(position - 1).getInitialLetter())) {
if (TextUtils.isEmpty(header)) {
holder.headerView.setVisibility(View.GONE);
} else {
holder.headerView.setVisibility(View.VISIBLE);
holder.headerView.setText(header);
}
} else {
holder.headerView.setVisibility(View.GONE);
}
EaseAvatarOptions avatarOptions = EaseUI.getInstance().getAvatarOptions();
if (avatarOptions != null && holder.avatar instanceof EaseImageView) {
EaseImageView avatarView = ((EaseImageView) holder.avatar);
if (avatarOptions.getAvatarShape() != 0)
avatarView.setShapeType(avatarOptions.getAvatarShape());
if (avatarOptions.getAvatarBorderWidth() != 0)
avatarView.setBorderWidth(avatarOptions.getAvatarBorderWidth());
if (avatarOptions.getAvatarBorderColor() != 0)
avatarView.setBorderColor(avatarOptions.getAvatarBorderColor());
if (avatarOptions.getAvatarRadius() != 0)
avatarView.setRadius(avatarOptions.getAvatarRadius());
}
EaseUserUtils.setUserNick(username, holder.nameView);
EaseUserUtils.setUserAvatar(getContext(), username, holder.avatar);
if (primaryColor != 0)
holder.nameView.setTextColor(primaryColor);
if (primarySize != 0)
holder.nameView.setTextSize(TypedValue.COMPLEX_UNIT_PX, primarySize);
if (initialLetterBg != null)
holder.headerView.setBackgroundDrawable(initialLetterBg);
if (initialLetterColor != 0)
holder.headerView.setTextColor(initialLetterColor);
return convertView;
}
Aggregations