Compare commits

...

13 Commits

Author SHA1 Message Date
77ee092b5b chore: 版本更新至 5.30.2 2023-08-31 16:58:17 +08:00
c65147e309 Merge branch 'hotfix/v5.30.1-951/ad-sdk-init-issue' into 'release'
fix: 修复开屏广告有机率因为初始化问题导致无法显示的问题

See merge request halo/android/assistant-android!1307
2023-08-31 16:02:13 +08:00
1ff2bb0bcc fix: 修复开屏广告有机率因为初始化问题导致无法显示的问题 2023-08-31 15:45:46 +08:00
89ecf09b55 Merge branch 'hotfix/v5.30.1-951/gson-culprit' into 'release'
fix: 捕抓 gson toList 方法在部分设备上异常闪退的问题

See merge request halo/android/assistant-android!1304
2023-08-31 10:19:34 +08:00
2cfb227c22 fix: 捕抓 gson toList 方法在部分设备上异常闪退的问题 2023-08-31 10:18:02 +08:00
f34adc8e6d chore: 版本更新至 5.30.1 2023-08-30 17:39:45 +08:00
8606c8f87a Merge branch 'feature-GHZS-sentry-327130' into 'release'
Fix Sentry327130 QQ小游戏生命周期回调异常处理

See merge request halo/android/assistant-android!1301
2023-08-30 17:22:18 +08:00
caf2dbacf9 Fix Sentry327130 QQ小游戏生命周期回调异常处理 2023-08-30 17:22:18 +08:00
9587336b31 Merge branch 'fix/vgame_ui_issue' into 'release'
fix: 修复畅玩首页最近在玩区域的更多按钮被隐藏的问题

See merge request halo/android/assistant-android!1299
2023-08-30 15:23:31 +08:00
e1c2b2027a fix: 修复畅玩首页最近在玩区域的更多按钮被隐藏的问题 2023-08-30 15:22:39 +08:00
c5ff26c879 Merge branch 'fix/crashes' into 'release'
修复Sentry闪退问题

See merge request halo/android/assistant-android!1298
2023-08-30 15:10:57 +08:00
9690a695d4 fix: Sentry327122 https://sentry.shanqu.cc/organizations/lightgame/issues/327122/ 2023-08-30 15:06:59 +08:00
78e9c43f24 fix: Sentry323027 https://sentry.shanqu.cc/organizations/lightgame/issues/323027/ 2023-08-30 15:06:59 +08:00
10 changed files with 68 additions and 69 deletions

View File

