This commit is contained in:
张玉久
2019-12-26 11:27:20 +08:00
parent 4243f37126
commit 1694603cd0
6 changed files with 96 additions and 42 deletions

View File

@ -3,7 +3,6 @@ package com.gh.common.util;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import androidx.core.content.ContextCompat;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.View;
@ -22,6 +21,8 @@ import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
import androidx.core.content.ContextCompat;
/**
* @author 温冠超
* @email 294299195@qq.com
@ -53,6 +54,28 @@ public class GameViewUtils {
}
}
public static void setLabelList(Context context, LinearLayout labelLayout, String tagType, List<TagStyleEntity> tagStyle) {
labelLayout.removeAllViews();
if (tagStyle == null || tagStyle.isEmpty()) {
labelLayout.addView(getGameTagView(context, "官方版", 0, tagType, null));
} else {
for (int i = 0; i < tagStyle.size() - 1; i++) {
View view;
if (i == tagStyle.size() - 1) {
view = getGameTagView(context, tagStyle.get(i).getName(), 0, tagType, tagStyle.size() > i ? tagStyle.get(i) : null);
} else {
view = getGameTagView(context, tagStyle.get(i).getName(), DisplayUtils.dip2px(context, 8), tagType, tagStyle.size() > i ? tagStyle.get(i) : null);
}
if (view != null) {
labelLayout.addView(view);
}
if (labelLayout.getChildCount() == 3) {
break;
}
}
}
}
private static TextView getGameTagView(Context context, String tagStr, int rightMargin, String tagType, TagStyleEntity tagEntity) {
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);