diff --git a/app/src/main/java/com/gh/common/databind/BindingAdapters.java b/app/src/main/java/com/gh/common/databind/BindingAdapters.java index 321525a421..17b4168814 100644 --- a/app/src/main/java/com/gh/common/databind/BindingAdapters.java +++ b/app/src/main/java/com/gh/common/databind/BindingAdapters.java @@ -13,6 +13,12 @@ import android.widget.EditText; import android.widget.LinearLayout; import android.widget.TextView; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.content.ContextCompat; +import androidx.databinding.BindingAdapter; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; + import com.facebook.drawee.view.SimpleDraweeView; import com.gh.base.OnViewClickListener; import com.gh.common.constant.Config; @@ -66,12 +72,6 @@ import java.text.SimpleDateFormat; import java.util.List; import java.util.Locale; -import androidx.annotation.Nullable; -import androidx.appcompat.app.AppCompatActivity; -import androidx.core.content.ContextCompat; -import androidx.databinding.BindingAdapter; -import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; - /** * Created by khy on 12/02/18. */ @@ -227,7 +227,7 @@ public class BindingAdapters { view.setVisibility(View.VISIBLE); } } - + /** * lazy 的 paddingTop */ @@ -633,27 +633,9 @@ public class BindingAdapters { } } - @BindingAdapter({"gameLabelList", "subjectTag"}) - public static void setGameLabelList(LinearLayout layout, GameEntity gameEntity, String subjectTag) { - if (gameEntity == null) return; - if (gameEntity.getTest() != null) { - layout.removeAllViews(); - View testView = LayoutInflater.from(layout.getContext()).inflate(R.layout.game_test_label, null); - TextView testType = testView.findViewById(R.id.test_type); - TextView testTime = testView.findViewById(R.id.test_time); - testType.setText(gameEntity.getTest().getType()); - testType.setBackgroundColor(ContextCompat.getColor(layout.getContext(), R.color.tag_yellow)); - - if (gameEntity.getTest().getStart() == 0) { - testTime.setVisibility(View.GONE); - } else { - testTime.setText(GameViewUtils.getGameTestDate(gameEntity.getTest().getStart())); - } - layout.addView(testView); - } else { - GameViewUtils.setLabelList(layout.getContext(), layout, gameEntity.getTag(), subjectTag, gameEntity.getTagStyle()); - } - + @BindingAdapter("gameLabelList") + public static void setGameLabelList(LinearLayout layout, List tagStyle) { + GameViewUtils.setLabelList(layout.getContext(), layout, tagStyle); } @BindingAdapter("isRefreshing") diff --git a/app/src/main/java/com/gh/common/util/DownloadItemUtils.java b/app/src/main/java/com/gh/common/util/DownloadItemUtils.java index 08893ab6d6..19be73c0af 100644 --- a/app/src/main/java/com/gh/common/util/DownloadItemUtils.java +++ b/app/src/main/java/com/gh/common/util/DownloadItemUtils.java @@ -8,6 +8,12 @@ import android.text.TextUtils; import android.view.View; import android.widget.TextView; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.collection.ArrayMap; +import androidx.core.content.ContextCompat; +import androidx.recyclerview.widget.RecyclerView; + import com.gh.common.constant.Config; import com.gh.common.dialog.CertificationDialog; import com.gh.common.dialog.DeviceRemindDialog; @@ -34,12 +40,6 @@ import com.lightgame.utils.Utils; import java.util.concurrent.LinkedBlockingQueue; -import androidx.annotation.Nullable; -import androidx.appcompat.app.AppCompatActivity; -import androidx.collection.ArrayMap; -import androidx.core.content.ContextCompat; -import androidx.recyclerview.widget.RecyclerView; - /** * todo 下载判断不能以按钮文案为判断条件,否则按钮文案修改时又要修改判断逻辑 */ @@ -130,11 +130,6 @@ public class DownloadItemUtils { holder.gameDownloadBtn.setTextColor(Color.WHITE); holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_pause_dn); } - if (gameEntity.isLibaoExists()) { - holder.gameLibaoIcon.setVisibility(View.VISIBLE); - } else { - holder.gameLibaoIcon.setVisibility(View.GONE); - } } public static void updateItem(Context context, GameEntity gameEntity, GameViewHolder holder, @@ -157,12 +152,6 @@ public class DownloadItemUtils { holder.gameDownloadBtn.setVisibility(View.VISIBLE); } - if (gameEntity.isLibaoExists()) { - holder.gameLibaoIcon.setVisibility(View.VISIBLE); - } else { - holder.gameLibaoIcon.setVisibility(View.GONE); - } - // 显示预约 if (gameEntity.isReservable()) { holder.gameDes.setVisibility(View.VISIBLE); diff --git a/app/src/main/java/com/gh/common/util/GameViewUtils.java b/app/src/main/java/com/gh/common/util/GameViewUtils.java index 6282b22160..9d827d533b 100644 --- a/app/src/main/java/com/gh/common/util/GameViewUtils.java +++ b/app/src/main/java/com/gh/common/util/GameViewUtils.java @@ -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 tag, String tagType, List tagStyle) { + public static void setLabelList(Context context, LinearLayout labelLayout, List 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); diff --git a/app/src/main/java/com/gh/gamecenter/history/HistoryGameListAdapter.kt b/app/src/main/java/com/gh/gamecenter/history/HistoryGameListAdapter.kt index aa8e129038..1f31035f0a 100644 --- a/app/src/main/java/com/gh/gamecenter/history/HistoryGameListAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/history/HistoryGameListAdapter.kt @@ -54,7 +54,6 @@ class HistoryGameListAdapter(context: Context, private val mViewModel: HistoryGa holder.initServerType(gameEntity) holder.binding.subjectTag = "type" holder.binding.executePendingBindings() - holder.binding.gameLibaoIcon.visibleIf(gameEntity.isLibaoExists) holder.itemView.setOnClickListener { GameDetailActivity.startGameDetailActivity(mContext, gameEntity.id, "(浏览记录:游戏)") diff --git a/app/src/main/res/layout/game_attach_item.xml b/app/src/main/res/layout/game_attach_item.xml index 476ac97982..6dbfe434eb 100644 --- a/app/src/main/res/layout/game_attach_item.xml +++ b/app/src/main/res/layout/game_attach_item.xml @@ -34,18 +34,6 @@ app:layout_constraintTop_toTopOf="parent" app:roundedCornerRadius="5dp" /> - - - - + android:layout_height="28dp"> + android:textSize="10sp" /> @@ -178,12 +178,12 @@ + android:orientation="horizontal" + android:visibility="visible" /> diff --git a/app/src/main/res/layout/home_game_item.xml b/app/src/main/res/layout/home_game_item.xml index 81d994557b..c8a1191ee7 100644 --- a/app/src/main/res/layout/home_game_item.xml +++ b/app/src/main/res/layout/home_game_item.xml @@ -45,18 +45,6 @@ app:layout_constraintTop_toTopOf="parent" app:roundedCornerRadius="5dp" /> - - - + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 488bbeb8e6..b6c1a324dd 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -170,4 +170,5 @@ #2A85FB #F3F3F3 #3CB9FF + #E8F3FF \ No newline at end of file