Compare commits

..

2 Commits

Author SHA1 Message Date
3bba93184f fix:【光环助手】开屏自有广告显示问题 https://jira.shanqu.cc/browse/GHZSCY-7994 2025-05-15 14:57:04 +08:00
94f4e82715 ci 2025-05-15 14:55:18 +08:00
252 changed files with 2958 additions and 4639 deletions

View File

@ -72,6 +72,7 @@ android_build:
only:
- dev
- release
- fix/GHZSCY-7994
# 代码检查
sonarqube_analysis:
@ -103,6 +104,7 @@ sonarqube_analysis:
only:
- dev
- release
- fix/GHZSCY-7994
## 发送简易检测结果报告
send_sonar_report:
@ -121,6 +123,7 @@ send_sonar_report:
only:
- dev
- release
- fix/GHZSCY-7994
oss-upload&send-email:
tags:
@ -157,4 +160,4 @@ oss-upload&send-email:
only:
- dev
- release
- fix/GHZSCY-7994

View File

@ -154,7 +154,7 @@ android {
zipAlignEnabled false
signingConfig signingConfigs.debug
buildConfigField "String", "EXPOSURE_REPO", "\"exposure\""
buildConfigField "String", "EXPOSURE_REPO", "\"test\""
buildConfigField "String", "EXPOSURE_VERSION", "\"E4\""
multiDexKeepProguard file("tinker_multidexkeep.pro")

View File

@ -3,14 +3,9 @@ package com.gh.vspace.installexternalgames
import android.Manifest
import android.app.Dialog
import android.content.ComponentName
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Build
import android.os.Bundle
import android.os.Environment
import android.provider.Settings
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AlertDialog
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.LinearLayoutManager
import com.gh.common.util.DialogUtils
@ -42,9 +37,6 @@ class InstallExternalGameFragment : ToolbarFragment(), OnItemClickListener {
private var uninstallDisposable: Disposable? = null
private var shouldScan = false
override fun getLayoutId() = 0
override fun getInflatedLayout() =
@ -82,24 +74,7 @@ class InstallExternalGameFragment : ToolbarFragment(), OnItemClickListener {
adapter.notifyDataSetChanged()
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
if (!Environment.isExternalStorageManager()) {
shouldScan = true
AlertDialog.Builder(requireContext()).setMessage("请在设置页面允许光环助手")
.setNegativeButton("") { dialog, which ->
val intent = Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
startActivity(intent)
}.show()
} else {
mViewModel.scanPaths()
}
} else {
requestStoragePermission()
}
requestStoragePermission()
}
private fun requestStoragePermission() {
@ -121,12 +96,6 @@ class InstallExternalGameFragment : ToolbarFragment(), OnItemClickListener {
}
}
override fun onStart() {
super.onStart()
if (shouldScan) {
mViewModel.scanPaths()
}
}
private fun initView() {
dialog = DialogUtils.showWaitDialog(requireContext(), "")
@ -183,7 +152,7 @@ class InstallExternalGameFragment : ToolbarFragment(), OnItemClickListener {
}, true)
VHelper.newCwValidateVspaceBeforeAction(
requireContext(), null,
requireContext(),null,
) {
dialog.show()
}

View File

@ -5,7 +5,6 @@ import android.app.Activity
import android.content.Context
import android.content.SharedPreferences
import android.graphics.drawable.Animatable
import android.os.Build
import android.os.Message
import android.text.TextUtils
import android.view.View
@ -44,7 +43,6 @@ import com.gh.gamecenter.feature.exposure.ExposureType
import com.gh.gamecenter.retrofit.RetrofitManager
import com.halo.assistant.HaloApp
import io.reactivex.schedulers.Schedulers
import java.util.Locale
/**
* 广告实现代理类
@ -122,12 +120,7 @@ object AdDelegateHelper {
if (isFromRetry && mAdConfigList.isNotEmpty()) {
return
}
val paramsMap = if (keyword.isNotEmpty()) {
mapOf("keyword" to keyword, "android_sdk_version" to Build.VERSION.SDK_INT)
} else {
mapOf("android_sdk_version" to Build.VERSION.SDK_INT)
}
val paramsMap = if (keyword.isNotEmpty()) mapOf("keyword" to keyword) else mapOf()
RetrofitManager.getInstance()
.newApi
.getAdConfig(paramsMap)
@ -189,16 +182,11 @@ object AdDelegateHelper {
// HarmonyOS 2.2.0 版本不展示第三方开屏广告 (因为会引起奇怪的闪退)
if (MetaUtil.getRom().name == "HarmonyOS"
&& MetaUtil.getRom().versionName == "2.2.0"
&& config.displayRule.adSource == AD_TYPE_SDK) {
&& config.displayRule.adSource == "third_party_ads") {
return
}
// 华为系 Android 10 不展示第三方开屏广告 (因为会引起奇怪的闪退)
if (isBuggyHuaweiDevice() && config.displayRule.adSource == AD_TYPE_SDK) {
return
}
mSplashAd = config
}
@ -227,7 +215,6 @@ object AdDelegateHelper {
private fun shouldShowStartUpAdWhenHotLaunch() = (mCsjAdImpl != null)
&& mSplashAd?.displayRule?.hotStartSplashAd?.type == AD_TYPE_SDK
&& mSplashAd?.hotStartThirdPartyAd != null
&& !isBuggyHuaweiDevice()
/**
* 是否需要显示下载管理广告
@ -796,16 +783,4 @@ object AdDelegateHelper {
mCsjAdImpl?.cancelSplashAd(context)
}
/**
* 是否为有问题的华为系 Android 10 设备
*/
private fun isBuggyHuaweiDevice(): Boolean {
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.Q) {
val manufacturer = Build.MANUFACTURER.lowercase(Locale.CHINA) ?: ""
return manufacturer == "huawei" || manufacturer == "honor"
} else {
return false
}
}
}

View File

@ -16,10 +16,12 @@ import com.gh.gamecenter.GameDetailActivity
import com.gh.gamecenter.R
import com.gh.gamecenter.common.base.BaseRecyclerViewHolder
import com.gh.gamecenter.common.base.fragment.BaseDialogFragment
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.exposure.ExposureSource
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.common.view.FixLinearLayoutManager
import com.gh.gamecenter.core.utils.DisplayUtils
import com.gh.gamecenter.core.utils.SPUtils.getBoolean
import com.gh.gamecenter.databinding.DialogReserveBinding
import com.gh.gamecenter.databinding.DialogReserveItemBinding
import com.gh.gamecenter.feature.entity.GameEntity

View File

@ -1,54 +0,0 @@
package com.gh.common.exposure
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.exposure.IExposureStateChangeListener
import com.gh.gamecenter.feature.exposure.RecyclerViewExposureHelper
import com.lightgame.utils.Utils
class DefaultExposureStateChangeListener : IExposureStateChangeListener {
override fun onExposureStateChange(
exposureEvent: ExposureEvent,
position: Int,
inExposure: Boolean
) {
val exposureStatus = if (inExposure) "曝光中" else "结束曝光"
val isCPMExposureEvent = exposureEvent.payload.miniGameType == Constants.WECHAT_MINI_GAME_CPM
Utils.log(
RecyclerViewExposureHelper.TAG,
"onExposureStateChange: 名称 ${exposureEvent.payload.gameName} 位置 $position, $exposureStatus"
)
// 如果是 CPM 曝光事件,且在曝光中,直接上报 CPM 曝光 (内部有做简单的去重处理CPM 曝光追求一个及时上报,不用理会曝光时长)
if (isCPMExposureEvent && inExposure) {
Utils.log(
RecyclerViewExposureHelper.TAG,
"上报 CPM 曝光 ${exposureEvent.payload.gameName} ${exposureEvent.id}"
)
ExposureManager.logCPM(exposureEvent)
}
if (!inExposure
&& System.currentTimeMillis() - exposureEvent.timeInMillisecond > DEFAULT_VALID_EXPOSURE_THRESHOLD
) {
Utils.log(
RecyclerViewExposureHelper.TAG,
"上报曝光 ${exposureEvent.payload.gameName} ${exposureEvent.id},是否为 CPM 小游戏 -> ${isCPMExposureEvent}" +
"曝光时长为 ${System.currentTimeMillis() - exposureEvent.timeInMillisecond}ms"
)
// 标记当前 ExposureEvent 已经被使用过
exposureEvent.markIsUsed()
ExposureManager.log(exposureEvent)
}
}
companion object {
// 默认曝光有效时长
const val DEFAULT_VALID_EXPOSURE_THRESHOLD = 1000L
}
}

View File

