package com.fanxin.easeui.adapter; import java.util.List; import android.content.Context; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ImageView; import com.bumptech.glide.Glide; import com.fanxin.easeui.domain.EaseEmojicon; import com.fanxin.easeui.utils.EaseSmileUtils; import com.hyphenate.easeui.R; public class EmojiconGridAdapter extends ArrayAdapter<EaseEmojicon>{ private EaseEmojicon.Type emojiconType; public EmojiconGridAdapter(Context context, int textViewResourceId, List<EaseEmojicon> objects, EaseEmojicon.Type emojiconType) { super(context, textViewResourceId, objects); this.emojiconType = emojiconType; } @Override public View getView(int position, View convertView, ViewGroup parent) { if(convertView == null){ if(emojiconType == EaseEmojicon.Type.BIG_EXPRESSION){ convertView = View.inflate(getContext(), R.layout.ease_row_big_expression, null); }else{ convertView = View.inflate(getContext(), R.layout.ease_row_expression, null); } } ImageView imageView = (ImageView) convertView.findViewById(R.id.iv_expression); EaseEmojicon emojicon = getItem(position); //if you want show a name for the icons, you can set text to R.id.tv_name if(EaseSmileUtils.DELETE_KEY.equals(emojicon.getEmojiText())){ imageView.setImageResource(R.drawable.ease_delete_expression); }else{ if(emojicon.getIcon() != 0){ imageView.setImageResource(emojicon.getIcon()); }else if(emojicon.getIconPath() != null){ Glide.with(getContext()).load(emojicon.getIconPath()).placeholder(R.drawable.ease_default_expression).into(imageView); } } return convertView; } }