Search in sources :

Example 1 with AutoWrapLayout

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);
        }
    }
}
Also used : Context(android.content.Context) GalleryTagGroup(com.hippo.ehviewer.client.data.GalleryTagGroup) RoundSideRectDrawable(com.hippo.drawable.RoundSideRectDrawable) AutoWrapLayout(com.hippo.widget.AutoWrapLayout) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) ObservedTextView(com.hippo.widget.ObservedTextView) Resources(android.content.res.Resources) SuppressLint(android.annotation.SuppressLint) LinearLayout(android.widget.LinearLayout)

Aggregations

SuppressLint (android.annotation.SuppressLint)1 Context (android.content.Context)1 Resources (android.content.res.Resources)1 LayoutInflater (android.view.LayoutInflater)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 RoundSideRectDrawable (com.hippo.drawable.RoundSideRectDrawable)1 GalleryTagGroup (com.hippo.ehviewer.client.data.GalleryTagGroup)1 AutoWrapLayout (com.hippo.widget.AutoWrapLayout)1 ObservedTextView (com.hippo.widget.ObservedTextView)1