diff --git a/.gitmodules b/.gitmodules index 6c012ef391..5e47976cd4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "libraries/LGLibrary"] path = libraries/LGLibrary - url = git@gitlab.ghzhushou.com:android/common-library.git + url = git@gitlab.ghzs.com:android/common-library.git branch = master diff --git a/app/build.gradle b/app/build.gradle index 0d57b20a15..04a768b838 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,6 +1,5 @@ apply plugin: 'com.android.application' - -apply plugin: 'org.jetbrains.kotlin.android.extensions' +apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-android' // kotlin apply plugin: 'kotlin-kapt' diff --git a/app/src/main/java/com/gh/common/dialog/ReserveDialogFragment.kt b/app/src/main/java/com/gh/common/dialog/ReserveDialogFragment.kt new file mode 100644 index 0000000000..933d1a60a9 --- /dev/null +++ b/app/src/main/java/com/gh/common/dialog/ReserveDialogFragment.kt @@ -0,0 +1,118 @@ +package com.gh.common.dialog + +import android.annotation.SuppressLint +import android.os.Bundle +import android.text.Html +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.EditText +import android.widget.TextView +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ViewModel +import butterknife.BindView +import butterknife.ButterKnife +import butterknife.OnClick +import com.gh.common.util.observeNonNull +import com.gh.common.util.viewModelProvider +import com.gh.gamecenter.R +import com.lightgame.dialog.BaseDialogFragment +import com.lightgame.utils.Utils + +class ReserveDialogFragment : BaseDialogFragment() { + + @BindView(R.id.reserve_hint_tv) + lateinit var reserveHintTv: TextView + @BindView(R.id.reserve_content_tv) + lateinit var reserveContentTv: TextView + @BindView(R.id.reserve_completed_content_tv) + lateinit var reserveCompletedContentTv: TextView + @BindView(R.id.mobile_et) + lateinit var mobileEt: EditText + @BindView(R.id.reserve_container) + lateinit var reserveContainer: View + @BindView(R.id.reserve_completed_container) + lateinit var reserveCompletedContainer: View + + lateinit var mViewModel: ReserveViewModel + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + mViewModel = viewModelProvider() + } + + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { + return inflater.inflate(R.layout.dialog_reserve_game, null) + } + + @Suppress("DEPRECATION") + @SuppressLint("SetTextI18n") + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + ButterKnife.bind(this, view) + + val reserveContent = "游戏上线,您将免费收到短信提醒" + + reserveContentTv.text = Html.fromHtml(reserveContent) + + mViewModel.reservation.observeNonNull(this) { + if (it) { + showSuccessDialog() + } + } + dialog.setCanceledOnTouchOutside(true) + } + + private fun showSuccessDialog() { + reserveHintTv.text = "游戏预约成功" + reserveCompletedContentTv.text = Html.fromHtml("游戏上线,将通过免费短信提醒您建议你设置微信提醒,多渠道提醒,不会错过任何预约的游戏。" + + "一个帐号仅需设置一次,即可永久有效。") + + reserveContainer.visibility = View.GONE + reserveCompletedContainer.visibility = View.VISIBLE + } + + @OnClick(R.id.reserve_with_mobile_btn, + R.id.reserve_without_mobile_btn, + R.id.close_btn, + R.id.customizable_btn) + fun onClick(view: View) { + when (view.id) { + R.id.reserve_without_mobile_btn -> { + mViewModel.reserve() + } + + R.id.reserve_with_mobile_btn -> { + val mobile = mobileEt.text.toString() + if (mobile.length < 11 || !mobile.startsWith("1")) { + Utils.toast(context, "手机号格式错误,请检查并重新输入") + return + } + + mViewModel.reserve(mobile = mobile) + } + + R.id.close_btn -> { + dismiss() + } + + R.id.customizable_btn -> { + dismiss() + } + } + } +} + +class ReserveViewModel : ViewModel() { + val reservation = MutableLiveData() + + fun reserve(mobile: String = "") { + if (mobile.isNotEmpty()) { + reservation.postValue(true) + } else { + reservation.postValue(true) + } + } + +} \ No newline at end of file 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 379515b25a..06738ef428 100644 --- a/app/src/main/java/com/gh/common/util/DownloadItemUtils.java +++ b/app/src/main/java/com/gh/common/util/DownloadItemUtils.java @@ -3,15 +3,18 @@ package com.gh.common.util; import android.content.Context; import android.graphics.Color; import android.os.Message; -import androidx.annotation.Nullable; -import androidx.core.content.ContextCompat; -import androidx.collection.ArrayMap; -import androidx.recyclerview.widget.RecyclerView; 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; import com.gh.common.exposure.ExposureUtils; import com.gh.common.view.DownloadDialog; @@ -124,6 +127,17 @@ public class DownloadItemUtils { holder.gameLibaoIcon.setVisibility(View.GONE); } + // 显示预约 + if (gameEntity.getCanReserve()) { + holder.gameDes.setVisibility(View.VISIBLE); + holder.gameProgressbar.setVisibility(View.GONE); + holder.gameInfo.setVisibility(View.GONE); + holder.gameDownloadBtn.setBackgroundResource(R.drawable.button_reserve); + holder.gameDownloadBtn.setText("预约"); + holder.gameDownloadBtn.setTextColor(Color.WHITE); + return; + } + if (gameEntity.getApk() == null || gameEntity.getApk().isEmpty()) { holder.gameDes.setVisibility(View.VISIBLE); holder.gameProgressbar.setVisibility(View.GONE); @@ -297,6 +311,16 @@ public class DownloadItemUtils { final String location, final ExposureEvent traceEvent) { + if (gameEntity.getCanReserve()) { + downloadBtn.setOnClickListener(v -> { + CheckLoginUtils.checkLogin(context, entrance, () -> { + ReserveDialogFragment dialogFragment = new ReserveDialogFragment(); + dialogFragment.show(((AppCompatActivity) context).getSupportFragmentManager(), "reserve"); + }); + }); + return; + } + if (gameEntity.getApk().size() == 1) { downloadBtn.setOnClickListener(v -> onNormalClick(context, downloadBtn, gameEntity, position, adapter, entrance, location, traceEvent)); } else { 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 3f6ac21958..a4ef65b29e 100644 --- a/app/src/main/java/com/gh/gamecenter/entity/GameEntity.kt +++ b/app/src/main/java/com/gh/gamecenter/entity/GameEntity.kt @@ -1,7 +1,6 @@ package com.gh.gamecenter.entity import android.os.Parcelable -import androidx.collection.ArrayMap import com.gh.common.constant.Config import com.gh.gamecenter.game.data.GameSubjectData import com.google.gson.annotations.SerializedName @@ -20,6 +19,8 @@ data class GameEntity( var nameSuffix: String = "", var brief: String? = null, + var canReserve: Boolean = false, + private var tag: ArrayList? = null, private var apk: ArrayList? = null, @SerializedName("apk_normal") diff --git a/app/src/main/res/drawable-xhdpi/ic_reserve.png b/app/src/main/res/drawable-xhdpi/ic_reserve.png new file mode 100644 index 0000000000..66413df52f Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_reserve.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_reserved.png b/app/src/main/res/drawable-xhdpi/ic_reserved.png new file mode 100644 index 0000000000..a99740694b Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_reserved.png differ diff --git a/app/src/main/res/drawable/button_reserve.xml b/app/src/main/res/drawable/button_reserve.xml new file mode 100644 index 0000000000..83524570c3 --- /dev/null +++ b/app/src/main/res/drawable/button_reserve.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/round_grey_stroke.xml b/app/src/main/res/drawable/round_grey_stroke.xml new file mode 100644 index 0000000000..6715dacb8b --- /dev/null +++ b/app/src/main/res/drawable/round_grey_stroke.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_reserve_game.xml b/app/src/main/res/layout/dialog_reserve_game.xml new file mode 100644 index 0000000000..c3a8dff29c --- /dev/null +++ b/app/src/main/res/layout/dialog_reserve_game.xml @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle index 8dcdfe6121..9298799a35 100644 --- a/build.gradle +++ b/build.gradle @@ -3,14 +3,16 @@ apply from: 'dependencies.gradle' buildscript { + // 升级至 1.3.30+ 会找不到 @Parcelize 注解 ext.kotlin_version = '1.3.10' + repositories { google() jcenter() maven { url "https://maven.google.com" } maven { url "https://dl.bintray.com/thelasterstar/maven/" } //weiboSDK -// maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } } + dependencies { classpath "com.android.tools.build:gradle:3.4.1" @@ -32,7 +34,6 @@ allprojects { google() jcenter() maven { url "https://dl.bintray.com/thelasterstar/maven/" }//weiboSDK -// maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } maven { url 'http://maven.aliyun.com/nexus/content/repositories/releases/' } } } @@ -68,7 +69,6 @@ subprojects { } } - } } } \ No newline at end of file