use of com.hippo.ehviewer.client.EhTagDatabase 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);
}
EhTagDatabase ehTags = Settings.getShowTagTranslations() ? EhTagDatabase.getInstance(context) : null;
int colorTag = AttrResources.getAttrColor(context, R.attr.tagBackgroundColor);
int colorName = AttrResources.getAttrColor(context, R.attr.tagGroupBackgroundColor);
for (GalleryTagGroup tg : tagGroups) {
LinearLayout ll = (LinearLayout) inflater.inflate(R.layout.gallery_tag_group, mTags, false);
ll.setOrientation(LinearLayout.HORIZONTAL);
mTags.addView(ll);
String readableTagName = null;
if (ehTags != null) {
readableTagName = ehTags.getTranslation("n:" + tg.groupName);
}
TextView tgName = (TextView) inflater.inflate(R.layout.item_gallery_tag, ll, false);
ll.addView(tgName);
tgName.setText(readableTagName != null ? readableTagName : tg.groupName);
tgName.setBackgroundDrawable(new RoundSideRectDrawable(colorName));
String prefix = EhTagDatabase.namespaceToPrefix(tg.groupName);
if (prefix == null) {
prefix = "";
}
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);
String readableTag = null;
if (ehTags != null) {
readableTag = ehTags.getTranslation(prefix + tagStr);
}
tag.setText(readableTag != null ? readableTag : tagStr);
tag.setBackgroundDrawable(new RoundSideRectDrawable(colorTag));
tag.setTag(R.id.tag, tg.groupName + ":" + tagStr);
tag.setOnClickListener(this);
tag.setOnLongClickListener(this);
}
}
}
Aggregations