diff --git a/app/src/main/java/com/gh/common/util/DataUtils.java b/app/src/main/java/com/gh/common/util/DataUtils.java index 4cf03cda43..550cc4e8b1 100644 --- a/app/src/main/java/com/gh/common/util/DataUtils.java +++ b/app/src/main/java/com/gh/common/util/DataUtils.java @@ -2,17 +2,14 @@ package com.gh.common.util; import android.annotation.SuppressLint; import android.app.Application; -import android.content.ContentResolver; import android.content.ContentValues; import android.content.Context; import android.net.Uri; -import android.os.Build; import android.preference.PreferenceManager; import android.text.TextUtils; import android.util.Log; import com.gh.base.GlobalActivityManager; - import com.gh.gamecenter.BuildConfig; import com.gh.gamecenter.common.base.activity.BaseActivity; import com.gh.gamecenter.common.constant.Constants; @@ -126,6 +123,16 @@ public class DataUtils { // 避免初始化顺序问题导致 MetaUtil 一直持有空的 gid MetaUtil.INSTANCE.refreshMeta(); + + ContentValues values = new ContentValues(); + values.put(GhContentProvider.KEY_GID, gid); + values.put(GhContentProvider.KEY_ANDROID_ID, MetaUtil.getBase64EncodedAndroidId()); + try { + HaloApp.getInstance().getContentResolver().insert(Uri.parse("content://com.gh.gamecenter.provider/device"), values); + } catch (Exception exception) { + SentryHelper.INSTANCE.onEvent("DEVICE_INSERT_ERROR", "exception_digest", exception.getLocalizedMessage()); + exception.printStackTrace(); + } } @Override diff --git a/app/src/main/java/com/gh/common/util/DownloadItemUtils.kt b/app/src/main/java/com/gh/common/util/DownloadItemUtils.kt index 449c4747de..71ba98de45 100644 --- a/app/src/main/java/com/gh/common/util/DownloadItemUtils.kt +++ b/app/src/main/java/com/gh/common/util/DownloadItemUtils.kt @@ -119,7 +119,7 @@ object DownloadItemUtils { fun updateItemWithReserveStatus(holder: GameViewHolder, gameEntity: GameEntity) { if ("download" == gameEntity.reserveStatus) { // 已上线 - updateItem(holder.gameDes.context, gameEntity, holder, false) + updateItem(holder.gameDownloadBtn.context, gameEntity, holder, false) } else if ("appointment" == gameEntity.reserveStatus) { // 已预约 holder.gameDownloadBtn.text = "已预约" @@ -337,20 +337,24 @@ object DownloadItemUtils { ) { val entryMap: ArrayMap = gameEntity.getEntryMap() val apkEntity = gameEntity.getApk()[0] + var downloadEntity: DownloadEntity? = null if (entryMap.isNotEmpty()) { - val downloadEntity = entryMap[apkEntity.getPlatform()] - if (downloadEntity != null) { - if (downloadEntity.isSimulatorGame()) { - if (downloadEntity.status != DownloadStatus.done) { - // 更改进度条和提示文本的状态 - changeStatus(context, holder, downloadEntity) - return - } - } else { + downloadEntity = entryMap[apkEntity.getPlatform()] + } + if (downloadEntity == null) { + downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity) + } + if (downloadEntity != null) { + if (downloadEntity.isSimulatorGame()) { + if (downloadEntity.status != DownloadStatus.done) { // 更改进度条和提示文本的状态 changeStatus(context, holder, downloadEntity) return } + } else { + // 更改进度条和提示文本的状态 + changeStatus(context, holder, downloadEntity) + return } } updateItemViewStatus(holder, briefStyle, gameEntity.columnRecommend, isShowRecommendStar) @@ -365,18 +369,22 @@ object DownloadItemUtils { isShowRecommendStar: Boolean = false ) { val entryMap = gameEntity.getEntryMap() + var downloadEntity: DownloadEntity? = null if (entryMap.isNotEmpty()) { val queue = DownloadManager.getInstance().getQueue(gameEntity.name) - val downloadEntity = if (queue != null && !queue.isEmpty()) { + downloadEntity = if (queue != null && !queue.isEmpty()) { entryMap[queue.peek()] } else { entryMap[entryMap.keyAt(0)] } - if (downloadEntity != null) { - // 更改进度条和提示文本的状态 - changeStatus(context, holder, downloadEntity, gameEntity.getApk().size > 1) - return - } + } + if (downloadEntity == null) { + downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity) + } + if (downloadEntity != null) { + // 更改进度条和提示文本的状态 + changeStatus(context, holder, downloadEntity, gameEntity.getApk().size > 1) + return } updateItemViewStatus(holder, briefStyle, gameEntity.columnRecommend, isShowRecommendStar) } @@ -463,7 +471,7 @@ object DownloadItemUtils { if (isShowRecommendStar && holder.recommendStarInfo != null) { holder.recommendStarInfo!!.visibility = View.VISIBLE if (holder.gameRating != null) holder.gameRating!!.visibility = View.GONE - holder.gameDes.visibility = View.GONE + holder.gameDes?.visibility = View.GONE return } @@ -473,13 +481,13 @@ object DownloadItemUtils { holder.recommendContainer!!.visibility = View.VISIBLE } if (holder.gameRating != null) holder.gameRating!!.visibility = View.GONE - holder.gameDes.visibility = View.GONE - holder.recommendTv.text = recommendStyle.text + holder.gameDes?.visibility = View.GONE + holder.recommendTv?.text = recommendStyle.text if (TextUtils.isEmpty(recommendStyle.icon)) { - holder.recommendIv.visibility = View.GONE + holder.recommendIv?.visibility = View.GONE holder.recommendContainer?.setPadding(6F.dip2px(), 0, 8F.dip2px(), 0) } else { - holder.recommendIv.visibility = View.VISIBLE + holder.recommendIv?.visibility = View.VISIBLE ImageUtils.display(holder.recommendIv, recommendStyle.icon) } return @@ -496,9 +504,9 @@ object DownloadItemUtils { // 缺省情况下回落到游戏简介 if (TextUtils.isEmpty(briefStyle) || briefStyle!!.contains("brief") || briefStyle.contains("recommend")) { - holder.gameDes.visibility = View.VISIBLE + holder.gameDes?.visibility = View.VISIBLE } else { - holder.gameDes.visibility = View.GONE + holder.gameDes?.visibility = View.GONE } } diff --git a/app/src/main/java/com/gh/common/util/GameUtils.java b/app/src/main/java/com/gh/common/util/GameUtils.java index b0cabd3b66..3906766d87 100644 --- a/app/src/main/java/com/gh/common/util/GameUtils.java +++ b/app/src/main/java/com/gh/common/util/GameUtils.java @@ -180,7 +180,17 @@ public class GameUtils { if (gameEntity.isVGame()) { return context.getString(R.string.smooth); } else { - return context.getString(R.string.download); + if ("smooth".equals(gameEntity.getDownloadStatus())) { + GameEntity.GameCategory gameCategory = gameEntity.getGameCategory(); + if (gameCategory.equals(GameEntity.GameCategory.ONLINE_GAME) + || gameCategory.equals(GameEntity.GameCategory.INTERNATIONAL_ONLINE_GAME)) { + return context.getString(R.string.download); + } else { + return context.getString(R.string.attempt); + } + } else { + return context.getString(R.string.download); + } } } } diff --git a/app/src/main/java/com/gh/common/util/NewFlatLogUtils.kt b/app/src/main/java/com/gh/common/util/NewFlatLogUtils.kt index 5061cfa973..9db826b3ed 100644 --- a/app/src/main/java/com/gh/common/util/NewFlatLogUtils.kt +++ b/app/src/main/java/com/gh/common/util/NewFlatLogUtils.kt @@ -1330,4 +1330,32 @@ object NewFlatLogUtils { } log(json) } + + //用户通过活动页的“立即投稿/添加”成功创建游戏单时上报 + fun logActivityGameListCreateSuccessV2( + entrance: String, + gameId: String, + gameName: String, + gameCollectId: String, + gameCollectTitle: String, + activityId: String, + activityName: String, + ) { + val json = json { + "event" to "activity_game_list_create_success_v2" + "entrance" to entrance + if (gameId.isNotEmpty()) { + "game_id" to gameId + } + if (gameName.isNotEmpty()) { + "game_name" to gameName + } + "game_collect_id" to gameCollectId + "game_collect_title" to gameCollectTitle + "activity_id" to activityId + "activity_name" to activityName + parseAndPutMeta().invoke(this) + } + log(json, "event", false) + } } \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/adapter/ImagePagerAdapter.java b/app/src/main/java/com/gh/gamecenter/adapter/ImagePagerAdapter.java index 5d7e64de63..ee120c84af 100644 --- a/app/src/main/java/com/gh/gamecenter/adapter/ImagePagerAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/adapter/ImagePagerAdapter.java @@ -18,6 +18,11 @@ import com.gh.gamecenter.feature.exposure.ExposureSource; import com.gh.gamecenter.feature.exposure.ExposureType; import com.gh.gamecenter.common.utils.DataLogUtils; import com.gh.common.util.DirectUtils; +import com.gh.gamecenter.MainActivity; +import com.gh.gamecenter.R; +import com.gh.gamecenter.common.entity.ExposureEntity; +import com.gh.gamecenter.common.entity.LinkEntity; +import com.gh.gamecenter.common.utils.DataLogUtils; import com.gh.gamecenter.common.utils.ImageUtils; import com.gh.gamecenter.core.utils.MtaHelper; import com.gh.gamecenter.core.utils.PageSwitchDataHelper; @@ -79,7 +84,7 @@ public class ImagePagerAdapter extends RecyclingPagerAdapter { @Override public View getView(final int position, View view, ViewGroup container) { if (view == null) { - view = new SimpleDraweeView(mContext); + view = View.inflate(mContext, R.layout.game_slide_list_item, null); } int index = getPosition(position); @@ -87,7 +92,15 @@ public class ImagePagerAdapter extends RecyclingPagerAdapter { final LinkEntity slideEntity = mSlideEntityList.get(index); - ImageUtils.display(mContext.getResources(), (SimpleDraweeView) view, slideEntity.getImage(), R.drawable.preload); + SimpleDraweeView slideImage = (SimpleDraweeView) view.findViewById(R.id.slideImage); + ImageUtils.display(slideImage, slideEntity.getImage()); + + View playIv = view.findViewById(R.id.playIv); + if ("video".equals(slideEntity.getType())) { + playIv.setVisibility(View.VISIBLE); + } else { + playIv.setVisibility(View.GONE); + } ExposureEvent exposureEvent = null; if ("game".equals(slideEntity.getType())) { diff --git a/app/src/main/java/com/gh/gamecenter/forum/search/UserSearchListAdapter.kt b/app/src/main/java/com/gh/gamecenter/forum/search/UserSearchListAdapter.kt index 39b23906da..c12a465e1b 100644 --- a/app/src/main/java/com/gh/gamecenter/forum/search/UserSearchListAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/forum/search/UserSearchListAdapter.kt @@ -4,18 +4,17 @@ import android.content.Context import android.view.ViewGroup import androidx.core.content.ContextCompat import androidx.recyclerview.widget.RecyclerView -import com.gh.gamecenter.common.base.BaseRecyclerViewHolder -import com.gh.gamecenter.common.constant.ItemViewType -import com.gh.common.util.* +import com.gh.common.util.CheckLoginUtils +import com.gh.common.util.DialogUtils +import com.gh.common.util.DirectUtils +import com.gh.common.util.NewLogUtils import com.gh.gamecenter.R -import com.gh.gamecenter.common.viewholder.FooterViewHolder +import com.gh.gamecenter.common.base.BaseRecyclerViewHolder import com.gh.gamecenter.common.baselist.ListAdapter import com.gh.gamecenter.common.callback.ConfirmListener -import com.gh.gamecenter.common.utils.goneIf -import com.gh.gamecenter.common.utils.toBinding -import com.gh.gamecenter.common.utils.toColor -import com.gh.gamecenter.common.utils.toDrawable -import com.gh.gamecenter.common.utils.ImageUtils +import com.gh.gamecenter.common.constant.ItemViewType +import com.gh.gamecenter.common.utils.* +import com.gh.gamecenter.common.viewholder.FooterViewHolder import com.gh.gamecenter.core.utils.MtaHelper import com.gh.gamecenter.databinding.UserSearchListItemBinding import com.gh.gamecenter.entity.FollowersOrFansEntity @@ -63,7 +62,9 @@ class UserSearchListAdapter(context: Context, val mEntrance: String, val mViewMo val binding = (holder as UserSearchListViewHolder).binding val entity = mEntityList[position] ImageUtils.display(binding.userAvatar, entity.icon) - ImageUtils.display(binding.userBadge, entity.auth.icon) + binding.userBadge.goneIf(entity.auth.icon.isEmpty()) { + ImageUtils.display(binding.userBadge, entity.auth.icon) + } binding.userNameTv.text = entity.name ImageUtils.display(binding.userBadgeIcon, entity.badge?.icon) binding.userBadgeIcon.goneIf(entity.badge == null) diff --git a/app/src/main/java/com/gh/gamecenter/game/horizontal/GameHorizontalAdapter.kt b/app/src/main/java/com/gh/gamecenter/game/horizontal/GameHorizontalAdapter.kt index 7a246a63ce..2aa080fe88 100644 --- a/app/src/main/java/com/gh/gamecenter/game/horizontal/GameHorizontalAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/game/horizontal/GameHorizontalAdapter.kt @@ -9,6 +9,7 @@ import com.gh.common.util.DownloadItemUtils import com.gh.common.util.NewLogUtils import com.gh.gamecenter.GameDetailActivity import com.gh.gamecenter.R +import com.gh.gamecenter.adapter.viewholder.GameViewHolder import com.gh.gamecenter.common.utils.dip2px import com.gh.gamecenter.common.utils.goneIf import com.gh.gamecenter.common.utils.toBinding @@ -127,7 +128,16 @@ class GameHorizontalAdapter( if (position < (exposureEventList?.size ?: 0)) exposureEventList!![position] else null ) - DownloadItemUtils.updateDownloadButton(mContext, holder.binding.simpleGameContainer.downloadBtn, gameEntity) + DownloadItemUtils.updateItem( + mContext, + gameEntity, + GameViewHolder(holder.binding.simpleGameContainer.root).apply { + gameDownloadBtn = holder.binding.simpleGameContainer.downloadBtn + gameDownloadTips = holder.binding.simpleGameContainer.downloadTipsLottie + multiVersionDownloadTv = holder.binding.simpleGameContainer.multiVersionDownloadTv + }, + true + ) } } diff --git a/app/src/main/java/com/gh/gamecenter/game/horizontal/GameHorizontalSlideAdapter.kt b/app/src/main/java/com/gh/gamecenter/game/horizontal/GameHorizontalSlideAdapter.kt index f8c5d91bca..97753072b1 100644 --- a/app/src/main/java/com/gh/gamecenter/game/horizontal/GameHorizontalSlideAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/game/horizontal/GameHorizontalSlideAdapter.kt @@ -6,6 +6,7 @@ import com.gh.gamecenter.feature.exposure.ExposureEvent import com.gh.common.util.DownloadItemUtils import com.gh.gamecenter.GameDetailActivity import com.gh.gamecenter.R +import com.gh.gamecenter.adapter.viewholder.GameViewHolder import com.gh.gamecenter.common.utils.* import com.gh.gamecenter.core.utils.* import com.gh.gamecenter.databinding.GameHorizontalItemBinding @@ -94,10 +95,15 @@ class GameHorizontalSlideAdapter( if (position < (exposureEventList?.size ?: 0)) exposureEventList!![position] else null ) - DownloadItemUtils.updateDownloadButton( + DownloadItemUtils.updateItem( mContext, - holder.binding.simpleGameContainer.downloadBtn, - gameEntity + gameEntity, + GameViewHolder(holder.binding.simpleGameContainer.root).apply { + gameDownloadBtn = holder.binding.simpleGameContainer.downloadBtn + gameDownloadTips = holder.binding.simpleGameContainer.downloadTipsLottie + multiVersionDownloadTv = holder.binding.simpleGameContainer.multiVersionDownloadTv + }, + true ) } } diff --git a/app/src/main/java/com/gh/gamecenter/game/rank/RankAdapter.kt b/app/src/main/java/com/gh/gamecenter/game/rank/RankAdapter.kt index 761236906e..75e43f2aea 100644 --- a/app/src/main/java/com/gh/gamecenter/game/rank/RankAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/game/rank/RankAdapter.kt @@ -13,6 +13,7 @@ import com.gh.gamecenter.feature.exposure.ExposureEvent import com.gh.common.util.* import com.gh.gamecenter.GameDetailActivity import com.gh.gamecenter.R +import com.gh.gamecenter.adapter.viewholder.GameViewHolder import com.gh.gamecenter.common.utils.* import com.gh.gamecenter.databinding.RankGameItemBinding import com.gh.gamecenter.feature.entity.GameEntity @@ -185,7 +186,11 @@ class RankAdapter( exposureEvent ) - DownloadItemUtils.updateDownloadButton(mContext, downloadBtn, gameEntity, false) + DownloadItemUtils.updateItem(mContext, gameEntity, GameViewHolder(root).also { + it.gameDownloadBtn = downloadBtn + it.gameDownloadTips = downloadTipsLottie + it.multiVersionDownloadTv = multiVersionDownloadTv + }, true) } } diff --git a/app/src/main/java/com/gh/gamecenter/game/rank/RankGameItem.kt b/app/src/main/java/com/gh/gamecenter/game/rank/RankGameItem.kt index cb7962be74..e1f5ef4b2b 100644 --- a/app/src/main/java/com/gh/gamecenter/game/rank/RankGameItem.kt +++ b/app/src/main/java/com/gh/gamecenter/game/rank/RankGameItem.kt @@ -12,6 +12,7 @@ import com.gh.gamecenter.feature.exposure.ExposureEvent import com.gh.common.util.* import com.gh.gamecenter.GameDetailActivity import com.gh.gamecenter.R +import com.gh.gamecenter.adapter.viewholder.GameViewHolder import com.gh.gamecenter.common.utils.* import com.gh.gamecenter.core.utils.* import com.gh.gamecenter.feature.entity.GameEntity @@ -62,18 +63,21 @@ class RankGameItem(val rankItemUi: RankGameItemUi) { clickCallback = null, refreshCallback = object : EmptyCallback { override fun onCallback() { - DownloadItemUtils.updateDownloadButton( - root.context, - downloadTv, - gameEntity, - false - ) + DownloadItemUtils.updateItem(root.context, gameEntity, GameViewHolder(root).also { + it.gameDownloadBtn = downloadTv + it.gameDownloadTips = downloadTipsLottie + it.multiVersionDownloadTv = multiVersionDownloadTv + }, true) } }, allStateClickCallback = null ) - DownloadItemUtils.updateDownloadButton(root.context, downloadTv, gameEntity, false) + DownloadItemUtils.updateItem(root.context, gameEntity, GameViewHolder(root).also { + it.gameDownloadBtn = downloadTv + it.gameDownloadTips = downloadTipsLottie + it.multiVersionDownloadTv = multiVersionDownloadTv + }, true) } } } diff --git a/app/src/main/java/com/gh/gamecenter/game/rank/RankGameItemUi.kt b/app/src/main/java/com/gh/gamecenter/game/rank/RankGameItemUi.kt index f48bf44c49..bf045559b7 100644 --- a/app/src/main/java/com/gh/gamecenter/game/rank/RankGameItemUi.kt +++ b/app/src/main/java/com/gh/gamecenter/game/rank/RankGameItemUi.kt @@ -5,13 +5,18 @@ import android.graphics.Typeface import android.text.TextUtils import android.util.AttributeSet import android.view.Gravity +import android.view.View import android.widget.LinearLayout import android.widget.TextView import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.content.ContextCompat import com.gh.gamecenter.feature.view.DownloadButton import com.gh.gamecenter.feature.view.GameIconView +import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat +import com.airbnb.lottie.LottieAnimationView +import com.airbnb.lottie.LottieDrawable import com.gh.gamecenter.R +import com.gh.gamecenter.common.utils.setDrawableEnd import splitties.dimensions.dip import splitties.views.bottomPadding import splitties.views.dsl.constraintlayout.* @@ -27,6 +32,8 @@ class RankGameItemUi(override val ctx: Context) : Ui { var nameTv: TextView var tagContainer: LinearLayout var downloadTv: DownloadButton + var downloadTipsLottie: LottieAnimationView + var multiVersionDownloadTv: TextView override val root: ConstraintLayout = constraintLayout { orderTv = initOrderTv() @@ -34,6 +41,8 @@ class RankGameItemUi(override val ctx: Context) : Ui { nameTv = initNameTv() tagContainer = LinearLayout(ctx).apply { orientation = LinearLayout.HORIZONTAL } downloadTv = initDownloadTv() + downloadTipsLottie = initDownloadTipsLottie() + multiVersionDownloadTv = initMultiVersionDownloadTv() topPadding = dip(8) bottomPadding = dip(8) @@ -74,6 +83,20 @@ class RankGameItemUi(override val ctx: Context) : Ui { endOfParent() }) + add(multiVersionDownloadTv, lParams(wrapContent, dip(26)) { + topToTopOf(downloadTv) + bottomToBottomOf(downloadTv) + startToStartOf(downloadTv) + endToEndOf(downloadTv) + }) + + add(downloadTipsLottie, lParams(dip(16), dip(16)) { + topToTopOf(downloadTv) + endToEndOf(downloadTv) + + topMargin = dip(-8) + }) + add(tagContainer, lParams(0, wrapContent) { topToBottomOf(nameTv) startToEndOf(iconIv) @@ -103,7 +126,35 @@ class RankGameItemUi(override val ctx: Context) : Ui { } private fun initDownloadTv() = DownloadButton(ctx).apply { + id = R.id.download_btn text = context.getString(R.string.download) + showProgress = true + } + + private fun initDownloadTipsLottie(): LottieAnimationView { + return LottieAnimationView(ctx).apply { + id = R.id.downloadTipsLottie + repeatMode = LottieDrawable.RESTART + repeatCount = LottieDrawable.INFINITE + visibility = View.GONE + } + } + + private fun initMultiVersionDownloadTv(): TextView { + return textView { + id = R.id.multiVersionDownloadTv + textSize = 12F + gravity = Gravity.CENTER + text = "展开" + setTextColor(ContextCompat.getColor(context, R.color.white)) + setDrawableEnd( + VectorDrawableCompat.create( + resources, R.drawable.ic_jump_universal, null + ) + ) + compoundDrawablePadding = dip(2) + visibility = View.GONE + } } } diff --git a/app/src/main/java/com/gh/gamecenter/game/vertical/GameVerticalAdapter.kt b/app/src/main/java/com/gh/gamecenter/game/vertical/GameVerticalAdapter.kt index 50190f4b47..fd44572d6c 100644 --- a/app/src/main/java/com/gh/gamecenter/game/vertical/GameVerticalAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/game/vertical/GameVerticalAdapter.kt @@ -85,6 +85,12 @@ class GameVerticalAdapter( GameItemViewHolder.initGameSubtitle(gameEntity, gameSubtitleTv, mGameDesSpace) ConstraintSet().apply { clone(root) + connect( + R.id.game_name, + ConstraintSet.END, + if (gameEntity.serverLabel != null && !gameEntity.advanceDownload) R.id.game_server_type else R.id.gameSubtitleTv, + ConstraintSet.START + ) connect( R.id.adLabelTv, ConstraintSet.START, diff --git a/app/src/main/java/com/gh/gamecenter/gamecollection/publish/GameCollectionEditActivity.kt b/app/src/main/java/com/gh/gamecenter/gamecollection/publish/GameCollectionEditActivity.kt index 7e87f3f658..39e24b06fa 100644 --- a/app/src/main/java/com/gh/gamecenter/gamecollection/publish/GameCollectionEditActivity.kt +++ b/app/src/main/java/com/gh/gamecenter/gamecollection/publish/GameCollectionEditActivity.kt @@ -19,12 +19,13 @@ import com.gh.gamecenter.common.base.activity.ToolBarActivity import com.gh.gamecenter.common.base.fragment.WaitingDialogFragment import com.gh.gamecenter.common.constant.Constants import com.gh.gamecenter.common.constant.EntranceConsts +import com.gh.gamecenter.common.eventbus.EBReuse +import com.gh.gamecenter.common.mvvm.Status import com.gh.gamecenter.common.utils.* import com.gh.gamecenter.core.utils.PatternUtils import com.gh.gamecenter.databinding.ActivityGameCollectionEditBinding import com.gh.gamecenter.databinding.ItemGameCollectionFlexTagBinding import com.gh.gamecenter.entity.* -import com.gh.gamecenter.common.eventbus.EBReuse import com.gh.gamecenter.gamecollection.choose.ChooseGamesActivity import com.gh.gamecenter.gamecollection.choose.ChooseGamesViewModel import com.gh.gamecenter.gamecollection.tag.GameCollectionTagSelectActivity @@ -236,6 +237,17 @@ class GameCollectionEditActivity : ToolBarActivity() { mActivityName ) } + if (mGameEntity != null || mActivityName.isNotEmpty()) { + com.gh.common.util.NewFlatLogUtils.logActivityGameListCreateSuccessV2( + if (mGameEntity != null) "添加" else "立即投稿", + if (mGameEntity != null) mGameEntity?.id ?: "" else "", + if (mGameEntity != null) mGameEntity?.name ?: "" else "", + it.data ?: "", + mBinding.gameCollectionTitleEt.text.toString().trim(), + mActivityId, + mActivityName + ) + } } finish() } else { diff --git a/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailViewModel.kt b/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailViewModel.kt index 8eeddf7e37..cf00ededda 100644 --- a/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailViewModel.kt +++ b/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailViewModel.kt @@ -141,7 +141,6 @@ class GameDetailViewModel( // 4.4以下设备不显示顶部视频 displayTopVideo = data.topVideo != null && !data.topVideo?.url.isNullOrEmpty() - && !data.topVideo?.videoId.isNullOrEmpty() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT data.contentCard.forEach { diff --git a/app/src/main/java/com/gh/gamecenter/gamedetail/rating/RatingReplyAdapter.kt b/app/src/main/java/com/gh/gamecenter/gamedetail/rating/RatingReplyAdapter.kt index c3601366df..4c802965af 100644 --- a/app/src/main/java/com/gh/gamecenter/gamedetail/rating/RatingReplyAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/gamedetail/rating/RatingReplyAdapter.kt @@ -19,6 +19,7 @@ import com.gh.common.util.NewFlatLogUtils import com.gh.common.util.NewLogUtils import com.gh.gamecenter.GameDetailActivity import com.gh.gamecenter.R +import com.gh.gamecenter.adapter.viewholder.GameViewHolder import com.gh.gamecenter.common.base.BaseRecyclerViewHolder import com.gh.gamecenter.common.base.activity.BaseActivity import com.gh.gamecenter.common.baselist.ListAdapter @@ -177,7 +178,16 @@ class RatingReplyAdapter( refreshCallback = null, allStateClickCallback = { logGameDetailCommentDetailCommentClick("按钮") } ) - DownloadItemUtils.updateDownloadButton(mContext, this, game, false, PluginLocation.only_game) + DownloadItemUtils.updateItem( + mContext, + game, + GameViewHolder(holder.binding.root).apply { + gameDownloadBtn = holder.binding.gameDownload + multiVersionDownloadTv = holder.binding.multiVersionDownloadTv + gameDownloadTips = holder.binding.downloadTipsLottie + }, + true + ) } } is RatingDetailCommentItemViewHolder -> { diff --git a/app/src/main/java/com/gh/gamecenter/home/HomeGameItemViewHolder.kt b/app/src/main/java/com/gh/gamecenter/home/HomeGameItemViewHolder.kt index ac13d1197f..a125b74e88 100644 --- a/app/src/main/java/com/gh/gamecenter/home/HomeGameItemViewHolder.kt +++ b/app/src/main/java/com/gh/gamecenter/home/HomeGameItemViewHolder.kt @@ -11,6 +11,7 @@ import com.gh.common.util.DirectUtils import com.gh.common.util.DownloadItemUtils import com.gh.gamecenter.GameDetailActivity import com.gh.gamecenter.R +import com.gh.gamecenter.adapter.viewholder.GameViewHolder import com.gh.gamecenter.common.base.BaseRecyclerViewHolder import com.gh.gamecenter.common.utils.* import com.gh.gamecenter.core.utils.DisplayUtils @@ -158,7 +159,16 @@ class HomeGameItemViewHolder(val binding: HomeGameItemBinding) : BaseRecyclerVie "", exposureEvent ) - DownloadItemUtils.updateDownloadButton(binding.root.context, binding.downloadBtn, game) + DownloadItemUtils.updateItem( + binding.root.context, + game, + GameViewHolder(binding.root).apply { + gameDownloadBtn = binding.downloadBtn + multiVersionDownloadTv = binding.multiVersionDownloadTv + gameDownloadTips = binding.downloadTipsLottie + }, + true + ) binding.downloadBtn.goneIf(game.homeSetting.downloadBtnSwitch != "on") binding.gameRating.goneIf(!(game.showComment && game.commentCount >= 3 && game.star >= 7 && game.homeSetting.downloadBtnSwitch == "on")) binding.gameRating2.goneIf(!(game.showComment && game.commentCount >= 3 && game.star >= 7 && game.homeSetting.downloadBtnSwitch != "on")) diff --git a/app/src/main/java/com/gh/gamecenter/provider/GhContentProvider.kt b/app/src/main/java/com/gh/gamecenter/provider/GhContentProvider.kt index 95845fabb6..14f9a61f4e 100644 --- a/app/src/main/java/com/gh/gamecenter/provider/GhContentProvider.kt +++ b/app/src/main/java/com/gh/gamecenter/provider/GhContentProvider.kt @@ -8,13 +8,13 @@ import android.database.sqlite.SQLiteOpenHelper import android.net.Uri import android.text.TextUtils import android.util.Base64 -import com.halo.assistant.HaloApp import com.gh.gamecenter.BuildConfig import com.gh.gamecenter.common.constant.Constants import com.gh.gamecenter.core.utils.GsonUtils import com.gh.gamecenter.core.utils.SPUtils import com.gh.gamecenter.login.entity.UserInfoEntity import com.gh.gamecenter.login.user.UserRepository +import com.halo.assistant.HaloApp import com.lightgame.utils.Utils class GhContentProvider : ContentProvider() { @@ -25,12 +25,13 @@ class GhContentProvider : ContentProvider() { init { mUriMatcher.addURI(AUTHORITY, CERTIFICATION_TABLE_NAME, 1) mUriMatcher.addURI(AUTHORITY, SYNC_CERTIFICATION_TABLE_NAME, 2) + mUriMatcher.addURI(AUTHORITY, DEVICE_TABLE_NAME, 3) } private fun initProviderSqliteHelper(context: Context?) { val helper: SQLiteOpenHelper = - object : SQLiteOpenHelper(context, CERTIFICATION_DATABASE_NAME, null, 1) { + object : SQLiteOpenHelper(context, CERTIFICATION_DATABASE_NAME, null, 2) { override fun onCreate(db: SQLiteDatabase) { // 创建表格 val sql = "CREATE TABLE $CERTIFICATION_TABLE_NAME(" + @@ -46,10 +47,24 @@ class GhContentProvider : ContentProvider() { "$KEY_ID_CARD TEXT" + ")" db.execSQL(syncSql) + + val deviceSql = "CREATE TABLE ${DEVICE_TABLE_NAME}(" + + "$KEY_PRIMARY_KEY INTEGER PRIMARY KEY AUTOINCREMENT," + + "$KEY_GID TEXT," + + "$KEY_ANDROID_ID TEXT" + + ")" + db.execSQL(deviceSql) } override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) { - // do nothing + if (oldVersion == 1 && newVersion == 2) { + val deviceSql = "CREATE TABLE ${DEVICE_TABLE_NAME}(" + + "$KEY_PRIMARY_KEY INTEGER PRIMARY KEY AUTOINCREMENT," + + "$KEY_GID TEXT," + + "$KEY_ANDROID_ID TEXT" + + ")" + db.execSQL(deviceSql) + } } } mSqLiteDatabase = helper.writableDatabase @@ -87,6 +102,15 @@ class GhContentProvider : ContentProvider() { null, null ) + 3 -> return mSqLiteDatabase?.query( + DEVICE_TABLE_NAME, + null, + null, + null, + null, + null, + null + ) } return null @@ -166,7 +190,29 @@ class GhContentProvider : ContentProvider() { UserRepository.getInstance().syncCertificate(finalRealName, finalIdCard) return ContentUris.withAppendedId(uri, 1) } - + } + } else if (mUriMatcher.match(uri) == 3) { + try { + // 固定主键(只保留一条数据即可) + values?.put(KEY_PRIMARY_KEY, 1) + // 如果已存在则直接替换 + val rowId: Long? = mSqLiteDatabase?.insertWithOnConflict( + DEVICE_TABLE_NAME, + null, + values, + SQLiteDatabase.CONFLICT_REPLACE + ) + if (rowId != null && rowId > 0) { + val nameUri = ContentUris.withAppendedId(uri, rowId) + context.contentResolver.notifyChange(nameUri, null) + Utils.log( + "DeviceContentProvider", + "insert success:" + uri.authority + ", status => " + values?.toString() + ) + return nameUri + } + } catch (e: SQLiteFullException) { + Utils.toast(context, "数据库内存已满,无法同步") } } return null @@ -193,10 +239,13 @@ class GhContentProvider : ContentProvider() { private const val AUTHORITY = "${BuildConfig.APPLICATION_ID}.provider" private const val CERTIFICATION_DATABASE_NAME = "gh_certification.db" private const val CERTIFICATION_TABLE_NAME = "certification" + private const val DEVICE_TABLE_NAME = "device" const val KEY_PRIMARY_KEY = "primary_key" const val KEY_IS_CERTIFICATED = "is_certificated" const val KEY_IS_ADULT = "is_adult" + const val KEY_GID = "gid" + const val KEY_ANDROID_ID = "android_id" private const val SYNC_CERTIFICATION_TABLE_NAME = "sync_certification" diff --git a/app/src/main/java/com/gh/gamecenter/qa/video/detail/ForumVideoDetailFragment.kt b/app/src/main/java/com/gh/gamecenter/qa/video/detail/ForumVideoDetailFragment.kt index 4ee33610cb..2fbdd0541e 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/video/detail/ForumVideoDetailFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/video/detail/ForumVideoDetailFragment.kt @@ -27,6 +27,7 @@ import com.gh.common.util.NewLogUtils import com.gh.download.DownloadManager import com.gh.gamecenter.GameDetailActivity import com.gh.gamecenter.R +import com.gh.gamecenter.adapter.viewholder.GameViewHolder import com.gh.gamecenter.common.base.fragment.BaseFragment_TabLayout import com.gh.gamecenter.common.constant.Constants import com.gh.gamecenter.common.constant.EntranceConsts @@ -470,12 +471,15 @@ class ForumVideoDetailFragment : BaseFragment_TabLayout() { } }, null ) - DownloadItemUtils.updateDownloadButton( + DownloadItemUtils.updateItem( requireContext(), - mBinding.downloadBtn, gameEntity, - false, - PluginLocation.only_game + GameViewHolder(mBinding.gameInfoContainer).apply { + gameDownloadBtn = mBinding.downloadBtn + gameDownloadTips = mBinding.downloadTipsLottie + multiVersionDownloadTv = mBinding.multiVersionDownloadTv + }, + true ) } diff --git a/app/src/main/java/com/gh/gamecenter/video/detail/VideoAdapter.kt b/app/src/main/java/com/gh/gamecenter/video/detail/VideoAdapter.kt index b78687a529..803ac9ad11 100644 --- a/app/src/main/java/com/gh/gamecenter/video/detail/VideoAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/video/detail/VideoAdapter.kt @@ -3,12 +3,14 @@ package com.gh.gamecenter.video.detail import android.app.Activity import android.view.View import android.view.ViewGroup +import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import androidx.fragment.app.Fragment import androidx.recyclerview.widget.RecyclerView import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import com.gh.gamecenter.feature.exposure.ExposureEvent import com.gh.gamecenter.feature.exposure.ExposureSource +import com.airbnb.lottie.LottieAnimationView import com.gh.common.exposure.IExposable import com.gh.common.util.DownloadItemUtils import com.gh.common.util.LogUtils @@ -16,6 +18,7 @@ import com.gh.common.videolog.VideoRecordUtils import com.gh.gamecenter.feature.view.DownloadButton import com.gh.download.cache.ExoCacheManager import com.gh.gamecenter.R +import com.gh.gamecenter.adapter.viewholder.GameViewHolder import com.gh.gamecenter.common.base.activity.BaseActivity import com.gh.gamecenter.common.constant.Constants import com.gh.gamecenter.common.utils.ImageUtils @@ -165,7 +168,8 @@ class VideoAdapter( private fun setDownloadButton(videoView: DetailPlayerView?, position: Int) { videoList[position].game?.let { game -> - + val multiTv = videoView?.findViewById(R.id.multiVersionDownloadTv) + val downloadTipsLottie = videoView?.findViewById(R.id.downloadTipsLottie) videoView?.findViewById(R.id.download_btn)?.run { val btn = this val exposureEvent = generateExposure(game) @@ -201,12 +205,15 @@ class VideoAdapter( videoView.uploadVideoStreamingPlaying("点击下载按钮", btn.text.toString()) } }) - DownloadItemUtils.updateDownloadButton( + DownloadItemUtils.updateItem( mFragment.requireContext(), - this, game, - false, - PluginLocation.only_game + GameViewHolder(videoView).apply { + gameDownloadBtn = this@run + gameDownloadTips = downloadTipsLottie + multiVersionDownloadTv = multiTv + }, + true ) } } diff --git a/app/src/main/java/com/gh/gamecenter/video/detail/VideoDetailContainerFragment.kt b/app/src/main/java/com/gh/gamecenter/video/detail/VideoDetailContainerFragment.kt index 0ddac01eff..dc006dabc0 100644 --- a/app/src/main/java/com/gh/gamecenter/video/detail/VideoDetailContainerFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/video/detail/VideoDetailContainerFragment.kt @@ -78,6 +78,10 @@ class VideoDetailContainerFragment : BaseLazyFragment(), OnBackPressedListener { mAdapter.notifyItemByDownload(downloadEntity) } } + + override fun onDataInit(downloadEntity: DownloadEntity) { + onDataChanged(downloadEntity) + } } override fun getLayoutId(): Int = 0 diff --git a/app/src/main/java/com/gh/vspace/VBackupHelper.kt b/app/src/main/java/com/gh/vspace/VBackupHelper.kt index e43938601a..8529b66466 100644 --- a/app/src/main/java/com/gh/vspace/VBackupHelper.kt +++ b/app/src/main/java/com/gh/vspace/VBackupHelper.kt @@ -111,7 +111,7 @@ object VBackupHelper { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { Files.move(backupZip.file.toPath(), File(backupDir.absolutePath + "/" + fileName + ".zip").toPath()) } - } catch (e: Exception) { + } catch (e: Throwable) { e.printStackTrace() } } diff --git a/app/src/main/res/layout/fragment_forum_video_detail.xml b/app/src/main/res/layout/fragment_forum_video_detail.xml index aeaffddf5d..7386c9c8f4 100644 --- a/app/src/main/res/layout/fragment_forum_video_detail.xml +++ b/app/src/main/res/layout/fragment_forum_video_detail.xml @@ -124,12 +124,40 @@ android:id="@+id/downloadBtn" android:layout_width="60dp" android:layout_height="28dp" - app:download_button_show_progress="false" + app:download_button_show_progress="true" app:download_button_text_size="12sp" app:layout_constraintBottom_toBottomOf="@+id/gameIconView" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="@+id/gameIconView" /> + + + + @@ -25,14 +25,52 @@ android:textSize="12sp" tools:text="超杀默示录" /> - + + + + + + + + diff --git a/app/src/main/res/layout/game_slide_list_item.xml b/app/src/main/res/layout/game_slide_list_item.xml new file mode 100644 index 0000000000..57201941cd --- /dev/null +++ b/app/src/main/res/layout/game_slide_list_item.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/game_test_item.xml b/app/src/main/res/layout/game_test_item.xml index 3efca98eeb..175b52d7d0 100644 --- a/app/src/main/res/layout/game_test_item.xml +++ b/app/src/main/res/layout/game_test_item.xml @@ -202,7 +202,7 @@ android:id="@+id/home2_download_btn" android:layout_width="60dp" android:layout_height="28.5dp" - app:download_button_show_progress="false" + app:download_button_show_progress="true" app:download_button_text_size="12sp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" diff --git a/app/src/main/res/layout/home_game_item.xml b/app/src/main/res/layout/home_game_item.xml index 920ac3693c..726170ab1c 100644 --- a/app/src/main/res/layout/home_game_item.xml +++ b/app/src/main/res/layout/home_game_item.xml @@ -131,13 +131,41 @@ android:layout_height="28dp" android:layout_marginLeft="8dp" android:visibility="gone" - app:download_button_show_progress="false" + app:download_button_show_progress="true" app:download_button_text_size="12sp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" tools:visibility="visible" /> + + + + - + android:layout_centerHorizontal="true"> + + + + + + + + + + + + diff --git a/app/src/main/res/layout/rating_reply_head_item.xml b/app/src/main/res/layout/rating_reply_head_item.xml index cb0eeb2def..25a6e548a4 100644 --- a/app/src/main/res/layout/rating_reply_head_item.xml +++ b/app/src/main/res/layout/rating_reply_head_item.xml @@ -84,12 +84,40 @@ android:id="@+id/game_download" android:layout_width="56dp" android:layout_height="28dp" - app:download_button_show_progress="false" + app:download_button_show_progress="true" app:download_button_text_size="12sp" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="@+id/gameIconContainer" app:layout_constraintBottom_toBottomOf="@+id/gameIconContainer" /> + + + +