Compare commits
188 Commits
v5.32.5
...
v5.33.2-10
| Author | SHA1 | Date | |
|---|---|---|---|
| 98fb4b381a | |||
| 1afed0d6db | |||
| 5c872b282c | |||
| 12be13d267 | |||
| 83f50bb42c | |||
| 61e73ad932 | |||
| e811538bbd | |||
| 818dec8428 | |||
| b79ada682f | |||
| 78330c1d12 | |||
| ff6e73cdb1 | |||
| 4be928b015 | |||
| a28451a976 | |||
| ec70e2c47e | |||
| 68d546c7ca | |||
| 365aa5d8da | |||
| c842a9a184 | |||
| 6093b662a1 | |||
| 85d8638178 | |||
| ff434a0e51 | |||
| 93ec29884b | |||
| f7bb617edb | |||
| 1b5567f470 | |||
| d1628b3377 | |||
| 509d6f4ac6 | |||
| 5f9257a103 | |||
| d50bea5f62 | |||
| e138890f4d | |||
| 96734e3ead | |||
| 7a596f49ca | |||
| 564e5cbb8c | |||
| 25d7f2731a | |||
| 36c164da26 | |||
| 4996d62252 | |||
| 20bab0fc84 | |||
| 74f6f3467b | |||
| af4647dc37 | |||
| e2306124b2 | |||
| 00cd4c1f1f | |||
| 4ace4b8056 | |||
| bffdc42eac | |||
| 0d6aa9f11d | |||
| 357c48ab08 | |||
| f1d3705f80 | |||
| 699679289b | |||
| f8dc122c41 | |||
| 0a56189ae8 | |||
| e079116d80 | |||
| d661a91c2f | |||
| 3ff5b04893 | |||
| 9c8bc7742c | |||
| 4c01859683 | |||
| 794a681f07 | |||
| 9778cf439b | |||
| a66f62bcb7 | |||
| 0935a75ec0 | |||
| 0a221c07bf | |||
| 011ff1e24a | |||
| 9cd8b5d8d5 | |||
| 1eb77e8bd2 | |||
| 650dd2e2ad | |||
| 563955940d | |||
| 376996540d | |||
| 1292446bd0 | |||
| 427ce5bc38 | |||
| e7897f9b18 | |||
| 55ece981b5 | |||
| 7f68b165cb | |||
| bf46229bcd | |||
| ce80f133a0 | |||
| e5ea731946 | |||
| 24d7f60426 | |||
| 3a0205789a | |||
| f86edd196f | |||
| 898278b3d9 | |||
| fd757a346c | |||
| ed32da8882 | |||
| d7e88ba38a | |||
| af0ba215dd | |||
| 8e7a168495 | |||
| 913bf7ad2f | |||
| 4d84af6ff9 | |||
| 1acfe4227f | |||
| 847def3d30 | |||
| f523e984c8 | |||
| 5fe39d69de | |||
| 0c76783397 | |||
| e4b5a6ef5a | |||
| f03a9677cc | |||
| c4b519204b | |||
| 423bcda7ff | |||
| 2bb61e8e4b | |||
| 84d8de881e | |||
| 3809d6d887 | |||
| 96c18ec7a6 | |||
| d052ef5923 | |||
| 993631c853 | |||
| 3a9958fa7d | |||
| bb51391b61 | |||
| 57f1cb7e59 | |||
| b4cd90a7e9 | |||
| 6ec9d2076f | |||
| 22c727cd2f | |||
| 5e5aee539e | |||
| c158225472 | |||
| ac5b7837db | |||
| 05a113de40 | |||
| d45d02bfd2 | |||
| 395433f21f | |||
| ccbd70666a | |||
| aaa8eda004 | |||
| 748497e5b1 | |||
| 1cf49b931e | |||
| e4a9d533d4 | |||
| 36e9bd20ac | |||
| cc4ef16e10 | |||
| 6a446a6f3a | |||
| 233e0ec71d | |||
| d6e1a90472 | |||
| 0911cd146b | |||
| 8e255b1803 | |||
| 14939625dd | |||
| 19afb7221d | |||
| ae0f4c948b | |||
| d650739632 | |||
| 6f6a734cb5 | |||
| e510146775 | |||
| 8b863955a3 | |||
| 37155b96dd | |||
| e55d4d3332 | |||
| 3e38830480 | |||
| dabf532ae7 | |||
| 7aa2b20224 | |||
| 10572e7b0b | |||
| 3912729fff | |||
| 78ff8dcb0a | |||
| 80e7ad9401 | |||
| a9ba7d056b | |||
| da4e83d29d | |||
| cc9c390bbb | |||
| d96ae0cdbb | |||
| c8a1bd5278 | |||
| aa0d36a3ba | |||
| ffe1c0606a | |||
| 7f73b728a5 | |||
| 5cfb7f5036 | |||
| 399e513174 | |||
| 1eeb34c93a | |||
| d18f3909ea | |||
| c23118e535 | |||
| 4d4498cdee | |||
| a348b80eaf | |||
| 64bdbbf409 | |||
| 984bb60e6a | |||
| 1461af16b9 | |||
| 14fca95ed6 | |||
| c3926c85d8 | |||
| 9b73272019 | |||
| 5757df01e7 | |||
| 3f60f85992 | |||
| 52980189ed | |||
| 852f7734ef | |||
| a25503113b | |||
| 0d6b62b361 | |||
| e3b8ea74c1 | |||
| bf10d5aa42 | |||
| 3efcd71046 | |||
| ce99eef958 | |||
| 4f1ccac6fc | |||
| 41c8d4950f | |||
| d633d9b37b | |||
| 23ec072ac5 | |||
| 3f3fd1ad5f | |||
| 3022118445 | |||
| edf56c92d5 | |||
| ad6bf59297 | |||
| 42e009b91d | |||
| fe2d0e6a34 | |||
| 1cbfbeb118 | |||
| d845ceb31a | |||
| c080049322 | |||
| 820e29db23 | |||
| be4d464bc0 | |||
| e3c56fa800 | |||
| 7e982e30a3 | |||
| 0eae5262af | |||
| 6656cbc635 | |||
| 0a6b93a8f8 |
@ -71,7 +71,7 @@ android_build:
|
||||
exit_codes: 137
|
||||
only:
|
||||
- dev
|
||||
- dev-5.32.0
|
||||
- dev-5.33.0
|
||||
|
||||
# 代码检查
|
||||
sonarqube_analysis:
|
||||
@ -102,7 +102,7 @@ sonarqube_analysis:
|
||||
exit_codes: 137
|
||||
only:
|
||||
- dev
|
||||
- dev-5.32.0
|
||||
- dev-5.33.0
|
||||
|
||||
## 发送简易检测结果报告
|
||||
send_sonar_report:
|
||||
@ -120,7 +120,7 @@ send_sonar_report:
|
||||
exit_codes: 137
|
||||
only:
|
||||
- dev
|
||||
- dev-5.32.0
|
||||
- dev-5.33.0
|
||||
|
||||
oss-upload&send-email:
|
||||
tags:
|
||||
@ -152,4 +152,4 @@ oss-upload&send-email:
|
||||
- /usr/local/bin/python /ci-android-mail-jira-comment.py
|
||||
only:
|
||||
- dev
|
||||
- dev-5.32.0
|
||||
- dev-5.33.0
|
||||
@ -95,8 +95,10 @@ android {
|
||||
buildConfigField "int", "ACTIVATE_REPORTING_RATIO", "${ACTIVATE_REPORTING_RATIO}"
|
||||
|
||||
// All third-party appid/appkey
|
||||
buildConfigField "boolean", "IS_GAT_APP", "false"
|
||||
buildConfigField "String", "API_HOST", "\"${API_HOST}\""
|
||||
buildConfigField "String", "NEW_API_HOST", "\"${NEW_API_HOST}\""
|
||||
buildConfigField "String", "LOG_HUB_PROJECT", "\"${LOG_HUB_PROJECT}\""
|
||||
buildConfigField "String", "VAPI_HOST", "\"${VAPI_HOST}\""
|
||||
buildConfigField "String", "WECHAT_APPID", "\"${WECHAT_APPID}\""
|
||||
buildConfigField "String", "WECHAT_SECRET", "\"${WECHAT_SECRET}\""
|
||||
@ -157,7 +159,7 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
flavorDimensions("env")
|
||||
flavorDimensions("env", "region")
|
||||
|
||||
sourceSets {
|
||||
publish {
|
||||
@ -175,6 +177,15 @@ android {
|
||||
gdt {
|
||||
java.srcDirs = ['src/main/java', 'src/gdt/java']
|
||||
}
|
||||
gat {
|
||||
java.srcDirs = ['src/main/java', 'src/gat/java']
|
||||
}
|
||||
cn {
|
||||
java.srcDirs = ['src/main/java', 'src/cn/java']
|
||||
}
|
||||
sm {
|
||||
java.srcDirs = ['src/main/java', 'src/sm/java']
|
||||
}
|
||||
}
|
||||
|
||||
productFlavors {
|
||||
@ -242,6 +253,37 @@ android {
|
||||
buildConfigField "String", "DEV_CSJ_APPID", "\"${CSJ_APPID}\""
|
||||
buildConfigField "String", "CSJ_APPID", "\"${CSJ_APPID}\""
|
||||
}
|
||||
|
||||
sm {
|
||||
dimension "env"
|
||||
|
||||
buildConfigField "String", "DEV_API_HOST", "\"${API_HOST}\""
|
||||
buildConfigField "String", "NEW_DEV_API_HOST", "\"${NEW_API_HOST}\""
|
||||
buildConfigField "String", "DEV_VAPI_HOST", "\"${VAPI_HOST}\""
|
||||
buildConfigField "String", "QUICK_LOGIN_APPID", "\"${QUICK_LOGIN_APPID}\""
|
||||
buildConfigField "String", "QUICK_LOGIN_APPKEY", "\"${QUICK_LOGIN_APPKEY}\""
|
||||
buildConfigField "String", "DEV_CSJ_APPID", "\"${CSJ_APPID}\""
|
||||
buildConfigField "String", "CSJ_APPID", "\"${CSJ_APPID}\""
|
||||
}
|
||||
|
||||
// 港澳台
|
||||
gat {
|
||||
dimension "region"
|
||||
|
||||
applicationId rootProject.ext.applicationIdGat
|
||||
|
||||
// 支持繁体
|
||||
resConfigs "zh", "zh-rTW"
|
||||
|
||||
buildConfigField "boolean", "IS_GAT_APP", "true"
|
||||
buildConfigField "String", "LOG_HUB_PROJECT", "\"${LOG_HUB_PROJECT_GAT}\""
|
||||
buildConfigField "String", "API_HOST", "\"${API_HOST_GAT}\""
|
||||
buildConfigField "String", "NEW_API_HOST", "\"${NEW_API_HOST_GAT}\""
|
||||
}
|
||||
|
||||
cn {
|
||||
dimension "region"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -258,6 +300,7 @@ dependencies {
|
||||
teaImplementation fileTree(include: ['*.jar', '*.aar'], dir: 'src/tea/libs')
|
||||
kuaishouImplementation fileTree(include: ['*.jar', '*.aar'], dir: 'src/kuaishou/libs')
|
||||
gdtImplementation fileTree(include: ['*.jar', '*.aar'], dir: 'src/gdt/libs')
|
||||
smImplementation fileTree(include: ['*.jar', '*.aar'], dir: 'src/sm/libs')
|
||||
testImplementation 'junit:junit:4.12'
|
||||
|
||||
debugImplementation "com.squareup.leakcanary:leakcanary-android:${leakcanary}"
|
||||
|
||||
@ -88,6 +88,9 @@
|
||||
-keep class com.qq.gdt.action.** {*;}
|
||||
-keep public class com.tencent.turingfd.sdk.**
|
||||
|
||||
### 神马 SDK
|
||||
-dontwarn com.gism.**
|
||||
|
||||
-keepclasseswithmembers class * {
|
||||
native <methods>;
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import com.lightgame.utils.Utils
|
||||
import com.qq.gdt.action.ActionParam
|
||||
import com.qq.gdt.action.ActionType
|
||||
import com.qq.gdt.action.GDTAction
|
||||
import com.qq.gdt.action.PrivateController
|
||||
import org.json.JSONObject
|
||||
|
||||
object GdtHelper {
|
||||
@ -16,6 +17,12 @@ object GdtHelper {
|
||||
|
||||
@JvmStatic
|
||||
fun init(application: Application, channel: String) {
|
||||
GDTAction.setPrivateController(object : PrivateController() {
|
||||
override fun isCanUsePhoneState(): Boolean {
|
||||
return false
|
||||
}
|
||||
})
|
||||
|
||||
if (channel == "KS_GDT_GHZS_MC01") {
|
||||
GDTAction.init(application, KS_USER_ACTION_SET_ID, KS_APP_SECRET_ID, channel)
|
||||
} else {
|
||||
|
||||
Binary file not shown.
@ -67,7 +67,7 @@ class InstallExternalGameFragment : ToolbarFragment(), OnItemClickListener {
|
||||
it.layoutManager = LinearLayoutManager(requireContext())
|
||||
val itemDecoration = HorizontalDividerItemDecoration.Builder(requireContext())
|
||||
.size(2F.dip2px())
|
||||
.color(R.color.divider.toColor(requireContext()))
|
||||
.color(R.color.ui_divider.toColor(requireContext()))
|
||||
.build()
|
||||
if (it.itemDecorationCount != 0) {
|
||||
it.removeItemDecorationAt(0)
|
||||
|
||||
7
app/src/internal/res/values-zh-rTW/strings.xml
Normal file
7
app/src/internal/res/values-zh-rTW/strings.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="title_install_external_game">從SD卡安裝</string>
|
||||
<string name="text_install">安裝</string>
|
||||
<string name="text_uninstall">卸載</string>
|
||||
<string name="text_start">啟動</string>
|
||||
</resources>
|
||||
Binary file not shown.
BIN
app/src/kuaishou/libs/monitorsdk-1.0.15.aar
Normal file
BIN
app/src/kuaishou/libs/monitorsdk-1.0.15.aar
Normal file
Binary file not shown.
@ -99,6 +99,9 @@
|
||||
android:name="android.permission.GET_TASKS"
|
||||
tools:node="remove" />
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"
|
||||
tools:node="remove"/>
|
||||
|
||||
<supports-screens
|
||||
android:anyDensity="true"
|
||||
android:largeScreens="true"
|
||||
@ -771,6 +774,10 @@
|
||||
android:name="com.gh.gamecenter.UserAuthActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.SplashAdActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
|
||||
<!-- <activity-->
|
||||
<!-- android:name="${applicationId}.douyinapi.DouYinEntryActivity"-->
|
||||
@ -826,6 +833,8 @@
|
||||
<!-- tools:node="remove" />-->
|
||||
<!-- </provider>-->
|
||||
|
||||
<service android:name = "com.gh.gamecenter.install.InstallService" />
|
||||
|
||||
<receiver
|
||||
android:name="com.gh.gamecenter.receiver.DownloadReceiver"
|
||||
android:exported="false">
|
||||
|
||||
@ -17,6 +17,7 @@ import com.gh.common.exposure.ExposureManager
|
||||
import com.gh.common.util.DirectUtils.directToLinkPage
|
||||
import com.gh.common.util.LogUtils
|
||||
import com.gh.common.util.NewFlatLogUtils.logOpenScreenAdSkip
|
||||
import com.gh.common.util.PackageUtils
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.gh.gamecenter.MainActivity
|
||||
import com.gh.gamecenter.R
|
||||
@ -66,6 +67,7 @@ object AdDelegateHelper {
|
||||
private const val AD_SDK_CSJ = "穿山甲"
|
||||
private const val AD_SDK_BEIZI = "倍孜"
|
||||
const val AD_TYPE_SDK = "third_party_ads" // 第三方 SDK 广告
|
||||
const val AD_TYPE_OWNER = "owner_ads" // 自有广告
|
||||
|
||||
private const val KEY_CACHE_CONFIG = "cache_config" // 放在 SP 里的广告缓存(避免接口加载问题)
|
||||
|
||||
@ -73,6 +75,7 @@ object AdDelegateHelper {
|
||||
HaloApp.getInstance().getSharedPreferences("AdConfig", Context.MODE_PRIVATE)
|
||||
}
|
||||
|
||||
var isShowingSplashAd = false // 是否正在显示开屏广告
|
||||
var gameSearchKeyword = ""
|
||||
|
||||
fun initAdSdk(context: Context) {
|
||||
@ -174,9 +177,99 @@ object AdDelegateHelper {
|
||||
|
||||
/**
|
||||
* 是否需要显示开屏广告
|
||||
* @param isHotLaunch 是否为热启动
|
||||
*/
|
||||
fun shouldShowStartUpAd(): Boolean {
|
||||
fun shouldShowStartUpAd(isHotLaunch: Boolean): Boolean {
|
||||
return mSplashAd != null
|
||||
&& !isShowingSplashAd
|
||||
&& (!isHotLaunch || shouldShowStartUpAdWhenHotLaunch())
|
||||
&& !isMatchAdFreeRule(mSplashAd)
|
||||
&& isMatchStartUpAdDisplayRule()
|
||||
}
|
||||
|
||||
/**
|
||||
* 热启动是否需要显示开屏广告
|
||||
*/
|
||||
private fun shouldShowStartUpAdWhenHotLaunch() = mSplashAd?.displayRule?.hotStartSplashAd?.type == AD_TYPE_SDK
|
||||
|
||||
/**
|
||||
* 是否需要显示下载管理广告
|
||||
*/
|
||||
fun shouldShowDownloadManagerAd(): Boolean {
|
||||
return mDownloadManagerAd != null && !isMatchAdFreeRule(mDownloadManagerAd) && isMatchDownloadManagerAdDisplayRule()
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否需要显示游戏搜索广告
|
||||
*/
|
||||
fun shouldShowGameSearchAd(adConfig: AdConfig): Boolean {
|
||||
return !isMatchAdFreeRule(adConfig) && isMatchGameSearchAdDisplayRule(adConfig)
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否在免广告时长内
|
||||
*/
|
||||
private fun isMatchAdFreeRule(adConfig: AdConfig?): Boolean {
|
||||
adConfig?.displayRule?.run {
|
||||
if (adFreeDuration > 0) {
|
||||
val ghInstalledDurationInHours = (System.currentTimeMillis() - PackageUtils.getInstalledTime(
|
||||
HaloApp.getInstance(),
|
||||
BuildConfig.APPLICATION_ID
|
||||
)).toFloat() / 1000 / 3600
|
||||
return ghInstalledDurationInHours < adFreeDuration
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否大于开屏广告展示间隔时长
|
||||
*/
|
||||
private fun isMatchStartUpAdDisplayRule(): Boolean {
|
||||
mSplashAd?.displayRule?.run {
|
||||
if (adDisplayInterval > 0) {
|
||||
val lastShowTime = SPUtils.getLong(Constants.SP_LAST_SPLASH_AD_SHOW_TIME, 0L)
|
||||
val durationInMinutes = (System.currentTimeMillis() - lastShowTime).toFloat() / 1000 / 60
|
||||
return durationInMinutes > adDisplayInterval
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否大于广告管理展示间隔时长
|
||||
*/
|
||||
private fun isMatchDownloadManagerAdDisplayRule(): Boolean {
|
||||
mDownloadManagerAd?.displayRule?.run {
|
||||
if (adDisplayInterval > 0) {
|
||||
val lastShowTime = SPUtils.getLong(Constants.SP_LAST_DOWNLOAD_MANAGER_AD_SHOW_TIME, 0L)
|
||||
val durationInMinutes = (System.currentTimeMillis() - lastShowTime).toFloat() / 1000 / 60
|
||||
return durationInMinutes > adDisplayInterval
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否大于游戏搜索展示间隔时长
|
||||
*/
|
||||
private fun isMatchGameSearchAdDisplayRule(adConfig: AdConfig?): Boolean {
|
||||
adConfig?.displayRule?.run {
|
||||
if (adDisplayInterval > 0) {
|
||||
val lastShowTime = SPUtils.getLong(Constants.SP_LAST_GAME_SEARCH_AD_SHOW_TIME + adConfig.position, 0L)
|
||||
val durationInMinutes = (System.currentTimeMillis() - lastShowTime).toFloat() / 1000 / 60
|
||||
return durationInMinutes > adDisplayInterval
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
@ -200,54 +293,124 @@ object AdDelegateHelper {
|
||||
sdkStartAdContainer: ViewGroup,
|
||||
adsViewGroup: FrameLayout,
|
||||
handler: BaseActivity.BaseHandler,
|
||||
hideCallback: () -> Unit
|
||||
isHotLaunch: Boolean,
|
||||
hideAction: () -> Unit
|
||||
) {
|
||||
val hideCallback = {
|
||||
isShowingSplashAd = false
|
||||
hideAction.invoke()
|
||||
}
|
||||
if (mSplashAd != null) {
|
||||
if (mSplashAd!!.displayRule.adSource == AD_TYPE_SDK) {
|
||||
// 第三方开屏广告回调,失败时根据接口配置选项决定是否显示自有开屏广告
|
||||
val sdkSplashCallback: (isSuccess: Boolean) -> Unit = { isSuccess ->
|
||||
if (isSuccess) {
|
||||
hideCallback.invoke()
|
||||
} else {
|
||||
if (mSplashAd?.displayRule?.onFailedAction == "show") {
|
||||
sdkStartAdContainer.visibility = View.GONE
|
||||
requestStandardSplashAd(
|
||||
mSplashAd!!.ownerAd?.startAd,
|
||||
startAdContainer,
|
||||
handler,
|
||||
hideCallback
|
||||
)
|
||||
} else {
|
||||
hideCallback.invoke()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 第三方广告的数据为空,按加载失败处理
|
||||
if (mSplashAd?.thirdPartyAd == null) {
|
||||
sdkSplashCallback.invoke(false)
|
||||
return
|
||||
}
|
||||
|
||||
if (mSplashAd?.thirdPartyAd?.sourceName == AD_SDK_BEIZI) {
|
||||
sdkStartAdContainer.visibility = View.VISIBLE
|
||||
requestBeiziSplashAd(sdkStartAdContainer, adsViewGroup, adViewWidthInPx, adViewHeightInPx, sdkSplashCallback)
|
||||
} else if (mSplashAd?.thirdPartyAd?.sourceName == AD_SDK_CSJ) {
|
||||
sdkStartAdContainer.visibility = View.VISIBLE
|
||||
requestCsjSplashAd(
|
||||
when (if (isHotLaunch) mSplashAd!!.displayRule.hotStartSplashAd?.type else mSplashAd!!.displayRule.adSource) {
|
||||
AD_TYPE_SDK -> {
|
||||
isShowingSplashAd = true
|
||||
requestThirdPartySplashAd(
|
||||
activity,
|
||||
mSplashAd?.thirdPartyAd?.slotId ?: "unknown",
|
||||
adViewWidthInPx,
|
||||
adViewHeightInPx,
|
||||
adViewWidthInDp,
|
||||
adViewHeightInDp,
|
||||
startAdContainer,
|
||||
sdkStartAdContainer,
|
||||
sdkSplashCallback
|
||||
adsViewGroup,
|
||||
handler,
|
||||
isHotLaunch,
|
||||
hideCallback
|
||||
)
|
||||
}
|
||||
|
||||
AD_TYPE_OWNER -> {
|
||||
isShowingSplashAd = true
|
||||
requestStandardSplashAd(
|
||||
activity,
|
||||
adViewWidthInPx,
|
||||
adViewHeightInPx,
|
||||
adViewWidthInDp,
|
||||
adViewHeightInDp,
|
||||
startAdContainer,
|
||||
sdkStartAdContainer,
|
||||
adsViewGroup,
|
||||
handler,
|
||||
isHotLaunch,
|
||||
hideCallback
|
||||
)
|
||||
}
|
||||
} else {
|
||||
requestStandardSplashAd(mSplashAd!!.ownerAd?.startAd, startAdContainer, handler, hideCallback)
|
||||
}
|
||||
} else {
|
||||
hideCallback.invoke()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取第三方开屏广告
|
||||
*/
|
||||
private fun requestThirdPartySplashAd(
|
||||
activity: Activity,
|
||||
adViewWidthInPx: Int,
|
||||
adViewHeightInPx: Int,
|
||||
adViewWidthInDp: Float,
|
||||
adViewHeightInDp: Float,
|
||||
startAdContainer: ViewGroup,
|
||||
sdkStartAdContainer: ViewGroup,
|
||||
adsViewGroup: FrameLayout,
|
||||
handler: BaseActivity.BaseHandler,
|
||||
isHotLaunch: Boolean,
|
||||
hideCallback: () -> Unit
|
||||
) {
|
||||
val timeout = if (isHotLaunch) {
|
||||
((mSplashAd!!.displayRule.hotStartSplashAd?.timeout ?: 3.5F) * 1000).toInt()
|
||||
} else {
|
||||
(mSplashAd!!.displayRule.timeout * 1000).toInt()
|
||||
}
|
||||
// 第三方开屏广告回调,失败时根据接口配置选项决定是否显示自有开屏广告
|
||||
val sdkSplashCallback: (isSuccess: Boolean) -> Unit = { isSuccess ->
|
||||
if (isSuccess) {
|
||||
hideCallback.invoke()
|
||||
SPUtils.setLong(Constants.SP_LAST_SPLASH_AD_SHOW_TIME, System.currentTimeMillis())
|
||||
} else {
|
||||
if (mSplashAd?.displayRule?.adSource == AD_TYPE_SDK && mSplashAd?.displayRule?.onFailedAction == "show" && !isHotLaunch) {
|
||||
sdkStartAdContainer.visibility = View.GONE
|
||||
requestStandardSplashAd(
|
||||
activity,
|
||||
adViewWidthInPx,
|
||||
adViewHeightInPx,
|
||||
adViewWidthInDp,
|
||||
adViewHeightInDp,
|
||||
startAdContainer,
|
||||
sdkStartAdContainer,
|
||||
adsViewGroup,
|
||||
handler,
|
||||
isHotLaunch,
|
||||
hideCallback
|
||||
)
|
||||
} else {
|
||||
hideCallback.invoke()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 第三方广告的数据为空,按加载失败处理
|
||||
if (mSplashAd?.thirdPartyAd == null) {
|
||||
sdkSplashCallback.invoke(false)
|
||||
return
|
||||
}
|
||||
|
||||
if (mSplashAd?.thirdPartyAd?.sourceName == AD_SDK_BEIZI) {
|
||||
sdkStartAdContainer.visibility = View.VISIBLE
|
||||
requestBeiziSplashAd(sdkStartAdContainer, adsViewGroup, adViewWidthInPx, adViewHeightInPx, timeout.toLong(), sdkSplashCallback)
|
||||
} else if (mSplashAd?.thirdPartyAd?.sourceName == AD_SDK_CSJ) {
|
||||
sdkStartAdContainer.visibility = View.VISIBLE
|
||||
requestCsjSplashAd(
|
||||
activity,
|
||||
mSplashAd?.thirdPartyAd?.slotId ?: "unknown",
|
||||
adViewWidthInPx,
|
||||
adViewHeightInPx,
|
||||
adViewWidthInDp,
|
||||
adViewHeightInDp,
|
||||
sdkStartAdContainer,
|
||||
timeout,
|
||||
sdkSplashCallback
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -262,6 +425,7 @@ object AdDelegateHelper {
|
||||
adViewWidthInDp: Float,
|
||||
adViewHeightInDp: Float,
|
||||
startAdContainer: ViewGroup,
|
||||
timeout: Int,
|
||||
callback: (isSuccess: Boolean) -> Unit,
|
||||
) {
|
||||
if (mCsjAdImpl == null) {
|
||||
@ -275,6 +439,7 @@ object AdDelegateHelper {
|
||||
adViewWidthInDp,
|
||||
adViewHeightInDp,
|
||||
startAdContainer,
|
||||
timeout,
|
||||
callback,
|
||||
)
|
||||
}
|
||||
@ -288,12 +453,13 @@ object AdDelegateHelper {
|
||||
adsFl: FrameLayout,
|
||||
adViewWidthInPx: Int,
|
||||
adViewHeightInPx: Int,
|
||||
timeout: Long,
|
||||
callback: (isSuccess: Boolean) -> Unit,
|
||||
) {
|
||||
if (mBeiziAdImpl == null) {
|
||||
callback.invoke(false)
|
||||
} else {
|
||||
mBeiziAdImpl?.requestSplashAd(startAdContainer, adsFl, adViewWidthInPx, adViewHeightInPx, callback)
|
||||
mBeiziAdImpl?.requestSplashAd(startAdContainer, adsFl, adViewWidthInPx, adViewHeightInPx, timeout, callback)
|
||||
}
|
||||
}
|
||||
|
||||
@ -301,13 +467,41 @@ object AdDelegateHelper {
|
||||
* 显示自有的开屏广告
|
||||
*/
|
||||
private fun requestStandardSplashAd(
|
||||
splashAd: StartupAdEntity?,
|
||||
activity: Activity,
|
||||
adViewWidthInPx: Int,
|
||||
adViewHeightInPx: Int,
|
||||
adViewWidthInDp: Float,
|
||||
adViewHeightInDp: Float,
|
||||
startAdContainer: ViewGroup,
|
||||
sdkStartAdContainer: ViewGroup,
|
||||
adsViewGroup: FrameLayout,
|
||||
handler: BaseActivity.BaseHandler,
|
||||
isHotLaunch: Boolean,
|
||||
hideCallback: () -> Unit
|
||||
) {
|
||||
val splashAd = mSplashAd?.ownerAd?.startAd
|
||||
val onEmptyCallback = {
|
||||
if (mSplashAd?.displayRule?.adSource == AD_TYPE_OWNER && mSplashAd?.displayRule?.onFailedAction == "show" && mSplashAd?.thirdPartyAd != null) {
|
||||
// 自有广告为空时,显示第三方广告
|
||||
requestThirdPartySplashAd(
|
||||
activity,
|
||||
adViewWidthInPx,
|
||||
adViewHeightInPx,
|
||||
adViewWidthInDp,
|
||||
adViewHeightInDp,
|
||||
startAdContainer,
|
||||
sdkStartAdContainer,
|
||||
adsViewGroup,
|
||||
handler,
|
||||
isHotLaunch,
|
||||
hideCallback
|
||||
)
|
||||
} else {
|
||||
hideCallback.invoke()
|
||||
}
|
||||
}
|
||||
if (splashAd == null) {
|
||||
hideCallback.invoke()
|
||||
onEmptyCallback.invoke()
|
||||
return
|
||||
}
|
||||
|
||||
@ -320,7 +514,7 @@ object AdDelegateHelper {
|
||||
) {
|
||||
showStandardSplashAd(splashAd, startAdContainer, handler, hideCallback)
|
||||
} else {
|
||||
hideCallback.invoke()
|
||||
onEmptyCallback.invoke()
|
||||
}
|
||||
|
||||
"everyday" -> {
|
||||
@ -331,7 +525,7 @@ object AdDelegateHelper {
|
||||
) {
|
||||
showStandardSplashAd(splashAd, startAdContainer, handler, hideCallback)
|
||||
} else {
|
||||
hideCallback.invoke()
|
||||
onEmptyCallback.invoke()
|
||||
}
|
||||
}
|
||||
|
||||
@ -394,6 +588,7 @@ object AdDelegateHelper {
|
||||
} else {
|
||||
LogUtils.logStartAd("start_ads", ad)
|
||||
}
|
||||
SPUtils.setLong(Constants.SP_LAST_SPLASH_AD_SHOW_TIME, System.currentTimeMillis())
|
||||
handler.sendEmptyMessageDelayed(MainActivity.COUNTDOWN_AD, 1000)
|
||||
}
|
||||
|
||||
|
||||
@ -233,7 +233,7 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
mKeyboardHeightProvider = KeyboardHeightProvider(this)
|
||||
mRichEditor.post { mKeyboardHeightProvider?.start() }
|
||||
mRichEditor.enableForceDark(DarkModeUtils.isDarkModeOn(this))
|
||||
mRichEditor.setEditorBackgroundColor(R.color.background_white.toColor(this))
|
||||
mRichEditor.setEditorBackgroundColor(R.color.ui_surface.toColor(this))
|
||||
mRichEditor.setEditorFontColor(if (mIsDarkModeOn) Color.parseColor("#C2C2C2") else Color.parseColor("#4A4A4A"))
|
||||
// 防止个别手机在Js里无法获取粘贴内容
|
||||
mRichEditor.addJavascriptInterface(OnPasteListener(), "onPasteListener")
|
||||
@ -797,9 +797,9 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
|
||||
override fun onDarkModeChanged() {
|
||||
super.onDarkModeChanged()
|
||||
updateStatusBarColor(R.color.background_white, R.color.background_white)
|
||||
updateStatusBarColor(R.color.ui_surface, R.color.ui_surface)
|
||||
mRichEditor.enableForceDark(DarkModeUtils.isDarkModeOn(this))
|
||||
mRichEditor.setEditorBackgroundColor(R.color.background_white.toColor(this))
|
||||
mRichEditor.setEditorBackgroundColor(R.color.ui_surface.toColor(this))
|
||||
mRichEditor.setEditorFontColor(if (mIsDarkModeOn) Color.parseColor("#C2C2C2") else Color.parseColor("#4A4A4A"))
|
||||
}
|
||||
|
||||
|
||||
@ -4,11 +4,13 @@ import android.app.Activity
|
||||
import android.app.Application
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.gh.ad.AdDelegateHelper
|
||||
import com.gh.common.util.FloatingBackViewManager
|
||||
import com.gh.common.xapk.XapkInstaller
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.SingletonWebActivity
|
||||
import com.gh.gamecenter.SkipActivity
|
||||
import com.gh.gamecenter.SplashAdActivity
|
||||
import com.gh.gamecenter.SplashScreenActivity
|
||||
import com.gh.gamecenter.authorization.AuthorizationActivity
|
||||
import com.gh.gamecenter.common.base.GlobalActivityManager
|
||||
@ -18,6 +20,8 @@ import com.halo.assistant.HaloApp
|
||||
|
||||
// TODO:移动到对应的模块
|
||||
class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
||||
private var isFromBackgroundToForeground = false // 是否后台回到前台
|
||||
private var activityCount = 0
|
||||
|
||||
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
|
||||
// do nothing
|
||||
@ -25,6 +29,19 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
||||
|
||||
override fun onActivityStarted(activity: Activity) {
|
||||
GlobalActivityManager.currentActivity = activity
|
||||
activityCount ++
|
||||
if (activityCount == 1 && isFromBackgroundToForeground) {
|
||||
if (AdDelegateHelper.shouldShowStartUpAd(true)
|
||||
&& !HaloApp.getInstance().isSkippingThirdParty
|
||||
&& activity !is SplashScreenActivity
|
||||
&& activity !is SkipActivity
|
||||
&& activity !is AuthorizationActivity
|
||||
&& activity !is SplashAdActivity
|
||||
) {
|
||||
activity.startActivity(SplashAdActivity.getIntent(activity))
|
||||
}
|
||||
isFromBackgroundToForeground = false
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityResumed(activity: Activity) {
|
||||
@ -74,7 +91,8 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
||||
}
|
||||
|
||||
override fun onActivityStopped(activity: Activity) {
|
||||
// do nothing
|
||||
activityCount --
|
||||
isFromBackgroundToForeground = activityCount <= 0
|
||||
}
|
||||
|
||||
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {
|
||||
|
||||
@ -11,7 +11,8 @@ class CheckStoragePermissionHandler : DownloadChainHandler() {
|
||||
context,
|
||||
gameEntity.id,
|
||||
gameEntity.name ?: "",
|
||||
gameEntity.categoryChinese
|
||||
gameEntity.categoryChinese,
|
||||
gameEntity.getApk().firstOrNull()?.format,
|
||||
) {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
|
||||
@ -1,16 +1,25 @@
|
||||
package com.gh.common.chain
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import com.gh.common.util.DialogUtils
|
||||
import com.gh.common.util.DirectUtils
|
||||
import com.gh.common.util.TempCertificationUtils
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
|
||||
class LandPageAddressHandler : DownloadChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity, asVGame: Boolean) {
|
||||
if (gameEntity.isLandPageAddressDialog()) {
|
||||
DialogUtils.showLandPageAddressDialog(context, gameEntity) {// 跳转第三方落地页
|
||||
DirectUtils.directToExternalBrowser(context, gameEntity.landPageAddressDialog!!.link!!)
|
||||
TempCertificationUtils.checkCertificationBeforeAction(gameEntity) {
|
||||
if (context is Activity && context.isFinishing) {
|
||||
// 当前 context 已经无效,不需要再传递执行下去了
|
||||
return@checkCertificationBeforeAction
|
||||
}
|
||||
|
||||
DialogUtils.showLandPageAddressDialog(context, gameEntity) {// 跳转第三方落地页
|
||||
DirectUtils.directToExternalBrowser(context, gameEntity.landPageAddressDialog!!.link!!)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (hasNext()) {
|
||||
|
||||
@ -1,18 +1,27 @@
|
||||
package com.gh.common.chain
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import com.gh.common.util.DialogUtils
|
||||
import com.gh.common.util.TempCertificationUtils
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
|
||||
class OverseaDownloadHandler : DownloadChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity, asVGame: Boolean) {
|
||||
if (gameEntity.isOverseaAddressDialog()) {
|
||||
DialogUtils.showOverseaDownloadDialog(context, gameEntity) {// 跳转海外下载地址弹窗
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
} else {
|
||||
processEndCallback?.invoke(asVGame, null)
|
||||
TempCertificationUtils.checkCertificationBeforeAction(gameEntity) {
|
||||
if (context is Activity && context.isFinishing) {
|
||||
// 当前 context 已经无效,不需要再传递执行下去了
|
||||
return@checkCertificationBeforeAction
|
||||
}
|
||||
|
||||
DialogUtils.showOverseaDownloadDialog(context, gameEntity) {// 跳转海外下载地址弹窗
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
} else {
|
||||
processEndCallback?.invoke(asVGame, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -29,6 +29,7 @@ import com.gh.gamecenter.entity.VSetting;
|
||||
import com.gh.gamecenter.feature.entity.NewsEntity;
|
||||
import com.gh.gamecenter.feature.entity.SettingsEntity;
|
||||
import com.gh.gamecenter.feature.entity.SimulatorEntity;
|
||||
import com.gh.gamecenter.feature.utils.ContentBlockedHelper;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
import com.gh.vspace.VHelper;
|
||||
import com.halo.assistant.HaloApp;
|
||||
@ -460,6 +461,11 @@ public class Config {
|
||||
DarkModeUtils.INSTANCE.initDarkMode();
|
||||
}
|
||||
SPUtils.setString(Constants.SP_NEW_API_SETTINGS, GsonUtils.toJson(data));
|
||||
|
||||
// 刷新屏蔽字段
|
||||
if (mNewApiSettingsEntity.getGameShieldContents() != null) {
|
||||
ContentBlockedHelper.INSTANCE.init(mNewApiSettingsEntity.getGameShieldContents());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -120,13 +120,13 @@ object AddKaiFuBindingAdapter {
|
||||
@BindingAdapter("kaiFuTextColor", "kaiFuTextPosition")
|
||||
fun kaiFuTextColor(view: EditText, dataMark: Int, position: Int) {
|
||||
if (dataMark == 1 && view.id == R.id.kaifu_add_time || dataMark == 2 && view.id == R.id.kaifu_add_first_name || dataMark == 3 && view.id == R.id.kaifu_add_server_name || dataMark == 4) {
|
||||
view.setTextColor(ContextCompat.getColor(view.context, R.color.theme_red))
|
||||
view.setHintTextColor(ContextCompat.getColor(view.context, R.color.theme_red))
|
||||
view.setTextColor(ContextCompat.getColor(view.context, R.color.secondary_red))
|
||||
view.setHintTextColor(ContextCompat.getColor(view.context, R.color.secondary_red))
|
||||
} else if (position == 0) {
|
||||
view.setTextColor(ContextCompat.getColor(view.context, R.color.hint))
|
||||
view.setHintTextColor(ContextCompat.getColor(view.context, R.color.hint))
|
||||
} else {
|
||||
view.setTextColor(ContextCompat.getColor(view.context, R.color.text_title))
|
||||
view.setTextColor(ContextCompat.getColor(view.context, R.color.text_primary))
|
||||
view.setHintTextColor(ContextCompat.getColor(view.context, R.color.hint))
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ class ApplyModeratorDialogFragment : BaseDialogFragment() {
|
||||
requireContext(),
|
||||
startText.length,
|
||||
startText.length + mGroupNumber.length,
|
||||
R.color.theme_font,
|
||||
R.color.text_theme,
|
||||
true
|
||||
) {
|
||||
DirectUtils.directToQqGroup(
|
||||
|
||||
@ -60,7 +60,7 @@ class GameOffServiceDialogFragment : BaseDialogFragment() {
|
||||
if (index == notEmptySite.size - 1) bottomMargin = 8F.dip2px()
|
||||
}
|
||||
siteTv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14F)
|
||||
siteTv.setTextColor(R.color.theme_font.toColor(requireContext()))
|
||||
siteTv.setTextColor(R.color.text_theme.toColor(requireContext()))
|
||||
siteTv.text = site.text
|
||||
siteTv.paintFlags = siteTv.paintFlags or Paint.UNDERLINE_TEXT_FLAG
|
||||
siteTv.setOnClickListener {
|
||||
|
||||
@ -76,7 +76,7 @@ class NewPrivacyPolicyDialogFragment : BaseDialogFragment() {
|
||||
contentText.setSpan(object : ClickableSpan() {
|
||||
override fun updateDrawState(ds: TextPaint) {
|
||||
super.updateDrawState(ds)
|
||||
ds.color = ContextCompat.getColor(requireContext(), R.color.theme_font)
|
||||
ds.color = ContextCompat.getColor(requireContext(), R.color.text_theme)
|
||||
ds.isUnderlineText = false
|
||||
}
|
||||
|
||||
|
||||
@ -125,7 +125,7 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
requireContext(),
|
||||
0,
|
||||
(link.title ?: "").length,
|
||||
R.color.theme_font,
|
||||
R.color.text_theme,
|
||||
true
|
||||
) {
|
||||
LogUtils.uploadPackageCheck(
|
||||
@ -391,10 +391,10 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
val isAllInstalled = checkDetectionsInstalled(mAllInstalledPackages, entity.packages)
|
||||
if (isAllInstalled) {
|
||||
holder.binding.statusTv.text = "已安装"
|
||||
holder.binding.statusTv.setTextColor(ContextCompat.getColor(context, R.color.theme_font))
|
||||
holder.binding.statusTv.setTextColor(ContextCompat.getColor(context, R.color.text_theme))
|
||||
} else {
|
||||
holder.binding.statusTv.text = "未安装"
|
||||
holder.binding.statusTv.setTextColor(ContextCompat.getColor(context, R.color.theme_red))
|
||||
holder.binding.statusTv.setTextColor(ContextCompat.getColor(context, R.color.secondary_red))
|
||||
}
|
||||
holder.binding.statusTv.visibility = View.VISIBLE
|
||||
} else {
|
||||
|
||||
@ -59,7 +59,7 @@ class PrivacyPolicyDialogFragment : BaseDialogFragment() {
|
||||
skipText.setSpan(object : ClickableSpan() {
|
||||
override fun updateDrawState(ds: TextPaint) {
|
||||
super.updateDrawState(ds)
|
||||
ds.color = ContextCompat.getColor(requireContext(), R.color.theme_font)
|
||||
ds.color = ContextCompat.getColor(requireContext(), R.color.text_theme)
|
||||
ds.isUnderlineText = false
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ class PrivacyPolicyDialogFragment : BaseDialogFragment() {
|
||||
skipText.setSpan(object : ClickableSpan() {
|
||||
override fun updateDrawState(ds: TextPaint) {
|
||||
super.updateDrawState(ds)
|
||||
ds.color = ContextCompat.getColor(requireContext(), R.color.theme_font)
|
||||
ds.color = ContextCompat.getColor(requireContext(), R.color.text_theme)
|
||||
ds.isUnderlineText = false
|
||||
}
|
||||
|
||||
@ -115,7 +115,7 @@ class PrivacyPolicyDialogFragment : BaseDialogFragment() {
|
||||
skipText.setSpan(object : ClickableSpan() {
|
||||
override fun updateDrawState(ds: TextPaint) {
|
||||
super.updateDrawState(ds)
|
||||
ds.color = ContextCompat.getColor(requireContext(), R.color.theme_font)
|
||||
ds.color = ContextCompat.getColor(requireContext(), R.color.text_theme)
|
||||
ds.isUnderlineText = false
|
||||
}
|
||||
|
||||
|
||||
@ -82,4 +82,8 @@ class AppProviderImpl : IAppProvider {
|
||||
override fun getIsBrandNewInstall(): Boolean {
|
||||
return HaloApp.getInstance().isBrandNewInstall
|
||||
}
|
||||
|
||||
override fun setSkippingThirdParty(isSkippingThirdParty: Boolean) {
|
||||
HaloApp.getInstance().isSkippingThirdParty = isSkippingThirdParty
|
||||
}
|
||||
}
|
||||
@ -19,6 +19,7 @@ class BuildConfigImpl : IBuildConfigProvider {
|
||||
override fun getExposureVersion(): String = BuildConfig.EXPOSURE_VERSION
|
||||
|
||||
override fun isDebug(): Boolean = BuildConfig.DEBUG
|
||||
override fun isGATApp(): Boolean = BuildConfig.IS_GAT_APP
|
||||
|
||||
override fun getApiHost(): String = BuildConfig.API_HOST
|
||||
|
||||
@ -31,4 +32,5 @@ class BuildConfigImpl : IBuildConfigProvider {
|
||||
override fun getVApiHost(): String = BuildConfig.VAPI_HOST
|
||||
|
||||
override fun getVDevApiHost(): String = BuildConfig.DEV_VAPI_HOST
|
||||
override fun getLogProducerProject(): String = BuildConfig.LOG_HUB_PROJECT
|
||||
}
|
||||
@ -9,8 +9,8 @@ import com.gh.gamecenter.core.provider.IGameSubstituteRepositoryProvider
|
||||
@Route(path = RouteConsts.provider.gameSubstituteRepository, name = "GameSubstituteRepositoryHelper暴露服务")
|
||||
class GameSubstituteRepositoryProviderImpl : IGameSubstituteRepositoryProvider {
|
||||
|
||||
override fun updateSubstitutableGames() {
|
||||
GameSubstituteRepositoryHelper.updateSubstitutableGames()
|
||||
override fun updateHistoricInstalledGameSet() {
|
||||
GameSubstituteRepositoryHelper.updateHistoricInstalledGameSet()
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
|
||||
@ -3,7 +3,8 @@ package com.gh.common.provider
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.core.provider.IVHelperProvider
|
||||
import com.gh.gamecenter.feature.entity.InstallGameEntity
|
||||
import com.gh.gamecenter.feature.provider.IVHelperProvider
|
||||
import com.gh.vspace.VHelper
|
||||
|
||||
@Route(path = RouteConsts.provider.vhelper, name = "VHelper暴露服务")
|
||||
@ -12,6 +13,14 @@ class VHelperProviderImpl: IVHelperProvider {
|
||||
return VHelper.isVGameOn()
|
||||
}
|
||||
|
||||
override fun getAllInstalledVGameEntity(): ArrayList<InstallGameEntity> {
|
||||
return VHelper.getAllInstalledVGameEntity()
|
||||
}
|
||||
|
||||
override fun launch(context: Context, packageName: String, ignoreGApps: Boolean, showLoading: Boolean) {
|
||||
VHelper.launch(context, packageName, ignoreGApps, showLoading)
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ object NewSimulatorGameManager {
|
||||
},
|
||||
uiModificationCallback = { binding ->
|
||||
binding.contentTv.gravity = Gravity.START
|
||||
binding.contentTv.setTextColor(R.color.text_subtitle.toColor(context))
|
||||
binding.contentTv.setTextColor(R.color.text_secondary.toColor(context))
|
||||
},
|
||||
extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true)
|
||||
)
|
||||
|
||||
@ -395,7 +395,7 @@ class SimulatorDownloadManager private constructor() {
|
||||
ToastUtils.showToast("该模拟器暂未提供下载")
|
||||
},
|
||||
uiModificationCallback = { binding ->
|
||||
binding.confirmTv.setTextColor(R.color.text_body.toColor(context))
|
||||
binding.confirmTv.setTextColor(R.color.text_instance.toColor(context))
|
||||
},
|
||||
extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true)
|
||||
)
|
||||
@ -420,7 +420,7 @@ class SimulatorDownloadManager private constructor() {
|
||||
DownloadStatus.diskioerror,
|
||||
DownloadStatus.diskisfull -> {
|
||||
DownloadManager.getInstance().addObserver(dataWatcher)
|
||||
uiExecutor.executeWithDelay(Runnable { DownloadManager.getInstance().resume(entity, true) }, 200)
|
||||
uiExecutor.executeWithDelay(Runnable { DownloadManager.getInstance().resume(entity, false) }, 200)
|
||||
SensorsBridge.trackSimulatorDownloadDialogShow(
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
|
||||
@ -9,6 +9,7 @@ import androidx.fragment.app.Fragment
|
||||
import com.gh.download.simple.AutoUnregisteredSimpleDownloadListener
|
||||
import com.gh.download.simple.DownloadListener
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.cloudarchive.BaseCloudArchiveViewModel
|
||||
import com.gh.gamecenter.common.eventbus.EBReuse
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.runOnUiThread
|
||||
@ -36,6 +37,7 @@ object ArchiveDownloadButtonHelper {
|
||||
entrance: String,
|
||||
fragment: Fragment,
|
||||
packageName: String,
|
||||
viewModel: BaseCloudArchiveViewModel,
|
||||
archiveEntity: ArchiveEntity,
|
||||
downloadBtn: TextView,
|
||||
gameEntity: GameEntity?,
|
||||
@ -60,19 +62,23 @@ object ArchiveDownloadButtonHelper {
|
||||
}
|
||||
}
|
||||
// 检查本地是否已下载存档
|
||||
VArchiveHelper.isArchiveDownloaded(archiveEntity.md5) -> showApplyArchiveTipDialog(
|
||||
context,
|
||||
entrance,
|
||||
packageName,
|
||||
archiveEntity,
|
||||
gameEntity
|
||||
)
|
||||
VArchiveHelper.isArchiveDownloaded(archiveEntity.md5) -> viewModel.getArchiveConfigString {
|
||||
showApplyArchiveTipDialog(
|
||||
context,
|
||||
entrance,
|
||||
packageName,
|
||||
it,
|
||||
archiveEntity,
|
||||
gameEntity
|
||||
)
|
||||
}
|
||||
// 检查完毕下载存档
|
||||
else -> downloadArchive(
|
||||
context,
|
||||
entrance,
|
||||
fragment,
|
||||
packageName,
|
||||
viewModel,
|
||||
archiveEntity,
|
||||
downloadBtn,
|
||||
gameEntity,
|
||||
@ -125,6 +131,7 @@ object ArchiveDownloadButtonHelper {
|
||||
context: Context,
|
||||
entrance: String,
|
||||
packageName: String,
|
||||
config: String,
|
||||
archiveEntity: ArchiveEntity,
|
||||
gameEntity: GameEntity?
|
||||
) {
|
||||
@ -135,7 +142,7 @@ object ArchiveDownloadButtonHelper {
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe()
|
||||
|
||||
VArchiveHelper.applyGameArchive(context, packageName, this) { packageName, isSuccess ->
|
||||
VArchiveHelper.applyGameArchive(context, packageName, config, this) { packageName, isSuccess ->
|
||||
runOnUiThread {
|
||||
if (isSuccess) {
|
||||
VHelper.launch(context, packageName)
|
||||
@ -161,6 +168,7 @@ object ArchiveDownloadButtonHelper {
|
||||
entrance: String,
|
||||
fragment: Fragment,
|
||||
packageName: String,
|
||||
viewModel: BaseCloudArchiveViewModel,
|
||||
archiveEntity: ArchiveEntity,
|
||||
downloadBtn: TextView,
|
||||
gameEntity: GameEntity?,
|
||||
@ -197,7 +205,9 @@ object ArchiveDownloadButtonHelper {
|
||||
DownloadStatus.COMPLETED -> {
|
||||
dismissArchiveLoadingDialog(archiveLoadingDialog)
|
||||
downloadBtn.text = R.string.archive_apply.toResString()
|
||||
showApplyArchiveTipDialog(context, entrance, packageName, archiveEntity, gameEntity)
|
||||
viewModel.getArchiveConfigString {
|
||||
showApplyArchiveTipDialog(context, entrance, packageName, it, archiveEntity, gameEntity)
|
||||
}
|
||||
downloadCompletedListener?.invoke()
|
||||
}
|
||||
else -> {
|
||||
@ -251,43 +261,46 @@ object ArchiveDownloadButtonHelper {
|
||||
context: Context,
|
||||
entrance: String,
|
||||
packageName: String,
|
||||
config: String,
|
||||
archiveEntity: ArchiveEntity,
|
||||
gameEntity: GameEntity?
|
||||
) {
|
||||
DialogHelper.showDialog(
|
||||
context,
|
||||
R.string.archive_dialog_title.toResString(),
|
||||
R.string.archive_apply_dialog_content.toResString(),
|
||||
R.string.archive_apply.toResString(),
|
||||
R.string.cancel.toResString(),
|
||||
{
|
||||
applyArchive(context, entrance, packageName, archiveEntity, gameEntity)
|
||||
NewFlatLogUtils.logCloudArchiveApplyDialogRelated("cloud_save_overwrite_dialog_click", "使用")
|
||||
SensorsBridge.trackEvent(
|
||||
"CloudSaveOverwriteDialogClick",
|
||||
"game_id", gameEntity?.id ?: "",
|
||||
"game_name", gameEntity?.name ?: "",
|
||||
"button_name", "使用"
|
||||
)
|
||||
},
|
||||
{
|
||||
NewFlatLogUtils.logCloudArchiveApplyDialogRelated("cloud_save_overwrite_dialog_click", "取消")
|
||||
SensorsBridge.trackEvent(
|
||||
"CloudSaveOverwriteDialogClick",
|
||||
"game_id", gameEntity?.id ?: "",
|
||||
"game_name", gameEntity?.name ?: "",
|
||||
"button_name", "取消"
|
||||
)
|
||||
},
|
||||
extraConfig = DialogHelper.Config(centerTitle = true)
|
||||
)
|
||||
runOnUiThread {
|
||||
DialogHelper.showDialog(
|
||||
context,
|
||||
R.string.archive_dialog_title.toResString(),
|
||||
R.string.archive_apply_dialog_content.toResString(),
|
||||
R.string.archive_apply.toResString(),
|
||||
R.string.cancel.toResString(),
|
||||
{
|
||||
applyArchive(context, entrance, packageName, config, archiveEntity, gameEntity)
|
||||
NewFlatLogUtils.logCloudArchiveApplyDialogRelated("cloud_save_overwrite_dialog_click", "使用")
|
||||
SensorsBridge.trackEvent(
|
||||
"CloudSaveOverwriteDialogClick",
|
||||
"game_id", gameEntity?.id ?: "",
|
||||
"game_name", gameEntity?.name ?: "",
|
||||
"button_name", "使用"
|
||||
)
|
||||
},
|
||||
{
|
||||
NewFlatLogUtils.logCloudArchiveApplyDialogRelated("cloud_save_overwrite_dialog_click", "取消")
|
||||
SensorsBridge.trackEvent(
|
||||
"CloudSaveOverwriteDialogClick",
|
||||
"game_id", gameEntity?.id ?: "",
|
||||
"game_name", gameEntity?.name ?: "",
|
||||
"button_name", "取消"
|
||||
)
|
||||
},
|
||||
extraConfig = DialogHelper.Config(centerTitle = true)
|
||||
)
|
||||
|
||||
NewFlatLogUtils.logCloudArchiveApplyDialogRelated("cloud_save_overwrite_dialog_show")
|
||||
SensorsBridge.trackEvent(
|
||||
"CloudSaveOverwriteDialogShow",
|
||||
"game_id", gameEntity?.id ?: "",
|
||||
"game_name", gameEntity?.name ?: ""
|
||||
)
|
||||
NewFlatLogUtils.logCloudArchiveApplyDialogRelated("cloud_save_overwrite_dialog_show")
|
||||
SensorsBridge.trackEvent(
|
||||
"CloudSaveOverwriteDialogShow",
|
||||
"game_id", gameEntity?.id ?: "",
|
||||
"game_name", gameEntity?.name ?: ""
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun dismissArchiveLoadingDialog(archiveLoadingDialog: Dialog) {
|
||||
|
||||
@ -64,7 +64,7 @@ object BbsReportHelper {
|
||||
this,
|
||||
1f,
|
||||
false,
|
||||
R.color.background
|
||||
R.color.ui_background
|
||||
)
|
||||
)
|
||||
binding.reasonRv.adapter = reportReasonAdapter
|
||||
@ -94,7 +94,7 @@ object BbsReportHelper {
|
||||
binding.otherReasonEt.doOnTextChanged { text, start, before, count ->
|
||||
val tvCount: Int = text.toString().length
|
||||
if (tvCount >= 500) {
|
||||
binding.tvCount.setTextColor(R.color.theme_red.toColor(binding.tvCount.context))
|
||||
binding.tvCount.setTextColor(R.color.secondary_red.toColor(binding.tvCount.context))
|
||||
}
|
||||
binding.tvCount.text = "$tvCount/500"
|
||||
}
|
||||
|
||||
@ -198,7 +198,7 @@ public class CommentUtils {
|
||||
LinearLayout container = new LinearLayout(context);
|
||||
container.setOrientation(LinearLayout.VERTICAL);
|
||||
container.setPadding(0, DisplayUtils.dip2px(context, 12), 0, DisplayUtils.dip2px(context, 12));
|
||||
container.setBackgroundColor(ContextCompat.getColor(context, R.color.background_white));
|
||||
container.setBackgroundColor(ContextCompat.getColor(context, R.color.ui_surface));
|
||||
|
||||
for (final String s : arrReportType) {
|
||||
TextView reportTypeTv = new TextView(context);
|
||||
@ -248,12 +248,12 @@ public class CommentUtils {
|
||||
public static void postVote(final Context context, final CommentEntity commentEntity,
|
||||
final TextView commentLikeCountTv, final ImageView commentLikeIv,
|
||||
final OnVoteListener listener) {
|
||||
if (commentLikeCountTv.getCurrentTextColor() == ContextCompat.getColor(context, R.color.theme_font)) {
|
||||
if (commentLikeCountTv.getCurrentTextColor() == ContextCompat.getColor(context, R.color.text_theme)) {
|
||||
ToastUtils.INSTANCE.showToast("已经点过赞啦!");
|
||||
return;
|
||||
}
|
||||
commentEntity.setVote(commentEntity.getVote() + 1);
|
||||
commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.theme_font));
|
||||
commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.text_theme));
|
||||
commentLikeIv.setImageResource(R.drawable.comment_vote_select);
|
||||
commentLikeCountTv.setText(NumberUtils.transSimpleCount(commentEntity.getVote()));
|
||||
commentLikeCountTv.setVisibility(View.VISIBLE);
|
||||
@ -318,12 +318,12 @@ public class CommentUtils {
|
||||
entrance = "视频流-评论-点赞";
|
||||
}
|
||||
CheckLoginUtils.checkLogin(context, entrance, () -> {
|
||||
if (commentLikeCountTv.getCurrentTextColor() == ContextCompat.getColor(context, R.color.theme_font)) {
|
||||
if (commentLikeCountTv.getCurrentTextColor() == ContextCompat.getColor(context, R.color.text_theme)) {
|
||||
ToastUtils.INSTANCE.showToast("已经点过赞啦!");
|
||||
return;
|
||||
}
|
||||
commentEntity.setVote(commentEntity.getVote() + 1);
|
||||
commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.theme_font));
|
||||
commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.text_theme));
|
||||
commentLikeIv.setImageResource(R.drawable.comment_vote_select);
|
||||
commentLikeCountTv.setText(NumberUtils.transSimpleCount(commentEntity.getVote()));
|
||||
commentLikeCountTv.setVisibility(View.VISIBLE);
|
||||
@ -444,7 +444,7 @@ public class CommentUtils {
|
||||
public void onFailure(@Nullable HttpException e) {
|
||||
super.onFailure(e);
|
||||
commentEntity.setVote(commentEntity.getVote() + 1);
|
||||
commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.theme_font));
|
||||
commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.text_theme));
|
||||
commentLikeIv.setImageResource(R.drawable.comment_vote_select);
|
||||
commentLikeCountTv.setText(NumberUtils.transSimpleCount(commentEntity.getVote()));
|
||||
commentLikeCountTv.setVisibility(View.VISIBLE);
|
||||
@ -502,7 +502,7 @@ public class CommentUtils {
|
||||
holder.commentLikeCountTv.setVisibility(View.GONE);
|
||||
} else { // 检查是否已点赞
|
||||
if (userDataEntity != null && (userDataEntity.isCommentVoted())) {
|
||||
holder.commentLikeCountTv.setTextColor(ContextCompat.getColor(mContext, R.color.theme_font));
|
||||
holder.commentLikeCountTv.setTextColor(ContextCompat.getColor(mContext, R.color.text_theme));
|
||||
holder.commentLikeIv.setImageResource(R.drawable.comment_vote_select);
|
||||
}
|
||||
holder.commentLikeCountTv.setVisibility(View.VISIBLE);
|
||||
|
||||
@ -125,8 +125,6 @@ public class DataUtils {
|
||||
|
||||
HaloApp.getInstance().setGid(gid);
|
||||
|
||||
SensorsBridge.setGid(gid);
|
||||
|
||||
// 更新广告配置
|
||||
ExtensionsKt.doOnMainProcessOnly(HaloApp.getInstance(), () -> {
|
||||
AdDelegateHelper.INSTANCE.requestAdConfig(false, "", null);
|
||||
@ -134,7 +132,7 @@ public class DataUtils {
|
||||
|
||||
// 避免重复调用
|
||||
if (!TextUtils.isEmpty(gid)) {
|
||||
GameSubstituteRepositoryHelper.updateSubstitutableGames();
|
||||
GameSubstituteRepositoryHelper.updateHistoricInstalledGameSet();
|
||||
}
|
||||
|
||||
getDeviceCertification(gid);
|
||||
@ -180,9 +178,11 @@ public class DataUtils {
|
||||
if (idCardEntity != null) {
|
||||
boolean isCertificated = !TextUtils.isEmpty(data.getIdCard().getId());
|
||||
boolean isAdult = data.getIdCard().getMinor() == null || !data.getIdCard().getMinor();
|
||||
boolean isCertificating = data.getIdCard().getStatus() == 1;
|
||||
|
||||
values.put(GhContentProvider.KEY_IS_CERTIFICATED, isCertificated); // 是否认证
|
||||
values.put(GhContentProvider.KEY_IS_ADULT, isAdult); // 是否成年
|
||||
values.put(GhContentProvider.KEY_IS_CERTIFICATING, isCertificating); // 是否认证中
|
||||
|
||||
if (!isCertificated) {
|
||||
RealNameHelper.updateCertificationStatus(0);
|
||||
@ -196,6 +196,7 @@ public class DataUtils {
|
||||
} else {
|
||||
values.put(GhContentProvider.KEY_IS_CERTIFICATED, false);
|
||||
values.put(GhContentProvider.KEY_IS_ADULT, false);
|
||||
values.put(GhContentProvider.KEY_IS_CERTIFICATING, false);
|
||||
RealNameHelper.updateCertificationStatus(0);
|
||||
}
|
||||
|
||||
|
||||
@ -458,8 +458,7 @@ public class DetailDownloadUtils {
|
||||
break;
|
||||
case waiting:
|
||||
downloadButton.setText(R.string.waiting);
|
||||
downloadButton.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_NORMAL);
|
||||
downloadButton.setVisibility(View.GONE);
|
||||
downloadButton.setButtonStyle(DownloadButton.ButtonStyle.WAITING);
|
||||
break;
|
||||
case overflow:
|
||||
case timeout:
|
||||
|
||||
@ -4,7 +4,6 @@ import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
@ -12,16 +11,9 @@ import android.net.Uri;
|
||||
import android.os.CountDownTimer;
|
||||
import android.provider.Settings;
|
||||
import android.text.Html;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextPaint;
|
||||
import android.text.TextUtils;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.ClickableSpan;
|
||||
import android.text.style.URLSpan;
|
||||
import android.text.style.UnderlineSpan;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -34,12 +26,9 @@ import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.facebook.drawee.generic.GenericDraweeHierarchy;
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.filter.RegionSetting;
|
||||
@ -47,11 +36,9 @@ import com.gh.common.xapk.XapkDialogHelper;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.ShellActivity;
|
||||
import com.gh.gamecenter.adapter.ReportReasonAdapter;
|
||||
import com.gh.gamecenter.adapter.viewholder.PrivacyPolicyItemViewHolder;
|
||||
import com.gh.gamecenter.common.base.TrackableDialog;
|
||||
import com.gh.gamecenter.common.callback.CancelListener;
|
||||
import com.gh.gamecenter.common.callback.ConfirmListener;
|
||||
import com.gh.gamecenter.common.callback.SimpleCallback;
|
||||
import com.gh.gamecenter.common.databinding.DialogAlertDefaultBinding;
|
||||
import com.gh.gamecenter.common.entity.SimpleGameEntity;
|
||||
import com.gh.gamecenter.common.entity.SuggestType;
|
||||
@ -60,9 +47,7 @@ import com.gh.gamecenter.common.utils.ExtensionsKt;
|
||||
import com.gh.gamecenter.common.utils.ImageUtils;
|
||||
import com.gh.gamecenter.common.utils.NetworkUtils;
|
||||
import com.gh.gamecenter.common.utils.SensorsBridge;
|
||||
import com.gh.gamecenter.common.view.CustomLinkMovementMethod;
|
||||
import com.gh.gamecenter.common.view.DrawableView;
|
||||
import com.gh.gamecenter.common.view.FixLinearLayoutManager;
|
||||
import com.gh.gamecenter.common.view.MaxHeightLinearLayout;
|
||||
import com.gh.gamecenter.common.view.MaxHeightNestedScrollView;
|
||||
import com.gh.gamecenter.common.view.VerticalItemDecoration;
|
||||
@ -80,10 +65,7 @@ import com.gh.gamecenter.databinding.DialogRelievePhoneBinding;
|
||||
import com.gh.gamecenter.databinding.DialogReportReasonBinding;
|
||||
import com.gh.gamecenter.databinding.DialogWechatReserveSuccessBinding;
|
||||
import com.gh.gamecenter.databinding.ImprintContentItemBinding;
|
||||
import com.gh.gamecenter.databinding.PrivacyItemBinding;
|
||||
import com.gh.gamecenter.entity.BadgeEntity;
|
||||
import com.gh.gamecenter.entity.PermissionsEntity;
|
||||
import com.gh.gamecenter.entity.PrivacyPolicyEntity;
|
||||
import com.gh.gamecenter.entity.TrackableEntity;
|
||||
import com.gh.gamecenter.feature.entity.ApkEntity;
|
||||
import com.gh.gamecenter.feature.entity.Badge;
|
||||
@ -91,7 +73,6 @@ import com.gh.gamecenter.feature.entity.GameEntity;
|
||||
import com.gh.gamecenter.feature.entity.SettingsEntity;
|
||||
import com.gh.gamecenter.help.HelpAndFeedbackBridge;
|
||||
import com.gh.gamecenter.setting.SettingBridge;
|
||||
import com.lightgame.adapter.BaseRecyclerAdapter;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
import com.lightgame.utils.AppManager;
|
||||
import com.lightgame.utils.Util_System_Keyboard;
|
||||
@ -328,180 +309,7 @@ public class DialogUtils {
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public static void showPrivacyPolicyDialog(Context context,
|
||||
@NonNull PrivacyPolicyEntity entity,
|
||||
SimpleCallback<Boolean> callback) {
|
||||
|
||||
final Context activityContext = checkDialogContext(context);
|
||||
|
||||
// 区分此 dialog 是点击 dialog 外部取消的还是点击返回取消的
|
||||
AtomicBoolean isCanceledByClickOutsideOfDialog = new AtomicBoolean(true);
|
||||
|
||||
final Dialog dialog = new Dialog(activityContext, R.style.GhAlertDialog);
|
||||
View contentView = LayoutInflater.from(activityContext).inflate(R.layout.dialog_privacy_policy, null);
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(contentView);
|
||||
|
||||
Window window = dialog.getWindow();
|
||||
if (window != null) {
|
||||
window.setBackgroundDrawableResource(android.R.color.transparent);
|
||||
WindowManager.LayoutParams params = window.getAttributes();
|
||||
params.horizontalMargin = 0;
|
||||
params.width = context.getResources().getDisplayMetrics().widthPixels - DisplayUtils.dip2px(40);
|
||||
// int height = context.getResources().getDisplayMetrics().heightPixels - DisplayUtils.dip2px(120);
|
||||
// int maxHeight = DisplayUtils.dip2px(446);
|
||||
// if (height > maxHeight) {
|
||||
// params.height = maxHeight;
|
||||
// } else {
|
||||
// params.height = height;
|
||||
// }
|
||||
window.setAttributes(params);
|
||||
}
|
||||
|
||||
TextView title = contentView.findViewById(R.id.title);
|
||||
TextView bottomContent = contentView.findViewById(R.id.bottom_content);
|
||||
TextView topContent = contentView.findViewById(R.id.top_content);
|
||||
TextView allowButton = contentView.findViewById(R.id.allow_button);
|
||||
TextView disallowButton = contentView.findViewById(R.id.disallow_button);
|
||||
TextView linkContent = contentView.findViewById(R.id.link_content);
|
||||
RecyclerView permissions = contentView.findViewById(R.id.permissions_content);
|
||||
|
||||
permissions.setLayoutManager(new FixLinearLayoutManager(context));
|
||||
permissions.setAdapter(new BaseRecyclerAdapter(context) {
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = mLayoutInflater.inflate(R.layout.privacy_item, parent, false);
|
||||
return new PrivacyPolicyItemViewHolder(PrivacyItemBinding.bind(view));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
if (holder instanceof PrivacyPolicyItemViewHolder) {
|
||||
PrivacyPolicyItemViewHolder viewHolder = (PrivacyPolicyItemViewHolder) holder;
|
||||
PrivacyItemBinding binding = viewHolder.getBinding();
|
||||
final PermissionsEntity permissionsEntity = entity.getPermissions().get(position);
|
||||
ImageUtils.display(binding.icon, permissionsEntity.getIcon());
|
||||
binding.name.setText(permissionsEntity.getName());
|
||||
binding.intro.setText(permissionsEntity.getIntro());
|
||||
GenericDraweeHierarchy hierarchy = binding.icon.getHierarchy();
|
||||
if (hierarchy != null) {
|
||||
if (position == 0) {
|
||||
hierarchy.setPlaceholderImage(R.drawable.permission_storage);
|
||||
} else if (position == 1) {
|
||||
hierarchy.setPlaceholderImage(R.drawable.permission_phone_state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return entity.getPermissions().size();
|
||||
}
|
||||
});
|
||||
|
||||
SpannableStringBuilder skipText = new SpannableStringBuilder("查看完整版的隐私政策和用户协议");
|
||||
skipText.setSpan(new ClickableSpan() {
|
||||
@Override
|
||||
public void updateDrawState(@NonNull TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
ds.setColor(ContextCompat.getColor(activityContext, R.color.theme_font));
|
||||
ds.setUnderlineText(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
// MtaHelper.onEvent("隐私政策弹窗", "隐私政策弹窗", "点击隐私政策");
|
||||
DirectUtils.directToExternalBrowser(context, context.getString(R.string.privacy_policy_url));
|
||||
}
|
||||
}, skipText.length() - 9, skipText.length() - 5, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
|
||||
skipText.setSpan(new ClickableSpan() {
|
||||
@Override
|
||||
public void updateDrawState(@NonNull TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
ds.setColor(ContextCompat.getColor(activityContext, R.color.theme_font));
|
||||
ds.setUnderlineText(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
// MtaHelper.onEvent("隐私政策弹窗", "隐私政策弹窗", "点击用户协议");
|
||||
DirectUtils.directToExternalBrowser(context, context.getString(R.string.disclaimer_url));
|
||||
}
|
||||
}, skipText.length() - 4, skipText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
|
||||
/*skipText.setSpan(new ClickableSpan() {
|
||||
@Override
|
||||
public void updateDrawState(@NonNull TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
ds.setColor(ContextCompat.getColor(activityContext, R.color.theme_font));
|
||||
ds.setUnderlineText(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
// MtaHelper.onEvent("隐私政策弹窗", "隐私政策弹窗", "点击第三方SDK接入说明");
|
||||
activityContext.startActivity(WebActivity.getThirdPartySdkStatementIntent(activityContext));
|
||||
}
|
||||
}, skipText.length() - 10, skipText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);*/
|
||||
|
||||
title.setText(entity.getTitle());
|
||||
linkContent.setText(skipText);
|
||||
linkContent.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
topContent.setText(entity.getTopContent());
|
||||
bottomContent.setText(ExtensionsKt.fromHtml(entity.getBottomContent()));
|
||||
bottomContent.setMovementMethod(CustomLinkMovementMethod.getInstance());
|
||||
|
||||
// Remove underline
|
||||
Spannable sa = (Spannable) bottomContent.getText();
|
||||
for (URLSpan u : sa.getSpans(0, sa.length(), URLSpan.class)) {
|
||||
sa.setSpan(new UnderlineSpan() {
|
||||
public void updateDrawState(TextPaint tp) {
|
||||
tp.setUnderlineText(false);
|
||||
}
|
||||
}, sa.getSpanStart(u), sa.getSpanEnd(u), 0);
|
||||
}
|
||||
|
||||
allowButton.setOnClickListener(view -> {
|
||||
dialog.dismiss();
|
||||
callback.onCallback(true);
|
||||
// MtaHelper.onEvent("隐私政策弹窗", "隐私政策弹窗", "点击同意");
|
||||
});
|
||||
|
||||
disallowButton.setOnClickListener(v -> {
|
||||
dialog.dismiss();
|
||||
callback.onCallback(false);
|
||||
// showPrivacyPolicyDisallowDialog(activityContext, entity, callback);
|
||||
// MtaHelper.onEvent("隐私政策弹窗", "隐私政策弹窗", "不同意并退出App");
|
||||
});
|
||||
|
||||
dialog.setOnCancelListener(cd -> {
|
||||
if (isCanceledByClickOutsideOfDialog.get()) {
|
||||
// MtaHelper.onEvent("隐私政策弹窗", "隐私政策弹窗", "点击空白");
|
||||
}
|
||||
});
|
||||
|
||||
dialog.setOnKeyListener((dialog1, keyCode, event) -> {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
|
||||
isCanceledByClickOutsideOfDialog.set(false);
|
||||
// MtaHelper.onEvent("隐私政策弹窗", "隐私政策弹窗", "点击返回");
|
||||
}
|
||||
return false;
|
||||
});
|
||||
// 用户未同意隐私策略不应该触发 MTA 事件
|
||||
// MtaHelper.onEvent("隐私政策弹窗", "隐私政策弹窗", "出现弹窗");
|
||||
|
||||
try {
|
||||
dialog.setCancelable(false);
|
||||
dialog.show();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
public static void showPrivacyPolicyDisallowDialog(Context context,
|
||||
@NonNull PrivacyPolicyEntity entity,
|
||||
EmptyCallback callback) {
|
||||
final Context activityContext = checkDialogContext(context);
|
||||
|
||||
@ -547,8 +355,8 @@ public class DialogUtils {
|
||||
TextView negativeTv = contentView.findViewById(R.id.negative);
|
||||
TextView positiveTv = contentView.findViewById(R.id.positive);
|
||||
TextView content = contentView.findViewById(R.id.content);
|
||||
positiveTv.setBackground(DrawableView.getOvalDrawable(R.color.background, 999));
|
||||
negativeTv.setBackground(DrawableView.getOvalDrawable(R.color.theme, 999));
|
||||
positiveTv.setBackground(DrawableView.getOvalDrawable(R.color.ui_background, 999));
|
||||
negativeTv.setBackground(DrawableView.getOvalDrawable(R.color.primary_theme, 999));
|
||||
content.setText(Html.fromHtml(context.getString(R.string.video_upload_draft_dialog_content)));
|
||||
|
||||
negativeTv.setOnClickListener(view -> {
|
||||
@ -1251,10 +1059,10 @@ public class DialogUtils {
|
||||
|
||||
DialogPackageParseErrorBinding binding = DialogPackageParseErrorBinding.inflate(LayoutInflater.from(context), null, false);
|
||||
Context finalContext = context;
|
||||
SpannableStringBuilder builder = new SpanBuilder("您也可以点击提交反馈跟我们联系").click(context, 6, 10, R.color.theme_font, true, new Function0<Unit>() {
|
||||
SpannableStringBuilder builder = new SpanBuilder("您也可以点击提交反馈跟我们联系").click(context, 6, 10, R.color.text_theme, true, new Function0<Unit>() {
|
||||
@Override
|
||||
public Unit invoke() {
|
||||
SimpleGameEntity entity = new SimpleGameEntity(gameId, gameName, "");
|
||||
SimpleGameEntity entity = new SimpleGameEntity(gameId, gameName, "", "");
|
||||
HelpAndFeedbackBridge.startSuggestionActivity(finalContext, SuggestType.GAME, "notfound", "模拟器安装包解析错误", entity);
|
||||
dialog.dismiss();
|
||||
return null;
|
||||
@ -1310,7 +1118,7 @@ public class DialogUtils {
|
||||
return null;
|
||||
});
|
||||
binding.reasonRv.setLayoutManager(new LinearLayoutManager(context));
|
||||
binding.reasonRv.addItemDecoration(new VerticalItemDecoration(context, 1F, false, R.color.background));
|
||||
binding.reasonRv.addItemDecoration(new VerticalItemDecoration(context, 1F, false, R.color.ui_background));
|
||||
binding.reasonRv.setAdapter(reportReasonAdapter);
|
||||
|
||||
binding.negativeBtn.setOnClickListener(v -> {
|
||||
@ -1332,7 +1140,7 @@ public class DialogUtils {
|
||||
ExtensionsKt.setTextChangedListener(binding.otherReasonEt, (s, start, before, count) -> {
|
||||
int tvCount = s.length();
|
||||
if (tvCount >= 500) {
|
||||
binding.tvCount.setTextColor(ContextCompat.getColor(finalContext, R.color.theme_red));
|
||||
binding.tvCount.setTextColor(ContextCompat.getColor(finalContext, R.color.secondary_red));
|
||||
}
|
||||
binding.tvCount.setText(tvCount + "/500");
|
||||
return null;
|
||||
|
||||
@ -321,6 +321,8 @@ object DirectUtils {
|
||||
|
||||
"qa", "qa_content", "Q&A" -> directToQa(context, linkEntity.text ?: "", linkEntity.link ?: "")
|
||||
|
||||
"qa_list" -> directToHelpAndFeedback(context)
|
||||
|
||||
"qa_collection", "Q&A合集" -> directToQaCollection(
|
||||
context, linkEntity.text
|
||||
?: "", linkEntity.link
|
||||
@ -920,9 +922,9 @@ object DirectUtils {
|
||||
browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
}
|
||||
context.startActivity(browserIntent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
Utils.toast(context, "跳转地址无效")
|
||||
url.copyTextAndToast(context.getString(R.string.direct_to_external_browser_failed_toast))
|
||||
}
|
||||
}
|
||||
|
||||
@ -1939,7 +1941,8 @@ object DirectUtils {
|
||||
fromRatingKey: Boolean = false,
|
||||
diagnosis: String = "",
|
||||
forceLogin: Boolean = true,
|
||||
requestCode: Int? = null
|
||||
requestCode: Int? = null,
|
||||
isSmoothGame: Boolean = false
|
||||
) {
|
||||
val intent = HelpAndFeedbackBridge.getIntent(
|
||||
context,
|
||||
@ -1952,7 +1955,8 @@ object DirectUtils {
|
||||
qaContentId,
|
||||
fromRatingKey,
|
||||
diagnosis,
|
||||
forceLogin
|
||||
forceLogin,
|
||||
isSmoothGame
|
||||
)
|
||||
if (requestCode != null) {
|
||||
(context as Activity).startActivityForResult(intent, requestCode)
|
||||
|
||||
@ -890,6 +890,7 @@ object DownloadItemUtils {
|
||||
gameEntity.id,
|
||||
gameEntity.name ?: "",
|
||||
gameEntity.categoryChinese,
|
||||
gameEntity.getApk().firstOrNull()?.format,
|
||||
clickRunnable
|
||||
)
|
||||
}
|
||||
@ -1122,7 +1123,7 @@ object DownloadItemUtils {
|
||||
}
|
||||
when (str) {
|
||||
context.getString(R.string.resume) -> {
|
||||
DownloadManager.getInstance().resume(downloadEntity, true)
|
||||
DownloadManager.getInstance().resume(downloadEntity, false)
|
||||
}
|
||||
|
||||
context.getString(R.string.waiting) -> {
|
||||
|
||||
@ -8,6 +8,7 @@ import com.gh.common.xapk.XapkInstaller
|
||||
import com.gh.download.DownloadDataHelper
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.ShellActivity
|
||||
import com.gh.gamecenter.common.base.GlobalActivityManager.getCurrentPageEntity
|
||||
import com.gh.gamecenter.common.base.GlobalActivityManager.getLastPageEntity
|
||||
import com.gh.gamecenter.common.base.activity.BaseActivity
|
||||
@ -171,6 +172,33 @@ object DownloadObserver {
|
||||
ToastUtils.toast("该游戏未接入防沉迷系统,暂不支持下载")
|
||||
}
|
||||
|
||||
// 删除任务
|
||||
downloadEntity.status = DownloadStatus.cancel
|
||||
downloadManager.cancel(downloadEntity.url)
|
||||
} else if (DownloadStatus.isCertificating == downloadEntity.status) {
|
||||
// 未接入防沉迷系统
|
||||
val currentActivity = AppManager.getInstance().currentActivity()
|
||||
|
||||
if (currentActivity != null) {
|
||||
DialogHelper.showDialog(
|
||||
context = currentActivity,
|
||||
title = "实名提示",
|
||||
content = "您当前的身份信息正在认证中,根据相关政策要求,该游戏需通过认证后才能进行下载",
|
||||
cancelText = "知道了",
|
||||
confirmText = "查看实名认证",
|
||||
cancelClickCallback = null,
|
||||
confirmClickCallback = {
|
||||
currentActivity.startActivity(
|
||||
ShellActivity.getIntent(
|
||||
currentActivity,
|
||||
ShellActivity.Type.REAL_NAME_INFO,
|
||||
))
|
||||
}
|
||||
)
|
||||
} else {
|
||||
ToastUtils.toast("您当前的身份信息正在认证中,根据相关政策要求,该游戏需通过认证后才能进行下载")
|
||||
}
|
||||
|
||||
// 删除任务
|
||||
downloadEntity.status = DownloadStatus.cancel
|
||||
downloadManager.cancel(downloadEntity.url)
|
||||
|
||||
@ -18,7 +18,6 @@ import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.entity.ErrorEntity
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.common.utils.SensorsBridge
|
||||
import com.gh.gamecenter.login.user.LoginTag
|
||||
import com.halo.assistant.fragment.user.UserInfoEditFragment
|
||||
import com.halo.assistant.fragment.user.VerifyPhoneFragment
|
||||
import com.lightgame.utils.AppManager
|
||||
@ -236,7 +235,7 @@ object ErrorHelper {
|
||||
)
|
||||
}
|
||||
binding.hintTv.text = errorEntity.data?.text
|
||||
binding.hintTv.setTextColor(R.color.theme_font.toColor(context))
|
||||
binding.hintTv.setTextColor(R.color.text_theme.toColor(context))
|
||||
binding.hintTv.setOnClickListener {
|
||||
errorEntity.data?.toLinkEntity()?.let { entity ->
|
||||
DirectUtils.directToLinkPage(context, entity, "实名提醒弹窗", "")
|
||||
@ -297,7 +296,7 @@ object ErrorHelper {
|
||||
)
|
||||
}
|
||||
binding.hintTv.text = errorEntity.data?.text
|
||||
binding.hintTv.setTextColor(R.color.theme_font.toColor(context))
|
||||
binding.hintTv.setTextColor(R.color.text_theme.toColor(context))
|
||||
binding.hintTv.setOnClickListener {
|
||||
errorEntity.data?.toLinkEntity()?.let { entity ->
|
||||
DirectUtils.directToLinkPage(context, entity, "手机号验证", "")
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.text.TextUtils
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.common.utils.doOnMainProcessOnly
|
||||
import com.gh.gamecenter.common.utils.toJson
|
||||
import com.gh.gamecenter.common.utils.toObject
|
||||
import com.gh.gamecenter.core.utils.MtaHelper
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.SubjectEntity
|
||||
import com.gh.gamecenter.login.user.UserManager
|
||||
@ -18,17 +18,19 @@ import com.lightgame.utils.Utils
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
||||
/**
|
||||
* 首页补充游戏库辅助类
|
||||
* 补充游戏库管理类
|
||||
*/
|
||||
object GameSubstituteRepositoryHelper {
|
||||
|
||||
private const val SP_GAME_SUB = "sp_game_sub"
|
||||
private const val KEY_GAME_REPOSITORY = "game_substitute_repository"
|
||||
|
||||
private var mSubstitutableGameIdSet = hashSetOf<String>()
|
||||
private var mApi = RetrofitManager.getInstance().api
|
||||
private var mHistoricInstalledGameIdSet = hashSetOf<String>() // 历史已安装过的游戏 ID 列表
|
||||
private var mApplicationContext = HaloApp.getInstance().application
|
||||
private val mGameSubSp by lazy { mApplicationContext.getSharedPreferences(SP_GAME_SUB, Context.MODE_PRIVATE) }
|
||||
|
||||
var gameCollectionList: List<SubjectEntity> = arrayListOf()
|
||||
private var mGameCollectionList: List<SubjectEntity> = arrayListOf() // 游戏补充库
|
||||
|
||||
init {
|
||||
loadSavedRepository()
|
||||
@ -50,9 +52,13 @@ object GameSubstituteRepositoryHelper {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 联网获取历史已安装过的游戏 ID 列表
|
||||
* 包括根据用户 ID 获取的已玩游戏 ID 列表,以及根据 gid 获取的已下载游戏 ID 列表
|
||||
*/
|
||||
@JvmStatic
|
||||
@SuppressLint("CheckResult")
|
||||
fun updateSubstitutableGames() {
|
||||
fun updateHistoricInstalledGameSet() {
|
||||
mApplicationContext.doOnMainProcessOnly {
|
||||
val single = if (UserManager.getInstance().isLoggedIn) {
|
||||
mApi.getIdListOfPlayedGames(UserManager.getInstance().userId, Utils.getTime(mApplicationContext))
|
||||
@ -61,28 +67,22 @@ object GameSubstituteRepositoryHelper {
|
||||
}
|
||||
single.subscribeOn(Schedulers.io()).subscribe(object : BiResponse<List<String>>() {
|
||||
override fun onSuccess(data: List<String>) {
|
||||
mSubstitutableGameIdSet = data.toHashSet()
|
||||
mHistoricInstalledGameIdSet = data.toHashSet()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新内存中的游戏库(即从 SP 中再读一次)
|
||||
*/
|
||||
@JvmStatic
|
||||
fun refreshRepositoryFromLocal() = loadSavedRepository()
|
||||
|
||||
private fun loadSavedRepository() {
|
||||
gameCollectionList = SPUtils.getString(KEY_GAME_REPOSITORY).toObject() ?: arrayListOf()
|
||||
mGameCollectionList = SPUtils.getString(mGameSubSp, KEY_GAME_REPOSITORY).toObject() ?: arrayListOf()
|
||||
}
|
||||
|
||||
private fun updateGameRepository(subjects: List<SubjectEntity>?) {
|
||||
if (subjects == null) return
|
||||
|
||||
SPUtils.setString(KEY_GAME_REPOSITORY, subjects.toJson())
|
||||
SPUtils.setString(mGameSubSp, KEY_GAME_REPOSITORY, subjects.toJson())
|
||||
|
||||
gameCollectionList = subjects
|
||||
mGameCollectionList = subjects
|
||||
}
|
||||
|
||||
/**
|
||||
@ -90,19 +90,12 @@ object GameSubstituteRepositoryHelper {
|
||||
* @param collectionId 补充游戏库相应专题 ID
|
||||
* @param gameIdList 该专题里已经包含的游戏 ID 列表
|
||||
*/
|
||||
private fun getOneUniqueGame(collectionId: String?, gameIdList: HashSet<String>): GameEntity? {
|
||||
private fun getValidGame(collectionId: String?, gameIdList: HashSet<String>): GameEntity? {
|
||||
collectionId?.let {
|
||||
val collection = gameCollectionList.find { it.id == collectionId }
|
||||
val collection = mGameCollectionList.find { it.id == collectionId }
|
||||
collection?.let {
|
||||
val game = collection.data?.find { game -> isThisGameUnique(game, gameIdList) }
|
||||
val game = collection.data?.find { game -> isThisGameValid(game, gameIdList) }
|
||||
game?.let {
|
||||
collection.data?.remove(game)
|
||||
// collection.data?.size?.let { remainingSize ->
|
||||
// // 记录被替换游戏的数量,10个以上的时候触发
|
||||
// if (remainingSize % 10 == 0) {
|
||||
// SentryHelper.onEvent("game_substitute", "substituted_size", "${50 - remainingSize}")
|
||||
// }
|
||||
// }
|
||||
// 产品说要记录补充专题的曝光数,所以这个游戏附带了所在专题的名字
|
||||
game.subjectName = collection.name
|
||||
game.subjectId = collection.id
|
||||
@ -115,14 +108,17 @@ object GameSubstituteRepositoryHelper {
|
||||
|
||||
/**
|
||||
* 替换游戏,包括 已安装,历史下载,历史已安装等类型
|
||||
* @param gameList 需要被替换数据的游戏列表
|
||||
* @param displayingGameIdSet 页面正在显示的游戏 ID 列表,避免重复替换
|
||||
* @param relatedCollectionId 关联的替换合集 ID
|
||||
*/
|
||||
fun replaceGames(
|
||||
gameList: MutableList<GameEntity>,
|
||||
alreadyDisplayedGameIdSet: HashSet<String>,
|
||||
displayingGameIdSet: HashSet<String>,
|
||||
relatedCollectionId: String,
|
||||
shouldLogReplaceEvent: Boolean
|
||||
) {
|
||||
val positionOfTheGameToReplaceList = arrayListOf<Int>()
|
||||
// 需要被替换的游戏 position 列表
|
||||
val positionOfGameToBeReplacedList = arrayListOf<Int>()
|
||||
|
||||
// 标记需要替换的已安装游戏
|
||||
for ((index, game) in gameList.withIndex()) {
|
||||
@ -132,28 +128,29 @@ object GameSubstituteRepositoryHelper {
|
||||
continue
|
||||
}
|
||||
|
||||
var isThisPositionLabeled = false
|
||||
// 这个 position 的游戏是否需要被替换
|
||||
var thisPositionNeedToBeReplaced = false
|
||||
|
||||
// 从 游戏ID 判断当前游戏是否需要被替换
|
||||
if (mSubstitutableGameIdSet.contains(game.id)) {
|
||||
positionOfTheGameToReplaceList.add(index)
|
||||
isThisPositionLabeled = true
|
||||
if (mHistoricInstalledGameIdSet.contains(game.id)) {
|
||||
positionOfGameToBeReplacedList.add(index)
|
||||
thisPositionNeedToBeReplaced = true
|
||||
}
|
||||
|
||||
// 检查是否已安装该游戏里同包名的 APK
|
||||
if (!isThisPositionLabeled) {
|
||||
if (!thisPositionNeedToBeReplaced) {
|
||||
for (apk in game.getApk()) {
|
||||
if (PackageHelper.validLocalPackageNameSet.contains(apk.packageName)) {
|
||||
// 将该位置的游戏标记为需要替换
|
||||
positionOfTheGameToReplaceList.add(index)
|
||||
isThisPositionLabeled = true
|
||||
positionOfGameToBeReplacedList.add(index)
|
||||
thisPositionNeedToBeReplaced = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 若此游戏所包含的 apk 没有已安装,那么再检查是否已安装有预设相关包名
|
||||
if (!isThisPositionLabeled) {
|
||||
if (!thisPositionNeedToBeReplaced) {
|
||||
var relatedPackageList = arrayListOf<String>()
|
||||
for (entity in PackageHelper.relatedPackageList) {
|
||||
if (entity.gameId == game.id) {
|
||||
@ -164,39 +161,45 @@ object GameSubstituteRepositoryHelper {
|
||||
|
||||
for (packageName in relatedPackageList) {
|
||||
if (PackageHelper.validLocalPackageNameSet.contains(packageName)) {
|
||||
positionOfTheGameToReplaceList.add(index)
|
||||
positionOfGameToBeReplacedList.add(index)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (positionOfTheGameToReplaceList.isNotEmpty()) {
|
||||
if (shouldLogReplaceEvent) {
|
||||
MtaHelper.onEvent("首页_加载", "启动光环", "替换游戏")
|
||||
}
|
||||
for (position in positionOfTheGameToReplaceList) {
|
||||
val replacingGame = getOneUniqueGame(relatedCollectionId, alreadyDisplayedGameIdSet)
|
||||
replacingGame?.let {
|
||||
gameList[position] = replacingGame
|
||||
if (positionOfGameToBeReplacedList.isNotEmpty()) {
|
||||
for (position in positionOfGameToBeReplacedList) {
|
||||
val validGame = getValidGame(relatedCollectionId, displayingGameIdSet)
|
||||
validGame?.let {
|
||||
gameList[position] = it
|
||||
displayingGameIdSet.add(it.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun isThisGameUnique(game: GameEntity, gameIdList: HashSet<String>): Boolean {
|
||||
// 判断该游戏是否出现在已安装列表
|
||||
if (mSubstitutableGameIdSet.contains(game.id)) return false
|
||||
/**
|
||||
* 判断该游戏是否有效
|
||||
* @param game 需要判断的游戏
|
||||
* @param gameIdList 专题里已经包含的游戏 ID 列表
|
||||
*/
|
||||
private fun isThisGameValid(
|
||||
game: GameEntity,
|
||||
gameIdList: HashSet<String>
|
||||
): Boolean {
|
||||
// 该游戏是否在历史已安装列表中
|
||||
if (mHistoricInstalledGameIdSet.contains(game.id)) return false
|
||||
|
||||
// 该补充游戏是否已经存在关联关系
|
||||
// 该游戏是否与专题里已包含的游戏存在关联关系
|
||||
for (relatedId in game.relatedGameIds!!) {
|
||||
if (gameIdList.contains(relatedId)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查本地是否已安装该游戏,已过滤部分框架服务的包名
|
||||
for (apk in game.getApk()) {
|
||||
// 检查本地是否已安装该游戏,已过滤那部分框架服务的包名
|
||||
if (PackageHelper.validLocalPackageNameSet.contains(apk.packageName)) {
|
||||
return false
|
||||
}
|
||||
|
||||
@ -183,12 +183,12 @@ public class LibaoUtils {
|
||||
case "coming":
|
||||
libaoBtn.setText(R.string.libao_coming);
|
||||
libaoBtn.setBackgroundResource(R.drawable.button_round_gray_light);
|
||||
libaoBtn.setTextColor(context.getResources().getColor(R.color.text_subtitleDesc));
|
||||
libaoBtn.setTextColor(context.getResources().getColor(R.color.text_tertiary));
|
||||
break;
|
||||
case "used_up":
|
||||
libaoBtn.setText(R.string.libao_used_up);
|
||||
libaoBtn.setBackgroundResource(R.drawable.button_normal_round_border);
|
||||
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme_font));
|
||||
libaoBtn.setTextColor(context.getResources().getColor(R.color.text_theme));
|
||||
break;
|
||||
case "finish":
|
||||
libaoBtn.setText(R.string.libao_finish);
|
||||
@ -198,12 +198,12 @@ public class LibaoUtils {
|
||||
case "linged":
|
||||
libaoBtn.setText(R.string.libao_linged);
|
||||
libaoBtn.setBackgroundResource(R.drawable.button_round_gray_light);
|
||||
libaoBtn.setTextColor(context.getResources().getColor(R.color.text_subtitleDesc));
|
||||
libaoBtn.setTextColor(context.getResources().getColor(R.color.text_tertiary));
|
||||
break;
|
||||
case "taoed":
|
||||
libaoBtn.setText(R.string.libao_taoed);
|
||||
libaoBtn.setBackgroundResource(R.drawable.button_normal_round_border);
|
||||
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme_font));
|
||||
libaoBtn.setTextColor(context.getResources().getColor(R.color.text_theme));
|
||||
break;
|
||||
case "copy":
|
||||
libaoBtn.setText(R.string.libao_copy);
|
||||
@ -213,13 +213,13 @@ public class LibaoUtils {
|
||||
case "repeatLinged":
|
||||
libaoBtn.setText(R.string.libao_repeat_ling);
|
||||
libaoBtn.setBackgroundResource(R.drawable.button_normal_round_border);
|
||||
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme_font));
|
||||
libaoBtn.setTextColor(context.getResources().getColor(R.color.text_theme));
|
||||
break;
|
||||
case "repeatTao":
|
||||
case "repeatTaoed":
|
||||
libaoBtn.setText(R.string.libao_repeat_tao);
|
||||
libaoBtn.setBackgroundResource(R.drawable.button_normal_round_border);
|
||||
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme_font));
|
||||
libaoBtn.setTextColor(context.getResources().getColor(R.color.text_theme));
|
||||
break;
|
||||
case "unshelve":
|
||||
libaoBtn.setBackgroundResource(R.drawable.button_border_round_gray);
|
||||
|
||||
@ -259,6 +259,7 @@ public class LogUtils {
|
||||
private static void uploadToReservation(JSONObject object) {
|
||||
Context context = HaloApp.getInstance().getApplication();
|
||||
try {
|
||||
object.put(KEY_EVENT, "appointment");
|
||||
object.put("version", PackageUtils.getGhVersionName());
|
||||
object.put("channel", HaloApp.getInstance().getChannel());
|
||||
object.put("dia", MetaUtil.getBase64EncodedAndroidId());
|
||||
|
||||
@ -668,7 +668,8 @@ object NewFlatLogUtils {
|
||||
searchKey: String,
|
||||
bbsId: String,
|
||||
sequence: Int,
|
||||
name: String
|
||||
name: String,
|
||||
button: String
|
||||
) {
|
||||
json {
|
||||
KEY_EVENT to "search_bbs_click"
|
||||
@ -677,6 +678,7 @@ object NewFlatLogUtils {
|
||||
"bbs_id" to bbsId
|
||||
"sequence" to sequence
|
||||
"name" to name
|
||||
"button" to button
|
||||
parseAndPutMeta()()
|
||||
}.let(::log)
|
||||
}
|
||||
@ -1271,10 +1273,19 @@ object NewFlatLogUtils {
|
||||
}
|
||||
|
||||
// 存档分享弹窗点击事件
|
||||
fun logCloudArchiveShareDialogClick(buttonType: String, gameId: String, gameName: String, cloudSaveId: String) {
|
||||
fun logCloudArchiveShareDialogClick(
|
||||
buttonType: String,
|
||||
gameId: String,
|
||||
gameName: String,
|
||||
cloudSaveId: String,
|
||||
cloudSaveName: String,
|
||||
content: String
|
||||
) {
|
||||
val json = json {
|
||||
"cloud_save_id" to cloudSaveId
|
||||
KEY_EVENT to "cloud_save_share_dialog_click"
|
||||
"cloud_save_id" to cloudSaveId
|
||||
"cloud_save_name" to cloudSaveName
|
||||
"content" to content
|
||||
KEY_BUTTON_TYPE to buttonType
|
||||
KEY_GAME_ID to gameId
|
||||
KEY_GAME_NAME to gameName
|
||||
@ -1324,12 +1335,14 @@ object NewFlatLogUtils {
|
||||
}
|
||||
|
||||
// 上传存档弹窗点击事件
|
||||
fun logCloudArchiveUploadDialogClick(buttonType: String, gameId: String, gameName: String) {
|
||||
fun logCloudArchiveUploadDialogClick(gameId: String, gameName: String, cloudSaveId: String, cloudSaveName: String, isSuccess: Boolean) {
|
||||
val json = json {
|
||||
KEY_EVENT to "cloud_save_upload_dialog_click"
|
||||
KEY_BUTTON_TYPE to buttonType
|
||||
KEY_GAME_ID to gameId
|
||||
KEY_GAME_NAME to gameName
|
||||
"cloud_save_id" to cloudSaveId
|
||||
"cloud_save_name" to cloudSaveName
|
||||
"is_success" to isSuccess
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json)
|
||||
@ -1770,7 +1783,12 @@ object NewFlatLogUtils {
|
||||
}
|
||||
|
||||
//新游开测详情页点击游戏类型
|
||||
fun logGameTestDetailGameCategoryClick(tabName: String, gameCategory: String, gameTestStartType: String, isOn: Boolean) {
|
||||
fun logGameTestDetailGameCategoryClick(
|
||||
tabName: String,
|
||||
gameCategory: String,
|
||||
gameTestStartType: String,
|
||||
isOn: Boolean
|
||||
) {
|
||||
val json = json {
|
||||
"event" to "game_test_detail_game_category_click"
|
||||
"tab_name" to tabName
|
||||
@ -2657,4 +2675,49 @@ object NewFlatLogUtils {
|
||||
}
|
||||
log(json)
|
||||
}
|
||||
|
||||
// 搜索结果页面点击横幅位卡片
|
||||
@JvmStatic
|
||||
fun logGameSearchFirstGameBannerClick(
|
||||
gameId: String,
|
||||
gameName: String,
|
||||
sequence: Int,
|
||||
linkType: String?,
|
||||
linkId: String?,
|
||||
linkText: String?
|
||||
) {
|
||||
json {
|
||||
KEY_EVENT to "game_search_first_game_banner_click"
|
||||
"game_id" to gameId
|
||||
"game_name" to gameName
|
||||
"sequence" to sequence
|
||||
"link_type" to linkType
|
||||
"link_id" to linkId
|
||||
"link_text" to linkText
|
||||
parseAndPutMeta()(this)
|
||||
}.let(::log)
|
||||
}
|
||||
|
||||
// 搜索结果页面点击卡片栏卡片
|
||||
fun logGameSearchFirstGameCardClick(
|
||||
gameId: String,
|
||||
gameName: String,
|
||||
title: String,
|
||||
sequence: Int,
|
||||
linkType: String?,
|
||||
linkId: String?,
|
||||
linkText: String?
|
||||
) {
|
||||
json {
|
||||
KEY_EVENT to "game_search_first_game_card_click"
|
||||
"game_id" to gameId
|
||||
"game_name" to gameName
|
||||
"title" to title
|
||||
"sequence" to sequence
|
||||
"link_type" to linkType
|
||||
"link_id" to linkId
|
||||
"link_text" to linkText
|
||||
parseAndPutMeta()(this)
|
||||
}.let(::log)
|
||||
}
|
||||
}
|
||||
@ -19,6 +19,7 @@ import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.utils.CurrentActivityHolder
|
||||
import com.gh.gamecenter.core.utils.MD5Utils
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.install.InstallService
|
||||
import com.gh.gamecenter.vpn.VpnHelper
|
||||
import com.gh.vspace.VHelper
|
||||
import com.halo.assistant.HaloApp
|
||||
@ -159,6 +160,13 @@ object PackageInstaller {
|
||||
*/
|
||||
private fun install(context: Context, pkgPath: String) {
|
||||
HaloApp.put(Constants.LAST_INSTALL_GAME, pkgPath)
|
||||
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.TIRAMISU && Build.MANUFACTURER.lowercase().contains("xiaomi")) {
|
||||
val foregroundServiceIntent = Intent(context, InstallService::class.java)
|
||||
foregroundServiceIntent.putExtra(InstallService.KEY_SERVICE_ACTION, InstallService.START_FOREGROUND)
|
||||
context.startForegroundService(foregroundServiceIntent)
|
||||
}
|
||||
|
||||
val installIntent = getInstallIntent(context, pkgPath)
|
||||
context.startActivity(installIntent)
|
||||
}
|
||||
|
||||
@ -22,8 +22,8 @@ object RealNameHelper {
|
||||
/**
|
||||
* 弹未成年人不能下载游戏弹窗
|
||||
*/
|
||||
fun showRealNameUnqualifiedDialog(downloadEntity: DownloadEntity) {
|
||||
val contentText = if (downloadEntity.status == DownloadStatus.done) {
|
||||
fun showRealNameUnqualifiedDialog(downloadEntity: DownloadEntity?) {
|
||||
val contentText = if (downloadEntity?.status == DownloadStatus.done) {
|
||||
"为保护未成年身心健康成长\n" + "根据相关政策要求,该游戏不对未成年人开放"
|
||||
} else {
|
||||
"为保护未成年身心健康成长\n" + "根据相关政策要求,该游戏不对未成年人开放下载"
|
||||
@ -45,7 +45,7 @@ object RealNameHelper {
|
||||
}
|
||||
)
|
||||
}
|
||||
if (downloadEntity.status != DownloadStatus.done) {
|
||||
if (downloadEntity != null && downloadEntity.status != DownloadStatus.done) {
|
||||
DownloadManager.getInstance()
|
||||
.addInvisiblePendingTask(downloadEntity)
|
||||
}
|
||||
@ -54,22 +54,24 @@ object RealNameHelper {
|
||||
/**
|
||||
* 弹需要实名弹窗
|
||||
*/
|
||||
fun showRealNameUncertificatedDialog(downloadEntity: DownloadEntity) {
|
||||
fun showRealNameUncertificatedDialog(downloadEntity: DownloadEntity?) {
|
||||
// 是否强制实名
|
||||
val isForced = downloadEntity.getMetaExtra("force_real_name") != "false"
|
||||
val isForced = downloadEntity?.getMetaExtra("force_real_name") != "false"
|
||||
|
||||
NewLogUtils.logCertificationTrigger(downloadEntity.gameId, downloadEntity.name)
|
||||
SensorsBridge.trackEvent(
|
||||
"VerificationDialogShow",
|
||||
"game_id",
|
||||
downloadEntity.gameId,
|
||||
"game_name",
|
||||
downloadEntity.name ?: "",
|
||||
"game_type",
|
||||
downloadEntity.meta[Constants.GAME_CATEGORY_IN_CHINESE] ?: ""
|
||||
)
|
||||
downloadEntity?.let {
|
||||
NewLogUtils.logCertificationTrigger(downloadEntity.gameId, downloadEntity.name)
|
||||
SensorsBridge.trackEvent(
|
||||
"VerificationDialogShow",
|
||||
"game_id",
|
||||
downloadEntity.gameId,
|
||||
"game_name",
|
||||
downloadEntity.name ?: "",
|
||||
"game_type",
|
||||
downloadEntity.meta[Constants.GAME_CATEGORY_IN_CHINESE] ?: ""
|
||||
)
|
||||
}
|
||||
|
||||
val contentText = if (downloadEntity.status == DownloadStatus.done) {
|
||||
val contentText = if (downloadEntity?.status == DownloadStatus.done) {
|
||||
"为保护未成年身心健康成长\n" + "根据相关政策要求,该游戏不对未成年人开放\n" + "如需完成安装,请前往实名认证"
|
||||
} else {
|
||||
"为保护未成年身心健康成长\n" + "根据相关政策要求,该游戏不对未成年人开放下载\n" + "如需下载,请前往实名认证"
|
||||
@ -98,7 +100,7 @@ object RealNameHelper {
|
||||
putExtra(EntranceConsts.KEY_IS_FORCED_TO_CERTIFICATE_BUT_WITH_BACKDOOR, !isForced)
|
||||
}
|
||||
)
|
||||
if (downloadEntity.status == DownloadStatus.done) {
|
||||
if (downloadEntity?.status == DownloadStatus.done) {
|
||||
pendingInstallPkgPath = downloadEntity.path
|
||||
}
|
||||
NewLogUtils.logCertificationHintDialogOptionsClicked("前往实名认证")
|
||||
@ -123,7 +125,7 @@ object RealNameHelper {
|
||||
}
|
||||
}
|
||||
|
||||
if (downloadEntity.status != DownloadStatus.done) {
|
||||
if (downloadEntity != null && downloadEntity.status != DownloadStatus.done) {
|
||||
DownloadManager.getInstance()
|
||||
.addInvisiblePendingTask(downloadEntity)
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ object ReservationHelper {
|
||||
}, cancelClickCallback = {
|
||||
cancelListener?.onCancel()
|
||||
}, uiModificationCallback = {
|
||||
it.confirmTv.setTextColor(R.color.theme_red.toColor(context))
|
||||
it.confirmTv.setTextColor(R.color.secondary_red.toColor(context))
|
||||
}, extraConfig = DialogHelper.Config(centerContent = true, centerTitle = true)
|
||||
)
|
||||
}
|
||||
|
||||
@ -0,0 +1,92 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.common.utils.DialogHelper
|
||||
import com.gh.gamecenter.core.runOnIoThread
|
||||
import com.gh.gamecenter.core.runOnUiThread
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.ndownload.NHttpClient
|
||||
import com.lightgame.utils.AppManager
|
||||
import org.json.JSONObject
|
||||
import java.io.BufferedReader
|
||||
import java.io.InputStream
|
||||
import java.io.InputStreamReader
|
||||
import java.net.HttpURLConnection
|
||||
|
||||
/**
|
||||
* 一个临时用来检测实名的工具类,相关需求是这个 https://jira.shanqu.cc/browse/GHZS-4522
|
||||
*/
|
||||
object TempCertificationUtils {
|
||||
|
||||
fun checkCertificationBeforeAction(gameEntity: GameEntity, action: () -> Unit) {
|
||||
// 更新下载相关的meta信息,用于 connection 的 header
|
||||
DownloadManager.updateDownloadMetaMap()
|
||||
|
||||
runOnIoThread {
|
||||
try {
|
||||
val url = gameEntity.getApk().firstOrNull()?.url ?: return@runOnIoThread
|
||||
|
||||
val client = NHttpClient()
|
||||
val connection = client.connect(url, 3000, 3000, -1, -1, -1, null)
|
||||
val code = connection.responseCode
|
||||
if (code == HttpURLConnection.HTTP_FORBIDDEN) {
|
||||
val resultObject = JSONObject(getErrorResponse(connection.errorStream))
|
||||
val customResponseCode = resultObject.getString("code")
|
||||
|
||||
if ("403001" == customResponseCode) {
|
||||
// 未实名
|
||||
runOnUiThread {
|
||||
RealNameHelper.showRealNameUncertificatedDialog(null)
|
||||
}
|
||||
} else if ("403002" == customResponseCode) {
|
||||
// 未成年
|
||||
runOnUiThread {
|
||||
RealNameHelper.showRealNameUnqualifiedDialog(null)
|
||||
}
|
||||
} else if ("403003" == customResponseCode) {
|
||||
// 该游戏未接入防沉迷系统禁止下载
|
||||
val currentActivity = AppManager.getInstance().currentActivity()
|
||||
|
||||
if (currentActivity != null) {
|
||||
runOnUiThread {
|
||||
DialogHelper.showDialog(
|
||||
context = currentActivity,
|
||||
title = "温馨提示",
|
||||
content = "该游戏未接入防沉迷系统,暂不支持下载",
|
||||
confirmText = "知道了",
|
||||
cancelText = ""
|
||||
)
|
||||
}
|
||||
} else {
|
||||
ToastUtils.toast("该游戏未接入防沉迷系统,暂不支持下载")
|
||||
}
|
||||
} else if ("403004" == customResponseCode) {
|
||||
// 后台禁止该设备下载
|
||||
ToastUtils.showToast("网络异常")
|
||||
} else {
|
||||
ToastUtils.showToast("网络异常 $customResponseCode")
|
||||
}
|
||||
} else {
|
||||
runOnUiThread {
|
||||
action.invoke()
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
ToastUtils.showToast("网络异常,请稍后再试 ${e.message}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getErrorResponse(inputStream: InputStream): String {
|
||||
val bf = BufferedReader(InputStreamReader(inputStream))
|
||||
val stringBuffer = StringBuilder()
|
||||
var strCurrentLine: String?
|
||||
while (bf.readLine().also { strCurrentLine = it } != null) {
|
||||
stringBuffer.append(strCurrentLine)
|
||||
}
|
||||
bf.close()
|
||||
return stringBuffer.toString()
|
||||
}
|
||||
|
||||
}
|
||||
246
app/src/main/java/com/gh/common/video/CustomExo2PlayerManager.kt
Normal file
246
app/src/main/java/com/gh/common/video/CustomExo2PlayerManager.kt
Normal file
@ -0,0 +1,246 @@
|
||||
package com.gh.common.video
|
||||
|
||||
import android.content.Context
|
||||
import android.media.AudioManager
|
||||
import android.net.TrafficStats
|
||||
import android.net.Uri
|
||||
import android.os.Message
|
||||
import android.view.Surface
|
||||
import com.google.android.exoplayer2.SeekParameters
|
||||
import com.google.android.exoplayer2.video.DummySurface
|
||||
import com.shuyu.gsyvideoplayer.cache.ICacheManager
|
||||
import com.shuyu.gsyvideoplayer.model.GSYModel
|
||||
import com.shuyu.gsyvideoplayer.model.VideoOptionModel
|
||||
import com.shuyu.gsyvideoplayer.player.BasePlayerManager
|
||||
import tv.danmaku.ijk.media.player.IMediaPlayer
|
||||
|
||||
/**
|
||||
* 基于Exo2PlayerManager修改,主要做了如下改动:
|
||||
* 1.使用CustomIjkExo2MediaPlayer代替IjkExo2MediaPlayer
|
||||
* 2.复用mediaPlayer的实例,提高内存利用效率
|
||||
*/
|
||||
class CustomExo2PlayerManager : BasePlayerManager() {
|
||||
|
||||
private var context: Context? = null
|
||||
|
||||
private var mediaPlayer: CustomIjkExo2MediaPlayer? = null
|
||||
|
||||
private var surface: Surface? = null
|
||||
|
||||
private var dummySurface: DummySurface? = null
|
||||
|
||||
private var lastTotalRxBytes: Long = 0
|
||||
|
||||
private var lastTimeStamp: Long = 0
|
||||
|
||||
override fun getMediaPlayer(): IMediaPlayer? {
|
||||
return mediaPlayer
|
||||
}
|
||||
|
||||
override fun initVideoPlayer(
|
||||
context: Context,
|
||||
msg: Message,
|
||||
optionModelList: List<VideoOptionModel?>?,
|
||||
cacheManager: ICacheManager?
|
||||
) {
|
||||
this.context = context.applicationContext
|
||||
|
||||
val mediaPlayer = this.mediaPlayer ?: CustomIjkExo2MediaPlayer().apply {
|
||||
mediaPlayer = this
|
||||
}
|
||||
|
||||
if (mediaPlayer.appContext != context.applicationContext) {
|
||||
mediaPlayer.release()
|
||||
mediaPlayer.updateAppContext(context)
|
||||
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC)
|
||||
}
|
||||
|
||||
if (dummySurface == null) {
|
||||
dummySurface = DummySurface.newInstanceV17(context, false)
|
||||
}
|
||||
|
||||
//使用自己的cache模式
|
||||
val gsyModel = msg.obj as GSYModel
|
||||
try {
|
||||
mediaPlayer.isLooping = gsyModel.isLooping
|
||||
mediaPlayer.isPreview = gsyModel.mapHeadData != null && gsyModel.mapHeadData.isNotEmpty()
|
||||
if (gsyModel.isCache && cacheManager != null) {
|
||||
//通过管理器处理
|
||||
cacheManager.doCacheLogic(context, mediaPlayer, gsyModel.url, gsyModel.mapHeadData, gsyModel.cachePath)
|
||||
} else {
|
||||
//通过自己的内部缓存机制
|
||||
mediaPlayer.isCache = gsyModel.isCache
|
||||
mediaPlayer.cacheDir = gsyModel.cachePath
|
||||
mediaPlayer.overrideExtension = gsyModel.overrideExtension
|
||||
mediaPlayer.setDataSource(context, Uri.parse(gsyModel.url), gsyModel.mapHeadData)
|
||||
}
|
||||
if (gsyModel.speed != 1f && gsyModel.speed > 0) {
|
||||
mediaPlayer.setSpeed(gsyModel.speed, 1f)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
initSuccess(gsyModel)
|
||||
}
|
||||
|
||||
override fun showDisplay(msg: Message) {
|
||||
if (msg.obj == null) {
|
||||
mediaPlayer?.setSurface(dummySurface)
|
||||
} else {
|
||||
val holder = msg.obj as Surface
|
||||
surface = holder
|
||||
mediaPlayer?.setSurface(holder)
|
||||
}
|
||||
}
|
||||
|
||||
override fun setSpeed(speed: Float, soundTouch: Boolean) {
|
||||
try {
|
||||
mediaPlayer?.setSpeed(speed, 1f)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
override fun setNeedMute(needMute: Boolean) {
|
||||
if (needMute) {
|
||||
mediaPlayer?.setVolume(0f, 0f)
|
||||
} else {
|
||||
mediaPlayer?.setVolume(1f, 1f)
|
||||
}
|
||||
}
|
||||
|
||||
override fun setVolume(left: Float, right: Float) {
|
||||
mediaPlayer?.setVolume(left, right)
|
||||
}
|
||||
|
||||
override fun releaseSurface() {
|
||||
if (surface != null) {
|
||||
//surface.release();
|
||||
surface = null
|
||||
}
|
||||
}
|
||||
|
||||
override fun release() {
|
||||
mediaPlayer?.setSurface(null)
|
||||
mediaPlayer?.release()
|
||||
mediaPlayer = null
|
||||
|
||||
dummySurface?.release()
|
||||
dummySurface = null
|
||||
lastTotalRxBytes = 0
|
||||
lastTimeStamp = 0
|
||||
}
|
||||
|
||||
override fun getBufferedPercentage(): Int {
|
||||
return mediaPlayer?.bufferedPercentage ?: 0
|
||||
}
|
||||
|
||||
override fun getNetSpeed(): Long {
|
||||
return if (mediaPlayer != null) {
|
||||
getNetSpeed(context)
|
||||
} else 0
|
||||
}
|
||||
|
||||
|
||||
override fun setSpeedPlaying(speed: Float, soundTouch: Boolean) {}
|
||||
|
||||
|
||||
override fun start() {
|
||||
if (mediaPlayer != null) {
|
||||
mediaPlayer!!.start()
|
||||
}
|
||||
}
|
||||
|
||||
override fun stop() {
|
||||
if (mediaPlayer != null) {
|
||||
mediaPlayer!!.stop()
|
||||
}
|
||||
}
|
||||
|
||||
override fun pause() {
|
||||
if (mediaPlayer != null) {
|
||||
mediaPlayer!!.pause()
|
||||
}
|
||||
}
|
||||
|
||||
override fun getVideoWidth(): Int {
|
||||
return if (mediaPlayer != null) {
|
||||
mediaPlayer!!.videoWidth
|
||||
} else 0
|
||||
}
|
||||
|
||||
override fun getVideoHeight(): Int {
|
||||
return if (mediaPlayer != null) {
|
||||
mediaPlayer!!.videoHeight
|
||||
} else 0
|
||||
}
|
||||
|
||||
override fun isPlaying(): Boolean {
|
||||
return if (mediaPlayer != null) {
|
||||
mediaPlayer!!.isPlaying
|
||||
} else false
|
||||
}
|
||||
|
||||
override fun seekTo(time: Long) {
|
||||
if (mediaPlayer != null) {
|
||||
mediaPlayer!!.seekTo(time)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getCurrentPosition(): Long {
|
||||
return if (mediaPlayer != null) {
|
||||
mediaPlayer!!.currentPosition
|
||||
} else 0
|
||||
}
|
||||
|
||||
override fun getDuration(): Long {
|
||||
return if (mediaPlayer != null) {
|
||||
mediaPlayer!!.duration
|
||||
} else 0
|
||||
}
|
||||
|
||||
override fun getVideoSarNum(): Int {
|
||||
return if (mediaPlayer != null) {
|
||||
mediaPlayer!!.videoSarNum
|
||||
} else 1
|
||||
}
|
||||
|
||||
override fun getVideoSarDen(): Int {
|
||||
return if (mediaPlayer != null) {
|
||||
mediaPlayer!!.videoSarDen
|
||||
} else 1
|
||||
}
|
||||
|
||||
override fun isSurfaceSupportLockCanvas(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置seek的临近帧。
|
||||
*/
|
||||
fun setSeekParameter(seekParameters: SeekParameters?) {
|
||||
if (mediaPlayer != null) {
|
||||
mediaPlayer!!.setSeekParameter(seekParameters)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun getNetSpeed(context: Context?): Long {
|
||||
if (context == null) {
|
||||
return 0
|
||||
}
|
||||
val nowTotalRxBytes =
|
||||
if (TrafficStats.getUidRxBytes(context.applicationInfo.uid) == TrafficStats.UNSUPPORTED.toLong()) 0 else TrafficStats.getTotalRxBytes() / 1024 //转为KB
|
||||
val nowTimeStamp = System.currentTimeMillis()
|
||||
val calculationTime = nowTimeStamp - lastTimeStamp
|
||||
if (calculationTime == 0L) {
|
||||
return calculationTime
|
||||
}
|
||||
//毫秒转换
|
||||
val speed = (nowTotalRxBytes - lastTotalRxBytes) * 1000 / calculationTime
|
||||
lastTimeStamp = nowTimeStamp
|
||||
lastTotalRxBytes = nowTotalRxBytes
|
||||
return speed
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
package com.gh.common.video
|
||||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import com.shuyu.gsyvideoplayer.cache.ICacheManager
|
||||
import com.shuyu.gsyvideoplayer.cache.ICacheManager.ICacheAvailableListener
|
||||
import tv.danmaku.ijk.media.exo2.ExoSourceManager
|
||||
import tv.danmaku.ijk.media.player.IMediaPlayer
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* 基于ExoPlayerCacheManager修改,规避使用CustomExo2PlayerManager时的异常抛出
|
||||
*/
|
||||
class CustomExoPlayerCacheManager : ICacheManager {
|
||||
|
||||
protected var mExoSourceManager: ExoSourceManager? = null
|
||||
override fun doCacheLogic(
|
||||
context: Context,
|
||||
mediaPlayer: IMediaPlayer,
|
||||
url: String,
|
||||
header: Map<String, String>,
|
||||
cachePath: File?
|
||||
) {
|
||||
if (mediaPlayer !is CustomIjkExo2MediaPlayer) {
|
||||
throw UnsupportedOperationException("CustomExoPlayCacheManager only support CustomIjkExo2MediaPlayer")
|
||||
}
|
||||
mExoSourceManager = mediaPlayer.exoHelper
|
||||
//通过自己的内部缓存机制
|
||||
mediaPlayer.isCache = true
|
||||
mediaPlayer.cacheDir = cachePath
|
||||
mediaPlayer.setDataSource(context, Uri.parse(url), header)
|
||||
}
|
||||
|
||||
override fun clearCache(context: Context, cachePath: File, url: String) {
|
||||
ExoSourceManager.clearCache(context, cachePath, url)
|
||||
}
|
||||
|
||||
override fun release() {
|
||||
mExoSourceManager = null
|
||||
}
|
||||
|
||||
override fun hadCached(): Boolean {
|
||||
return mExoSourceManager != null && mExoSourceManager?.hadCached() == true
|
||||
}
|
||||
|
||||
override fun cachePreview(context: Context, cacheDir: File?, url: String): Boolean {
|
||||
return ExoSourceManager.cachePreView(context, cacheDir, url)
|
||||
}
|
||||
|
||||
override fun setCacheAvailableListener(cacheAvailableListener: ICacheAvailableListener) {}
|
||||
}
|
||||
@ -0,0 +1,558 @@
|
||||
package com.gh.common.video
|
||||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.os.Looper
|
||||
import android.view.Surface
|
||||
import android.view.SurfaceHolder
|
||||
import androidx.annotation.Size
|
||||
import com.google.android.exoplayer2.*
|
||||
import com.google.android.exoplayer2.DefaultRenderersFactory.ExtensionRendererMode
|
||||
import com.google.android.exoplayer2.analytics.AnalyticsListener
|
||||
import com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime
|
||||
import com.google.android.exoplayer2.decoder.DecoderCounters
|
||||
import com.google.android.exoplayer2.metadata.Metadata
|
||||
import com.google.android.exoplayer2.source.DefaultMediaSourceFactory
|
||||
import com.google.android.exoplayer2.source.MediaSource
|
||||
import com.google.android.exoplayer2.source.TrackGroupArray
|
||||
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector
|
||||
import com.google.android.exoplayer2.trackselection.MappingTrackSelector
|
||||
import com.google.android.exoplayer2.trackselection.TrackSelectionArray
|
||||
import tv.danmaku.ijk.media.exo2.ExoSourceManager
|
||||
import tv.danmaku.ijk.media.exo2.demo.EventLogger
|
||||
import tv.danmaku.ijk.media.player.AbstractMediaPlayer
|
||||
import tv.danmaku.ijk.media.player.MediaInfo
|
||||
import tv.danmaku.ijk.media.player.misc.IjkTrackInfo
|
||||
import java.io.File
|
||||
import java.io.FileDescriptor
|
||||
|
||||
/**
|
||||
* 基于IjkExo2MediaPlayer修改,实现列表视频播放的适配,主要做了如下改动:
|
||||
* 1. 复用SimpleExoPlayer的实例,避免在列表中使用时造成的卡顿
|
||||
* 2. 新增updateAppContext方法,提供切换上下文环境的入口
|
||||
* 3. 移除prepareAsync的Handler调用机制,避免频繁调用造成的队列拥堵问题
|
||||
*/
|
||||
class CustomIjkExo2MediaPlayer : AbstractMediaPlayer(), Player.EventListener, AnalyticsListener {
|
||||
|
||||
private var _appContext: Context? = null
|
||||
private var internalPlayer: SimpleExoPlayer? = null
|
||||
private var eventLogger: EventLogger? = null
|
||||
private var rendererFactory: DefaultRenderersFactory? = null
|
||||
private var mediaSource: MediaSource? = null
|
||||
private var trackSelector: MappingTrackSelector? = null
|
||||
private var loadControl: LoadControl? = null
|
||||
private var dataSource: String? = null
|
||||
private var surface: Surface? = null
|
||||
private var headers: MutableMap<String, String> = HashMap()
|
||||
private var speedPlaybackParameters: PlaybackParameters? = null
|
||||
private var videoWidth = 0
|
||||
private var videoHeight = 0
|
||||
private var lastReportedPlaybackState = 0
|
||||
private var isLastReportedPlayWhenReady = false
|
||||
private var isPreparing = true
|
||||
private var isBuffering = false
|
||||
private var isLooping = false
|
||||
|
||||
/**
|
||||
* 是否带上header
|
||||
*/
|
||||
var isPreview = false
|
||||
|
||||
/**
|
||||
* 是否开启缓存
|
||||
*/
|
||||
var isCache: Boolean = false
|
||||
|
||||
/**
|
||||
* dataSource等的帮组类
|
||||
*/
|
||||
private var _exoHelper: ExoSourceManager? = null
|
||||
|
||||
/**
|
||||
* 缓存目录,可以为空
|
||||
*/
|
||||
var cacheDir: File? = null
|
||||
|
||||
/**
|
||||
* 类型覆盖
|
||||
*/
|
||||
var overrideExtension: String? = null
|
||||
|
||||
private var audioSessionId = C.AUDIO_SESSION_ID_UNSET
|
||||
|
||||
val appContext: Context? get() = _appContext
|
||||
|
||||
val exoHelper: ExoSourceManager? get() = _exoHelper
|
||||
|
||||
fun updateAppContext(context: Context) {
|
||||
val appContext = context.applicationContext.apply {
|
||||
_appContext = this
|
||||
}
|
||||
resetFlags()
|
||||
_exoHelper = ExoSourceManager.newInstance(context, headers)
|
||||
val trackSelector = DefaultTrackSelector(appContext).also {
|
||||
trackSelector = it
|
||||
}
|
||||
val eventLogger = EventLogger(trackSelector).also {
|
||||
eventLogger = it
|
||||
}
|
||||
val preferExtensionDecoders = true
|
||||
val useExtensionRenderers = true //是否开启扩展
|
||||
@ExtensionRendererMode val extensionRendererMode =
|
||||
if (useExtensionRenderers) (if (preferExtensionDecoders) DefaultRenderersFactory.EXTENSION_RENDERER_MODE_PREFER else DefaultRenderersFactory.EXTENSION_RENDERER_MODE_ON) else DefaultRenderersFactory.EXTENSION_RENDERER_MODE_OFF
|
||||
val rendererFactory = DefaultRenderersFactory(appContext!!).also {
|
||||
it.setExtensionRendererMode(extensionRendererMode)
|
||||
rendererFactory = it
|
||||
}
|
||||
val loadControl = DefaultLoadControl().also {
|
||||
loadControl = it
|
||||
}
|
||||
internalPlayer = SimpleExoPlayer.Builder(appContext, rendererFactory)
|
||||
.setLooper(Looper.myLooper()!!)
|
||||
.setTrackSelector(trackSelector)
|
||||
.setLoadControl(loadControl)
|
||||
.build()
|
||||
.also {
|
||||
it.addListener(this)
|
||||
it.addAnalyticsListener(this)
|
||||
it.addListener(eventLogger)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getVideoRendererIndex(): Int {
|
||||
if (internalPlayer != null) {
|
||||
for (i in 0 until internalPlayer!!.rendererCount) {
|
||||
if (internalPlayer!!.getRendererType(i) == C.TRACK_TYPE_VIDEO) {
|
||||
return i
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
override fun setDisplay(sh: SurfaceHolder?) {
|
||||
if (sh == null) setSurface(null) else setSurface(sh.surface)
|
||||
}
|
||||
|
||||
override fun setSurface(surface: Surface?) {
|
||||
internalPlayer?.setVideoSurface(surface)
|
||||
?: let {
|
||||
this.surface = surface
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun setDataSource(context: Context?, uri: Uri, headers: Map<String, String>?) {
|
||||
if (headers != null) {
|
||||
this.headers.clear()
|
||||
this.headers.putAll(headers)
|
||||
}
|
||||
setDataSource(context, uri)
|
||||
}
|
||||
|
||||
override fun setDataSource(path: String?) {
|
||||
setDataSource(appContext, Uri.parse(path))
|
||||
}
|
||||
|
||||
override fun setDataSource(context: Context?, uri: Uri) {
|
||||
dataSource = uri.toString()
|
||||
// mediaSource = exoHelper?.getMediaSource(dataSource, isPreview, isCache, isLooping, cacheDir, overrideExtension)
|
||||
mediaSource = DefaultMediaSourceFactory(context!!).createMediaSource(MediaItem.fromUri(uri))
|
||||
}
|
||||
|
||||
override fun setDataSource(fd: FileDescriptor?) {
|
||||
throw UnsupportedOperationException("no support")
|
||||
}
|
||||
|
||||
override fun getDataSource(): String? {
|
||||
return dataSource
|
||||
}
|
||||
|
||||
@Throws(IllegalStateException::class)
|
||||
override fun prepareAsync() {
|
||||
|
||||
internalPlayer?.let {
|
||||
it.setPlaybackParameters(speedPlaybackParameters)
|
||||
if (surface != null) {
|
||||
it.setVideoSurface(surface)
|
||||
surface = null
|
||||
}
|
||||
mediaSource?.apply {
|
||||
it.setMediaSource(this)
|
||||
}
|
||||
it.prepare()
|
||||
it.playWhenReady = false
|
||||
}
|
||||
}
|
||||
|
||||
@Throws(IllegalStateException::class)
|
||||
override fun start() {
|
||||
internalPlayer?.play()
|
||||
}
|
||||
|
||||
@Throws(IllegalStateException::class)
|
||||
override fun stop() {
|
||||
resetFlags()
|
||||
internalPlayer?.clearMediaItems()
|
||||
internalPlayer?.stop()
|
||||
}
|
||||
|
||||
private fun resetFlags() {
|
||||
isPreparing = true
|
||||
isBuffering = false
|
||||
lastReportedPlaybackState = Player.STATE_IDLE
|
||||
isLastReportedPlayWhenReady = false
|
||||
}
|
||||
|
||||
@Throws(IllegalStateException::class)
|
||||
override fun pause() {
|
||||
internalPlayer?.pause()
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun setWakeMode(context: Context?, mode: Int) {
|
||||
// FIXME: implement
|
||||
}
|
||||
|
||||
override fun setScreenOnWhilePlaying(screenOn: Boolean) {
|
||||
// TODO: do nothing
|
||||
}
|
||||
|
||||
override fun getTrackInfo(): Array<IjkTrackInfo?>? {
|
||||
// TODO: implement
|
||||
return null
|
||||
}
|
||||
|
||||
override fun getVideoWidth(): Int {
|
||||
return videoWidth
|
||||
}
|
||||
|
||||
override fun getVideoHeight(): Int {
|
||||
return videoHeight
|
||||
}
|
||||
|
||||
override fun isPlaying(): Boolean {
|
||||
val state = internalPlayer?.playbackState ?: return false
|
||||
return when (state) {
|
||||
Player.STATE_BUFFERING, Player.STATE_READY -> internalPlayer!!.playWhenReady
|
||||
Player.STATE_IDLE, Player.STATE_ENDED -> false
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
@Throws(IllegalStateException::class)
|
||||
override fun seekTo(msec: Long) {
|
||||
internalPlayer?.seekTo(msec)
|
||||
}
|
||||
|
||||
override fun getCurrentPosition(): Long {
|
||||
return internalPlayer?.currentPosition ?: 0
|
||||
}
|
||||
|
||||
override fun getDuration(): Long {
|
||||
return internalPlayer?.duration ?: 0
|
||||
}
|
||||
|
||||
override fun getVideoSarNum(): Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
override fun getVideoSarDen(): Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
override fun reset() {
|
||||
internalPlayer?.release()
|
||||
internalPlayer = null
|
||||
|
||||
exoHelper?.release()
|
||||
|
||||
surface = null
|
||||
dataSource = null
|
||||
videoWidth = 0
|
||||
videoHeight = 0
|
||||
}
|
||||
|
||||
override fun setLooping(looping: Boolean) {
|
||||
isLooping = looping
|
||||
}
|
||||
|
||||
override fun isLooping(): Boolean {
|
||||
return isLooping
|
||||
}
|
||||
|
||||
override fun setVolume(leftVolume: Float, rightVolume: Float) {
|
||||
internalPlayer?.volume = (leftVolume + rightVolume) / 2
|
||||
}
|
||||
|
||||
override fun getAudioSessionId(): Int {
|
||||
return audioSessionId
|
||||
}
|
||||
|
||||
override fun getMediaInfo(): MediaInfo? {
|
||||
return null
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun setLogEnabled(enable: Boolean) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated in Java", ReplaceWith("true"))
|
||||
override fun isPlayable(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun setAudioStreamType(streamtype: Int) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun setKeepInBackground(keepInBackground: Boolean) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
override fun release() {
|
||||
if (internalPlayer != null) {
|
||||
reset()
|
||||
eventLogger = null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置seek 的临近帧。
|
||||
*/
|
||||
fun setSeekParameter(seekParameters: SeekParameters?) {
|
||||
internalPlayer?.setSeekParameters(seekParameters)
|
||||
}
|
||||
|
||||
fun getMediaSource(): MediaSource? {
|
||||
return mediaSource
|
||||
}
|
||||
|
||||
fun setMediaSource(mediaSource: MediaSource?) {
|
||||
this.mediaSource = mediaSource
|
||||
}
|
||||
|
||||
/**
|
||||
* 倍速播放
|
||||
*
|
||||
* @param speed 倍速播放,默认为1
|
||||
* @param pitch 音量缩放,默认为1,修改会导致声音变调
|
||||
*/
|
||||
fun setSpeed(@Size(min = 0) speed: Float, @Size(min = 0) pitch: Float) {
|
||||
val playbackParameters = PlaybackParameters(speed, pitch)
|
||||
speedPlaybackParameters = playbackParameters
|
||||
internalPlayer?.setPlaybackParameters(playbackParameters)
|
||||
}
|
||||
|
||||
fun getSpeed(): Float {
|
||||
return internalPlayer?.playbackParameters?.speed ?: 0F
|
||||
}
|
||||
|
||||
val bufferedPercentage: Int get() = internalPlayer?.bufferedPercentage ?: 0
|
||||
|
||||
|
||||
fun getTrackSelector(): MappingTrackSelector? {
|
||||
return trackSelector
|
||||
}
|
||||
|
||||
fun setTrackSelector(trackSelector: MappingTrackSelector?) {
|
||||
this.trackSelector = trackSelector
|
||||
}
|
||||
|
||||
fun getLoadControl(): LoadControl? {
|
||||
return loadControl
|
||||
}
|
||||
|
||||
fun setLoadControl(loadControl: LoadControl?) {
|
||||
this.loadControl = loadControl
|
||||
}
|
||||
|
||||
fun getRendererFactory(): DefaultRenderersFactory? {
|
||||
return rendererFactory
|
||||
}
|
||||
|
||||
fun setRendererFactory(rendererFactory: DefaultRenderersFactory?) {
|
||||
this.rendererFactory = rendererFactory
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun onTimelineChanged(timeline: Timeline, manifest: Any?, reason: Int) {
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun onPlayerStateChanged(playWhenReady: Boolean, playbackState: Int) {
|
||||
//重新播放状态顺序为:STATE_IDLE -》STATE_BUFFERING -》STATE_READY
|
||||
//缓冲时顺序为:STATE_BUFFERING -》STATE_READY
|
||||
// Log.e("CustomIjkExo2Player",
|
||||
// "onPlayerStateChanged: playWhenReady = $playWhenReady, playbackState = $playbackState"
|
||||
// )
|
||||
if (isLastReportedPlayWhenReady != playWhenReady || lastReportedPlaybackState != playbackState) {
|
||||
var buffer = 0
|
||||
if (internalPlayer != null) {
|
||||
buffer = internalPlayer!!.bufferedPercentage
|
||||
}
|
||||
if (isBuffering) {
|
||||
when (playbackState) {
|
||||
Player.STATE_ENDED, Player.STATE_READY -> {
|
||||
notifyOnInfo(MEDIA_INFO_BUFFERING_END, buffer)
|
||||
isBuffering = false
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
if (isPreparing) {
|
||||
when (playbackState) {
|
||||
Player.STATE_READY -> {
|
||||
notifyOnPrepared()
|
||||
isPreparing = false
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
when (playbackState) {
|
||||
Player.STATE_BUFFERING -> {
|
||||
notifyOnInfo(MEDIA_INFO_BUFFERING_START, buffer)
|
||||
isBuffering = true
|
||||
}
|
||||
|
||||
Player.STATE_READY -> {}
|
||||
Player.STATE_ENDED -> notifyOnCompletion()
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
isLastReportedPlayWhenReady = playWhenReady
|
||||
lastReportedPlaybackState = playbackState
|
||||
}
|
||||
|
||||
override fun onRepeatModeChanged(repeatMode: Int) {}
|
||||
|
||||
override fun onShuffleModeEnabledChanged(shuffleModeEnabled: Boolean) {}
|
||||
|
||||
override fun onPlayerError(error: ExoPlaybackException) {
|
||||
notifyOnError(MEDIA_ERROR_UNKNOWN, MEDIA_ERROR_UNKNOWN)
|
||||
}
|
||||
|
||||
override fun onPositionDiscontinuity(reason: Int) {}
|
||||
|
||||
override fun onPlaybackParametersChanged(playbackParameters: PlaybackParameters) {}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun onPlayerStateChanged(eventTime: EventTime, playWhenReady: Boolean, playbackState: Int) {
|
||||
}
|
||||
|
||||
override fun onTimelineChanged(eventTime: EventTime, reason: Int) {}
|
||||
|
||||
override fun onPositionDiscontinuity(eventTime: EventTime, reason: Int) {
|
||||
notifyOnInfo(ON_POSITION_DISCOUNTINUITY, reason)
|
||||
}
|
||||
|
||||
override fun onSeekStarted(eventTime: EventTime) {}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun onSeekProcessed(eventTime: EventTime) {
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated in Java", ReplaceWith("notifyOnSeekComplete()"))
|
||||
override fun onSeekProcessed() {
|
||||
notifyOnSeekComplete()
|
||||
}
|
||||
|
||||
override fun onPlaybackParametersChanged(eventTime: EventTime, playbackParameters: PlaybackParameters) {}
|
||||
|
||||
override fun onRepeatModeChanged(eventTime: EventTime, repeatMode: Int) {}
|
||||
|
||||
override fun onShuffleModeChanged(eventTime: EventTime, shuffleModeEnabled: Boolean) {}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun onLoadingChanged(eventTime: EventTime, isLoading: Boolean) {
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun onLoadingChanged(isLoading: Boolean) {
|
||||
}
|
||||
|
||||
override fun onPlayerError(eventTime: EventTime, error: ExoPlaybackException) {}
|
||||
|
||||
override fun onTracksChanged(
|
||||
eventTime: EventTime,
|
||||
trackGroups: TrackGroupArray,
|
||||
trackSelections: TrackSelectionArray
|
||||
) {
|
||||
}
|
||||
|
||||
override fun onTracksChanged(trackGroups: TrackGroupArray, trackSelections: TrackSelectionArray) {}
|
||||
|
||||
override fun onBandwidthEstimate(
|
||||
eventTime: EventTime,
|
||||
totalLoadTimeMs: Int,
|
||||
totalBytesLoaded: Long,
|
||||
bitrateEstimate: Long
|
||||
) {
|
||||
}
|
||||
|
||||
override fun onMetadata(eventTime: EventTime, metadata: Metadata) {}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun onDecoderEnabled(eventTime: EventTime, trackType: Int, decoderCounters: DecoderCounters) {
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun onDecoderInitialized(
|
||||
eventTime: EventTime,
|
||||
trackType: Int,
|
||||
decoderName: String,
|
||||
initializationDurationMs: Long
|
||||
) {
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun onDecoderInputFormatChanged(eventTime: EventTime, trackType: Int, format: Format) {
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun onDecoderDisabled(eventTime: EventTime, trackType: Int, decoderCounters: DecoderCounters) {
|
||||
audioSessionId = C.AUDIO_SESSION_ID_UNSET
|
||||
}
|
||||
|
||||
override fun onAudioUnderrun(
|
||||
eventTime: EventTime,
|
||||
bufferSize: Int,
|
||||
bufferSizeMs: Long,
|
||||
elapsedSinceLastFeedMs: Long
|
||||
) {
|
||||
}
|
||||
|
||||
override fun onDroppedVideoFrames(eventTime: EventTime, droppedFrames: Int, elapsedMs: Long) {}
|
||||
|
||||
override fun onVideoSizeChanged(
|
||||
eventTime: EventTime,
|
||||
width: Int,
|
||||
height: Int,
|
||||
unappliedRotationDegrees: Int,
|
||||
pixelWidthHeightRatio: Float
|
||||
) {
|
||||
videoWidth = (width * pixelWidthHeightRatio).toInt()
|
||||
videoHeight = height
|
||||
notifyOnVideoSizeChanged((width * pixelWidthHeightRatio).toInt(), height, 1, 1)
|
||||
if (unappliedRotationDegrees > 0) notifyOnInfo(MEDIA_INFO_VIDEO_ROTATION_CHANGED, unappliedRotationDegrees)
|
||||
}
|
||||
|
||||
override fun onRenderedFirstFrame(eventTime: EventTime, surface: Surface?) {}
|
||||
|
||||
override fun onDrmKeysLoaded(eventTime: EventTime) {}
|
||||
|
||||
override fun onDrmSessionManagerError(eventTime: EventTime, error: Exception) {}
|
||||
|
||||
override fun onDrmKeysRestored(eventTime: EventTime) {}
|
||||
|
||||
override fun onDrmKeysRemoved(eventTime: EventTime) {}
|
||||
|
||||
companion object {
|
||||
|
||||
const val ON_POSITION_DISCOUNTINUITY = 2702
|
||||
}
|
||||
}
|
||||
@ -95,7 +95,7 @@ class CatalogFilterView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
private fun showSelectTypePopupWindow(containerView: View, typeTv: TextView, typeText: String) {
|
||||
typeTv.setTextColor(R.color.theme_font.toColor(context))
|
||||
typeTv.setTextColor(R.color.text_theme.toColor(context))
|
||||
typeTv.setDrawableEnd(R.drawable.ic_filter_arrow_up)
|
||||
|
||||
val inflater = LayoutInflater.from(typeTv.context)
|
||||
@ -152,7 +152,7 @@ class CatalogFilterView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
private fun showSelectCatalogPopupWindow(containerView: View, catalogTv: TextView, catalogText: String) {
|
||||
catalogTv.setTextColor(R.color.theme_font.toColor(context))
|
||||
catalogTv.setTextColor(R.color.text_theme.toColor(context))
|
||||
catalogTv.setDrawableEnd(R.drawable.ic_filter_arrow_up)
|
||||
|
||||
val inflater = LayoutInflater.from(catalogTv.context)
|
||||
@ -211,7 +211,7 @@ class CatalogFilterView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
private fun showSelectSizePopupWindow(containerView: View, sizeTv: TextView, sizeText: String) {
|
||||
sizeTv.setTextColor(R.color.theme_font.toColor(context))
|
||||
sizeTv.setTextColor(R.color.text_theme.toColor(context))
|
||||
sizeTv.setDrawableEnd(R.drawable.ic_filter_arrow_up)
|
||||
|
||||
val inflater = LayoutInflater.from(sizeTv.context)
|
||||
|
||||
@ -90,7 +90,7 @@ class CategoryFilterView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
private fun showSelectTypePopupWindow(containerView: View, typeTv: TextView, typeText: String) {
|
||||
typeTv.setTextColor(R.color.theme_font.toColor(context))
|
||||
typeTv.setTextColor(R.color.text_theme.toColor(context))
|
||||
typeTv.setDrawableEnd(R.drawable.ic_filter_arrow_up)
|
||||
|
||||
val inflater = LayoutInflater.from(typeTv.context)
|
||||
@ -148,7 +148,7 @@ class CategoryFilterView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
private fun showSelectSizePopupWindow(containerView: View, sizeTv: TextView, sizeText: String) {
|
||||
sizeTv.setTextColor(R.color.theme_font.toColor(context))
|
||||
sizeTv.setTextColor(R.color.text_theme.toColor(context))
|
||||
sizeTv.setDrawableEnd(R.drawable.ic_filter_arrow_up)
|
||||
|
||||
val inflater = LayoutInflater.from(sizeTv.context)
|
||||
|
||||
@ -112,7 +112,7 @@ class ConfigFilterView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
private fun showSelectionPopupWindow(containerView: View, sizeTv: TextView, sizeText: String) {
|
||||
sizeTv.setTextColor(R.color.theme_font.toColor(sizeTv.context))
|
||||
sizeTv.setTextColor(R.color.text_theme.toColor(sizeTv.context))
|
||||
sizeTv.setDrawableEnd(R.drawable.ic_filter_arrow_up)
|
||||
|
||||
val inflater = LayoutInflater.from(sizeTv.context)
|
||||
|
||||
@ -97,7 +97,7 @@ public class DownloadProgressBar extends ProgressBar {
|
||||
super.onDraw(canvas);
|
||||
if (TextUtils.isEmpty(mText)) return;
|
||||
|
||||
mPaint.setColor(mDefaultColor == 0 ? ContextCompat.getColor(getContext(), R.color.theme_font) : mDefaultColor); // 初始化颜色
|
||||
mPaint.setColor(mDefaultColor == 0 ? ContextCompat.getColor(getContext(), R.color.text_theme) : mDefaultColor); // 初始化颜色
|
||||
mPaint.setTextSize(mTextSize);
|
||||
mFakeTextPaint.setTextSize(mTextSize);
|
||||
mFakeTextPaint.setStyle(Paint.Style.FILL_AND_STROKE);
|
||||
@ -187,7 +187,7 @@ public class DownloadProgressBar extends ProgressBar {
|
||||
break;
|
||||
case NONE:
|
||||
setProgressDrawable(getResources().getDrawable(R.drawable.button_round_gray_light));
|
||||
mDefaultColor = ContextCompat.getColor(getContext(), R.color.text_subtitleDesc);
|
||||
mDefaultColor = ContextCompat.getColor(getContext(), R.color.text_tertiary);
|
||||
setProgress(0);
|
||||
break;
|
||||
case LAUNCH_OR_OPEN:
|
||||
@ -206,12 +206,12 @@ public class DownloadProgressBar extends ProgressBar {
|
||||
mDefaultColor = Color.WHITE;
|
||||
} else {
|
||||
setProgressDrawable(getResources().getDrawable(R.drawable.detail_downloading_normal_style));
|
||||
mDefaultColor = ContextCompat.getColor(getContext(), R.color.theme_font);
|
||||
mDefaultColor = ContextCompat.getColor(getContext(), R.color.text_theme);
|
||||
}
|
||||
break;
|
||||
case DOWNLOADING_PLUGIN:
|
||||
setProgressDrawable(getResources().getDrawable(R.drawable.detail_downloading_normal_style));
|
||||
mDefaultColor = ContextCompat.getColor(getContext(), R.color.theme_font);
|
||||
mDefaultColor = ContextCompat.getColor(getContext(), R.color.text_theme);
|
||||
break;
|
||||
case RESERVABLE:
|
||||
setProgressDrawable(getResources().getDrawable(R.drawable.button_reserve));
|
||||
@ -223,7 +223,7 @@ public class DownloadProgressBar extends ProgressBar {
|
||||
break;
|
||||
case RESERVED:
|
||||
setProgressDrawable(getResources().getDrawable(R.drawable.button_round_gray_light));
|
||||
mDefaultColor = ContextCompat.getColor(getContext(), R.color.text_subtitleDesc);
|
||||
mDefaultColor = ContextCompat.getColor(getContext(), R.color.text_tertiary);
|
||||
break;
|
||||
case XAPK_FAILURE:
|
||||
case XAPK_SUCCESS:
|
||||
|
||||
@ -86,7 +86,7 @@ class FilterView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
||||
mSelectedSubFilter = filter
|
||||
mBinding?.subFilterTv?.text = filter
|
||||
if (filter != mSubFilterList.firstOrNull() && mHighlightSubFilterIfItsNotDefault) {
|
||||
mBinding?.subFilterTv?.setTextColor(R.color.theme_font.toColor(context))
|
||||
mBinding?.subFilterTv?.setTextColor(R.color.text_theme.toColor(context))
|
||||
} else {
|
||||
mBinding?.subFilterTv?.setTextColor(R.color.text_757575.toColor(context))
|
||||
}
|
||||
@ -108,7 +108,7 @@ class FilterView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
||||
subFilterText: String,
|
||||
selectedCallback: ((String) -> Unit)
|
||||
) {
|
||||
subFilterTv.setTextColor(R.color.theme_font.toColor(context))
|
||||
subFilterTv.setTextColor(R.color.text_theme.toColor(context))
|
||||
subFilterTv.setDrawableEnd(R.drawable.ic_filter_arrow_up)
|
||||
|
||||
val inflater = LayoutInflater.from(subFilterTv.context)
|
||||
@ -215,7 +215,7 @@ class FilterView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
||||
holder.binding.titleTv.background = R.drawable.bg_tag_text.toDrawable(context)
|
||||
holder.binding.titleTv.setTextColor(R.color.white.toColor(context))
|
||||
} else {
|
||||
holder.binding.titleTv.setBackgroundColor(R.color.background_white.toColor(context))
|
||||
holder.binding.titleTv.setBackgroundColor(R.color.ui_surface.toColor(context))
|
||||
holder.binding.titleTv.setTextColor(R.color.text_777777.toColor(context))
|
||||
}
|
||||
|
||||
|
||||
@ -91,7 +91,7 @@ class FlexLinearLayout @JvmOverloads constructor(context: Context, attrs: Attrib
|
||||
val params = LayoutParams(mLastItemWidth, mItemHeight)
|
||||
layoutParams = params
|
||||
setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_game_detail_label_more))
|
||||
if (DarkModeUtils.isDarkModeOn(context)) setColorFilter(R.color.text_title.toColor(context))
|
||||
if (DarkModeUtils.isDarkModeOn(context)) setColorFilter(R.color.text_primary.toColor(context))
|
||||
background = createNormalBackgroundDrawable()
|
||||
scaleType = ImageView.ScaleType.CENTER
|
||||
}
|
||||
@ -114,7 +114,7 @@ class FlexLinearLayout @JvmOverloads constructor(context: Context, attrs: Attrib
|
||||
setPadding(mPadding, 0, mPadding, 0)
|
||||
layoutParams = params
|
||||
|
||||
setTextColor(if (tag.isTop) "#${tag.color}".hexStringToIntColor() else R.color.text_title.toColor(context))
|
||||
setTextColor(if (tag.isTop) "#${tag.color}".hexStringToIntColor() else R.color.text_primary.toColor(context))
|
||||
background = if (tag.isTop) createTopBackgroundDrawable(tag) else createNormalBackgroundDrawable()
|
||||
setOnClickListener {
|
||||
onClickListener?.onItemClickListener(tag, position)
|
||||
|
||||
@ -80,7 +80,7 @@ class GameTagFlexLinearLayout @JvmOverloads constructor(context: Context, attrs:
|
||||
includeFontPadding = false
|
||||
textSize = mTextSize
|
||||
gravity = Gravity.CENTER
|
||||
setTextColor(R.color.text_subtitleDesc.toColor(context))
|
||||
setTextColor(R.color.text_tertiary.toColor(context))
|
||||
|
||||
val params = LayoutParams(LayoutParams.WRAP_CONTENT, mItemHeight)
|
||||
params.setMargins(0, 0, mMargin, 0)
|
||||
|
||||
@ -44,7 +44,12 @@ object DownloadDataHelper {
|
||||
return if (status == DownloadStatus.add) {
|
||||
"开始下载"
|
||||
} else if (status == DownloadStatus.pause) {
|
||||
"暂停下载"
|
||||
val pauseExtraString = downloadEntity.getMetaExtra(Constants.DOWNLOAD_PAUSE_EXTRA)
|
||||
if (pauseExtraString.isEmpty()) {
|
||||
"暂停下载"
|
||||
} else {
|
||||
"暂停下载-$pauseExtraString"
|
||||
}
|
||||
} else if (status == DownloadStatus.resume) {
|
||||
if (downloadEntity.meta[DOWNLOAD_RESUME_WAY] == DOWNLOAD_RESUME_AUTO) {
|
||||
"自动恢复下载"
|
||||
@ -95,6 +100,8 @@ object DownloadDataHelper {
|
||||
"网络异常"
|
||||
} else if (status == DownloadStatus.redirected) {
|
||||
"重定向至最终地址"
|
||||
} else if (status == DownloadStatus.resourceUnavailable) {
|
||||
"资源不可用"
|
||||
} else {
|
||||
"未知状态"
|
||||
}
|
||||
|
||||
@ -870,6 +870,8 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
NDownloadBridge.INSTANCE.cancel(url);
|
||||
|
||||
mDownloadDao.delete(url);
|
||||
// 避免非原子操作导致 snapshot 和 record 不一致,这里尝试清理 snapshot 的数据
|
||||
mDownloadDao.update(entry, true);
|
||||
|
||||
if (isDeleteFile) {
|
||||
FileUtils.deleteFile(entry.getPath());
|
||||
|
||||
@ -125,11 +125,11 @@ class DownloadDialogAdapter(
|
||||
rightLink.text = if (links?.size ?: 0 > 1) links?.get(1)?.title else ""
|
||||
leftLink.background = GradientDrawable().apply {
|
||||
cornerRadius = 8F.dip2px().toFloat()
|
||||
setStroke(0.5F.dip2px(), R.color.divider.toColor(mContext))
|
||||
setStroke(0.5F.dip2px(), R.color.ui_divider.toColor(mContext))
|
||||
}
|
||||
rightLink.background = GradientDrawable().apply {
|
||||
cornerRadius = 8F.dip2px().toFloat()
|
||||
setStroke(0.5F.dip2px(), R.color.divider.toColor(mContext))
|
||||
setStroke(0.5F.dip2px(), R.color.ui_divider.toColor(mContext))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ class DownloadDialogInstalledItemViewHolder(val binding: DownloadDialogInstalled
|
||||
binding.collection.setTextColor(R.color.text_05CBA3.toColor(binding.collection.context))
|
||||
gameEntity.pluginDesc + "此版本"
|
||||
} else {
|
||||
binding.collection.setTextColor(R.color.text_body.toColor(binding.collection.context))
|
||||
binding.collection.setTextColor(R.color.text_instance.toColor(binding.collection.context))
|
||||
"查看合集"
|
||||
}
|
||||
} else "查看详情"
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package com.gh.download.simple
|
||||
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lg.download.*
|
||||
import com.lg.ndownload.DownloadConfig
|
||||
import com.lg.ndownload.DownloadDbManager
|
||||
@ -11,20 +10,9 @@ import java.util.concurrent.Executors
|
||||
|
||||
object SimpleDownloadManager {
|
||||
|
||||
private const val MAX_DOWNLOADING_TASK = 2
|
||||
|
||||
private val mDownloadQueue by lazy { DownloadQueue.getInstance() }
|
||||
private val mExecutor by lazy { Executors.newCachedThreadPool() }
|
||||
|
||||
fun init() {
|
||||
ExecutorProvider.getInstance().backgroundExecutor.execute {
|
||||
DownloadDbManager.init(HaloApp.getInstance())
|
||||
}
|
||||
|
||||
// 设置最大同时下载任务数 (可选)
|
||||
DownloadQueue.getInstance().setMaxDownloadingTask(MAX_DOWNLOADING_TASK)
|
||||
}
|
||||
|
||||
/**
|
||||
* 继续任务
|
||||
*/
|
||||
|
||||
@ -12,7 +12,7 @@ class BbsCertificationActivity : ToolBarActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setNavigationTitle("社区交流身份认证")
|
||||
updateStatusBarColor(R.color.background_white, R.color.background_white)
|
||||
updateStatusBarColor(R.color.ui_surface, R.color.ui_surface)
|
||||
}
|
||||
|
||||
override fun isAutoResetViewBackgroundEnabled() = true
|
||||
|
||||
@ -30,7 +30,7 @@ class BlockActivity : DownloadToolbarActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setToolbarMenu(R.menu.menu_download)
|
||||
updateStatusBarColor(R.color.background_white, R.color.background_white)
|
||||
updateStatusBarColor(R.color.ui_surface, R.color.ui_surface)
|
||||
}
|
||||
|
||||
override fun provideNormalIntent(): Intent {
|
||||
@ -54,6 +54,6 @@ class BlockActivity : DownloadToolbarActivity() {
|
||||
|
||||
override fun onDarkModeChanged() {
|
||||
super.onDarkModeChanged()
|
||||
updateStatusBarColor(R.color.background_white, R.color.background_white)
|
||||
updateStatusBarColor(R.color.ui_surface, R.color.ui_surface)
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ public class CollectionActivity extends ToolBarActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.background_white, R.color.background_white);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.ui_surface, R.color.ui_surface);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -32,7 +32,7 @@ public class CollectionActivity extends ToolBarActivity {
|
||||
@Override
|
||||
protected void onDarkModeChanged() {
|
||||
super.onDarkModeChanged();
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.background_white, R.color.background_white);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.ui_surface, R.color.ui_surface);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
||||
@ -19,7 +19,7 @@ public class ConcernActivity extends ToolBarActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.background_white, R.color.background_white);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.ui_surface, R.color.ui_surface);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -30,7 +30,7 @@ public class ConcernActivity extends ToolBarActivity {
|
||||
@Override
|
||||
protected void onDarkModeChanged() {
|
||||
super.onDarkModeChanged();
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.background_white, R.color.background_white);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.ui_surface, R.color.ui_surface);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
||||
@ -75,7 +75,7 @@ public class CropImageActivity extends ToolBarActivity {
|
||||
setToolbarMenu(R.menu.menu_positive);
|
||||
MenuItem menuItem = getMenuItem(R.id.layout_menu_positive);
|
||||
TextView menuButton = menuItem.getActionView().findViewById(R.id.menu_answer_post);
|
||||
menuButton.setTextColor(getResources().getColor(R.color.theme_font));
|
||||
menuButton.setTextColor(getResources().getColor(R.color.text_theme));
|
||||
|
||||
float ratio = getIntent().getFloatExtra(EntranceConsts.KEY_IMAGE_CROP_RATIO, 1F);
|
||||
mCropImageCustom.setCropRatio(ratio);
|
||||
|
||||
@ -12,7 +12,6 @@ import com.gh.gamecenter.common.base.activity.ToolBarActivity;
|
||||
import com.gh.gamecenter.common.base.fragment.BaseFragment_TabLayout;
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts;
|
||||
import com.gh.gamecenter.common.utils.ExtensionsKt;
|
||||
import com.gh.gamecenter.common.utils.SensorsBridge;
|
||||
import com.gh.gamecenter.download.DownloadFragment;
|
||||
import com.gh.vspace.VHelper;
|
||||
|
||||
@ -33,7 +32,7 @@ public class DownloadManagerActivity extends ToolBarActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.background_white, R.color.background_white);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.ui_surface, R.color.ui_surface);
|
||||
if (VHelper.isVGameOn()) {
|
||||
setToolbarMenu(R.menu.menu_download_manager);
|
||||
}
|
||||
@ -78,7 +77,7 @@ public class DownloadManagerActivity extends ToolBarActivity {
|
||||
@Override
|
||||
protected void onDarkModeChanged() {
|
||||
super.onDarkModeChanged();
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.background_white, R.color.background_white);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.ui_surface, R.color.ui_surface);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -20,7 +20,7 @@ public class InfoActivity extends ToolBarActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.background_white, R.color.background_white);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.ui_surface, R.color.ui_surface);
|
||||
}
|
||||
|
||||
public static Intent getIntent(Context context) {
|
||||
@ -30,7 +30,7 @@ public class InfoActivity extends ToolBarActivity {
|
||||
@Override
|
||||
protected void onDarkModeChanged() {
|
||||
super.onDarkModeChanged();
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.background_white, R.color.background_white);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.ui_surface, R.color.ui_surface);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -23,7 +23,7 @@ public class LibaoActivity extends ToolBarActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.background_white, R.color.background_white);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.ui_surface, R.color.ui_surface);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@ -36,7 +36,7 @@ public class LibaoActivity extends ToolBarActivity {
|
||||
@Override
|
||||
protected void onDarkModeChanged() {
|
||||
super.onDarkModeChanged();
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.background_white, R.color.background_white);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.ui_surface, R.color.ui_surface);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -205,7 +205,7 @@ public class LibaoDetailActivity extends ToolBarActivity implements LibaoDetailA
|
||||
if (mLibaoEntity != null) {
|
||||
mLibaoEntity.setClickReceiveBtnIn(isClickReceiveBtnIn);
|
||||
}
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.background_white, R.color.background_white);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.ui_surface, R.color.ui_surface);
|
||||
mIsScroll = true;
|
||||
|
||||
mSkeleton = Skeleton.bind(mListSkeleton).shimmer(false).load(R.layout.activity_libaodetail_skeleton).show();
|
||||
@ -562,16 +562,18 @@ public class LibaoDetailActivity extends ToolBarActivity implements LibaoDetailA
|
||||
@Override
|
||||
protected void onDarkModeChanged() {
|
||||
super.onDarkModeChanged();
|
||||
ExtensionsKt.setRootBackgroundColor(mContentView, R.color.background);
|
||||
mDetailBottom.setBackgroundColor(ContextCompat.getColor(this, R.color.background));
|
||||
ExtensionsKt.setRootBackgroundColor(mContentView, R.color.ui_background);
|
||||
mDetailBottom.setBackgroundColor(ContextCompat.getColor(this, R.color.ui_background));
|
||||
mLibaoDetailRv.getRecycledViewPool().clear();
|
||||
mAdapter.notifyItemRangeChanged(0, mAdapter.getItemCount());
|
||||
DetailDownloadUtils.updateViewHolder(getDetailViewHolder());
|
||||
if (mGameEntity != null) {
|
||||
DetailDownloadUtils.updateViewHolder(getDetailViewHolder());
|
||||
}
|
||||
if (mLibaoDetailRv.getItemDecorationCount() > 0) {
|
||||
mLibaoDetailRv.removeItemDecorationAt(0);
|
||||
mLibaoDetailRv.addItemDecoration(getItemDecoration());
|
||||
}
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.background_white, R.color.background_white);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.ui_surface, R.color.ui_surface);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -82,11 +82,13 @@ import com.gh.gamecenter.common.retrofit.Response;
|
||||
import com.gh.gamecenter.common.utils.DialogHelper;
|
||||
import com.gh.gamecenter.common.utils.ExtensionsKt;
|
||||
import com.gh.gamecenter.common.utils.NewFlatLogUtils;
|
||||
import com.gh.gamecenter.common.utils.PermissionHelper;
|
||||
import com.gh.gamecenter.common.utils.SensorsBridge;
|
||||
import com.gh.gamecenter.common.utils.ShareUtils;
|
||||
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.EmptyCallback;
|
||||
import com.gh.gamecenter.core.utils.GsonUtils;
|
||||
import com.gh.gamecenter.core.utils.MtaHelper;
|
||||
import com.gh.gamecenter.core.utils.SPUtils;
|
||||
@ -155,8 +157,8 @@ public class MainActivity extends BaseActivity {
|
||||
public static final String SWITCH_TO_VIDEO = "switch_to_video";
|
||||
public static final String SHOW_AD = "show_ad";
|
||||
public static final int COUNTDOWN_AD = 100;
|
||||
private static final int COUNTDOWN_MAX_COUNT = 3;
|
||||
private int countdownCount = 0;
|
||||
public static final int COUNTDOWN_MAX_COUNT = 3;
|
||||
private int mCountdownCount = 0;
|
||||
|
||||
private static final String CURRENT_PAGE = "current_page";
|
||||
|
||||
@ -176,8 +178,8 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
mShouldShowAd = getIntent().getBooleanExtra(SHOW_AD, false) && savedInstanceState == null;
|
||||
|
||||
mShouldShowAd = getIntent().getBooleanExtra(SHOW_AD, false) && savedInstanceState == null
|
||||
&& !HaloApp.getInstance().isAlreadyUpAndRunning;
|
||||
HaloApp.getInstance().isAlreadyUpAndRunning = true;
|
||||
|
||||
mMainWrapperViewModel = new ViewModelProvider(this, new MainWrapperViewModel.Factory(HaloApp.getInstance()))
|
||||
@ -226,6 +228,7 @@ public class MainActivity extends BaseActivity {
|
||||
DataUtils.getGid();
|
||||
}
|
||||
|
||||
|
||||
mPackageViewModel = ViewModelProviders.of(this, new PackageViewModel.Factory()).get(PackageViewModel.class);
|
||||
|
||||
final boolean containsErrorMsg = com.gh.gamecenter.common.constant.Config.isContainsErrorMsg();
|
||||
@ -507,10 +510,10 @@ public class MainActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示开屏广告
|
||||
* 显示冷启动开屏广告
|
||||
*/
|
||||
private void showSplashAd() {
|
||||
if (AdDelegateHelper.INSTANCE.shouldShowStartUpAd()) {
|
||||
if (AdDelegateHelper.INSTANCE.shouldShowStartUpAd(false)) {
|
||||
ViewGroup startAdContainer = findViewById(R.id.startAdContainer);
|
||||
ViewGroup sdkStartAdContainer = findViewById(R.id.sdkStartAdContainer);
|
||||
FrameLayout adsFl = findViewById(R.id.adsFl);
|
||||
@ -522,21 +525,26 @@ public class MainActivity extends BaseActivity {
|
||||
float screenWidthInDp = DisplayUtils.px2dip(this, screenWidthInPx);
|
||||
float screenHeightInDp = DisplayUtils.px2dip(this, screenHeightInPx);
|
||||
|
||||
AdDelegateHelper.requestSplashAd(
|
||||
this,
|
||||
screenWidthInPx,
|
||||
screenHeightInPx,
|
||||
screenWidthInDp,
|
||||
screenHeightInDp,
|
||||
startAdContainer,
|
||||
sdkStartAdContainer,
|
||||
adsFl,
|
||||
(BaseHandler) mBaseHandler,
|
||||
() -> {
|
||||
hideSplashAd();
|
||||
return null;
|
||||
}
|
||||
);
|
||||
if (startAdContainer != null && sdkStartAdContainer != null && adsFl != null) {
|
||||
AdDelegateHelper.requestSplashAd(
|
||||
this,
|
||||
screenWidthInPx,
|
||||
screenHeightInPx,
|
||||
screenWidthInDp,
|
||||
screenHeightInDp,
|
||||
startAdContainer,
|
||||
sdkStartAdContainer,
|
||||
adsFl,
|
||||
(BaseHandler) mBaseHandler,
|
||||
false,
|
||||
() -> {
|
||||
hideSplashAd();
|
||||
return null;
|
||||
}
|
||||
);
|
||||
} else {
|
||||
hideSplashAd();
|
||||
}
|
||||
} else {
|
||||
hideSplashAd();
|
||||
}
|
||||
@ -546,12 +554,13 @@ public class MainActivity extends BaseActivity {
|
||||
protected void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
if (msg.what == COUNTDOWN_AD) {
|
||||
countdownCount++;
|
||||
TextView jumpBtn = findViewById(R.id.jumpBtn);
|
||||
jumpBtn.setText(String.format(Locale.CHINA, "跳过 %d", COUNTDOWN_MAX_COUNT - countdownCount));
|
||||
if (COUNTDOWN_MAX_COUNT < countdownCount) {
|
||||
mCountdownCount++;
|
||||
if (COUNTDOWN_MAX_COUNT < mCountdownCount) {
|
||||
AdDelegateHelper.INSTANCE.setShowingSplashAd(false);
|
||||
hideSplashAd();
|
||||
} else {
|
||||
TextView jumpBtn = findViewById(R.id.jumpBtn);
|
||||
jumpBtn.setText(String.format(Locale.CHINA, "跳过 %d", COUNTDOWN_MAX_COUNT - mCountdownCount));
|
||||
mBaseHandler.sendEmptyMessageDelayed(COUNTDOWN_AD, 1000);
|
||||
}
|
||||
}
|
||||
@ -883,6 +892,7 @@ public class MainActivity extends BaseActivity {
|
||||
@Override
|
||||
protected void onSaveInstanceState(@NotNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.clear();
|
||||
outState.putInt(CURRENT_PAGE, mMainWrapperFragment.getCurrentItem());
|
||||
if (mMainWrapperFragment != null) {
|
||||
outState.putInt(BaseFragment_ViewPager.ARGS_INDEX, mMainWrapperFragment.getCurrentItem());
|
||||
|
||||
@ -278,7 +278,7 @@ public class NewsDetailActivity extends DownloadToolbarActivity implements OnCli
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.background_white, R.color.background_white);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.ui_surface, R.color.ui_surface);
|
||||
|
||||
mDetailRv = findViewById(R.id.news_detail_rv_show);
|
||||
mDetailBottomLl = findViewById(R.id.news_detail_ll_bottom);
|
||||
@ -807,16 +807,16 @@ public class NewsDetailActivity extends DownloadToolbarActivity implements OnCli
|
||||
@Override
|
||||
protected void onDarkModeChanged() {
|
||||
super.onDarkModeChanged();
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.background_white, R.color.background_white);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.ui_surface, R.color.ui_surface);
|
||||
mNewsShare.setIcon(R.drawable.icon_share_black);
|
||||
mNewsCollection.setIcon(R.drawable.community_content_detail_collect_unselect);
|
||||
mDetailRv.removeItemDecoration(mItemDecoration);
|
||||
mItemDecoration = new VerticalItemDecoration(this, 8, false);
|
||||
mDetailRv.addItemDecoration(mItemDecoration);
|
||||
if (mContentView != null) {
|
||||
mContentView.setBackgroundColor(ContextCompat.getColor(this, R.color.background));
|
||||
findViewById(R.id.bottomContainer).setBackgroundColor(ContextCompat.getColor(this, R.color.background_white));
|
||||
((TextView) findViewById(R.id.commentTv)).setTextColor(ContextCompat.getColor(this, R.color.text_subtitle));
|
||||
mContentView.setBackgroundColor(ContextCompat.getColor(this, R.color.ui_background));
|
||||
findViewById(R.id.bottomContainer).setBackgroundColor(ContextCompat.getColor(this, R.color.ui_surface));
|
||||
((TextView) findViewById(R.id.commentTv)).setTextColor(ContextCompat.getColor(this, R.color.text_secondary));
|
||||
}
|
||||
if (adapter != null) {
|
||||
adapter.notifyItemRangeChanged(0, adapter.getItemCount());
|
||||
|
||||
@ -61,7 +61,7 @@ open class SearchActivity : BaseActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
updateStatusBarColor(R.color.background_white, R.color.background_white)
|
||||
updateStatusBarColor(R.color.ui_surface, R.color.ui_surface)
|
||||
|
||||
searchEt = findViewById(R.id.searchEt)
|
||||
searchBtn = findViewById(R.id.searchBtn)
|
||||
@ -304,7 +304,7 @@ open class SearchActivity : BaseActivity() {
|
||||
|
||||
override fun onDarkModeChanged() {
|
||||
super.onDarkModeChanged()
|
||||
updateStatusBarColor(R.color.background_white, R.color.background_white)
|
||||
updateStatusBarColor(R.color.ui_surface, R.color.ui_surface)
|
||||
}
|
||||
|
||||
override fun isAutoResetViewBackgroundEnabled() = true
|
||||
|
||||
@ -52,7 +52,7 @@ public class ShareGhActivity extends ToolBarActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.background_white, R.color.background_white);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.ui_surface, R.color.ui_surface);
|
||||
mGhQrcode = findViewById(R.id.gh_address_qrcode);
|
||||
mGhAddress = findViewById(R.id.gh_address_tv);
|
||||
mContentLl = findViewById(R.id.content_ll);
|
||||
@ -75,6 +75,6 @@ public class ShareGhActivity extends ToolBarActivity {
|
||||
@Override
|
||||
protected void onDarkModeChanged() {
|
||||
super.onDarkModeChanged();
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.background_white, R.color.background_white);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.ui_surface, R.color.ui_surface);
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,9 +153,8 @@ public class SkipActivity extends BaseActivity {
|
||||
case HOST_SUGGESTION:
|
||||
if (!TextUtils.isEmpty(qaId)) {
|
||||
DirectUtils.directToQa(this, qaTitle, qaId);
|
||||
} else if ("vgame".equals(suggestionType)) {
|
||||
DirectUtils.directToFeedback(this, content, isQaFeedback, qaContentId, false, true, EntranceConsts.ENTRANCE_BROWSER);
|
||||
} else {
|
||||
// 插件反馈跳转到意见反馈分类页
|
||||
DirectUtils.directToFeedback(this, content, isQaFeedback, qaContentId, true, false, EntranceConsts.ENTRANCE_BROWSER);
|
||||
}
|
||||
break;
|
||||
@ -226,7 +225,7 @@ public class SkipActivity extends BaseActivity {
|
||||
String tagActivityName = uri.getQueryParameter("tagActivityName");
|
||||
VideoLinkEntity linkEntity = new VideoLinkEntity(title, categoryId, link, tagActivityId, tagActivityName);
|
||||
|
||||
SimpleGameEntity simpleGameEntity = new SimpleGameEntity(gameId != null ? gameId : "", gameName != null ? gameName : "", "");
|
||||
SimpleGameEntity simpleGameEntity = new SimpleGameEntity(gameId != null ? gameId : "", gameName != null ? gameName : "", "", "");
|
||||
Bundle nextToBundle = VideoManagerActivity.getVideoManagerBundle(linkEntity, simpleGameEntity, EntranceConsts.ENTRANCE_BROWSER, "");
|
||||
CheckLoginUtils.checkLogin(this, nextToBundle, true, EntranceConsts.ENTRANCE_BROWSER, () ->
|
||||
DirectUtils.directToVideoManager(SkipActivity.this, linkEntity, simpleGameEntity, EntranceConsts.ENTRANCE_BROWSER, "浏览器"));
|
||||
|
||||
98
app/src/main/java/com/gh/gamecenter/SplashAdActivity.kt
Normal file
98
app/src/main/java/com/gh/gamecenter/SplashAdActivity.kt
Normal file
@ -0,0 +1,98 @@
|
||||
package com.gh.gamecenter
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.os.Message
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.TextView
|
||||
import com.gh.ad.AdDelegateHelper
|
||||
import com.gh.ad.AdDelegateHelper.requestSplashAd
|
||||
import com.gh.ad.AdDelegateHelper.shouldShowStartUpAd
|
||||
import com.gh.gamecenter.common.base.activity.BaseActivity
|
||||
import com.gh.gamecenter.common.utils.dip2px
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* 开屏广告(热启动)
|
||||
*/
|
||||
class SplashAdActivity : BaseActivity() {
|
||||
private var mCountdownCount = 0
|
||||
override fun getLayoutId(): Int = R.layout.activity_splash_ad
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
overridePendingTransition(0, 0)
|
||||
DisplayUtils.transparentStatusBar(this)
|
||||
showSplashAd()
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示开屏广告
|
||||
*/
|
||||
private fun showSplashAd() {
|
||||
if (shouldShowStartUpAd(true)) {
|
||||
val startAdContainer = findViewById<ViewGroup>(R.id.startAdContainer)
|
||||
val sdkStartAdContainer = findViewById<ViewGroup>(R.id.sdkStartAdContainer)
|
||||
val adsFl = findViewById<FrameLayout>(R.id.adsFl)
|
||||
|
||||
val screenWidthInPx = DisplayUtils.getScreenWidth(this)
|
||||
val screenHeightInPx = (DisplayUtils.getScreenHeight(this)
|
||||
+ DisplayUtils.getStatusBarHeight(this.resources)
|
||||
- 112F.dip2px())
|
||||
val screenWidthInDp = DisplayUtils.px2dip(this, screenWidthInPx.toFloat()).toFloat()
|
||||
val screenHeightInDp = DisplayUtils.px2dip(this, screenHeightInPx.toFloat()).toFloat()
|
||||
requestSplashAd(
|
||||
this,
|
||||
screenWidthInPx,
|
||||
screenHeightInPx,
|
||||
screenWidthInDp,
|
||||
screenHeightInDp,
|
||||
startAdContainer!!,
|
||||
sdkStartAdContainer!!,
|
||||
adsFl!!,
|
||||
(mBaseHandler as BaseHandler),
|
||||
true
|
||||
) {
|
||||
finishActivity()
|
||||
null
|
||||
}
|
||||
} else {
|
||||
finishActivity()
|
||||
}
|
||||
}
|
||||
|
||||
private fun finishActivity() {
|
||||
finish()
|
||||
overridePendingTransition(0, 0)
|
||||
}
|
||||
|
||||
override fun handleBackPressed(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun handleMessage(msg: Message) {
|
||||
super.handleMessage(msg)
|
||||
if (msg.what == MainActivity.COUNTDOWN_AD) {
|
||||
mCountdownCount++
|
||||
if (MainActivity.COUNTDOWN_MAX_COUNT < mCountdownCount) {
|
||||
AdDelegateHelper.isShowingSplashAd = false
|
||||
finishActivity()
|
||||
} else {
|
||||
val jumpBtn = findViewById<TextView>(R.id.jumpBtn)
|
||||
jumpBtn.text =
|
||||
String.format(Locale.CHINA, "跳过 %d", MainActivity.COUNTDOWN_MAX_COUNT - mCountdownCount)
|
||||
mBaseHandler.sendEmptyMessageDelayed(MainActivity.COUNTDOWN_AD, 1000)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun getIntent(context: Context): Intent {
|
||||
return Intent(context, SplashAdActivity::class.java)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,57 +1,40 @@
|
||||
package com.gh.gamecenter
|
||||
|
||||
import android.Manifest
|
||||
import android.app.NotificationChannel
|
||||
import android.app.NotificationManager
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.preference.PreferenceManager
|
||||
import android.text.method.ScrollingMovementMethod
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.viewpager.widget.PagerAdapter
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.core.app.NotificationCompat
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.g00fy2.versioncompare.Version
|
||||
import com.gh.ad.AdDelegateHelper
|
||||
import com.gh.common.dialog.NewPrivacyPolicyDialogFragment
|
||||
import com.gh.common.util.*
|
||||
import com.gh.common.util.GameSubstituteRepositoryHelper.updateGameSubstituteRepository
|
||||
import com.gh.common.util.UsageStatsHelper.checkAndPostUsageStats
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.common.base.activity.BaseActivity
|
||||
import com.gh.gamecenter.common.callback.SimpleCallback
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.common.exposure.meta.MetaUtil
|
||||
import com.gh.gamecenter.common.tracker.TrackerLogger
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.provider.IAppProvider
|
||||
import com.gh.gamecenter.core.provider.IPackageUtilsProvider
|
||||
import com.gh.gamecenter.core.runOnIoThread
|
||||
import com.gh.gamecenter.core.utils.*
|
||||
import com.gh.gamecenter.entity.PrivacyPolicyEntity
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.feature.utils.PlatformUtils
|
||||
import com.gh.gamecenter.pkg.PkgHelper
|
||||
import com.gh.vspace.VHelper
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.download.FileUtils
|
||||
import org.json.JSONObject
|
||||
import pub.devrel.easypermissions.AfterPermissionGranted
|
||||
import pub.devrel.easypermissions.EasyPermissions
|
||||
import java.io.BufferedReader
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.io.InputStreamReader
|
||||
import splitties.systemservices.notificationManager
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
/**
|
||||
* 引导页面
|
||||
@ -61,22 +44,9 @@ class SplashScreenActivity : BaseActivity() {
|
||||
|
||||
private var mSharedPreferences: SharedPreferences? = null
|
||||
private var mIsNewForThisVersion = false
|
||||
private var mStartMainActivityDirectly = false // 是否不需要用户点击立即体验就直接跳转首页
|
||||
private var mViewModel: SplashScreenViewModel? = null
|
||||
private var mShouldPrefetchData = true
|
||||
|
||||
private val mPermissions by lazy {
|
||||
if (isStoragePermissionsRequired) {
|
||||
arrayOf(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||
PermissionHelper.PERMISSION_GET_INSTALLED_LIST
|
||||
)
|
||||
} else {
|
||||
arrayOf(PermissionHelper.PERMISSION_GET_INSTALLED_LIST)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
mViewModel = viewModelProvider()
|
||||
mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
|
||||
@ -104,18 +74,11 @@ class SplashScreenActivity : BaseActivity() {
|
||||
|
||||
// 判断是不是这个版本的新用户
|
||||
if (mIsNewForThisVersion) {
|
||||
mContentView.setPadding(0, 0, 0, 0)
|
||||
val guideLayout = findViewById<ViewPager>(R.id.splash_intro_vp_guide)
|
||||
guideLayout.adapter = GuidePagerAdapter()
|
||||
|
||||
// 判断是不是光环的新用户
|
||||
if (HaloApp.getInstance().isBrandNewInstall) {
|
||||
// 引导页需用户点击 “立即体验” 按钮才进入首页,所以这里不能置为true
|
||||
// https://git.ghzs.com/pm/halo-app-issues/-/issues/1422(第3点)
|
||||
// mStartMainActivityDirectly = true;
|
||||
SPUtils.setLong(Constants.SP_INITIAL_USAGE_TIME, System.currentTimeMillis())
|
||||
if (!PackageFlavorHelper.IS_TEST_FLAVOR) {
|
||||
showPrivacyDialog(guideLayout)
|
||||
showPrivacyDialog()
|
||||
} else {
|
||||
// Test dex2oat
|
||||
executeDex2OatInAdvance()
|
||||
@ -127,11 +90,11 @@ class SplashScreenActivity : BaseActivity() {
|
||||
"测试环境",
|
||||
{
|
||||
SPUtils.setBoolean(Constants.SP_IS_DEV_ENV, false)
|
||||
showPrivacyDialog(guideLayout)
|
||||
showPrivacyDialog()
|
||||
},
|
||||
{
|
||||
SPUtils.setBoolean(Constants.SP_IS_DEV_ENV, true)
|
||||
showPrivacyDialog(guideLayout)
|
||||
showPrivacyDialog()
|
||||
},
|
||||
false,
|
||||
"",
|
||||
@ -140,15 +103,10 @@ class SplashScreenActivity : BaseActivity() {
|
||||
}
|
||||
} else {
|
||||
cancelPreviousUpdateTask()
|
||||
guideLayout.visibility = View.VISIBLE
|
||||
//requestPermission()
|
||||
}
|
||||
} else {
|
||||
if (com.gh.gamecenter.common.BuildConfig.BUILD_TIME != 0L) {
|
||||
showGitLogDialogIfNeeded()
|
||||
} else {
|
||||
launchMainActivity()
|
||||
}
|
||||
} else {
|
||||
launchMainActivity()
|
||||
}
|
||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.R) {
|
||||
SPUtils.setString(Constants.SP_XAPK_UNZIP_ACTIVITY, "")
|
||||
@ -180,41 +138,63 @@ class SplashScreenActivity : BaseActivity() {
|
||||
SPUtils.setBoolean(Constants.SP_SENSORS_IS_FIRST_TIME, false)
|
||||
}
|
||||
|
||||
private fun showPrivacyDialog(guideLayout: ViewPager) {
|
||||
private fun showPrivacyDialog() {
|
||||
NewPrivacyPolicyDialogFragment.show(this, null) { isSuccess: Boolean ->
|
||||
if (isSuccess) {
|
||||
mShouldPrefetchData = false
|
||||
prefetchData()
|
||||
|
||||
val callback = object : SimpleCallback<Boolean> {
|
||||
override fun onCallback(arg: Boolean) {
|
||||
// Dialog dismiss 后的回调
|
||||
guideLayout.visibility = View.VISIBLE
|
||||
SPUtils.setBoolean(Constants.SP_BRAND_NEW_USER, false)
|
||||
if (arg) {
|
||||
requestPermission()
|
||||
} else {
|
||||
mStartMainActivityDirectly = false
|
||||
}
|
||||
}
|
||||
}
|
||||
SPUtils.setBoolean(Constants.SP_BRAND_NEW_USER, false)
|
||||
|
||||
mViewModel?.showPrivacyPolicy({
|
||||
DialogUtils.showPrivacyPolicyDialog(this@SplashScreenActivity, it, callback)
|
||||
}, {
|
||||
DialogUtils.showPrivacyPolicyDialog(this@SplashScreenActivity, PrivacyPolicyEntity.createDefaultData(), callback)
|
||||
})
|
||||
// 荣耀高版本系统设备在获取已安装列表权限时,会把存储权限等的东西也一并弹出来,导致超量获取权限
|
||||
// 神奇的是,只需要在获取权限前弹出一条通知,再获取权限就会恢复正常.....
|
||||
val isMalfunctioningHonorDevice = Build.MANUFACTURER.lowercase() == "honor"
|
||||
&& Build.VERSION.SDK_INT > Build.VERSION_CODES.R
|
||||
|
||||
if (isMalfunctioningHonorDevice) {
|
||||
showHonorNotification()
|
||||
mBaseHandler.postDelayed({
|
||||
requestGetInstallListPermissionAndLaunchMainActivity()
|
||||
}, 100L)
|
||||
} else {
|
||||
requestGetInstallListPermissionAndLaunchMainActivity()
|
||||
}
|
||||
} else {
|
||||
DialogUtils.showPrivacyPolicyDisallowDialog(
|
||||
this,
|
||||
PrivacyPolicyEntity.createDefaultData()
|
||||
) {
|
||||
showPrivacyDialog(guideLayout)
|
||||
DialogUtils.showPrivacyPolicyDisallowDialog(this) {
|
||||
showPrivacyDialog()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
private fun showHonorNotification() {
|
||||
val channel =
|
||||
NotificationChannel(HONOR_CULPRIT_CHANNEL, HONOR_CULPRIT_CHANNEL, NotificationManager.IMPORTANCE_MIN)
|
||||
notificationManager.createNotificationChannel(channel)
|
||||
val builder = NotificationCompat.Builder(HaloApp.getInstance().application, HONOR_CULPRIT_CHANNEL)
|
||||
.setSmallIcon(R.mipmap.logo)
|
||||
.setContentTitle("光环助手荣耀设备启动服务")
|
||||
|
||||
val notification = builder.build()
|
||||
|
||||
notificationManager.notify(HONOR_CULPRIT_CHANNEL, HONOR_CULPRIT_ID, notification)
|
||||
notificationManager.cancel(HONOR_CULPRIT_ID)
|
||||
}
|
||||
|
||||
// 尝试获取安装应用列表权限并启动首页(不在乎结果)
|
||||
private fun requestGetInstallListPermissionAndLaunchMainActivity() {
|
||||
if (PackageUtils.isSupportGetInstalledAppsPermission(this)
|
||||
&& PermissionHelper.isGetInstalledListPermissionDisabled(this)
|
||||
) {
|
||||
PermissionHelper.requestGetInstalledAppsListPermission(this, true) {
|
||||
launchMainActivity()
|
||||
}
|
||||
} else {
|
||||
launchMainActivity()
|
||||
}
|
||||
}
|
||||
|
||||
// 删除更新后的光环助手包
|
||||
private fun cancelPreviousUpdateTask() {
|
||||
val all = DownloadManager.getInstance().allDownloadEntity
|
||||
@ -237,26 +217,12 @@ class SplashScreenActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun requestPermission() {
|
||||
if (!EasyPermissions.hasPermissions(this, *mPermissions)) {
|
||||
checkAndRequestPermission()
|
||||
}
|
||||
}
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return if (mIsNewForThisVersion) {
|
||||
R.layout.activity_splash_intro
|
||||
} else 0
|
||||
}
|
||||
override fun getLayoutId() = 0
|
||||
|
||||
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK && event.repeatCount == 0) {
|
||||
if (mIsNewForThisVersion && EasyPermissions.hasPermissions(this, *mPermissions)) {
|
||||
if (com.gh.gamecenter.common.BuildConfig.BUILD_TIME != 0L) {
|
||||
showGitLogDialogIfNeeded()
|
||||
} else {
|
||||
launchMainActivity()
|
||||
}
|
||||
if (mIsNewForThisVersion) {
|
||||
launchMainActivity()
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
@ -291,77 +257,7 @@ class SplashScreenActivity : BaseActivity() {
|
||||
HaloApp.getInstance().flavorProvider.init(HaloApp.getInstance(), this, PkgHelper.getActivateRatio())
|
||||
|
||||
SensorsBridge.init(HaloApp.getInstance(), HaloApp.getInstance().channel)
|
||||
}
|
||||
|
||||
private fun getGitLogString(): String {
|
||||
if (com.gh.gamecenter.common.BuildConfig.BUILD_TIME != 0L) {
|
||||
val stringBuilder = StringBuilder()
|
||||
var bufferedReader: BufferedReader? = null
|
||||
var inputStreamReader: InputStreamReader? = null
|
||||
try {
|
||||
inputStreamReader = InputStreamReader(assets.open("gitlog.txt"))
|
||||
bufferedReader = BufferedReader(inputStreamReader)
|
||||
var line: String?
|
||||
stringBuilder.append("本光环安装包最近20次代码变更如下:")
|
||||
stringBuilder.append(System.getProperty("line.separator"))
|
||||
while (bufferedReader.readLine().also { line = it } != null) {
|
||||
line?.let {
|
||||
val urlRegex = Regex("http(s)?://([\\w-]+\\.)+[\\w-]+(/[\\w- ./?%&=]*)?")
|
||||
if (urlRegex.containsMatchIn(it)) {
|
||||
line = urlRegex.replace(it, "")
|
||||
}
|
||||
}
|
||||
stringBuilder.append(line)
|
||||
stringBuilder.append(System.getProperty("line.separator"))
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
} finally {
|
||||
inputStreamReader?.close()
|
||||
bufferedReader?.close()
|
||||
}
|
||||
return stringBuilder.toString()
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
private fun showGitLogDialogIfNeeded() {
|
||||
if (com.gh.gamecenter.common.BuildConfig.BUILD_TIME != 0L) {
|
||||
val gitLog = getGitLogString()
|
||||
if (gitLog.isNotEmpty()) {
|
||||
val md5 = MD5Utils.getContentMD5(gitLog)
|
||||
if (SPUtils.getString(Constants.GIT_LOG_MD5, "") != md5) {
|
||||
SPUtils.setString(Constants.GIT_LOG_MD5, md5)
|
||||
DialogHelper.showDialog(
|
||||
this,
|
||||
"${PackageUtils.getGhVersionName()} ${com.gh.gamecenter.common.BuildConfig.BUILD_TIME}",
|
||||
gitLog,
|
||||
"确定",
|
||||
"",
|
||||
{
|
||||
launchMainActivity()
|
||||
},
|
||||
extraConfig = DialogHelper.Config(
|
||||
centerTitle = true,
|
||||
centerContent = false
|
||||
),
|
||||
uiModificationCallback = { binding ->
|
||||
binding.contentTv.run {
|
||||
maxHeight = 500F.dip2px()
|
||||
textSize = 10F
|
||||
isVerticalScrollBarEnabled = true
|
||||
movementMethod = ScrollingMovementMethod.getInstance()
|
||||
}
|
||||
},
|
||||
)
|
||||
} else {
|
||||
launchMainActivity()
|
||||
}
|
||||
} else {
|
||||
launchMainActivity()
|
||||
}
|
||||
}
|
||||
SensorsBridge.setOAID(HaloApp.getInstance().oaid)
|
||||
}
|
||||
|
||||
private fun prefetchData() {
|
||||
@ -393,112 +289,11 @@ class SplashScreenActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
@AfterPermissionGranted(REQUEST_PERMISSION_TAG)
|
||||
private fun checkAndRequestPermission() {
|
||||
if (EasyPermissions.hasPermissions(this, *mPermissions)) {
|
||||
onPermissionsGranted(REQUEST_PERMISSION_TAG, ArrayList(mPermissions.toList()))
|
||||
|
||||
if (mStartMainActivityDirectly) {
|
||||
if (com.gh.gamecenter.common.BuildConfig.BUILD_TIME != 0L) {
|
||||
showGitLogDialogIfNeeded()
|
||||
} else {
|
||||
launchMainActivity()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ActivityCompat.requestPermissions(this, mPermissions, REQUEST_PERMISSION_TAG)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPermissionsDenied(requestCode: Int, perms: List<String>) {
|
||||
if (mStartMainActivityDirectly) {
|
||||
if (com.gh.gamecenter.common.BuildConfig.BUILD_TIME != 0L) {
|
||||
showGitLogDialogIfNeeded()
|
||||
} else {
|
||||
launchMainActivity()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPermissionsGranted(requestCode: Int, perms: MutableList<String>?) {
|
||||
super.onPermissionsGranted(requestCode, perms)
|
||||
|
||||
if (perms?.contains(Manifest.permission.READ_EXTERNAL_STORAGE) == true) {
|
||||
// 恢复畅玩数据
|
||||
VHelper.recoverVDataIfPossible()
|
||||
// 检查是否有旧版本光环,有就删掉
|
||||
runOnIoThread { deleteOutdatedUpdatePackage() }
|
||||
}
|
||||
}
|
||||
|
||||
// 检查下载文件夹下是否有旧版本的光环助手的包,有则删除
|
||||
private fun deleteOutdatedUpdatePackage() {
|
||||
try {
|
||||
val folder = File(FileUtils.getDownloadDir(this) + File.separator)
|
||||
if (folder.isDirectory) {
|
||||
for (file in folder.listFiles()) {
|
||||
if (!file.isDirectory && file.name.startsWith("光环助手V")) {
|
||||
val name = file.name
|
||||
val index = name.indexOf("_")
|
||||
if (index != -1) {
|
||||
val versionString = name.substring(name.indexOf("V") + 1, index)
|
||||
val currentVersion = Version(PackageUtils.getGhVersionName())
|
||||
if (currentVersion.isHigherThan(versionString) || currentVersion.isEqual(versionString)) {
|
||||
file.delete()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
private inner class GuidePagerAdapter : PagerAdapter() {
|
||||
private val mPics = intArrayOf(R.drawable.splash_01)
|
||||
override fun getCount(): Int {
|
||||
return mPics.size
|
||||
}
|
||||
|
||||
override fun instantiateItem(container: ViewGroup, position: Int): Any {
|
||||
val view = View.inflate(container.context, R.layout.splash_guide_item, null)
|
||||
val ivImage = view.findViewById<ImageView>(R.id.splsh_guide_iv_image)
|
||||
ivImage.setImageResource(mPics[position])
|
||||
if (position == mPics.size - 1) {
|
||||
val tvSkip = view.findViewById<TextView>(R.id.splsh_guide_tv_skip)
|
||||
// 如果屏幕特短,或者是平板的横屏显示,把图片改成按高度显示
|
||||
if (DisplayUtils.isUltraShortScreen(this@SplashScreenActivity)) {
|
||||
ivImage.scaleType = ImageView.ScaleType.CENTER_INSIDE
|
||||
}
|
||||
tvSkip.setOnClickListener {
|
||||
if (com.gh.gamecenter.common.BuildConfig.BUILD_TIME != 0L) {
|
||||
showGitLogDialogIfNeeded()
|
||||
} else {
|
||||
launchMainActivity()
|
||||
}
|
||||
}
|
||||
}
|
||||
container.addView(view)
|
||||
return view
|
||||
}
|
||||
|
||||
override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
|
||||
container.removeView(`object` as View)
|
||||
}
|
||||
|
||||
override fun isViewFromObject(view: View, `object`: Any): Boolean {
|
||||
return view === `object`
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val REQUEST_PERMISSION_TAG = 30001
|
||||
|
||||
// 启动时的存储权限获取是否开启
|
||||
val isStoragePermissionsRequired by lazy {
|
||||
HaloApp.getInstance().channel != "GH_206" && HaloApp.getInstance().channel != "GH_110"
|
||||
}
|
||||
const val HONOR_CULPRIT_ID = 12324
|
||||
const val HONOR_CULPRIT_CHANNEL = "荣耀通道"
|
||||
|
||||
@JvmStatic
|
||||
fun getSplashScreenIntent(context: Context?, bundle: Bundle?): Intent {
|
||||
|
||||
@ -15,7 +15,6 @@ import com.gh.gamecenter.core.utils.GsonUtils
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.feature.entity.AuthDialogEntity
|
||||
import com.gh.gamecenter.entity.DeviceDialogEntity
|
||||
import com.gh.gamecenter.entity.PrivacyPolicyEntity
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
@ -91,25 +90,6 @@ class SplashScreenViewModel(application: Application) : AndroidViewModel(applica
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取隐私政策指引概要
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
fun showPrivacyPolicy(successCallBack: (PrivacyPolicyEntity) -> Unit, onFailureCallBack: () -> Unit) {
|
||||
mApi.privacyPolicy
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : BiResponse<PrivacyPolicyEntity>() {
|
||||
override fun onSuccess(data: PrivacyPolicyEntity) {
|
||||
successCallBack.invoke(data)
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
onFailureCallBack.invoke()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断新老用户
|
||||
*/
|
||||
|
||||
@ -12,14 +12,14 @@ class UserAuthActivity : ToolBarActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setNavigationTitle("已获得认证")
|
||||
updateStatusBarColor(R.color.background_white, R.color.background_white)
|
||||
updateStatusBarColor(R.color.ui_surface, R.color.ui_surface)
|
||||
}
|
||||
|
||||
override fun isAutoResetViewBackgroundEnabled(): Boolean = false
|
||||
|
||||
override fun onDarkModeChanged() {
|
||||
super.onDarkModeChanged()
|
||||
updateStatusBarColor(R.color.background_white, R.color.background_white)
|
||||
updateStatusBarColor(R.color.ui_surface, R.color.ui_surface)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@ -11,7 +11,7 @@ class UserInfoActivity : ToolBarActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
updateStatusBarColor(R.color.background_white, R.color.background_white)
|
||||
updateStatusBarColor(R.color.ui_surface, R.color.ui_surface)
|
||||
}
|
||||
|
||||
companion object {
|
||||
@ -28,6 +28,6 @@ class UserInfoActivity : ToolBarActivity() {
|
||||
|
||||
override fun onDarkModeChanged() {
|
||||
super.onDarkModeChanged()
|
||||
updateStatusBarColor(R.color.background_white, R.color.background_white)
|
||||
updateStatusBarColor(R.color.ui_surface, R.color.ui_surface)
|
||||
}
|
||||
}
|
||||
@ -11,7 +11,7 @@ class VerifyPhoneActivity : ToolBarActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
updateStatusBarColor(R.color.background_white, R.color.background_white)
|
||||
updateStatusBarColor(R.color.ui_surface, R.color.ui_surface)
|
||||
}
|
||||
|
||||
override fun isAutoResetViewBackgroundEnabled() = true
|
||||
|
||||
@ -29,13 +29,13 @@ public class VoteActivity extends ToolBarActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.background_white, R.color.background_white);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.ui_surface, R.color.ui_surface);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDarkModeChanged() {
|
||||
super.onDarkModeChanged();
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.background_white, R.color.background_white);
|
||||
ExtensionsKt.updateStatusBarColor(this, R.color.ui_surface, R.color.ui_surface);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -39,7 +39,7 @@ open class WebActivity : ToolBarActivity() {
|
||||
} else {
|
||||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
updateStatusBarColor(R.color.background_white, R.color.background_white)
|
||||
updateStatusBarColor(R.color.ui_surface, R.color.ui_surface)
|
||||
}
|
||||
|
||||
override fun provideNormalIntent(): Intent {
|
||||
@ -72,7 +72,7 @@ open class WebActivity : ToolBarActivity() {
|
||||
|
||||
override fun onDarkModeChanged() {
|
||||
super.onDarkModeChanged()
|
||||
updateStatusBarColor(R.color.background_white, R.color.background_white)
|
||||
updateStatusBarColor(R.color.ui_surface, R.color.ui_surface)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@ -20,15 +20,17 @@ import android.util.Base64;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.gamecenter.common.utils.SensorsBridge;
|
||||
import com.gh.common.util.IntegralLogHelper;
|
||||
import com.gh.gamecenter.common.callback.BiCallback;
|
||||
import com.gh.gamecenter.common.constant.RouteConsts;
|
||||
import com.gh.gamecenter.common.eventbus.EBShare;
|
||||
import com.gh.gamecenter.common.utils.BitmapUtils;
|
||||
import com.gh.gamecenter.common.utils.ImageUtils;
|
||||
import com.gh.gamecenter.common.utils.SensorsBridge;
|
||||
import com.gh.gamecenter.common.utils.ShareUtils;
|
||||
import com.gh.gamecenter.core.provider.IAppProvider;
|
||||
import com.lightgame.utils.Utils;
|
||||
import com.sina.weibo.sdk.api.ImageObject;
|
||||
import com.sina.weibo.sdk.api.TextObject;
|
||||
@ -50,6 +52,7 @@ import java.io.ByteArrayOutputStream;
|
||||
*/
|
||||
@Route(path = RouteConsts.activity.weiBoShareActivity)
|
||||
public class WeiBoShareActivity extends Activity implements WbShareCallback {
|
||||
private IAppProvider mAppProvider = (IAppProvider) ARouter.getInstance().build(RouteConsts.provider.app).navigation();
|
||||
|
||||
private static final String WEIBO_SCOPE = (
|
||||
"email,direct_messages_read,direct_messages_write,"
|
||||
@ -95,6 +98,9 @@ public class WeiBoShareActivity extends Activity implements WbShareCallback {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (mAppProvider != null) {
|
||||
mAppProvider.setSkippingThirdParty(true);
|
||||
}
|
||||
Bundle extras = getIntent().getExtras();
|
||||
|
||||
if (extras == null) return;
|
||||
@ -326,4 +332,12 @@ public class WeiBoShareActivity extends Activity implements WbShareCallback {
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (mAppProvider != null) {
|
||||
mAppProvider.setSkippingThirdParty(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -228,10 +228,10 @@ public class CleanApkAdapter extends BaseRecyclerAdapter<KcSelectGameViewHolder>
|
||||
if (!mIsChooseApk) {
|
||||
if (gameEntity.getInstallStatus() == INSTALLED) {
|
||||
holder.binding.selectGameSize.setText(R.string.installed);
|
||||
holder.binding.selectGameSize.setTextColor(ContextCompat.getColor(mContext, R.color.theme_font));
|
||||
holder.binding.selectGameSize.setTextColor(ContextCompat.getColor(mContext, R.color.text_theme));
|
||||
} else {
|
||||
holder.binding.selectGameSize.setText(R.string.installed_not);
|
||||
holder.binding.selectGameSize.setTextColor(ContextCompat.getColor(mContext, R.color.theme_red));
|
||||
holder.binding.selectGameSize.setTextColor(ContextCompat.getColor(mContext, R.color.secondary_red));
|
||||
}
|
||||
holder.binding.selectGameDes.setText(mContext.getString(R.string.clean_apk_version, gameEntity.getGameVersion(), sizeName));
|
||||
holder.binding.selectGameDes.setTextColor(ContextCompat.getColor(mContext, R.color.content));
|
||||
|
||||
@ -37,7 +37,7 @@ public class LiBaoCodeAdapter extends BaseRecyclerAdapter<LiBaoCodeViewHolder> {
|
||||
@Override
|
||||
public void onBindViewHolder(LiBaoCodeViewHolder holder, int position) {
|
||||
final UserDataLibaoEntity userDataLibaoEntity = mUserDataLibaoList.get(position);
|
||||
holder.binding.libaoCodeTv.setTextColor(ContextCompat.getColor(mContext, R.color.text_subtitle));
|
||||
holder.binding.libaoCodeTv.setTextColor(ContextCompat.getColor(mContext, R.color.text_secondary));
|
||||
if ("ling".equals(userDataLibaoEntity.getType()) || "linged".equals(userDataLibaoEntity.getType())) {
|
||||
StringBuilder content = new StringBuilder();
|
||||
if (mUserDataLibaoList.size() > 1) {
|
||||
|
||||
@ -159,15 +159,15 @@ public class LibaoDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
|
||||
|
||||
SpannableStringBuilder builder = new SpanBuilder("此礼包有问题?点击反馈")
|
||||
.click(mContext, 7, 11, R.color.theme_font, false, () -> {
|
||||
.click(mContext, 7, 11, R.color.text_theme, false, () -> {
|
||||
HelpAndFeedbackBridge.startSuggestionActivity(mContext,
|
||||
SuggestType.GAME, "libao",
|
||||
StringUtils.buildString(mLibaoEntity.getName(), "有问题:"), new SimpleGameEntity(mLibaoEntity.getGame().getId(), mLibaoEntity.getGame().getName(), mLibaoEntity.getGame().getIcon()));
|
||||
StringUtils.buildString(mLibaoEntity.getName(), "有问题:"), new SimpleGameEntity(mLibaoEntity.getGame().getId(), mLibaoEntity.getGame().getName(), mLibaoEntity.getGame().getIcon(), ""));
|
||||
return null;
|
||||
})
|
||||
.build();
|
||||
viewHolder.getHint().setText(builder);
|
||||
viewHolder.getHint().setTextColor(ContextCompat.getColor(mContext, R.color.text_subtitle));
|
||||
viewHolder.getHint().setTextColor(ContextCompat.getColor(mContext, R.color.text_secondary));
|
||||
viewHolder.getHint().setMovementMethod(new LinkMovementMethod());
|
||||
}
|
||||
}
|
||||
@ -199,7 +199,7 @@ public class LibaoDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
}
|
||||
});
|
||||
|
||||
ExtensionsKt.setRootBackgroundColor(holder.binding.getRoot(), R.color.background_white);
|
||||
ExtensionsKt.setRootBackgroundColor(holder.binding.getRoot(), R.color.ui_surface);
|
||||
if (mLibaoEntity.getGame() != null) {
|
||||
holder.binding.libaodetailGameIcon.displayGameIcon(mLibaoEntity.getGame().getIcon(), mLibaoEntity.getGame().getIconSubscript(), mLibaoEntity.getGame().getIconFloat());
|
||||
GameEntity gameEntity = mLibaoEntity.getGame().toGameEntity();
|
||||
@ -370,7 +370,7 @@ public class LibaoDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
@Override
|
||||
public void updateDrawState(@NonNull TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
ds.setColor(ExtensionsKt.toColor(R.color.theme_font, mContext));
|
||||
ds.setColor(ExtensionsKt.toColor(R.color.text_theme, mContext));
|
||||
ds.setUnderlineText(false);
|
||||
}
|
||||
|
||||
|
||||
@ -1,17 +1,22 @@
|
||||
package com.gh.gamecenter.adapter
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.util.SparseIntArray
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.util.forEach
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.fragment.app.FragmentPagerAdapter
|
||||
import com.gh.gamecenter.common.BuildConfig
|
||||
|
||||
/***
|
||||
* 支持替换Fragment的FragmentPagerAdapter
|
||||
*/
|
||||
class MainFragmentPagerAdapter(
|
||||
private val mContext: Context,
|
||||
private val mFragmentManager: FragmentManager,
|
||||
private val mFragmentsList: ArrayList<Fragment>
|
||||
private val mFragmentsList: ArrayList<Fragment>,
|
||||
) : FragmentPagerAdapter(mFragmentManager) {
|
||||
private val mFragmentPositionSparseArray = SparseIntArray() // 记录Fragment的位置
|
||||
private val mFragmentPositionUpdateSparseArray = SparseIntArray() // 记录更新后Fragment的位置
|
||||
@ -76,4 +81,24 @@ class MainFragmentPagerAdapter(
|
||||
override fun getItem(position: Int): Fragment = mFragmentsList[position]
|
||||
|
||||
override fun getItemId(position: Int): Long = mFragmentsList[position].hashCode().toLong()
|
||||
|
||||
override fun finishUpdate(container: ViewGroup) {
|
||||
// 替换Fragment闪退关联问题(REPLACE_FRAGMENT_CRASH)
|
||||
try {
|
||||
super.finishUpdate(container)
|
||||
} catch (e: Throwable) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
throw e
|
||||
} else {
|
||||
e.printStackTrace()
|
||||
|
||||
// 重启APP
|
||||
val pm = mContext.packageManager
|
||||
val intent = pm?.getLaunchIntentForPackage(mContext.packageName)
|
||||
val mainIntent = Intent.makeRestartActivityTask(intent!!.component)
|
||||
mContext.startActivity(mainIntent)
|
||||
Runtime.getRuntime().exit(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -217,7 +217,7 @@ public class MessageDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
} else if (holder instanceof FooterViewHolder) {
|
||||
initFooterViewHolder((FooterViewHolder) holder);
|
||||
} else if (holder instanceof CommentHeadViewHolder) {
|
||||
((CommentHeadViewHolder) holder).binding.getRoot().setBackgroundColor(ContextCompat.getColor(mContext, R.color.background_white));
|
||||
((CommentHeadViewHolder) holder).binding.getRoot().setBackgroundColor(ContextCompat.getColor(mContext, R.color.ui_surface));
|
||||
((CommentHeadViewHolder) holder).binding.commentHeadTitle.setTextColor(ContextCompat.getColor(mContext, R.color.text_3a3a3a));
|
||||
if (mHotCommentList.size() != 0 && position == 1) {
|
||||
((CommentHeadViewHolder) holder).binding.commentHeadTitle.setText(R.string.comment_hot);
|
||||
@ -266,8 +266,8 @@ public class MessageDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
viewHolder.binding.getRoot().setBackground(ContextCompat.getDrawable(mContext, R.drawable.reuse_listview_item_style));
|
||||
viewHolder.binding.newsDigestTitle.setTextColor(ContextCompat.getColor(mContext, R.color.text_black));
|
||||
viewHolder.binding.newsDigestContent.setTextColor(ContextCompat.getColor(mContext, R.color.text_3a3a3a));
|
||||
viewHolder.binding.newsDigestCommentnum.setTextColor(ContextCompat.getColor(mContext, R.color.text_subtitleDesc));
|
||||
viewHolder.binding.newsDigestReadNum.setTextColor(ContextCompat.getColor(mContext, R.color.text_subtitleDesc));
|
||||
viewHolder.binding.newsDigestCommentnum.setTextColor(ContextCompat.getColor(mContext, R.color.text_tertiary));
|
||||
viewHolder.binding.newsDigestReadNum.setTextColor(ContextCompat.getColor(mContext, R.color.text_tertiary));
|
||||
|
||||
if (mConcernEntity.getViews() != 0) {
|
||||
viewHolder.binding.newsDigestReadNum.setText(NumberUtils.transSimpleCount(mConcernEntity.getViews()));
|
||||
@ -355,12 +355,12 @@ public class MessageDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
|
||||
private void initCommentViewHolder(final CommentViewHolder holder, int position) {
|
||||
holder.itemView.setBackground(ContextCompat.getDrawable(mContext, R.drawable.reuse_listview_item_style));
|
||||
holder.commentContentTv.setTextColor(ContextCompat.getColor(mContext, R.color.text_title));
|
||||
holder.commentTimeTv.setTextColor(ContextCompat.getColor(mContext, R.color.text_subtitleDesc));
|
||||
holder.commentReply.setTextColor(ContextCompat.getColor(mContext, R.color.text_title));
|
||||
holder.commentUserNameTv.setTextColor(ContextCompat.getColor(mContext, R.color.text_subtitle));
|
||||
holder.badgeNameTv.setTextColor(ContextCompat.getColor(mContext, R.color.text_subtitleDesc));
|
||||
holder.quoteAuthorTv.setTextColor(ContextCompat.getColor(mContext, R.color.text_subtitle));
|
||||
holder.commentContentTv.setTextColor(ContextCompat.getColor(mContext, R.color.text_primary));
|
||||
holder.commentTimeTv.setTextColor(ContextCompat.getColor(mContext, R.color.text_tertiary));
|
||||
holder.commentReply.setTextColor(ContextCompat.getColor(mContext, R.color.text_primary));
|
||||
holder.commentUserNameTv.setTextColor(ContextCompat.getColor(mContext, R.color.text_secondary));
|
||||
holder.badgeNameTv.setTextColor(ContextCompat.getColor(mContext, R.color.text_tertiary));
|
||||
holder.quoteAuthorTv.setTextColor(ContextCompat.getColor(mContext, R.color.text_secondary));
|
||||
holder.commentLikeIv.setImageResource(R.drawable.comment_vote_unselect);
|
||||
holder.quoteContainer.setBackground(ContextCompat.getDrawable(mContext, R.drawable.community_comment_reply_background));
|
||||
|
||||
|
||||
@ -210,10 +210,11 @@ class DetailViewHolder(
|
||||
return
|
||||
} else if (XapkUnzipStatus.FAILURE.name == xapkStatus) {
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(
|
||||
mViewHolder.context,
|
||||
mGameEntity.id,
|
||||
(if (mGameEntity.name != null) mGameEntity.name else "")!!,
|
||||
mGameEntity.categoryChinese
|
||||
context = mViewHolder.context,
|
||||
gameId = mGameEntity.id,
|
||||
gameName = (if (mGameEntity.name != null) mGameEntity.name else "")!!,
|
||||
gameType = mGameEntity.categoryChinese,
|
||||
gameFormat = mGameEntity.getApk().firstOrNull()?.format
|
||||
) {
|
||||
if (mDownloadEntity != null) {
|
||||
val path = mDownloadEntity!!.path
|
||||
@ -303,7 +304,8 @@ class DetailViewHolder(
|
||||
context = mViewHolder.context,
|
||||
gameId = mGameEntity.id,
|
||||
gameName = mGameEntity.name ?: "",
|
||||
gameType = mGameEntity.categoryChinese
|
||||
gameType = mGameEntity.categoryChinese,
|
||||
gameFormat = mGameEntity.getApk().firstOrNull()?.format
|
||||
) {
|
||||
DownloadDialog.showDownloadDialog(
|
||||
context = mViewHolder.context,
|
||||
@ -364,7 +366,8 @@ class DetailViewHolder(
|
||||
context = mViewHolder.context,
|
||||
gameId = mGameEntity.id,
|
||||
gameName = (if (mGameEntity.name != null) mGameEntity.name else "")!!,
|
||||
gameType = mGameEntity.categoryChinese
|
||||
gameType = mGameEntity.categoryChinese,
|
||||
gameFormat = mGameEntity.getApk().firstOrNull()?.format
|
||||
) {
|
||||
if (mDownloadEntity == null) {
|
||||
mDownloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(mGameEntity)
|
||||
@ -505,7 +508,7 @@ class DetailViewHolder(
|
||||
}
|
||||
if (mDownloadEntity != null) {
|
||||
if (downloadButton.text.contains("继续加载")) {
|
||||
DownloadManager.getInstance().resume(mDownloadEntity, true)
|
||||
DownloadManager.getInstance().resume(mDownloadEntity, false)
|
||||
} else {
|
||||
DownloadManager.getInstance().pause(mDownloadEntity!!.url)
|
||||
downloadButton.text = "继续加载 " + mDownloadEntity!!.percent + "%"
|
||||
|
||||
@ -10,6 +10,9 @@ import com.gh.gamecenter.common.utils.toColor
|
||||
import com.gh.gamecenter.databinding.GameHeadItemBinding
|
||||
import com.gh.gamecenter.entity.SubjectEntity
|
||||
|
||||
/**
|
||||
* 专题头部
|
||||
*/
|
||||
class GameHeadViewHolder(var binding: GameHeadItemBinding) :
|
||||
BaseRecyclerViewHolder<Any>(binding.root) {
|
||||
|
||||
@ -66,7 +69,7 @@ class GameHeadViewHolder(var binding: GameHeadItemBinding) :
|
||||
if (binding.headMore.visibility == View.VISIBLE && (binding.headMore.text == "更多" || binding.headMore.text == "全部" || binding.headMore.text == "游戏单广场")) {
|
||||
binding.arrowIv.visibility = View.VISIBLE
|
||||
}
|
||||
binding.headTitle.setTextColor(R.color.text_title.toColor(binding.root.context))
|
||||
binding.headTitle.setTextColor(R.color.text_primary.toColor(binding.root.context))
|
||||
binding.adLabelTv.goneIf(!subject.adIconActive)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,15 +1,18 @@
|
||||
package com.gh.gamecenter.adapter.viewholder
|
||||
|
||||
import com.facebook.drawee.generic.RoundingParams
|
||||
import com.gh.gamecenter.common.base.BaseRecyclerViewHolder
|
||||
import com.gh.common.databind.BindingAdapters
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.BaseRecyclerViewHolder
|
||||
import com.gh.gamecenter.common.utils.ImageUtils
|
||||
import com.gh.gamecenter.common.utils.goneIf
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.databinding.GameImageItemBinding
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
|
||||
/**
|
||||
* 游戏专题-大图-显示/只显示
|
||||
*/
|
||||
class GameImageViewHolder(var binding: GameImageItemBinding) : BaseRecyclerViewHolder<Any>(binding.root) {
|
||||
|
||||
// 注意:专题详情的大图不能用此方法
|
||||
|
||||
@ -65,7 +65,7 @@ public class GameViewHolder extends RecyclerView.ViewHolder {
|
||||
gameServerType.setText(serverLabel.getValue());
|
||||
if (gameEntity.isUseDefaultServerStyle()) {
|
||||
gameServerType.setBackground(ExtensionsKt.toDrawable(R.drawable.server_label_default_bg));
|
||||
gameServerType.setTextColor(ExtensionsKt.toColor(R.color.text_server_label));
|
||||
gameServerType.setTextColor(ExtensionsKt.toColor(R.color.text_secondary));
|
||||
} else {
|
||||
gameServerType.setBackground(DrawableView.getServerDrawable(serverLabel.getColor()));
|
||||
gameServerType.setTextColor(ExtensionsKt.toColor(R.color.white));
|
||||
|
||||
@ -215,8 +215,8 @@ class AmwayAdapter(
|
||||
binding.gameContainer.background = R.drawable.selector_f8f8f8.toDrawable(context)
|
||||
binding.commentContainer.background = R.drawable.selector_f8f8f8.toDrawable(context)
|
||||
binding.gameNameTv.setTextColor(R.color.title.toColor(context))
|
||||
binding.ratingTv.setTextColor(R.color.theme_font.toColor(context))
|
||||
binding.tagTv.setTextColor(R.color.text_subtitleDesc.toColor(context))
|
||||
binding.ratingTv.setTextColor(R.color.text_theme.toColor(context))
|
||||
binding.tagTv.setTextColor(R.color.text_tertiary.toColor(context))
|
||||
binding.amwayContentTv.setTextColor(R.color.text_3a3a3a.toColor(context))
|
||||
binding.userNameTv.setTextColor(R.color.title.toColor(context))
|
||||
binding.likeCountTv.setTextColor(R.color.text_B3B3B3.toColor(context))
|
||||
@ -233,7 +233,7 @@ class AmwayAdapter(
|
||||
val m = Pattern.compile(RatingEditActivity.LABEL_REGEX).matcher(amway.comment.content)
|
||||
if (m.find()) {
|
||||
val contents =
|
||||
TextHelper.getCommentLabelSpannableStringBuilder(amway.comment.content, R.color.theme_font)
|
||||
TextHelper.getCommentLabelSpannableStringBuilder(amway.comment.content, R.color.text_theme)
|
||||
binding.amwayContentTv.setTextWithHighlightedTextWrappedInsideWrapper(contents, copyClickedText = true)
|
||||
} else {
|
||||
binding.amwayContentTv.setTextWithHighlightedTextWrappedInsideWrapper(
|
||||
@ -311,7 +311,7 @@ class AmwayAdapter(
|
||||
|
||||
if (amway.comment.me.isVoted) {
|
||||
binding.likeIv.isChecked = true
|
||||
binding.likeCountTv.setTextColor(R.color.theme_font.toColor(binding.likeCountTv.context))
|
||||
binding.likeCountTv.setTextColor(R.color.text_theme.toColor(binding.likeCountTv.context))
|
||||
binding.likeClickableView.setOnClickListener {
|
||||
debounceActionWithInterval(binding.likeClickableView.id, 1000L) {
|
||||
binding.likeIv.context.ifLogin("安利墙-取消点赞") {
|
||||
@ -357,7 +357,7 @@ class AmwayAdapter(
|
||||
likeIv: CheckableImageView,
|
||||
likeAnimView: LottieAnimationView
|
||||
) {
|
||||
likeTv.setTextColor(R.color.theme_font.toColor(likeTv.context))
|
||||
likeTv.setTextColor(R.color.text_theme.toColor(likeTv.context))
|
||||
likeIv.isChecked = true
|
||||
likeIv.visibility = View.INVISIBLE
|
||||
likeAnimView.visibility = View.VISIBLE
|
||||
|
||||
@ -354,13 +354,13 @@ class AmwayFragment : LazyListFragment<AmwayListItemData, AmwayViewModel>() {
|
||||
mAlternativeBinding?.firstBackground?.goneIf(mIsDarkModeOn)
|
||||
mAlternativeBinding?.secondBackground?.goneIf(mIsDarkModeOn)
|
||||
mAlternativeBinding?.topBackgroundView?.goneIf(mIsDarkModeOn)
|
||||
mAlternativeBinding?.listRefresh?.setBackgroundColor(R.color.background.toColor(requireContext()))
|
||||
mAlternativeBinding?.listRefresh?.setBackgroundColor(R.color.ui_background.toColor(requireContext()))
|
||||
onScrollChanged()
|
||||
} else {
|
||||
mDefaultBinding?.nightMaskView?.goneIf(!mIsDarkModeOn)
|
||||
mDefaultBinding?.appbar?.setBackgroundColor(R.color.background_white.toColor(requireContext()))
|
||||
mDefaultBinding?.collapsingToolbar?.setContentScrimColor(R.color.background_white.toColor(requireContext()))
|
||||
mDefaultBinding?.listRefresh?.setBackgroundColor(R.color.background.toColor(requireContext()))
|
||||
mDefaultBinding?.appbar?.setBackgroundColor(R.color.ui_surface.toColor(requireContext()))
|
||||
mDefaultBinding?.collapsingToolbar?.setContentScrimColor(R.color.ui_surface.toColor(requireContext()))
|
||||
mDefaultBinding?.listRefresh?.setBackgroundColor(R.color.ui_background.toColor(requireContext()))
|
||||
}
|
||||
if (mIsFromMainWrapper) {
|
||||
DisplayUtils.setLightStatusBar(requireActivity(), !mIsDarkModeOn && mIsCollapsed)
|
||||
|
||||
@ -64,7 +64,7 @@ class AmwaySearchDefaultFragment : SearchDefaultFragment() {
|
||||
headTitle.text = getString(R.string.search_history)
|
||||
headTitle.textSize = 16F
|
||||
headActionTv.text = "清空"
|
||||
headActionTv.setTextColor(R.color.text_subtitleDesc.toColor(requireContext()))
|
||||
headActionTv.setTextColor(R.color.text_tertiary.toColor(requireContext()))
|
||||
headActionTv.setDrawableStart(
|
||||
AppCompatResources.getDrawable(
|
||||
requireContext(),
|
||||
|
||||
@ -29,10 +29,10 @@ class AmwaySearchViewHolder(var binding: AmwaySearchItemBinding, val mViewModel:
|
||||
binding.hintTv.goneIf(gameEntity.showComment)
|
||||
|
||||
if (gameEntity.showComment) {
|
||||
binding.nameTv.setTextColor(ContextCompat.getColor(binding.root.context, R.color.text_title))
|
||||
binding.nameTv.setTextColor(ContextCompat.getColor(binding.root.context, R.color.text_primary))
|
||||
binding.nameTv.setTypeface(binding.nameTv.typeface, Typeface.BOLD)
|
||||
} else {
|
||||
binding.nameTv.setTextColor(ContextCompat.getColor(binding.root.context, R.color.text_subtitleDesc))
|
||||
binding.nameTv.setTextColor(ContextCompat.getColor(binding.root.context, R.color.text_tertiary))
|
||||
binding.nameTv.setTypeface(binding.nameTv.typeface, Typeface.NORMAL)
|
||||
}
|
||||
|
||||
|
||||
@ -73,7 +73,7 @@ class AuthorizationActivity : ToolBarActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
DisplayUtils.transparentStatusBar(this)
|
||||
setNavigationTitle("光环助手授权登陆")
|
||||
updateStatusBarColor(R.color.background_white, R.color.background_white)
|
||||
updateStatusBarColor(R.color.ui_surface, R.color.ui_surface)
|
||||
mBinding = ActivityAuthorizationBinding.bind(mContentView)
|
||||
checkParam()
|
||||
initView()
|
||||
@ -102,7 +102,7 @@ class AuthorizationActivity : ToolBarActivity() {
|
||||
|
||||
override fun onDarkModeChanged() {
|
||||
super.onDarkModeChanged()
|
||||
updateStatusBarColor(R.color.background_white, R.color.background_white)
|
||||
updateStatusBarColor(R.color.ui_surface, R.color.ui_surface)
|
||||
}
|
||||
|
||||
override fun onRestart() {
|
||||
|
||||
@ -13,7 +13,7 @@ class CatalogActivity : DownloadToolbarActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setToolbarMenu(R.menu.menu_download)
|
||||
updateStatusBarColor(R.color.background_white, R.color.background_white)
|
||||
updateStatusBarColor(R.color.ui_surface, R.color.ui_surface)
|
||||
}
|
||||
|
||||
override fun showDownloadMenu(): Boolean {
|
||||
@ -26,7 +26,7 @@ class CatalogActivity : DownloadToolbarActivity() {
|
||||
|
||||
override fun onDarkModeChanged() {
|
||||
super.onDarkModeChanged()
|
||||
updateStatusBarColor(R.color.background_white, R.color.background_white)
|
||||
updateStatusBarColor(R.color.ui_surface, R.color.ui_surface)
|
||||
}
|
||||
|
||||
override fun isAutoResetViewBackgroundEnabled() = true
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user