Search in sources :

Example 6 with EaseUser

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;
}
Also used : EaseImageView(com.hyphenate.easeui.widget.EaseImageView) EaseUser(com.hyphenate.easeui.domain.EaseUser) EaseAvatarOptions(com.hyphenate.easeui.domain.EaseAvatarOptions)

Aggregations

EaseUser (com.hyphenate.easeui.domain.EaseUser)6 View (android.view.View)2 OnClickListener (android.view.View.OnClickListener)2 ListView (android.widget.ListView)2 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 MotionEvent (android.view.MotionEvent)1 OnTouchListener (android.view.View.OnTouchListener)1 AdapterView (android.widget.AdapterView)1 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)1 EMGroup (com.hyphenate.chat.EMGroup)1 EaseAvatarOptions (com.hyphenate.easeui.domain.EaseAvatarOptions)1 EaseImageView (com.hyphenate.easeui.widget.EaseImageView)1 EaseVoiceRecorderView (com.hyphenate.easeui.widget.EaseVoiceRecorderView)1 Entry (java.util.Map.Entry)1