This commit is contained in:
juntao
2021-06-03 16:38:12 +08:00
parent 28fb45f0b8
commit a0b8caa60a
18 changed files with 176 additions and 56 deletions

View File

@ -138,7 +138,7 @@ public class DownloadItemUtils {
holder.gameDownloadBtn.setText("已预约");
holder.gameDownloadBtn.setTextColor(ContextCompat.getColor(holder.gameDes.getContext(), R.color.aaaaaa));
holder.gameDownloadBtn.setBackgroundResource(R.drawable.button_round_f5f5f5);
updateItemViewStatus(holder, false, null);
updateItemViewStatus(holder, false, null, null);
}
}
@ -171,7 +171,7 @@ public class DownloadItemUtils {
// 显示预约
if (gameEntity.isReservable()) {
updateItemViewStatus(holder, false, briefStyle);
updateItemViewStatus(holder, false, briefStyle, gameEntity.getColumnRecommend());
if (!ReservationRepository.thisGameHasBeenReserved(gameEntity.getId())) {
holder.gameDownloadBtn.setText("预约");
holder.gameDownloadBtn.setTextColor(Color.WHITE);
@ -189,7 +189,7 @@ public class DownloadItemUtils {
LinkEntity h5LinkEntity = gameEntity.getH5Link();
String offStatus = gameEntity.getDownloadOffStatus();
updateItemViewStatus(holder, false, briefStyle);
updateItemViewStatus(holder, false, briefStyle, gameEntity.getColumnRecommend());
if (h5LinkEntity != null) {
if ("play".equals(h5LinkEntity.getType())) {
@ -252,7 +252,7 @@ public class DownloadItemUtils {
GameUtils.setDownloadBtnStatus(context, gameEntity, holder.gameDownloadBtn, pluginLocation);
updateItemViewStatus(holder, false, briefStyle);
updateItemViewStatus(holder, false, briefStyle, gameEntity.getColumnRecommend());
}
// 更新插件的条目有多个apk包
@ -276,14 +276,14 @@ public class DownloadItemUtils {
return;
}
}
updateItemViewStatus(holder, false, briefStyle);
updateItemViewStatus(holder, false, briefStyle, gameEntity.getColumnRecommend());
}
// 更改进度条和提示文本的状态
public static void changeStatus(Context context, GameViewHolder holder, DownloadEntity downloadEntity,
boolean isShowPlatform, boolean isNormal) {
updateItemViewStatus(holder, true, null);
updateItemViewStatus(holder, true, null, null);
holder.gameProgressbar.setProgressDrawable(context.getResources().getDrawable(R.drawable.progressbar_bg_style));
String platform = PlatformUtils.getInstance(context).getPlatformName(downloadEntity.getPlatform());
@ -377,22 +377,53 @@ public class DownloadItemUtils {
}
}
private static void updateItemViewStatus(GameViewHolder holder, boolean hasDownload, @Nullable String briefStyle) {
private static void updateItemViewStatus(GameViewHolder holder,
boolean hasDownload,
@Nullable String briefStyle,
@Nullable LinkEntity recommendStyle) {
if (hasDownload) {
if (holder.gameRating != null) holder.gameRating.setVisibility(View.GONE);
holder.gameDes.setVisibility(View.GONE);
holder.gameProgressbar.setVisibility(View.VISIBLE);
holder.gameInfo.setVisibility(View.VISIBLE);
holder.recommendContainer.setVisibility(View.GONE);
} else {
holder.gameProgressbar.setVisibility(View.GONE);
holder.gameInfo.setVisibility(View.GONE);
// 推荐优先,有推荐内容时不执行下面的 star 和 brief 代码块
if (briefStyle != null
&& recommendStyle != null
&& briefStyle.contains("recommend")) {
holder.recommendContainer.setVisibility(View.VISIBLE);
if (holder.gameRating != null) holder.gameRating.setVisibility(View.GONE);
holder.gameDes.setVisibility(View.GONE);
holder.recommendTv.setText(recommendStyle.getText());
if ("none".equals(recommendStyle.getType())) {
holder.recommendIv.setVisibility(View.GONE);
} else {
Context context = holder.recommendContainer.getContext();
int drawableId = context.getResources().getIdentifier(
"ic_recommend_" + recommendStyle.getType(),
"drawable",
context.getPackageName());
holder.recommendIv.setVisibility(View.VISIBLE);
holder.recommendIv.setImageResource(drawableId);
}
return;
} else {
holder.recommendContainer.setVisibility(View.GONE);
}
if (briefStyle != null && briefStyle.contains("star")) {
if (holder.gameRating != null) holder.gameRating.setVisibility(View.VISIBLE);
} else {
if (holder.gameRating != null) holder.gameRating.setVisibility(View.GONE);
}
if (TextUtils.isEmpty(briefStyle) || briefStyle.contains("brief")) {
// 缺省情况下回落到游戏简介
if (TextUtils.isEmpty(briefStyle) || briefStyle.contains("brief") || briefStyle.contains("recommend")) {
holder.gameDes.setVisibility(View.VISIBLE);
} else {
holder.gameDes.setVisibility(View.GONE);