@ -4,14 +4,12 @@ import com.gh.gamecenter.BuildConfig
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.loghub.TLogHubHelper
import com.gh.gamecenter.common.utils.FixedSizeLinkedHashSet
import com.gh.gamecenter.common.utils.toJson
import com.gh.gamecenter.core.AppExecutor
import com.gh.gamecenter.dsp.DspReportHelper
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.exposure.ExposureType
import com.gh.gamecenter.feature.minigame.wechat.WGameSubjectCPMListReportHelper
import com.google.gson.ExclusionStrategy
import com.google.gson.FieldAttributes
import com.google.gson.GsonBuilder
import com.lightgame.utils.Utils
import com.volcengine.model.tls.LogItem
@ -33,20 +31,6 @@ object ExposureManager {
private val exposureSet by lazy { hashSetOf<ExposureEvent>() }
private val exposureCache by lazy { FixedSizeLinkedHashSet<String>(300) }
private val gson by lazy {
GsonBuilder()
.addSerializationExclusionStrategy(object: ExclusionStrategy {
override fun shouldSkipClass(clazz: Class<*>): Boolean {
return false
}
override fun shouldSkipField(f: FieldAttributes): Boolean {
return f.name == "additional"
}
})
.create()
}
/**
* Log a single exposure event.
*/
@ -102,15 +86,6 @@ object ExposureManager {
}
}
/**
* Log a wechat mini game cpm collection of exposure event.
*/
fun logCPM(event: ExposureEvent) {
AppExecutor.logExecutor.execute {
WGameSubjectCPMListReportHelper.reportExposure(event)
}
}
/**
* @param forcedUpload Ignore all restrictions.
*/
@ -139,14 +114,14 @@ object ExposureManager {
private fun buildLog(event: ExposureEvent) = LogItem(System.currentTimeMillis()).apply {
addContent("__id", event.id)
addContent("payload", gson.toJson(event.payload))
addContent("payload", event.payload.toJson())
addContent("event", event.event.toString())
addContent("source", eliminateMultipleBrackets(gson.toJson(event.source)))
addContent("meta", gson.toJson(event.meta))
addContent("source", eliminateMultipleBrackets(event.source.toJson()))
addContent("meta", event.meta.toJson())
addContent("real_millisecond", event.timeInMillisecond.toString())
addContent(
"e-traces", if (event.eTrace != null) {
eliminateMultipleBrackets(gson.toJson(event.eTrace))
eliminateMultipleBrackets(event.eTrace?.toJson() ?: "")
} else ""
)
}

View File

@ -8,13 +8,13 @@ object ExposureTraceUtils {
val traceList = arrayListOf<ExposureEvent>()
event?.let {
//这里使用 copy是为了防止循环引用调用hashCode方法触发StackOverflowError错误
val exposureCopy = it.shallowCopy()
if (exposureCopy.eTrace == null) {
traceList.add(exposureCopy)
//这里使用deepCopy是为了防止循环引用调用hashCode方法触发StackOverflowError错误
val deepCopy = it.deepCopy()
if (deepCopy.eTrace == null) {
traceList.add(deepCopy)
} else {
traceList.addAll(exposureCopy.eTrace!!)
traceList.add(flattenTrace(exposureCopy))
traceList.addAll(deepCopy.eTrace!!)
traceList.add(flattenTrace(deepCopy))
}
}

View File

@ -5,7 +5,6 @@ import com.gh.common.util.DirectUtils
import com.gh.gamecenter.BuildConfig
import com.gh.gamecenter.common.entity.LaunchRedirect
import com.gh.gamecenter.common.entity.LaunchRedirectWrapper
import com.gh.gamecenter.common.pagelevel.PageLevelManager
import com.gh.gamecenter.common.retrofit.BiResponse
import com.gh.gamecenter.common.utils.singleToMain
import com.gh.gamecenter.core.AppExecutor
@ -66,11 +65,9 @@ class LaunchRedirectHandler(priority: Int) : PriorityChainHandler(priority) {
override fun onProcess(): Boolean {
val currentActivity = CurrentActivityHolder.getCurrentActivity()
if (GlobalPriorityChainHelper.isThisActivityValid(currentActivity) && launchData?.type != "bottom_tab") {
if (GlobalPriorityChainHelper.isThisActivityValid(currentActivity)) {
if (getStatus() == STATUS_VALID) {
// 设置下一个页面为顶级页面
PageLevelManager.setNextPageAsSupremePageLevel()
// 当 type 为 "bottom_tab" 时上面 doPreProcess 中已经处理过了,但再选中一次好像也没有什么问题,先不特殊处理这个 case 了
DirectUtils.directToLinkPage(currentActivity!!, launchData!!, "首次启动跳转", "")
// 跳转页面不管回调,延迟 500ms 后执行下一个 handler
AppExecutor.uiExecutor.executeWithDelay({

View File

@ -30,8 +30,6 @@ class DownloadButtonClickedProviderImpl : IDownloadButtonClickedProvider {
var packageName = ""
var exposureSourceList: List<ExposureSource>? = null
var customPageTrackData: CustomPageTrackData? = null
var isAd = false
var adGroupId = ""
val pushMessageId = (HaloApp.get(Constants.PUSH_MESSAGE_ID, false) as? String) ?: ""
val pushLinkId = (HaloApp.get(Constants.PUSH_LINK_ENTITY, false) as? LinkEntity)?.link ?: ""
val isFromPush = pushMessageId.isNotEmpty()
@ -62,8 +60,6 @@ class DownloadButtonClickedProviderImpl : IDownloadButtonClickedProvider {
packageName = boundedObject.getUniquePackageName() ?: ""
exposureSourceList = boundedObject.exposureEvent?.source
customPageTrackData = boundedObject.customPageTrackData
isAd = boundedObject.adGroupId.isNotEmpty()
adGroupId = boundedObject.adGroupId
}
is GameUpdateEntity -> {
@ -148,8 +144,6 @@ class DownloadButtonClickedProviderImpl : IDownloadButtonClickedProvider {
"last_page_name", GlobalActivityManager.getLastPageEntity().pageName,
"last_page_id", GlobalActivityManager.getLastPageEntity().pageId,
"last_page_business_id", GlobalActivityManager.getLastPageEntity().pageBusinessId,
"is_ad", isAd.toString(),
"ad_group_id", adGroupId,
"is_from_push_notifications", isFromPush,
"message_id", pushMessageId,
"link_id", pushLinkId,

View File

@ -1,6 +1,9 @@
package com.gh.common.provider
import android.content.Context
import com.therouter.router.Route
import com.gh.common.exposure.ExposureManager
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.provider.IExposureManagerProvider
@ -9,8 +12,4 @@ class ExposureManagerProviderImpl: IExposureManagerProvider {
override fun logExposure(exposureEvent: ExposureEvent) {
ExposureManager.log(exposureEvent)
}
override fun logExposureList(exposureEventList: List<ExposureEvent>) {
ExposureManager.log(exposureEventList)
}
}

View File

@ -1,20 +1,8 @@
package com.gh.common.util
import android.annotation.SuppressLint
import android.text.TextUtils
import com.gh.common.constant.Config
import com.gh.gamecenter.common.entity.IdfaData
import com.gh.gamecenter.common.pagelevel.IPageLevelProvider
import com.gh.gamecenter.common.retrofit.BiResponse
import com.gh.gamecenter.common.tracker.IBusiness
import com.gh.gamecenter.common.utils.SensorsBridge
import com.gh.gamecenter.core.utils.CurrentActivityHolder
import com.gh.gamecenter.entity.StartupAdEntity
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.entity.SettingsEntity
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.retrofit.RetrofitManager
import io.reactivex.schedulers.Schedulers
object AdHelper {
@ -24,102 +12,6 @@ object AdHelper {
const val LOCATION_SUGGESTION_FUNCTION = "suggestion_function"
const val LOCATION_SIMULATOR_GAME = "simulator_game"
// 广告标识 https://jira.shanqu.cc/browse/GHZSCY-7041
private var idfa = ""
@SuppressLint("CheckResult")
@JvmStatic
fun getIdfa(versionName: String, channel: String) {
RetrofitManager.getInstance().newApi.getIdfa(versionName, channel)
.subscribeOn(Schedulers.io())
.subscribe(object : BiResponse<IdfaData>() {
override fun onSuccess(data: IdfaData) {
idfa = data.AD
SensorsBridge.trackGetAdTag(data.AD)
}
override fun onFailure(exception: Exception) {
super.onFailure(exception)
SensorsBridge.trackGetAdTag("")
}
})
}
fun getIdfaString() : String {
return idfa
}
/**
* 记录广告游戏填充
*/
fun reportAdRequest(exposureEvent: ExposureEvent) {
val payload = exposureEvent.payload
NewFlatLogUtils.logAdRequest(
pageLevel = payload.pageLevel ?: "",
currentPageCode = payload.currentPageCode ?: "",
currentPageId = payload.currentPageId ?: "",
gameName = payload.gameName ?: "",
gameId = payload.gameId ?: "",
moduleType = payload.moduleType ?: "",
moduleStyle = payload.moduleStyle ?: "",
moduleName = payload.moduleName ?: "",
moduleId = payload.moduleId ?: "",
searchContent = payload.searchContent ?: "",
sequence = payload.sequence ?: -1,
outerSequence = payload.outerSequence ?: -1,
adGroupId = payload.adGroupId ?: "",
)
}
/**
* 记录广告游戏填充
*/
fun reportAdRequest(gameEntity: GameEntity) {
val currentActivity = CurrentActivityHolder.getCurrentActivity()
val subPageCode = gameEntity.subPageCode
val subPageId = gameEntity.subPageId
val currentActivitySimpleName = if (currentActivity != null) currentActivity::class.simpleName else "unknown"
val businessId = if (currentActivity is IBusiness) currentActivity.getBusinessId() else null
var currentPageCode = currentActivitySimpleName
var currentPageId = businessId?.first
// 子页面的 pageCode 添加到主页面后, pageId 优先级高于主页面 pageId
if (!subPageCode.isNullOrEmpty()) {
currentPageCode = "$currentActivitySimpleName-$subPageCode"
if (!subPageId.isNullOrEmpty()) {
currentPageId = subPageId
}
}
var pageLevelString: String? = gameEntity.pageLevelString
if (TextUtils.isEmpty(pageLevelString)) {
val pageLevelProvider = currentActivity as? IPageLevelProvider
pageLevelString = pageLevelProvider?.getPageLevel()?.toFormattedString()
}
NewFlatLogUtils.logAdRequest(
pageLevel = pageLevelString ?: "",
currentPageCode = currentPageCode ?: "",
currentPageId = currentPageId ?: "",
gameName = gameEntity.name ?: "",
gameId = gameEntity.id,
moduleStyle = gameEntity.customPageTrackData?.modulePattern ?: "",
moduleType = gameEntity.customPageTrackData?.moduleType ?: "",
moduleName = gameEntity.customPageTrackData?.linkContentName ?: "",
moduleId = gameEntity.customPageTrackData?.linkContentId ?: "",
searchContent = "",
sequence = gameEntity.sequence ?: -1,
outerSequence = gameEntity.outerSequence ?: -1,
adGroupId = gameEntity.adGroupId,
)
}
@JvmStatic
fun getStartUp(): StartupAdEntity? {
return Config.getNewApiSettingsEntity()?.startup

View File

@ -867,8 +867,6 @@ object DownloadItemUtils {
"last_page_id", getLastPageEntity().pageId,
"last_page_business_id", getLastPageEntity().pageBusinessId,
"source", gameEntity.exposureEvent?.source?.toString() ?: "",
"is_ad", if (gameEntity.adGroupId.isEmpty()) "false" else "true",
"ad_group_id", gameEntity.adGroupId,
*gameEntity.customPageTrackData?.toKV() ?: arrayOf()
)
allStateClickCallback?.onCallback()

View File

@ -501,7 +501,6 @@ object DownloadObserver {
val isPlatformRecommend =
java.lang.Boolean.parseBoolean(downloadEntity.getMetaExtra(Constants.IS_PLATFORM_RECOMMEND))
val adGroupId = downloadEntity.getMetaExtra(Constants.AD_GROUP_ID)
val exposureEvent = ExposureUtils.logADownloadCompleteExposureEvent(
GameEntity(
_id = downloadEntity.gameId,
@ -535,8 +534,6 @@ object DownloadObserver {
"game_id", downloadEntity.gameId,
"game_type", downloadEntity.categoryChinese,
"game_schema_type", if (downloadEntity.getMetaExtra(Constants.KEY_BIT) == "32") "32位" else "64位",
"is_ad", if (adGroupId.isEmpty()) "false" else "true",
"ad_group_id", adGroupId,
*kvs
)
} else if (downloadEntity.gameId == Constants.HALO_FUN_GAME_ID) {
@ -601,8 +598,6 @@ object DownloadObserver {
if (downloadEntity.asVGame()) "畅玩下载" else "本地下载",
"is_from_push_notifications",
isFromPush,
"is_ad", if (adGroupId.isEmpty()) "false" else "true",
"ad_group_id", adGroupId,
"message_id",
pushMessageId,
"link_id",

View File

@ -99,11 +99,6 @@ object GameSubstituteRepositoryHelper {
continue
}
// 广告系统的广告游戏不替换
if (game.adGroupId.isNotEmpty()) {
continue
}
// 这个 position 的游戏是否需要被替换
var thisPositionNeedToBeReplaced = false

View File

@ -324,19 +324,7 @@ public class LibaoUtils {
libaoBtn.setText(com.gh.gamecenter.feature.R.string.libao_finish);
libaoBtn.setBackgroundResource(R.drawable.button_border_round_gray);
libaoBtn.setTextColor(context.getResources().getColor(com.gh.gamecenter.common.R.color.button_gray));
libaoBtn.setOnClickListener(v ->
{
ToastUtils.toast("兑换码领取已结束");
SensorsBridge.trackEvent("GameGiftDraw",
"gift_type", "兑换码",
"game_name", libaoEntity.getGame().getName(),
"game_id", libaoEntity.getGame().getId(),
"gift_id", libaoEntity.getId(),
"gift_name", libaoEntity.getName(),
"source_entrance", sourceEntrance,
"button_name", libaoBtn.getText().toString()
);
});
libaoBtn.setOnClickListener(v -> ToastUtils.toast("兑换码领取已结束"));
} else {
libaoBtn.setText(R.string.libao_copy);
libaoBtn.setTextColor(ExtensionsKt.toColor(com.gh.gamecenter.common.R.color.white, context));
@ -350,23 +338,6 @@ public class LibaoUtils {
libaoEntity.getGame().getId(),
libaoEntity.getGame().getName()
);
SensorsBridge.trackEvent("GameGiftDraw",
"gift_type", "兑换码",
"game_name", libaoEntity.getGame().getName(),
"game_id", libaoEntity.getGame().getId(),
"gift_id", libaoEntity.getId(),
"gift_name", libaoEntity.getName(),
"source_entrance", sourceEntrance,
"button_name", libaoBtn.getText().toString()
);
SensorsBridge.trackEvent("GameGiftDrawResult",
"gift_type", "兑换码",
"game_name", libaoEntity.getGame().getName(),
"game_id", libaoEntity.getGame().getId(),
"gift_id", libaoEntity.getId(),
"gift_name", libaoEntity.getName(),
"source_entrance", sourceEntrance
);
ExtensionsKt.copyTextAndToast(libaoEntity.getCode(), libaoEntity.getToast());
});
}
@ -375,25 +346,6 @@ public class LibaoUtils {
libaoBtn.setOnClickListener(v -> {
String btnStatus = libaoBtn.getText().toString();
String giftType;
if ("ling".equals(libaoEntity.getStatus()) || "linged".equals(libaoEntity.getStatus())) {
giftType = "普通礼包";
} else if ("copy".equals(libaoEntity.getReceiveMethod())) {
giftType = "兑换码";
} else {
giftType = "淘号礼包";
}
SensorsBridge.trackEvent("GameGiftDraw",
"gift_type", giftType,
"game_name", libaoEntity.getGame().getName(),
"game_id", libaoEntity.getGame().getId(),
"gift_id", libaoEntity.getId(),
"gift_name", libaoEntity.getName(),
"source_entrance", sourceEntrance,
"button_name", btnStatus
);
// 领取限制
CheckLoginUtils.checkLogin(context, "礼包详情-[" + btnStatus + "]", () -> {
if ("领取".equals(btnStatus) || "淘号".equals(btnStatus)) {
@ -456,11 +408,27 @@ public class LibaoUtils {
} else {
libaoLing(context, libaoBtn, libaoEntity, adapter, isInstallRequired, null, entrance, sourceEntrance, listener);
}
SensorsBridge.trackEvent("GameGiftDraw",
"gift_type", "普通礼包",
"game_name", libaoEntity.getGame().getName(),
"game_id", libaoEntity.getGame().getId(),
"gift_id", libaoEntity.getId(),
"gift_name", libaoEntity.getName(),
"source_entrance", sourceEntrance
);
break;
case "再淘":
case "再淘一个":
case "淘号":
libaoTao(context, libaoBtn, libaoEntity, isInstallRequired, adapter, status, entrance, sourceEntrance, listener);
SensorsBridge.trackEvent("GameGiftDraw",
"gift_type", "淘号礼包",
"game_name", libaoEntity.getGame().getName(),
"game_id", libaoEntity.getGame().getId(),
"gift_id", libaoEntity.getId(),
"gift_name", libaoEntity.getName(),
"source_entrance", sourceEntrance
);
break;
}
});
@ -547,7 +515,6 @@ public class LibaoUtils {
try {
JSONObject errorJson = new JSONObject(exception.response().errorBody().string());
String detail = errorJson.getString("detail").toLowerCase();
int code = errorJson.getInt("code");
switch (detail) {
case "coming":
Utils.toast(context, "礼包领取时间未开始");
@ -578,13 +545,7 @@ public class LibaoUtils {
Utils.toast(context, "淘号失败,稍后重试");
break;
default:
if (code == 403211) {
Utils.toast(context, "条件不符,请先提交游戏评价");
} else if (code == 403212) {
Utils.toast(context, "条件不符,请修改游戏评价");
} else {
Utils.toast(context, "操作失败");
}
Utils.toast(context, "操作失败");
break;
}
@ -702,7 +663,6 @@ public class LibaoUtils {
String string = exception.response().errorBody().string();
JSONObject errorJson = new JSONObject(string);
String detail = errorJson.getString("detail").toLowerCase();
int code = errorJson.getInt("code");
switch (detail) {
case "coming":
Utils.toast(context, "礼包领取时间未开始");
@ -742,13 +702,7 @@ public class LibaoUtils {
Utils.toast(context, "网络状态异常,请稍后再试");
break;
default:
if (code == 403211) {
Utils.toast(context, "条件不符,请先提交游戏评价");
} else if (code == 403212) {
Utils.toast(context, "条件不符,请修改游戏评价");
} else {
Utils.toast(context, "操作失败");
}
Utils.toast(context, "操作失败");
break;
}
} catch (Exception ex) {

View File

@ -2779,44 +2779,6 @@ object NewFlatLogUtils {
}.let(::log)
}
/**
* 广告游戏填充
* 广告游戏填充到广告位置时,上报该广告游戏插入的位置信息(用于数据回收验证策略的效果,无须曝光,只要请求了广告,就上报)
*/
fun logAdRequest(
pageLevel: String,
currentPageCode: String,
currentPageId: String,
gameName: String,
gameId: String,
moduleType: String,
moduleStyle: String,
moduleName: String,
moduleId: String,
searchContent: String,
sequence: Int,
outerSequence: Int,
adGroupId: String,
) {
json {
KEY_EVENT to "ad_request"
"page_level" to pageLevel
"current_page_code" to currentPageCode
"current_page_id" to currentPageId
KEY_GAME_NAME to gameName
KEY_GAME_ID to gameId
"module_type" to moduleType
"module_style" to moduleStyle
"module_name" to moduleName
"module_id" to moduleId
"search_content" to searchContent
"sequence" to sequence
"outer_sequence" to outerSequence
"ad_group_id" to adGroupId
parseAndPutMeta()(this)
}.let(::log)
}
// 自有开屏广告加载
fun logSplashAdLoad(id: String) {
json {

View File

@ -64,6 +64,8 @@ object PackageInstaller {
showUnzipToast: Boolean,
ignoreAsVGame: Boolean,
) {
val pkgPath = downloadEntity.path
val isXapk = XapkInstaller.XAPK_EXTENSION_NAME == pkgPath.getExtension()
val isDownloadAsVGame = downloadEntity.getMetaExtra(Constants.EXTRA_DOWNLOAD_TYPE) == Constants.VGAME
|| downloadEntity.getMetaExtra(Constants.EXTRA_DOWNLOAD_TYPE) == Constants.DUAL_DOWNLOAD_VGAME
@ -97,7 +99,7 @@ object PackageInstaller {
context.startActivity(mainIntent)
Runtime.getRuntime().exit(0)
} else {
if (XapkInstaller.isXapk(downloadEntity)) {
if (isXapk) {
XapkInstaller.install(context, downloadEntity, showUnzipToast)
} else {
install(context, downloadEntity.isPlugin, downloadEntity.path, downloadEntity)
@ -209,6 +211,9 @@ object PackageInstaller {
pkgPath: String,
sessionId: Int = -1
) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
return
}
val installer = context.packageManager.packageInstaller
val session = installer.openSession(sessionId)
// 监听安装回调的组件可以是Activity、Service或者是BroadcastReceiver

View File

@ -80,8 +80,6 @@ object ReservationHelper {
"last_page_id", getLastPageEntity().pageId,
"last_page_business_id", getLastPageEntity().pageBusinessId,
"source", game?.exposureEvent?.source?.toString() ?: "",
"is_ad", if (game?.adGroupId.isNullOrEmpty() == true) "false" else "true",
"ad_group_id", game?.adGroupId ?: "",
*game?.customPageTrackData?.toKV() ?: arrayOf()
)
@ -120,8 +118,6 @@ object ReservationHelper {
"last_page_id", getLastPageEntity().pageId,
"last_page_business_id", getLastPageEntity().pageBusinessId,
"source", game?.exposureEvent?.source?.toString() ?: "",
"is_ad", if (game?.adGroupId.isNullOrEmpty() == true) "false" else "true",
"ad_group_id", game?.adGroupId ?: "",
*game?.customPageTrackData?.toKV() ?: arrayOf()
)
ToastUtils.showToast(exception.message ?: "")

View File

@ -20,7 +20,6 @@ import com.gh.gamecenter.common.utils.setDrawableEnd
import com.gh.gamecenter.common.utils.toColor
import com.gh.gamecenter.entity.SubjectSettingEntity
import com.google.android.flexbox.FlexboxLayout
import splitties.views.leftPadding
class ConfigFilterView @JvmOverloads constructor(
context: Context,
@ -214,10 +213,6 @@ class ConfigFilterView @JvmOverloads constructor(
fun initSubjectFilterView(subjectSetting: SubjectSettingEntity) {
ratingTv.visibility = View.VISIBLE
if (subjectSetting.typeEntity.layout == "hide") {
container.leftPadding = 8F.dip2px()
}
if (subjectSetting.filterOptions.size > 1) {
// 重排序
subjectSetting.filterOptions.forEachIndexed { index, s ->

View File

@ -0,0 +1,15 @@
package com.gh.common.xapk
import com.lightgame.download.DownloadEntity
interface IXapkUnzipListener {
fun onProgress(downloadEntity: DownloadEntity, unzipPath: String, unzipSize: Long, unzipProgress: Long)
fun onNext(downloadEntity: DownloadEntity, unzipPath: String)
fun onCancel(downloadEntity: DownloadEntity)
fun onFailure(downloadEntity: DownloadEntity, exception: Exception)
fun onSuccess(downloadEntity: DownloadEntity)
}

View File

@ -52,12 +52,6 @@ import com.gh.gamecenter.core.utils.SPUtils
*
* obb文件直接解压至根目录即可,无需操作文件
* apk文件这解压的gh-files文件夹中
*
* update: 2025/4/29
* 简单来说有两种XAPK文件的格式
* XAPK = Android App Bundle基础APK + 配置APK) 【downloadentity.format == xapk(apks)】
* XAPK = APK文件 + OBB数据文件 【downloadentity.format == xapk】
*
*/
@SuppressLint("StaticFieldLeak")
object XapkInstaller : XApkUnZipCallback, XApkUnZipOutputFactory {
@ -98,90 +92,85 @@ object XapkInstaller : XApkUnZipCallback, XApkUnZipOutputFactory {
private val mPendingSessionInfoMap = HashMap<String, XapkPendingSessionInfo>()
fun isXapk(downloadEntity: DownloadEntity) = XAPK_EXTENSION_NAME == downloadEntity.path.getExtension()
private fun isXapkApks(downloadEntity: DownloadEntity) = downloadEntity.format == Constants.XAPK_APKS_FORMAT
/**
* precondition: assert_true(isXapk())
*
*/
// 按并行解压
@JvmStatic
fun install(context: Context, downloadEntity: DownloadEntity, showUnzipToast: Boolean = false) {
this.mContext = context
val isXapkApks = isXapkApks(downloadEntity)
if (isXapkApks && MiuiUtils.isMiui() && !MiuiUtils.isMiuiOptimizationDisabled()) {
// 小米手机开启miui以后需要引导用户关闭miui优化
DialogHelper.showMiuiOptimizationWarning(
context,
downloadEntity,
onHintClick = {
val guides = Config.getNewApiSettingsEntity()?.install
val miuiOptimizationGuide = guides?.guides?.findLast {
it.type == GUIDE_TYPE_MIUI_OPTIMIZATION
}
if (miuiOptimizationGuide != null) {
DirectUtils.directToLinkPage(
context,
miuiOptimizationGuide.link,
MIUI_OPTIMIZATION_WARNING_DIALOG_ENTRANCE,
""
)
}
},
onConfirmClick = {
if (SystemUtils.isDevelopmentSettingsEnabled(context)) {
context.startActivity(
Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
)
it.markDismissByTouchInside()
it.dismiss()
} else {
ToastUtils.showToast(context.getString(R.string.miui_open_adb_hint))
}
}
)
return
}
PermissionHelper.checkManageAllFilesOrStoragePermissionBeforeAction(context) {
val unzipAction = {
DownloadManager.getInstance().getDownloadEntitySnapshot(downloadEntity.url, downloadEntity.gameId)
?.let {
unzipXapkFile(it, isXapkApks)
if (showUnzipToast) {
Utils.toast(mContext, "解压过程请勿退出光环助手!")
val filePath = downloadEntity.path
if (XAPK_EXTENSION_NAME == filePath.getExtension()) {
if (MiuiUtils.isMiui() && !MiuiUtils.isMiuiOptimizationDisabled() && downloadEntity.format == Constants.XAPK_APKS_FORMAT) {// 小米手机开启miui以后需要引导用户关闭miui优化
DialogHelper.showMiuiOptimizationWarning(
context,
downloadEntity,
onHintClick = {
val guides = Config.getNewApiSettingsEntity()?.install
val miuiOptimizationGuide = guides?.guides?.findLast {
it.type == GUIDE_TYPE_MIUI_OPTIMIZATION
}
if (miuiOptimizationGuide != null) {
DirectUtils.directToLinkPage(
context,
miuiOptimizationGuide.link,
MIUI_OPTIMIZATION_WARNING_DIALOG_ENTRANCE,
""
)
}
},
onConfirmClick = {
if (SystemUtils.isDevelopmentSettingsEnabled(context)) {
context.startActivity(
Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
)
it.markDismissByTouchInside()
it.dismiss()
} else {
ToastUtils.showToast(context.getString(R.string.miui_open_adb_hint))
}
}
)
return
}
// XAPK (apks) 格式,不在乎 obb 文件夹是否可读
if (isXapkApks) {
unzipAction.invoke()
return@checkManageAllFilesOrStoragePermissionBeforeAction
}
// 以 file 的方式访问 obb 文件夹是否可行
val isFileStyleObbFolderReadable =
if (systemHasFlaw) {
File(Environment.getExternalStorageDirectory().path, "\u200bAndroid/obb").list() != null
} else {
File(Environment.getExternalStorageDirectory().path, "Android/obb").list() != null
PermissionHelper.checkManageAllFilesOrStoragePermissionBeforeAction(context) {
val unzipAction = {
DownloadManager.getInstance().getDownloadEntitySnapshot(downloadEntity.url, downloadEntity.gameId)
?.let {
unzipXapkFile(it)
if (showUnzipToast) {
Utils.toast(mContext, "解压过程请勿退出光环助手!")
}
}
}
// 如果是文件夹风格的 obb 文件夹可读,或当前上下文不是 AppCompatActivity或当前上下文已经被销毁则直接解压
if (isFileStyleObbFolderReadable
|| context !is AppCompatActivity
|| context.isFinishing
) {
unzipAction.invoke()
} else {
unzipWithCulpritHandled(context, downloadEntity.url, unzipAction)
// XAPK (apks) 格式,不在乎 obb 文件夹是否可读
if (downloadEntity.format == Constants.XAPK_APKS_FORMAT) {
unzipAction.invoke()
return@checkManageAllFilesOrStoragePermissionBeforeAction
}
// 以 file 的方式访问 obb 文件夹是否可行
val isFileStyleObbFolderReadable =
if (systemHasFlaw) {
File(Environment.getExternalStorageDirectory().path, "\u200bAndroid/obb").list() != null
} else {
File(Environment.getExternalStorageDirectory().path, "Android/obb").list() != null
}
// 如果是文件夹风格的 obb 文件夹可读,或当前上下文不是 AppCompatActivity或当前上下文已经被销毁则直接解压
if (isFileStyleObbFolderReadable
|| context !is AppCompatActivity
|| context.isFinishing
) {
unzipAction.invoke()
} else {
unzipWithCulpritHandled(context, downloadEntity.url, unzipAction)
}
}
} else {
throwExceptionInDebug("如果是Apk包请使用PackageInstaller进行安装")
PackageInstaller.install(mContext, downloadEntity)
}
}
@ -261,8 +250,13 @@ object XapkInstaller : XApkUnZipCallback, XApkUnZipOutputFactory {
}
}
private fun unzipXapkFile(downloadEntity: DownloadEntity, isXapkApks: Boolean) {
XApkUnZipEntry(downloadEntity.path, File(downloadEntity.path), isXapkApks).let(mXApkUnZipper::unzip)
private fun unzipXapkFile(downloadEntity: DownloadEntity) {
mXApkUnZipper.unzip(
XApkUnZipEntry(
downloadEntity.path,
File(downloadEntity.path)
)
)
mDownloadEntityMap[downloadEntity.path] = downloadEntity
}
@ -475,16 +469,13 @@ object XapkInstaller : XApkUnZipCallback, XApkUnZipOutputFactory {
mPendingSessionInfoMap[downloadEntity.path] = XapkPendingSessionInfo(downloadEntity.path, sessionId)
AppExecutor.ioExecutor.execute {// 有可能卡顿造成anr
try {
PackageInstaller.installMultiple(
applicationContext,
downloadEntity.packageName,
downloadEntity.path,
sessionId
)
NDataChanger.notifyDataChanged(downloadEntity)
} catch (ignore: Exception) {
}
PackageInstaller.installMultiple(
applicationContext,
downloadEntity.packageName,
downloadEntity.path,
sessionId
)
NDataChanger.notifyDataChanged(downloadEntity)
}
}
}

View File

@ -0,0 +1,243 @@
package com.gh.common.xapk
import android.os.Build
import android.os.Environment
import com.gh.gamecenter.BuildConfig
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.core.utils.MD5Utils
import com.halo.assistant.HaloApp
import com.lightgame.download.DownloadEntity
import com.lightgame.utils.Utils
import net.lingala.zip4j.progress.ProgressMonitor
import java.io.File
import java.util.zip.ZipFile
class XapkUnzipThread(
private var mDownloadEntity: DownloadEntity,
private var mUnzipListener: IXapkUnzipListener
) : Thread() {
private val mDefaultBufferSize = 1024 * 1024
var canceled = false
override fun run() {
super.run()
try {
val path = mDownloadEntity.path
var unzipSize = 0L
try {
unzipSize = getUnzipSize(path)
} catch (e: Exception) {
planB()
return
}
val msg = FileUtils.isCanDownload(HaloApp.getInstance().application, unzipSize)
if (!msg.isNullOrEmpty()) {
// 空间不足应该不用刷新页面,保持不变就好
Utils.toast(HaloApp.getInstance().application, "设备存储空间不足,请清理后重试!")
mUnzipListener.onCancel(mDownloadEntity)
return
}
var unzipProgress = 0L
val absolutePath = Environment.getExternalStorageDirectory().absolutePath
val xapkFile = File(path)
val unzipClosure: (zip: ZipFile) -> Unit = { zip ->
for (zipEntry in zip.entries().asSequence()) {
val outputFile = if (zipEntry.name.getExtension() == XapkInstaller.XAPK_DATA_EXTENSION_NAME) {
File(absolutePath + File.separator + zipEntry.name)
} else if (zipEntry.name.getExtension() == XapkInstaller.PACKAGE_EXTENSION_NAME) {
// apk文件名称 = xapk文件名 + MD5(本身的文件名称) + ".apk"
// 如 abc_com.gh.gamecenter.apk 这样的文件名,在使用浏览器安装时系统浏览器可能会抹掉文件类型,导致无法唤起下载完自动安装,这里去掉多个 "." 号,保证浏览器安装正常使用
val fileName = xapkFile.nameWithoutExtension + "_" + MD5Utils.getContentMD5(zipEntry.name) + "." + XapkInstaller.PACKAGE_EXTENSION_NAME
File(FileUtils.getDownloadPath(HaloApp.getInstance().application, fileName))
} else continue // 暂时只需要解压xpk/obb文件
if (zipEntry.isDirectory) {
if (!outputFile.exists()) {
throwException("unzip create file path failure", !outputFile.mkdirs())
}
continue
}
if (!outputFile.parentFile.exists()) {
throwException("unzip create file path failure", !outputFile.parentFile.mkdirs())
}
// 如果存在同名且大小一致,可以认为该文件已经解压缩(在不解压缩的情况下如果如果获取压缩文件的MD5????)
if (!outputFile.exists()) {
throwException("unzip create file failure", !outputFile.createNewFile())
} else if (outputFile.length() != zipEntry.size) {
throwException("unzip delete existing file failure", !outputFile.delete())
throwException("unzip create file failure", !outputFile.createNewFile())
} else {
unzipProgress += zipEntry.size
mUnzipListener.onProgress(mDownloadEntity, outputFile.path, unzipSize, unzipProgress)
mUnzipListener.onNext(mDownloadEntity, outputFile.path)
continue
}
// unzip
zip.getInputStream(zipEntry).use { input ->
outputFile.outputStream().use { output ->
val buffer = ByteArray(mDefaultBufferSize)
var bytes = input.read(buffer)
while (bytes >= 0) {
output.write(buffer, 0, bytes)
unzipProgress += bytes
bytes = input.read(buffer)
if (canceled) {
mUnzipListener.onCancel(mDownloadEntity)
return@use
} else {
// 防止多次短时间内多次触发onProgress方法导致阻塞主线程低端机会出现十分明显的卡顿
debounceActionWithInterval(-1, 500) {
mUnzipListener.onProgress(
mDownloadEntity,
outputFile.path,
unzipSize,
unzipProgress
)
}
}
}
}
}
mUnzipListener.onNext(mDownloadEntity, outputFile.path)
}
}
// Kotlin 1.4.X 在安卓 4.4 以下使用 use 默认关闭 ZipFile 的流时会触发
// java.lang.IncompatibleClassChangeError: interface not implemented 的 Error (Throwable)
// 但实测是不影响解压的,所以这里换用 let 不关闭流,确保不闪退,并且不影响解压结果
// 帮用户解压了,但游戏能不能安装就看天吧 (毕竟支持4.X的游戏也不多了)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
ZipFile(File(path)).use { unzipClosure.invoke(it) }
} else {
ZipFile(File(path)).let { unzipClosure.invoke(it) }
}
mUnzipListener.onSuccess(mDownloadEntity)
} catch (e: Exception) {
if (BuildConfig.DEBUG) throw e
mUnzipListener.onFailure(mDownloadEntity, e)
}
}
/**
* 部分未知情况(有可能是项目配置问题有可能时Zip包破损)原生的ZipFile无法打开压缩包,则启动以下备用方案
* 具体复现机型:小米 9(Android 9)
* 具体复现的压缩包:太空竞速2 具体可以咨询陈思雨
*
* 实现方式请参考:https://github.com/srikanth-lingala/zip4j
* 注意使用该库的ZipInputStream依然无法解压,提示头文件丢失
*
* 后续如果有需要可以直接使用该方法进行解压
*/
private fun planB() {
val zipPath = mDownloadEntity.path
val absolutePath = Environment.getExternalStorageDirectory().absolutePath
val zipFile = net.lingala.zip4j.ZipFile(zipPath)
val progressMonitor = zipFile.progressMonitor
zipFile.isRunInThread = true
val fileHeaders = zipFile.fileHeaders
var unzipSize = 0L
for (fileHeader in fileHeaders) {
unzipSize += fileHeader.uncompressedSize;
}
var unzipProgress = 0L
var completedSize = 0L
for (fileHeader in fileHeaders) {
if (canceled) {
mUnzipListener.onCancel(mDownloadEntity)
return
}
// 暂时只需要解压xpk/obb文件
val extension = fileHeader.fileName.getExtension()
if (extension != XapkInstaller.XAPK_DATA_EXTENSION_NAME && extension != XapkInstaller.PACKAGE_EXTENSION_NAME) continue
var unzipPath = ""
if (extension == XapkInstaller.XAPK_DATA_EXTENSION_NAME) {
unzipPath = absolutePath + File.separator + fileHeader.fileName
if (hasUnzipFile(unzipPath, fileHeader.uncompressedSize)) {
mUnzipListener.onNext(mDownloadEntity, unzipPath)
continue
}
zipFile.extractFile(fileHeader.fileName, absolutePath)
}
if (extension == XapkInstaller.PACKAGE_EXTENSION_NAME) {
val downloadDir = FileUtils.getDownloadDir(HaloApp.getInstance().application)
val unzipFileName = File(zipPath).nameWithoutExtension + "_" + fileHeader.fileName
unzipPath = downloadDir + File.separator + unzipFileName
if (hasUnzipFile(unzipPath, fileHeader.uncompressedSize)) {
mUnzipListener.onNext(mDownloadEntity, unzipPath)
continue
}
zipFile.extractFile(fileHeader.fileName, downloadDir, unzipFileName)
}
throwExceptionInDebug("check unzipPath", unzipPath.isEmpty())
// 回调太频繁了,变态吗? 4K回调一次,还不能改,FUCK
var filterCounter = 0
val filterInterval = 1024 * 10
while (progressMonitor.state != ProgressMonitor.State.READY) {
filterCounter++
if (filterCounter % filterInterval == 0) {
unzipProgress = completedSize + progressMonitor.workCompleted
mUnzipListener.onProgress(mDownloadEntity, unzipPath, unzipSize, unzipProgress)
if (canceled) {
progressMonitor.isCancelAllTasks = true
mUnzipListener.onCancel(mDownloadEntity)
return
}
}
}
completedSize += fileHeader.uncompressedSize
mUnzipListener.onNext(mDownloadEntity, unzipPath)
}
mUnzipListener.onSuccess(mDownloadEntity)
}
private fun hasUnzipFile(unzipPath: String, uncompressedSize: Long): Boolean {
val unzipFile = File(unzipPath)
if (unzipFile.exists() || unzipFile.length() == uncompressedSize) return true
return false
}
private fun getUnzipSize(path: String): Long {
var totalSize = 0L
val calculateSizeClosure: (zip: ZipFile) -> Unit = { zip ->
for (entry in zip.entries()) {
totalSize += entry.size
}
}
// Kotlin 1.4.X 在安卓 4.4 以下使用 use 默认ZipFile 的流时会触发
// java.lang.IncompatibleClassChangeError: interface not implemented 的 Error (Throwable)
// 实测是不影响解压,所以这里换用 let 不关闭流,确保不闪退
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
ZipFile(File(path)).use { calculateSizeClosure.invoke(it) }
} else {
ZipFile(File(path)).let { calculateSizeClosure.invoke(it) }
}
return totalSize
}
}

View File

@ -60,7 +60,6 @@ import com.gh.ndownload.NDownloadBridge;
import com.gh.ndownload.NDownloadService;
import com.gh.vspace.VHelper;
import com.halo.assistant.HaloApp;
import com.lg.vspace.archive.common.Const;
import com.lightgame.download.DataWatcher;
import com.lightgame.download.DownloadConfig;
import com.lightgame.download.DownloadDao;
@ -414,9 +413,6 @@ public class DownloadManager implements DownloadStatusListener {
// 将下载事件放入 downloadEntity 中供下载完成时取出使用
downloadEntity.setExposureTrace(GsonUtils.toJson(downloadExposureEvent));
// 记录广告组 id
ExtensionsKt.addMetaExtra(downloadEntity, Constants.AD_GROUP_ID, gameEntity.getAdGroupId());
// 保存所有游戏标签
List<String> tags = new ArrayList<>();
for (TagStyleEntity tag : gameEntity.getTagStyle()) {
@ -449,9 +445,7 @@ public class DownloadManager implements DownloadStatusListener {
"game_name", gameEntity.getName(),
"game_id", gameEntity.getId(),
"game_type", gameEntity.getCategoryChinese(),
"game_schema_type", gameEntity.getGameBitChinese(),
"is_ad", TextUtils.isEmpty(gameEntity.getAdGroupId()) ? "false" : "true",
"ad_group_id", gameEntity.getAdGroupId(),
"game_schema_type", gameEntity.getGameBitChinese()
};
List<String> vaList = new ArrayList<>(Arrays.asList(vaKvs));
if (customPageTrackData != null) {
@ -481,8 +475,6 @@ public class DownloadManager implements DownloadStatusListener {
"game_id", gameEntity.getId(),
"game_name", gameEntity.getName(),
"game_type", gameEntity.getCategoryChinese(),
"is_ad", TextUtils.isEmpty(gameEntity.getAdGroupId()) ? "false" : "true",
"ad_group_id", gameEntity.getAdGroupId(),
"game_label", String.join(",", tags),
"game_schema_type", gameEntity.getGameBitChinese(),
"page_name", GlobalActivityManager.getCurrentPageEntity().getPageName(),

View File

@ -76,8 +76,6 @@ import com.gh.gamecenter.common.entity.SuggestType;
import com.gh.gamecenter.common.eventbus.EBNetworkState;
import com.gh.gamecenter.common.eventbus.EBReuse;
import com.gh.gamecenter.common.exposure.meta.MetaUtil;
import com.gh.gamecenter.common.pagelevel.PageLevel;
import com.gh.gamecenter.common.pagelevel.PageLevelManager;
import com.gh.gamecenter.common.retrofit.BiResponse;
import com.gh.gamecenter.common.retrofit.Response;
import com.gh.gamecenter.common.utils.DialogHelper;
@ -90,6 +88,7 @@ import com.gh.gamecenter.core.AppExecutor;
import com.gh.gamecenter.core.utils.ClassUtils;
import com.gh.gamecenter.core.utils.DisplayUtils;
import com.gh.gamecenter.core.utils.GsonUtils;
import com.gh.gamecenter.core.utils.MtaHelper;
import com.gh.gamecenter.core.utils.SPUtils;
import com.gh.gamecenter.core.utils.ToastUtils;
import com.gh.gamecenter.core.utils.UrlFilterUtils;
@ -229,6 +228,9 @@ public class MainActivity extends BaseActivity {
},
() -> {
DirectUtils.directToSuggestion(MainActivity.this, SuggestType.APP, "APP闪退", false, 100);
MtaHelper.onEventWithBasicDeviceInfo(
"闪退弹窗",
"玩家操作", "点击反馈");
return null;
});
} else {
@ -236,9 +238,17 @@ public class MainActivity extends BaseActivity {
, "暂不", "马上反馈",
() -> {
DirectUtils.directToSuggestion(MainActivity.this, SuggestType.APP, "APP闪退", false, 100);
MtaHelper.onEventWithBasicDeviceInfo(
"闪退弹窗",
"玩家操作", "点击反馈");
return null;
},
() -> null);
() -> {
MtaHelper.onEventWithBasicDeviceInfo(
"闪退弹窗",
"玩家操作", "点击关闭");
return null;
});
}
}
@ -383,6 +393,7 @@ public class MainActivity extends BaseActivity {
HistoryHelper.deleteAttentionVideoRecord();
}
});
}
}
@ -1099,28 +1110,6 @@ public class MainActivity extends BaseActivity {
}
}
@Override
public void initPageLevel(@Nullable Bundle savedInstanceState) {
if (savedInstanceState != null) {
if (savedInstanceState.getParcelable(PageLevelManager.KEY_PAGE_LEVEL) != null) {
mPageLevel = savedInstanceState.getParcelable(PageLevelManager.KEY_PAGE_LEVEL);
}
}
if (mPageLevel == null) {
mPageLevel = new PageLevel(
PageLevel.TYPE_T,
-1,
-1,
new HashMap<>(),
-1,
null);
}
PageLevelManager.INSTANCE.setCurrentPageLevel(mPageLevel);
}
@Override
public Pair<String, String> getBusinessId() {
if (mMainWrapperFragment != null) {

View File

@ -330,9 +330,6 @@ class SplashScreenActivity : BaseActivity(), ISplashScreen {
}
}
override fun initPageLevel(savedInstanceState: Bundle?) {
// do nothing
}
companion object {
private const val KEY_REGISTRATION_ID = "registration_id"

View File

@ -422,66 +422,9 @@ public class LibaoDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
ExtensionsKt.setDrawableEnd(holder.binding.libaodetailCondition, com.gh.gamecenter.common.R.drawable.ic_libao_activity_arrow, null, null);
holder.binding.libaodetailCondition.setCompoundDrawablePadding(DisplayUtils.dip2px(4F));
}
} else if (mLibaoDetailEntity.getReceiveCondition() != null) {
holder.binding.libaodetailCondition.setVisibility(View.VISIBLE);
holder.binding.libaodetailConditionDescTv.setVisibility(View.VISIBLE);
holder.binding.libaodetailCondition.setText("领取条件:");
holder.binding.libaodetailConditionDescTv.setText(
getConditionDescText(
mGameEntity.getName(),
mLibaoDetailEntity.getReceiveCondition().getStar(),
mLibaoDetailEntity.getReceiveCondition().getWords()
)
);
}
}
/**
* 根据评分和字数限制生成文案。
*
* @param gameName 游戏名称
* @param star 评分选项 (-1: 无限制, 5: 5星好评, 4: 4星及以上, 3: 3星及以上, 2: 2星及以上, 1: 1星及以上)
* @param words 字数限制 (-1: 无限制, n: 字数不少于n)
* @return 生成的文案
*/
private String getConditionDescText(String gameName, int star, int words) {
StringBuilder text = new StringBuilder();
text.append("发表《").append(gameName).append("");
if (words == -1) {
text.append("的游戏评价");
} else {
text.append("不少于").append(words).append("字的游戏评价");
}
if (star != -1) {
text.append("并给予");
switch (star) {
case 5:
text.append("5星好评");
break;
case 4:
text.append("4星及以上评分");
break;
case 3:
text.append("3星及以上评分");
break;
case 2:
text.append("2星及以上评分");
break;
case 1:
text.append("1星及以上评分");
break;
default:
//throw new IllegalArgumentException("Invalid star value: " + star); // 或者返回一个默认值,比如空字符串或错误消息
return ""; // or return a default string or throw an exception.
}
}
return text.toString();
}
public LibaoEntity getLibaoEntity() {
return mLibaoEntity;
}

View File

@ -135,7 +135,7 @@ class DetailViewHolder(
vUpdate = view.findViewById(R.id.v_update)
tvUpdate = view.findViewById(R.id.tv_update)
context = view.context.getActivity() ?: view.context
context = view.context
com.gh.gamecenter.common.R.color.text_aw_primary.toColor()
var gameDownloadMode = gameEntity.getGameDownloadButtonMode()
@ -605,8 +605,6 @@ class DetailViewHolder(
"last_page_id", getLastPageEntity().pageId,
"last_page_business_id", getLastPageEntity().pageBusinessId,
"source", mGameEntity.exposureEvent?.source?.toString() ?: "",
"is_ad", if (mGameEntity.adGroupId.isEmpty()) "false" else "true",
"ad_group_id", mGameEntity.adGroupId,
*mGameEntity.customPageTrackData?.toKV() ?: arrayOf()
)
CheckLoginUtils.checkLogin(mViewHolder.context, mEntrance) {

View File

@ -8,20 +8,14 @@ import com.gh.gamecenter.common.utils.goneIf
import com.gh.gamecenter.core.utils.DisplayUtils
import com.gh.gamecenter.databinding.GameImageItemBinding
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.exposure.IExposureProvider
/**
* 游戏专题-大图-显示/只显示
*/
class GameImageViewHolder(var binding: GameImageItemBinding) : BaseRecyclerViewHolder<Any>(binding.root),
IExposureProvider {
private var boundedGameEntity: GameEntity? = null
class GameImageViewHolder(var binding: GameImageItemBinding) : BaseRecyclerViewHolder<Any>(binding.root) {
// 注意:专题详情的大图不能用此方法
fun bindImage(entity: GameEntity, applyRoundCorner: Boolean = false) {
boundedGameEntity = entity
binding.run {
gameContainer.goneIf(!(entity.type == "game" && entity.getApk().isNotEmpty()))
gameIcon.displayGameIcon(entity)
@ -34,17 +28,11 @@ class GameImageViewHolder(var binding: GameImageItemBinding) : BaseRecyclerViewH
if (applyRoundCorner) {
val roundingParams = RoundingParams.fromCornersRadius(
binding.root.resources.getDimensionPixelSize(com.gh.gamecenter.common.R.dimen.home_large_image_radius)
.toFloat()
binding.root.resources.getDimensionPixelSize(com.gh.gamecenter.common.R.dimen.home_large_image_radius).toFloat()
)
binding.gameImageIcon.hierarchy.roundingParams = roundingParams
}
ImageUtils.displayWithAdaptiveHeight(binding.gameImageIcon, entity.image, width)
}
override fun provideExposureData(): ExposureEvent? {
return boundedGameEntity?.exposureEvent?.getFreshExposureEvent()
}
}

View File

@ -28,6 +28,7 @@ class BannerAdapter(
private var mExposureSourceList = ArrayList<ExposureSource>()
init {
mItemData.exposureEventList = arrayListOf()
mExposureSourceList.addAll(mExposureSource)
mExposureSourceList.add(ExposureSource("精选页轮播图"))
}
@ -66,6 +67,7 @@ class BannerAdapter(
payload.sourcePageName = it[PageSwitchDataHelper.PAGE_BUSINESS_NAME]
}
}
mItemData.exposureEventList?.add(exposureEvent)
}
view.setOnClickListener {
@ -86,6 +88,12 @@ class BannerAdapter(
mBanners = banners
}
if (mItemData.exposureEventList != null) {
mItemData.exposureEventList?.clear()
mItemData = itemData
mItemData.exposureEventList = arrayListOf()
}
notifyDataSetChanged()
}
}

View File

@ -13,27 +13,27 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.gh.gamecenter.common.base.BaseRecyclerViewHolder
import com.gh.gamecenter.common.constant.ItemViewType
import com.gh.common.exposure.IExposable
import com.gh.common.util.*
import com.gh.gamecenter.R
import com.gh.gamecenter.common.viewholder.FooterViewHolder
import com.gh.gamecenter.common.baselist.ListAdapter
import com.gh.gamecenter.common.exposure.ExposureSource
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.core.runOnIoThread
import com.gh.gamecenter.core.utils.PageSwitchDataHelper
import com.gh.gamecenter.databinding.*
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.entity.SpecialCatalogEntity
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.exposure.IExposureProvider
import com.gh.gamecenter.subject.SubjectActivity.Companion.startSubjectActivity
class SpecialCatalogAdapter(
context: Context,
private val mCatalogViewModel: SpecialCatalogViewModel,
private val mLastPageDataMap: HashMap<String, String>? = null
) : ListAdapter<SpecialCatalogItemData>(context) {
) : ListAdapter<SpecialCatalogItemData>(context), IExposable {
private val mExposureEventSparseArray: SparseArray<ExposureEvent> = SparseArray()
var isAutoScroll = true
var isBannerSizeMoreThanOne = false
@ -153,8 +153,8 @@ class SpecialCatalogAdapter(
payload.sourcePageName = it[PageSwitchDataHelper.PAGE_BUSINESS_NAME]
}
}
mExposureEventSparseArray.append(position, exposureEvent)
}
holder.exposureEvent = exposureEvent
root.setOnClickListener {
DirectUtils.directToLinkPage(
mContext,
@ -208,32 +208,28 @@ class SpecialCatalogAdapter(
is CatalogSubjectItemHolder -> {
val subject = mEntityList[position].subject!!
runOnIoThread(isLightWeightTask = true) {
for ((index, game) in subject.link.data.withIndex()) {
game.sequence = index
game.subjectName = subject.link.text
game.outerSequence = mEntityList[position].position
val exposureList = arrayListOf<ExposureEvent>()
for ((index, game) in subject.link.data.withIndex()) {
game.sequence = index
game.subjectName = subject.link.text
game.outerSequence = mEntityList[position].position
val exposureEvent = ExposureEvent.createEventWithSourceConcat(
game,
mCatalogViewModel.basicExposureSource,
listOf(ExposureSource("精选页专题", subject.link.text ?: ""))
).apply {
mLastPageDataMap?.let {
payload.sourcePage = it[PageSwitchDataHelper.PAGE_BUSINESS_TYPE]
payload.sourcePageId = it[PageSwitchDataHelper.PAGE_BUSINESS_ID]
payload.sourcePageName = it[PageSwitchDataHelper.PAGE_BUSINESS_NAME]
}
}
game.exposureEvent = exposureEvent
if (game.adGroupId.isNotEmpty() && !game.isAdRequestReported) {
AdHelper.reportAdRequest(exposureEvent)
game.isAdRequestReported = true
val exposureEvent = ExposureEvent.createEventWithSourceConcat(
game,
mCatalogViewModel.basicExposureSource,
listOf(ExposureSource("精选页专题", subject.link.text ?: ""))
).apply {
mLastPageDataMap?.let {
payload.sourcePage = it[PageSwitchDataHelper.PAGE_BUSINESS_TYPE]
payload.sourcePageId = it[PageSwitchDataHelper.PAGE_BUSINESS_ID]
payload.sourcePageName = it[PageSwitchDataHelper.PAGE_BUSINESS_NAME]
}
}
exposureList.add(exposureEvent)
game.exposureEvent = exposureEvent
}
mEntityList[position].exposureEventList = exposureList
holder.bindSubject(subject.link.data, mEntityList[position].position)
}
@ -269,6 +265,10 @@ class SpecialCatalogAdapter(
}
}
override fun getEventByPosition(pos: Int): ExposureEvent? = mExposureEventSparseArray.get(pos)
override fun getEventListByPosition(pos: Int): List<ExposureEvent>? = mEntityList[pos].exposureEventList
inner class CatalogBannerItemHolder(val binding: CatalogBannerItemBinding) :
BaseRecyclerViewHolder<Any>(binding.root) {
@ -393,14 +393,7 @@ class SpecialCatalogAdapter(
}
}
inner class CatalogImageItemHolder(val binding: CatalogImageItemBinding) :
BaseRecyclerViewHolder<Any>(binding.root), IExposureProvider {
var exposureEvent: ExposureEvent? = null
override fun provideExposureData(): ExposureEvent? {
return exposureEvent?.getFreshExposureEvent()
}
}
inner class CatalogImageItemHolder(val binding: CatalogImageItemBinding) : BaseRecyclerViewHolder<Any>(binding.root)
inner class CatalogHeaderItemHolder(val binding: CatalogHeaderItemBinding) :
BaseRecyclerViewHolder<Any>(binding.root)

View File

@ -3,15 +3,14 @@ package com.gh.gamecenter.catalog
import android.os.Bundle
import android.view.View
import com.ethanhua.skeleton.Skeleton
import com.gh.common.exposure.DefaultExposureStateChangeListener
import com.gh.gamecenter.common.constant.Constants
import com.gh.common.exposure.ExposureListener
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.utils.viewModelProvider
import com.gh.gamecenter.R
import com.gh.gamecenter.common.baselist.ListFragment
import com.gh.gamecenter.common.utils.toColor
import com.gh.gamecenter.databinding.FragmentListBaseSkeletonBinding
import com.gh.gamecenter.feature.exposure.addExposureHelper
class SpecialCatalogFragment : ListFragment<SpecialCatalogItemData, SpecialCatalogViewModel>() {
@ -22,6 +21,8 @@ class SpecialCatalogFragment : ListFragment<SpecialCatalogItemData, SpecialCatal
private var mAdapter: SpecialCatalogAdapter? = null
private var mLastPageDataMap: HashMap<String, String>? = null
private lateinit var mExposureListener: ExposureListener
override fun getLayoutId() = 0
override fun getInflatedLayout() = mBinding.root
@ -42,6 +43,7 @@ class SpecialCatalogFragment : ListFragment<SpecialCatalogItemData, SpecialCatal
mLastPageDataMap
).apply {
mAdapter = this
mExposureListener = ExposureListener(this@SpecialCatalogFragment, this)
}
override fun getItemDecoration() = null
@ -49,6 +51,7 @@ class SpecialCatalogFragment : ListFragment<SpecialCatalogItemData, SpecialCatal
override fun isAutomaticLoad(): Boolean = false
override fun onCreate(savedInstanceState: Bundle?) {
mIsCategoryV2 = arguments?.getBoolean(EntranceConsts.KEY_IS_CATEGORY_V2) ?: false
mCatalogId = arguments?.getString(EntranceConsts.KEY_CATALOG_ID) ?: ""
mCatalogTitle = arguments?.getString(EntranceConsts.KEY_CATALOG_TITLE) ?: ""
@ -62,8 +65,6 @@ class SpecialCatalogFragment : ListFragment<SpecialCatalogItemData, SpecialCatal
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
mListRv.addExposureHelper(this, DefaultExposureStateChangeListener())
val skeletonLayoutId =
if (mIsCategoryV2) R.layout.fragment_special_catalog_second_skeleton else R.layout.fragment_special_catalog_first_skeleton
mSkeletonScreen = Skeleton.bind(mBinding.listSkeleton)
@ -76,6 +77,8 @@ class SpecialCatalogFragment : ListFragment<SpecialCatalogItemData, SpecialCatal
.load(skeletonLayoutId)
.show()
onLoadRefresh()
mListRv.addOnScrollListener(mExposureListener)
}
override fun onResume() {

View File

@ -1,5 +1,6 @@
package com.gh.gamecenter.catalog
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.entity.SpecialCatalogEntity
class SpecialCatalogItemData(
@ -10,4 +11,5 @@ class SpecialCatalogItemData(
val subjectCollection: SpecialCatalogEntity? = null,
var position: Int = 0,
var exposureEventList: ArrayList<ExposureEvent>? = null
)

View File

@ -9,8 +9,6 @@ import com.gh.gamecenter.common.utils.toBinding
import com.gh.gamecenter.common.utils.toColor
import com.gh.gamecenter.databinding.CatalogSubjectGameItemBinding
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.exposure.IExposureProvider
import com.lightgame.adapter.BaseRecyclerAdapter
class SpecialCatalogSubjectAdapter(
@ -43,8 +41,6 @@ class SpecialCatalogSubjectAdapter(
}
val entity = mList[position]
holder.bindGameEntity(entity)
gameIcon.displayGameIcon(entity)
gameName.text = entity.name
gameName.setTextColor(com.gh.gamecenter.common.R.color.text_primary.toColor(mContext))
@ -88,15 +84,5 @@ class SpecialCatalogSubjectAdapter(
}
class CatalogSubjectGameItemViewHolder(val binding: CatalogSubjectGameItemBinding) :
BaseRecyclerViewHolder<Any>(binding.root), IExposureProvider {
private var boundedGameEntity: GameEntity? = null
fun bindGameEntity(gameEntity: GameEntity) {
boundedGameEntity = gameEntity
}
override fun provideExposureData(): ExposureEvent? {
return boundedGameEntity?.exposureEvent?.getFreshExposureEvent()
}
}
BaseRecyclerViewHolder<Any>(binding.root)
}

View File

@ -35,6 +35,7 @@ class SpecialCatalogSubjectCollectionAdapter(
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) =
CatalogSubjectCollectionListItemViewHolder(parent.toBinding())
override fun onBindViewHolder(holder: CatalogSubjectCollectionListItemViewHolder, position: Int) {
holder.binding.run {
root.layoutParams = (root.layoutParams as ViewGroup.MarginLayoutParams).apply {

View File

@ -9,7 +9,6 @@ import com.gh.gamecenter.common.baselist.ListViewModel
import com.gh.gamecenter.common.entity.ExposureEntity
import com.gh.gamecenter.common.exposure.ExposureSource
import com.gh.gamecenter.entity.SpecialCatalogEntity
import com.gh.gamecenter.feature.exposure.ExposureConstants
import com.gh.gamecenter.retrofit.RetrofitManager
import com.halo.assistant.HaloApp
import io.reactivex.Observable
@ -61,8 +60,6 @@ class SpecialCatalogViewModel(
game.containerType =
if (mIsCategoryV2) ExposureEntity.CATEGORY_V2_ID else ExposureEntity.CATEGORY_ID
game.containerId = mCatalogId
game.subPageCode = ExposureConstants.CATEGORY_V2
game.subPageId = mCatalogId
}
}

View File

@ -28,11 +28,6 @@ class CategoryV2Activity : DownloadToolbarActivity() {
override fun isAutoResetViewBackgroundEnabled() = true
override fun getBusinessId(): Pair<String, String> {
val categoryId = intent.extras?.getString(EntranceConsts.KEY_CATEGORY_ID, "") ?: ""
return Pair(categoryId, "")
}
override fun onDarkModeChanged() {
super.onDarkModeChanged()
updateStatusBarColor(com.gh.gamecenter.common.R.color.ui_surface, com.gh.gamecenter.common.R.color.ui_surface)

View File

@ -290,6 +290,7 @@ class CategoryV2Fragment : LazyFragment() {
mEntity?.run {
viewModel.run {
clearSelectedTag()
childFragmentManager.fragments.find { it.isAdded }
val targetFragment =
if (hasSpecial && position == 1) {
val fragment = childFragmentManager.findFragmentByTag(SpecialCatalogFragment::class.java.name)
@ -318,6 +319,7 @@ class CategoryV2Fragment : LazyFragment() {
)
fragment
}
childFragmentManager
.beginTransaction()
.replace(R.id.gamesContainer, targetFragment, targetFragment::class.java.name)

View File

@ -1,11 +1,12 @@
package com.gh.gamecenter.category2
import android.content.Context
import android.util.SparseArray
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.gh.common.databind.BindingAdapters
import com.gh.common.util.AdHelper
import com.gh.common.exposure.IExposable
import com.gh.common.util.DownloadItemUtils
import com.gh.gamecenter.GameDetailActivity
import com.gh.gamecenter.adapter.viewholder.GameViewHolder
@ -16,7 +17,6 @@ import com.gh.gamecenter.common.exposure.ExposureSource
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.common.view.DrawableView
import com.gh.gamecenter.common.viewholder.FooterViewHolder
import com.gh.gamecenter.core.runOnIoThread
import com.gh.gamecenter.core.utils.PageSwitchDataHelper
import com.gh.gamecenter.core.utils.StringUtils
import com.gh.gamecenter.databinding.CategoryGameItemBinding
@ -24,7 +24,6 @@ import com.gh.gamecenter.eventbus.EBDownloadStatus
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.exposure.ExposureType
import com.gh.gamecenter.feature.exposure.IExposureProvider
import com.gh.gamecenter.feature.game.GameItemViewHolder
import com.lightgame.download.DownloadEntity
import org.json.JSONException
@ -36,7 +35,9 @@ class CategoryV2ListAdapter(
private val mCategoryViewModel: CategoryV2ViewModel,
private val mEntrance: String?,
private var mLastPageDataMap: HashMap<String, String>? = null
) : ListAdapter<GameEntity>(context) {
) : ListAdapter<GameEntity>(context), IExposable {
private val mExposureEventSparseArray: SparseArray<ExposureEvent> = SparseArray()
val positionAndPackageMap = HashMap<String, Int>()
@ -124,13 +125,7 @@ class CategoryV2ListAdapter(
payload.sourcePageName = it[PageSwitchDataHelper.PAGE_BUSINESS_NAME]
}
}
runOnIoThread(isLightWeightTask = true) {
if (gameEntity.adGroupId.isNotEmpty() && !gameEntity.isAdRequestReported) {
AdHelper.reportAdRequest(event)
gameEntity.isAdRequestReported = true
}
}
mExposureEventSparseArray.put(position, event)
holder.itemView.setOnClickListener {
GameDetailActivity.startGameDetailActivity(
@ -236,13 +231,17 @@ class CategoryV2ListAdapter(
}
}
override fun getEventByPosition(pos: Int): ExposureEvent? {
return mExposureEventSparseArray.get(pos)
}
override fun getEventListByPosition(pos: Int): List<ExposureEvent>? {
return null
}
inner class CategoryGameItemViewHolder(val binding: CategoryGameItemBinding) :
BaseRecyclerViewHolder<Any>(binding.root), IExposureProvider {
private var boundedGameEntity: GameEntity? = null
BaseRecyclerViewHolder<Any>(binding.root) {
fun bindGameItem(gameEntity: GameEntity) {
boundedGameEntity = gameEntity
binding.run {
gameIconView.displayGameIcon(gameEntity)
gameRating.textSize = if (gameEntity.commentCount > 3) 12F else 10F
@ -295,10 +294,6 @@ class CategoryV2ListAdapter(
// 由于RecyclerView的复用机制 需要每次测量gameName的宽
binding.gameName.requestLayout()
}
override fun provideExposureData(): ExposureEvent? {
return boundedGameEntity?.exposureEvent?.getFreshExposureEvent()
}
}
inner class CategoryGameViewHolder(val binding: CategoryGameItemBinding) : GameViewHolder(binding.root) {

View File

@ -6,7 +6,7 @@ import androidx.fragment.app.viewModels
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.ethanhua.skeleton.Skeleton
import com.gh.common.exposure.DefaultExposureStateChangeListener
import com.gh.common.exposure.ExposureListener
import com.gh.common.util.DialogUtils
import com.gh.common.view.CategoryFilterView
import com.gh.common.xapk.XapkInstaller
@ -24,8 +24,6 @@ import com.gh.gamecenter.databinding.FragmentCategoryListBinding
import com.gh.gamecenter.entity.SubjectSettingEntity
import com.gh.gamecenter.eventbus.EBDownloadStatus
import com.gh.gamecenter.eventbus.EBPackage
import com.gh.gamecenter.feature.exposure.addExposureHelper
import com.google.android.flexbox.FlexboxLayout
import com.gh.gamecenter.feature.entity.GameEntity
import com.lightgame.download.DataWatcher
import com.lightgame.download.DownloadEntity
@ -115,7 +113,7 @@ class CategoryV2ListFragment : ListFragment<GameEntity, CategoryV2ListViewModel>
onRefresh()
}
mListRv.addExposureHelper(this, DefaultExposureStateChangeListener())
mListRv.addOnScrollListener(ExposureListener(this, provideListAdapter()))
mSkeletonScreen = Skeleton.bind(mBinding?.listSkeleton)
.shimmer(true)

View File

@ -5,14 +5,12 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.gh.common.exposure.ExposureUtils
import com.gh.common.util.AdHelper
import com.gh.common.view.CategoryFilterView
import com.gh.gamecenter.common.baselist.ListViewModel
import com.gh.gamecenter.common.entity.ExposureEntity
import com.gh.gamecenter.common.exposure.ExposureSource
import com.gh.gamecenter.core.utils.UrlFilterUtils
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.exposure.ExposureConstants
import com.gh.gamecenter.retrofit.RetrofitManager
import com.halo.assistant.HaloApp
import io.reactivex.Observable
@ -35,7 +33,7 @@ class CategoryV2ListViewModel(
return RetrofitManager
.getInstance()
.api
.getCategoryV2Games(categoryId, getFilter(), getSortType(), AdHelper.getIdfaString(), page)
.getCategoryV2Games(categoryId, getFilter(), getSortType(), page)
}
override fun mergeResultLiveData() {
@ -45,11 +43,7 @@ class CategoryV2ListViewModel(
containerId = categoryId,
containerType = ExposureEntity.CATEGORY_V2_ID
)
it.forEach { game ->
game.hideSizeInsideDes = true
game.subPageCode = ExposureConstants.CATEGORY_V2
game.subPageId = categoryId
}
it.forEach { game -> game.hideSizeInsideDes = true }
mResultLiveData.postValue(it)
}
}
@ -68,6 +62,7 @@ class CategoryV2ListViewModel(
"min_size", gameFiltered.size.min.toString(),
"max_size", gameFiltered.size.max.toString()
)
}
private fun getSortType(): String? {

View File

@ -166,7 +166,7 @@ class CategoryV2ViewModel : ViewModel() {
if (position != oldPosition) {
_selectedSidebarsPosition.value = position
// 如果是点击搜索而被动切换到 “全部” tab则这里不需要更新筛选条件
if (triggerSearch && position != INVALID_POSITION) {
if (triggerSearch && position != 1) {
updateGameFiltered()
}
}

View File

@ -33,10 +33,8 @@ import com.gh.gamecenter.discovery.interestedgame.InterestedGameActivity
import com.gh.gamecenter.entity.DiscoveryGameCardLabel
import com.gh.gamecenter.eventbus.EBDownloadStatus
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.exposure.ExposureConstants
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.exposure.ExposureType
import com.gh.gamecenter.feature.exposure.IExposureProvider
import com.gh.gamecenter.feature.game.GameItemViewHolder
import com.lightgame.download.DownloadEntity
@ -139,7 +137,6 @@ class DiscoveryAdapter(
if (mOuterSequence >= 0) {
outerSequence = mOuterSequence
}
subPageCode = ExposureConstants.DISCOVERY
},
mBaseExposureSource,
exposureSources,
@ -349,9 +346,7 @@ class DiscoveryAdapter(
return null
}
class DiscoveryGameViewHolder(val binding: DiscoveryGameItemBinding) : GameViewHolder(binding.root), IExposureProvider {
private var boundedGameEntity: GameEntity? = null
class DiscoveryGameViewHolder(val binding: DiscoveryGameItemBinding) : GameViewHolder(binding.root) {
init {
gameDownloadBtn = binding.downloadBtn
gameDes = binding.gameDes
@ -363,7 +358,6 @@ class DiscoveryAdapter(
}
fun bindGameItem(gameEntity: GameEntity) {
boundedGameEntity = gameEntity
binding.run {
root.background = com.gh.gamecenter.common.R.drawable.reuse_listview_item_style.toDrawable(root.context)
gameKaifuType.setBackgroundColor(com.gh.gamecenter.common.R.color.primary_theme.toColor(root.context))
@ -421,12 +415,9 @@ class DiscoveryAdapter(
)
}
}
override fun provideExposureData(): ExposureEvent? {
return boundedGameEntity?.exposureEvent?.getFreshExposureEvent()
}
}
class RecommendInterestViewHolder(val binding: ItemRecommendInterestBinding) :
BaseRecyclerViewHolder<Any>(binding.root)

View File

@ -9,7 +9,7 @@ import io.reactivex.Single
class GameSubjectDSPRemoteDataSource(private val api: DspApiService = RetrofitManager.getInstance().dspApiService) {
fun getDspGames(count: Int): Single<List<GameEntity>> {
fun getDspGames(type: String, count: Int): Single<List<GameEntity>> {
val meta = MetaUtil.getMeta()
val request = mapOf(
"device" to mapOf(

View File

@ -4,7 +4,6 @@ import android.os.Parcelable
import com.gh.gamecenter.common.entity.IconFloat
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.entity.TagStyleEntity
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.IgnoredOnParcel
import kotlinx.parcelize.Parcelize
@ -43,16 +42,12 @@ data class AmwayCommentEntity(
// 曝光用的位置
var sequence: Int = 0,
var outerSequence: Int = 0
) : Parcelable {
@IgnoredOnParcel
val name: String?
get() = mName.removeSuffix(".")
@IgnoredOnParcel
var exposureEvent: ExposureEvent? = null
fun toGameEntity(): GameEntity {
val gameEntity = GameEntity()
gameEntity.id = id

View File

@ -1,26 +0,0 @@
package com.gh.gamecenter.entity
import com.gh.gamecenter.servers.gametest2.GameServerTestV2ViewModel
import com.google.gson.annotations.SerializedName
data class GameServerTestDisplaySetting(
@SerializedName("time_text_past")
val timeTextPast: String = RECENT,
@SerializedName("time_text_present")
val timeTextPresent: String = TODAY,
@SerializedName("time_text_future")
val timeTextFuture: String = FUTURE,
@SerializedName("game_category")
val gameCategory: List<String> = listOf(
GameServerTestV2ViewModel.GameCategory.Local.value,
GameServerTestV2ViewModel.GameCategory.Online.value,
GameServerTestV2ViewModel.GameCategory.Welfare.value,
GameServerTestV2ViewModel.GameCategory.Gjonline.value
),
) {
companion object {
const val RECENT = "近期"
const val TODAY = "今天"
const val FUTURE = "预约"
}
}

View File

@ -13,14 +13,6 @@ class LibaoDetailEntity {
var des: String? = null
// 领取限制 发表游戏评价 (game_comment)
@SerializedName("receive_limit")
var receiveLimit: String? = ""
// 领取条件
@SerializedName("receive_condition")
var receiveCondition: Condition ? = null
@SerializedName("new_des")
var newDes: String? = null
@ -32,10 +24,4 @@ class LibaoDetailEntity {
@SerializedName("me")
var me: MeEntity? = null
class Condition(
// 评分,-1/5/4/3/2/1 => 无限制、5星好评、4星及以上评分、3星及以上评分、2星及以上评分、1星及以上评分
val star: Int = 0,
// 字数,-1/n => 无限制、数量
val words: Int = 0
)
}

View File

@ -1,33 +0,0 @@
package com.gh.gamecenter.entity
import com.gh.gamecenter.feature.entity.GameEntity
import com.google.gson.annotations.SerializedName
data class SearchGameUnionEntity(
@SerializedName("type")
private val _type: String? = null,
@SerializedName("link_game")
val linkGame: GameEntity? = null,
@SerializedName("link_wechat_game_cpm_column")
val linkWechatGameCpmColumn: SearchSubjectEntity? = null,
@SerializedName("link_dsp_game_column")
val linkDspGameColumn: SearchSubjectEntity? = null,
@SerializedName("link_wechat_game")
val linkWechatGame: GameEntity? = null,
@SerializedName("link_column")
val linkColum: SearchSubjectEntity? = null,
@SerializedName("link_ad_space")
val linkAdSpace: AdConfig? = null
) {
val type: String
get() = _type ?: ""
companion object {
const val TYPE_GAME = "game"
const val TYPE_WECHAT_GAME_CPM_COLUMN = "wechat_game_cpm_column"
const val TYPE_DSP_GAME_COLUMN = "dsp_game_column"
const val TYPE_WECHAT_GAME = "wechat_game"
const val TYPE_COLUMN = "column"
const val TYPE_AD_SPACE = "ad_space"
}
}

View File

@ -2,9 +2,8 @@ package com.gh.gamecenter.entity
import android.os.Parcelable
import com.gh.common.filter.RegionSettingHelper
import com.gh.gamecenter.entity.SearchGameUnionEntity.Companion.TYPE_DSP_GAME_COLUMN
import com.gh.gamecenter.entity.SearchGameUnionEntity.Companion.TYPE_WECHAT_GAME_CPM_COLUMN
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.personalhome.home.UserHistoryViewModel
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize
@ -19,6 +18,10 @@ data class SearchSubjectEntity(
val codeId: String = "", // 广告CODE_ID(本地字段),不为空时为广告专题
@SerializedName("ad_icon_active")
val adIconActive: Boolean = false,
// 本地字段标记是否为微信小游戏CPM专题
var isWGameSubjectCPM: Boolean = false,
// 本地字段标记是否为DSP专题
var isDspSubject: Boolean = false,
val type: String = "",
@SerializedName("column_type")
@ -28,11 +31,10 @@ data class SearchSubjectEntity(
val size: Int = -1, // 专题游戏数量
) : Parcelable {
val isWGameSubjectCPM: Boolean
get() = type == TYPE_WECHAT_GAME_CPM_COLUMN
val isDspSubject: Boolean
get() = type == TYPE_DSP_GAME_COLUMN
companion object {
const val TYPE_WECHAT_GAME_CPM_COLUMN = "wechat_game_cpm_column"
const val TYPE_DSP_GAME_COLUMN = "dsp_game_column"
}
fun getFilterGame() = RegionSettingHelper.filterGame(games)
}

View File

@ -122,9 +122,7 @@ data class SubjectEntity(
@SerializedName("column_type")
private val _columnType: String? = null,
@SerializedName("size")
private val _size: Size? = null,
@SerializedName("onlyFee")
private val _onlyFee: Boolean? = false,
private val _size: Size? = null
) : Parcelable {
@IgnoredOnParcel
@ -163,9 +161,6 @@ data class SubjectEntity(
val size: Size
get() = _size ?: Size()
val onlyFee: Boolean
get() = _onlyFee ?: false
var isDspSubject: Boolean = false
companion object {
@ -178,13 +173,9 @@ data class SubjectEntity(
@Parcelize
data class Size(
@SerializedName("index")
private val _index: Int? = null,
@SerializedName("limit")
private val _limit: Int? = null,
private val _index: Int? = null
) : Parcelable {
val index: Int
get() = _index ?: 0
val limit: Int
get() = _limit ?: -1
}
}

View File

@ -33,6 +33,7 @@ class FollowCommonCollectionViewHolder(
override fun addExposureEvent(childPosition: Int, link: ExposureLinkEntity) = Unit
override fun onChildItemClick(childPosition: Int, entity: CommonCollectionContentEntity) {
val linkEntity = entity.linkEntity
NewLogUtils.logCommonCollectionClick(

View File

@ -50,6 +50,9 @@ class FollowHomeSlideListViewHolder(
}
override fun updateImmersiveColor(color: Int) = Unit
override fun createExposureEvent(childPosition: Int, game: GameEntity?): ExposureEvent? = null
})
}

View File

@ -29,12 +29,15 @@ class FollowHomeSlideWithCardsViewHolder(
useCase,
lifecycleOwner,
binding,
0,
null,
"",
object : CommonContentHomeSlideWithCardsUi.HomeSLideWithCardsEventListener {
override fun updateImmersiveColor(color: Int) = Unit
override fun createEventWithSourceConcat(game: GameEntity, subSlideId: String) = Unit
override fun createExposureEvent(actualPosition: Int, game: GameEntity?): ExposureEvent? = null
override fun addGameExposureEvent(position: Int, game: GameEntity, subSlideId: String) = Unit
override fun navigateToGameDetailPage(
childPosition: Int,
gameEntity: GameEntity,

View File

@ -399,8 +399,7 @@ class GameFragmentAdapter(
position = prefixedPosition,
gameColumnName = gameEntity.name ?: "",
gameColumnId = gameEntity.link ?: "",
text = "游戏专题",
adGroupId = gameEntity.adGroupId
text = "游戏专题"
)
}
@ -575,7 +574,7 @@ class GameFragmentAdapter(
position = sequence,
gameColumnName = subject.name ?: "",
gameColumnId = subject.id ?: "",
text = "游戏专题",
text = "游戏专题"
)
}

View File

@ -21,8 +21,6 @@ import com.gh.gamecenter.common.viewholder.FooterViewHolder
import com.gh.gamecenter.core.utils.MtaHelper
import com.gh.gamecenter.core.utils.PageSwitchDataHelper
import com.gh.gamecenter.databinding.GameColumnCollectionItemBinding
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.exposure.ExposureConstants
import com.gh.gamecenter.feature.exposure.ExposureEvent
class ColumnCollectionDetailAdapter(
@ -97,13 +95,8 @@ class ColumnCollectionDetailAdapter(
text = "游戏专题"
)
}
val fakeGameEntity = GameEntity(_id = ExposureConstants.COLUMN_COLLECTION_DETAIL)
fakeGameEntity.subPageCode = ExposureConstants.COLUMN_COLLECTION_DETAIL
fakeGameEntity.subPageId = mViewModel.collectionId
val exposureEvent = ExposureEvent.createEventWithSourceConcat(
fakeGameEntity,
null,
mBasicExposureSourceList ?: arrayListOf(),
arrayListOf(
ExposureSource("合集详情", ""),

View File

@ -18,7 +18,6 @@ import com.gh.gamecenter.common.utils.goneIf
import com.gh.gamecenter.common.utils.toBinding
import com.gh.gamecenter.common.viewholder.FooterViewHolder
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.exposure.ExposureConstants
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.game.data.CommonContentCollectionDetailItem
import com.gh.gamecenter.game.data.CommonContentCollectionDetailRecommendCardItem
@ -143,8 +142,6 @@ class CustomCommonCollectionDetailAdapter(
ExposureEvent.createEventWithSourceConcat(
gameEntity.also {
it.sequence = position
it.subPageCode = ExposureConstants.CUSTOM_COMMON_COLLECTION_DETAIL
it.subPageId = commonCollectionEntity?.id ?: ""
},
basicSource = mBasicExposureSourceList ?: listOf(),
listOf(

View File

@ -18,8 +18,6 @@ import com.gh.gamecenter.gamedetail.detail.viewholder.BaseGameDetailItemViewHold
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.subjectTypeToComponentStyle
import com.lightgame.adapter.BaseRecyclerAdapter
import com.lightgame.download.DownloadEntity
import kotlin.collections.forEachIndexed
import kotlin.collections.isNotEmpty
class GameHorizontalAdapter(
context: Context,
@ -138,8 +136,7 @@ class GameHorizontalAdapter(
gameColumnName = subjectEntity.name ?: "",
gameColumnId = subjectEntity.id ?: "",
text = "游戏",
columnPattern = subjectTypeToComponentStyle[subjectEntity.type] ?: "",
adGroupId = gameEntity.adGroupId,
columnPattern = subjectTypeToComponentStyle[subjectEntity.type] ?: ""
)
}
}

View File

@ -6,22 +6,9 @@ import android.widget.TextView
import com.gh.gamecenter.common.base.BaseRecyclerViewHolder
import com.gh.gamecenter.databinding.GameHorizontalSimpleItemBinding
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.exposure.IExposureProvider
class GameHorizontalSimpleItemViewHolder(val binding: GameHorizontalSimpleItemBinding) :
BaseRecyclerViewHolder<GameEntity>(binding.root), IExposureProvider {
private var boundedGameEntity: GameEntity? = null
fun bindData(game: GameEntity) {
boundedGameEntity = game
}
override fun provideExposureData(): ExposureEvent? {
return boundedGameEntity?.exposureEvent?.getFreshExposureEvent()
}
BaseRecyclerViewHolder<GameEntity>(binding.root) {
companion object {
@JvmStatic
fun setHorizontalNameAndGravity(view: TextView, name: String?) {

View File

@ -26,9 +26,8 @@ class HotGameListViewModel(
subjectData.subjectId,
subjectData.sort,
subjectData.filter.ifEmpty { "type:全部" },
"",
"",
page)
page
)
}
override fun mergeResultLiveData() {

View File

@ -30,7 +30,6 @@ import com.gh.gamecenter.entity.GamesCollectionDetailEntity
import com.gh.gamecenter.eventbus.EBUserFollow
import com.gh.gamecenter.feature.entity.CommentEntity
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.exposure.ExposureConstants
import com.gh.gamecenter.login.user.UserManager
import com.gh.gamecenter.qa.article.detail.CommentItemData
import com.gh.gamecenter.qa.comment.base.BaseCommentViewModel
@ -137,9 +136,6 @@ open class GameCollectionDetailViewModel(
games?.forEach {
it.isAdData = adIconActive
it.subPageCode = ExposureConstants.GAME_COLLECTION_DETAIL
it.subPageId = gameCollectionId
add(CommentItemData(game = it))
gameList?.add(it)
}

View File

@ -30,7 +30,6 @@ import com.gh.gamecenter.entity.RecommendPopupEntity
import com.gh.gamecenter.entity.SubjectEntity
import com.gh.gamecenter.entity.UnifiedUserTrendEntity
import com.gh.gamecenter.feature.entity.*
import com.gh.gamecenter.feature.exposure.ExposureConstants
import com.gh.gamecenter.feature.utils.ApkActiveUtils
import com.gh.gamecenter.feature.utils.ConcernUtils
import com.gh.gamecenter.feature.utils.ContentBlockedHelper
@ -38,6 +37,7 @@ import com.gh.gamecenter.gamedetail.detail.viewholder.GameDetailContentRecommend
import com.gh.gamecenter.gamedetail.entity.*
import com.gh.gamecenter.livedata.Event
import com.gh.gamecenter.login.user.UserManager
import com.gh.gamecenter.login.user.UserRepository
import com.gh.gamecenter.manager.PackagesManager
import com.gh.gamecenter.retrofit.RetrofitManager
import com.gh.vspace.VHelper
@ -105,7 +105,7 @@ class GameDetailViewModel(
private var relatedGameList = arrayListOf<GameEntity>()
// 内容卡片相关
private var contentCardList: List<ContentCardEntity>? = null
private var contentCardList: List<ContentCardEntity>?= null
private val contentCardSp by lazy {
HaloApp.getInstance().getSharedPreferences(SP_CONTENT_CARD, Context.MODE_PRIVATE)
}
@ -134,9 +134,9 @@ class GameDetailViewModel(
private var isGameUpdatable = false
private val compositeDisposable = CompositeDisposable()
private var userRelatedInfoReceivedCallback: (() -> Unit)? = null
init {
loadData()
}
@ -191,7 +191,6 @@ class GameDetailViewModel(
.subscribe(object : Response<GameEntity>() {
override fun onResponse(response: GameEntity?) {
game = response
game?.subPageCode = ExposureConstants.GAME_DETAIL
gameLiveData.postValue(Resource.success(game))
loadGameDetailData()
}
@ -559,9 +558,6 @@ class GameDetailViewModel(
detailDataList.find { it.linkEveryonePlaying != null }?.let {
if (relatedGameList.isNotEmpty()) {
relatedGameList.shuffle()
relatedGameList.forEach { game ->
game.subPageCode = ExposureConstants.GAME_DETAIL
}
val recommendedGames = SubjectEntity().apply { data = relatedGameList }
it.linkEveryonePlaying?.recommendedGames = recommendedGames
} else {
@ -1121,14 +1117,6 @@ class GameDetailViewModel(
compositeDisposable.clear()
}
fun markContentCardRedDot(contentCardEntity: ContentCardEntity) {
SPUtils.setString(contentCardSp, RED_DOT_PREFIX + (gameId ?: "") + contentCardEntity.link.type, contentCardEntity.redDot.toString())
}
fun shouldShowContentCardRedDot(contentCardEntity: ContentCardEntity): Boolean {
return SPUtils.getString(contentCardSp, RED_DOT_PREFIX + (gameId ?: "") + contentCardEntity.link.type) != contentCardEntity.redDot.toString()
}
class Factory(
private val application: Application,
private val gameId: String?,
@ -1145,7 +1133,6 @@ class GameDetailViewModel(
companion object {
const val SP_CONTENT_CARD = "content_card"
const val TAG = "GameDetailViewModel"
const val RED_DOT_PREFIX = "red_dot_"
//[已领取/已淘号/再领/再淘]的礼包置底显示
fun sortLibaoList(libaoList: ArrayList<LibaoEntity>?) {

View File

@ -14,7 +14,6 @@ import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.view.menu.ActionMenuItemView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.view.doOnNextLayout
import androidx.core.view.isVisible
@ -97,7 +96,6 @@ import io.reactivex.disposables.Disposable
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
import retrofit2.HttpException
import splitties.views.horizontalPadding
import java.util.*
class GameDetailWrapperFragment : BaseLazyFragment(), IScrollable {
@ -288,7 +286,7 @@ class GameDetailWrapperFragment : BaseLazyFragment(), IScrollable {
initSkeleton()
binding.reuseNoneData.reuseNoneDataTv.text = "页面不见了"
bodyBinding.tabIndicator.setIndicatorWidth(16)
bodyBinding.tabIndicator.setIndicatorWidth(12)
bodyBinding.viewPager.offscreenPageLimit = 4
binding.expandSpecialDownloadIv.enlargeTouchArea()
@ -359,14 +357,8 @@ class GameDetailWrapperFragment : BaseLazyFragment(), IScrollable {
}
backBtn.setOnClickListener { requireActivity().finish() }
moreMenuItem = actionMenuView.menu.findItem(R.id.menu_more)
downloadMenuItem = actionMenuView.menu.findItem(R.id.menu_download)?.apply {
actionView?.updateLayoutParams<LayoutParams> { width = 40F.dip2px() }
}
downloadMenuItem = actionMenuView.menu.findItem(R.id.menu_download)
downloadMenuItem?.isVisible = Config.isShow()
actionMenuView.findViewById<ActionMenuItemView>(R.id.menu_more)?.run {
updateLayoutParams<LayoutParams> { width = 40F.dip2px() }
horizontalPadding = 8F.dip2px()
}
}
downloadMenuIcon = downloadMenuItem?.actionView?.findViewById(R.id.menu_download_iv)
@ -475,10 +467,6 @@ class GameDetailWrapperFragment : BaseLazyFragment(), IScrollable {
gameEntity?.gameBitChinese ?: "",
"download_type",
gameEntity?.downloadType ?: "",
"is_ad",
traceEvent?.payload?.isAd ?: false,
"ad_group_id",
traceEvent?.payload?.adGroupId ?: "",
*(traceEvent?.additional ?: emptyArray())
)
}, 120)
@ -815,10 +803,7 @@ class GameDetailWrapperFragment : BaseLazyFragment(), IScrollable {
downloadStatus = gameEntity?.downloadStatusChinese ?: "",
gameType = gameEntity?.categoryChinese ?: "",
position = position,
tabContent = tabEntity.name,
linkType = tabEntity.link?.type ?: "",
linkId = tabEntity.link?.link ?: "",
linkText = tabEntity.link?.text ?: ""
tabContent = tabEntity.name
)
val entrance = if (mEntrance.contains("论坛详情")) "论坛" else "游戏"
@ -921,7 +906,7 @@ class GameDetailWrapperFragment : BaseLazyFragment(), IScrollable {
tab.customView = tabItemBinding.root
updateTabStyle(tab, i == bodyBinding.viewPager.currentItem)
tab.view.clipChildren = false
tab.view.setPadding(0, 0, if (i == tabEntityList.size - 1) 8F.dip2px() else 0, 0)
tab.view.setPadding(0, 0, 0, 0)
tab.view.setOnTouchListener { _, event ->
if (event.action == MotionEvent.ACTION_DOWN) {
handleTabTouchEvent(tabEntity?.name ?: "")
@ -948,7 +933,7 @@ class GameDetailWrapperFragment : BaseLazyFragment(), IScrollable {
tab.customView?.findViewById<TextView>(R.id.tab_title)
?.setTypeface(if (isChecked) Typeface.DEFAULT_BOLD else Typeface.DEFAULT)
tab.customView?.findViewById<TextView>(R.id.tab_title)?.setTextColor(
if (isChecked) com.gh.gamecenter.common.R.color.text_primary.toColor(requireContext()) else com.gh.gamecenter.common.R.color.text_secondary.toColor(
if (isChecked) com.gh.gamecenter.common.R.color.text_primary.toColor(requireContext()) else com.gh.gamecenter.common.R.color.text_tertiary.toColor(
requireContext()
)
)

View File

@ -684,7 +684,7 @@ class GameDetailFragment : LazyFragment(), IScrollable {
null,
gameStatus = gameStatus
)
GameFunctionDialogFragment.show(requireContext(), gameEntity, gameDetailInfoTag.infoTags, gameDetailInfoTag.link)
GameFunctionDialogFragment.show(requireContext(), gameDetailInfoTag.infoTags)
}
}
}
@ -922,10 +922,8 @@ class GameDetailFragment : LazyFragment(), IScrollable {
}
override fun scrollToTop() {
if (::binding.isInitialized) {
binding.gamedetailAppbar.setExpanded(true)
binding.detailRv.scrollToPosition(0)
}
binding.gamedetailAppbar.setExpanded(true)
binding.detailRv.scrollToPosition(0)
}
// 登录事件/礼包状态变更事件

View File

@ -253,7 +253,7 @@ class GameLibaoAdapter(
null,
true,
"游戏详情",
"礼包列表页"
"游戏详情"
) {
adapter.notifyItemChanged(position)
}

View File

@ -1,7 +1,6 @@
package com.gh.gamecenter.gamedetail.detail.viewholder
import android.content.Context
import android.widget.TextView
import androidx.core.view.isVisible
import androidx.lifecycle.LifecycleOwner
import com.gh.common.constant.Config
@ -132,9 +131,11 @@ class GameDetailContentCardSingleItemViewHolder(
contentBannerView.startBannerLoop()
}
val showRedDot = contentCardEntity.redDot != 0 && viewModel.shouldShowContentCardRedDot(contentCardEntity)
redDotTv.goneIf(!showRedDot) {
redDotTv.text = contentCardEntity.redDot.toString()
redDotTv.goneIf(!((contentCardEntity.link.type == TYPE_SERVER && contentCardEntity.server?.total != 0) || contentCardEntity.link.type == TYPE_GIFT)) {
if ((contentCardEntity.link.type == TYPE_SERVER) && (contentCardEntity.server?.calendar?.isNotEmpty() == true))
redDotTv.text = contentCardEntity.server?.total.toString()
if ((contentCardEntity.link.type == TYPE_GIFT) && (contentCardEntity.libao != null))
redDotTv.text = contentCardEntity.libao?.total.toString()
}
val showNewTag = contentCardEntity.link.type == TYPE_ARCHIVE && contentCardEntity.archive != null && contentCardEntity.showNewTag
@ -172,11 +173,11 @@ class GameDetailContentCardSingleItemViewHolder(
confirmText = context.getString(com.gh.gamecenter.common.R.string.confirm),
cancelText = context.getString(com.gh.gamecenter.common.R.string.cancel),
confirmClickCallback = {
jumpToContentCardLink(context, contentCardEntity, viewModel, redDotTv)
jumpToContentCardLink(context, contentCardEntity, viewModel)
}
)
} else {
jumpToContentCardLink(context, contentCardEntity, viewModel, redDotTv)
jumpToContentCardLink(context, contentCardEntity, viewModel)
}
}
@ -188,16 +189,11 @@ class GameDetailContentCardSingleItemViewHolder(
}
}
fun jumpToContentCardLink(context: Context, contentCardEntity: ContentCardEntity, viewModel: GameDetailViewModel, redDotTv: TextView) {
fun jumpToContentCardLink(context: Context, contentCardEntity: ContentCardEntity, viewModel: GameDetailViewModel) {
val path = "游戏详情->内容卡片"
when (contentCardEntity.link.type) {
TYPE_GIFT,
TYPE_ARCHIVE -> {
if (contentCardEntity.link.type == TYPE_GIFT) {
viewModel.markContentCardRedDot(contentCardEntity)
redDotTv.isVisible = false
}
val type = if (contentCardEntity.link.type == TYPE_GIFT) GameDetailTabEntity.TYPE_GIFT else GameDetailTabEntity.TYPE_ARCHIVE
val tabList = viewModel.gameDetailTabListLiveData.value?.data
if (tabList?.find { it.type == type } != null) {
@ -212,8 +208,6 @@ class GameDetailContentCardSingleItemViewHolder(
TYPE_SERVER -> {
if (viewModel.game != null && contentCardEntity.server != null) {
viewModel.markContentCardRedDot(contentCardEntity)
redDotTv.isVisible = false
context.startActivity(
ServersCalendarActivity.getIntent(
context,

View File

@ -10,6 +10,8 @@ import com.gh.gamecenter.gamedetail.GameDetailViewModel
import com.gh.gamecenter.gamedetail.detail.viewholder.GameDetailContentCardSingleItemViewHolder.Companion.jumpToContentCardLink
import com.gh.gamecenter.gamedetail.entity.ContentCardEntity
import com.gh.gamecenter.gamedetail.entity.ContentCardEntity.Companion.TYPE_ARCHIVE
import com.gh.gamecenter.gamedetail.entity.ContentCardEntity.Companion.TYPE_GIFT
import com.gh.gamecenter.gamedetail.entity.ContentCardEntity.Companion.TYPE_SERVER
import com.gh.gamecenter.gamedetail.entity.GameDetailData
class GameDetailContentCardTripleItemViewHolder(
@ -72,9 +74,11 @@ class GameDetailContentCardTripleItemViewHolder(
titleTv.text = contentCardEntity.title
ImageUtils.display(iconIv, contentCardEntity.icon)
val showRedDot = contentCardEntity.redDot != 0 && viewModel.shouldShowContentCardRedDot(contentCardEntity)
redDotTv.goneIf(!showRedDot) {
redDotTv.text = contentCardEntity.redDot.toString()
redDotTv.goneIf(!((contentCardEntity.link.type == TYPE_SERVER && contentCardEntity.server?.total != 0) || contentCardEntity.link.type == TYPE_GIFT)) {
if ((contentCardEntity.link.type == TYPE_SERVER) && (contentCardEntity.server?.calendar?.isNotEmpty() == true))
redDotTv.text = contentCardEntity.server?.total.toString()
if ((contentCardEntity.link.type == TYPE_GIFT) && (contentCardEntity.libao != null))
redDotTv.text = contentCardEntity.libao?.total.toString()
}
val showNewTag = contentCardEntity.link.type == TYPE_ARCHIVE && contentCardEntity.archive != null && contentCardEntity.showNewTag
@ -112,11 +116,11 @@ class GameDetailContentCardTripleItemViewHolder(
confirmText = context.getString(com.gh.gamecenter.common.R.string.confirm),
cancelText = context.getString(com.gh.gamecenter.common.R.string.cancel),
confirmClickCallback = {
jumpToContentCardLink(context, contentCardEntity, viewModel, redDotTv)
jumpToContentCardLink(context, contentCardEntity, viewModel)
}
)
} else {
jumpToContentCardLink(context, contentCardEntity, viewModel, redDotTv)
jumpToContentCardLink(context, contentCardEntity, viewModel)
}
}

View File

@ -20,8 +20,6 @@ import com.gh.gamecenter.game.horizontal.GameHorizontalListType
import com.gh.gamecenter.gamedetail.GameDetailViewModel
import com.gh.gamecenter.gamedetail.entity.GameDetailData
import com.gh.gamecenter.gamedetail.entity.GameDetailRecommendColumn
import kotlin.collections.firstOrNull
import kotlin.collections.withIndex
class GameDetailRecommendColumnItemViewHolder(
val binding: ItemGameDetailRecyclerViewBinding,
@ -75,8 +73,7 @@ class GameDetailRecommendColumnItemViewHolder(
linkType = columnData.display?.moreLink?.type ?: "",
linkId = columnData.display?.moreLink?.link ?: "",
text = "右上角",
buttonType = columnData.display?.home ?: "",
adGroupId = viewModel.game?.adGroupId ?: ""
buttonType = columnData.display?.home ?: ""
)
when (columnData.display?.home) {

View File

@ -9,29 +9,19 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.LinearLayoutManager
import com.gh.common.util.DirectUtils
import com.gh.gamecenter.BuildConfig
import com.gh.gamecenter.common.base.fragment.BaseBottomDialogFragment
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.entity.LinkEntity
import com.gh.gamecenter.common.utils.SensorsBridge
import com.gh.gamecenter.common.utils.goneIf
import com.gh.gamecenter.databinding.DialogGameDetailRecyclerViewBinding
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.gamedetail.entity.GameDetailInfoTag
import com.lightgame.utils.AppManager
class GameFunctionDialogFragment: BaseBottomDialogFragment<DialogGameDetailRecyclerViewBinding>() {
private var infoTags: List<GameDetailInfoTag.InfoTag> = arrayListOf()
private var linkEntity: LinkEntity? = null
private var gameEntity: GameEntity? = null
private val adapter by lazy { GameFunctionAdapter(requireContext(), infoTags) }
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
gameEntity = arguments?.getParcelable(EntranceConsts.KEY_GAME_ENTITY)
infoTags = arguments?.getParcelableArrayList(KEY_INFO_TAG) ?: arrayListOf()
linkEntity = arguments?.getParcelable(EntranceConsts.KEY_LINK)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@ -40,28 +30,6 @@ class GameFunctionDialogFragment: BaseBottomDialogFragment<DialogGameDetailRecyc
mBinding.closeIv.setOnClickListener {
dismissAllowingStateLoss()
}
mBinding.subtitleTv.goneIf(linkEntity == null) {
mBinding.subtitleTv.text = linkEntity?.text
mBinding.subtitleTv.setOnClickListener { _ ->
linkEntity?.let {
DirectUtils.directToLinkPage(requireContext(), it, "游戏详情-功能说明", "")
SensorsBridge.trackGameDetailModuleClick(
gameEntity?.id,
gameEntity?.name,
gameEntity?.categoryChinese,
"组件内容",
"功能标签",
"功能标签",
null,
subModuleName = "跳转入口",
linkType = it.type,
linkId = it.link,
linkText = it.text,
gameStatus = null
)
}
}
}
mBinding.recyclerView.run {
layoutManager = LinearLayoutManager(requireContext())
adapter = this@GameFunctionDialogFragment.adapter
@ -78,7 +46,7 @@ class GameFunctionDialogFragment: BaseBottomDialogFragment<DialogGameDetailRecyc
const val KEY_INFO_TAG = "info_tag"
@JvmStatic
fun show(context: Context?, gameEntity: GameEntity?, infoTags: List<GameDetailInfoTag.InfoTag>, linkEntity: LinkEntity?) {
fun show(context: Context?, infoTags: List<GameDetailInfoTag.InfoTag>) {
val fragmentActivity: FragmentActivity = if (context is FragmentActivity) {
context
} else if (BuildConfig.DEBUG) {
@ -97,9 +65,7 @@ class GameFunctionDialogFragment: BaseBottomDialogFragment<DialogGameDetailRecyc
val dialogFragment = GameFunctionDialogFragment()
dialogFragment.arguments = bundleOf(
EntranceConsts.KEY_GAME_ENTITY to gameEntity,
KEY_INFO_TAG to infoTags,
EntranceConsts.KEY_LINK to linkEntity
KEY_INFO_TAG to infoTags
)
dialogFragment.show(fragmentActivity.supportFragmentManager, GameFunctionDialogFragment::class.java.name)
}

View File

@ -8,9 +8,10 @@ import android.view.*
import android.widget.ImageView
import android.widget.TextView
import androidx.lifecycle.ViewModelProvider
import com.gh.common.util.*
import com.gh.common.xapk.XapkInstaller
import com.gh.common.xapk.XapkUnzipStatus
import com.gh.common.util.DirectUtils
import com.gh.common.util.PackageInstaller
import com.gh.common.util.PackageLauncher
import com.gh.common.util.PackageUtils
import com.gh.download.DownloadManager
import com.gh.gamecenter.R
import com.gh.gamecenter.ShellActivity
@ -79,15 +80,6 @@ class SpecialDownloadDialogFragment : BaseDraggableDialogFragment() {
DownloadStatus.done -> {
downloadBtn?.setProgress(1.0F)
downloadBtn?.setText(context?.getString(com.gh.gamecenter.feature.R.string.install) ?: "")
val xapkStatus = downloadEntity.meta[XapkInstaller.XAPK_UNZIP_STATUS]
when {
(XapkUnzipStatus.SUCCESS.name == xapkStatus || XapkUnzipStatus.INSTALLED.name == xapkStatus) && XapkInstaller.isInstalling(downloadEntity.path) -> {
downloadBtn?.setText(context?.getString(com.gh.gamecenter.feature.R.string.installing) ?: "")
}
XapkUnzipStatus.UNZIPPING.name == xapkStatus -> {
downloadBtn?.setText(context?.getString(com.gh.gamecenter.feature.R.string.unzipping) ?: "")
}
}
}
DownloadStatus.cancel -> {

View File

@ -31,13 +31,6 @@ class ContentCardEntity(
var showNewTag: Boolean = false,
) {
val redDot
get() = when (link.type) {
TYPE_SERVER -> server?.total ?: 0
TYPE_GIFT -> libao?.total ?: 0
else -> 0
}
@Keep
class Dialog(
@SerializedName("_id")

View File

@ -219,9 +219,7 @@ data class GameDetailInfoTag(
@SerializedName("info_tags")
val infoTags: List<InfoTag> = listOf(), // 功能标签
@SerializedName("request_speed_status")
val requestSpeedStatus: String = "", // 求加速状态, on/off
@SerializedName("plugin_tutorial_link")
val link: LinkEntity? = null, // 插件教程链接
val requestSpeedStatus: String = "" // 求加速状态, on/off
) {
@Parcelize
data class InfoTag(

View File

@ -360,8 +360,7 @@ class LegacyHomeFragmentAdapterAssistant(
position = prefixedPosition,
gameColumnName = gameEntity.name ?: "",
gameColumnId = gameEntity.link ?: "",
text = "游戏专题",
adGroupId = gameEntity.adGroupId
text = "游戏专题"
)
}

View File

@ -1,11 +1,9 @@
package com.gh.gamecenter.home.custom
import com.gh.common.util.AdHelper
import com.gh.gamecenter.common.exposure.ExposureSource
import com.gh.gamecenter.core.runOnIoThread
import com.gh.gamecenter.feature.entity.CustomPageTrackData
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.exposure.ExposureConstants
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.home.custom.model.CustomSubjectCollectionItem
@ -20,9 +18,6 @@ fun createExposureEvent(
game?.sequence = childPosition
game?.outerSequence = position
game?.customPageTrackData = customPageTrackData
game?.pageLevelString = customPageTrackData.pageLocation.pageLevelString
game?.subPageCode = ExposureConstants.CUSTOM_PAGE
game?.subPageId = customPageTrackData.pageLocation.pageId
val event = ExposureEvent.createEventWithSourceConcat(
gameEntity = game,
basicSource = base,
@ -37,7 +32,9 @@ fun fillExposureInSubjectCollection(
base: List<ExposureSource>,
customPageTrackData: CustomPageTrackData
) {
runOnIoThread(isLightWeightTask = true) {
val eventList = arrayListOf<ExposureEvent>()
runOnIoThread(true) {
item.data.data.forEachIndexed { index, customSubject ->
val source = if (item.isSubjectCollection) {
listOf(
@ -54,9 +51,8 @@ fun fillExposureInSubjectCollection(
)
}
customSubject.games.forEach { game ->
game.pageLevelString = customPageTrackData.pageLocation.pageLevelString
game.isAdData = customSubject.adIconActive
game.exposureEvent = createExposureEvent(
val event = createExposureEvent(
game,
source,
base,
@ -64,15 +60,10 @@ fun fillExposureInSubjectCollection(
item.componentPosition,
customPageTrackData
)
game.subPageCode = ExposureConstants.CUSTOM_PAGE
game.subPageId = customPageTrackData.pageLocation.pageId
game.exposureSource = game.exposureEvent?.source
if (game.adGroupId.isNotEmpty() && !game.isAdRequestReported) {
AdHelper.reportAdRequest(game.exposureEvent!!)
game.isAdRequestReported = true
}
eventList.add(event)
}
}
}
item.exposureEventList = eventList
}

View File

@ -12,7 +12,7 @@ import androidx.fragment.app.viewModels
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.OnScrollListener
import com.gh.common.exposure.DefaultExposureStateChangeListener
import com.gh.common.exposure.ExposureListener
import com.gh.common.exposure.ExposureManager
import com.gh.common.iinterface.ISearchToolbarTab
import com.gh.common.iinterface.ISmartRefresh
@ -41,7 +41,6 @@ import com.gh.gamecenter.common.entity.LinkEntity
import com.gh.gamecenter.common.eventbus.EBReuse
import com.gh.gamecenter.common.exposure.ExposureSource
import com.gh.gamecenter.common.tracker.IBusiness
import com.gh.gamecenter.common.pagelevel.IPageLevelProvider
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.common.view.ScrollableLinearLayoutManager
import com.gh.gamecenter.core.AppExecutor
@ -60,7 +59,6 @@ import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.entity.PageLocation
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.exposure.ExposureType
import com.gh.gamecenter.feature.exposure.addExposureHelper
import com.gh.gamecenter.feature.minigame.MiniGameItemHelper
import com.gh.gamecenter.feature.utils.SentryHelper
import com.gh.gamecenter.game.commoncollection.detail.CustomCommonCollectionDetailActivity
@ -90,11 +88,7 @@ class CustomPageFragment : LazyFragment(), ISmartRefreshContent, IScrollable, IB
private var searchToolbarTabWrapperViewModel: SearchToolbarTabWrapperViewModel? = null
private var mainWrapperViewModel: MainWrapperViewModel? = null
private val viewModel by viewModels<CustomPageViewModel>(
factoryProducer = {
CustomPageViewModel.Factory(com.gh.gamecenter.login.HaloApp.getInstance())
}
)
private val viewModel by viewModels<CustomPageViewModel>()
private lateinit var binding: FragmentCustomBinding
@ -117,7 +111,6 @@ class CustomPageFragment : LazyFragment(), ISmartRefreshContent, IScrollable, IB
private var customPageName = ""
private var bottomTabId = ""
private var bottomTabName = ""
private var bottomTabIndex = -1
private var tabIndex = -1
private var showFloatingWindow = true
private var showPullDownPush = true
@ -151,7 +144,6 @@ class CustomPageFragment : LazyFragment(), ISmartRefreshContent, IScrollable, IB
customPageName = arguments?.getString(EntranceConsts.KEY_CUSTOM_PAGE_NAME, "") ?: ""
bottomTabId = arguments?.getString(EntranceConsts.KEY_BOTTOM_TAB_ID, "") ?: ""
bottomTabName = arguments?.getString(EntranceConsts.KEY_BOTTOM_TAB_NAME, "") ?: ""
bottomTabIndex = arguments?.getInt(EntranceConsts.KEY_BOTTOM_TAB_INDEX, -1) ?: -1
tabIndex = arguments?.getInt(EntranceConsts.KEY_TAB_INDEX, -1) ?: -1
showFloatingWindow = arguments?.getBoolean(EntranceConsts.KEY_SHOW_FLOATING_WINDOW, true) ?: true
showPullDownPush = arguments?.getBoolean(EntranceConsts.KEY_SHOW_PULL_DOWN_PUSH, true) ?: true
@ -190,17 +182,8 @@ class CustomPageFragment : LazyFragment(), ISmartRefreshContent, IScrollable, IB
exposureSourceList,
isInSearchToolbarTabWrapperPage
)
val precisePageLevelString = (activity as? IPageLevelProvider)
?.getPageLevel()
?.getTempNewPageLevel(topTabPosition = tabIndex, bottomTabPosition = bottomTabIndex)
?.toFormattedString(ignoreBottomTabPositionMap = true)
?: ""
pageLocation = PageLocation(
bottomTabName,
bottomTabIndex,
precisePageLevelString,
multiTabNavName,
multiTabNavId,
tabIndex,
@ -247,12 +230,7 @@ class CustomPageFragment : LazyFragment(), ISmartRefreshContent, IScrollable, IB
})
dataList.observe(viewLifecycleOwner) {
adapter.submitList(it) {
if (shouldScrollToTop) {
shouldScrollToTop = false
binding.gameList.scrollToPosition(0)
}
}
adapter.submitList(it)
}
loadStatus.observe(viewLifecycleOwner) { (status, isPullToRefresh) ->
@ -374,6 +352,7 @@ class CustomPageFragment : LazyFragment(), ISmartRefreshContent, IScrollable, IB
)
}
}
})
subjectDestination.observe(viewLifecycleOwner, EventObserver { subject ->
@ -574,7 +553,6 @@ class CustomPageFragment : LazyFragment(), ISmartRefreshContent, IScrollable, IB
binding.gameList.itemAnimator = null
binding.gameList.layoutManager = layoutManager
binding.gameList.adapter = adapter
binding.gameList.addExposureHelper(this, DefaultExposureStateChangeListener())
var listScrollHeight = 0
binding.gameList.addOnScrollListener(object : OnScrollListener() {
@ -592,6 +570,9 @@ class CustomPageFragment : LazyFragment(), ISmartRefreshContent, IScrollable, IB
}
})
val exposureListener = ExposureListener(this, adapter)
binding.gameList.addOnScrollListener(exposureListener)
binding.gameRefresh.setOnRefreshListener {
onRefresh()
}

View File

@ -7,8 +7,6 @@ import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData
import androidx.lifecycle.MediatorLiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.gh.common.util.GameUtils
import com.gh.common.util.NewFlatLogUtils
import com.gh.common.util.NewLogUtils
@ -33,24 +31,10 @@ import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.home.PageConfigure
import com.gh.gamecenter.home.custom.GamePositionAndPackageHelper.Companion.putGameWithPosition
import com.gh.gamecenter.home.custom.eventlistener.OnCustomPageEventListener
import com.gh.gamecenter.home.custom.model.CustomCommonContentCollectionItem
import com.gh.gamecenter.home.custom.model.CustomDspPlaceholderItem
import com.gh.gamecenter.home.custom.model.CustomPKItem
import com.gh.gamecenter.home.custom.model.CustomPageData
import com.gh.gamecenter.home.custom.model.CustomPageItem
import com.gh.gamecenter.home.custom.model.*
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.COMPONENTS_COLLECTION_STYLE_REFRESH_ICONS_4_2
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.COMPONENTS_COLLECTION_STYLE_REFRESH_SLIDE_LIST
import com.gh.gamecenter.home.custom.model.CustomPageRepository
import com.gh.gamecenter.home.custom.model.CustomPluginItem
import com.gh.gamecenter.home.custom.model.CustomRecentGamesItem
import com.gh.gamecenter.home.custom.model.CustomSplitCommonContentCollectionItem
import com.gh.gamecenter.home.custom.model.CustomSplitSubjectItem
import com.gh.gamecenter.home.custom.model.CustomSubjectCollectionItem
import com.gh.gamecenter.home.custom.model.CustomSubjectItem
import com.gh.gamecenter.home.custom.model.CustomWeChatMiniGamesCPMSubjectItem
import com.gh.gamecenter.livedata.Event
import com.gh.gamecenter.login.user.UserRepository
import com.gh.gamecenter.login.user.UserViewModel
import com.gh.gamecenter.wrapper.SearchToolbarTabWrapperViewModel
import com.lightgame.utils.Utils
import io.reactivex.android.schedulers.AndroidSchedulers
@ -60,7 +44,9 @@ import io.reactivex.schedulers.Schedulers
import retrofit2.HttpException
import kotlin.collections.set
class CustomPageViewModel(application: Application) : AndroidViewModel(application), OnCustomPageEventListener {
class CustomPageViewModel(
application: Application
) : AndroidViewModel(application), OnCustomPageEventListener {
private val compositeDisposable = CompositeDisposable()
@ -122,6 +108,8 @@ class CustomPageViewModel(application: Application) : AndroidViewModel(applicati
*/
private val cpmSubjectChangedPageMap: ArrayMap<String, Int> = ArrayMap()
var slideDiscoveryGamesPage = -1
private lateinit var _pageTracker: CustomPageTracker
val pageTracker: CustomPageTracker
@ -132,12 +120,10 @@ class CustomPageViewModel(application: Application) : AndroidViewModel(applicati
val pkVoteResultLiveData = MutableLiveData<Event<Pair<String, Boolean>>>()
var shouldScrollToTop: Boolean = false
fun init(
pageConfigure: PageConfigure,
searchToolbarTabWrapperViewModel: SearchToolbarTabWrapperViewModel?,
pageLocation: PageLocation,
pageLocation: PageLocation
) {
this.searchToolbarTabWrapperViewModel = searchToolbarTabWrapperViewModel
_pageConfigure = pageConfigure
@ -411,7 +397,7 @@ class CustomPageViewModel(application: Application) : AndroidViewModel(applicati
if (gameList != null) {// 直接读取缓存数据
notifyWGameCPMABatchChanged(gameList, subjectId, page)
} else {
repository.loadChangeSubjectWGameCPM(page, subjectEntity.size.limit, subjectEntity.onlyFee)
repository.loadChangeSubjectWGameCPM(page)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Response<List<GameEntity>>() {
@ -473,7 +459,7 @@ class CustomPageViewModel(application: Application) : AndroidViewModel(applicati
// 随机产生专题数据(换一换)
private fun getRandomGameList(
oldList: MutableList<GameEntity>?,
sourceList: MutableList<GameEntity>,
sourceList: MutableList<GameEntity>
): MutableList<GameEntity> {
val resultGameList = ArrayList<GameEntity>()
val filterGameList = GameUtils.removeDuplicateData(oldList, sourceList)//排除重复
@ -584,11 +570,6 @@ class CustomPageViewModel(application: Application) : AndroidViewModel(applicati
subjectItem.data
)
if (customPageItemList.isEmpty()) return
if (index == 0) {
shouldScrollToTop = true
}
newData[index] = customPageItemList[0]
newData.addAll(index + 1, customPageItemList.subList(1, customPageItemList.size))
newData.forEachIndexed { pos, customPageItem ->
@ -626,10 +607,6 @@ class CustomPageViewModel(application: Application) : AndroidViewModel(applicati
subjectItem.data
)
if (customPageItemList.isEmpty()) return
if (index == 0) {
shouldScrollToTop = true
}
newData[index] = customPageItemList[0]
newData.addAll(index + 1, customPageItemList.subList(1, customPageItemList.size))
newData.forEachIndexed { pos, customPageItem ->
@ -724,7 +701,7 @@ class CustomPageViewModel(application: Application) : AndroidViewModel(applicati
private fun getPositionAndPackageMap(
customPageItem: CustomPageItem,
gameList: List<GameEntity>?,
gameList: List<GameEntity>?
): HashMap<String, Int> {
val hashMap = hashMapOf<String, Int>()
if (customPageItem.shouldShowDownloadButton) {
@ -743,7 +720,7 @@ class CustomPageViewModel(application: Application) : AndroidViewModel(applicati
item: CustomPageItem,
childPosition: Int,
game: GameEntity,
text: String,
text: String
) {
_gameDetailDestination.value = Event(Pair("", game))
}
@ -769,7 +746,7 @@ class CustomPageViewModel(application: Application) : AndroidViewModel(applicati
override fun navigateSubjectDetailPage(
item: CustomSubjectCollectionItem,
subject: CustomPageData.LinkColumnCollection.CustomSubjectEntity,
subject: CustomPageData.LinkColumnCollection.CustomSubjectEntity
) {
_subjectDestinationWithCustom.value = Event(subject to item.data.subjectType)
}
@ -782,7 +759,7 @@ class CustomPageViewModel(application: Application) : AndroidViewModel(applicati
override fun navigateSubjectCollectionPage(
item: CustomSubjectCollectionItem,
childPosition: Int,
subject: CustomPageData.LinkColumnCollection.CustomSubjectEntity?,
subject: CustomPageData.LinkColumnCollection.CustomSubjectEntity?
) {
_subjectCollectionDestination.value = Event(Triple(item, childPosition, subject))
}
@ -795,7 +772,7 @@ class CustomPageViewModel(application: Application) : AndroidViewModel(applicati
override fun navigateGameListDetailPage(
item: CustomSubjectCollectionItem,
childPosition: Int,
subject: CustomPageData.LinkColumnCollection.CustomSubjectEntity,
subject: CustomPageData.LinkColumnCollection.CustomSubjectEntity
) {
_gameListDetailDestination.value = Event(Triple(item, childPosition, subject))
}
@ -831,7 +808,7 @@ class CustomPageViewModel(application: Application) : AndroidViewModel(applicati
item: CustomPageItem,
link: LinkEntity,
text: String,
exposureEvent: ExposureEvent?,
exposureEvent: ExposureEvent?
) {
_linkDestination.value = Event(Pair(link, exposureEvent))
}
@ -857,7 +834,7 @@ class CustomPageViewModel(application: Application) : AndroidViewModel(applicati
item: CustomPageItem,
gameId: String,
gameName: String?,
childPosition: Int,
childPosition: Int
) {
val exposureEvent = item.exposureEventList.getOrNull(childPosition)
_gameDetailDestinationOnAmway.value = Event(Pair(gameId, exposureEvent))
@ -932,7 +909,7 @@ class CustomPageViewModel(application: Application) : AndroidViewModel(applicati
class SubjectChanged(
val subjectId: String,
val page: Int,
val page: Int
) {
companion object {
private const val HASH = 30
@ -952,13 +929,4 @@ class CustomPageViewModel(application: Application) : AndroidViewModel(applicati
}
class Factory(private val mApplication: Application)
: ViewModelProvider.NewInstanceFactory() {
override fun <T : ViewModel> create(modelClass: Class<T>): T {
return CustomPageViewModel(mApplication) as T
}
}
}

View File

@ -7,8 +7,6 @@ import androidx.recyclerview.widget.RecyclerView
import com.gh.gamecenter.common.utils.ImageUtils
import com.gh.gamecenter.common.utils.toBinding
import com.gh.gamecenter.databinding.GameCollectionBannerItemBinding
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.exposure.IExposureProvider
import com.gh.gamecenter.home.custom.model.CustomPageData
class AnnouncementBannerAdapter(
@ -46,6 +44,7 @@ class AnnouncementBannerAdapter(
} else {
notifyDataSetChanged()
}
}
}
@ -73,6 +72,7 @@ class AnnouncementBannerAdapter(
override fun onBindViewHolder(holder: AnnouncementBannerChildViewHolder, position: Int) {
val item = getItem(position)
listener.exposure(position, item)
holder.bind(item)
holder.binding.bannerIv.setOnClickListener {
listener.onItemClick(getDataPosition(position), item)
@ -80,23 +80,19 @@ class AnnouncementBannerAdapter(
}
class AnnouncementBannerChildViewHolder(val binding: GameCollectionBannerItemBinding) :
RecyclerView.ViewHolder(binding.root), IExposureProvider {
var exposureEvent: ExposureEvent? = null
RecyclerView.ViewHolder(binding.root) {
fun bind(item: CustomPageData.Announcement) {
exposureEvent = item.exposureEvent
ImageUtils.display(binding.bannerIv, item.image)
}
override fun provideExposureData(): ExposureEvent? {
return exposureEvent?.getFreshExposureEvent()
}
}
interface OnChildEventListener {
fun onItemClick(childPosition: Int, announcement: CustomPageData.Announcement)
fun getCurrentPosition(): Int
fun exposure(childPosition: Int, announcement: CustomPageData.Announcement)
}
}

View File

@ -9,13 +9,12 @@ 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.databinding.RecyclerContentLabelLaneItemBinding
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.exposure.IExposureProvider
import com.gh.gamecenter.home.custom.model.CustomPageData
class ContentLabelLaneAdapter(
context: Context,
private val clickInvoke: (Int, CustomPageData.CommonContentCollection.ContentTag) -> Unit,
private val exposureInvoke: (Int, CustomPageData.CommonContentCollection.ContentTag) -> Unit
) : CustomBaseChildAdapter<CustomPageData.CommonContentCollection.ContentTag, ContentLabelLaneAdapter.ContentLabelChildViewHolder>(
context
) {
@ -30,9 +29,6 @@ class ContentLabelLaneAdapter(
override fun onBindViewHolder(holder: ContentLabelChildViewHolder, position: Int) {
val item = getItem(position)
holder.exposureEvent = item.exposureEvent
with(holder.binding) {
vBackground.background = R.drawable.bg_shape_content_label_lane_item.toDrawable(context)
tvTitle.setTextColor(com.gh.gamecenter.common.R.color.text_primary.toColor(context))
@ -51,6 +47,7 @@ class ContentLabelLaneAdapter(
}
}
exposureInvoke(position, item)
holder.itemView.setOnClickListener {
clickInvoke(position, item)
}
@ -58,12 +55,9 @@ class ContentLabelLaneAdapter(
class ContentLabelChildViewHolder(
val binding: RecyclerContentLabelLaneItemBinding
) : RecyclerView.ViewHolder(binding.root), IExposureProvider {
var exposureEvent : ExposureEvent? = null
) : RecyclerView.ViewHolder(binding.root) {
override fun provideExposureData(): ExposureEvent? {
return exposureEvent?.getFreshExposureEvent()
}
}
}

View File

@ -9,8 +9,6 @@ import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.databinding.CommonCollectionItemBinding
import com.gh.gamecenter.entity.CommonCollectionContentEntity
import com.gh.gamecenter.entity.ExposureLinkEntity
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.exposure.IExposureProvider
import com.gh.gamecenter.home.custom.model.CustomPageData
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.COMMON_CONTENT_COLLECTION_LAYOUT_HORIZONTAL_IMAGE_TEXT
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.COMMON_CONTENT_COLLECTION_LAYOUT_HORIZONTAL_SLIDE_BANNER
@ -59,7 +57,6 @@ class CustomCommonCollectionAdapter(
}
}
listener.addExposureEvent(position, item.linkEntity)
holder.boundedLinkEntity = item.linkEntity
holder.binding.apply {
ImageUtils.display(commonCollectionImage, item.image)
@ -112,15 +109,10 @@ class CustomCommonCollectionAdapter(
}
class CustomCommonCollectionItemViewHolder(val binding: CommonCollectionItemBinding) :
BaseRecyclerViewHolder<Any>(binding.root), IExposureProvider {
var boundedLinkEntity: ExposureLinkEntity? = null
override fun provideExposureData(): ExposureEvent? {
return boundedLinkEntity?.exposureEvent?.getFreshExposureEvent()
}
}
BaseRecyclerViewHolder<Any>(binding.root)
interface OnEventListener {
fun addExposureEvent(childPosition: Int, exposureLinkEntity: ExposureLinkEntity)
fun onChildItemClick(childPosition: Int, item: CommonCollectionContentEntity)

View File

@ -166,6 +166,7 @@ class CustomDiscoverCardGameAdapter(
RetrofitManager.getInstance().api.discorveryFeedback(gameId, paramsMap.toRequestBody())
.compose(singleToMain())
.subscribe(object : BiResponse<ResponseBody>() {
override fun onSuccess(data: ResponseBody) {
callback.invoke()
}
@ -193,6 +194,7 @@ class CustomDiscoverCardGameAdapter(
notifyChildItem(busFour.packageName)
}
private fun notifyChildItem(packageName: String) {
dataList.forEachIndexed { position, gameEntity ->
gameEntity.getApk().forEach { apkEntity ->

View File

@ -25,9 +25,8 @@ import com.gh.gamecenter.core.utils.StringUtils
import com.gh.gamecenter.databinding.RecyclerFoldSlideLargeImageItemBinding
import com.gh.gamecenter.eventbus.EBDownloadStatus
import com.gh.gamecenter.eventbus.EBPackage
import com.gh.gamecenter.feature.entity.CustomPageTrackData
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.exposure.IExposureProvider
import com.gh.gamecenter.feature.game.GameItemViewHolder
import com.gh.gamecenter.feature.minigame.MiniGameItemHelper
import com.gh.gamecenter.home.custom.eventlistener.SubjectEventHelper
@ -54,6 +53,7 @@ class CustomFoldSlideLargeImageItemAdapter(
}
submitList(list, true)
}
}
override fun getKey(t: GameEntity): String {
@ -88,8 +88,10 @@ class CustomFoldSlideLargeImageItemAdapter(
holder.itemView.setOnClickListener {
eventHelper.navigateToGameDetailPage(realPosition, game)
}
}
override fun onAttachedToRecyclerView(recyclerView: RecyclerView) {
_recyclerView = recyclerView
}
@ -105,6 +107,7 @@ class CustomFoldSlideLargeImageItemAdapter(
return@forEach
}
}
}
override fun notifyDownloadDeleted(status: EBDownloadStatus) {
@ -136,6 +139,7 @@ class CustomFoldSlideLargeImageItemAdapter(
action(position, game)
}
}
}
fun getInitPosition() =
@ -149,7 +153,7 @@ class CustomFoldSlideLargeImageItemAdapter(
private val eventHelper: SubjectEventHelper,
val binding: RecyclerFoldSlideLargeImageItemBinding
) :
RecyclerView.ViewHolder(binding.root), IExposureProvider {
RecyclerView.ViewHolder(binding.root) {
private lateinit var item: GameEntity
@ -196,6 +200,7 @@ class CustomFoldSlideLargeImageItemAdapter(
}
if (data.shouldShowDownloadButton) {
binding.btnDownload.goneIf(false)
DownloadItemUtils.setOnClickListener(
itemView.context, binding.btnDownload, game, bindingAdapterPosition,
@ -221,6 +226,7 @@ class CustomFoldSlideLargeImageItemAdapter(
} else {
binding.btnDownload.goneIf(true)
}
}
private fun getBottomBackground(oColor: String): Pair<Int, Drawable> {
@ -297,10 +303,6 @@ class CustomFoldSlideLargeImageItemAdapter(
}
}
override fun provideExposureData(): ExposureEvent? {
return item.exposureEvent?.getFreshExposureEvent()
}
companion object {
private const val BUBBLE_SHOW_DURATION = 4000L
}

View File

@ -24,6 +24,7 @@ class CustomGameHorizontalSlideAdapter(
var gameName = ""
var entrance = ""
private var _exposureEventList: List<ExposureEvent>? = null
private var isShowFirstLine = false
private var isShowSecondLine = false
@ -41,11 +42,12 @@ class CustomGameHorizontalSlideAdapter(
get() = _data.data
fun setData(data: CustomSubjectItem) {
fun setData(data: CustomSubjectItem, exposureEventList: List<ExposureEvent>?) {
isShowFirstLine = false
isShowSecondLine = false
hasTwoLinesName = false
_data = data
_exposureEventList = exposureEventList
data.data.data?.forEach {
if (!isShowFirstLine && it.assignRemark.firstLine.isNotEmpty()) {
isShowFirstLine = true
@ -84,6 +86,7 @@ class CustomGameHorizontalSlideAdapter(
}
holder.bindGameHorizontalItem(gameEntity, subjectEntity, isShowFirstLine, isShowSecondLine)
holder.itemView.setOnClickListener {
gameEntity.exposureEvent = _exposureEventList?.getOrNull(position)
eventHelper.navigateToGameDetailPage(position, gameEntity)
}
@ -96,7 +99,7 @@ class CustomGameHorizontalSlideAdapter(
this,
StringUtils.buildString("(游戏-专题:", subjectEntity.name, "-列表[", (position + 1).toString(), "])"),
location = StringUtils.buildString("游戏-专题-", subjectEntity.name, ":", gameEntity.name),
traceEvent = gameEntity.exposureEvent
traceEvent = _exposureEventList?.getOrNull(position)
) {
eventHelper.onDownloadButtonClick(position, gameEntity)
}

View File

@ -20,7 +20,6 @@ import com.gh.gamecenter.entity.GameNavigationEntity
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.exposure.ExposureType
import com.gh.gamecenter.feature.exposure.IExposureProvider
class CustomGameNavigationAdapter(
context: Context,
@ -47,7 +46,6 @@ class CustomGameNavigationAdapter(
// 是否显示小红点
var isShowHint = false
val entity = dataList[position]
holder.exposureEvent = exposureEventList?.getOrNull(position)
ImageUtils.display(holder.binding.navigationView, entity.image)
holder.binding.navigationNameTv.text = if (entity.isShowEntryName) {
entity.entryName
@ -134,6 +132,7 @@ class CustomGameNavigationAdapter(
listener.navigateToLinkPage(it, "导航栏", exposureEvent)
}
}
}
private fun showGuide(entity: GameNavigationEntity, binding: ItemGameNavigationCustomBinding) {
@ -157,6 +156,7 @@ class CustomGameNavigationAdapter(
gradientDrawable.setStroke(1F.dip2px(), entity.guide.borderColorInt)
gradientDrawable.setColor(entity.guide.backgroundColorInt)
binding.tvBubble.background = gradientDrawable
}
companion object {
@ -164,14 +164,7 @@ class CustomGameNavigationAdapter(
}
class GameNavigationViewHolder(val binding: ItemGameNavigationCustomBinding) :
BaseRecyclerViewHolder<RecyclerView.ViewHolder>(binding.root), IExposureProvider {
var exposureEvent: ExposureEvent? = null
override fun provideExposureData(): ExposureEvent? {
return exposureEvent?.getFreshExposureEvent()
}
}
BaseRecyclerViewHolder<RecyclerView.ViewHolder>(binding.root)
interface OnEventListener {
fun navigateToLinkPage(link: LinkEntity, text: String, exposureEvent: ExposureEvent?)

View File

@ -15,6 +15,7 @@ import com.gh.common.util.HomePluggableHelper
import com.gh.gamecenter.common.constant.ItemViewType
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.core.utils.DisplayUtils
import com.gh.gamecenter.core.utils.MtaHelper.onEvent
import com.gh.gamecenter.core.utils.StringUtils
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.entity.PluginLocation
@ -119,6 +120,7 @@ class CustomGamePluginAdapter(
null
)
holder.itemView.setOnClickListener { v: View? ->
onEvent("首页_新", "点击", "插件化" + (position + 1) + "_" + gameEntity.name)
DataCollectionUtils.uploadClick(
context,
"插件化" + "-列表",

View File

@ -11,10 +11,10 @@ import com.gh.gamecenter.adapter.viewholder.GameViewHolder
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.eventbus.EBDownloadStatus
import com.gh.gamecenter.eventbus.EBPackage
import com.gh.gamecenter.feature.entity.CustomPageTrackData
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.exposure.IExposureProvider
import com.gh.gamecenter.feature.game.GameItemViewHolder
import com.gh.gamecenter.feature.minigame.MiniGameItemHelper
import com.gh.gamecenter.game.vertical.GameItemUi
import com.gh.gamecenter.home.custom.eventlistener.GameSubjectCollectionEventHelper
import com.gh.gamecenter.home.custom.model.CustomPageData
@ -95,13 +95,12 @@ class CustomGameRefreshVerticalAdapter(
return
}
}
}
inner class SimpleGameItemViewHolder(private val ui: GameItemUi) : ViewHolder(ui.root), IExposureProvider {
inner class SimpleGameItemViewHolder(private val ui: GameItemUi) : ViewHolder(ui.root) {
var placeholderGameViewHolder: GameViewHolder? = null
private var exposureEvent: ExposureEvent? = null
fun bindSimpleGameItem(
adapter: RecyclerView.Adapter<ViewHolder>,
gameEntity: GameEntity,
@ -125,8 +124,6 @@ class CustomGameRefreshVerticalAdapter(
var paddingEnd = if (isEndOfRow) 16F.dip2px() else 0F.dip2px()
val height = 80F.dip2px()
exposureEvent = gameEntity.exposureEvent
itemView.layoutParams = if (!isEndOfRow) {
paddingEnd += 1
ViewGroup.LayoutParams(maxWidth - 24F.dip2px(), height)
@ -213,9 +210,6 @@ class CustomGameRefreshVerticalAdapter(
root.setPadding(paddingStart, 8F.dip2px(), paddingEnd, 8F.dip2px())
}
}
override fun provideExposureData(): ExposureEvent? {
return exposureEvent?.getFreshExposureEvent()
}
}
}

View File

@ -13,9 +13,8 @@ import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.entity.SubjectEntity
import com.gh.gamecenter.eventbus.EBDownloadStatus
import com.gh.gamecenter.eventbus.EBPackage
import com.gh.gamecenter.feature.entity.CustomPageTrackData
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.exposure.IExposureProvider
import com.gh.gamecenter.feature.game.GameItemViewHolder
import com.gh.gamecenter.feature.minigame.MiniGameItemHelper
import com.gh.gamecenter.game.vertical.GameItemUi
@ -104,11 +103,9 @@ class CustomGameVerticalAdapter(
class SimpleGameItemViewHolder(
private val ui: GameItemUi,
private val eventHelper: SubjectEventHelper
) : ViewHolder(ui.root), IExposureProvider {
) : ViewHolder(ui.root) {
var placeholderGameViewHolder: GameViewHolder? = null
private var boundedGameEntity: GameEntity? = null
fun bindSimpleGameItem(
adapter: RecyclerView.Adapter<ViewHolder>,
gameEntity: GameEntity,
@ -125,8 +122,6 @@ class CustomGameVerticalAdapter(
) {
val context = itemView.context
boundedGameEntity = gameEntity
val paddingStart = 16F.dip2px()
val isEndOfRow = position >= if (adapter.itemCount % spanCount == 0) {
adapter.itemCount - spanCount
@ -225,10 +220,6 @@ class CustomGameVerticalAdapter(
root.setPadding(paddingStart, root.paddingTop, paddingEnd, root.paddingBottom)
}
}
override fun provideExposureData(): ExposureEvent? {
return boundedGameEntity?.exposureEvent?.getFreshExposureEvent()
}
}
}

View File

@ -12,8 +12,6 @@ import com.gh.gamecenter.common.utils.safelyGetInRelease
import com.gh.gamecenter.common.view.AsyncCell
import com.gh.gamecenter.core.utils.DisplayUtils
import com.gh.gamecenter.databinding.HomeGameCollectionCardItemCustomBinding
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.exposure.IExposureListProvider
import com.gh.gamecenter.home.PageConfigure
import com.gh.gamecenter.home.custom.eventlistener.GameSubjectCollectionEventHelper
import com.gh.gamecenter.home.custom.model.CustomPageData
@ -23,9 +21,10 @@ class CustomHomeGameCollectionCarouselAdapter(
context: Context,
private val pageConfigure: PageConfigure,
private val eventHelper: GameSubjectCollectionEventHelper
) : CustomBaseChildAdapter<
CustomPageData.LinkColumnCollection.CustomSubjectEntity,
CustomHomeGameCollectionCarouselAdapter.HomeGameCollectionCardViewHolder>(context) {
) :
CustomBaseChildAdapter<CustomPageData.LinkColumnCollection.CustomSubjectEntity, CustomHomeGameCollectionCarouselAdapter.HomeGameCollectionCardViewHolder>(
context
) {
private val mPosterWidth = DisplayUtils.getScreenWidth() - 50F.dip2px()
@ -49,8 +48,10 @@ class CustomHomeGameCollectionCarouselAdapter(
pageConfigure.entrance,
position
)
}
}
}
override fun getItemViewType(position: Int) = position
@ -67,18 +68,15 @@ class CustomHomeGameCollectionCarouselAdapter(
}
inner class HomeGameCollectionCardViewHolder(cell: HomeGameCollectionCarouselItemCell) :
BaseRecyclerViewHolder<Any>(cell), IExposureListProvider {
private var boundedItemData: CustomPageData.LinkColumnCollection.CustomSubjectEntity? = null
BaseRecyclerViewHolder<Any>(cell) {
fun bindGameCollectionCard(
binding: HomeGameCollectionCardItemCustomBinding,
itemData: CustomPageData.LinkColumnCollection.CustomSubjectEntity,
entrance: String,
itemPosition: Int
) {
boundedItemData = itemData
binding.run {
val context = root.context
root.layoutParams.width = mPosterWidth
if (itemData.user.isValid) {
@ -123,15 +121,8 @@ class CustomHomeGameCollectionCarouselAdapter(
root.setOnClickListener {
eventHelper.navigateSubjectCollectionPage(itemPosition, itemData)
}
}
}
override fun provideExposureData(): ExposureEvent? = null
override fun provideExposureDataList(): List<ExposureEvent>? {
return boundedItemData?.games?.map {
it.exposureEvent?.getFreshExposureEvent()!!
}
}
}
}

View File

@ -18,9 +18,8 @@ import com.gh.gamecenter.databinding.ItemHomeGameCollectionBigSlideCardGameBindi
import com.gh.gamecenter.databinding.ItemHomeGameCollectionSmallSlideCardCustomBinding
import com.gh.gamecenter.eventbus.EBDownloadStatus
import com.gh.gamecenter.eventbus.EBPackage
import com.gh.gamecenter.feature.entity.CustomPageTrackData
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.exposure.IExposureListProvider
import com.gh.gamecenter.home.custom.IGameChangedNotifier
import com.gh.gamecenter.home.custom.eventlistener.GameSubjectCollectionEventHelper
import com.gh.gamecenter.home.custom.model.CustomPageData
@ -107,7 +106,6 @@ class CustomHomeGameCollectionSlideAdapter(
// 小卡片
if (holder is HomeGameCollectionSmallSlideCardViewHolder) {
holder.updateSubject(subject)
holder.binding.run {
val params = root.layoutParams as ViewGroup.MarginLayoutParams
params.leftMargin = if (position == 0) 0 else (-24F).dip2px()
@ -186,10 +184,8 @@ class CustomHomeGameCollectionSlideAdapter(
}
}
inner class HomeGameCollectionBigSlideCardViewHolder(view: View) :
BaseRecyclerViewHolder<Any>(view),
IGameChangedNotifier,
IExposureListProvider {
inner class HomeGameCollectionBigSlideCardViewHolder(view: View) : BaseRecyclerViewHolder<Any>(view),
IGameChangedNotifier {
private var subject: CustomPageData.LinkColumnCollection.CustomSubjectEntity? = null
@ -298,33 +294,8 @@ class CustomHomeGameCollectionSlideAdapter(
eventHelper.navigateToGameDetailPage(bindingAdapterPosition, gameEntity, subject)
}
}
override fun provideExposureDataList(): List<ExposureEvent>? {
return subject?.games?.map {
it.exposureEvent?.getFreshExposureEvent()!!
}
}
override fun provideExposureData(): ExposureEvent? = null
}
class HomeGameCollectionSmallSlideCardViewHolder(val binding: ItemHomeGameCollectionSmallSlideCardCustomBinding) :
RecyclerView.ViewHolder(binding.root),
IExposureListProvider {
private var boundedSubject: CustomPageData.LinkColumnCollection.CustomSubjectEntity? = null
fun updateSubject(subject: CustomPageData.LinkColumnCollection.CustomSubjectEntity) {
boundedSubject = subject
}
override fun provideExposureDataList(): List<ExposureEvent>? {
return boundedSubject?.games?.map {
it.exposureEvent?.getFreshExposureEvent()!!
}
}
override fun provideExposureData(): ExposureEvent? = null
}
RecyclerView.ViewHolder(binding.root)
}

View File

@ -5,28 +5,20 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView.ViewHolder
import com.gh.common.util.DownloadItemUtils
import com.gh.gamecenter.common.exposure.ExposureSource
import com.gh.gamecenter.common.utils.SensorsBridge
import com.gh.gamecenter.common.utils.toBinding
import com.gh.gamecenter.core.utils.StringUtils
import com.gh.gamecenter.entity.GameDataWrapper
import com.gh.gamecenter.eventbus.EBDownloadStatus
import com.gh.gamecenter.eventbus.EBPackage
import com.gh.gamecenter.feature.entity.CustomPageTrackData
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.entity.PageLocation
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.home.PageConfigure
import com.gh.gamecenter.home.custom.createExposureEvent
import com.gh.gamecenter.home.custom.eventlistener.OtherItemEventHelper
import com.gh.gamecenter.home.custom.model.CustomPageItem
import com.gh.gamecenter.home.test_v2.HomeGameTestV2GameListPlaceHolderViewHolder
import com.gh.gamecenter.home.test_v2.HomeGameTestV2GameListSpaceViewHolder
import com.gh.gamecenter.home.test_v2.HomeGameTestV2GameListViewHolder
import com.lightgame.download.DownloadEntity
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
/**
* @author : liujiarui
@ -38,9 +30,7 @@ class CustomHomeGameTestV2GameListRvAdapter(
private val childEventHelper: OtherItemEventHelper,
private val linkText: String,
private val pageLocation: PageLocation,
private val pageConfigure: PageConfigure,
private val componentPosition: Int,
private val trackData: CustomPageTrackData,
private val exposureInvoke: (Int, GameEntity) -> ExposureEvent
) : CustomBaseChildAdapter<GameDataWrapper, ViewHolder>(context) {
private val mEntrance: String = "新游开测"
@ -72,6 +62,7 @@ class CustomHomeGameTestV2GameListRvAdapter(
&& oldItem.gameData?.id == newItem.gameData?.id
&& oldItem.gameData?.name == newItem.gameData?.name
}
}, false).dispatchUpdatesTo(this)
}
@ -184,6 +175,7 @@ class CustomHomeGameTestV2GameListRvAdapter(
notifyItemChanged(index)
}
}
}
override fun notifyDownloadDeleted(status: EBDownloadStatus) {
@ -209,21 +201,17 @@ class CustomHomeGameTestV2GameListRvAdapter(
gameEntity: GameEntity,
position: Int
): ExposureEvent {
val time = gameEntity.time?.time ?: 0L
val date = Date(time * 1000L)
val sdf = SimpleDateFormat("MM.dd", Locale.CHINA)
val format = sdf.format(date)
gameEntity.exposureEvent = createExposureEvent(
gameEntity,
listOf(ExposureSource("新游开测", "$linkText-$format")),
pageConfigure.exposureSourceList,
position,
componentPosition,
trackData
)
return gameEntity.exposureEvent!!
return exposureInvoke(position, gameEntity)
}
/**
* 左右滑动曝光条目
*/
fun exposureItem(firstItemPosition: Int) {
val gameList = dataList
for (position in firstItemPosition..firstItemPosition + 2) {
val gameEntity = gameList.getOrNull(position)?.gameData ?: continue
putExposureEvent(gameEntity, position)
}
}
}

View File

@ -6,7 +6,9 @@ import com.gh.gamecenter.common.utils.dip2px
import com.gh.gamecenter.common.utils.toBinding
import com.gh.gamecenter.eventbus.EBDownloadStatus
import com.gh.gamecenter.eventbus.EBPackage
import com.gh.gamecenter.feature.entity.CustomPageTrackData
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.home.PageConfigure
import com.gh.gamecenter.home.custom.eventlistener.SubjectEventHelper
import com.gh.gamecenter.home.custom.model.CustomSubjectItem
@ -21,6 +23,7 @@ class CustomHomeHorizontalSlideVideoAdapter(
context: Context,
private val pageConfigure: PageConfigure,
private val eventHelper: SubjectEventHelper,
private val exposureClosure: (GameEntity, Int) -> ExposureEvent,
) : CustomBaseChildAdapter<GameEntity, CustomHomeHorizontalSlideVideoItemViewHolder>(context) {
private lateinit var item: CustomSubjectItem
@ -41,6 +44,8 @@ class CustomHomeHorizontalSlideVideoAdapter(
override fun onBindViewHolder(holder: CustomHomeHorizontalSlideVideoItemViewHolder, position: Int) {
val gameEntity = dataList[position]
val event = exposureClosure(gameEntity, position)
holder.binding.root.setPadding(
16F.dip2px(),
holder.binding.root.topPadding,
@ -62,11 +67,13 @@ class CustomHomeHorizontalSlideVideoAdapter(
gameEntity,
this,
pageConfigure.entrance,
event,
item.data.showIndexIconSubscript,
item.data.showIndexSubtitle
)
}
override fun notifyDownload(download: DownloadEntity) {
dataList.forEachIndexed { index, game ->
if (game.id == download.gameId) {

View File

@ -10,8 +10,6 @@ import com.gh.gamecenter.common.entity.IconFloat
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.core.utils.ToastUtils
import com.gh.gamecenter.databinding.ItemHomeVgameRefactorBinding
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.exposure.IExposureProvider
import com.gh.gamecenter.home.custom.eventlistener.OtherItemEventHelper
import com.gh.gamecenter.manager.PackagesManager
import com.gh.vspace.VGameItemData
@ -54,13 +52,9 @@ class CustomHomeRecentVGameAdapter(
private var binding: ItemHomeVgameRefactorBinding,
private val childEventHelper: OtherItemEventHelper
) :
RecyclerView.ViewHolder(binding.root), IExposureProvider {
private var boundedItem: VGameItemData? = null
RecyclerView.ViewHolder(binding.root) {
fun bindView(entity: VGameItemData) {
boundedItem = entity
if (binding.gameIconIv.getTag(R.string.app_name) != entity.downloadEntity.packageName) {
val iconFloat = IconFloat(
entity.downloadEntity.getMetaExtra(Constants.GAME_ICON_FLOAT_TOP_TEXT),
@ -182,9 +176,5 @@ class CustomHomeRecentVGameAdapter(
binding.controlTv.text = itemData.controlText
binding.progressBar.progress = downloadEntity.percent.toInt()
}
override fun provideExposureData(): ExposureEvent? {
return boundedItem?.exposureEvent?.getFreshExposureEvent()
}
}
}

View File

@ -130,6 +130,7 @@ class CustomHomeRecommendItemGridAdapter(
}
interface OnEventListener {
fun navigateToLinkPage(link: LinkEntity, text: String, exposureEvent: ExposureEvent?)
}
}

View File

@ -15,6 +15,8 @@ import com.gh.gamecenter.common.entity.LinkEntity
import com.gh.gamecenter.common.utils.DataLogUtils
import com.gh.gamecenter.common.utils.goneIf
import com.gh.gamecenter.common.utils.toBinding
import com.gh.gamecenter.core.runOnIoThread
import com.gh.gamecenter.core.utils.MtaHelper
import com.gh.gamecenter.core.utils.PageSwitchDataHelper
import com.gh.gamecenter.entity.HomeSlide
import com.gh.gamecenter.feature.entity.GameEntity
@ -48,6 +50,7 @@ class CustomHomeSlideListAdapter(
}
}
val dataCount: Int
get() = dataList.size
@ -74,8 +77,21 @@ class CustomHomeSlideListAdapter(
return
}
val homeSlide = dataList[actualPosition]
val game = homeSlide.linkGame
if (homeSlide.linkType == "game") {
game?.exposureEvent = listener.createExposureEvent(actualPosition, game)
} else {
game?.exposureEvent = listener.createExposureEvent(actualPosition, game)
?.also {
it.payload.controlType = "轮播图"
it.payload.controlName = homeSlide.title
it.payload.controlLinkName = homeSlide.linkText
it.payload.controlLinkType = homeSlide.linkType
}
}
if (holder is CustomHomeSlideListItemViewHolder) {
holder.bindSlideListItem(homeSlide)
@ -113,6 +129,11 @@ class CustomHomeSlideListAdapter(
) {
rootView.setOnClickListener {
val actualPositionString = (actualPosition + 1).toString()
if (homeSlide.linkType == "video") {
MtaHelper.onEvent("首页_新", "轮播_点击", actualPositionString + "_视频详情")
} else if (homeSlide.linkType == "game") {
MtaHelper.onEvent("首页_新", "轮播_点击", actualPositionString + "_游戏详情")
}
PageSwitchDataHelper.pushCurrentPageData(
hashMapOf(
@ -219,8 +240,11 @@ class CustomHomeSlideListAdapter(
fun getActualSize() = dataList.size
interface OnEventListener {
fun createExposureEvent(actualPosition: Int, game: GameEntity?): ExposureEvent?
fun navigateToGameDetailPage(actualPosition: Int, game: GameEntity, text: String, link: LinkEntity?)
fun navigateToLinkPage(link: LinkEntity, text: String, exposureEvent: ExposureEvent?)
}
}

View File

@ -1,18 +1,20 @@
package com.gh.gamecenter.home.custom.adapter
import android.content.Context
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView.ViewHolder
import com.gh.common.util.DownloadItemUtils
import com.gh.gamecenter.R
import com.gh.gamecenter.adapter.viewholder.GameViewHolder
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.core.utils.StringUtils
import com.gh.gamecenter.databinding.RecyclerChildIconMatrixCustomBinding
import com.gh.gamecenter.eventbus.EBDownloadStatus
import com.gh.gamecenter.eventbus.EBPackage
import com.gh.gamecenter.feature.entity.CustomPageTrackData
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.exposure.IExposureProvider
import com.gh.gamecenter.home.custom.adapter.CustomPageAdapter.Companion.PAYLOAD_REFRESH_GAME_CHANGED
import com.gh.gamecenter.home.custom.eventlistener.SubjectEventHelper
import com.gh.gamecenter.home.custom.model.CustomSplitSubjectItem
@ -48,9 +50,6 @@ class CustomIconMatrixAdapter(
val isRefreshDownloadStatus = payloads.any {
PAYLOAD_REFRESH_GAME_CHANGED == it
}
holder.boundedGameEntity = getItem(position)
if (isRefreshDownloadStatus) {
DownloadItemUtils.updateItem(
context,
@ -78,6 +77,7 @@ class CustomIconMatrixAdapter(
item.name
)
gameName.maxLines = if (subject.showDownload) 1 else 2
}
val showStar = subject.showStar
&& subject.data?.any { it.commentCount > 3 } ?: false
@ -123,6 +123,7 @@ class CustomIconMatrixAdapter(
notifyItemChanged(index, PAYLOAD_REFRESH_GAME_CHANGED)
}
}
}
override fun notifyDownloadDeleted(status: EBDownloadStatus) {
@ -146,11 +147,5 @@ class CustomIconMatrixAdapter(
class CustomChildIconMatrixViewHolder(
val binding: RecyclerChildIconMatrixCustomBinding
) : ViewHolder(binding.root), IExposureProvider {
var boundedGameEntity: GameEntity? = null
override fun provideExposureData(): ExposureEvent? {
return boundedGameEntity?.exposureEvent?.getFreshExposureEvent()
}
}
) : ViewHolder(binding.root)
}

View File

@ -9,11 +9,13 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.OnScrollListener
import com.gh.common.exposure.IExposable
import com.gh.gamecenter.R
import com.gh.gamecenter.common.baselist.LoadStatus
import com.gh.gamecenter.common.utils.toBinding
import com.gh.gamecenter.eventbus.EBDownloadStatus
import com.gh.gamecenter.eventbus.EBPackage
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.game.GameAndPosition
import com.gh.gamecenter.home.custom.CustomPageViewModel
import com.gh.gamecenter.home.custom.IGameChangedNotifier
@ -67,7 +69,7 @@ class CustomPageAdapter(
private val viewModel: CustomPageViewModel,
private val lifecycleOwner: LifecycleOwner,
private val scrollCalculatorHelper: ScrollCalculatorHelper,
) : ListAdapter<CustomPageItem, BaseCustomViewHolder>(CALLBACK), IGameChangedNotifier {
) : ListAdapter<CustomPageItem, BaseCustomViewHolder>(CALLBACK), IExposable, IGameChangedNotifier {
private var loadStatus: LoadStatus? = null
@ -84,13 +86,13 @@ class CustomPageAdapter(
}
val firstShowPosition: LiveData<Int> = _firstShowPosition
override fun submitList(list: List<CustomPageItem>?, commitCallback: Runnable?) {
override fun submitList(list: List<CustomPageItem>?) {
val dataWithFooter = if (list.isNullOrEmpty()) {
ArrayList(list)
} else {
list + CustomFooterItem
}
super.submitList(dataWithFooter, commitCallback)
super.submitList(dataWithFooter)
}
/**
@ -304,10 +306,10 @@ class CustomPageAdapter(
val item = getItem(position)
when (holder) {
is CustomDoubleCardViewHolder -> holder.bindView(item)
is CustomHomeHorizontalSlideVideoListViewHolder -> holder.bindView(item)
is CustomGameItemViewHolder -> holder.bindView(item, this)
is CustomGameItemViewHolder -> {
holder.bindView(item, this)
}
is CustomGameVerticalSlideViewHolder -> holder.bindView(item)
@ -337,7 +339,9 @@ class CustomPageAdapter(
is CustomHomeItemGameTestV2ViewHolder -> holder.bindView(item, position)
is CustomHomeDiscoverCardViewHolder -> holder.bindView(item, position)
is CustomHomeDiscoverCardViewHolder -> {
holder.bindView(item, position)
}
is CustomBigImageRecommendViewHolder -> holder.bindView(item)
@ -411,6 +415,14 @@ class CustomPageAdapter(
holder.onViewDetach(recyclerView)
}
override fun getEventByPosition(pos: Int): ExposureEvent? {
return getItem(pos).exposureEvent
}
override fun getEventListByPosition(pos: Int): List<ExposureEvent>? {
return getItem(pos).exposureEventList
}
override fun notifyDownload(download: DownloadEntity) {
val data = getGameEntityByPackage(download.packageName)
data.forEach { (game, position, _) ->
@ -436,6 +448,7 @@ class CustomPageAdapter(
it.notifyDownloadDeleted(status)
}
}
}
override fun notifyInstalled(busFour: EBPackage) {
@ -504,6 +517,7 @@ class CustomPageAdapter(
private val onLoadMoreListener = object : OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy)
val layoutManger = recyclerView.layoutManager
@ -514,6 +528,7 @@ class CustomPageAdapter(
}
}
}
}

View File

@ -10,9 +10,8 @@ import com.gh.gamecenter.common.view.AsyncCell
import com.gh.gamecenter.databinding.RankCollectionItemCustomBinding
import com.gh.gamecenter.eventbus.EBDownloadStatus
import com.gh.gamecenter.eventbus.EBPackage
import com.gh.gamecenter.feature.entity.CustomPageTrackData
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.exposure.IExposureListProvider
import com.gh.gamecenter.game.rank.CustomRankGameItem
import com.gh.gamecenter.game.rank.RankGameItemUi
import com.gh.gamecenter.home.custom.IGameChangedNotifier
@ -110,6 +109,8 @@ class CustomRankCollectionAdapter(
holder.gameItemList[i].rankItemUi.root.visibility = View.GONE
}
}
}
}
}
@ -137,6 +138,7 @@ class CustomRankCollectionAdapter(
override fun onViewAttachedToWindow(holder: RankCollectionItemViewHolder) {
super.onViewAttachedToWindow(holder)
viewHolderList.add(holder)
}
override fun onViewDetachedFromWindow(holder: RankCollectionItemViewHolder) {
@ -160,7 +162,7 @@ class CustomRankCollectionAdapter(
}
inner class RankCollectionItemViewHolder(view: View) :
BaseRecyclerViewHolder<Any>(view), IGameChangedNotifier, IExposureListProvider {
BaseRecyclerViewHolder<Any>(view), IGameChangedNotifier {
val gameItemList = arrayListOf<CustomRankGameItem>()
@ -233,13 +235,5 @@ class CustomRankCollectionAdapter(
}
}
}
override fun provideExposureData(): ExposureEvent? = null
override fun provideExposureDataList(): List<ExposureEvent>? {
return subjectEntity?.games?.map {
it.exposureEvent?.getFreshExposureEvent()!!
}
}
}
}

View File

@ -9,8 +9,6 @@ import com.gh.gamecenter.common.utils.toBinding
import com.gh.gamecenter.common.utils.toColor
import com.gh.gamecenter.databinding.RecyclerRefreshIconItemCustomBinding
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.exposure.IExposureProvider
import com.gh.gamecenter.game.horizontal.GameHorizontalSimpleItemViewHolder
import com.gh.gamecenter.home.custom.eventlistener.GameSubjectCollectionEventHelper
import com.gh.gamecenter.home.custom.model.CustomPageData
@ -18,6 +16,7 @@ import com.gh.gamecenter.home.custom.model.CustomPageData
class CustomRefreshIconAdapter(
context: Context,
private val eventHelper: GameSubjectCollectionEventHelper,
private val exposureInvoke: (Int, GameEntity) -> Unit
) : CustomBaseChildAdapter<GameEntity, CustomRefreshIconAdapter.RefreshIconChildViewHolder>(context) {
private var collectionName = ""
@ -46,7 +45,8 @@ class CustomRefreshIconAdapter(
override fun onBindViewHolder(holder: RefreshIconChildViewHolder, position: Int) {
val gameEntity = getItem(position)
holder.exposureEvent = gameEntity.exposureEvent
exposureInvoke(position, gameEntity)
holder.binding.run {
val padR = if (position == itemCount - 1) 16F.dip2px() else 0
root.setPadding(16F.dip2px(), 0, padR, 0)
@ -65,15 +65,10 @@ class CustomRefreshIconAdapter(
)
eventHelper.navigateToGameDetailPage(position, gameEntity, subject)
}
}
}
class RefreshIconChildViewHolder(val binding: RecyclerRefreshIconItemCustomBinding) :
ViewHolder(binding.root), IExposureProvider {
var exposureEvent: ExposureEvent? = null
override fun provideExposureData(): ExposureEvent? {
return exposureEvent?.getFreshExposureEvent()
}
}
class RefreshIconChildViewHolder(val binding: RecyclerRefreshIconItemCustomBinding) : ViewHolder(binding.root)
}

View File

@ -6,11 +6,12 @@ import androidx.recyclerview.widget.RecyclerView
import com.gh.gamecenter.common.utils.toBinding
import com.gh.gamecenter.common.utils.visibleIf
import com.gh.gamecenter.databinding.RecyclerNotificationColumnItemBinding
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.exposure.IExposureProvider
import com.gh.gamecenter.home.custom.model.CustomPageData
class NotificationColumnAdapter(context: Context, ) :
class NotificationColumnAdapter(
context: Context,
private val exposureInvoke: (Int, CustomPageData.Notify) -> Unit
) :
CustomBaseChildAdapter<CustomPageData.Notify, NotificationColumnAdapter.NotificationColumChildViewHolder>(context) {
private var toBeDeletedItemIds = arrayListOf<String>()
@ -50,14 +51,13 @@ class NotificationColumnAdapter(context: Context, ) :
override fun onBindViewHolder(holder: NotificationColumChildViewHolder, position: Int) {
val item = getItem(position)
holder.exposureEvent = item.exposureEvent
with(holder.binding) {
ivIcon.displayGameIcon(item.image, null, goneIfEmpty = true, null)
tvTitle.text = item.title
tvDesc.text = item.addedContent
ivClose.visibleIf(item.isClosable)
}
exposureInvoke(position, item)
}
private fun getValidItem(position: Int): CustomPageData.Notify {
@ -90,13 +90,5 @@ class NotificationColumnAdapter(context: Context, ) :
class NotificationColumChildViewHolder(
val binding: RecyclerNotificationColumnItemBinding
) : RecyclerView.ViewHolder(binding.root), IExposureProvider {
var exposureEvent: ExposureEvent? = null
override fun provideExposureData(): ExposureEvent? {
return exposureEvent?.getFreshExposureEvent()
}
}
) : RecyclerView.ViewHolder(binding.root)
}

View File

@ -9,8 +9,6 @@ import androidx.recyclerview.widget.RecyclerView
import com.gh.gamecenter.R
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.databinding.RecyclerRecommendCardItemBinding
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.exposure.IExposureProvider
import com.gh.gamecenter.home.custom.model.CustomPageData
import com.gh.gamecenter.home.custom.ui.RecommendCardUi
@ -25,6 +23,7 @@ class RecommendCardAdapter(
override fun onBindViewHolder(holder: RecommendCardChildViewHolder, position: Int) {
val item = getItem(position)
listener.onItemExposure(position, item)
holder.bind(item, position)
holder.itemView.setOnClickListener {
listener.onItemClick(position, item)
@ -32,13 +31,9 @@ class RecommendCardAdapter(
}
class RecommendCardChildViewHolder(val binding: RecyclerRecommendCardItemBinding) :
RecyclerView.ViewHolder(binding.root), IExposureProvider {
private var exposureEvent: ExposureEvent? = null
RecyclerView.ViewHolder(binding.root) {
fun bind(item: CustomPageData.RecommendCard, position: Int) {
exposureEvent = item.exposureEvent
binding.tvTitle.setTextColor(com.gh.gamecenter.common.R.color.text_primary.toColor(itemView.context))
binding.tvOriginalPrice.setTextColor(com.gh.gamecenter.common.R.color.text_tertiary.toColor(itemView.context))
@ -92,9 +87,5 @@ class RecommendCardAdapter(
hideOutOfBoundViewsIfNeed(views)
}
}
override fun provideExposureData(): ExposureEvent? {
return exposureEvent?.getFreshExposureEvent()
}
}
}

View File

@ -8,7 +8,6 @@ import com.gh.gamecenter.common.entity.PKEntity
import com.gh.gamecenter.entity.*
import com.gh.gamecenter.feature.entity.FloatingWindowEntity
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.IgnoredOnParcel
@ -567,8 +566,6 @@ class CustomPageData(
community = _linkCommunity
)
var exposureEvent: ExposureEvent? = null
data class Guide(
@SerializedName("text")
private val _text: String? = null
@ -636,8 +633,6 @@ class CustomPageData(
text = linkText,
community = _linkCommunity
)
var exposureEvent: ExposureEvent? = null
}
data class Announcement(
@ -680,8 +675,6 @@ class CustomPageData(
text = linkText,
community = _linkCommunity
)
var exposureEvent: ExposureEvent? = null
}
data class LinkRecentlyPlayed(
@ -762,8 +755,6 @@ class CustomPageData(
community = _linkCommunity
)
var exposureEvent: ExposureEvent? = null
data class TextWithSymbol(
@SerializedName("text")
private val _text: String? = null,

View File

@ -1,7 +1,6 @@
package com.gh.gamecenter.home.custom.model
import android.annotation.SuppressLint
import com.gh.common.util.AdHelper
import com.gh.gamecenter.BuildConfig
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.entity.PKEntity
@ -32,15 +31,9 @@ class CustomPageRemoteDataSource(
}
@SuppressLint("CheckResult")
fun loadCustomPageData(
pageId: String,
page: Int,
forceLoad: Boolean = false,
): Single<CustomPageData> {
val isDefaultPage = pageId == mainWrapperRepository.defaultCustomPageId
fun loadCustomPageData(pageId: String, page: Int, forceLoad: Boolean = false): Single<CustomPageData> {
return if (page == 1 &&
isDefaultPage &&
pageId == mainWrapperRepository.defaultCustomPageId &&
mainWrapperRepository.customPageLiveData.value != null &&
!forceLoad
) {
@ -48,11 +41,7 @@ class CustomPageRemoteDataSource(
it.onSuccess(mainWrapperRepository.customPageLiveData.value!!)
}
} else {
newApi.getCustomPageData(
pageId,
page,
if (!isDefaultPage) AdHelper.getIdfaString() else ""
)
newApi.getCustomPageData(pageId, page)
}
}

Some files were not shown because too many files have changed in this diff Show More