use of com.wefika.flowlayout.FlowLayout in project Conversations by siacs.
the class ListItemAdapter method getView.
@Override
public View getView(int position, View view, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ListItem item = getItem(position);
if (view == null) {
view = inflater.inflate(R.layout.contact, parent, false);
}
TextView tvName = (TextView) view.findViewById(R.id.contact_display_name);
TextView tvJid = (TextView) view.findViewById(R.id.contact_jid);
ImageView picture = (ImageView) view.findViewById(R.id.contact_photo);
FlowLayout tagLayout = (FlowLayout) view.findViewById(R.id.tags);
List<ListItem.Tag> tags = item.getTags(activity);
if (tags.size() == 0 || !this.showDynamicTags) {
tagLayout.setVisibility(View.GONE);
} else {
tagLayout.setVisibility(View.VISIBLE);
tagLayout.removeAllViewsInLayout();
for (ListItem.Tag tag : tags) {
TextView tv = (TextView) inflater.inflate(R.layout.list_item_tag, tagLayout, false);
tv.setText(tag.getName());
tv.setBackgroundColor(tag.getColor());
tv.setOnClickListener(this.onTagTvClick);
tagLayout.addView(tv);
}
}
final String jid = item.getDisplayJid();
if (jid != null) {
tvJid.setVisibility(View.VISIBLE);
tvJid.setText(jid);
} else {
tvJid.setVisibility(View.GONE);
}
tvName.setText(item.getDisplayName());
loadAvatar(item, picture);
return view;
}
Aggregations