use of com.hippo.widget.AutoWrapLayout in project EhViewer by seven332.
the class GalleryDetailScene method bindTags.
@SuppressWarnings("deprecation")
private void bindTags(GalleryTagGroup[] tagGroups) {
Context context = getContext2();
LayoutInflater inflater = getLayoutInflater2();
Resources resources = getResources2();
if (null == context || null == inflater || null == resources || null == mTags || null == mNoTags) {
return;
}
mTags.removeViews(1, mTags.getChildCount() - 1);
if (tagGroups == null || tagGroups.length == 0) {
mNoTags.setVisibility(View.VISIBLE);
return;
} else {
mNoTags.setVisibility(View.GONE);
}
int colorTag = resources.getColor(R.color.colorPrimary);
int colorName = resources.getColor(R.color.purple_a400);
for (GalleryTagGroup tg : tagGroups) {
LinearLayout ll = (LinearLayout) inflater.inflate(R.layout.gallery_tag_group, mTags, false);
ll.setOrientation(LinearLayout.HORIZONTAL);
mTags.addView(ll);
TextView tgName = (TextView) inflater.inflate(R.layout.item_gallery_tag, ll, false);
ll.addView(tgName);
tgName.setText(tg.groupName);
tgName.setBackgroundDrawable(new RoundSideRectDrawable(colorName));
AutoWrapLayout awl = new AutoWrapLayout(context);
ll.addView(awl, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
for (int j = 0, z = tg.size(); j < z; j++) {
TextView tag = (TextView) inflater.inflate(R.layout.item_gallery_tag, awl, false);
awl.addView(tag);
String tagStr = tg.getTagAt(j);
tag.setText(tagStr);
tag.setBackgroundDrawable(new RoundSideRectDrawable(colorTag));
tag.setTag(R.id.tag, tg.groupName + ":" + tagStr);
tag.setOnClickListener(this);
tag.setOnLongClickListener(this);
}
}
}
Aggregations