光环助手V4.0.0补充需求:游戏列表优化(后台尚未完成,标签颜色暂且写死) https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/862

This commit is contained in:
kehaoyuan
2020-05-13 16:27:41 +08:00
parent 48e2831e96
commit 04864e059c
10 changed files with 63 additions and 107 deletions

View File

@ -10,6 +10,9 @@ import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
import androidx.core.content.ContextCompat;
import com.gh.common.view.DrawableView;
import com.gh.gamecenter.R;
import com.gh.gamecenter.entity.TagStyleEntity;
@ -21,8 +24,6 @@ import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
import androidx.core.content.ContextCompat;
/**
* @author 温冠超
* @email 294299195@qq.com
@ -32,21 +33,16 @@ import androidx.core.content.ContextCompat;
*/
public class GameViewUtils {
public static void setLabelList(Context context, LinearLayout labelLayout, List<String> tag, String tagType, List<TagStyleEntity> tagStyle) {
public static void setLabelList(Context context, LinearLayout labelLayout, List<TagStyleEntity> tagStyle) {
labelLayout.removeAllViews();
if (tag == null || tag.isEmpty()) {
labelLayout.addView(getGameTagView(context, "官方版", 0, tagType, null));
if (tagStyle == null || tagStyle.isEmpty()) {
TagStyleEntity tagEntity = new TagStyleEntity();
tagEntity.setName("官方版");
labelLayout.addView(getNewGameTagView(context, tagEntity, 0));
} 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, tagStyle.size() > i ? tagStyle.get(i) : null);
} else {
view = getGameTagView(context, tag.get(i), DisplayUtils.dip2px(context, 8), tagType, tagStyle.size() > i ? tagStyle.get(i) : null);
}
if (view != null) {
labelLayout.addView(view);
}
for (int i = 0, size = tagStyle.size(); i < size; i++) {
View view = getNewGameTagView(context, tagStyle.get(i), i == size - 1 ? 0 : DisplayUtils.dip2px(context, 8));
labelLayout.addView(view);
if (labelLayout.getChildCount() == 3) {
break;
}
@ -76,6 +72,28 @@ public class GameViewUtils {
}
}
// 新的游戏标签样式 version>=4.0.0
private static TextView getNewGameTagView(Context context, TagStyleEntity tagEntity, int rightMargin) {
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lparams.rightMargin = rightMargin;
TextView tag = new TextView(context);
tag.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10);
tag.setSingleLine(true);
tag.setText(tagEntity.getName());
tag.setLayoutParams(lparams);
tag.setPadding(
DisplayUtils.dip2px(context, 4),
0,
DisplayUtils.dip2px(context, 4),
DisplayUtils.dip2px(context, 1));
// todo 背景要色
tag.setTextColor(context.getResources().getColor(R.color.theme_font));
tag.setBackground(DrawableView.getOvalDrawable(R.color.text_E8F3FF, 2));
return tag;
}
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);