Search in sources :

Example 1 with FlowLayout

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;
}
Also used : FlowLayout(com.wefika.flowlayout.FlowLayout) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) ListItem(eu.siacs.conversations.entities.ListItem) ImageView(android.widget.ImageView)

Aggregations

LayoutInflater (android.view.LayoutInflater)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 FlowLayout (com.wefika.flowlayout.FlowLayout)1 ListItem (eu.siacs.conversations.entities.ListItem)1