@ -60,9 +60,6 @@ object AdDelegateHelper {
private val mGameSearchAdList: ArrayList<AdConfig> by lazy { arrayListOf() }
private var mVGameLaunchAd: AdConfig? = null
private var mIsCsjRequired: Boolean = false // 是否需要初始化穿山甲 SDK
private var mIsBeiziRequired: Boolean = false // 师傅需要初始化 Beizi SDK
private const val AD_SDK_CSJ = "穿山甲"
private const val AD_SDK_BEIZI = "倍孜"
private const val AD_TYPE_SDK = "third_party_ads" // 第三方 SDK 广告
@ -73,11 +70,32 @@ object AdDelegateHelper {
HaloApp.getInstance().getSharedPreferences("AdConfig", Context.MODE_PRIVATE)
}
fun initAdSdk(context: Context) {
// 初始化 Beizi
if (mBeiziAdImpl == null) {
mBeiziAdImpl =
ARouter.getInstance().build(RouteConsts.provider.beiziAd).navigation() as? IBeiziAdProvider
mBeiziAdImpl?.initSDK(context)
}
// 初始化穿山甲
if (mCsjAdImpl == null) {
mCsjAdImpl =
ARouter.getInstance().build(RouteConsts.provider.csjAd).navigation() as? ICsjAdProvider
mCsjAdImpl?.initSDK(context, BuildConfig.CSJ_APPID, HaloApp.getInstance().oaid)
// 监听亮色/暗色模式切换
DarkModeUtils.registerModeChangeListener {
val topActivity = CurrentActivityHolder.getCurrentActivity() ?: return@registerModeChangeListener
updateThemeStatus(context, DarkModeUtils.isDarkModeOn(topActivity))
}
}
}
/**
* 请求接口获取广告相关配置
*/
@SuppressLint("CheckResult")
fun requestAdConfig(context: Context, isFromRetry: Boolean) {
fun requestAdConfig(isFromRetry: Boolean) {
// mAdConfigList 不为空不需要重试
if (isFromRetry && mAdConfigList != null) {
return
@ -89,7 +107,7 @@ object AdDelegateHelper {
.subscribeOn(Schedulers.io())
.subscribe(object : BiResponse<List<AdConfig>>() {
override fun onSuccess(data: List<AdConfig>) {
handleAdConfig(context, data)
handleAdConfig(data)
// 缓存数据到 SP 供接口请求失败用
SPUtils.setString(mAdConfigSp, KEY_CACHE_CONFIG, data.toJson())
@ -101,7 +119,7 @@ object AdDelegateHelper {
// 若接口请求失败时,从 SP 里获取上次缓存的数据
val cachedConfig: List<AdConfig>? = SPUtils.getString(mAdConfigSp, KEY_CACHE_CONFIG).toObject()
if (cachedConfig != null) {
handleAdConfig(context, cachedConfig)
handleAdConfig(cachedConfig)
}
}
})
@ -124,7 +142,7 @@ object AdDelegateHelper {
/**
* 处理广告配置
*/
fun handleAdConfig(context: Context, configList: List<AdConfig>) {
fun handleAdConfig(configList: List<AdConfig>) {
for (config in configList) {
// 处理返回的数据
when (config.location) {
@ -133,39 +151,6 @@ object AdDelegateHelper {
"game_search" -> config.let { mGameSearchAdList.add(it) }
"helper_launch" -> mVGameLaunchAd = config
}
// 根据返回的值里判断是否含有 Beizi 的广告
if (!mIsBeiziRequired) {
if (config.thirdPartyAd?.sourceName == AD_SDK_BEIZI) {
mIsBeiziRequired = true
}
}
// 根据返回的值里判断是否含有 穿山甲 的广告
if (!mIsCsjRequired) {
if (config.thirdPartyAd?.sourceName == AD_SDK_CSJ) {
mIsCsjRequired = true
}
}
}
// 初始化 Beizi
if (mIsBeiziRequired && mBeiziAdImpl == null) {
mBeiziAdImpl =
ARouter.getInstance().build(RouteConsts.provider.beiziAd).navigation() as? IBeiziAdProvider
mBeiziAdImpl?.initSDK(context)
}
// 初始化穿山甲
if (mIsCsjRequired && mCsjAdImpl == null) {
mCsjAdImpl =
ARouter.getInstance().build(RouteConsts.provider.csjAd).navigation() as? ICsjAdProvider
mCsjAdImpl?.initSDK(context, BuildConfig.CSJ_APPID, HaloApp.getInstance().oaid)
// 监听亮色/暗色模式切换
DarkModeUtils.registerModeChangeListener {
val topActivity = CurrentActivityHolder.getCurrentActivity() ?: return@registerModeChangeListener
updateThemeStatus(context, DarkModeUtils.isDarkModeOn(topActivity))
}
}
}

View File

@ -24,7 +24,7 @@ public class NetworkStateReceiver extends BroadcastReceiver {
// 奇怪,初次注册监听就会有回调,会导致部分接口短时间内触发两次调用
ExtensionsKt.doOnMainProcessOnly(context, () -> {
if (NetworkUtils.isNetworkConnected(context)) {
AdDelegateHelper.INSTANCE.requestAdConfig(context, true);
AdDelegateHelper.INSTANCE.requestAdConfig(true);
RegionSettingHelper.getRegionSetting();
ReservationRepository.refreshReservationsIfNeeded();
EventBus.getDefault().post(new EBNetworkState(NetworkUtils.isNetworkConnected(context)));

View File

@ -31,15 +31,17 @@ class GameServerTestActivity : DownloadToolbarActivity() {
companion object {
fun getIntent(context: Context, id: String, title: String, entrance: String, traceEvent: ExposureEvent?): Intent {
val bundle = Bundle()
val exposureSourceList = traceEvent?.source
bundle.putString(GameServersTestFragment.TEST_COLUMN_ID, id)
bundle.putString(GameServersTestFragment.TEST_TITLE, title)
bundle.putString(EntranceConsts.KEY_ENTRANCE, entrance)
if (exposureSourceList is ArrayList) {
bundle.putParcelableArrayList(EntranceConsts.KEY_EXPOSURE_SOURCE_LIST, exposureSourceList)
} else {
bundle.putParcelableArrayList(EntranceConsts.KEY_EXPOSURE_SOURCE_LIST, ArrayList(exposureSourceList))
traceEvent?.source?.let {
if (it is ArrayList) {
bundle.putParcelableArrayList(EntranceConsts.KEY_EXPOSURE_SOURCE_LIST, it)
} else {
bundle.putParcelableArrayList(EntranceConsts.KEY_EXPOSURE_SOURCE_LIST, ArrayList(it))
}
}
return getTargetIntent(
context,
GameServerTestActivity::class.java,

View File

@ -1,6 +1,7 @@
package com.gh.vspace
import android.content.Context
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
@ -43,6 +44,7 @@ class HomeRecentVGameViewHolder(var binding: ItemHomeRecentVgameBinding) :
}
})
binding.moreTv.visibility = View.VISIBLE
binding.moreTv.setOnClickListener {
NewFlatLogUtils.logHaloFunManageShow("最近在玩")
binding.root.context.startActivity(

View File

@ -306,9 +306,10 @@ public class HaloApp extends MultiDexApplication {
// 获取 settings 配置
ExtensionsKt.doOnMainProcessOnly(this, com.gh.common.constant.Config::getGhzsSettings);
// 获取广告配置
// 初始化广告 SDK 并获取广告配置
ExtensionsKt.doOnMainProcessOnly(this, () -> {
AdDelegateHelper.INSTANCE.requestAdConfig(this, false);
AdDelegateHelper.INSTANCE.initAdSdk(this);
AdDelegateHelper.INSTANCE.requestAdConfig(false);
});
String localTemporaryDeviceId = SPUtils.getString(Constants.SP_TEMPORARY_DEVICE_ID);

View File

@ -7,8 +7,8 @@ ext {
targetSdkVersion = 28
// application info (每个大版本之间的 versionCode 增加 20)
versionCode = 950
versionName = "5.30.0"
versionCode = 952
versionName = "5.30.2"
applicationId = "com.gh.gamecenter"
// AndroidX

View File

@ -22,6 +22,8 @@ object CsjAdHelper {
const val TAG = "CsjAdHelper"
var mIsInitialed = false
fun init(context: Context, csjId: String, oaid: String) {
try {
@ -80,10 +82,12 @@ object CsjAdHelper {
object : InitCallback {
override fun success() {
Utils.log(TAG, "穿山甲初始化成功")
mIsInitialed = true
}
override fun fail(p0: Int, p1: String?) {
Utils.log(TAG, "穿山甲初始化失败, $p0 $p1")
mIsInitialed = false
}
})
}
@ -116,6 +120,14 @@ object CsjAdHelper {
.setAdLoadType(TTAdLoadType.LOAD)// 推荐使用,用于标注此次的广告请求用途为预加载(当做缓存)还是实时加载,方便后续为开发者优化相关策略
.build()
Utils.log(TAG, "请求开屏广告")
if (!mIsInitialed) {
Utils.log(TAG, "初始化未完成,不加载开屏动画")
callback.invoke(false)
return
}
mTTAdNative.loadSplashAd(adSlot, object : CSJSplashAdListener {
override fun onSplashLoadSuccess() {
Utils.log(TAG, "开屏广告加载成功")
@ -201,7 +213,7 @@ object CsjAdHelper {
mTTAdNative.loadNativeExpressAd(adSlot, object : NativeExpressAdListener {
// 广告请求失败
override fun onError(code: Int, message: String) {
Utils.log(TAG, "requestFlowAd 广告请求失败 $message")
Utils.log(TAG, "requestFlowAd $code 广告请求失败 $message")
callback.invoke(false)
}

View File

@ -11,20 +11,15 @@ import com.tencent.qqmini.sdk.launcher.model.MiniAppInfo
class MiniCustomizedProxyImpl : MiniCustomizedProxy() {
override fun onAppStateChange(info: MiniAppInfo, appState: Int) {
val provider = ARouter
.getInstance()
.build(RouteConsts.provider.realName)
.navigation() as IRealNameProvider
when(appState) {
AppState.STATE_SHOW -> provider.setAppInfo(info.appId, info.name) {
QGameHelper.stopMiniApp(AppLoaderFactory.g().context, info, true)
}
AppState.STATE_HIDE -> {}
AppState.STATE_STOP -> {}
}
override fun onAppStateChange(info: MiniAppInfo?, appState: Int) {
if(info != null && appState == AppState.STATE_SHOW) {
val provider = ARouter
.getInstance()
.build(RouteConsts.provider.realName)
.navigation() as IRealNameProvider
provider.setAppInfo(info.appId, info.name) {
QGameHelper.stopMiniApp(AppLoaderFactory.g().context, info, true)
}
}
}
}

View File

@ -21,21 +21,23 @@ object GsonUtils {
}
@JvmStatic
@Deprecated("部分 7.1.1 设备会出现 AssertionError尽量不要在关键功能上使用此方法")
fun <T> fromJsonList(json: JSONArray): List<T> {
return try {
val type = object : TypeToken<List<T>>() {}.type
return gson.fromJson(json.toString(), type)
} catch (e: Exception) {
} catch (e: Throwable) {
listOf()
}
}
@JvmStatic
@Deprecated("部分 7.1.1 设备会出现 AssertionError尽量不要在关键功能上使用此方法")
fun <T> fromJsonList(json: String): List<T> {
return try {
val type = object : TypeToken<List<T>>() {}.type
gson.fromJson(json, type)
} catch (e: Exception) {
} catch (e: Throwable) {
listOf()
}
}

View File

@ -73,7 +73,7 @@ class SortedMessageListAdapter(
ovalHint.background = R.drawable.oval_message_hint_bg.toDrawable(mContext)
titleTv.text = entity.title
if (mMessageTypeMap.getOrDefault(entity.type, null) != null && entity.icon.isEmpty()) {
if (mMessageTypeMap[entity.type] != null && entity.icon.isEmpty()) {
ImageUtils.display(iconIv, mMessageTypeMap[entity.type])
} else {
ImageUtils.display(iconIv, entity.icon)