整理专题合并,首页游戏列表和专题列表增加游戏标签

This commit is contained in:
kehaoyuan
2017-05-28 16:10:33 +08:00
parent b7ccf66418
commit 7c78109bf2
15 changed files with 81 additions and 76 deletions

View File

@ -4,6 +4,7 @@ import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.View;
import android.widget.LinearLayout;
@ -29,17 +30,17 @@ import java.util.TimeZone;
*/
public class GameViewUtils {
public static void setLabelList(Context context, LinearLayout labelLayout, List<String> tag) {
public static void setLabelList(Context context, LinearLayout labelLayout, List<String> tag, String tagType) {
labelLayout.removeAllViews();
if (tag == null || tag.isEmpty()) {
labelLayout.addView(getGameTagView(context, "官方版", 0));
labelLayout.addView(getGameTagView(context, "官方版", 0, tagType));
} else {
for (int i = 0, size = tag.size(); i < size; i++) {
View view;
if (i == size - 1) {
view = getGameTagView(context, tag.get(i), 0);
view = getGameTagView(context, tag.get(i), 0, tagType);
} else {
view = getGameTagView(context, tag.get(i), DisplayUtils.dip2px(context, 6));
view = getGameTagView(context, tag.get(i), DisplayUtils.dip2px(context, 6), tagType);
}
if (view != null) {
labelLayout.addView(view);
@ -51,7 +52,7 @@ public class GameViewUtils {
}
}
private static TextView getGameTagView(Context context, String tagStr, int rightMargin) {
private static TextView getGameTagView(Context context, String tagStr, int rightMargin, String tagType) {
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lparams.rightMargin = rightMargin;
@ -63,7 +64,13 @@ public class GameViewUtils {
tag.setBackgroundResource(R.drawable.border_green_bg);
tag.setTextColor(ContextCompat.getColor(context, R.color.tag_green));
} else {
String colorStr = TagUtils.getInstance(context).getColor(tagStr);
String colorStr;
if (!TextUtils.isEmpty(tagType) && tagType.equals("type")) { // 游戏标签
colorStr = "#ff6a28";
} else {
colorStr = TagUtils.getInstance(context).getColor(tagStr);
}
if (colorStr == null) {
return null;
}