光环助手V3.3-游戏专题样式强化(补充测试完成)

This commit is contained in:
kehaoyuan
2018-06-19 14:37:33 +08:00
parent 685c38dcf7
commit 47482ba793
16 changed files with 138 additions and 53 deletions

View File

@ -12,6 +12,7 @@ import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
import com.gh.gamecenter.R;
import com.gh.gamecenter.entity.TagStyleEntity;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@ -30,17 +31,17 @@ import java.util.TimeZone;
*/
public class GameViewUtils {
public static void setLabelList(Context context, LinearLayout labelLayout, List<String> tag, String tagType) {
public static void setLabelList(Context context, LinearLayout labelLayout, List<String> tag, String tagType, List<TagStyleEntity> tagStyle) {
labelLayout.removeAllViews();
if (tag == null || tag.isEmpty()) {
labelLayout.addView(getGameTagView(context, "官方版", 0, tagType));
labelLayout.addView(getGameTagView(context, "官方版", 0, tagType, null));
} else {
for (int i = 0, size = tag.size(); i < size; i++) {
View view;
if (i == size - 1) {
view = getGameTagView(context, tag.get(i), 0, tagType);
view = getGameTagView(context, tag.get(i), 0, tagType, tagStyle.size() > i ? tagStyle.get(i) : null);
} else {
view = getGameTagView(context, tag.get(i), DisplayUtils.dip2px(context, 6), tagType);
view = getGameTagView(context, tag.get(i), DisplayUtils.dip2px(context, 6), tagType, tagStyle.size() > i ? tagStyle.get(i) : null);
}
if (view != null) {
labelLayout.addView(view);
@ -52,7 +53,7 @@ public class GameViewUtils {
}
}
private static TextView getGameTagView(Context context, String tagStr, int rightMargin, String tagType) {
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);
lparams.rightMargin = rightMargin;
@ -65,22 +66,32 @@ public class GameViewUtils {
tag.setTextColor(ContextCompat.getColor(context, R.color.tag_green));
} else {
String colorStr;
if (!TextUtils.isEmpty(tagType) && "type".equals(tagType)) { // 游戏标签
colorStr = "#ff6a28";
if (!TextUtils.isEmpty(tagType) && "type".equals(tagType) && tagEntity != null) { // 游戏标签
colorStr = "#" + tagEntity.getColor();
GradientDrawable gradientDrawable = new GradientDrawable();
if ("border".equals(tagEntity.getStyle())) {
gradientDrawable.setColor(Color.TRANSPARENT);
gradientDrawable.setStroke(DisplayUtils.dip2px(context, 0.6f), Color.parseColor(colorStr));
tag.setTextColor(Color.parseColor(colorStr));
} else {
gradientDrawable.setColor(Color.parseColor(colorStr));
gradientDrawable.setShape(GradientDrawable.RECTANGLE);
tag.setTextColor(Color.WHITE);
}
tag.setBackgroundDrawable(gradientDrawable);
} else {
colorStr = TagUtils.getInstance(context).getColor(tagStr);
if (colorStr == null) {
return null;
}
int color = Color.parseColor(colorStr);
GradientDrawable gradientDrawable = new GradientDrawable();
gradientDrawable.setColor(Color.TRANSPARENT);
gradientDrawable.setStroke(DisplayUtils.dip2px(context, 0.6f), color);
tag.setBackgroundDrawable(gradientDrawable);
tag.setTextColor(color);
}
if (colorStr == null) {
return null;
}
int color = Color.parseColor(colorStr);
GradientDrawable gradientDrawable = new GradientDrawable();
gradientDrawable.setColor(Color.TRANSPARENT);
gradientDrawable.setStroke(DisplayUtils.dip2px(context, 0.6f), color);
tag.setBackgroundDrawable(gradientDrawable);
// tag.setBackgroundResource(R.drawable.border_blue_bg);
tag.setTextColor(color);
}
tag.setLayoutParams(lparams);
tag.setPadding(DisplayUtils.dip2px(context, 3),