From 9a0ffb29e09f80fcf368bc602e2819334b39f79a Mon Sep 17 00:00:00 2001 From: chenjuntao Date: Sun, 29 Sep 2019 16:09:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=9F=BA=E7=A1=80=E7=9A=84?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=B8=B8=E6=88=8F=E4=B8=8B=E8=BD=BD=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E7=9A=84=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E6=9A=82=E7=BC=BA=E8=AE=BE=E8=AE=A1=E5=9B=BE=20https://gitlab.?= =?UTF-8?q?ghzs.com/pm/halo-app-issues/issues/649?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gh/common/databind/BindingAdapters.java | 24 ++++++++++---- .../com/gh/common/util/DownloadItemUtils.java | 32 +++++++++++++------ .../adapter/viewholder/DetailViewHolder.java | 29 ++++++++++++++--- .../com/gh/gamecenter/entity/GameEntity.kt | 13 ++++++++ 4 files changed, 76 insertions(+), 22 deletions(-) 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 0903282e12..327a7230ec 100644 --- a/app/src/main/java/com/gh/common/databind/BindingAdapters.java +++ b/app/src/main/java/com/gh/common/databind/BindingAdapters.java @@ -9,10 +9,6 @@ import android.widget.EditText; import android.widget.LinearLayout; import android.widget.TextView; -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; @@ -40,8 +36,8 @@ import com.gh.gamecenter.databinding.KaifuAddItemBinding; import com.gh.gamecenter.databinding.KaifuDetailItemRowBinding; import com.gh.gamecenter.entity.ApkEntity; import com.gh.gamecenter.entity.GameEntity; -import com.gh.gamecenter.entity.ServerCalendarEntity; import com.gh.gamecenter.entity.PluginLocation; +import com.gh.gamecenter.entity.ServerCalendarEntity; import com.gh.gamecenter.eventbus.EBReuse; import com.gh.gamecenter.manager.PackagesManager; import com.lightgame.download.DownloadEntity; @@ -54,6 +50,10 @@ import java.text.SimpleDateFormat; import java.util.List; import java.util.Locale; +import androidx.core.content.ContextCompat; +import androidx.databinding.BindingAdapter; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; + /** * Created by khy on 12/02/18. */ @@ -319,8 +319,18 @@ public class BindingAdapters { } // 显示下载按钮状态 - if (gameEntity.getApk().isEmpty()) { - progressBar.setText("暂无下载"); + if (gameEntity.getApk().isEmpty() || gameEntity.getDownloadOffStatus() != null) { + String offStatus = gameEntity.getDownloadOffStatus(); + if (offStatus != null && !"off".equals(offStatus)) { + progressBar.setText("查看"); + if (offStatus.equals("dialog")) { + // TODO 设置背景为深色 + } else if (offStatus.equals("toast")) { + // TODO 设置背景为浅色 + } + } else { + progressBar.setText("暂无下载"); + } progressBar.setDownloadType(DownloadProgressBar.DownloadType.NONE); } else { String status = GameUtils.getDownloadBtnText(progressBar.getContext(), gameEntity, PluginLocation.only_game); 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 ebcbd9af51..6b17bda7b8 100644 --- a/app/src/main/java/com/gh/common/util/DownloadItemUtils.java +++ b/app/src/main/java/com/gh/common/util/DownloadItemUtils.java @@ -7,12 +7,6 @@ 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.ReserveDialogFragment; import com.gh.common.exposure.ExposureEvent; @@ -35,6 +29,12 @@ 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; + public class DownloadItemUtils { // 更新下载进度条 @@ -167,13 +167,25 @@ public class DownloadItemUtils { return; } - if (gameEntity.getApk() == null || gameEntity.getApk().isEmpty()) { + if (gameEntity.getApk().isEmpty() || gameEntity.getDownloadOffStatus() != null) { holder.gameDes.setVisibility(View.VISIBLE); holder.gameProgressbar.setVisibility(View.GONE); holder.gameInfo.setVisibility(View.GONE); - holder.gameDownloadBtn.setBackgroundResource(R.drawable.news_detail_comment); - holder.gameDownloadBtn.setText("暂无"); - holder.gameDownloadBtn.setTextColor(ContextCompat.getColor(context, R.color.button_gray)); + + String offStatus = gameEntity.getDownloadOffStatus(); + if (offStatus != null && !"off".equals(offStatus)) { + holder.gameDownloadBtn.setText("查看"); + holder.gameDownloadBtn.setTextColor(ContextCompat.getColor(context, R.color.white)); + if (offStatus.equals("dialog")) { + // TODO 设置背景为深色 + } else if (offStatus.equals("toast")) { + // TODO 设置背景为浅色 + } + } else { + holder.gameDownloadBtn.setText("暂无"); + holder.gameDownloadBtn.setTextColor(ContextCompat.getColor(context, R.color.button_gray)); + holder.gameDownloadBtn.setBackgroundResource(R.drawable.news_detail_comment); + } holder.gameDownloadBtn.setClickable(false); } else if (gameEntity.getApk().size() == 1) { updateNormalItem(context, holder, gameEntity, isShowPlatform, pluginLocation); 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 688f1fca63..0038260ddc 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 @@ -5,9 +5,6 @@ import android.content.Intent; import android.text.TextUtils; import android.view.View; -import androidx.annotation.Nullable; -import androidx.appcompat.app.AppCompatActivity; - import com.gh.common.dialog.ReserveDialogFragment; import com.gh.common.exposure.ExposureEvent; import com.gh.common.exposure.ExposureUtils; @@ -29,10 +26,17 @@ import com.gh.gamecenter.DownloadManagerActivity; import com.gh.gamecenter.R; import com.gh.gamecenter.entity.ApkEntity; import com.gh.gamecenter.entity.GameEntity; +import com.gh.gamecenter.eventbus.EBReuse; +import com.gh.gamecenter.gamedetail.GameDetailFragment; import com.lightgame.download.DownloadEntity; import com.lightgame.download.FileUtils; import com.lightgame.utils.Utils; +import org.greenrobot.eventbus.EventBus; + +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + /** * Created by khy on 27/06/17. * 详情页面下载ViewHolder @@ -140,7 +144,17 @@ public class DetailViewHolder { mViewHolder.context.startActivity(intent); break; case NONE: - Utils.toast(mViewHolder.context, "该游戏已关闭下载"); + String offStatus = mGameEntity.getDownloadOffStatus(); + if (offStatus != null && !"off".equals(offStatus)) { + if ("dialog".equals(offStatus)) { + showOffServiceDialog(); + } else if ("toast".equals(offStatus)) { + EventBus.getDefault().post(new EBReuse(GameDetailFragment.SKIP_RATING)); + Utils.toast(mViewHolder.context, "该游戏因故暂不提供下载,具体详情可在相关评论中查看,敬请谅解~"); + } + } else { + Utils.toast(mViewHolder.context, "该游戏已关闭下载"); + } break; case NORMAL: DataLogUtils.uploadGameLog(mViewHolder.context, mGameEntity.getId(), mGameEntity.getName(), mEntrance); @@ -214,7 +228,12 @@ public class DetailViewHolder { break; } } - + + private void showOffServiceDialog() { + // TODO showOffserviceDialog + Utils.toast(mViewHolder.context, "显示弹窗"); + } + private void download(boolean isSubscribe) { String str = mViewHolder.mDownloadPb.getText(); String method; 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 d439e89503..176fb489a4 100644 --- a/app/src/main/java/com/gh/gamecenter/entity/GameEntity.kt +++ b/app/src/main/java/com/gh/gamecenter/entity/GameEntity.kt @@ -55,6 +55,12 @@ data class GameEntity( @SerializedName("download_off_text") var downloadOffText: String? = null, + @SerializedName("download_off_status") + var downloadOffStatus: String? = null, // "off/dialog/toast", 只关闭、关闭且弹窗、关闭且toast + + @SerializedName("download_off_dialog") + var downloadOffDialog: Dialog? = null, + @SerializedName("libao_exists") var isLibaoExists: Boolean = false, @@ -284,6 +290,7 @@ data class GameEntity( data class Dialog(var title: String = "", var content: String = "", @SerializedName("close_button_text") + var sites: List = listOf(), var closeButtonText: String = "", @SerializedName("confirm_button") var confirmButton: LinkEntity = LinkEntity(), @@ -297,6 +304,12 @@ data class GameEntity( var models: ArrayList = arrayListOf(), @SerializedName("system_versions") var systemVersions: ArrayList = arrayListOf()) : Parcelable + + @Parcelize + data class Site( + var url: String = "", + var text: String = "" + ) : Parcelable } companion object {