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 505078fb74..30c333f3bf 100644 --- a/app/src/main/java/com/gh/common/databind/BindingAdapters.java +++ b/app/src/main/java/com/gh/common/databind/BindingAdapters.java @@ -356,13 +356,12 @@ public class BindingAdapters { break; case NORMAL: case PLUGIN: - String msg = gameEntity.getVersionNumber().equals("无版号-有内购") ? v.getContext().getString(R.string.attempt_tips_1) : - v.getContext().getString(R.string.attempt_tips_2); + String msg = gameEntity.getVersionNumberString(); if (gameEntity.getApk().size() == 1) { ApkEntity apk = gameEntity.getApk().get(0); DownloadDialogHelper.findAvailableDialogAndShow(v.getContext(), gameEntity, apk, () -> { - if (gameEntity.getVersionNumber().contains("无版号")) { + if (gameEntity.isShowVersionNumber()) { DialogUtils.showVersionNumberDialog(v.getContext(), msg, () -> { DialogUtils.checkDownload(v.getContext(), apk.getSize(), isSubscribe -> download(progressBar, gameEntity, traceEvent, isSubscribe, entrance, location)); @@ -374,7 +373,7 @@ public class BindingAdapters { }); } else { - if (gameEntity.getVersionNumber().contains("无版号")) { + if (gameEntity.isShowVersionNumber()) { DialogUtils.showVersionNumberDialog(v.getContext(), msg, () -> { DownloadDialog.getInstance(v.getContext()).showPopupWindow(v, gameEntity, entrance, location + gameEntity.getName(), traceEvent); 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 fb7e415522..c6e342ba7e 100644 --- a/app/src/main/java/com/gh/common/util/DownloadItemUtils.java +++ b/app/src/main/java/com/gh/common/util/DownloadItemUtils.java @@ -450,10 +450,8 @@ public class DownloadItemUtils { clickCallback.onCallback(); } PermissionHelper.checkStoragePermissionBeforeAction(context, () -> { - String str = downloadBtn.getText().toString(); - if (str.equals(context.getString(R.string.attempt))) { - String msg = gameEntity.getVersionNumber().equals("无版号-有内购") ? context.getString(R.string.attempt_tips_1) : - context.getString(R.string.attempt_tips_2); + if (gameEntity.isShowVersionNumber()) { + String msg = gameEntity.getVersionNumberString(); DialogUtils.showVersionNumberDialog(context, msg, () -> { DownloadDialog.getInstance(context).showPopupWindow(v, gameEntity, entrance, location, traceEvent); }); @@ -496,14 +494,18 @@ public class DownloadItemUtils { DataLogUtils.uploadGameLog(context, gameEntity.getId(), gameEntity.getName(), entrance); } else if (str.equals(context.getString(R.string.attempt))) { - String msg = gameEntity.getVersionNumber().equals("无版号-有内购") ? context.getString(R.string.attempt_tips_1) : - context.getString(R.string.attempt_tips_2); + String msg = gameEntity.getVersionNumberString(); DownloadDialogHelper.findAvailableDialogAndShow(context, gameEntity, apk, () -> { - DialogUtils.showVersionNumberDialog(context, msg, () -> { + if (gameEntity.isShowVersionNumber()) { + DialogUtils.showVersionNumberDialog(context, msg, () -> { + DialogUtils.checkDownload(context, apk.getSize(), + isSubscribe -> download(context, gameEntity, downloadBtn, entrance, location, isSubscribe, traceEvent)); + }); + } else { DialogUtils.checkDownload(context, apk.getSize(), isSubscribe -> download(context, gameEntity, downloadBtn, entrance, location, isSubscribe, traceEvent)); - }); + } }); DataLogUtils.uploadGameLog(context, gameEntity.getId(), gameEntity.getName(), entrance); diff --git a/app/src/main/java/com/gh/gamecenter/adapter/viewholder/DetailViewHolder.java b/app/src/main/java/com/gh/gamecenter/adapter/viewholder/DetailViewHolder.java index 5a636e96d1..ddbfcde836 100644 --- a/app/src/main/java/com/gh/gamecenter/adapter/viewholder/DetailViewHolder.java +++ b/app/src/main/java/com/gh/gamecenter/adapter/viewholder/DetailViewHolder.java @@ -169,15 +169,14 @@ public class DetailViewHolder { case NORMAL: DataLogUtils.uploadGameLog(mViewHolder.context, mGameEntity.getId(), mGameEntity.getName(), mEntrance); case PLUGIN: - String msg = mGameEntity.getVersionNumber().equals("无版号-有内购") ? mViewHolder.context.getString(R.string.attempt_tips_1) : - mViewHolder.context.getString(R.string.attempt_tips_2); + String msg = mGameEntity.getVersionNumberString(); PermissionHelper.checkStoragePermissionBeforeAction(mViewHolder.context, () -> { if (mGameEntity.getApk().size() == 1) { ApkEntity apk = mGameEntity.getApk().get(0); DownloadDialogHelper.findAvailableDialogAndShow(mViewHolder.context, mGameEntity, apk, () -> { - if (mGameEntity.getVersionNumber().contains("无版号")) { + if (mGameEntity.isShowVersionNumber()) { DialogUtils.showVersionNumberDialog(mViewHolder.context, msg, () -> { DialogUtils.checkDownload(mViewHolder.context, apk.getSize(), this::download); }); @@ -186,7 +185,7 @@ public class DetailViewHolder { } }); } else { - if (mGameEntity.getVersionNumber().contains("无版号")) { + if (mGameEntity.isShowVersionNumber()) { DialogUtils.showVersionNumberDialog(mViewHolder.context, msg, () -> { DownloadDialog.getInstance(mViewHolder.context).showPopupWindowAutoDownload(v, mGameEntity, diff --git a/app/src/main/java/com/gh/gamecenter/entity/GameEntity.kt b/app/src/main/java/com/gh/gamecenter/entity/GameEntity.kt index 561536d485..d4425b7201 100644 --- a/app/src/main/java/com/gh/gamecenter/entity/GameEntity.kt +++ b/app/src/main/java/com/gh/gamecenter/entity/GameEntity.kt @@ -3,8 +3,10 @@ package com.gh.gamecenter.entity import android.os.Parcelable import com.gh.common.constant.Config import com.gh.common.exposure.ExposureEvent +import com.gh.gamecenter.R import com.gh.gamecenter.game.data.GameSubjectData import com.google.gson.annotations.SerializedName +import com.halo.assistant.HaloApp import com.lightgame.download.DownloadEntity import kotlinx.android.parcel.IgnoredOnParcel import kotlinx.android.parcel.Parcelize @@ -165,7 +167,7 @@ data class GameEntity( @SerializedName("mutex_package") val mutexPackage: List? = null, @SerializedName("version_number") - val versionNumber: String = "",// 有版号、无版号-有内购、无版号-无内购 + val versionNumber: String = "",// 无版号无内购无弹窗、无版号无内购有弹窗、无版号有内购、有版号 @SerializedName("plugin_link") val pluginLink: List = arrayListOf(), @SerializedName("p_button_add_word") @@ -202,6 +204,20 @@ data class GameEntity( this.mName = name } + //是否需要弹出试玩弹窗 + fun isShowVersionNumber(): Boolean { + return versionNumber == "无版号无内购有弹窗" || versionNumber == "无版号有内购" + } + + //是获取试玩弹窗提示文案 + fun getVersionNumberString(): String { + return when (versionNumber) { + "无版号有内购" -> HaloApp.getInstance().application.getString(R.string.attempt_tips_1) + "无版号无内购有弹窗" -> HaloApp.getInstance().application.getString(R.string.attempt_tips_2) + else -> "" + } + } + fun getTag(): ArrayList { if (tag == null) tag = ArrayList() if (!Config.isShowPlugin(id)) return ArrayList()