Compare commits
316 Commits
v5.30.0-95
...
v5.32.2-99
| Author | SHA1 | Date | |
|---|---|---|---|
| 2393dc2291 | |||
| cb94bc9f29 | |||
| a60442db41 | |||
| 9691344e67 | |||
| 41ba8c3e5a | |||
| b203d3a756 | |||
| 28bca22d93 | |||
| 905571a637 | |||
| dc9ac67e6e | |||
| 8c1d4a3778 | |||
| 7189261c01 | |||
| 86c1781426 | |||
| 4812e9258b | |||
| b906fe7b47 | |||
| 846fd7222e | |||
| 1afabdfd94 | |||
| 8ed2a13884 | |||
| cd13c98ac2 | |||
| 2c49b468e6 | |||
| d175e895c3 | |||
| 1c0af1be7d | |||
| 62f5a479c9 | |||
| a87011d5b0 | |||
| c6c2213a88 | |||
| 9ede98deea | |||
| e46ec7c416 | |||
| d49c6bc3ca | |||
| 2bba43cf26 | |||
| 19f54bb8d2 | |||
| a167e7ff58 | |||
| ddd9032dbf | |||
| 1062522388 | |||
| b631c3437c | |||
| 5de5b005bf | |||
| 7d99db505b | |||
| 3b3e2e572e | |||
| 56eb40740a | |||
| d697bc7b8a | |||
| 95beddc194 | |||
| 5e3e4a88f5 | |||
| 75dabfef6b | |||
| e51e976385 | |||
| 28b9e14487 | |||
| 5ee1e823c5 | |||
| 11eee2eb0a | |||
| 42fa273d06 | |||
| 69dcd407b1 | |||
| 66722a313f | |||
| 81b0404999 | |||
| 79dadfeae6 | |||
| 601733f257 | |||
| 48a6bd0d2e | |||
| dfb89980fe | |||
| e7d4c598a3 | |||
| d6d0bea491 | |||
| 1f05d6e0ba | |||
| c995846db7 | |||
| 964b2afaae | |||
| 7cd4a45915 | |||
| 707361e660 | |||
| b427418ec6 | |||
| 580a00e1a9 | |||
| 1e13ae4815 | |||
| e18aeb92dd | |||
| 24aaeeee7f | |||
| a70a397199 | |||
| 7f4d06fbe1 | |||
| 690ca33702 | |||
| cf6a80dd0d | |||
| c409b755cf | |||
| 0399a0cc91 | |||
| c28d6f3080 | |||
| 56501f9f33 | |||
| ebcf2aaa9e | |||
| 0f9f3dc073 | |||
| 8c92da2ceb | |||
| 671c59a9de | |||
| adcb8a4693 | |||
| 95d87858f1 | |||
| 0a463b0ddd | |||
| 2da4230d8c | |||
| b00fda2289 | |||
| 86790e7b69 | |||
| 80ea7303f8 | |||
| 700831ba26 | |||
| e35950ad89 | |||
| 7be72e76f2 | |||
| 6d5b0eb1e8 | |||
| 0dcf5d2097 | |||
| 32e584c04c | |||
| f726a4629f | |||
| fbe29d82be | |||
| a6c2254db3 | |||
| 3d4977dc87 | |||
| 4d0fda6157 | |||
| 34fb8ccf93 | |||
| 49b9c3a135 | |||
| bc04dcc94b | |||
| eb0bba47f9 | |||
| 9ba4e9c2cf | |||
| 3a69bb4452 | |||
| 0581ebf409 | |||
| 44607a9039 | |||
| 00db8c00c6 | |||
| c64713117e | |||
| 28e28d0775 | |||
| 6f53a67554 | |||
| f2b965b447 | |||
| 0ae4f745ee | |||
| bcfd9cdfef | |||
| 94ffe5a86f | |||
| c3ddd28bad | |||
| eab8bc846c | |||
| 05268442f8 | |||
| 55521e6f29 | |||
| db5b09cc11 | |||
| b0922b4c29 | |||
| 455ed32ac6 | |||
| fd92979481 | |||
| 3d322b29c1 | |||
| dcfc2f44cb | |||
| b809ae6687 | |||
| c575e589ae | |||
| 2af47af681 | |||
| b1228bdd2a | |||
| 4008c7fa4d | |||
| f2d714280b | |||
| 6862609bba | |||
| 3afae78477 | |||
| b03df595bc | |||
| c6f0825fb5 | |||
| cbc2902613 | |||
| db725a417d | |||
| 4270924d0f | |||
| 69fc206377 | |||
| 8468ec45c2 | |||
| 256a4c2b0a | |||
| 7d01e47c26 | |||
| 5814f468b3 | |||
| a5730e0ffd | |||
| 0dfd87db25 | |||
| 31aa16f155 | |||
| b22c6b9a5b | |||
| ffae0d1b1d | |||
| 5d8a31c725 | |||
| 1c35982db0 | |||
| 52f71dc79e | |||
| f1c0155379 | |||
| 19dc23d98a | |||
| 69c82ec0e6 | |||
| b1a9d96c3b | |||
| a88500576f | |||
| 058eaf0a4a | |||
| 1b326a0515 | |||
| 3fc1fd821a | |||
| b3af44cc4c | |||
| 44c1711be7 | |||
| c616df87ea | |||
| dd7072eea4 | |||
| 4ee463f03e | |||
| d3dc31eeaf | |||
| 08b364a626 | |||
| 9e6d1e5fbd | |||
| 75a21ee04e | |||
| 27d13d4ce9 | |||
| 16526ddfbd | |||
| d6e676300e | |||
| 7852972e01 | |||
| 6ff76ea1ed | |||
| 39d51ceeb3 | |||
| 00fc6e447c | |||
| 76fff608ed | |||
| 460409ac30 | |||
| 80403e1684 | |||
| ef32fd946b | |||
| 23d57c8bbd | |||
| c46b93769d | |||
| 2305229919 | |||
| 0e9453b1b2 | |||
| 420290bc87 | |||
| 91be2cea1d | |||
| 4dc3a8edc3 | |||
| 5ba9c74583 | |||
| a694e401d3 | |||
| a6cb0b9fa0 | |||
| 9b599fd28d | |||
| f04fecc11e | |||
| 471e28099b | |||
| 5a3031ae87 | |||
| 1421f27bd3 | |||
| e9e152eeee | |||
| aae6904e4b | |||
| db7fbe057e | |||
| 042508e8e6 | |||
| af5736f54d | |||
| 56816fa682 | |||
| 05e0609f94 | |||
| 7a080851ae | |||
| e1ce989d43 | |||
| 6e00a0c2a6 | |||
| 71318fa9ef | |||
| 05b4896d6e | |||
| 7f40e45ef2 | |||
| 2928c59b87 | |||
| ceb2442f3f | |||
| cec684c325 | |||
| b5e4bf772b | |||
| 9f3fe9e30d | |||
| c7174bbaec | |||
| de013e0129 | |||
| 412ea87668 | |||
| dc40f81ff2 | |||
| 25c849ccad | |||
| 927c846bcb | |||
| fcd13ba8b0 | |||
| bccd161762 | |||
| 776dfddc34 | |||
| b31b529ca7 | |||
| 1cc2f5387a | |||
| 5c79a01cc6 | |||
| 1e3704c1ed | |||
| 41340f7333 | |||
| e73fc09d9b | |||
| d593c54262 | |||
| b1e5d48098 | |||
| f9d652d629 | |||
| 77ee092b5b | |||
| 0a61d29f37 | |||
| c65147e309 | |||
| 1ff2bb0bcc | |||
| f8ce9ffc90 | |||
| 42366a8591 | |||
| 5dbf29a09d | |||
| 9621a62ed6 | |||
| 07f320db27 | |||
| 89ecf09b55 | |||
| 2cfb227c22 | |||
| 285ec88d01 | |||
| 1f86e7b32d | |||
| f34adc8e6d | |||
| 8606c8f87a | |||
| caf2dbacf9 | |||
| df6c87eed2 | |||
| 2894a964ea | |||
| 421baf2889 | |||
| 040901f9df | |||
| 9587336b31 | |||
| e1c2b2027a | |||
| c5ff26c879 | |||
| 9690a695d4 | |||
| 78e9c43f24 | |||
| 2d9af85b62 | |||
| 35c71c70c9 | |||
| 70e63ed8e3 | |||
| b7a36074ed | |||
| 0cb7e4c9a1 | |||
| 152b9add80 | |||
| ab27ca5256 | |||
| 90545415ae | |||
| 8018517207 | |||
| c79128d6f4 | |||
| 141d179a64 | |||
| 0a9471fc2e | |||
| ce3d594a4e | |||
| 553f84daa1 | |||
| 70f782cb5c | |||
| 28725ae76f | |||
| b0972f1a80 | |||
| 585660e52d | |||
| 20998852b6 | |||
| 929a2c4d29 | |||
| f0fd323107 | |||
| 00892e831a | |||
| a55fcdcb28 | |||
| 548a34c66d | |||
| 55f51284c8 | |||
| 079dac80f8 | |||
| b33fee6ec0 | |||
| 2c1fdae6c7 | |||
| 6a935b18e8 | |||
| 91c363fb55 | |||
| e1a65c5fce | |||
| 9fd6ce4e74 | |||
| 46df9cdccc | |||
| 339665f90f | |||
| 96d9d05eb9 | |||
| b1c848a7a6 | |||
| eb4d84bb48 | |||
| 04f72091e4 | |||
| 5d21d62140 | |||
| 0a7b646779 | |||
| 9f9a675f04 | |||
| 238220548a | |||
| dfc023a0cd | |||
| cbd9a5708b | |||
| 8b0a639196 | |||
| 75f164249f | |||
| fd72f01b1d | |||
| c17a55e33c | |||
| 1aded5ecf4 | |||
| d86dc7a03c | |||
| 9741334c2e | |||
| 48f762140b | |||
| eba7f31b32 | |||
| 38d91af306 | |||
| f2bf3df304 | |||
| c2b46ea5f2 | |||
| f12c0f8066 | |||
| 5f158f74e8 | |||
| 503376edc2 | |||
| 7490617191 | |||
| 13949e86c4 | |||
| 1207d53314 | |||
| f02b232589 | |||
| d61abd1174 | |||
| a460ae0788 |
@ -61,7 +61,7 @@ android_build:
|
||||
script:
|
||||
- export GRADLE_USER_HOME=/home/gitlab-runner/ci-build-cache/$CI_PROJECT_PATH/.gradle
|
||||
- chmod +x ./gradlew
|
||||
- ./scripts/jenkins_build.sh -c
|
||||
- ./scripts/jenkins_build.sh $CI_COMMIT_REF_NAME $BEFORE_COMMIT_SHA $CI_COMMIT_SHA
|
||||
#设置打包后的产物,用于job之间共享
|
||||
artifacts:
|
||||
paths:
|
||||
@ -71,8 +71,7 @@ android_build:
|
||||
exit_codes: 137
|
||||
only:
|
||||
- dev
|
||||
- dev-5.29.0
|
||||
- dev-5.30.0
|
||||
- dev-5.32.0
|
||||
|
||||
# 代码检查
|
||||
sonarqube_analysis:
|
||||
@ -103,8 +102,7 @@ sonarqube_analysis:
|
||||
exit_codes: 137
|
||||
only:
|
||||
- dev
|
||||
- dev-5.29.0
|
||||
- dev-5.30.0
|
||||
- dev-5.32.0
|
||||
|
||||
## 发送简易检测结果报告
|
||||
send_sonar_report:
|
||||
@ -122,12 +120,11 @@ send_sonar_report:
|
||||
exit_codes: 137
|
||||
only:
|
||||
- dev
|
||||
- dev-5.29.0
|
||||
- dev-5.30.0
|
||||
- dev-5.32.0
|
||||
|
||||
oss-upload&send-email:
|
||||
tags:
|
||||
- rancher-k8s
|
||||
- sysadm-devops
|
||||
stage: oss-upload&send-email
|
||||
image: hub.shanqu.cc/devops/android-apk-oss-upload:latest
|
||||
variables:
|
||||
@ -135,9 +132,9 @@ oss-upload&send-email:
|
||||
VAULT_ADDR: https://vault.shanqu.cc # 固定值
|
||||
VAULT_SECRET_PATH: prod/devops/android-apk-oss-upload # 固定值
|
||||
VAULT_ROLE: android-apk-oss-upload # 固定值
|
||||
ENDPOINT: "oss-cn-shenzhen-internal.aliyuncs.com" # 固定值
|
||||
BUCKET: "shanqu" # 固定值
|
||||
FILE_PATH: "app/build/tmp/" # APK 存放路径
|
||||
ENDPOINT: "tos-cn-guangzhou.ivolces.com" # 固定值
|
||||
BUCKET: "sysadm-public" # 固定值
|
||||
FILE_PATH: "app/build/tmp/" # APK 存放路径
|
||||
Email_To_List: $EMAIL_TO_LIST # 邮件接受人列表
|
||||
Email_Title: "光环助手 $CI_COMMIT_BRANCH" # 邮件标题
|
||||
PIPELINE_ID: $CI_PIPELINE_ID # 流水线id
|
||||
@ -152,8 +149,7 @@ oss-upload&send-email:
|
||||
### 开启上传 ###
|
||||
- /usr/local/bin/python /upload.py
|
||||
### 发送邮件
|
||||
- /usr/local/bin/python /ci-android-mail.py
|
||||
- /usr/local/bin/python /ci-android-mail-jira-comment.py
|
||||
only:
|
||||
- dev
|
||||
- dev-5.29.0
|
||||
- dev-5.30.0
|
||||
- dev-5.32.0
|
||||
20
README.md
20
README.md
@ -30,14 +30,7 @@
|
||||
|
||||
### git 版本管理
|
||||
|
||||
本项目使用简化版的 git flow 来管理分支,细节请看 [光环安卓简单 git 规范](https://git.ghzs.com/halo/android/assistant-android/-/wikis/%E5%85%89%E7%8E%AF%E5%AE%89%E5%8D%93%E7%AE%80%E5%8D%95-git-%E8%A7%84%E8%8C%83)
|
||||
|
||||
### API 环境配置
|
||||
|
||||
本项目使用 Build Variants 来切换 API 环境
|
||||
|
||||
* internal 为测试环境
|
||||
* publish 为正式环境
|
||||
本项目使用简化版的 git flow 来管理分支,细节请看 [光环安卓简单 git 规范](https://git.shanqu.cc/halo/android/assistant-android/-/wikis/%E5%85%89%E7%8E%AF%E5%AE%89%E5%8D%93%E7%AE%80%E5%8D%95-git-%E8%A7%84%E8%8C%83)
|
||||
|
||||
### 图片资源配置
|
||||
|
||||
@ -53,14 +46,3 @@
|
||||
|
||||
* 本项目使用了微信的 [AndResGuard](https://github.com/shwenzhang/AndResGuard) 作为资源混淆压缩方案,新增需要使用 `getIdentifier` 获取的资源文件时需要添加至白名单
|
||||
* 本项目默认使用 R8 作为混淆工具,往 proguard-rules.txt 添加 proguard 新配置项时请检查可用性(如语法等)
|
||||
|
||||
### APK打包配置
|
||||
|
||||
> 打内部测试包:`./scripts/test_build.sh`
|
||||
> 打邮件测试包:`./scripts/jenkins_build.sh`
|
||||
|
||||
### TODO
|
||||
|
||||
* 把原有 EventBus 的消息 Type 统一到一个文件内
|
||||
* 将实现细节从 View(Fragment、Activity) 剥离并以 MVVM 结构改造
|
||||
* 重构 MainActivity
|
||||
|
||||
@ -188,7 +188,8 @@ android {
|
||||
buildConfigField "String", "DEV_VAPI_HOST", "\"${DEV_VAPI_HOST}\""
|
||||
buildConfigField "String", "QUICK_LOGIN_APPID", "\"${DEV_QUICK_LOGIN_APPID}\""
|
||||
buildConfigField "String", "QUICK_LOGIN_APPKEY", "\"${DEV_QUICK_LOGIN_APPKEY}\""
|
||||
buildConfigField "String", "CSJ_APPID", "\"${DEV_CSJ_APPID}\""
|
||||
buildConfigField "String", "DEV_CSJ_APPID", "\"${DEV_CSJ_APPID}\""
|
||||
buildConfigField "String", "CSJ_APPID", "\"${CSJ_APPID}\""
|
||||
}
|
||||
|
||||
// publish, 发布时候使用的 flavor,接口仅包含正式环境
|
||||
@ -200,6 +201,7 @@ android {
|
||||
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}\""
|
||||
}
|
||||
|
||||
@ -211,6 +213,7 @@ android {
|
||||
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}\""
|
||||
|
||||
manifestPlaceholders.put("APPLOG_SCHEME", "rangersapplog.byAx6uYt".toLowerCase())
|
||||
@ -224,6 +227,7 @@ android {
|
||||
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}\""
|
||||
}
|
||||
|
||||
@ -235,6 +239,7 @@ android {
|
||||
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}\""
|
||||
}
|
||||
}
|
||||
@ -337,7 +342,10 @@ dependencies {
|
||||
implementation(project(':module_core_feature')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
implementation(project(':module_feedback')) {
|
||||
// implementation(project(':module_feedback')) {
|
||||
// exclude group: 'androidx.swiperefreshlayout'
|
||||
// }
|
||||
implementation(project(':feature:new_feedback',)) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
implementation(project(':module_sensors_data')) {
|
||||
@ -356,6 +364,7 @@ dependencies {
|
||||
implementation(project(':feature:qq_game')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
internalImplementation(project(':module_internal_test'))
|
||||
}
|
||||
|
||||
File propFile = file('sign.properties')
|
||||
|
||||
@ -92,3 +92,7 @@
|
||||
native <methods>;
|
||||
}
|
||||
|
||||
-keepclassmembernames class com.contrarywind.view.WheelView {
|
||||
private int itemsVisible;
|
||||
}
|
||||
|
||||
|
||||
32
app/src/internal/java/com/gh/vspace/ExternalGameUsage.kt
Normal file
32
app/src/internal/java/com/gh/vspace/ExternalGameUsage.kt
Normal file
@ -0,0 +1,32 @@
|
||||
package com.gh.vspace
|
||||
|
||||
import android.content.Intent
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.Keep
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.databinding.LayoutPersonalOtherItemBinding
|
||||
import com.gh.vspace.installexternalgames.InstallExternalGameActivity
|
||||
|
||||
@Keep
|
||||
class ExternalGameUsage : IExternalGamesUsage {
|
||||
override fun addInstallExternalGameButton(viewParent: ViewGroup) {
|
||||
val context = viewParent.context
|
||||
viewParent.findViewById<View>(R.id.install_game_from_external) ?: run {
|
||||
val binding = LayoutPersonalOtherItemBinding.inflate(LayoutInflater.from(context)).apply {
|
||||
root.id = R.id.install_game_from_external
|
||||
titleTv.text = context.getString(R.string.title_install_external_game)
|
||||
iconIv.setImageResource(R.drawable.ic_personal_my_game)
|
||||
root.setOnClickListener {
|
||||
VHelper.connectService {
|
||||
context.startActivity(
|
||||
InstallExternalGameActivity.getIntent(context)
|
||||
.apply { flags = flags or Intent.FLAG_ACTIVITY_NEW_TASK })
|
||||
}
|
||||
}
|
||||
}
|
||||
viewParent.addView(binding.root, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
package com.gh.vspace.installexternalgames;
|
||||
|
||||
public class Constants {
|
||||
public static final String TAG = "从SD卡安装";
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package com.gh.vspace.installexternalgames
|
||||
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.gamecenter.common.utils.goneIf
|
||||
import com.gh.gamecenter.common.utils.toBinding
|
||||
|
||||
class ExternalGameAdapter(private val games: List<ExternalGameUiState>, private val onItemClickListener: OnItemClickListener) :
|
||||
RecyclerView.Adapter<ExternalGameViewHolder>() {
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ExternalGameViewHolder {
|
||||
return ExternalGameViewHolder(parent.toBinding())
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return games.size
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ExternalGameViewHolder, position: Int) {
|
||||
val item = games[position]
|
||||
holder.apkInfo.text = item.externalGameEntity.let { item ->
|
||||
"""
|
||||
应用程序名:${item.appName}
|
||||
版本号:${item.apkVersion}
|
||||
包名: ${item.apkPackageName}
|
||||
路径:${item.apkPath}
|
||||
""".trimIndent()
|
||||
}
|
||||
holder.install.goneIf(item.isInstalled) {
|
||||
holder.install.setOnClickListener {
|
||||
onItemClickListener.onItemClick(item, OnItemClickListener.ClickType.CLICK_INSTALL)
|
||||
}
|
||||
}
|
||||
holder.uninstall.goneIf(!item.isInstalled) {
|
||||
holder.uninstall.setOnClickListener {
|
||||
onItemClickListener.onItemClick(
|
||||
item,
|
||||
OnItemClickListener.ClickType.CLICK_UNINSTALL
|
||||
)
|
||||
}
|
||||
}
|
||||
holder.start.goneIf(!item.isInstalled) {
|
||||
holder.start.setOnClickListener {
|
||||
onItemClickListener.onItemClick(item, OnItemClickListener.ClickType.CLICK_START)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.gh.vspace.installexternalgames
|
||||
|
||||
data class ExternalGameEntity(
|
||||
val cpuAbi: Set<String>,
|
||||
val apkPath: String,
|
||||
val apkFileName: String,
|
||||
val appName: String,
|
||||
val apkVersion: String,
|
||||
val apkPackageName: String,
|
||||
val lastModified: Long,
|
||||
)
|
||||
@ -0,0 +1,6 @@
|
||||
package com.gh.vspace.installexternalgames
|
||||
|
||||
data class ExternalGameUiState(
|
||||
val externalGameEntity: ExternalGameEntity,
|
||||
val isInstalled: Boolean
|
||||
)
|
||||
@ -0,0 +1,11 @@
|
||||
package com.gh.vspace.installexternalgames
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.gamecenter.databinding.LayoutExternalGameItemBinding
|
||||
|
||||
class ExternalGameViewHolder(binding: LayoutExternalGameItemBinding) : RecyclerView.ViewHolder(binding.root) {
|
||||
val apkInfo = binding.apkFileInfo
|
||||
val install = binding.btnInstall
|
||||
val uninstall = binding.btnUninstall
|
||||
val start = binding.btnStart
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.gh.vspace.installexternalgames
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.gh.gamecenter.common.base.activity.ToolBarActivity
|
||||
|
||||
class InstallExternalGameActivity : ToolBarActivity() {
|
||||
companion object {
|
||||
fun getIntent(context: Context): Intent {
|
||||
return getTargetIntent(context, InstallExternalGameActivity::class.java, InstallExternalGameFragment::class.java, Bundle())
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,153 @@
|
||||
package com.gh.vspace.installexternalgames
|
||||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.gh.common.util.DialogUtils
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.fragment.ToolbarFragment
|
||||
import com.gh.gamecenter.common.exposure.meta.MetaUtil
|
||||
import com.gh.gamecenter.common.utils.dip2px
|
||||
import com.gh.gamecenter.common.utils.toColor
|
||||
import com.gh.gamecenter.common.utils.viewModelProvider
|
||||
import com.gh.gamecenter.common.view.divider.HorizontalDividerItemDecoration
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.databinding.FragmentInstallExternalGamesBinding
|
||||
import com.gh.vspace.VHelper
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lg.vspace.VirtualAppManager
|
||||
import io.reactivex.Single
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
||||
class InstallExternalGameFragment : ToolbarFragment(), OnItemClickListener {
|
||||
|
||||
private val mViewModel: InstallExternalGameViewModel by lazy { viewModelProvider() }
|
||||
|
||||
private lateinit var mBinding: FragmentInstallExternalGamesBinding
|
||||
|
||||
private val games = mutableListOf<ExternalGameUiState>()
|
||||
private var adapter = ExternalGameAdapter(games, this)
|
||||
|
||||
private var uninstallDisposable: Disposable? = null
|
||||
|
||||
override fun getLayoutId() = 0
|
||||
|
||||
override fun getInflatedLayout() =
|
||||
FragmentInstallExternalGamesBinding.inflate(layoutInflater).apply { mBinding = this }.root
|
||||
|
||||
private lateinit var dialog: Dialog
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setNavigationTitle(getString(com.gh.gamecenter.R.string.title_install_external_game))
|
||||
initView()
|
||||
mViewModel.gamesList.observe(this) {
|
||||
if (dialog.isShowing) {
|
||||
dialog.dismiss()
|
||||
}
|
||||
games.clear()
|
||||
games.addAll(
|
||||
it.map {
|
||||
ExternalGameUiState(it, VHelper.isInstalled(it.apkPackageName))
|
||||
}
|
||||
)
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
mViewModel.scanPaths()
|
||||
|
||||
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
dialog = DialogUtils.showWaitDialog(requireContext(), "")
|
||||
mBinding.externalGamesList.let {
|
||||
it.adapter = adapter
|
||||
it.layoutManager = LinearLayoutManager(requireContext())
|
||||
val itemDecoration = HorizontalDividerItemDecoration.Builder(requireContext())
|
||||
.size(2F.dip2px())
|
||||
.color(R.color.divider.toColor(requireContext()))
|
||||
.build()
|
||||
if (it.itemDecorationCount != 0) {
|
||||
it.removeItemDecorationAt(0)
|
||||
}
|
||||
it.addItemDecoration(itemDecoration)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
if (dialog.isShowing) {
|
||||
dialog.dismiss()
|
||||
}
|
||||
if (uninstallDisposable?.isDisposed != true) {
|
||||
uninstallDisposable?.dispose()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onItemClick(externalGameUiState: ExternalGameUiState, clickType: OnItemClickListener.ClickType) {
|
||||
when (clickType) {
|
||||
OnItemClickListener.ClickType.CLICK_INSTALL -> {
|
||||
install(externalGameUiState)
|
||||
}
|
||||
OnItemClickListener.ClickType.CLICK_UNINSTALL -> {
|
||||
uninstall(externalGameUiState)
|
||||
}
|
||||
OnItemClickListener.ClickType.CLICK_START -> {
|
||||
start(externalGameUiState)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun install(externalGameUiState: ExternalGameUiState) {
|
||||
val bit =
|
||||
externalGameUiState.externalGameEntity.cpuAbi.let { if (it.size == 1 && it.contains("armeabi-v7a")) "32" else "64" }
|
||||
if (VHelper.showDialogIfVSpaceIsNeeded(
|
||||
requireContext(),
|
||||
"",
|
||||
externalGameUiState.externalGameEntity.appName,
|
||||
"",
|
||||
bit = bit
|
||||
)
|
||||
) return
|
||||
dialog.show()
|
||||
externalGameUiState.externalGameEntity.let {
|
||||
val intent = VirtualAppManager.getInstallIntent(context, it.apkPath, it.apkPackageName)
|
||||
requireActivity().startActivity(intent)
|
||||
}
|
||||
}
|
||||
|
||||
private fun uninstall(externalGameUiState: ExternalGameUiState) {
|
||||
dialog.show()
|
||||
uninstallDisposable = Single.create<Void> {
|
||||
VHelper.uninstall(externalGameUiState.externalGameEntity.apkPackageName)
|
||||
}.subscribeOn(Schedulers.from(AppExecutor.lightWeightIoExecutor)).observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe { t1, t2 ->
|
||||
if (dialog.isShowing) {
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun start(externalGameUiState: ExternalGameUiState) {
|
||||
val intent = VirtualAppManager.get().getStartGameIntent(
|
||||
externalGameUiState.externalGameEntity.apkPackageName,
|
||||
"",
|
||||
externalGameUiState.externalGameEntity.appName,
|
||||
"",
|
||||
MetaUtil.getBase64EncodedAndroidId(),
|
||||
HaloApp.getInstance().gid,
|
||||
com.gh.gamecenter.BuildConfig.VERSION_NAME,
|
||||
HaloApp.getInstance().channel,
|
||||
"",
|
||||
""
|
||||
)
|
||||
requireActivity().startActivity(intent)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
package com.gh.vspace.installexternalgames
|
||||
|
||||
import android.app.Application
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Environment
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.gh.gamecenter.core.runOnIoThread
|
||||
import com.gh.vspace.VHelper
|
||||
import com.lg.vspace.helper.compat.NativeLibraryHelperCompat
|
||||
import com.lightgame.utils.Utils
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
|
||||
class InstallExternalGameViewModel(application: Application) : AndroidViewModel(application) {
|
||||
private val _gamesList = MutableLiveData<List<ExternalGameEntity>>(listOf())
|
||||
val gamesList: LiveData<List<ExternalGameEntity>> = _gamesList
|
||||
private val pkgManger = getApplication<Application>().packageManager
|
||||
private var disposable: Disposable = VHelper.callSite.observeOn(AndroidSchedulers.mainThread()).subscribe {
|
||||
scanPaths()
|
||||
}
|
||||
|
||||
fun scanPaths() {
|
||||
runOnIoThread {
|
||||
_gamesList.postValue(Environment.getExternalStorageDirectory().walk().maxDepth(1)
|
||||
.filter { it.isHidden.not() }
|
||||
.filter { it.isFile }
|
||||
.onEach {
|
||||
Utils.log(Constants.TAG, "获得文件: ${it.name}")
|
||||
}
|
||||
.filter { it.extension == "apk" }
|
||||
.map {
|
||||
val packageInfo = pkgManger.getPackageArchiveInfo(
|
||||
it.absolutePath,
|
||||
PackageManager.GET_META_DATA or PackageManager.GET_ACTIVITIES
|
||||
)
|
||||
packageInfo?.let { packageInfo ->
|
||||
val applicationInfo = packageInfo.applicationInfo
|
||||
applicationInfo.publicSourceDir = it.absolutePath
|
||||
applicationInfo.sourceDir = it.absolutePath
|
||||
ExternalGameEntity(
|
||||
cpuAbi = NativeLibraryHelperCompat.getPackageAbiList(it.absolutePath),
|
||||
apkPath = it.absolutePath,
|
||||
apkFileName = it.name,
|
||||
apkPackageName = packageInfo.packageName,
|
||||
apkVersion = packageInfo.versionName,
|
||||
appName = pkgManger.getApplicationLabel(applicationInfo).toString(),
|
||||
lastModified = it.lastModified()
|
||||
)
|
||||
}
|
||||
}.filterNotNull()
|
||||
.toList().sortedByDescending { it.lastModified }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
disposable.dispose()
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.gh.vspace.installexternalgames
|
||||
|
||||
interface OnItemClickListener {
|
||||
|
||||
enum class ClickType {
|
||||
CLICK_INSTALL, CLICK_UNINSTALL, CLICK_START
|
||||
}
|
||||
|
||||
fun onItemClick(externalGameUiState: ExternalGameUiState, clickType: ClickType)
|
||||
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/external_games_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
43
app/src/internal/res/layout/layout_external_game_item.xml
Normal file
43
app/src/internal/res/layout/layout_external_game_item.xml
Normal file
@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/apk_file_info"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="20sp"
|
||||
tools:text="文件名:\n路径:" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_install"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/text_install"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_uninstall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/text_uninstall"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_start"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/text_start"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
4
app/src/internal/res/values/ids.xml
Normal file
4
app/src/internal/res/values/ids.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<item name="install_game_from_external" type="id" />
|
||||
</resources>
|
||||
7
app/src/internal/res/values/strings.xml
Normal file
7
app/src/internal/res/values/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>
|
||||
@ -78,6 +78,8 @@
|
||||
androidx.constraintlayout.compose,
|
||||
androidx.compose.ui.test.manifest,
|
||||
com.bytedance.sdk.openadsdk,
|
||||
com.bykv.vk.openvk,
|
||||
com.bytedance.tools,
|
||||
androidx.compose.ui.tooling.preview,
|
||||
com.tencent.qqmini,
|
||||
com.tencent.qqmini.minigame.external,
|
||||
@ -275,7 +277,7 @@
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.VoteActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateAlwaysHidden|adjustResize" />
|
||||
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.WeiBoShareActivity"
|
||||
@ -474,6 +476,14 @@
|
||||
android:name="com.gh.gamecenter.gamedetail.fuli.kaifu.ServersCalendarActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".gamedetail.fuli.kaifu.ServersCalendarManagementActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".gamedetail.fuli.kaifu.ServersSubscribedGameListActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".qa.answer.draft.AnswerDraftActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
@ -754,7 +764,11 @@
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.qgame.QGameSubjectActivity"
|
||||
android:name="com.gh.gamecenter.gamecollection.hotlist.GameCollectionListDetailActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.UserAuthActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
|
||||
|
||||
1
app/src/main/assets/lottie/video.json
Normal file
1
app/src/main/assets/lottie/video.json
Normal file
File diff suppressed because one or more lines are too long
@ -205,14 +205,17 @@ RE.setOutdent = function() {
|
||||
|
||||
RE.setJustifyLeft = function() {
|
||||
document.execCommand('justifyLeft', false, null);
|
||||
RE.enabledEditingItems()
|
||||
}
|
||||
|
||||
RE.setJustifyCenter = function() {
|
||||
document.execCommand('justifyCenter', false, null);
|
||||
RE.enabledEditingItems()
|
||||
}
|
||||
|
||||
RE.setJustifyRight = function() {
|
||||
document.execCommand('justifyRight', false, null);
|
||||
RE.enabledEditingItems()
|
||||
}
|
||||
|
||||
RE.setBlockquote = function() {
|
||||
@ -227,6 +230,16 @@ RE.insertImage = function(url) {
|
||||
RE.insertHTML(html);
|
||||
}
|
||||
|
||||
// 设置分割线
|
||||
RE.insertHorizontalRule = function() {
|
||||
document.execCommand('insertHorizontalRule', false, null);
|
||||
}
|
||||
|
||||
// 设置编辑器默认换行符
|
||||
RE.setDefaultParagraphSeparator = function(separator) {
|
||||
document.execCommand('defaultParagraphSeparator', false, separator);
|
||||
}
|
||||
|
||||
// 替换成缩略图
|
||||
RE.replaceTbImage = function(imgRuleFlag, gifRuleFlag) {
|
||||
var imgs = document.getElementsByTagName("img");
|
||||
@ -574,6 +587,10 @@ document.addEventListener("selectionchange", function(e) {
|
||||
RE.sendElementNameToNative()
|
||||
});
|
||||
|
||||
document.addEventListener("selectionchange", function(e) {
|
||||
RE.enabledEditingItems(e)
|
||||
});
|
||||
|
||||
RE.recursion = function(dom) {
|
||||
var parenDom = dom.parentElement
|
||||
if (parenDom && parenDom instanceof Element &&
|
||||
@ -616,7 +633,6 @@ RE.sendElementNameToNative = function() {
|
||||
// android function to open link
|
||||
function customLinkgo(self) {
|
||||
var datas = self.dataset.datas
|
||||
// console.log(datas)
|
||||
window.OnLinkClickListener.onClick(datas)
|
||||
}
|
||||
|
||||
|
||||
@ -30,7 +30,6 @@ body {
|
||||
}
|
||||
|
||||
#editor {
|
||||
display: table-cell;
|
||||
outline: 0px solid transparent;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
|
||||
@ -23,6 +23,7 @@ import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.activity.BaseActivity
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.common.exposure.ExposureSource
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.provider.IBeiziAdProvider
|
||||
@ -33,7 +34,6 @@ import com.gh.gamecenter.core.utils.TimeUtils.getToday
|
||||
import com.gh.gamecenter.entity.AdConfig
|
||||
import com.gh.gamecenter.entity.StartupAdEntity
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent.Companion.createEvent
|
||||
import com.gh.gamecenter.feature.exposure.ExposureSource
|
||||
import com.gh.gamecenter.feature.exposure.ExposureType
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
@ -60,12 +60,12 @@ object AdDelegateHelper {
|
||||
private val mGameSearchAdList: ArrayList<AdConfig> by lazy { arrayListOf() }
|
||||
private var mVGameLaunchAd: AdConfig? = null
|
||||
|
||||
private var mIsCsjRequired: Boolean = false // 是否需要初始化穿山甲 SDK
|
||||
private var mIsBeiziRequired: Boolean = false // 师傅需要初始化 Beizi SDK
|
||||
val vGameLaunchAd: AdConfig?
|
||||
get() = mVGameLaunchAd
|
||||
|
||||
private const val AD_SDK_CSJ = "穿山甲"
|
||||
private const val AD_SDK_BEIZI = "倍孜"
|
||||
private const val AD_TYPE_SDK = "third_party_ads" // 第三方 SDK 广告
|
||||
const val AD_TYPE_SDK = "third_party_ads" // 第三方 SDK 广告
|
||||
|
||||
private const val KEY_CACHE_CONFIG = "cache_config" // 放在 SP 里的广告缓存(避免接口加载问题)
|
||||
|
||||
@ -73,23 +73,49 @@ object AdDelegateHelper {
|
||||
HaloApp.getInstance().getSharedPreferences("AdConfig", Context.MODE_PRIVATE)
|
||||
}
|
||||
|
||||
var gameSearchKeyword = ""
|
||||
|
||||
fun initAdSdk(context: Context) {
|
||||
// 初始化 Beizi
|
||||
if (mBeiziAdImpl == null) {
|
||||
mBeiziAdImpl =
|
||||
ARouter.getInstance().build(RouteConsts.provider.beiziAd).navigation() as? IBeiziAdProvider
|
||||
mBeiziAdImpl?.initSDK(context)
|
||||
}
|
||||
|
||||
// 初始化穿山甲
|
||||
if (mCsjAdImpl == null) {
|
||||
mCsjAdImpl =
|
||||
ARouter.getInstance().build(RouteConsts.provider.csjAd).navigation() as? ICsjAdProvider
|
||||
val csjAppId = if (EnvHelper.isDevEnv) BuildConfig.DEV_CSJ_APPID else BuildConfig.CSJ_APPID
|
||||
mCsjAdImpl?.initSDK(context, csjAppId, HaloApp.getInstance().oaid)
|
||||
// 监听亮色/暗色模式切换
|
||||
DarkModeUtils.registerModeChangeListener {
|
||||
val topActivity = CurrentActivityHolder.getCurrentActivity() ?: return@registerModeChangeListener
|
||||
updateThemeStatus(context, DarkModeUtils.isDarkModeOn(topActivity))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求接口获取广告相关配置
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
fun requestAdConfig(context: Context, isFromRetry: Boolean) {
|
||||
fun requestAdConfig(isFromRetry: Boolean, keyword: String = "", callback: (() -> Unit)? = null) {
|
||||
// mAdConfigList 不为空不需要重试
|
||||
if (isFromRetry && mAdConfigList != null) {
|
||||
return
|
||||
}
|
||||
|
||||
val paramsMap = if (keyword.isNotEmpty()) mapOf("keyword" to keyword) else mapOf()
|
||||
RetrofitManager.getInstance()
|
||||
.newApi
|
||||
.adConfig
|
||||
.getAdConfig(paramsMap)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : BiResponse<List<AdConfig>>() {
|
||||
override fun onSuccess(data: List<AdConfig>) {
|
||||
handleAdConfig(context, data)
|
||||
gameSearchKeyword = keyword
|
||||
handleAdConfig(data)
|
||||
callback?.invoke()
|
||||
|
||||
// 缓存数据到 SP 供接口请求失败用
|
||||
SPUtils.setString(mAdConfigSp, KEY_CACHE_CONFIG, data.toJson())
|
||||
@ -101,8 +127,10 @@ object AdDelegateHelper {
|
||||
// 若接口请求失败时,从 SP 里获取上次缓存的数据
|
||||
val cachedConfig: List<AdConfig>? = SPUtils.getString(mAdConfigSp, KEY_CACHE_CONFIG).toObject()
|
||||
if (cachedConfig != null) {
|
||||
handleAdConfig(context, cachedConfig)
|
||||
handleAdConfig(cachedConfig)
|
||||
}
|
||||
|
||||
callback?.invoke()
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -124,48 +152,23 @@ object AdDelegateHelper {
|
||||
/**
|
||||
* 处理广告配置
|
||||
*/
|
||||
fun handleAdConfig(context: Context, configList: List<AdConfig>) {
|
||||
fun handleAdConfig(configList: List<AdConfig>) {
|
||||
mGameSearchAdList.clear()
|
||||
mSplashAd = null
|
||||
mDownloadManagerAd = null
|
||||
mVGameLaunchAd = null
|
||||
for (config in configList) {
|
||||
// 处理返回的数据
|
||||
when (config.location) {
|
||||
"halo_launch" -> mSplashAd = config
|
||||
"halo_launch" -> {
|
||||
config.ownerAd?.startAd?.let { it.id = config.ownerAd.id }
|
||||
mSplashAd = config
|
||||
}
|
||||
|
||||
"download_manager" -> mDownloadManagerAd = config
|
||||
"game_search" -> config.let { mGameSearchAdList.add(it) }
|
||||
"helper_launch" -> mVGameLaunchAd = config
|
||||
}
|
||||
|
||||
// 根据返回的值里判断是否含有 Beizi 的广告
|
||||
if (!mIsBeiziRequired) {
|
||||
if (config.thirdPartyAd?.sourceName == AD_SDK_BEIZI) {
|
||||
mIsBeiziRequired = true
|
||||
}
|
||||
}
|
||||
|
||||
// 根据返回的值里判断是否含有 穿山甲 的广告
|
||||
if (!mIsCsjRequired) {
|
||||
if (config.thirdPartyAd?.sourceName == AD_SDK_CSJ) {
|
||||
mIsCsjRequired = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化 Beizi
|
||||
if (mIsBeiziRequired && mBeiziAdImpl == null) {
|
||||
mBeiziAdImpl =
|
||||
ARouter.getInstance().build(RouteConsts.provider.beiziAd).navigation() as? IBeiziAdProvider
|
||||
mBeiziAdImpl?.initSDK(context)
|
||||
}
|
||||
|
||||
// 初始化穿山甲
|
||||
if (mIsCsjRequired && mCsjAdImpl == null) {
|
||||
mCsjAdImpl =
|
||||
ARouter.getInstance().build(RouteConsts.provider.csjAd).navigation() as? ICsjAdProvider
|
||||
mCsjAdImpl?.initSDK(context, BuildConfig.CSJ_APPID, HaloApp.getInstance().oaid)
|
||||
// 监听亮色/暗色模式切换
|
||||
DarkModeUtils.registerModeChangeListener {
|
||||
val topActivity = CurrentActivityHolder.getCurrentActivity() ?: return@registerModeChangeListener
|
||||
updateThemeStatus(context, DarkModeUtils.isDarkModeOn(topActivity))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -208,7 +211,12 @@ object AdDelegateHelper {
|
||||
} else {
|
||||
if (mSplashAd?.displayRule?.onFailedAction == "show") {
|
||||
sdkStartAdContainer.visibility = View.GONE
|
||||
requestStandardSplashAd(mSplashAd!!.ownerAd, startAdContainer, handler, hideCallback)
|
||||
requestStandardSplashAd(
|
||||
mSplashAd!!.ownerAd?.startAd,
|
||||
startAdContainer,
|
||||
handler,
|
||||
hideCallback
|
||||
)
|
||||
} else {
|
||||
hideCallback.invoke()
|
||||
}
|
||||
@ -238,7 +246,7 @@ object AdDelegateHelper {
|
||||
)
|
||||
}
|
||||
} else {
|
||||
requestStandardSplashAd(mSplashAd!!.ownerAd, startAdContainer, handler, hideCallback)
|
||||
requestStandardSplashAd(mSplashAd!!.ownerAd?.startAd, startAdContainer, handler, hideCallback)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -344,7 +352,9 @@ object AdDelegateHelper {
|
||||
val jumpBtn: View = startAdContainer.findViewById(R.id.jumpBtn)
|
||||
val jumpDetailBtn: TextView = startAdContainer.findViewById(R.id.jumpDetailBtn)
|
||||
val adImage: SimpleDraweeView = startAdContainer.findViewById(R.id.adImage)
|
||||
val icpContainer: View? = startAdContainer.findViewById(R.id.startAdIcpContainer)
|
||||
startAdContainer.visibility = View.VISIBLE
|
||||
icpContainer?.visibility = View.VISIBLE
|
||||
jumpDetailBtn.text = ad.desc
|
||||
jumpDetailBtn.setDrawableEnd(
|
||||
AppCompatResources.getDrawable(
|
||||
@ -388,9 +398,9 @@ object AdDelegateHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取信息流广告
|
||||
* 获取第三方信息流广告
|
||||
*/
|
||||
fun requestFlowAd(
|
||||
fun requestThirdPartyFlowAd(
|
||||
fragment: Fragment,
|
||||
slotId: String,
|
||||
adContainerView: ViewGroup,
|
||||
@ -401,9 +411,9 @@ object AdDelegateHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 Banner 广告
|
||||
* 获取第三方 Banner 广告
|
||||
*/
|
||||
fun requestBannerAd(
|
||||
fun requestThirdPartyBannerAd(
|
||||
fragment: Fragment,
|
||||
containerView: ViewGroup,
|
||||
ad: AdConfig.ThirdPartyAd,
|
||||
|
||||
@ -57,11 +57,16 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
private lateinit var mEditorFontItalic: CheckableImageView
|
||||
private lateinit var mEditorFontStrikeThrough: CheckableImageView
|
||||
private lateinit var mEditorFontUnderline: CheckableImageView
|
||||
private lateinit var mEditorParagraphDivider: CheckableImageView
|
||||
private lateinit var mEditorParagraphH1: CheckableImageView
|
||||
private lateinit var mEditorParagraphH2: CheckableImageView
|
||||
private lateinit var mEditorParagraphH3: CheckableImageView
|
||||
private lateinit var mEditorParagraphH4: CheckableImageView
|
||||
private lateinit var mEditorParagraphQuote: CheckableImageView
|
||||
private lateinit var mEditorAlignLeft: CheckableImageView
|
||||
private lateinit var mEditorAlignCenter: CheckableImageView
|
||||
private lateinit var mEditorAlignRight: CheckableImageView
|
||||
private lateinit var mEditorAlignContainer: View
|
||||
private lateinit var mEditorFontContainer: View
|
||||
private lateinit var mEditorParagraphContainer: View
|
||||
private lateinit var mEditorLinkContainer: View
|
||||
@ -97,6 +102,7 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
mRichEditor.insertCustomStyleLink(insertData)
|
||||
}
|
||||
}
|
||||
|
||||
INSERT_ARTICLE_CODE -> {
|
||||
val article =
|
||||
data?.getParcelableExtra<ArticleEntity>(ArticleEntity::class.java.simpleName)
|
||||
@ -106,6 +112,7 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
mRichEditor.insertCustomStyleLink(insertData)
|
||||
}
|
||||
}
|
||||
|
||||
INSERT_GAME_CODE -> {
|
||||
val game = data?.getParcelableExtra<GameEntity>(GameEntity::class.java.simpleName)
|
||||
if (game != null) {
|
||||
@ -114,6 +121,7 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
mRichEditor.insertCustomStyleLink(insertData)
|
||||
}
|
||||
}
|
||||
|
||||
INSERT_GAME_COLLECTION_CODE -> {
|
||||
val gameCollectionEntity =
|
||||
data?.getParcelableExtra<GamesCollectionEntity>(GamesCollectionEntity::class.java.simpleName)
|
||||
@ -123,9 +131,11 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
mRichEditor.insertCustomStyleLink(insertData)
|
||||
}
|
||||
}
|
||||
|
||||
REQUEST_CODE_IMAGE -> {
|
||||
if (data != null) mViewModel.uploadPic(data)
|
||||
}
|
||||
|
||||
INSERT_MEDIA_VIDEO_CODE -> {
|
||||
val localVideoList =
|
||||
data?.getParcelableArrayListExtra<LocalVideoEntity>(LocalVideoEntity::class.java.name)
|
||||
@ -135,12 +145,14 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
uploadVideo(localVideoList)
|
||||
}
|
||||
}
|
||||
|
||||
REQUEST_CODE_IMAGE_CROP -> {
|
||||
val imagePath = data?.getStringExtra(CropImageActivity.RESULT_CLIP_PATH)
|
||||
if (!imagePath.isNullOrEmpty()) {
|
||||
mViewModel.uploadPoster(imagePath)
|
||||
}
|
||||
}
|
||||
|
||||
INSERT_VIDEO_CODE -> {
|
||||
val videoEntity = data?.getParcelableExtra<MyVideoEntity>(MyVideoEntity::class.java.simpleName)
|
||||
if (videoEntity != null) {
|
||||
@ -194,7 +206,12 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
mEditorParagraphH2 = findViewById(R.id.editor_paragraph_h2)
|
||||
mEditorParagraphH3 = findViewById(R.id.editor_paragraph_h3)
|
||||
mEditorParagraphH4 = findViewById(R.id.editor_paragraph_h4)
|
||||
mEditorParagraphDivider = findViewById(R.id.editor_paragraph_divider)
|
||||
mEditorParagraphQuote = findViewById(R.id.editor_paragraph_quote)
|
||||
mEditorAlignLeft = findViewById(R.id.editor_align_left)
|
||||
mEditorAlignCenter = findViewById(R.id.editor_align_center)
|
||||
mEditorAlignRight = findViewById(R.id.editor_align_right)
|
||||
mEditorAlignContainer = findViewById(R.id.editor_align_container)
|
||||
mEditorFontContainer = findViewById(R.id.editor_font_container)
|
||||
mEditorParagraphContainer = findViewById(R.id.editor_paragraph_container)
|
||||
mEditorLinkContainer = findViewById(R.id.editor_link_container)
|
||||
@ -241,6 +258,13 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
mRichEditor.hasFocus()
|
||||
} else false
|
||||
}
|
||||
|
||||
mRichEditor.setOnDecorationChangeListener { _, types ->
|
||||
mEditorAlignLeft.isChecked = types.contains(RichEditor.Type.JUSTIFYLEFT)
|
||||
mEditorAlignCenter.isChecked = types.contains(RichEditor.Type.JUSTIFYCENTER)
|
||||
mEditorAlignRight.isChecked = types.contains(RichEditor.Type.JUSTIFYRIGHT)
|
||||
}
|
||||
|
||||
mOriginalCb.setOnCheckedChangeListener { _, isChecked ->
|
||||
if (isChecked) {
|
||||
mOriginalTipsContainer.alpha = 0f
|
||||
@ -325,6 +349,9 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
MtaHelper.onEvent(mtaEventName(), "文字样式", "文字样式-下滑线")
|
||||
}
|
||||
}
|
||||
mEditorParagraphDivider.setOnClickListener {
|
||||
mRichEditor.insertDivider()
|
||||
}
|
||||
mEditorParagraphH1.setOnClickListener {
|
||||
if (mEditorParagraphH1.isChecked) {
|
||||
mRichEditor.formatBlock()
|
||||
@ -370,6 +397,27 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
}
|
||||
mEditorParagraphQuote.isChecked = !mEditorParagraphQuote.isChecked
|
||||
}
|
||||
mEditorAlignLeft.setOnClickListener {
|
||||
if (!mEditorAlignLeft.isChecked) {
|
||||
mRichEditor.setAlignLeft()
|
||||
MtaHelper.onEvent(mtaEventName(), "文本对齐选项", "文本对齐选项-靠左")
|
||||
mEditorAlignLeft.isChecked = !mEditorAlignLeft.isChecked
|
||||
}
|
||||
}
|
||||
mEditorAlignCenter.setOnClickListener {
|
||||
if (!mEditorAlignCenter.isChecked) {
|
||||
mRichEditor.setAlignCenter()
|
||||
MtaHelper.onEvent(mtaEventName(), "文本对齐选项", "文本对齐选项-靠中")
|
||||
mEditorAlignCenter.isChecked = !mEditorAlignCenter.isChecked
|
||||
}
|
||||
}
|
||||
mEditorAlignRight.setOnClickListener {
|
||||
if (!mEditorAlignRight.isChecked) {
|
||||
mRichEditor.setAlignRight()
|
||||
MtaHelper.onEvent(mtaEventName(), "文本对齐选项", "文本对齐选项-靠右")
|
||||
mEditorAlignRight.isChecked = !mEditorAlignRight.isChecked
|
||||
}
|
||||
}
|
||||
findViewById<View>(R.id.editor_link_answer).setOnClickListener {
|
||||
MtaHelper.onEvent(mtaEventName(), "插入链接", "插入链接-回答")
|
||||
startActivityForResult(
|
||||
@ -449,25 +497,22 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
return
|
||||
}
|
||||
try {
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(this,
|
||||
object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
val maxChooseCount = if (videoCount + 3 <= MAX_MEDIA_COUNT) 3 else MAX_MEDIA_COUNT - videoCount
|
||||
startActivityForResult(
|
||||
LocalMediaActivity.getIntent(
|
||||
this@BaseRichEditorActivity,
|
||||
LocalMediaActivity.ChooseType.VIDEO,
|
||||
maxChooseCount,
|
||||
if (mtaEventName() == "提问帖") "发提问帖" else "发帖子"
|
||||
), INSERT_MEDIA_VIDEO_CODE
|
||||
)
|
||||
NewLogUtils.logChooseMedia(
|
||||
"view_media",
|
||||
if (mtaEventName() == "提问帖") "提问帖" else "帖子",
|
||||
"视频"
|
||||
)
|
||||
}
|
||||
})
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(this) {
|
||||
val maxChooseCount = if (videoCount + 3 <= MAX_MEDIA_COUNT) 3 else MAX_MEDIA_COUNT - videoCount
|
||||
startActivityForResult(
|
||||
LocalMediaActivity.getIntent(
|
||||
this@BaseRichEditorActivity,
|
||||
LocalMediaActivity.ChooseType.VIDEO,
|
||||
maxChooseCount,
|
||||
if (mtaEventName() == "提问帖") "发提问帖" else "发帖子"
|
||||
), INSERT_MEDIA_VIDEO_CODE
|
||||
)
|
||||
NewLogUtils.logChooseMedia(
|
||||
"view_media",
|
||||
if (mtaEventName() == "提问帖") "提问帖" else "帖子",
|
||||
"视频"
|
||||
)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
toast(R.string.media_image_hint)
|
||||
e.printStackTrace()
|
||||
@ -482,18 +527,16 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
return
|
||||
}
|
||||
try {
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(this, object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
val maxChooseCount = if (imageCount + 10 <= MAX_IMAGE_COUNT) 10 else MAX_IMAGE_COUNT - imageCount
|
||||
val intent = LocalMediaActivity.getIntent(
|
||||
this@BaseRichEditorActivity,
|
||||
LocalMediaActivity.ChooseType.IMAGE,
|
||||
maxChooseCount,
|
||||
if (mtaEventName() == "提问帖") "发提问帖" else "发帖子"
|
||||
)
|
||||
startActivityForResult(intent, REQUEST_CODE_IMAGE)
|
||||
}
|
||||
})
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(this) {
|
||||
val maxChooseCount = if (imageCount + 10 <= MAX_IMAGE_COUNT) 10 else MAX_IMAGE_COUNT - imageCount
|
||||
val intent = LocalMediaActivity.getIntent(
|
||||
this@BaseRichEditorActivity,
|
||||
LocalMediaActivity.ChooseType.IMAGE,
|
||||
maxChooseCount,
|
||||
if (mtaEventName() == "提问帖") "发提问帖" else "发帖子"
|
||||
)
|
||||
startActivityForResult(intent, REQUEST_CODE_IMAGE)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
toast(R.string.media_image_hint)
|
||||
e.printStackTrace()
|
||||
@ -516,6 +559,7 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
mEditorFontContainer.visibility = if (mEditorFont.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorParagraphContainer.visibility =
|
||||
if (mEditorFont.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorAlignContainer.visibility = if (mEditorFont.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorLinkContainer.visibility = View.GONE
|
||||
mTagsContainer.visibility = View.GONE
|
||||
mIsExtendedKeyboardShow = mEditorFont.isChecked
|
||||
@ -537,6 +581,7 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
if (mEditorLink.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorLinkContainer.visibility = if (mEditorLink.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorFontContainer.visibility = View.GONE
|
||||
mEditorAlignContainer.visibility = View.GONE
|
||||
mEditorParagraphContainer.visibility = View.GONE
|
||||
mTagsContainer.visibility = View.GONE
|
||||
mIsExtendedKeyboardShow = mEditorLink.isChecked
|
||||
@ -776,7 +821,7 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
const val INSERT_VIDEO_CODE = 415
|
||||
const val MAX_INPUT_TEXT_NUM = 10000
|
||||
const val MAX_MEDIA_COUNT = 20
|
||||
const val MAX_IMAGE_COUNT = 35
|
||||
const val MAX_IMAGE_COUNT = 70
|
||||
|
||||
const val REQUEST_CODE_IMAGE = 120
|
||||
const val INSERT_MEDIA_VIDEO_CODE = 121
|
||||
|
||||
@ -28,6 +28,7 @@ import com.gh.gamecenter.retrofit.service.ApiService
|
||||
import com.gh.gamecenter.video.upload.OnUploadListener
|
||||
import com.gh.gamecenter.video.upload.UploadManager
|
||||
import com.google.gson.JsonObject
|
||||
import com.lightgame.download.FileUtils
|
||||
import com.lightgame.utils.Utils
|
||||
import com.zhihu.matisse.Matisse
|
||||
import com.zhihu.matisse.internal.utils.PathUtils
|
||||
@ -38,6 +39,10 @@ import okhttp3.ResponseBody
|
||||
import retrofit2.HttpException
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
import kotlin.collections.HashMap
|
||||
import kotlin.collections.LinkedHashMap
|
||||
import kotlin.collections.set
|
||||
|
||||
// TODO: 移动到module_bbs模块
|
||||
@ -124,8 +129,17 @@ abstract class BaseRichEditorViewModel(application: Application) : AndroidViewMo
|
||||
}
|
||||
val map = LinkedHashMap<String, String>()
|
||||
for (key in imageUrlMap.keys) {
|
||||
map[MD5Utils.getUrlMD5(key)] = FILE_HOST + key.decodeURI()
|
||||
mapImages[TextUtils.htmlEncode(key).decodeURI()] = imageUrlMap[key] ?: ""
|
||||
val localFileUri = FILE_HOST + key.decodeURI()
|
||||
|
||||
// 文件格式为 HEIC 时,使用经 OSS 转码的图片作为预览图片
|
||||
if (FileUtils.getFileMimeType(getApplication(), key.decodeURI())?.lowercase(Locale.CHINA)?.contains("heic") == true) {
|
||||
val transformedImgUrl = ImageUtils.getTransformedUrl(imageUrlMap[key], 5000) ?: ""
|
||||
map[MD5Utils.getUrlMD5(key)] = transformedImgUrl
|
||||
mapImages[transformedImgUrl.decodeURI()] = imageUrlMap[key] ?: ""
|
||||
} else {
|
||||
map[MD5Utils.getUrlMD5(key)] = localFileUri
|
||||
mapImages[TextUtils.htmlEncode(key).decodeURI()] = imageUrlMap[key] ?: ""
|
||||
}
|
||||
}
|
||||
chooseImagesUploadSuccess.value = map
|
||||
}
|
||||
|
||||
@ -24,10 +24,12 @@ import com.gh.gamecenter.common.callback.BiCallback
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.common.entity.NotificationUgc
|
||||
import com.gh.gamecenter.common.exposure.ExposureSource
|
||||
import com.gh.gamecenter.common.loghub.LoghubUtils
|
||||
import com.gh.gamecenter.common.provider.IHelpAndFeedbackProvider
|
||||
import com.gh.gamecenter.common.tracker.Tracker
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.common.utils.NewFlatLogUtils
|
||||
import com.gh.gamecenter.common.view.dsbridge.CompletionHandler
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.core.runOnIoThread
|
||||
@ -39,7 +41,6 @@ import com.gh.gamecenter.eventbus.EBPackage
|
||||
import com.gh.gamecenter.feature.entity.Badge
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.gh.gamecenter.feature.exposure.ExposureSource
|
||||
import com.gh.gamecenter.login.user.LoginTag
|
||||
import com.gh.gamecenter.login.user.UserManager
|
||||
import com.gh.gamecenter.login.user.UserRepository
|
||||
@ -68,9 +69,14 @@ class DefaultJsApi(
|
||||
val entrance: String = "",
|
||||
private var mFragment: Fragment? = null,
|
||||
private var mBbsId: String? = "",
|
||||
private var mOriginUrl: String?= "",
|
||||
private var mOriginUrl: String? = "",
|
||||
private val mForumName: String? = ""
|
||||
) {
|
||||
|
||||
companion object {
|
||||
private const val SOURCE_ENTRANCE = "webView"
|
||||
}
|
||||
|
||||
private var mLoginHandler: CompletionHandler<Any>? = null
|
||||
private var mDownloadWatcher: DataWatcher? = null // 下载观察者
|
||||
private var mDownloadUrlSet: HashSet<String>? = null // 下载的 url 集合
|
||||
@ -229,7 +235,14 @@ class DefaultJsApi(
|
||||
|
||||
val context = CurrentActivityHolder.getCurrentActivity()
|
||||
|
||||
context?.startActivity(ImageViewerActivity.getIntent(context, imageEvent.imageList, imageEvent.position, "浏览器"))
|
||||
context?.startActivity(
|
||||
ImageViewerActivity.getIntent(
|
||||
context,
|
||||
imageEvent.imageList,
|
||||
imageEvent.position,
|
||||
"浏览器"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
@ -278,11 +291,18 @@ class DefaultJsApi(
|
||||
|
||||
/**
|
||||
* 打开论坛搜索页
|
||||
* 如果用户是从 webView跳转到论坛搜索页,则sourceEntrance为空
|
||||
*/
|
||||
@JavascriptInterface
|
||||
fun openForumSearch(msg: Any) {
|
||||
runOnUiThread {
|
||||
DirectUtils.directToForumOrUserSearch(context, mBbsId ?: "", entrance.ifBlank { "内部网页" })
|
||||
DirectUtils.directToForumOrUserSearch(
|
||||
context,
|
||||
mBbsId ?: "",
|
||||
entrance.ifBlank { "内部网页" },
|
||||
SOURCE_ENTRANCE,
|
||||
mForumName ?: ""
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -384,7 +404,7 @@ class DefaultJsApi(
|
||||
|
||||
@JavascriptInterface
|
||||
fun showQaFeedbackDialog(msg: Any) {
|
||||
val mHelpAndFeedbackHelp =
|
||||
val mHelpAndFeedbackHelp =
|
||||
ARouter.getInstance().build(RouteConsts.provider.helpAndFeedback).navigation() as? IHelpAndFeedbackProvider
|
||||
mHelpAndFeedbackHelp?.showQaFeedbackDialogFragment(context as AppCompatActivity, msg.toString())
|
||||
}
|
||||
@ -530,13 +550,24 @@ class DefaultJsApi(
|
||||
@JavascriptInterface
|
||||
fun installDownloadedGame(event: Any) {
|
||||
val url = event.toString()
|
||||
val vUrl = VHelper.getVUrl(url)
|
||||
|
||||
val downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(url, null, false)
|
||||
?: DownloadManager.getInstance().getDownloadEntitySnapshot(vUrl, null, false)
|
||||
val downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(url, null)
|
||||
?: DownloadManager.getInstance().getDownloadEntitySnapshot(url, null)
|
||||
|
||||
NewFlatLogUtils.logGameInstall(
|
||||
gameId = downloadEntity?.gameId ?: "",
|
||||
gameName = downloadEntity?.name ?: "",
|
||||
trigger = "主动安装"
|
||||
)
|
||||
|
||||
SensorsBridge.trackInstallGameClick(
|
||||
gameId = downloadEntity?.gameId ?: "",
|
||||
gameName = downloadEntity?.name ?: "",
|
||||
action = "主动安装"
|
||||
)
|
||||
|
||||
downloadEntity?.let {
|
||||
PackageInstaller.install(context, it, showUnzipToast = false)
|
||||
PackageInstaller.install(context, it, showUnzipToast = false, ignoreAsVGame = false)
|
||||
}
|
||||
}
|
||||
|
||||
@ -737,6 +768,7 @@ class DefaultJsApi(
|
||||
var status: String = "" // DOWNLOADING, PAUSED, DOWNLOADED, ERROR, UNKNOWN
|
||||
) {
|
||||
companion object {
|
||||
|
||||
fun fromDownloadEntity(downloadEntity: DownloadEntity): SimpleDownloadEntity {
|
||||
val status: String = when (downloadEntity.status) {
|
||||
add,
|
||||
|
||||
@ -350,7 +350,8 @@ object DefaultUrlHandler {
|
||||
}
|
||||
|
||||
EntranceConsts.HOST_FORUM_DETAIL -> {
|
||||
DirectUtils.directForumDetail(context, id, entrance)
|
||||
val sectionId = uri.getQueryParameter("section_id") ?: ""
|
||||
DirectUtils.directForumDetailSection(context, id, sectionId, entrance)
|
||||
}
|
||||
|
||||
EntranceConsts.HOST_GAME_RATING_DETAIL -> {
|
||||
@ -438,17 +439,17 @@ object DefaultUrlHandler {
|
||||
directToFeedback(
|
||||
context,
|
||||
content,
|
||||
null,
|
||||
isQaFeedback,
|
||||
qaContentId,
|
||||
isPlugin = false,
|
||||
isSmoothGame = false,
|
||||
EntranceConsts.ENTRANCE_BROWSER
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
EntranceConsts.HOST_HELP_AND_FEEDBACK -> {
|
||||
val position = uri.getQueryParameter("position") ?: ""
|
||||
DirectUtils.directToHelpAndFeedback(context, position.toInt())
|
||||
DirectUtils.directToHelpAndFeedback(context)
|
||||
}
|
||||
|
||||
EntranceConsts.HOST_HELP_DETAIL -> {
|
||||
@ -489,12 +490,13 @@ object DefaultUrlHandler {
|
||||
val activityName = uri.getQueryParameter("activity_name") ?: ""
|
||||
val gameId = uri.getQueryParameter("game_id") ?: ""
|
||||
context.startActivity(
|
||||
GameCollectionEditActivity.getIntent(
|
||||
GameCollectionEditActivity.getCreateIntent(
|
||||
context,
|
||||
activityId,
|
||||
activityName,
|
||||
gameId,
|
||||
entrance
|
||||
entrance,
|
||||
"其他"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@ -1,22 +1,21 @@
|
||||
package com.gh.common.chain
|
||||
|
||||
import android.content.Context
|
||||
import com.gh.common.xapk.XapkInstaller
|
||||
import com.gh.download.server.BrowserInstallHelper
|
||||
import com.gh.gamecenter.core.utils.EmptyCallback
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
|
||||
class BrowserInstallHandler : ChainHandler() {
|
||||
class BrowserInstallHandler : DownloadChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity) {
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity, asVGame: Boolean) {
|
||||
BrowserInstallHelper.showBrowserInstallHintDialog(
|
||||
context,
|
||||
gameEntity.isVGame() || gameEntity.isSplitXApk()
|
||||
gameEntity,
|
||||
asVGame || gameEntity.isSplitXApk()
|
||||
) {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
} else {
|
||||
processEndCallback?.invoke(null)
|
||||
processEndCallback?.invoke(asVGame, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,14 +4,14 @@ import android.content.Context
|
||||
import com.gh.common.dialog.CertificationDialog
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
|
||||
class CertificationHandler : ChainHandler() {
|
||||
class CertificationHandler : DownloadChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity) {
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity, asVGame: Boolean) {
|
||||
CertificationDialog.showCertificationDialog(context, gameEntity) {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
} else {
|
||||
processEndCallback?.invoke(null)
|
||||
processEndCallback?.invoke(asVGame, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,24 +0,0 @@
|
||||
package com.gh.common.chain
|
||||
|
||||
import android.content.Context
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
|
||||
abstract class ChainHandler {
|
||||
private var next: ChainHandler? = null
|
||||
var processEndCallback: ((Any?) -> Unit)? = null
|
||||
|
||||
fun setNext(next: ChainHandler?) {
|
||||
this.next = next
|
||||
}
|
||||
|
||||
fun getNext(): ChainHandler? {
|
||||
return next
|
||||
}
|
||||
|
||||
fun hasNext(): Boolean {
|
||||
return next != null
|
||||
}
|
||||
|
||||
abstract fun handleRequest(context: Context, gameEntity: GameEntity)
|
||||
|
||||
}
|
||||
@ -5,15 +5,15 @@ import com.gh.common.util.DialogUtils
|
||||
import com.gh.gamecenter.common.utils.safelyGetInRelease
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
|
||||
class CheckDownloadHandler : ChainHandler() {
|
||||
class CheckDownloadHandler : DownloadChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity) {
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity, asVGame: Boolean) {
|
||||
val apk = gameEntity.getApk().safelyGetInRelease(0) ?: return
|
||||
DialogUtils.checkDownload(context, apk.size, gameEntity.id, gameEntity.name) { isSubscribe: Boolean ->
|
||||
DialogUtils.checkDownload(context, apk.size, gameEntity.id, gameEntity.name, gameEntity.categoryChinese) { isSubscribe: Boolean ->
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
} else {
|
||||
processEndCallback?.invoke(isSubscribe)
|
||||
processEndCallback?.invoke(asVGame, isSubscribe)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,20 +2,22 @@ package com.gh.common.chain
|
||||
|
||||
import android.content.Context
|
||||
import com.gh.gamecenter.common.utils.PermissionHelper
|
||||
import com.gh.gamecenter.core.utils.EmptyCallback
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
|
||||
class CheckStoragePermissionHandler : ChainHandler() {
|
||||
class CheckStoragePermissionHandler : DownloadChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity) {
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(context, object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
} else {
|
||||
processEndCallback?.invoke(null)
|
||||
}
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity, asVGame: Boolean) {
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(
|
||||
context,
|
||||
gameEntity.id,
|
||||
gameEntity.name ?: "",
|
||||
gameEntity.categoryChinese
|
||||
) {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
} else {
|
||||
processEndCallback?.invoke(asVGame, null)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,22 +1,22 @@
|
||||
package com.gh.common.chain
|
||||
|
||||
class ChainBuilder {
|
||||
class DownloadChainBuilder {
|
||||
|
||||
private val handlers: MutableList<ChainHandler> = ArrayList()
|
||||
private val handlers: MutableList<DownloadChainHandler> = ArrayList()
|
||||
|
||||
private var processEndCallback: ((Any?) -> Unit)? = null
|
||||
private var processEndCallback: ((asVGame: Boolean, Any?) -> Unit)? = null
|
||||
|
||||
fun setProcessEndCallback(callback: (Any?) -> Unit): ChainBuilder {
|
||||
fun setProcessEndCallback(callback: (asVGame: Boolean, Any?) -> Unit): DownloadChainBuilder {
|
||||
processEndCallback = callback
|
||||
return this
|
||||
}
|
||||
|
||||
fun addHandler(handler: ChainHandler): ChainBuilder {
|
||||
fun addHandler(handler: DownloadChainHandler): DownloadChainBuilder {
|
||||
handlers.add(handler)
|
||||
return this
|
||||
}
|
||||
|
||||
fun buildHandlerChain(): ChainHandler? {
|
||||
fun buildHandlerChain(): DownloadChainHandler? {
|
||||
for (i in handlers.indices) {
|
||||
handlers[i].processEndCallback = processEndCallback
|
||||
if (i + 1 < handlers.size) {
|
||||
@ -0,0 +1,40 @@
|
||||
package com.gh.common.chain
|
||||
|
||||
import android.content.Context
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
|
||||
abstract class DownloadChainHandler {
|
||||
private var next: DownloadChainHandler? = null
|
||||
|
||||
// asVGame: 当前下载是否以畅玩游戏来进行
|
||||
var processEndCallback: ((asVGame: Boolean, Any?) -> Unit)? = null
|
||||
|
||||
/**
|
||||
* 设置下一个处理者
|
||||
*/
|
||||
fun setNext(next: DownloadChainHandler?) {
|
||||
this.next = next
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下一个处理者
|
||||
*/
|
||||
fun getNext(): DownloadChainHandler? {
|
||||
return next
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否存在下一个处理者
|
||||
*/
|
||||
fun hasNext(): Boolean {
|
||||
return next != null
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理请求
|
||||
* @param gameEntity 游戏实体
|
||||
* @param asVGame 是否作为畅玩游戏进行
|
||||
*/
|
||||
abstract fun handleRequest(context: Context, gameEntity: GameEntity, asVGame: Boolean)
|
||||
|
||||
}
|
||||
@ -3,21 +3,18 @@ package com.gh.common.chain
|
||||
import android.content.Context
|
||||
import com.gh.common.util.DownloadDialogHelper
|
||||
import com.gh.gamecenter.common.utils.safelyGetInRelease
|
||||
import com.gh.gamecenter.core.utils.EmptyCallback
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
|
||||
class DownloadDialogHelperHandler : ChainHandler() {
|
||||
class DownloadDialogHelperHandler : DownloadChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity) {
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity, asVGame: Boolean) {
|
||||
val apk = gameEntity.getApk().safelyGetInRelease(0) ?: return
|
||||
DownloadDialogHelper.findAvailableDialogAndShow(context, gameEntity, apk, object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
} else {
|
||||
processEndCallback?.invoke(null)
|
||||
}
|
||||
DownloadDialogHelper.findAvailableDialogAndShow(context, gameEntity, apk) {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
} else {
|
||||
processEndCallback?.invoke(asVGame, null)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5,14 +5,14 @@ import androidx.appcompat.app.AppCompatActivity
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.gamedetail.dialog.GamePermissionDialogFragment
|
||||
|
||||
class GamePermissionHandler : ChainHandler() {
|
||||
class GamePermissionHandler : DownloadChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity) {
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity, asVGame: Boolean) {
|
||||
GamePermissionDialogFragment.show((context as AppCompatActivity), gameEntity, gameEntity.info) {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
} else {
|
||||
processEndCallback?.invoke(null)
|
||||
processEndCallback?.invoke(asVGame, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,18 +5,18 @@ import com.gh.common.util.DialogUtils
|
||||
import com.gh.common.util.DirectUtils
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
|
||||
class LandPageAddressHandler : ChainHandler() {
|
||||
class LandPageAddressHandler : DownloadChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity) {
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity, asVGame: Boolean) {
|
||||
if (gameEntity.isLandPageAddressDialog()) {
|
||||
DialogUtils.showLandPageAddressDialog(context, gameEntity) {// 跳转第三方落地页
|
||||
DirectUtils.directToExternalBrowser(context, gameEntity.landPageAddressDialog!!.link!!)
|
||||
}
|
||||
} else {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
} else {
|
||||
processEndCallback?.invoke(null)
|
||||
processEndCallback?.invoke(asVGame, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,22 +4,22 @@ import android.content.Context
|
||||
import com.gh.common.util.DialogUtils
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
|
||||
class OverseaDownloadHandler : ChainHandler() {
|
||||
class OverseaDownloadHandler : DownloadChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity) {
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity, asVGame: Boolean) {
|
||||
if (gameEntity.isOverseaAddressDialog()) {
|
||||
DialogUtils.showOverseaDownloadDialog(context, gameEntity) {// 跳转海外下载地址弹窗
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
} else {
|
||||
processEndCallback?.invoke(null)
|
||||
processEndCallback?.invoke(asVGame, null)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
} else {
|
||||
processEndCallback?.invoke(null)
|
||||
processEndCallback?.invoke(asVGame, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,14 +5,14 @@ import androidx.appcompat.app.AppCompatActivity
|
||||
import com.gh.common.dialog.PackageCheckDialogFragment
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
|
||||
class PackageCheckHandler : ChainHandler() {
|
||||
class PackageCheckHandler : DownloadChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity) {
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity, asVGame: Boolean) {
|
||||
PackageCheckDialogFragment.show((context as AppCompatActivity), gameEntity) {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
} else {
|
||||
processEndCallback?.invoke(null)
|
||||
processEndCallback?.invoke(asVGame, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,18 +4,20 @@ import android.content.Context
|
||||
import com.gh.gamecenter.common.utils.DialogHelper
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
|
||||
class UnsupportedFeatureHandler : ChainHandler() {
|
||||
class UnsupportedFeatureHandler : DownloadChainHandler() {
|
||||
|
||||
override fun handleRequest(
|
||||
context: Context, gameEntity: GameEntity
|
||||
context: Context,
|
||||
gameEntity: GameEntity,
|
||||
asVGame: Boolean
|
||||
) {
|
||||
if (shouldShowUnsupportedFeatureDialog()) {
|
||||
DialogHelper.showUnsupportedFeatureDialog(context)
|
||||
} else {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
} else {
|
||||
processEndCallback?.invoke(null)
|
||||
processEndCallback?.invoke(asVGame, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,31 +5,27 @@ import com.gh.common.simulator.NewSimulatorGameManager
|
||||
import com.gh.common.simulator.SimulatorGameManager
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
|
||||
class UpdateNewSimulatorHandler: ChainHandler() {
|
||||
class UpdateNewSimulatorHandler: DownloadChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity) {
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity, asVGame: Boolean) {
|
||||
if (SimulatorGameManager.isSimulatorGame(gameEntity)) {
|
||||
if (NewSimulatorGameManager.shouldShowUpdateNewSimulatorAlert(context)) {
|
||||
NewSimulatorGameManager.showUpdateNewsSimulator(context) {
|
||||
NewSimulatorGameManager.showUpdateNewsSimulator(context, gameEntity) {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
} else {
|
||||
processEndCallback?.invoke(null)
|
||||
processEndCallback?.invoke(asVGame, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -4,15 +4,23 @@ import android.content.Context
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.vspace.VHelper
|
||||
|
||||
class ValidateVSpaceHandler : ChainHandler() {
|
||||
class ValidateVSpaceHandler : DownloadChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity) {
|
||||
VHelper.validateVSpaceBeforeAction(context, gameEntity) {
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity, asVGame: Boolean) {
|
||||
val closure = {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
} else {
|
||||
processEndCallback?.invoke(null)
|
||||
processEndCallback?.invoke(asVGame, null)
|
||||
}
|
||||
}
|
||||
|
||||
if (asVGame) {
|
||||
VHelper.validateVSpaceBeforeAction(context, gameEntity) {
|
||||
closure.invoke()
|
||||
}
|
||||
} else {
|
||||
closure.invoke()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3,29 +3,59 @@ package com.gh.common.chain
|
||||
import android.content.Context
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.utils.DialogHelper
|
||||
import com.gh.gamecenter.common.utils.SensorsBridge
|
||||
import com.gh.gamecenter.common.utils.toResString
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
|
||||
class VersionNumberHandler : ChainHandler() {
|
||||
class VersionNumberHandler : DownloadChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity) {
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity, asVGame: Boolean) {
|
||||
val confirmCallback = {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||
} else {
|
||||
processEndCallback?.invoke(null)
|
||||
processEndCallback?.invoke(asVGame, null)
|
||||
}
|
||||
}
|
||||
if (!gameEntity.isShowVersionNumber()) {
|
||||
confirmCallback.invoke()
|
||||
} else {
|
||||
SensorsBridge.trackGameDemoDialogShow(
|
||||
gameId = gameEntity.id,
|
||||
gameName = gameEntity.name ?: "",
|
||||
gameType = gameEntity.categoryChinese
|
||||
)
|
||||
DialogHelper.showGuideDialog(
|
||||
context,
|
||||
"温馨提示",
|
||||
gameEntity.getVersionNumberString(),
|
||||
"继续下载",
|
||||
R.string.cancel.toResString(),
|
||||
{ confirmCallback.invoke() },
|
||||
{
|
||||
confirmCallback.invoke()
|
||||
SensorsBridge.trackGameDemoDialogClick(
|
||||
buttonName = "继续下载",
|
||||
gameId = gameEntity.id,
|
||||
gameName = gameEntity.name ?: "",
|
||||
gameType = gameEntity.categoryChinese
|
||||
)
|
||||
},
|
||||
cancelClickCallback = {
|
||||
SensorsBridge.trackGameDemoDialogClick(
|
||||
buttonName = R.string.cancel.toResString(),
|
||||
gameId = gameEntity.id,
|
||||
gameName = gameEntity.name ?: "",
|
||||
gameType = gameEntity.categoryChinese
|
||||
)
|
||||
},
|
||||
touchOutsideCallback = {
|
||||
SensorsBridge.trackGameDemoDialogClick(
|
||||
buttonName = "关闭弹窗",
|
||||
gameId = gameEntity.id,
|
||||
gameName = gameEntity.name ?: "",
|
||||
gameType = gameEntity.categoryChinese
|
||||
)
|
||||
},
|
||||
extraConfig = DialogHelper.Config(titleIcon = R.drawable.ic_dialog_tips)
|
||||
)
|
||||
}
|
||||
|
||||
@ -13,14 +13,14 @@ import android.widget.PopupWindow
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.databinding.BindingAdapter
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.callback.OnViewClickListener
|
||||
import com.gh.gamecenter.common.databinding.LayoutPopupContainerBinding
|
||||
import com.gh.gamecenter.common.utils.dip2px
|
||||
import com.gh.gamecenter.common.utils.toDrawable
|
||||
import com.gh.gamecenter.common.view.BugFixedPopupWindow
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.databinding.KaifuAddItemBinding
|
||||
import com.gh.gamecenter.databinding.LayoutAddKaifuPopupBinding
|
||||
import com.gh.gamecenter.databinding.LayoutPopupContainerBinding
|
||||
import com.gh.gamecenter.feature.entity.ServerCalendarEntity
|
||||
import com.gh.gamecenter.servers.add.AddKaiFuPopupAdapter
|
||||
import java.text.SimpleDateFormat
|
||||
|
||||
@ -3,27 +3,21 @@ package com.gh.common.databind;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.TextUtils;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.gh.common.chain.BrowserInstallHandler;
|
||||
import com.gh.common.chain.CertificationHandler;
|
||||
import com.gh.common.chain.ChainBuilder;
|
||||
import com.gh.common.chain.ChainHandler;
|
||||
import com.gh.common.chain.DownloadChainBuilder;
|
||||
import com.gh.common.chain.DownloadChainHandler;
|
||||
import com.gh.common.chain.CheckDownloadHandler;
|
||||
import com.gh.common.chain.CheckStoragePermissionHandler;
|
||||
import com.gh.common.chain.DownloadDialogHelperHandler;
|
||||
@ -46,7 +40,6 @@ import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.GameUtils;
|
||||
import com.gh.common.util.GameViewUtils;
|
||||
import com.gh.common.util.LogUtils;
|
||||
import com.gh.common.util.NewsUtils;
|
||||
import com.gh.common.util.PackageInstaller;
|
||||
import com.gh.common.util.PackageLauncher;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
@ -57,24 +50,16 @@ import com.gh.download.server.BrowserInstallHelper;
|
||||
import com.gh.gamecenter.DownloadManagerActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.WebActivity;
|
||||
import com.gh.gamecenter.common.baselist.LoadStatus;
|
||||
import com.gh.gamecenter.common.callback.OnViewClickListener;
|
||||
import com.gh.gamecenter.common.entity.LinkEntity;
|
||||
import com.gh.gamecenter.common.eventbus.EBReuse;
|
||||
import com.gh.gamecenter.common.utils.DarkModeUtils;
|
||||
import com.gh.gamecenter.common.utils.ExtensionsKt;
|
||||
import com.gh.gamecenter.common.utils.ImageUtils;
|
||||
import com.gh.gamecenter.common.view.DrawableView;
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils;
|
||||
import com.gh.gamecenter.common.utils.NewFlatLogUtils;
|
||||
import com.gh.gamecenter.common.utils.SensorsBridge;
|
||||
import com.gh.gamecenter.core.utils.MtaHelper;
|
||||
import com.gh.gamecenter.core.utils.NumberUtils;
|
||||
import com.gh.gamecenter.core.utils.ToastUtils;
|
||||
import com.gh.gamecenter.databinding.KaifuDetailItemRowBinding;
|
||||
import com.gh.gamecenter.feature.entity.ApkEntity;
|
||||
import com.gh.gamecenter.feature.entity.CommunityVideoEntity;
|
||||
import com.gh.gamecenter.feature.entity.GameEntity;
|
||||
import com.gh.gamecenter.feature.entity.PluginLocation;
|
||||
import com.gh.gamecenter.feature.entity.ServerCalendarEntity;
|
||||
import com.gh.gamecenter.feature.entity.TagStyleEntity;
|
||||
import com.gh.gamecenter.feature.entity.TestEntity;
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent;
|
||||
@ -83,14 +68,11 @@ import com.gh.gamecenter.feature.view.DownloadButton;
|
||||
import com.gh.gamecenter.feature.view.GameIconView;
|
||||
import com.gh.gamecenter.gamedetail.dialog.GamePermissionDialogFragment;
|
||||
import com.gh.gamecenter.manager.PackagesManager;
|
||||
import com.gh.vspace.VDownloadManagerActivity;
|
||||
import com.gh.vspace.VHelper;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
import com.lightgame.download.FileUtils;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -98,134 +80,8 @@ import java.util.List;
|
||||
/**
|
||||
* Created by khy on 12/02/18.
|
||||
*/
|
||||
|
||||
public class BindingAdapters {
|
||||
|
||||
public static void loadIcon(SimpleDraweeView view, String imageUrl) {
|
||||
ImageUtils.displayIcon(view, imageUrl);
|
||||
}
|
||||
|
||||
public static void loadImage(SimpleDraweeView view, String imageUrl) {
|
||||
ImageUtils.display(view, imageUrl);
|
||||
}
|
||||
|
||||
public static void setTextSize(TextView view, int number) {
|
||||
view.setTextSize(number);
|
||||
}
|
||||
|
||||
public static void setTypeface(TextView view, String type) {
|
||||
if (type == null) return;
|
||||
|
||||
switch (type) {
|
||||
case "bold":
|
||||
view.setTypeface(null, Typeface.BOLD);
|
||||
break;
|
||||
case "italic":
|
||||
view.setTypeface(null, Typeface.ITALIC);
|
||||
break;
|
||||
case "bold_italic":
|
||||
view.setTypeface(null, Typeface.BOLD_ITALIC);
|
||||
break;
|
||||
default:
|
||||
view.setTypeface(null, Typeface.NORMAL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void addDetailKaiFuView(LinearLayout view, List<ServerCalendarEntity> list
|
||||
, OnViewClickListener listener, Boolean isReadyPatch) {
|
||||
if (list == null) return;
|
||||
view.removeAllViews();
|
||||
for (int i = 0; i < list.size() + 1; i++) { // 1 is Title
|
||||
View inflate = LayoutInflater.from(view.getContext()).inflate(R.layout.kaifu_detail_item_row, null);
|
||||
KaifuDetailItemRowBinding binding = KaifuDetailItemRowBinding.bind(inflate);
|
||||
binding.getRoot().setBackgroundColor(isReadyPatch != null && isReadyPatch ? ExtensionsKt.toColor(R.color.theme) : ExtensionsKt.toColor(R.color.white));
|
||||
binding.getRoot().setPadding(DisplayUtils.dip2px(1), DisplayUtils.dip2px(1), DisplayUtils.dip2px(1), i == list.size() ? DisplayUtils.dip2px(1) : 0);
|
||||
ServerCalendarEntity serverEntity = list.get(i - 1);
|
||||
binding.timeTv.setText(i == 0 ? "时间" : serverEntity.getFormatTime("HH:mm"));
|
||||
binding.remarkTv.setText(i == 0 ? "备注" : serverEntity.getRemark());
|
||||
binding.nameTv.setText(i == 0 ? "名字" : (TextUtils.isEmpty(serverEntity.getNote()) ? "-" : serverEntity.getNote()));
|
||||
if (i != 0) {
|
||||
binding.getRoot().setOnClickListener(v -> {
|
||||
listener.onClick(v, isReadyPatch != null && isReadyPatch ? serverEntity : null);
|
||||
});
|
||||
|
||||
// 滑动冲突处理
|
||||
binding.getRoot().setOnTouchListener((v, event) -> {
|
||||
if (list.size() > 5) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
EventBus.getDefault().post(new EBReuse("CalenderDown"));
|
||||
} else if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) {
|
||||
EventBus.getDefault().post(new EBReuse("CalenderCancel"));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
view.addView(inflate);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果超过10000,则转换为1.0W
|
||||
public static void transSimpleCount(TextView view, int count) {
|
||||
view.setText(NumberUtils.transSimpleCount(count));
|
||||
}
|
||||
|
||||
public static void textColorFromString(TextView tv, String hexString) {
|
||||
if (TextUtils.isEmpty(hexString)) return;
|
||||
|
||||
try {
|
||||
tv.setTextColor(Color.parseColor(hexString));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void showHide(View view, Boolean show) {
|
||||
if (show != null && show) {
|
||||
view.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
view.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public static void goneIf(View view, Boolean gone) {
|
||||
if (gone != null && gone) {
|
||||
view.setVisibility(View.GONE);
|
||||
} else {
|
||||
view.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* lazy 的 paddingTop
|
||||
*/
|
||||
public static void lazyPaddingLeft(View view, int paddingLeftInDp) {
|
||||
view.setPadding(DisplayUtils.dip2px(paddingLeftInDp), view.getPaddingTop(), view.getPaddingRight(), view.getPaddingBottom());
|
||||
}
|
||||
|
||||
/**
|
||||
* lazy 的 paddingTop
|
||||
*/
|
||||
public static void lazyPaddingTop(View view, int paddingTopInDp) {
|
||||
view.setPadding(view.getPaddingLeft(), DisplayUtils.dip2px(paddingTopInDp), view.getPaddingRight(), view.getPaddingBottom());
|
||||
}
|
||||
|
||||
/**
|
||||
* lazy 的 paddingBottom
|
||||
*/
|
||||
public static void lazyPaddingBottom(View view, int paddingBottomInDp) {
|
||||
view.setPadding(view.getPaddingLeft(), view.getPaddingTop(), view.getPaddingRight(), DisplayUtils.dip2px(paddingBottomInDp));
|
||||
}
|
||||
|
||||
public static void visibleInvisible(View view, Boolean show) {
|
||||
if (show != null && show) {
|
||||
view.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
view.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setMessageUnread(TextView view, int unreadCount) {
|
||||
if (unreadCount < 100) {
|
||||
view.setText(String.valueOf(unreadCount));
|
||||
@ -234,119 +90,12 @@ public class BindingAdapters {
|
||||
}
|
||||
}
|
||||
|
||||
public static void setServerTypePadding(TextView view, String serverType) {
|
||||
int paddRight = 0;
|
||||
if (TextUtils.isEmpty(serverType)) {
|
||||
} else {
|
||||
if ("删档内测".equals(serverType) || "不删档内测".equals(serverType)) {
|
||||
if ("删档内测".equals(serverType)) {
|
||||
paddRight = DisplayUtils.dip2px(view.getContext(), 50);
|
||||
} else {
|
||||
paddRight = DisplayUtils.dip2px(view.getContext(), 60);
|
||||
}
|
||||
} else {
|
||||
paddRight = DisplayUtils.dip2px(view.getContext(), 30);
|
||||
}
|
||||
}
|
||||
view.setPadding(0, 0, paddRight, 0);
|
||||
}
|
||||
|
||||
public static void setServerType(TextView view, String serverType) {
|
||||
view.setText(serverType);
|
||||
if ("删档内测".equals(serverType) || "不删档内测".equals(serverType)) {
|
||||
view.setBackgroundResource(R.drawable.textview_server_tag);
|
||||
} else {
|
||||
view.setBackgroundResource(R.drawable.textview_orange_up);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setGame(View view, GameEntity gameEntity) {
|
||||
if (gameEntity != null && view instanceof GameIconView) {
|
||||
((GameIconView) view).displayGameIcon(gameEntity);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setGameIcon(View view, GameEntity gameEntity) {
|
||||
if (gameEntity != null && view instanceof GameIconView) {
|
||||
((GameIconView) view).displayGameIcon(gameEntity.getIcon(), gameEntity.getIconSubscript(), gameEntity.getIconFloat());
|
||||
}
|
||||
}
|
||||
|
||||
public static void setArticleType(TextView view, String articleType) {
|
||||
NewsUtils.setNewsType(view, articleType, 0, 0);
|
||||
}
|
||||
|
||||
public static void setDetailDownloadText(TextView view, GameEntity gameEntity) {
|
||||
if (gameEntity == null || gameEntity.getApk().isEmpty()) {
|
||||
view.setBackgroundResource(R.drawable.game_item_btn_pause_style);
|
||||
view.setTextColor(0xFF999999);
|
||||
view.setClickable(false);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setLiBaoBtn(TextView view, String status) {
|
||||
if (TextUtils.isEmpty(status)) return;
|
||||
switch (status) {
|
||||
case "coming":
|
||||
view.setText(R.string.libao_coming);
|
||||
view.setBackgroundResource(R.drawable.textview_blue_style);
|
||||
break;
|
||||
case "ling":
|
||||
view.setText(R.string.libao_ling);
|
||||
view.setBackgroundResource(R.drawable.textview_green_style);
|
||||
break;
|
||||
case "tao":
|
||||
view.setText(R.string.libao_tao);
|
||||
view.setBackgroundResource(R.drawable.textview_orange_style);
|
||||
break;
|
||||
case "used_up":
|
||||
view.setText(R.string.libao_used_up);
|
||||
view.setBackgroundResource(R.drawable.textview_cancel_up);
|
||||
break;
|
||||
case "finish":
|
||||
view.setText(R.string.libao_finish);
|
||||
view.setBackgroundResource(R.drawable.textview_cancel_up);
|
||||
break;
|
||||
case "linged":
|
||||
view.setText(R.string.libao_linged);
|
||||
view.setBackgroundResource(R.drawable.libao_linged_style);
|
||||
view.setTextColor(ContextCompat.getColorStateList(view.getContext(), R.color.libao_linged_selector));
|
||||
break;
|
||||
case "taoed":
|
||||
view.setText(R.string.libao_taoed);
|
||||
view.setBackgroundResource(R.drawable.libao_taoed_style);
|
||||
view.setTextColor(ContextCompat.getColorStateList(view.getContext(), R.color.libao_taoed_selector));
|
||||
break;
|
||||
case "copy":
|
||||
view.setText(R.string.libao_copy);
|
||||
view.setBackgroundResource(R.drawable.textview_blue_style);
|
||||
break;
|
||||
case "repeatLing":
|
||||
view.setText(R.string.libao_repeat_ling);
|
||||
view.setBackgroundResource(R.drawable.textview_cancel_up);
|
||||
break;
|
||||
case "repeatLinged":
|
||||
view.setText(R.string.libao_repeat_ling);
|
||||
view.setBackgroundResource(R.drawable.textview_green_style);
|
||||
break;
|
||||
case "repeatTao":
|
||||
view.setText(R.string.libao_repeat_tao);
|
||||
view.setBackgroundResource(R.drawable.textview_cancel_up);
|
||||
break;
|
||||
case "repeatTaoed":
|
||||
view.setText(R.string.libao_repeat_tao);
|
||||
view.setBackgroundResource(R.drawable.textview_orange_style);
|
||||
break;
|
||||
case "unshelve":
|
||||
view.setBackgroundResource(R.drawable.textview_cancel_style);
|
||||
view.setText(R.string.libao_unshelve);
|
||||
break;
|
||||
default:
|
||||
view.setBackgroundResource(R.drawable.textview_cancel_style);
|
||||
view.setText("异常");
|
||||
}
|
||||
}
|
||||
|
||||
// 大图下的进度条
|
||||
public static void setDownloadButton(DownloadButton progressBar,
|
||||
GameEntity gameEntity,
|
||||
@ -374,13 +123,9 @@ public class BindingAdapters {
|
||||
switch (progressBar.getButtonStyle()) {
|
||||
case DOWNLOADING_PLUGIN:
|
||||
case DOWNLOADING_NORMAL:
|
||||
if (gameEntity.isVGame()) {
|
||||
v.getContext().startActivity(VDownloadManagerActivity.getIntent(v.getContext(), true));
|
||||
} else {
|
||||
Intent intent = DownloadManagerActivity.getDownloadMangerIntent(v.getContext(),
|
||||
gameEntity.getApk().get(0).getUrl(), entrance);
|
||||
v.getContext().startActivity(intent);
|
||||
}
|
||||
Intent intent = DownloadManagerActivity.getDownloadMangerIntent(v.getContext(),
|
||||
gameEntity.getApk().get(0).getUrl(), entrance);
|
||||
v.getContext().startActivity(intent);
|
||||
break;
|
||||
case NONE:
|
||||
Utils.toast(v.getContext(), "该游戏已关闭下载");
|
||||
@ -398,12 +143,12 @@ public class BindingAdapters {
|
||||
boolean isInstalled = PackageUtils.isInstalledFromAllPackage(v.getContext(), gameEntity.getSimulator().getApk().getPackageName());
|
||||
if (downloadEntity != null && SimulatorGameManager.isSimulatorGame(gameEntity) && !isInstalled) {
|
||||
SimulatorDownloadManager.getInstance().showDownloadDialog(v.getContext(), gameEntity.getSimulator(),
|
||||
SimulatorDownloadManager.SimulatorLocation.LAUNCH, gameEntity.getId(), gameEntity.getName(), null);
|
||||
SimulatorDownloadManager.SimulatorLocation.LAUNCH, gameEntity.getId(), gameEntity.getName(), gameEntity.getCategoryChinese(), null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ChainBuilder builder = new ChainBuilder();
|
||||
DownloadChainBuilder builder = new DownloadChainBuilder();
|
||||
builder.addHandler(new UnsupportedFeatureHandler());
|
||||
builder.addHandler(new GamePermissionHandler());
|
||||
builder.addHandler(new CheckStoragePermissionHandler());
|
||||
@ -417,22 +162,33 @@ public class BindingAdapters {
|
||||
builder.addHandler(new OverseaDownloadHandler());
|
||||
builder.addHandler(new CheckDownloadHandler());
|
||||
|
||||
builder.setProcessEndCallback(o -> {
|
||||
download(v.getContext(), progressBar, gameEntity, traceEvent, (boolean) o, entrance, location);
|
||||
builder.setProcessEndCallback((asVGame, isSubscribe) -> {
|
||||
download(v.getContext(),
|
||||
progressBar,
|
||||
gameEntity,
|
||||
traceEvent,
|
||||
asVGame,
|
||||
(boolean) isSubscribe,
|
||||
entrance,
|
||||
location);
|
||||
return null;
|
||||
});
|
||||
final ChainHandler chainHandler = builder.buildHandlerChain();
|
||||
final DownloadChainHandler chainHandler = builder.buildHandlerChain();
|
||||
if (chainHandler != null) {
|
||||
chainHandler.handleRequest(v.getContext(), gameEntity);
|
||||
chainHandler.handleRequest(
|
||||
v.getContext(),
|
||||
gameEntity,
|
||||
GameUtils.shouldPerformAsVGame(gameEntity)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
ChainBuilder builder = new ChainBuilder();
|
||||
DownloadChainBuilder builder = new DownloadChainBuilder();
|
||||
builder.addHandler(new UnsupportedFeatureHandler());
|
||||
builder.addHandler(new GamePermissionHandler());
|
||||
builder.addHandler(new CertificationHandler());
|
||||
builder.addHandler(new VersionNumberHandler());
|
||||
|
||||
builder.setProcessEndCallback(o -> {
|
||||
builder.setProcessEndCallback((asVGame, isSubscribe) -> {
|
||||
DownloadDialog.showDownloadDialog(
|
||||
v.getContext(),
|
||||
gameEntity,
|
||||
@ -441,9 +197,13 @@ public class BindingAdapters {
|
||||
location + ":" + gameEntity.getName());
|
||||
return null;
|
||||
});
|
||||
final ChainHandler chainHandler = builder.buildHandlerChain();
|
||||
final DownloadChainHandler chainHandler = builder.buildHandlerChain();
|
||||
if (chainHandler != null) {
|
||||
chainHandler.handleRequest(v.getContext(), gameEntity);
|
||||
chainHandler.handleRequest(
|
||||
v.getContext(),
|
||||
gameEntity,
|
||||
GameUtils.shouldPerformAsVGame(gameEntity)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -456,7 +216,14 @@ public class BindingAdapters {
|
||||
if (downloadEntity != null) {
|
||||
File file = new File(downloadEntity.getPath());
|
||||
if (!file.exists()) {
|
||||
download(v.getContext(), progressBar, gameEntity, traceEvent, false, entrance, location);
|
||||
download(v.getContext(),
|
||||
progressBar,
|
||||
gameEntity,
|
||||
traceEvent,
|
||||
false,
|
||||
false,
|
||||
entrance,
|
||||
location);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -465,12 +232,7 @@ public class BindingAdapters {
|
||||
return;
|
||||
}
|
||||
|
||||
if (gameEntity.isVGame()) {
|
||||
VHelper.installOrLaunch((AppCompatActivity) v.getContext(), gameEntity, null);
|
||||
return;
|
||||
}
|
||||
|
||||
PackageLauncher.launchApp(v.getContext(), gameEntity, gameEntity.getApk().get(0).getPackageName());
|
||||
PackageLauncher.launch(v.getContext(), gameEntity, null);
|
||||
} else {
|
||||
DownloadDialog.showDownloadDialog(
|
||||
v.getContext(),
|
||||
@ -483,15 +245,27 @@ public class BindingAdapters {
|
||||
case INSTALL_PLUGIN:
|
||||
case INSTALL_NORMAL:
|
||||
if (gameEntity.getApk().size() == 1) {
|
||||
|
||||
NewFlatLogUtils.INSTANCE.logGameInstall(
|
||||
gameEntity.getId(),
|
||||
gameEntity.getName() != null ? gameEntity.getName() : "",
|
||||
"主动安装"
|
||||
);
|
||||
|
||||
SensorsBridge.trackInstallGameClick(
|
||||
gameEntity.getId(),
|
||||
gameEntity.getName() != null ? gameEntity.getName() : "",
|
||||
"主动安装"
|
||||
);
|
||||
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity);
|
||||
|
||||
if (gameEntity.isVGame()) {
|
||||
VHelper.installOrLaunch(v.getContext(), gameEntity, null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (downloadEntity != null) {
|
||||
PackageInstaller.install(v.getContext(), downloadEntity);
|
||||
if (ExtensionsKt.isLocalDownloadInDualDownloadMode(downloadEntity)) {
|
||||
PackageInstaller.install(v.getContext(), downloadEntity);
|
||||
} else {
|
||||
VHelper.installOrLaunch(v.getContext(), gameEntity, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -577,7 +351,7 @@ public class BindingAdapters {
|
||||
}
|
||||
|
||||
} else {
|
||||
String status = GameUtils.getDownloadBtnText(progressBar.getContext(), gameEntity, PluginLocation.only_game);
|
||||
String status = GameUtils.getDownloadBtnText(progressBar.getContext(), gameEntity, true, false, PluginLocation.only_game);
|
||||
switch (status) {
|
||||
case "插件化":
|
||||
progressBar.setButtonStyle(DownloadButton.ButtonStyle.PLUGIN);
|
||||
@ -649,24 +423,6 @@ public class BindingAdapters {
|
||||
}
|
||||
}
|
||||
|
||||
/*private static void download(DownloadProgressBar progressBar, GameEntity gameEntity, ExposureEvent traceEvent, @Nullable String entrance, @Nullable String location, View v) {
|
||||
if (gameEntity.getApk().size() == 1) {
|
||||
ApkEntity apk = gameEntity.getApk().get(0);
|
||||
DownloadDialogHelper.findAvailableDialogAndShow(
|
||||
v.getContext(),
|
||||
gameEntity,
|
||||
apk,
|
||||
() -> {
|
||||
DialogUtils.checkDownload(v.getContext(), apk.getSize(),
|
||||
isSubscribe -> download(progressBar, gameEntity, traceEvent, isSubscribe, entrance, location));
|
||||
});
|
||||
} else {
|
||||
DownloadDialog.getInstance(v.getContext()).showPopupWindow(v, gameEntity,
|
||||
entrance, location + gameEntity.getName(), traceEvent);
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
private static void updateReservation(DownloadButton progressBar, GameEntity gameEntity) {
|
||||
// 显示预约
|
||||
if (gameEntity.isReservable()) {
|
||||
@ -686,45 +442,35 @@ public class BindingAdapters {
|
||||
DownloadButton progressBar,
|
||||
GameEntity gameEntity,
|
||||
ExposureEvent traceEvent,
|
||||
boolean asVGame,
|
||||
boolean isSubscribe,
|
||||
String entrance,
|
||||
String location) {
|
||||
if (BrowserInstallHelper.shouldAutoSwitchAssistantInstall(gameEntity)) {
|
||||
ToastUtils.toast(context.getString(R.string.unsupported_browser_install_hint));
|
||||
}
|
||||
String str = progressBar.getText().toString();
|
||||
String method;
|
||||
if (str.contains("更新")) {
|
||||
method = "更新";
|
||||
} else if (str.contains("插件化")) {
|
||||
method = "插件化";
|
||||
} else {
|
||||
method = progressBar.getContext().getString(R.string.download);
|
||||
}
|
||||
String buttonText = progressBar.getText();
|
||||
ApkEntity apkEntity = gameEntity.getApk().get(0);
|
||||
String msg = FileUtils.isCanDownload(progressBar.getContext(), apkEntity.getSize());
|
||||
if (TextUtils.isEmpty(msg)) {
|
||||
DownloadManager.createDownload(progressBar.getContext(),
|
||||
apkEntity,
|
||||
gameEntity,
|
||||
method,
|
||||
asVGame,
|
||||
gameEntity.isDualBtnModeEnabled(),
|
||||
entrance,
|
||||
location + gameEntity.getName(),
|
||||
isSubscribe,
|
||||
traceEvent);
|
||||
|
||||
progressBar.setProgress(0);
|
||||
progressBar.setButtonStyle("插件化".equals(method) ?
|
||||
progressBar.setButtonStyle(buttonText.contains("插件化") ?
|
||||
DownloadButton.ButtonStyle.DOWNLOADING_PLUGIN : DownloadButton.ButtonStyle.DOWNLOADING_NORMAL);
|
||||
} else {
|
||||
Utils.toast(progressBar.getContext(), msg);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setGameLabelList(LinearLayout layout, List<TagStyleEntity> tagStyle) {
|
||||
GameViewUtils.setLabelList(layout.getContext(), layout, tagStyle);
|
||||
}
|
||||
|
||||
// 包含测试开服标签
|
||||
public static void setGameTags(LinearLayout layout, GameEntity gameEntity) {
|
||||
try {
|
||||
@ -794,12 +540,6 @@ public class BindingAdapters {
|
||||
}
|
||||
}
|
||||
|
||||
public static void isRefreshing(SwipeRefreshLayout layout, LoadStatus status) {
|
||||
if (status != LoadStatus.INIT_LOADING && status != LoadStatus.LIST_LOADING) {
|
||||
layout.setRefreshing(false);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setGameName(TextView view, GameEntity game, boolean isShowPlatform, @Nullable Boolean isShowSuffix) {
|
||||
if (isShowSuffix == null) isShowSuffix = true; // 默认显示
|
||||
String gameName;
|
||||
@ -821,30 +561,6 @@ public class BindingAdapters {
|
||||
|
||||
}
|
||||
|
||||
public static void setCommunityImage(SimpleDraweeView imageView, List<String> images, List<CommunityVideoEntity> videos) {
|
||||
if (videos.size() > 0) {
|
||||
CommunityVideoEntity videoEntity = videos.get(0);
|
||||
ImageUtils.display(imageView, videoEntity.getPoster());
|
||||
imageView.setVisibility(View.VISIBLE);
|
||||
} else if (images.size() > 0) {
|
||||
imageView.setVisibility(View.VISIBLE);
|
||||
ImageUtils.display(imageView, images.get(0));
|
||||
} else {
|
||||
imageView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setCommunityVideoDuration(TextView mVideoDuration, List<CommunityVideoEntity> videos) {
|
||||
if (videos != null && videos.size() > 0) {
|
||||
CommunityVideoEntity videoEntity = videos.get(0);
|
||||
mVideoDuration.setBackground(DrawableView.getOvalDrawable(R.color.black_alpha_50, 999F));
|
||||
mVideoDuration.setText(videoEntity.getDuration());
|
||||
mVideoDuration.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mVideoDuration.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setGameTags(TextView view, List<TagStyleEntity> tags, int maxTags) {
|
||||
if (tags == null) {
|
||||
view.setText("");
|
||||
@ -872,16 +588,4 @@ public class BindingAdapters {
|
||||
}
|
||||
view.setText(span);
|
||||
}
|
||||
|
||||
public static void setVideoData(TextView view, int count) {
|
||||
if (count > 0) {
|
||||
ExtensionsKt.setDrawableStart(view, ContextCompat.getDrawable(view.getContext(), R.drawable.ic_video_data_up), null, null);
|
||||
view.setTextColor(ContextCompat.getColor(view.getContext(), R.color.text_EA3333));
|
||||
view.setText(count + "");
|
||||
} else {
|
||||
ExtensionsKt.removeDrawable(view);
|
||||
view.setTextColor(ContextCompat.getColor(view.getContext(), R.color.text_subtitleDesc));
|
||||
view.setText("-");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.gh.common.dialog
|
||||
|
||||
import android.app.Activity.RESULT_OK
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
@ -18,13 +19,10 @@ import com.gh.common.xapk.XapkInstaller
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.fragment.BaseDialogFragment
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.utils.PermissionHelper
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.common.utils.PermissionHelper.INSTALL_PERMISSION_CODE
|
||||
import com.gh.gamecenter.common.utils.getExtension
|
||||
import com.gh.gamecenter.common.utils.goneIf
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import com.lightgame.utils.Utils
|
||||
import kotlin.random.Random
|
||||
|
||||
class InstallPermissionDialogFragment : BaseDialogFragment() {
|
||||
@ -34,8 +32,11 @@ class InstallPermissionDialogFragment : BaseDialogFragment() {
|
||||
var url: String = ""
|
||||
var gameId: String = ""
|
||||
var gameName: String = ""
|
||||
var gameType: String = ""
|
||||
var mCallBack: ((isFromPermissionGrantedCallback: Boolean) -> Unit)? = null
|
||||
|
||||
private var dismissByTouchInside = false
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
mView = inflater.inflate(R.layout.dialog_install_permission, null, false)
|
||||
return mView
|
||||
@ -55,6 +56,12 @@ class InstallPermissionDialogFragment : BaseDialogFragment() {
|
||||
|
||||
if (isXapk) NewFlatLogUtils.logXApkInstallPermissionDialogShowed(gameId, gameName)
|
||||
|
||||
SensorsBridge.trackInstallPermissionDialogShow(
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameType
|
||||
)
|
||||
|
||||
val randomNumber = if (isXapk) 1 else Random.nextInt(2)
|
||||
closeTv.goneIf(randomNumber == 0)
|
||||
closeIv.goneIf(randomNumber != 0)
|
||||
@ -64,18 +71,38 @@ class InstallPermissionDialogFragment : BaseDialogFragment() {
|
||||
}
|
||||
|
||||
closeTv.setOnClickListener {
|
||||
dismissByTouchInside = true
|
||||
if (isXapk) {
|
||||
NewFlatLogUtils.logXApkInstallPermissionDialogClick("尝试解压", false, gameId, gameName)
|
||||
mCallBack?.invoke(false)
|
||||
}
|
||||
SensorsBridge.trackInstallPermissionDialogClick(
|
||||
buttonName = "尝试解压",
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameType
|
||||
)
|
||||
dismiss()
|
||||
}
|
||||
closeIv.setOnClickListener {
|
||||
dismissByTouchInside = true
|
||||
if (isXapk) NewFlatLogUtils.logXApkInstallPermissionDialogClick("关闭", false, gameId, gameName)
|
||||
SensorsBridge.trackInstallPermissionDialogClick(
|
||||
buttonName = "关闭",
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameType
|
||||
)
|
||||
dismiss()
|
||||
}
|
||||
activateTv.setOnClickListener {
|
||||
NewFlatLogUtils.logXApkInstallPermissionDialogClick("立即开启", false, gameId, gameName)
|
||||
SensorsBridge.trackInstallPermissionDialogClick(
|
||||
buttonName = "立即开启",
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameType
|
||||
)
|
||||
PermissionHelper.toInstallPermissionSetting(requireActivity())
|
||||
if (isXapk) {
|
||||
SPUtils.setString(Constants.SP_XAPK_UNZIP_ACTIVITY, requireActivity().javaClass.name)
|
||||
@ -84,9 +111,23 @@ class InstallPermissionDialogFragment : BaseDialogFragment() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDismiss(dialog: DialogInterface) {
|
||||
if (!dismissByTouchInside) {
|
||||
SensorsBridge.trackInstallPermissionDialogClick(
|
||||
buttonName = "关闭弹窗",
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameType
|
||||
)
|
||||
}
|
||||
super.onDismiss(dialog)
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (resultCode == RESULT_OK && requestCode == INSTALL_PERMISSION_CODE) {
|
||||
dismissByTouchInside = true
|
||||
|
||||
NewFlatLogUtils.logXApkInstallPermissionDialogClick("立即开启", true, gameId, gameName)
|
||||
|
||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.R) {
|
||||
@ -136,6 +177,7 @@ class InstallPermissionDialogFragment : BaseDialogFragment() {
|
||||
installPermissionDialogFragment.url = downloadEntity.url
|
||||
installPermissionDialogFragment.gameId = downloadEntity.gameId
|
||||
installPermissionDialogFragment.gameName = downloadEntity.name
|
||||
installPermissionDialogFragment.gameType = downloadEntity.categoryChinese
|
||||
val transaction: FragmentTransaction = activity.supportFragmentManager.beginTransaction()
|
||||
transaction.show(installPermissionDialogFragment)
|
||||
transaction.commit()
|
||||
@ -146,6 +188,7 @@ class InstallPermissionDialogFragment : BaseDialogFragment() {
|
||||
this.url = downloadEntity.url
|
||||
this.gameId = downloadEntity.gameId
|
||||
this.gameName = downloadEntity.name
|
||||
this.gameType = downloadEntity.categoryChinese
|
||||
}
|
||||
installPermissionDialogFragment.show(
|
||||
activity.supportFragmentManager,
|
||||
|
||||
@ -2,6 +2,7 @@ package com.gh.common.dialog
|
||||
|
||||
import android.animation.ValueAnimator
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.content.pm.PackageInfo
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
@ -11,6 +12,7 @@ import android.view.animation.LinearInterpolator
|
||||
import android.widget.LinearLayout
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.FragmentTransaction
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
@ -61,6 +63,8 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
var gameEntity: GameEntity? = null
|
||||
var callBack: ConfirmListener? = null
|
||||
|
||||
private var mDismissByTouchInside = false
|
||||
|
||||
private val dataWatcher = object : DataWatcher() {
|
||||
override fun onDataChanged(downloadEntity: DownloadEntity) {
|
||||
val packageName = downloadEntity.packageName
|
||||
@ -90,6 +94,11 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
EventBus.getDefault().register(this)
|
||||
gameEntity?.let {
|
||||
LogUtils.uploadPackageCheck("pkg_check_pop_click", "出现弹窗", it, "", "", "", "")
|
||||
SensorsBridge.trackPkgCheckDialogShow(
|
||||
gameId = it.id,
|
||||
gameName = it.name ?: "",
|
||||
gameType = it.categoryChinese
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,6 +137,18 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
"",
|
||||
""
|
||||
)
|
||||
SensorsBridge.trackPkgCheckDialogClick(
|
||||
buttonName = "点击链接",
|
||||
gameId = gameEntity?.id ?: "",
|
||||
gameName = gameEntity?.name ?: "",
|
||||
gameType = gameEntity?.categoryChinese ?: "",
|
||||
isNotPrompt = if (binding.noRemindAgainCb.isVisible) {
|
||||
binding.noRemindAgainCb.isChecked
|
||||
} else null,
|
||||
linkId = link.link ?: "",
|
||||
linkType = link.type ?: "",
|
||||
linkText = link.linkText ?: ""
|
||||
)
|
||||
DirectUtils.directToLinkPage(requireContext(), link, "包名检测弹窗", "")
|
||||
}.build()
|
||||
spanBuilder.append(linkSpan)
|
||||
@ -176,6 +197,7 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
}
|
||||
val isAllPackageInstalled = isAllPackageInstalled(mAllInstalledPackages, entity)
|
||||
if (isAllPackageInstalled) {
|
||||
mDismissByTouchInside = true
|
||||
callBack?.onConfirm()
|
||||
dismissAllowingStateLoss()
|
||||
} else {
|
||||
@ -193,6 +215,15 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
"",
|
||||
""
|
||||
)
|
||||
SensorsBridge.trackPkgCheckDialogClick(
|
||||
buttonName = "点击前往下载",
|
||||
gameId = gameEntity?.id ?: "",
|
||||
gameName = gameEntity?.name ?: "",
|
||||
gameType = gameEntity?.categoryChinese ?: "",
|
||||
isNotPrompt = if (binding.noRemindAgainCb.isVisible) {
|
||||
binding.noRemindAgainCb.isChecked
|
||||
} else null
|
||||
)
|
||||
DirectUtils.directToLinkPage(requireContext(), packageLink, "包名检测弹窗", "")
|
||||
}
|
||||
}
|
||||
@ -206,6 +237,19 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
saveRecord(entity)
|
||||
LogUtils.uploadPackageCheck("pkg_check_pop_click", "不再提示", gameEntity, "", "", "", "")
|
||||
}
|
||||
|
||||
mDismissByTouchInside = true
|
||||
|
||||
SensorsBridge.trackPkgCheckDialogClick(
|
||||
buttonName = binding.cancelTv.text.toString(),
|
||||
gameId = gameEntity?.id ?: "",
|
||||
gameName = gameEntity?.name ?: "",
|
||||
gameType = gameEntity?.categoryChinese ?: "",
|
||||
isNotPrompt = if (binding.noRemindAgainCb.isVisible) {
|
||||
binding.noRemindAgainCb.isChecked
|
||||
} else null
|
||||
)
|
||||
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
@ -300,6 +344,21 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
DownloadManager.getInstance().removeObserver(dataWatcher)
|
||||
}
|
||||
|
||||
override fun onDismiss(dialog: DialogInterface) {
|
||||
if (!mDismissByTouchInside) {
|
||||
SensorsBridge.trackPkgCheckDialogClick(
|
||||
buttonName = "关闭弹窗",
|
||||
gameId = gameEntity?.id ?: "",
|
||||
gameName = gameEntity?.name ?: "",
|
||||
gameType = gameEntity?.categoryChinese ?: "",
|
||||
isNotPrompt = if (binding.noRemindAgainCb.isVisible) {
|
||||
binding.noRemindAgainCb.isChecked
|
||||
} else null
|
||||
)
|
||||
}
|
||||
super.onDismiss(dialog)
|
||||
}
|
||||
|
||||
//安装、卸载事件
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onEventMainThread(busFour: EBPackage) {
|
||||
|
||||
@ -62,17 +62,17 @@ object ExposureUtils {
|
||||
host: String? = "unknown",
|
||||
path: String? = "unknown",
|
||||
downloadType: DownloadType
|
||||
) {
|
||||
): ExposureEvent? {
|
||||
val gameEntity = entity.copy()
|
||||
gameEntity.platform = platform
|
||||
gameEntity.downloadCompleteType = downloadType.toString()
|
||||
val traceEvent = trace?.toObject<ExposureEvent>()
|
||||
|
||||
if (TextUtils.isEmpty(entity.id)) return
|
||||
if (TextUtils.isEmpty(entity.id)) return null
|
||||
|
||||
// 避免生成 trace 相同的下载完成事件,根据日志看下载完成的同一秒有可能生成两条
|
||||
if (mDownloadCompleteTraceEventIdSet.contains(traceEvent?.id)) {
|
||||
return
|
||||
return null
|
||||
}
|
||||
|
||||
traceEvent?.payload?.gameId?.let { mDownloadCompleteTraceEventIdSet.add(it) }
|
||||
@ -91,12 +91,14 @@ object ExposureUtils {
|
||||
|
||||
ExposureManager.log(exposureEvent)
|
||||
ExposureManager.commitSavedExposureEvents(forcedUpload = true)
|
||||
|
||||
return exposureEvent
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getDownloadType(apkEntity: ApkEntity, gameId: String, isVGame: Boolean): DownloadType {
|
||||
fun getDownloadType(apkEntity: ApkEntity, gameId: String, asVGame: Boolean): DownloadType {
|
||||
return when {
|
||||
isVGame -> getVGameDownloadType(apkEntity, gameId)
|
||||
asVGame -> getVGameDownloadType(apkEntity, gameId)
|
||||
PackageUtils.isInstalled(
|
||||
HaloApp.getInstance().application,
|
||||
apkEntity.packageName
|
||||
@ -107,7 +109,7 @@ object ExposureUtils {
|
||||
|
||||
private fun getVGameDownloadType(apkEntity: ApkEntity, gameId: String): DownloadType {
|
||||
return when {
|
||||
PackagesManager.isCanUpdate(gameId, apkEntity.packageName) -> DownloadType.FUN_UPDATE
|
||||
PackagesManager.isCanUpdate(gameId, apkEntity.packageName, asVGame = true) -> DownloadType.FUN_UPDATE
|
||||
else -> DownloadType.FUN_DOWNLOAD
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,135 @@
|
||||
package com.gh.common.prioritychain
|
||||
|
||||
import android.app.Activity
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.FrameLayout
|
||||
import com.gh.common.util.NewFlatLogUtils
|
||||
import com.gh.gamecenter.GameDetailActivity
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.fragment.BaseFragment
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.view.BugFixedPopupWindow
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.databinding.PopupAccelerateNotificationBinding
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.fragment.MainWrapperViewModel
|
||||
|
||||
class AccelerateNotificationHandler(priority: Int) : PriorityChainHandler(priority) {
|
||||
|
||||
private var mActivity: Activity? = null
|
||||
private var mBaseHandler: BaseFragment.BaseHandler? = null
|
||||
private var mGameList: List<GameEntity>? = null
|
||||
private var mViewModel: MainWrapperViewModel? = null
|
||||
|
||||
/**
|
||||
* 提前预处理显示弹窗的内容
|
||||
*/
|
||||
fun doPreProcess(
|
||||
activity: Activity,
|
||||
baseHandler: BaseFragment.BaseHandler,
|
||||
gameEntityList: List<GameEntity>?,
|
||||
viewModel: MainWrapperViewModel
|
||||
) {
|
||||
mActivity = activity
|
||||
mGameList = gameEntityList
|
||||
mBaseHandler = baseHandler
|
||||
mViewModel = viewModel
|
||||
|
||||
if (getStatus() == STATUS_PENDING) {
|
||||
if (gameEntityList == null) {
|
||||
processNext()
|
||||
} else {
|
||||
updateStatus(STATUS_VALID)
|
||||
onProcess()
|
||||
}
|
||||
} else {
|
||||
if (gameEntityList == null) {
|
||||
updateStatus(STATUS_INVALID)
|
||||
} else {
|
||||
updateStatus(STATUS_VALID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onProcess() {
|
||||
when (getStatus()) {
|
||||
STATUS_VALID -> {
|
||||
val accelerateSet =
|
||||
HashSet(SPUtils.getStringSet(Constants.SP_ACCELERATE_NOTIFICATION_POP_UP_SET))
|
||||
if (!mGameList.isNullOrEmpty() && !accelerateSet.contains(mGameList!![0].messageId)) {
|
||||
showAccelerateNotificationPopupWindow(mActivity!!, mViewModel, mBaseHandler, mGameList!![0]) {
|
||||
processNext()
|
||||
}
|
||||
accelerateSet.add(mGameList!![0].messageId)
|
||||
SPUtils.setStringSet(Constants.SP_ACCELERATE_NOTIFICATION_POP_UP_SET, accelerateSet)
|
||||
} else {
|
||||
processNext()
|
||||
}
|
||||
}
|
||||
|
||||
STATUS_INVALID -> {
|
||||
processNext()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun showAccelerateNotificationPopupWindow(
|
||||
activity: Activity,
|
||||
viewModel: MainWrapperViewModel?,
|
||||
baseHandler: BaseFragment.BaseHandler?,
|
||||
gameEntity: GameEntity?,
|
||||
dismissCallback: (() -> Unit)?
|
||||
) {
|
||||
val binding: PopupAccelerateNotificationBinding =
|
||||
PopupAccelerateNotificationBinding.inflate(LayoutInflater.from(activity))
|
||||
if (gameEntity != null) {
|
||||
binding.gameIconView.displayGameIcon(gameEntity)
|
||||
binding.gameNameTv.text = gameEntity.name
|
||||
binding.root.setOnClickListener {
|
||||
NewFlatLogUtils.logMessageInformClickPluginVersion(
|
||||
gameEntity.id,
|
||||
gameEntity.name!!
|
||||
)
|
||||
if (gameEntity.messageId.isNotEmpty()) {
|
||||
// 把对应系统消息设为已读
|
||||
viewModel?.postMessageRead(gameEntity.messageId)
|
||||
}
|
||||
GameDetailActivity.startGameDetailActivity(
|
||||
context = activity,
|
||||
gameId = gameEntity.id,
|
||||
entrance = "首页插件上架弹窗",
|
||||
defaultTab = -1,
|
||||
isSkipGameComment = false,
|
||||
scrollToLibao = false,
|
||||
openVideoStreaming = false,
|
||||
openPlatformWindow = true,
|
||||
traceEvent = null
|
||||
)
|
||||
}
|
||||
}
|
||||
BugFixedPopupWindow(
|
||||
binding.root,
|
||||
FrameLayout.LayoutParams.MATCH_PARENT,
|
||||
FrameLayout.LayoutParams.WRAP_CONTENT
|
||||
).apply {
|
||||
isTouchable = true
|
||||
isFocusable = true
|
||||
isOutsideTouchable = true
|
||||
animationStyle = R.style.popup_window_ease_in_and_out_anim_style
|
||||
showAtLocation(
|
||||
activity.window.decorView,
|
||||
Gravity.TOP,
|
||||
0,
|
||||
DisplayUtils.getStatusBarHeight(activity.resources) + DisplayUtils.dip2px(42f)
|
||||
)
|
||||
setOnDismissListener {
|
||||
dismissCallback?.invoke()
|
||||
}
|
||||
baseHandler?.postDelayed({ dismiss() }, 5000)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,87 @@
|
||||
package com.gh.common.prioritychain
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.gh.gamecenter.common.base.fragment.BaseLazyFragment
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.core.provider.IFloatingWindowProvider
|
||||
import com.gh.gamecenter.feature.entity.WelcomeDialogEntity
|
||||
import com.gh.gamecenter.floatingwindow.FloatingWindowEntity
|
||||
import com.gh.gamecenter.fragment.WelcomeDialogFragment
|
||||
import com.lightgame.utils.Utils
|
||||
|
||||
class FloatingWindowHandler(priority: Int) : PriorityChainHandler(priority) {
|
||||
|
||||
private var mFragment: BaseLazyFragment? = null
|
||||
private var mRecyclerView: RecyclerView? = null
|
||||
private var mWindowList: ArrayList<FloatingWindowEntity>? = null
|
||||
|
||||
fun setData(windowList: ArrayList<FloatingWindowEntity>?) {
|
||||
mWindowList = windowList
|
||||
|
||||
if (mFragment != null) {
|
||||
doPreProcess()
|
||||
}
|
||||
}
|
||||
|
||||
fun setView(
|
||||
fragment: BaseLazyFragment,
|
||||
recyclerView: RecyclerView
|
||||
) {
|
||||
mFragment = fragment
|
||||
mRecyclerView = recyclerView
|
||||
|
||||
if (mWindowList != null) {
|
||||
doPreProcess()
|
||||
}
|
||||
}
|
||||
|
||||
private fun doPreProcess() {
|
||||
Utils.log(TAG, "FloatingWindowHandler preProcess windowSize is -> ${mWindowList?.size}")
|
||||
|
||||
if (getStatus() == STATUS_PENDING) {
|
||||
if (!mWindowList.isNullOrEmpty()) {
|
||||
updateStatus(STATUS_VALID)
|
||||
onProcess()
|
||||
} else {
|
||||
processNext()
|
||||
}
|
||||
} else {
|
||||
if (!mWindowList.isNullOrEmpty()) {
|
||||
updateStatus(STATUS_VALID)
|
||||
} else {
|
||||
updateStatus(STATUS_INVALID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onProcess() {
|
||||
when (getStatus()) {
|
||||
STATUS_VALID -> {
|
||||
val floatingWindowProvider =
|
||||
ARouter.getInstance().build(RouteConsts.provider.floatingwindow)
|
||||
.navigation() as? IFloatingWindowProvider<WelcomeDialogEntity>
|
||||
|
||||
// 强校验所有条件均通过才能显示
|
||||
if (floatingWindowProvider == null || mFragment == null || mFragment?.isAdded == false || mRecyclerView == null) {
|
||||
processNext()
|
||||
return
|
||||
}
|
||||
|
||||
floatingWindowProvider.showFloatingWindowOnly(
|
||||
mFragment!!,
|
||||
mRecyclerView!!,
|
||||
mWindowList!!,
|
||||
) {
|
||||
val welcomeDialog = WelcomeDialogFragment.getInstance(it, true, mFragment)
|
||||
welcomeDialog.show(mFragment!!.childFragmentManager, "WelcomeDialog")
|
||||
}
|
||||
}
|
||||
|
||||
STATUS_INVALID -> {
|
||||
processNext()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
package com.gh.common.prioritychain
|
||||
|
||||
import com.gh.gamecenter.fragment.HomeSearchToolWrapperFragment
|
||||
|
||||
class HomePushHandler(priority: Int): PriorityChainHandler(priority) {
|
||||
|
||||
private var mHomeFragment: HomeSearchToolWrapperFragment? = null
|
||||
|
||||
/**
|
||||
* 提前预处理显示弹窗的内容
|
||||
*/
|
||||
fun doPreProcess(homeFragment: HomeSearchToolWrapperFragment?, shouldShow: Boolean) {
|
||||
mHomeFragment = homeFragment
|
||||
|
||||
if (getStatus() == STATUS_PENDING) {
|
||||
if (shouldShow && homeFragment != null) {
|
||||
updateStatus(STATUS_VALID)
|
||||
onProcess()
|
||||
} else {
|
||||
processNext()
|
||||
}
|
||||
} else {
|
||||
if (shouldShow && homeFragment != null) {
|
||||
updateStatus(STATUS_VALID)
|
||||
} else {
|
||||
updateStatus(STATUS_INVALID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onProcess() {
|
||||
when (getStatus()) {
|
||||
STATUS_VALID -> {
|
||||
// 目前首页下拉二楼是首页最后一个弹窗类的东西,还没实现回调,如果有其它要在它后面弹出的,需要自行在它的实现结果后添加回调
|
||||
mHomeFragment?.popUpHomePushIfNeeded {
|
||||
processNext()
|
||||
}
|
||||
}
|
||||
STATUS_INVALID -> {
|
||||
processNext()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.gh.common.prioritychain
|
||||
|
||||
import com.gh.gamecenter.common.entity.NotificationUgc
|
||||
import com.gh.gamecenter.common.utils.NotificationHelper
|
||||
import com.gh.gamecenter.login.user.UserManager
|
||||
|
||||
class NotificationPermissionDialogHandler(priority: Int) : PriorityChainHandler(priority) {
|
||||
|
||||
override fun onProcess() {
|
||||
// 仅登录后再启动光环时请求一次权限
|
||||
if (UserManager.getInstance().isLoggedIn) {
|
||||
NotificationHelper.showNotificationHintDialog(NotificationUgc.LOGIN) {
|
||||
processNext()
|
||||
}
|
||||
} else {
|
||||
processNext()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package com.gh.common.prioritychain
|
||||
|
||||
import java.util.*
|
||||
import java.util.concurrent.PriorityBlockingQueue
|
||||
|
||||
class PriorityChain {
|
||||
|
||||
private val mHandlerQueue: Queue<PriorityChainHandler> = PriorityBlockingQueue()
|
||||
|
||||
fun addHandler(handler: PriorityChainHandler) {
|
||||
mHandlerQueue.add(handler.also {
|
||||
it.setPriorityChain(this)
|
||||
})
|
||||
}
|
||||
|
||||
fun start() {
|
||||
mHandlerQueue.poll()?.process(mHandlerQueue)
|
||||
}
|
||||
|
||||
fun isHandlerQueueEmpty() = mHandlerQueue.isEmpty()
|
||||
|
||||
}
|
||||
@ -0,0 +1,71 @@
|
||||
package com.gh.common.prioritychain
|
||||
|
||||
import com.lightgame.utils.Utils
|
||||
import java.util.*
|
||||
|
||||
abstract class PriorityChainHandler(private val mPriority: Int) : Comparable<PriorityChainHandler> {
|
||||
|
||||
private var mStatus = STATUS_UNKNOWN
|
||||
private var mQueue: Queue<PriorityChainHandler>? = null
|
||||
|
||||
private var mPriorityChain: PriorityChain? = null
|
||||
|
||||
/**
|
||||
* 获取当前 handler 的状态
|
||||
* - 等待结果返回 (STATUS_PENDING)
|
||||
* - 无需执行 (STATUS_INVALID)
|
||||
* - 可执行 (STATUS_VALID)
|
||||
* - 未知 (STATUS_UNKNOWN)
|
||||
*/
|
||||
fun getStatus(): Int = mStatus
|
||||
|
||||
fun updateStatus(status: Int) {
|
||||
Utils.log(TAG, "${javaClass.simpleName} updateStatus $status")
|
||||
|
||||
mStatus = status
|
||||
}
|
||||
|
||||
fun setPriorityChain(priorityChain: PriorityChain) {
|
||||
mPriorityChain = priorityChain
|
||||
}
|
||||
|
||||
fun process(queue: Queue<PriorityChainHandler>) {
|
||||
Utils.log(TAG, "${javaClass.simpleName} process $mStatus")
|
||||
|
||||
mQueue = queue
|
||||
// 若当前 handler 未经处理,将其状态改为 pending
|
||||
if (mStatus == STATUS_UNKNOWN) {
|
||||
updateStatus(STATUS_PENDING)
|
||||
}
|
||||
|
||||
onProcess()
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行相关功能的地方
|
||||
*/
|
||||
abstract fun onProcess()
|
||||
|
||||
/**
|
||||
* 分发给下一个 handler 处理
|
||||
*/
|
||||
fun processNext() {
|
||||
Utils.log(TAG, "${javaClass.simpleName} processNext $mStatus")
|
||||
|
||||
mQueue?.poll()?.process(mQueue!!)
|
||||
}
|
||||
|
||||
override fun compareTo(other: PriorityChainHandler): Int {
|
||||
return (mPriority - other.mPriority)
|
||||
}
|
||||
|
||||
companion object {
|
||||
internal const val STATUS_PENDING = 0
|
||||
internal const val STATUS_INVALID = 1
|
||||
internal const val STATUS_VALID = 2
|
||||
internal const val STATUS_UNKNOWN = 3
|
||||
|
||||
const val TAG = "PriorityChainHandler"
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
package com.gh.common.prioritychain
|
||||
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import com.gh.common.dialog.PrivacyPolicyDialogFragment
|
||||
import com.gh.gamecenter.entity.DialogEntity
|
||||
|
||||
class PrivacyPolicyDialogHandler(priority: Int) : PriorityChainHandler(priority) {
|
||||
|
||||
private var mActivity: FragmentActivity? = null
|
||||
private var mPrivacyPolicyEntity: DialogEntity.PrivacyPolicyEntity? = null
|
||||
|
||||
/**
|
||||
* 提前预处理显示弹窗的内容
|
||||
*/
|
||||
fun doPreProcess(fragmentActivity: FragmentActivity, privacyPolicyEntity: DialogEntity.PrivacyPolicyEntity?) {
|
||||
mActivity = fragmentActivity
|
||||
mPrivacyPolicyEntity = privacyPolicyEntity
|
||||
|
||||
if (getStatus() == STATUS_PENDING) {
|
||||
if (privacyPolicyEntity == null) {
|
||||
processNext()
|
||||
} else {
|
||||
updateStatus(STATUS_VALID)
|
||||
onProcess()
|
||||
}
|
||||
} else {
|
||||
if (privacyPolicyEntity == null) {
|
||||
updateStatus(STATUS_INVALID)
|
||||
} else {
|
||||
updateStatus(STATUS_VALID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onProcess() {
|
||||
when(getStatus()) {
|
||||
STATUS_VALID -> {
|
||||
PrivacyPolicyDialogFragment.show(mActivity!!, mPrivacyPolicyEntity) { _: Boolean? ->
|
||||
processNext()
|
||||
}
|
||||
}
|
||||
STATUS_INVALID -> {
|
||||
processNext()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
package com.gh.common.prioritychain
|
||||
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.gh.common.dialog.ReserveDialog
|
||||
import com.gh.gamecenter.common.entity.SimpleGameEntity
|
||||
import com.gh.gamecenter.message.MessageUnreadRepository
|
||||
|
||||
class ReserveDialogHandler(priority: Int) : PriorityChainHandler(priority) {
|
||||
|
||||
private var mFragment: Fragment? = null
|
||||
private var mReserveData: List<SimpleGameEntity>? = null
|
||||
|
||||
/**
|
||||
* 提前预处理显示弹窗的内容
|
||||
*/
|
||||
fun doPreProcess(fragment: Fragment, reserveData: List<SimpleGameEntity>?) {
|
||||
mFragment = fragment
|
||||
mReserveData = reserveData
|
||||
|
||||
if (getStatus() == STATUS_PENDING) {
|
||||
if (reserveData.isNullOrEmpty()) {
|
||||
processNext()
|
||||
} else {
|
||||
updateStatus(STATUS_VALID)
|
||||
onProcess()
|
||||
}
|
||||
} else {
|
||||
if (reserveData.isNullOrEmpty()) {
|
||||
updateStatus(STATUS_INVALID)
|
||||
} else {
|
||||
updateStatus(STATUS_VALID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onProcess() {
|
||||
when (getStatus()) {
|
||||
STATUS_VALID -> {
|
||||
val reserveDialog = ReserveDialog.getInstance(mReserveData!!)
|
||||
reserveDialog.setOnDismissListener {
|
||||
MessageUnreadRepository.loadMessageUnreadData()
|
||||
processNext()
|
||||
}
|
||||
reserveDialog.show(mFragment!!.childFragmentManager, "reserveDialog")
|
||||
}
|
||||
|
||||
STATUS_INVALID -> {
|
||||
processNext()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package com.gh.common.prioritychain
|
||||
|
||||
import android.content.Context
|
||||
import com.gh.gamecenter.manager.UpdateManager
|
||||
|
||||
class UpdateDialogHandler(context: Context, priority: Int) : PriorityChainHandler(priority) {
|
||||
|
||||
private val mUpdateManager = UpdateManager.getInstance(context)
|
||||
|
||||
override fun onProcess() {
|
||||
mUpdateManager.checkUpdate(true, null)
|
||||
mUpdateManager.setDismissCallback {
|
||||
processNext()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,79 @@
|
||||
package com.gh.common.prioritychain
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.gh.gamecenter.common.callback.BiCallback
|
||||
import com.gh.gamecenter.common.utils.ImageUtils
|
||||
import com.gh.gamecenter.feature.entity.WelcomeDialogEntity
|
||||
import com.gh.gamecenter.fragment.MainWrapperViewModel
|
||||
import com.gh.gamecenter.fragment.WelcomeDialogFragment
|
||||
import com.halo.assistant.HaloApp
|
||||
|
||||
class WelcomeDialogHandler(priority: Int): PriorityChainHandler(priority) {
|
||||
|
||||
private var mFragment: Fragment? = null
|
||||
private var mWelcomeDialogEntity: WelcomeDialogEntity? = null
|
||||
|
||||
fun doPreProcess(fragment: Fragment, welcomeDialogEntity: WelcomeDialogEntity?) {
|
||||
mFragment = fragment
|
||||
mWelcomeDialogEntity = welcomeDialogEntity
|
||||
|
||||
val preLoadClosure = {
|
||||
// 判断启动本次应用是否已经弹窗,不是的话弹启动弹窗
|
||||
if (HaloApp.get(MainWrapperViewModel.SHOULD_SHOW_OPENING_DIALOG, false) == null) {
|
||||
HaloApp.put(MainWrapperViewModel.SHOULD_SHOW_OPENING_DIALOG, false)
|
||||
ImageUtils.getBitmap(mWelcomeDialogEntity!!.icon, object : BiCallback<Bitmap, Boolean> {
|
||||
override fun onFirst(first: Bitmap) {
|
||||
if (getStatus() == STATUS_PENDING) {
|
||||
updateStatus(STATUS_VALID)
|
||||
onProcess()
|
||||
} else {
|
||||
updateStatus(STATUS_VALID)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSecond(second: Boolean) {
|
||||
processNext()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
processNext()
|
||||
}
|
||||
}
|
||||
|
||||
if (getStatus() == STATUS_PENDING) {
|
||||
if (welcomeDialogEntity == null) {
|
||||
processNext()
|
||||
} else {
|
||||
preLoadClosure.invoke()
|
||||
}
|
||||
} else {
|
||||
if (welcomeDialogEntity == null) {
|
||||
updateStatus(STATUS_INVALID)
|
||||
} else {
|
||||
preLoadClosure.invoke()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onProcess() {
|
||||
when (getStatus()) {
|
||||
STATUS_VALID -> {
|
||||
if (mFragment == null || !mFragment!!.isAdded) {
|
||||
updateStatus(STATUS_INVALID)
|
||||
processNext()
|
||||
} else {
|
||||
val welcomeDialog = WelcomeDialogFragment.getInstance(mWelcomeDialogEntity)
|
||||
welcomeDialog.setOnDismissListener {
|
||||
processNext()
|
||||
}
|
||||
welcomeDialog.show(mFragment!!.childFragmentManager, "WelcomeDialog")
|
||||
}
|
||||
}
|
||||
STATUS_INVALID -> {
|
||||
processNext()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -56,6 +56,22 @@ class ConfigProviderImpl : IConfigProvider {
|
||||
return Config.getSettings()?.image?.oss?.gifWaterMark ?: ""
|
||||
}
|
||||
|
||||
override fun getVideoSnapshotSuffix(): String {
|
||||
return Config.getSettings()?.image?.oss?.snapshot ?: ""
|
||||
}
|
||||
|
||||
override fun getImageCropSuffix(): String {
|
||||
return Config.getSettings()?.image?.oss?.crop ?: ""
|
||||
}
|
||||
|
||||
override fun getImageInfoSuffix(): String {
|
||||
return Config.getSettings()?.image?.oss?.info ?: ""
|
||||
}
|
||||
|
||||
override fun getImageResizeSuffix(): String {
|
||||
return Config.getSettings()?.image?.oss?.resize ?: ""
|
||||
}
|
||||
|
||||
override fun getQQ(): String {
|
||||
return Config.getSettings()?.support?.qq ?: ""
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.gh.common.provider
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gh.common.util.DirectUtils
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
@ -53,16 +54,16 @@ class DirectProviderImpl : IDirectProvider {
|
||||
DirectUtils.directDouyin(context, userId)
|
||||
}
|
||||
|
||||
override fun directToSuggestionFromDiagnosis(context: Context, diagnosis: String) {
|
||||
DirectUtils.directToSuggestion(context, diagnosis = diagnosis)
|
||||
override fun directToSuggestionFromDiagnosis(context: Context, content: String, diagnosis: String) {
|
||||
DirectUtils.directToSuggestion(context, content = content, diagnosis = diagnosis)
|
||||
}
|
||||
|
||||
override fun directToQa(context: Context, text: String?, id: String) {
|
||||
DirectUtils.directToQa(context, text, id)
|
||||
}
|
||||
|
||||
override fun directToHelpAndFeedback(context: Context, position: Int) {
|
||||
DirectUtils.directToHelpAndFeedback(context, position)
|
||||
override fun directToHelpAndFeedback(context: Context, bundle: Bundle?) {
|
||||
DirectUtils.directToHelpAndFeedback(context, bundle)
|
||||
}
|
||||
|
||||
override fun directToQqGroup(context: Context, groupNumber: String?): Boolean {
|
||||
@ -119,6 +120,10 @@ class DirectProviderImpl : IDirectProvider {
|
||||
return DirectUtils.directToQGameHome(context)
|
||||
}
|
||||
|
||||
override fun directToExternalBrowser(context: Context, url: String) {
|
||||
DirectUtils.directToExternalBrowser(context, url)
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@ -3,11 +3,14 @@ package com.gh.common.provider
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gh.common.util.NewFlatLogUtils
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.GlobalActivityManager
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.common.exposure.ExposureSource
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.entity.GameUpdateEntity
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.gh.gamecenter.feature.provider.IDownloadButtonClickedProvider
|
||||
import com.gh.gamecenter.feature.view.DownloadButton
|
||||
import com.gh.gamecenter.packagehelper.PackageRepository
|
||||
@ -25,6 +28,7 @@ class DownloadButtonClickedProviderImpl : IDownloadButtonClickedProvider {
|
||||
var downloadStatusInChinese = ""
|
||||
var gameSchemaType = ""
|
||||
var packageName = ""
|
||||
var exposureSourceList: List<ExposureSource>? = null
|
||||
|
||||
val boundedObject = downloadButton.getObject()
|
||||
|
||||
@ -36,17 +40,21 @@ class DownloadButtonClickedProviderImpl : IDownloadButtonClickedProvider {
|
||||
gameId = boundedObject.id
|
||||
gameName = boundedObject.name ?: ""
|
||||
gameCategory = boundedObject.category ?: ""
|
||||
downloadStatus = if (boundedObject.isVGame()) {
|
||||
"畅玩"
|
||||
} else if (boundedObject.downloadStatus == "demo") {
|
||||
"试玩"
|
||||
} else {
|
||||
"下载"
|
||||
}
|
||||
downloadStatus =
|
||||
if (boundedObject.isVGamePreferred()) {
|
||||
"畅玩"
|
||||
} else {
|
||||
if (boundedObject.downloadStatus == "demo") {
|
||||
"试玩"
|
||||
} else {
|
||||
"下载"
|
||||
}
|
||||
}
|
||||
gameTypeInChinese = boundedObject.categoryChinese
|
||||
downloadStatusInChinese = boundedObject.downloadStatusChinese
|
||||
gameSchemaType = boundedObject.gameBitChinese
|
||||
packageName = boundedObject.getUniquePackageName() ?: ""
|
||||
exposureSourceList = boundedObject.exposureEvent?.source
|
||||
}
|
||||
|
||||
is GameUpdateEntity -> {
|
||||
@ -57,14 +65,16 @@ class DownloadButtonClickedProviderImpl : IDownloadButtonClickedProvider {
|
||||
gameTypeInChinese = boundedObject.categoryChinese
|
||||
downloadStatusInChinese = boundedObject.downloadStatusChinese
|
||||
packageName = boundedObject.packageName
|
||||
exposureSourceList = boundedObject.exposureEvent?.source
|
||||
}
|
||||
|
||||
is DownloadEntity -> {
|
||||
gameId = boundedObject.gameId
|
||||
gameName = boundedObject.name ?: ""
|
||||
gameCategory = boundedObject.getGameCategory()
|
||||
downloadStatus = if (boundedObject.isVGame()) "畅玩" else "下载"
|
||||
downloadStatus = if (boundedObject.asVGame()) "畅玩" else "下载"
|
||||
packageName = boundedObject.packageName
|
||||
exposureSourceList = boundedObject.exposureTrace?.toObject<ExposureEvent>()?.source
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,28 +97,38 @@ class DownloadButtonClickedProviderImpl : IDownloadButtonClickedProvider {
|
||||
}
|
||||
|
||||
// 预约状态不上报
|
||||
if (downloadButton.buttonStyle != DownloadButton.ButtonStyle.RESERVABLE
|
||||
&& downloadButton.buttonStyle != DownloadButton.ButtonStyle.RESERVED
|
||||
) {
|
||||
if (downloadButton.buttonStyle == DownloadButton.ButtonStyle.NORMAL
|
||||
|| downloadButton.buttonStyle == DownloadButton.ButtonStyle.PLUGIN) {
|
||||
|
||||
val text = downloadButton.text.ifEmpty {
|
||||
downloadButton.getTag(R.string.download) ?: ""
|
||||
}.toString()
|
||||
|
||||
val downloadType = if (text.contains("畅玩")) {
|
||||
"畅玩下载"
|
||||
} else {
|
||||
"本地下载"
|
||||
}
|
||||
|
||||
// 上报神策点击事件
|
||||
SensorsBridge.trackEvent(
|
||||
SensorsBridge.trackEventWithExposureSource(
|
||||
"DownLoadbuttonClick",
|
||||
exposureSourceList,
|
||||
"game_id", gameId,
|
||||
"game_name", gameName,
|
||||
"game_type", gameTypeInChinese,
|
||||
"download_status", downloadStatusInChinese,
|
||||
"button_name", downloadButton.text,
|
||||
"game_schema_type", gameSchemaType,
|
||||
"download_type", downloadType,
|
||||
"page_name", GlobalActivityManager.getCurrentPageEntity().pageName,
|
||||
"page_id", GlobalActivityManager.getCurrentPageEntity().pageId,
|
||||
"page_business_id", GlobalActivityManager.getCurrentPageEntity().pageBusinessId,
|
||||
"last_page_name", GlobalActivityManager.getLastPageEntity().pageName,
|
||||
"last_page_id", GlobalActivityManager.getLastPageEntity().pageId,
|
||||
"last_page_business_id", GlobalActivityManager.getLastPageEntity().pageBusinessId
|
||||
"last_page_business_id", GlobalActivityManager.getLastPageEntity().pageBusinessId,
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -6,7 +6,6 @@ import com.gh.common.util.DirectUtils
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.common.entity.CommunityEntity
|
||||
import com.gh.gamecenter.common.entity.LinkEntity
|
||||
import com.gh.gamecenter.common.entity.SimpleGameEntity
|
||||
import com.gh.gamecenter.common.entity.SuggestType
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.gh.gamecenter.feature.provider.ILinkDirectUtilsProvider
|
||||
@ -48,17 +47,6 @@ class LinkDirectUtilsProviderImpl : ILinkDirectUtilsProvider {
|
||||
DirectUtils.directToSuggestion(context, type, suggestHintType, content, isQaFeedback, qaContentId)
|
||||
}
|
||||
|
||||
override fun directToSuggestion(
|
||||
context: Context,
|
||||
type: SuggestType,
|
||||
suggestHintType: String?,
|
||||
content: String?,
|
||||
game: SimpleGameEntity,
|
||||
platform: String
|
||||
) {
|
||||
DirectUtils.directToSuggestion(context, type, suggestHintType, content, game, platform)
|
||||
}
|
||||
|
||||
override fun directToSuggestion(context: Context, type: SuggestType, hiddenHint: String) {
|
||||
DirectUtils.directToSuggestion(context, type, hiddenHint)
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@ import com.lightgame.download.DownloadEntity
|
||||
class PackageInstallerProviderImpl : IPackageInstallerProvider {
|
||||
|
||||
override fun install(context: Context, downloadEntity: DownloadEntity, showUnzipToast: Boolean) {
|
||||
PackageInstaller.install(context, downloadEntity, showUnzipToast)
|
||||
PackageInstaller.install(context, downloadEntity, showUnzipToast, false)
|
||||
}
|
||||
|
||||
override fun uninstall(context: Context, path: String) {
|
||||
|
||||
@ -8,14 +8,6 @@ import com.gh.vspace.VHelper
|
||||
|
||||
@Route(path = RouteConsts.provider.vhelper, name = "VHelper暴露服务")
|
||||
class VHelperProviderImpl: IVHelperProvider {
|
||||
override fun getPlatformV(): String {
|
||||
return VHelper.PLATFORM_V
|
||||
}
|
||||
|
||||
override fun getVUrl(originUrl: String?): String {
|
||||
return VHelper.getVUrl(originUrl)
|
||||
}
|
||||
|
||||
override fun isVGameOn(): Boolean {
|
||||
return VHelper.isVGameOn()
|
||||
}
|
||||
|
||||
@ -21,10 +21,6 @@ class WebProviderImpl : IWebProvider {
|
||||
return WebActivity.getBindWechatIntent(context)
|
||||
}
|
||||
|
||||
override fun getSecurityCertificationIntent(context: Context): Intent {
|
||||
return WebActivity.getSecurityCertificationIntent(context)
|
||||
}
|
||||
|
||||
override fun getQAIntent(
|
||||
context: Context?,
|
||||
url: String?,
|
||||
|
||||
@ -41,7 +41,7 @@ object NewSimulatorGameManager {
|
||||
private const val KEY_USE_DEBUG_API = "USE_DEBUG_API"
|
||||
private const val KEY_META = "META"
|
||||
|
||||
// private const val GH_RETRO_EMU_APP_PACKAGE_NAME = "com.gh.retroemu"
|
||||
// private const val GH_RETRO_EMU_APP_PACKAGE_NAME = "com.gh.retroemu"
|
||||
private const val GH_RETRO_EMU_APP_LAUNCHER_ACTIVITY_NAME = "com.gh.retroemu.ui.SplashActivity"
|
||||
|
||||
|
||||
@ -61,10 +61,10 @@ object NewSimulatorGameManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* 弹出更新弹框
|
||||
*/
|
||||
* 弹出更新弹框
|
||||
*/
|
||||
@JvmStatic
|
||||
fun showUpdateNewsSimulator(context: Context, callback: EmptyCallback? = null){
|
||||
fun showUpdateNewsSimulator(context: Context, gameEntity: GameEntity, callback: EmptyCallback? = null) {
|
||||
NewFlatLogUtils.logSimulatorUpdateAlertShow()
|
||||
DialogHelper.showDialog(
|
||||
context,
|
||||
@ -76,7 +76,13 @@ object NewSimulatorGameManager {
|
||||
NewFlatLogUtils.logSimulatorUpdateAlertClick("更新")
|
||||
val simulator = Config.getNewSimulatorEntitySetting()
|
||||
if (simulator != null) {
|
||||
SimulatorDownloadManager.getInstance().showDownloadingDialog(context, simulator)
|
||||
SimulatorDownloadManager.getInstance().showDownloadingDialog(
|
||||
context,
|
||||
simulator,
|
||||
gameEntity.id,
|
||||
gameEntity.name ?: "",
|
||||
gameEntity.categoryChinese
|
||||
)
|
||||
}
|
||||
},
|
||||
cancelClickCallback = {
|
||||
@ -127,7 +133,10 @@ object NewSimulatorGameManager {
|
||||
)
|
||||
|
||||
val intent = Intent()
|
||||
intent.setClassName(SimulatorGameManager.NEW_SIMULATOR_PACKAGE_NAME, GH_RETRO_EMU_APP_LAUNCHER_ACTIVITY_NAME)
|
||||
intent.setClassName(
|
||||
SimulatorGameManager.NEW_SIMULATOR_PACKAGE_NAME,
|
||||
GH_RETRO_EMU_APP_LAUNCHER_ACTIVITY_NAME
|
||||
)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
intent.data = gamePackageFileUri
|
||||
gameEntity.getApk().safelyGetInRelease(0)?.let { apk ->
|
||||
@ -138,7 +147,10 @@ object NewSimulatorGameManager {
|
||||
intent.putExtra(KEY_GAME_ICON, it)
|
||||
intent.putExtra(KEY_GAME_PACKAGE_PATH, downloadEntity.path) // 游戏包文件路径,冗余参数)
|
||||
intent.putExtra(KEY_GAME_PACKAGE_SDCARD_PATH, true)
|
||||
intent.putExtra(KEY_GAME_PACKAGE_LAST_MODIFICATION, File(downloadEntity.path).lastModified()) // 游戏包文件修改时间
|
||||
intent.putExtra(
|
||||
KEY_GAME_PACKAGE_LAST_MODIFICATION,
|
||||
File(downloadEntity.path).lastModified()
|
||||
) // 游戏包文件修改时间
|
||||
intent.putExtra(KEY_GAME_EMU_SYSTEM, gameEntity.simulatorType) // 模拟器类型
|
||||
intent.putExtra(KEY_GAME_ID, gameEntity.id)
|
||||
// TODO 补充光环模拟器的游戏 id
|
||||
|
||||
@ -14,6 +14,7 @@ import com.gh.common.util.PackageInstaller
|
||||
import com.gh.common.util.PackageUtils
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.GlobalActivityManager
|
||||
import com.gh.gamecenter.common.base.TrackableDialog
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
@ -47,6 +48,7 @@ class SimulatorDownloadManager private constructor() {
|
||||
private var simulator: SimulatorEntity? = null
|
||||
private var gameId: String = ""
|
||||
private var gameName: String = ""
|
||||
private var gameType: String = ""
|
||||
private var downloadType: String = ""
|
||||
|
||||
private val dataWatcher = object : DataWatcher() {
|
||||
@ -99,33 +101,43 @@ class SimulatorDownloadManager private constructor() {
|
||||
downloadDialog?.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
DownloadStatus.diskisfull == downloadEntity.status -> {
|
||||
ToastUtils.showToast("存储空间已满,下载任务已暂停")
|
||||
}
|
||||
|
||||
DownloadStatus.diskioerror == downloadEntity.status -> {
|
||||
ToastUtils.showToast("下载 IO 出现异常,下载任务已暂停")
|
||||
}
|
||||
|
||||
DownloadStatus.neterror == downloadEntity.status -> {
|
||||
ToastUtils.showToast("网络不稳定,下载任务已暂停")
|
||||
}
|
||||
|
||||
DownloadStatus.timeout == downloadEntity.status -> {
|
||||
ToastUtils.showToast("网络不稳定,下载任务已暂停")
|
||||
}
|
||||
|
||||
DownloadStatus.notfound == downloadEntity.status -> {
|
||||
ToastUtils.showToast("下载链接异常,请稍后重试")
|
||||
}
|
||||
|
||||
DownloadStatus.uncertificated == downloadEntity.status -> {
|
||||
ToastUtils.showToast("请先进行实名认证")
|
||||
}
|
||||
|
||||
DownloadStatus.unqualified == downloadEntity.status -> {
|
||||
ToastUtils.showToast("未成年人暂不允许在此时间下载游戏")
|
||||
}
|
||||
|
||||
DownloadStatus.unavailable == downloadEntity.status -> {
|
||||
ToastUtils.showToast("该游戏未接入防沉迷系统,暂不支持下载")
|
||||
}
|
||||
|
||||
DownloadStatus.banned == downloadEntity.status -> {
|
||||
ToastUtils.showToast("网络异常")
|
||||
}
|
||||
|
||||
DownloadStatus.hijack == downloadEntity.status -> {
|
||||
ToastUtils.showToast("网络劫持,请稍后重试")
|
||||
}
|
||||
@ -135,7 +147,7 @@ class SimulatorDownloadManager private constructor() {
|
||||
}
|
||||
|
||||
fun showDownloadDialog(context: Context, simulator: SimulatorEntity?, location: SimulatorLocation) {
|
||||
showDownloadDialog(context, simulator, location, "", "", null)
|
||||
showDownloadDialog(context, simulator, location, "", "", "", null)
|
||||
}
|
||||
|
||||
fun showDownloadDialog(
|
||||
@ -144,6 +156,7 @@ class SimulatorDownloadManager private constructor() {
|
||||
location: SimulatorLocation,
|
||||
gameId: String = "",
|
||||
gameName: String = "",
|
||||
gameCategoryChinese: String = "",
|
||||
cancelCallback: (() -> Unit)? = null
|
||||
) {
|
||||
if (context == null) return
|
||||
@ -152,6 +165,7 @@ class SimulatorDownloadManager private constructor() {
|
||||
this.simulator = simulator
|
||||
this.gameId = gameId
|
||||
this.gameName = gameName
|
||||
this.gameType = gameCategoryChinese
|
||||
|
||||
PermissionHelper.checkGetInstalledAppsListBeforeAction(context, object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
@ -183,7 +197,8 @@ class SimulatorDownloadManager private constructor() {
|
||||
return
|
||||
}
|
||||
val title = if (shouldShowUpdate && isInstalled) "更新模拟器" else "安装模拟器"
|
||||
val message = if (shouldShowUpdate && isInstalled) "检测到模拟器存在更高版本,是否前往更新" else "模拟器游戏需要先下载安装对应的模拟器,才可以运行"
|
||||
val message =
|
||||
if (shouldShowUpdate && isInstalled) "检测到模拟器存在更高版本,是否前往更新" else "模拟器游戏需要先下载安装对应的模拟器,才可以运行"
|
||||
val positiveText =
|
||||
if (shouldShowUpdate && isInstalled) "更新(${simulator?.apk?.size})" else "下载(${simulator?.apk?.size})"
|
||||
val negativeText = if (shouldShowUpdate && isInstalled) "下次再说" else "取消"
|
||||
@ -195,6 +210,25 @@ class SimulatorDownloadManager private constructor() {
|
||||
if (shouldShowUpdate && isInstalled) {
|
||||
NewFlatLogUtils.logSimulatorUpdateAlertShow()
|
||||
}
|
||||
if (shouldShowUpdate && isInstalled) {
|
||||
SensorsBridge.trackSimulatorUpdateDialogShow(
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameCategoryChinese,
|
||||
lastPageId = GlobalActivityManager.getLastPageEntity().pageId,
|
||||
lastPageName = GlobalActivityManager.getLastPageEntity().pageName,
|
||||
lastPageBusinessId = GlobalActivityManager.getLastPageEntity().pageBusinessId
|
||||
)
|
||||
} else {
|
||||
SensorsBridge.trackSimulatorInstallDialogShow(
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameCategoryChinese,
|
||||
lastPageId = GlobalActivityManager.getLastPageEntity().pageId,
|
||||
lastPageName = GlobalActivityManager.getLastPageEntity().pageName,
|
||||
lastPageBusinessId = GlobalActivityManager.getLastPageEntity().pageBusinessId
|
||||
)
|
||||
}
|
||||
DialogHelper.showDialog(
|
||||
context,
|
||||
title,
|
||||
@ -207,16 +241,79 @@ class SimulatorDownloadManager private constructor() {
|
||||
cancelCallback?.invoke()
|
||||
NewFlatLogUtils.logSimulatorUpdateAlertClick("取消")
|
||||
MtaHelper.onEvent(trackableEntity.event, trackableEntity.key, "点击下次再说")
|
||||
SensorsBridge.trackSimulatorUpdateDialogClick(
|
||||
buttonName = negativeText,
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameCategoryChinese,
|
||||
lastPageId = GlobalActivityManager.getLastPageEntity().pageId,
|
||||
lastPageName = GlobalActivityManager.getLastPageEntity().pageName,
|
||||
lastPageBusinessId = GlobalActivityManager.getLastPageEntity().pageBusinessId
|
||||
)
|
||||
} else {
|
||||
SensorsBridge.trackSimulatorInstallDialogClick(
|
||||
buttonName = negativeText,
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameCategoryChinese,
|
||||
lastPageId = GlobalActivityManager.getLastPageEntity().pageId,
|
||||
lastPageName = GlobalActivityManager.getLastPageEntity().pageName,
|
||||
lastPageBusinessId = GlobalActivityManager.getLastPageEntity().pageBusinessId
|
||||
)
|
||||
}
|
||||
},
|
||||
confirmClickCallback = {
|
||||
showDownloadingDialog(context, simulator)
|
||||
showDownloadingDialog(context, simulator, gameId, gameName, gameCategoryChinese)
|
||||
NewFlatLogUtils.logSimulatorUpdateAlertClick("更新")
|
||||
MtaHelper.onEvent(
|
||||
trackableEntity.event,
|
||||
trackableEntity.key,
|
||||
if (shouldShowUpdate && isInstalled) "点击更新" else "点击下载"
|
||||
)
|
||||
if (shouldShowUpdate && isInstalled) {
|
||||
SensorsBridge.trackSimulatorUpdateDialogClick(
|
||||
buttonName = positiveText,
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameCategoryChinese,
|
||||
lastPageId = GlobalActivityManager.getLastPageEntity().pageId,
|
||||
lastPageName = GlobalActivityManager.getLastPageEntity().pageName,
|
||||
lastPageBusinessId = GlobalActivityManager.getLastPageEntity().pageBusinessId
|
||||
)
|
||||
} else {
|
||||
SensorsBridge.trackSimulatorInstallDialogClick(
|
||||
buttonName = positiveText,
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameCategoryChinese,
|
||||
lastPageId = GlobalActivityManager.getLastPageEntity().pageId,
|
||||
lastPageName = GlobalActivityManager.getLastPageEntity().pageName,
|
||||
lastPageBusinessId = GlobalActivityManager.getLastPageEntity().pageBusinessId
|
||||
)
|
||||
}
|
||||
},
|
||||
touchOutsideCallback = {
|
||||
if (shouldShowUpdate && isInstalled) {
|
||||
SensorsBridge.trackSimulatorUpdateDialogClick(
|
||||
buttonName = "关闭弹窗",
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameCategoryChinese,
|
||||
lastPageId = GlobalActivityManager.getLastPageEntity().pageId,
|
||||
lastPageName = GlobalActivityManager.getLastPageEntity().pageName,
|
||||
lastPageBusinessId = GlobalActivityManager.getLastPageEntity().pageBusinessId
|
||||
)
|
||||
} else {
|
||||
SensorsBridge.trackSimulatorInstallDialogClick(
|
||||
buttonName = "关闭弹窗",
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameCategoryChinese,
|
||||
lastPageId = GlobalActivityManager.getLastPageEntity().pageId,
|
||||
lastPageName = GlobalActivityManager.getLastPageEntity().pageName,
|
||||
lastPageBusinessId = GlobalActivityManager.getLastPageEntity().pageBusinessId
|
||||
)
|
||||
}
|
||||
},
|
||||
mtaEvent = trackableEntity.event, mtaKey = trackableEntity.key,
|
||||
extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true)
|
||||
@ -228,7 +325,13 @@ class SimulatorDownloadManager private constructor() {
|
||||
})
|
||||
}
|
||||
|
||||
fun showDownloadingDialog(context: Context, simulator: SimulatorEntity?) {
|
||||
fun showDownloadingDialog(
|
||||
context: Context,
|
||||
simulator: SimulatorEntity?,
|
||||
gameId: String = "",
|
||||
gameName: String = "",
|
||||
gameCategoryChinese: String = "",
|
||||
) {
|
||||
mContextRef = WeakReference(context)
|
||||
val msg = FileUtils.isCanDownload(context, simulator?.apk?.size)
|
||||
if (!msg.isNullOrEmpty()) {
|
||||
@ -261,6 +364,11 @@ class SimulatorDownloadManager private constructor() {
|
||||
}
|
||||
|
||||
downloadDialog?.setOnDismissListener {
|
||||
SensorsBridge.trackSimulatorDownloadDialogClose(
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameCategoryChinese
|
||||
)
|
||||
DownloadManager.getInstance().removeObserver(dataWatcher)
|
||||
}
|
||||
|
||||
@ -273,7 +381,7 @@ class SimulatorDownloadManager private constructor() {
|
||||
params?.width = context.resources.displayMetrics.widthPixels - DisplayUtils.dip2px(60f)
|
||||
downloadDialog?.window?.attributes = params
|
||||
|
||||
download(simulator)
|
||||
download(simulator, gameId, gameName, gameCategoryChinese)
|
||||
}
|
||||
|
||||
private fun showNoneEmulatorDialog(context: Context) {
|
||||
@ -293,7 +401,12 @@ class SimulatorDownloadManager private constructor() {
|
||||
)
|
||||
}
|
||||
|
||||
private fun download(simulator: SimulatorEntity?) {
|
||||
private fun download(
|
||||
simulator: SimulatorEntity?,
|
||||
gameId: String = "",
|
||||
gameName: String = "",
|
||||
gameCategoryChinese: String = ""
|
||||
) {
|
||||
val apkEntity = simulator?.apk ?: return
|
||||
|
||||
val entity = DownloadManager.getInstance().getDownloadEntityByUrl(apkEntity.url)
|
||||
@ -308,18 +421,30 @@ class SimulatorDownloadManager private constructor() {
|
||||
DownloadStatus.diskisfull -> {
|
||||
DownloadManager.getInstance().addObserver(dataWatcher)
|
||||
uiExecutor.executeWithDelay(Runnable { DownloadManager.getInstance().resume(entity, true) }, 200)
|
||||
SensorsBridge.trackSimulatorDownloadDialogShow(
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameCategoryChinese
|
||||
)
|
||||
downloadDialog?.show()
|
||||
}
|
||||
|
||||
DownloadStatus.done -> NDataChanger.notifyDataChanged(entity)
|
||||
|
||||
else -> createDownload(apkEntity, simulator)
|
||||
else -> createDownload(apkEntity, simulator, gameId, gameName, gameCategoryChinese)
|
||||
}
|
||||
} else {
|
||||
createDownload(apkEntity, simulator)
|
||||
createDownload(apkEntity, simulator, gameId, gameName, gameCategoryChinese)
|
||||
}
|
||||
}
|
||||
|
||||
private fun createDownload(apkEntity: ApkEntity, simulator: SimulatorEntity) {
|
||||
private fun createDownload(
|
||||
apkEntity: ApkEntity,
|
||||
simulator: SimulatorEntity,
|
||||
gameId: String = "",
|
||||
gameName: String = "",
|
||||
gameCategoryChinese: String = ""
|
||||
) {
|
||||
DownloadManager.getInstance().addObserver(dataWatcher)
|
||||
val downloadId = PackageInstaller.createDownloadId(simulator.name)
|
||||
val downloadEntity = DownloadEntity()
|
||||
@ -351,6 +476,11 @@ class SimulatorDownloadManager private constructor() {
|
||||
downloadType,
|
||||
""
|
||||
)
|
||||
SensorsBridge.trackSimulatorDownloadDialogShow(
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
gameType = gameCategoryChinese
|
||||
)
|
||||
|
||||
downloadDialog?.show()
|
||||
}
|
||||
|
||||
@ -150,7 +150,7 @@ object SimulatorGameManager {
|
||||
SimulatorDownloadManager.getInstance().showDownloadDialog(
|
||||
AppManager.getInstance().recentActiveActivity, simulator,
|
||||
SimulatorDownloadManager.SimulatorLocation.LAUNCH, gameEntity.id, gameEntity.name
|
||||
?: ""
|
||||
?: "", gameEntity.categoryChinese
|
||||
) {
|
||||
jumpToSimulator(downloadEntity, gameEntity)
|
||||
}
|
||||
|
||||
@ -1,15 +1,8 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.gamecenter.common.retrofit.Response
|
||||
import com.gh.gamecenter.common.utils.ImageUtils
|
||||
import com.gh.gamecenter.common.utils.observableToMain
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.entity.NewApiSettingsEntity
|
||||
import com.gh.gamecenter.entity.StartupAdEntity
|
||||
import com.gh.gamecenter.feature.entity.SettingsEntity
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
|
||||
object AdHelper {
|
||||
|
||||
|
||||
@ -109,12 +109,12 @@ object ArchiveDownloadButtonHelper {
|
||||
R.string.archive_download_dialog_content.toResString(),
|
||||
R.string.archive_download_dialog_confirm.toResString(),
|
||||
R.string.cancel.toResString(),
|
||||
{
|
||||
confirmClickCallback = {
|
||||
NewFlatLogUtils.logCloudArchiveGameDownloadDialogClick(R.string.archive_download_dialog_confirm.toResString())
|
||||
VHelper.disableLaunchGameAfterInstallation()
|
||||
EventBus.getDefault().post(EBReuse("download"))
|
||||
},
|
||||
{
|
||||
cancelClickCallback = {
|
||||
NewFlatLogUtils.logCloudArchiveGameDownloadDialogClick(R.string.cancel.toResString())
|
||||
},
|
||||
extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true)
|
||||
|
||||
@ -177,6 +177,8 @@ public class CommentUtils {
|
||||
return null;
|
||||
},
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
new DialogHelper.Config("", false, true, true, false, -1)
|
||||
);
|
||||
break;
|
||||
|
||||
@ -9,15 +9,16 @@ import android.preference.PreferenceManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.gh.gamecenter.common.base.GlobalActivityManager;
|
||||
import com.gh.ad.AdDelegateHelper;
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.common.base.GlobalActivityManager;
|
||||
import com.gh.gamecenter.common.base.activity.BaseActivity;
|
||||
import com.gh.gamecenter.common.constant.Constants;
|
||||
import com.gh.gamecenter.common.eventbus.EBReuse;
|
||||
import com.gh.gamecenter.common.exposure.meta.MetaUtil;
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse;
|
||||
import com.gh.gamecenter.common.utils.ExtensionsKt;
|
||||
import com.gh.gamecenter.common.utils.SensorsBridge;
|
||||
import com.gh.gamecenter.core.AppExecutor;
|
||||
import com.gh.gamecenter.core.utils.GsonUtils;
|
||||
import com.gh.gamecenter.core.utils.MtaHelper;
|
||||
import com.gh.gamecenter.core.utils.SPUtils;
|
||||
@ -114,18 +115,25 @@ public class DataUtils {
|
||||
Utils.log("Gid", gid);
|
||||
PreferenceManager.getDefaultSharedPreferences(HaloApp.getInstance().getApplication()).edit().putString(Constants.DEVICE_KEY, gid).apply();
|
||||
|
||||
String originalGid = HaloApp.getInstance().getGid();
|
||||
HaloApp.getInstance().setGid(gid);
|
||||
|
||||
// gid 变更时上报 gid 变更日志
|
||||
if (!TextUtils.isEmpty(originalGid) && !originalGid.equals(gid)) {
|
||||
NewFlatLogUtils.logGidChanged(originalGid, gid);
|
||||
// 默认用 APP 级已存储的 GID 来使用,不使用外部 GID
|
||||
String savedGid = SPUtils.getString(Constants.GID);
|
||||
if (!TextUtils.isEmpty(savedGid)) {
|
||||
gid = savedGid;
|
||||
} else {
|
||||
SPUtils.setString(Constants.GID, gid);
|
||||
}
|
||||
|
||||
HaloApp.getInstance().setGid(gid);
|
||||
|
||||
SensorsBridge.setGid(gid);
|
||||
|
||||
// 更新广告配置
|
||||
ExtensionsKt.doOnMainProcessOnly(HaloApp.getInstance(), () -> {
|
||||
AdDelegateHelper.INSTANCE.requestAdConfig(false, "", null);
|
||||
});
|
||||
|
||||
// 避免重复调用
|
||||
if (!TextUtils.isEmpty(gid) && !gid.equals(originalGid)) {
|
||||
if (!TextUtils.isEmpty(gid)) {
|
||||
GameSubstituteRepositoryHelper.updateSubstitutableGames();
|
||||
}
|
||||
|
||||
|
||||
@ -1,16 +1,20 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.filter.RegionSetting;
|
||||
import com.gh.common.filter.RegionSettingHelper;
|
||||
import com.gh.common.repository.ReservationRepository;
|
||||
import com.gh.common.simulator.SimulatorGameManager;
|
||||
import com.gh.gamecenter.feature.view.DownloadButton;
|
||||
import com.gh.common.xapk.XapkInstaller;
|
||||
import com.gh.common.xapk.XapkUnzipStatus;
|
||||
import com.gh.gamecenter.feature.entity.GameEntity;
|
||||
import com.gh.gamecenter.feature.entity.PluginLocation;
|
||||
import com.gh.gamecenter.feature.view.DownloadButton;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.DetailViewHolder;
|
||||
@ -18,7 +22,6 @@ import com.gh.gamecenter.common.constant.Constants;
|
||||
import com.gh.gamecenter.common.entity.LinkEntity;
|
||||
import com.gh.gamecenter.common.utils.ExtensionsKt;
|
||||
import com.gh.gamecenter.core.utils.SPUtils;
|
||||
import com.gh.gamecenter.feature.entity.PluginLocation;
|
||||
import com.gh.gamecenter.manager.PackagesManager;
|
||||
import com.gh.vspace.VHelper;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
@ -30,163 +33,125 @@ import java.util.Objects;
|
||||
* Created by khy on 27/06/17.
|
||||
* 详情下载工具类
|
||||
*/
|
||||
|
||||
public class DetailDownloadUtils {
|
||||
|
||||
public static void detailInitDownload(DetailViewHolder viewHolder, boolean isCheck) {
|
||||
String downloadAddWord = viewHolder.gameEntity.getDownloadAddWord();
|
||||
public static void updateViewHolder(DetailViewHolder viewHolder) {
|
||||
updateViewHolder(viewHolder, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新底部下载区域
|
||||
* @param viewHolder 下载区域的包裹
|
||||
* @param ignoreDownloadEntity 忽略下载实体(往往用于下载异常时)
|
||||
*/
|
||||
public static void updateViewHolder(DetailViewHolder viewHolder, boolean ignoreDownloadEntity) {
|
||||
GameEntity gameEntity = viewHolder.getGameEntity();
|
||||
String downloadAddWord = gameEntity.getDownloadAddWord();
|
||||
|
||||
// 隐藏下载按钮上的畅玩文案
|
||||
if (viewHolder.getOverlayTv() != null) {
|
||||
viewHolder.getOverlayTv().setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (viewHolder.mMultiVersionDownloadTv != null) {
|
||||
viewHolder.mMultiVersionDownloadTv.setVisibility(View.GONE);
|
||||
// 多版本下载箭头
|
||||
if (viewHolder.getMultiVersionDownloadTv() != null) {
|
||||
viewHolder.getMultiVersionDownloadTv().setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (viewHolder.gameEntity != null && Config.isShowDownload(viewHolder.gameEntity.getId()) && !"光环助手".equals(viewHolder.gameEntity.getName())) {
|
||||
viewHolder.downloadBottom.setVisibility(View.VISIBLE);
|
||||
// 根据预置的配置更新 ViewHolder 的状态 (譬如青少年模式、下载内容为空等)
|
||||
if (updateViewHolderWithPredefinedConfig(viewHolder, gameEntity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 游戏只包含单 APK 的情况
|
||||
if (gameEntity.getApk().size() == 1) {
|
||||
boolean showVGame = false; // 真下载按钮(DownloadButton)是否需要显示为畅玩,包括单按钮显示和双按钮显示
|
||||
boolean showDualDownloadButton = false; // 是否显示双下载按钮
|
||||
|
||||
int gameDownloadMode = gameEntity.getGameDownloadButtonMode(); // 获取游戏的下载按钮模式
|
||||
|
||||
DownloadEntity downloadEntity = null;
|
||||
if (!ignoreDownloadEntity) {
|
||||
downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity);
|
||||
}
|
||||
|
||||
// 不支持双下载按钮的情况时(新闻详情、礼包详情页),优选一个下载方式显示
|
||||
if (!viewHolder.isSupportDualButton()) {
|
||||
boolean performAsVGame = GameUtils.shouldPerformAsVGame(gameEntity);
|
||||
if (performAsVGame) {
|
||||
gameDownloadMode = GameEntity.GAME_DOWNLOAD_BUTTON_MODE_VGAME;
|
||||
} else {
|
||||
gameDownloadMode = GameEntity.GAME_DOWNLOAD_BUTTON_MODE_DOWNLOAD;
|
||||
}
|
||||
}
|
||||
|
||||
if (gameDownloadMode == GameEntity.GAME_DOWNLOAD_BUTTON_MODE_DOWNLOAD) {
|
||||
showVGame = false;
|
||||
if (viewHolder.getLocalDownloadContainer() != null) {
|
||||
viewHolder.getLocalDownloadContainer().setVisibility(View.GONE);
|
||||
}
|
||||
} else if (gameDownloadMode == GameEntity.GAME_DOWNLOAD_BUTTON_MODE_VGAME) {
|
||||
showVGame = true;
|
||||
if (viewHolder.getLocalDownloadContainer() != null) {
|
||||
viewHolder.getLocalDownloadContainer().setVisibility(View.GONE);
|
||||
}
|
||||
} else if (gameDownloadMode == GameEntity.GAME_DOWNLOAD_BUTTON_MODE_DUAL) {
|
||||
showVGame = true;
|
||||
showDualDownloadButton = true;
|
||||
if (viewHolder.getLocalDownloadContainer() != null) {
|
||||
viewHolder.getLocalDownloadContainer().setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
// 畅玩未安装,且当前下载的默认类型为"普通下载",且用户未安装时,禁用双按钮,禁用畅玩
|
||||
if (!VHelper.isInstalled(gameEntity.getUniquePackageName())
|
||||
&& !PackagesManager.isInstalled(gameEntity.getUniquePackageName())
|
||||
&& downloadEntity != null
|
||||
&& ExtensionsKt.isLocalDownloadInDualDownloadMode(downloadEntity)
|
||||
) {
|
||||
viewHolder.getDownloadPb().setVisibility(View.GONE);
|
||||
if (viewHolder.getOverlayTv() != null) {
|
||||
viewHolder.getOverlayTv().setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
viewHolder.getDownloadPb().setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
// 更新默认的下载按钮
|
||||
updateWithSingleApk(
|
||||
gameEntity,
|
||||
viewHolder,
|
||||
viewHolder.getDownloadPb(),
|
||||
downloadAddWord,
|
||||
showVGame,
|
||||
showDualDownloadButton,
|
||||
downloadEntity
|
||||
);
|
||||
|
||||
if (showDualDownloadButton) {
|
||||
// 双下载按钮时更新占位的下载按钮
|
||||
updateWithSingleApk(
|
||||
gameEntity,
|
||||
viewHolder,
|
||||
viewHolder.getLocalDownloadButton(),
|
||||
downloadAddWord,
|
||||
false,
|
||||
true,
|
||||
downloadEntity
|
||||
);
|
||||
}
|
||||
} else {
|
||||
viewHolder.downloadBottom.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (SPUtils.getBoolean(Constants.SP_TEENAGER_MODE)) {
|
||||
viewHolder.mDownloadPb.setText("查看");
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.TEENAGER_MODE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (viewHolder.gameEntity.isSpecialDownload()) {
|
||||
viewHolder.mDownloadPb.setText("查看下载资源");
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.SPECIAL_DOWNLOAD);
|
||||
return;
|
||||
}
|
||||
|
||||
if (viewHolder.gameEntity.isReservable()) {
|
||||
if (!ReservationRepository.thisGameHasBeenReserved(viewHolder.gameEntity.getId())) {
|
||||
if (TextUtils.isEmpty(downloadAddWord)) {
|
||||
viewHolder.mDownloadPb.setText(String.format("预约" + "《%s》", viewHolder.gameEntity.getName()));
|
||||
} else {
|
||||
viewHolder.mDownloadPb.setText(String.format("预约" + "《%s》%s", viewHolder.gameEntity.getName(), downloadAddWord));
|
||||
}
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.RESERVABLE);
|
||||
} else {
|
||||
viewHolder.mDownloadPb.setText("已预约《" + viewHolder.gameEntity.getName() + "》");
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.RESERVED);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
final RegionSetting.GameH5Download gameH5Download = RegionSettingHelper.getGameH5DownloadByGameId(viewHolder.gameEntity.getId());
|
||||
if (gameH5Download != null) {
|
||||
viewHolder.mDownloadPb.setText(TextUtils.isEmpty(viewHolder.gameEntity.getDownloadOffText()) ? "查看详情" : viewHolder.gameEntity.getDownloadOffText());
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.NORMAL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (viewHolder.gameEntity.isVGame() && !viewHolder.gameEntity.getApk().isEmpty()) {
|
||||
String status = GameUtils.getDownloadBtnText(viewHolder.context, viewHolder.gameEntity, PluginLocation.only_game);
|
||||
if (viewHolder.context.getString(R.string.launch).equals(status)) {
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.LAUNCH_OR_OPEN);
|
||||
} else if (viewHolder.context.getString(R.string.install).equals(status)) {
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.INSTALL_NORMAL);
|
||||
} else {
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.NORMAL);
|
||||
}
|
||||
|
||||
String downloadText;
|
||||
if (viewHolder.context.getString(R.string.launch).equals(status) || viewHolder.context.getString(R.string.install).equals(status) || viewHolder.context.getString(R.string.download).equals(status)) {
|
||||
downloadText = "";
|
||||
if (viewHolder.getOverlayTv() != null) {
|
||||
viewHolder.getOverlayTv().setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else if (viewHolder.context.getString(R.string.attempt).equals(status)) {
|
||||
downloadText = status + getDownloadSizeText(viewHolder);
|
||||
} else {
|
||||
downloadText = status + (TextUtils.isEmpty(downloadAddWord) ? "" : downloadAddWord) + getDownloadSizeText(viewHolder);
|
||||
}
|
||||
viewHolder.mDownloadPb.setText(downloadText);
|
||||
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(viewHolder.gameEntity);
|
||||
|
||||
// 在下载管理找不到下载实体,到畅玩数据库里找
|
||||
if (downloadEntity == null && viewHolder.gameEntity.isVGame()) {
|
||||
String packageName = viewHolder.gameEntity.getUniquePackageName();
|
||||
if (!TextUtils.isEmpty(packageName)) {
|
||||
downloadEntity = VHelper.getVDownloadEntitySnapshot(viewHolder.gameEntity.getId(), packageName);
|
||||
}
|
||||
}
|
||||
|
||||
if (downloadEntity != null) {
|
||||
viewHolder.downloadEntity = downloadEntity;
|
||||
detailInvalidate(viewHolder);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (viewHolder.gameEntity.getApk().isEmpty() || viewHolder.gameEntity.getDownloadOffStatus() != null) {
|
||||
LinkEntity h5LinkEntity = viewHolder.gameEntity.getH5Link();
|
||||
|
||||
if (h5LinkEntity != null) {
|
||||
if ("play".equals(h5LinkEntity.getType())) {
|
||||
String defaultString = String.format("开始玩" + "《%s》", viewHolder.gameEntity.getName());
|
||||
viewHolder.mDownloadPb.setText(TextUtils.isEmpty(h5LinkEntity.getText()) ? defaultString : h5LinkEntity.getText());
|
||||
} else {
|
||||
viewHolder.mDownloadPb.setText(TextUtils.isEmpty(h5LinkEntity.getText()) ? "查看" : h5LinkEntity.getText());
|
||||
}
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.H5_GAME);
|
||||
} else {
|
||||
if ("dialog".equals(viewHolder.gameEntity.getDownloadOffStatus())) {
|
||||
viewHolder.mDownloadPb.setText(TextUtils.isEmpty(viewHolder.gameEntity.getDownloadOffText()) ? "查看详情" : viewHolder.gameEntity.getDownloadOffText());
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.NONE_WITH_HINT);
|
||||
} else if ("updating".equals(viewHolder.gameEntity.getDownloadOffStatus())) {
|
||||
viewHolder.mDownloadPb.setText(TextUtils.isEmpty(viewHolder.gameEntity.getDownloadOffText()) ? "更新中" : viewHolder.gameEntity.getDownloadOffText());
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.UPDATING);
|
||||
} else {
|
||||
viewHolder.mDownloadPb.setText(TextUtils.isEmpty(viewHolder.gameEntity.getDownloadOffText()) ? "暂无下载" : viewHolder.gameEntity.getDownloadOffText());
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.NONE);
|
||||
}
|
||||
}
|
||||
} else if (viewHolder.gameEntity.getApk().size() == 1) {
|
||||
String status = GameUtils.getDownloadBtnText(viewHolder.context, viewHolder.gameEntity, PluginLocation.only_game);
|
||||
if (viewHolder.context.getString(R.string.pluggable).equals(status)) {
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.PLUGIN);
|
||||
} else if (viewHolder.context.getString(R.string.launch).equals(status)) {
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.LAUNCH_OR_OPEN);
|
||||
} else if (viewHolder.context.getString(R.string.install).equals(status)) {
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.INSTALL_NORMAL);
|
||||
} else {
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.NORMAL);
|
||||
}
|
||||
|
||||
String downloadText;
|
||||
if (viewHolder.isNewsDetail) {
|
||||
downloadText = status;
|
||||
} else if (viewHolder.context.getString(R.string.pluggable).equals(status)) {
|
||||
downloadText = "升级" + (TextUtils.isEmpty(downloadAddWord) ? "" : "至" + downloadAddWord) + getDownloadSizeText(viewHolder);
|
||||
} else if (viewHolder.context.getString(R.string.launch).equals(status)) {
|
||||
downloadText = status + (TextUtils.isEmpty(downloadAddWord) ? "" : "-" + downloadAddWord);
|
||||
} else if (viewHolder.context.getString(R.string.attempt).equals(status)) {
|
||||
downloadText = status + getDownloadSizeText(viewHolder);
|
||||
} else if (viewHolder.context.getString(R.string.install).equals(status)) {
|
||||
downloadText = viewHolder.context.getString(R.string.install);
|
||||
} else {
|
||||
downloadText = status + (TextUtils.isEmpty(downloadAddWord) ? "" : downloadAddWord) + getDownloadSizeText(viewHolder);
|
||||
}
|
||||
viewHolder.mDownloadPb.setText(downloadText);
|
||||
} else {
|
||||
viewHolder.mMultiVersionDownloadTv.setText("选择下载你的版本" + (TextUtils.isEmpty(downloadAddWord) ? "" : "-" + downloadAddWord));
|
||||
viewHolder.mMultiVersionDownloadTv.setVisibility(View.VISIBLE);
|
||||
viewHolder.mDownloadPb.setText("");
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.NORMAL);
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(viewHolder.gameEntity);
|
||||
// 游戏包含多 APK 的情况
|
||||
viewHolder.getMultiVersionDownloadTv().setText("选择下载你的版本" + (TextUtils.isEmpty(downloadAddWord) ? "" : "-" + downloadAddWord));
|
||||
viewHolder.getMultiVersionDownloadTv().setVisibility(View.VISIBLE);
|
||||
viewHolder.getDownloadPb().setText("");
|
||||
viewHolder.getDownloadPb().setButtonStyle(DownloadButton.ButtonStyle.NORMAL);
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity);
|
||||
if (downloadEntity != null) {
|
||||
switch (downloadEntity.getStatus()) {
|
||||
case downloading:
|
||||
viewHolder.mDownloadTips.setVisibility(View.VISIBLE);
|
||||
ExtensionsKt.setDownloadTipsAnimation(viewHolder.mDownloadTips, true);
|
||||
viewHolder.getDownloadTips().setVisibility(View.VISIBLE);
|
||||
ExtensionsKt.setDownloadTipsAnimation(viewHolder.getDownloadTips(), true);
|
||||
break;
|
||||
case done:
|
||||
case pause:
|
||||
@ -195,73 +160,348 @@ public class DetailDownloadUtils {
|
||||
case subscribe:
|
||||
case neterror:
|
||||
case overflow:
|
||||
viewHolder.mDownloadTips.setVisibility(View.VISIBLE);
|
||||
ExtensionsKt.setDownloadTipsAnimation(viewHolder.mDownloadTips, false);
|
||||
viewHolder.getDownloadTips().setVisibility(View.VISIBLE);
|
||||
ExtensionsKt.setDownloadTipsAnimation(viewHolder.getDownloadTips(), false);
|
||||
break;
|
||||
default:
|
||||
viewHolder.mDownloadTips.setVisibility(View.GONE);
|
||||
viewHolder.getDownloadTips().setVisibility(View.GONE);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
viewHolder.mDownloadTips.setVisibility(View.GONE);
|
||||
viewHolder.getDownloadTips().setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isCheck && viewHolder.gameEntity.getApk().size() == 1) {
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(viewHolder.gameEntity);
|
||||
/**
|
||||
* 更新只有单个 APK 文件时候的下载按钮状态
|
||||
*
|
||||
* @param downloadButton 下载按钮,可能是真的下载按钮也可能只是占位下载按钮
|
||||
* @param downloadAddWord 下载按钮的补充文案
|
||||
* @param showAsVGame 是否显示为畅玩游戏
|
||||
* @param showDualDownloadButton 是否正显示为双下载按钮
|
||||
*/
|
||||
|
||||
// 在下载管理找不到下载实体,到畅玩数据库里找
|
||||
if (downloadEntity == null && viewHolder.gameEntity.isVGame()) {
|
||||
String packageName = viewHolder.gameEntity.getUniquePackageName();
|
||||
if (!TextUtils.isEmpty(packageName)) {
|
||||
downloadEntity = VHelper.getVDownloadEntitySnapshot(viewHolder.gameEntity.getId(), packageName);
|
||||
private static void updateWithSingleApk(GameEntity gameEntity,
|
||||
DetailViewHolder viewHolder,
|
||||
DownloadButton downloadButton,
|
||||
String downloadAddWord,
|
||||
boolean showAsVGame,
|
||||
boolean showDualDownloadButton,
|
||||
DownloadEntity downloadEntity) {
|
||||
Context context = viewHolder.getContext();
|
||||
TextView overlayTv = viewHolder.getOverlayTv();
|
||||
|
||||
String status = GameUtils.getDownloadBtnText(context, gameEntity, false, showAsVGame, PluginLocation.only_game);
|
||||
|
||||
if (showAsVGame) {
|
||||
// 显示为畅玩游戏
|
||||
if (context.getString(R.string.launch).equals(status)) {
|
||||
downloadButton.setButtonStyle(DownloadButton.ButtonStyle.LAUNCH_OR_OPEN);
|
||||
} else {
|
||||
downloadButton.setButtonStyle(DownloadButton.ButtonStyle.NORMAL);
|
||||
}
|
||||
|
||||
String btnText;
|
||||
if (showDualDownloadButton
|
||||
&& (context.getString(R.string.launch).equals(status) || context.getString(R.string.install).equals(status) || context.getString(R.string.smooth).equals(status) || context.getString(R.string.update).equals(status))) {
|
||||
if (context.getString(R.string.smooth).equals(status)) {
|
||||
btnText = context.getString(R.string.download_v);
|
||||
} else if (context.getString(R.string.update).equals(status)) {
|
||||
btnText = context.getString(R.string.update_v);
|
||||
} else {
|
||||
btnText = context.getString(R.string.launch_v);
|
||||
}
|
||||
|
||||
if (overlayTv != null && downloadButton.getVisibility() != View.GONE) {
|
||||
overlayTv.setVisibility(View.VISIBLE);
|
||||
overlayTv.setText(btnText);
|
||||
downloadButton.setText("");
|
||||
}
|
||||
} else {
|
||||
btnText = status + (TextUtils.isEmpty(downloadAddWord) ? "" : downloadAddWord) + getDownloadSizeText(viewHolder);
|
||||
|
||||
if (overlayTv != null && downloadButton.getVisibility() != View.GONE) {
|
||||
if (context.getString(R.string.launch).equals(status)
|
||||
|| context.getString(R.string.install).equals(status)) {
|
||||
overlayTv.setVisibility(View.VISIBLE);
|
||||
overlayTv.setText("启动(畅玩)");
|
||||
} else {
|
||||
overlayTv.setVisibility(View.GONE);
|
||||
downloadButton.setText(btnText);
|
||||
}
|
||||
} else {
|
||||
if (overlayTv != null) {
|
||||
overlayTv.setVisibility(View.GONE);
|
||||
}
|
||||
downloadButton.setText(btnText);
|
||||
}
|
||||
}
|
||||
|
||||
if (downloadEntity != null) {
|
||||
viewHolder.downloadEntity = downloadEntity;
|
||||
detailInvalidate(viewHolder);
|
||||
// 在下载管理找不到下载实体,到畅玩数据库里找
|
||||
if (downloadEntity == null) {
|
||||
String packageName = gameEntity.getUniquePackageName();
|
||||
if (!TextUtils.isEmpty(packageName)) {
|
||||
downloadEntity = VHelper.getVDownloadEntitySnapshot(gameEntity.getId(), packageName);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 非畅玩,显示为普通游戏
|
||||
if (context.getString(R.string.pluggable).equals(status)) {
|
||||
downloadButton.setButtonStyle(DownloadButton.ButtonStyle.PLUGIN);
|
||||
} else if (context.getString(R.string.launch).equals(status)) {
|
||||
downloadButton.setButtonStyle(DownloadButton.ButtonStyle.LAUNCH_OR_OPEN);
|
||||
} else if (context.getString(R.string.install).equals(status)) {
|
||||
downloadButton.setButtonStyle(DownloadButton.ButtonStyle.INSTALL_NORMAL);
|
||||
} else {
|
||||
downloadButton.setButtonStyle(DownloadButton.ButtonStyle.NORMAL);
|
||||
}
|
||||
|
||||
if (showDualDownloadButton && viewHolder.getLocalDownloadSizeTv() != null) {
|
||||
viewHolder.getLocalDownloadSizeTv().setVisibility(View.GONE);
|
||||
String size = viewHolder.getGameEntity().getApk().get(0).getSize();
|
||||
if (size != null) {
|
||||
String sizeWithoutDigit = size.replaceAll("(?<=\\d)\\.[0-9]+(?!\\d)", "");
|
||||
viewHolder.getLocalDownloadSizeTv().setText(sizeWithoutDigit);
|
||||
}
|
||||
|
||||
// 若双下载按钮时,下载的游戏是以畅玩游戏下载的,把 downloadEntity 置空,避免把按钮更新到错误的状态
|
||||
if (downloadEntity != null && ExtensionsKt.isVGameDownloadInDualDownloadMode(downloadEntity)) {
|
||||
downloadEntity = null;
|
||||
}
|
||||
}
|
||||
|
||||
String btnText;
|
||||
String extraBtnText;
|
||||
if (viewHolder.isNewsDetail()) {
|
||||
btnText = status;
|
||||
extraBtnText = status;
|
||||
} else if (context.getString(R.string.pluggable).equals(status)) {
|
||||
btnText = "升级" + (TextUtils.isEmpty(downloadAddWord) ? "" : "至" + downloadAddWord) + getDownloadSizeText(viewHolder);
|
||||
extraBtnText = "升级" + (TextUtils.isEmpty(downloadAddWord) ? "" : "至" + downloadAddWord);
|
||||
} else if (context.getString(R.string.launch).equals(status)) {
|
||||
btnText = status + (TextUtils.isEmpty(downloadAddWord) ? "" : "-" + downloadAddWord);
|
||||
extraBtnText = context.getString(R.string.launch_local);
|
||||
} else if (context.getString(R.string.attempt).equals(status)) {
|
||||
btnText = status + getDownloadSizeText(viewHolder);
|
||||
extraBtnText = status;
|
||||
if (showDualDownloadButton
|
||||
&& viewHolder.getLocalDownloadContainer() != null
|
||||
&& viewHolder.getLocalDownloadContainer().getVisibility() == View.VISIBLE) {
|
||||
viewHolder.getLocalDownloadSizeTv().setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else if (context.getString(R.string.install).equals(status)) {
|
||||
btnText = context.getString(R.string.install);
|
||||
extraBtnText = context.getString(R.string.install_local);
|
||||
} else if (context.getString(R.string.update).equals(status)) {
|
||||
btnText = context.getString(R.string.update);
|
||||
extraBtnText = context.getString(R.string.update_local);
|
||||
if (showDualDownloadButton
|
||||
&& viewHolder.getLocalDownloadContainer() != null
|
||||
&& viewHolder.getLocalDownloadContainer().getVisibility() == View.VISIBLE) {
|
||||
viewHolder.getLocalDownloadSizeTv().setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else {
|
||||
btnText = status + (TextUtils.isEmpty(downloadAddWord) ? "" : downloadAddWord) + getDownloadSizeText(viewHolder);
|
||||
extraBtnText = context.getString(R.string.download_local);
|
||||
if (showDualDownloadButton
|
||||
&& viewHolder.getLocalDownloadContainer() != null
|
||||
&& viewHolder.getLocalDownloadContainer().getVisibility() == View.VISIBLE) {
|
||||
viewHolder.getLocalDownloadSizeTv().setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
downloadButton.setText(btnText);
|
||||
if (viewHolder.getLocalDownloadTitleTv() != null) {
|
||||
viewHolder.getLocalDownloadTitleTv().setText(extraBtnText);
|
||||
}
|
||||
}
|
||||
|
||||
if (overlayTv != null && overlayTv.getVisibility() == View.VISIBLE) {
|
||||
downloadButton.setTag(R.string.download, overlayTv.getText());
|
||||
} else {
|
||||
downloadButton.setTag(R.string.download, downloadButton.getText());
|
||||
}
|
||||
|
||||
if (downloadEntity == null) return;
|
||||
|
||||
if (handleDownloadButtonAsXapk(downloadEntity, downloadButton)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 非完成状态显示下载按钮
|
||||
if (downloadEntity.getStatus() != DownloadStatus.done) {
|
||||
viewHolder.getDownloadPb().setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
// 存在未完成的下载任务或不显示双按钮时,隐藏本地下载按钮
|
||||
if (viewHolder.getLocalDownloadContainer() != null) {
|
||||
if (downloadEntity.getStatus() != DownloadStatus.done) {
|
||||
viewHolder.getLocalDownloadContainer().setVisibility(View.GONE);
|
||||
} else if (showDualDownloadButton) {
|
||||
viewHolder.getLocalDownloadContainer().setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
viewHolder.getLocalDownloadContainer().setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
downloadButton.setProgress((int) (downloadEntity.getPercent() * 10));
|
||||
|
||||
if (overlayTv != null
|
||||
&& downloadEntity.getStatus() != DownloadStatus.done) {
|
||||
overlayTv.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (showAsVGame) {
|
||||
updateVStyleDownloadButton(viewHolder, downloadButton, downloadEntity, status);
|
||||
} else {
|
||||
updateDefaultStyleDownloadButton(context, viewHolder, downloadButton, gameEntity, downloadEntity);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据预置的配置更新 ViewHolder 的状态
|
||||
*
|
||||
* @return 是否已经是最终状态,返回 true 表示已应用当前配置,返回 false 表示不应用当前配置
|
||||
*/
|
||||
private static boolean updateViewHolderWithPredefinedConfig(DetailViewHolder viewHolder, GameEntity gameEntity) {
|
||||
String downloadAddWord = gameEntity.getDownloadAddWord();
|
||||
|
||||
// 不满足条件的部分游戏隐藏下载按钮
|
||||
if (Config.isShowDownload(gameEntity.getId())
|
||||
&& !"光环助手".equals(gameEntity.getName())) {
|
||||
viewHolder.getDownloadBottom().setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
viewHolder.getDownloadBottom().setVisibility(View.GONE);
|
||||
return true;
|
||||
}
|
||||
|
||||
// 青少年模式显示为查看
|
||||
if (SPUtils.getBoolean(Constants.SP_TEENAGER_MODE)) {
|
||||
viewHolder.getDownloadPb().setText("查看");
|
||||
viewHolder.getDownloadPb().setButtonStyle(DownloadButton.ButtonStyle.TEENAGER_MODE);
|
||||
return true;
|
||||
}
|
||||
|
||||
// 预约
|
||||
if (gameEntity.isReservable()) {
|
||||
if (!ReservationRepository.thisGameHasBeenReserved(gameEntity.getId())) {
|
||||
if (TextUtils.isEmpty(downloadAddWord)) {
|
||||
viewHolder.getDownloadPb().setText(String.format("预约" + "《%s》", gameEntity.getName()));
|
||||
} else {
|
||||
viewHolder.getDownloadPb().setText(String.format("预约" + "《%s》%s", gameEntity.getName(), downloadAddWord));
|
||||
}
|
||||
viewHolder.getDownloadPb().setButtonStyle(DownloadButton.ButtonStyle.RESERVABLE);
|
||||
} else {
|
||||
viewHolder.getDownloadPb().setText("已预约《" + gameEntity.getName() + "》");
|
||||
viewHolder.getDownloadPb().setButtonStyle(DownloadButton.ButtonStyle.RESERVED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// 国际服 H5 弹窗
|
||||
final RegionSetting.GameH5Download gameH5Download = RegionSettingHelper.getGameH5DownloadByGameId(gameEntity.getId());
|
||||
if (gameH5Download != null) {
|
||||
viewHolder.getDownloadPb().setText(TextUtils.isEmpty(gameEntity.getDownloadOffText()) ? "查看详情" : gameEntity.getDownloadOffText());
|
||||
viewHolder.getDownloadPb().setButtonStyle(DownloadButton.ButtonStyle.NORMAL);
|
||||
return true;
|
||||
}
|
||||
|
||||
// 特殊下载
|
||||
if (gameEntity.isSpecialDownload()) {
|
||||
viewHolder.getDownloadPb().setText("查看下载资源");
|
||||
viewHolder.getDownloadPb().setButtonStyle(DownloadButton.ButtonStyle.SPECIAL_DOWNLOAD);
|
||||
return true;
|
||||
}
|
||||
|
||||
// 处理不存在 APK 文件或游戏状态为关闭时的情况
|
||||
if (gameEntity.getApk().isEmpty() || gameEntity.getDownloadOffStatus() != null) {
|
||||
LinkEntity h5LinkEntity = gameEntity.getH5Link();
|
||||
|
||||
if (h5LinkEntity != null) {
|
||||
if ("play".equals(h5LinkEntity.getType())) {
|
||||
String defaultString = String.format("开始玩" + "《%s》", gameEntity.getName());
|
||||
viewHolder.getDownloadPb().setText(TextUtils.isEmpty(h5LinkEntity.getText()) ? defaultString : h5LinkEntity.getText());
|
||||
} else {
|
||||
viewHolder.getDownloadPb().setText(TextUtils.isEmpty(h5LinkEntity.getText()) ? "查看" : h5LinkEntity.getText());
|
||||
}
|
||||
viewHolder.getDownloadPb().setButtonStyle(DownloadButton.ButtonStyle.H5_GAME);
|
||||
} else {
|
||||
if ("dialog".equals(gameEntity.getDownloadOffStatus())) {
|
||||
viewHolder.getDownloadPb().setText(TextUtils.isEmpty(gameEntity.getDownloadOffText()) ? "查看详情" : gameEntity.getDownloadOffText());
|
||||
viewHolder.getDownloadPb().setButtonStyle(DownloadButton.ButtonStyle.NONE_WITH_HINT);
|
||||
} else if ("updating".equals(gameEntity.getDownloadOffStatus())) {
|
||||
viewHolder.getDownloadPb().setText(TextUtils.isEmpty(gameEntity.getDownloadOffText()) ? "更新中" : gameEntity.getDownloadOffText());
|
||||
viewHolder.getDownloadPb().setButtonStyle(DownloadButton.ButtonStyle.UPDATING);
|
||||
} else {
|
||||
viewHolder.getDownloadPb().setText(TextUtils.isEmpty(gameEntity.getDownloadOffText()) ? "暂无下载" : gameEntity.getDownloadOffText());
|
||||
viewHolder.getDownloadPb().setButtonStyle(DownloadButton.ButtonStyle.NONE);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static String getDownloadSizeText(DetailViewHolder viewHolder) {
|
||||
return String.format("(%s)", viewHolder.gameEntity.getApk().get(0).getSize());
|
||||
return String.format("(%s)", viewHolder.getGameEntity().getApk().get(0).getSize());
|
||||
}
|
||||
|
||||
public static void detailInvalidate(DetailViewHolder viewHolder) {
|
||||
DownloadEntity downloadEntity = viewHolder.downloadEntity;
|
||||
String xapkStatus = downloadEntity.getMeta().get(XapkInstaller.XAPK_UNZIP_STATUS);
|
||||
private static void updateVStyleDownloadButton(DetailViewHolder viewHolder,
|
||||
DownloadButton downloadButton,
|
||||
DownloadEntity downloadEntity,
|
||||
String status) {
|
||||
switch (downloadEntity.getStatus()) {
|
||||
case redirected:
|
||||
case downloading:
|
||||
downloadButton.setText("游戏加载中 " + downloadEntity.getPercent() + "%");
|
||||
downloadButton.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_NORMAL);
|
||||
break;
|
||||
case waiting:
|
||||
downloadButton.setText(R.string.waiting);
|
||||
downloadButton.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_NORMAL);
|
||||
downloadButton.setVisibility(View.GONE);
|
||||
break;
|
||||
case overflow:
|
||||
case timeout:
|
||||
case neterror:
|
||||
case subscribe:
|
||||
case diskisfull:
|
||||
case diskioerror:
|
||||
case pause:
|
||||
downloadButton.setText("继续加载 " + downloadEntity.getPercent() + "%");
|
||||
downloadButton.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_NORMAL);
|
||||
break;
|
||||
case done:
|
||||
if (!status.contains("更新")) {
|
||||
if (VHelper.isInstalled(downloadEntity.getPackageName())) {
|
||||
downloadButton.setButtonStyle(DownloadButton.ButtonStyle.LAUNCH_OR_OPEN);
|
||||
} else {
|
||||
downloadButton.setButtonStyle(DownloadButton.ButtonStyle.INSTALL_NORMAL);
|
||||
}
|
||||
|
||||
if (XapkUnzipStatus.SUCCESS.name().equals(xapkStatus) && XapkInstaller.INSTANCE.isInstalling(downloadEntity.getPath())) {
|
||||
viewHolder.mDownloadPb.setText("游戏安装中");
|
||||
viewHolder.mDownloadPb.setProgress(100);
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.INSTALL_NORMAL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (XapkUnzipStatus.UNZIPPING.name().equals(xapkStatus)) {
|
||||
String percent = downloadEntity.getMeta().get(XapkInstaller.XAPK_UNZIP_PERCENT);
|
||||
viewHolder.mDownloadPb.setText("游戏解压中 " + percent + "%");
|
||||
viewHolder.mDownloadPb.setProgress((int) (Float.valueOf(percent) * 10));
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.XAPK_UNZIPPING);
|
||||
return;
|
||||
} else if (XapkUnzipStatus.FAILURE.name().equals(xapkStatus)) {
|
||||
viewHolder.mDownloadPb.setText(R.string.install);
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.XAPK_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
viewHolder.mDownloadPb.setProgress((int) (viewHolder.downloadEntity.getPercent() * 10));
|
||||
if (viewHolder.getOverlayTv() != null) {
|
||||
viewHolder.getOverlayTv().setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (viewHolder.gameEntity.isVGame()) {
|
||||
updateVStyleButton(viewHolder);
|
||||
return;
|
||||
downloadButton.setText("");
|
||||
}
|
||||
break;
|
||||
case cancel:
|
||||
case hijack:
|
||||
case notfound:
|
||||
case uncertificated:
|
||||
case unqualified:
|
||||
case unavailable:
|
||||
case banned:
|
||||
updateViewHolder(viewHolder, true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void updateDefaultStyleDownloadButton(
|
||||
Context context,
|
||||
DetailViewHolder viewHolder,
|
||||
DownloadButton downloadButton,
|
||||
GameEntity gameEntity,
|
||||
DownloadEntity downloadEntity) {
|
||||
switch (downloadEntity.getStatus()) {
|
||||
case timeout:
|
||||
case neterror:
|
||||
@ -274,55 +514,37 @@ public class DetailDownloadUtils {
|
||||
case overflow:
|
||||
String downloadingText = "游戏加载中 " + downloadEntity.getPercent() + "%";
|
||||
String resumeText = "继续加载 " + downloadEntity.getPercent() + "%";
|
||||
viewHolder.mDownloadPb.setText((downloadEntity.getStatus() == DownloadStatus.downloading || downloadEntity.getStatus() == DownloadStatus.redirected) ? downloadingText : resumeText);
|
||||
downloadButton.setText((downloadEntity.getStatus() == DownloadStatus.downloading || downloadEntity.getStatus() == DownloadStatus.redirected) ? downloadingText : resumeText);
|
||||
if (downloadEntity.isPluggable() && PackagesManager.isInstalled(downloadEntity.getPackageName())) {
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_PLUGIN);
|
||||
downloadButton.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_PLUGIN);
|
||||
} else {
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_NORMAL);
|
||||
downloadButton.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_NORMAL);
|
||||
}
|
||||
break;
|
||||
case waiting:
|
||||
viewHolder.mDownloadPb.setText(R.string.waiting);
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.WAITING);
|
||||
downloadButton.setText(R.string.waiting);
|
||||
downloadButton.setButtonStyle(DownloadButton.ButtonStyle.WAITING);
|
||||
break;
|
||||
case done:
|
||||
if (SimulatorGameManager.isSimulatorGame(viewHolder.gameEntity)) {
|
||||
boolean isInstalled = PackageUtils.isInstalledFromAllPackage(viewHolder.context, viewHolder.gameEntity.getSimulator().getApk().getPackageName());
|
||||
boolean isInstalledNewSimulator = SimulatorGameManager.isNewSimulatorInstalled(viewHolder.context);
|
||||
if (SimulatorGameManager.isSimulatorGame(gameEntity)) {
|
||||
boolean isInstalled = PackageUtils.isInstalledFromAllPackage(context, gameEntity.getSimulator().getApk().getPackageName());
|
||||
boolean isInstalledNewSimulator = SimulatorGameManager.isNewSimulatorInstalled(context);
|
||||
if (isInstalled || isInstalledNewSimulator) {
|
||||
viewHolder.mDownloadPb.setText(R.string.launch);
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.LAUNCH_OR_OPEN);
|
||||
downloadButton.setText(R.string.launch);
|
||||
downloadButton.setButtonStyle(DownloadButton.ButtonStyle.LAUNCH_OR_OPEN);
|
||||
} else {
|
||||
if (SPUtils.getBoolean(Constants.SP_USE_BROWSER_TO_INSTALL) && !Objects.equals(Constants.XAPK_APKS_FORMAT, downloadEntity.getFormat())) {
|
||||
viewHolder.mDownloadPb.setText(R.string.browser_install_install);
|
||||
downloadButton.setText(R.string.browser_install_install);
|
||||
} else {
|
||||
viewHolder.mDownloadPb.setText(R.string.install);
|
||||
}
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.INSTALL_NORMAL);
|
||||
}
|
||||
} else if (viewHolder.gameEntity.isVGame()) {
|
||||
if (!viewHolder.mDownloadPb.getText().toString().contains("更新")) {
|
||||
if (VHelper.isInstalled(downloadEntity.getPackageName())) {
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.LAUNCH_OR_OPEN);
|
||||
} else {
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.INSTALL_NORMAL);
|
||||
}
|
||||
|
||||
viewHolder.mDownloadPb.setText("");
|
||||
if (viewHolder.getOverlayTv() != null) {
|
||||
viewHolder.getOverlayTv().setVisibility(View.VISIBLE);
|
||||
downloadButton.setText(R.string.install);
|
||||
}
|
||||
downloadButton.setButtonStyle(DownloadButton.ButtonStyle.INSTALL_NORMAL);
|
||||
}
|
||||
} else {
|
||||
if (SPUtils.getBoolean(Constants.SP_USE_BROWSER_TO_INSTALL) && !Objects.equals(Constants.XAPK_APKS_FORMAT, downloadEntity.getFormat())) {
|
||||
viewHolder.mDownloadPb.setText(R.string.browser_install_install);
|
||||
downloadButton.setText(R.string.browser_install_install);
|
||||
} else {
|
||||
viewHolder.mDownloadPb.setText(R.string.install);
|
||||
}
|
||||
if (downloadEntity.isPluggable() && PackagesManager.isInstalled(downloadEntity.getPackageName())) {
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.INSTALL_PLUGIN);
|
||||
} else {
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.INSTALL_NORMAL);
|
||||
downloadButton.setText(R.string.install);
|
||||
}
|
||||
}
|
||||
|
||||
@ -334,50 +556,35 @@ public class DetailDownloadUtils {
|
||||
case unqualified:
|
||||
case unavailable:
|
||||
case banned:
|
||||
detailInitDownload(viewHolder, false);
|
||||
updateViewHolder(viewHolder, true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void updateVStyleButton(DetailViewHolder viewHolder) {
|
||||
switch (viewHolder.downloadEntity.getStatus()) {
|
||||
case redirected:
|
||||
case downloading:
|
||||
viewHolder.mDownloadPb.setText("游戏加载中 " + viewHolder.downloadEntity.getPercent() + "%");
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_NORMAL);
|
||||
break;
|
||||
case waiting:
|
||||
viewHolder.mDownloadPb.setText(R.string.waiting);
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_NORMAL);
|
||||
break;
|
||||
case overflow:
|
||||
case timeout:
|
||||
case neterror:
|
||||
case subscribe:
|
||||
case diskisfull:
|
||||
case diskioerror:
|
||||
case pause:
|
||||
viewHolder.mDownloadPb.setText("继续加载 " + viewHolder.downloadEntity.getPercent() + "%");
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_NORMAL);
|
||||
break;
|
||||
case done:
|
||||
if (!viewHolder.mDownloadPb.getText().toString().contains("更新")) {
|
||||
if (VHelper.isInstalled(viewHolder.downloadEntity.getPackageName())) {
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.LAUNCH_OR_OPEN);
|
||||
} else {
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.INSTALL_NORMAL);
|
||||
}
|
||||
private static boolean handleDownloadButtonAsXapk(DownloadEntity downloadEntity, DownloadButton downloadButton) {
|
||||
String xapkStatus = downloadEntity.getMeta().get(XapkInstaller.XAPK_UNZIP_STATUS);
|
||||
|
||||
viewHolder.mDownloadPb.setText("");
|
||||
if (viewHolder.getOverlayTv() != null) {
|
||||
viewHolder.getOverlayTv().setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
if (XapkUnzipStatus.SUCCESS.name().equals(xapkStatus) && XapkInstaller.INSTANCE.isInstalling(downloadEntity.getPath())) {
|
||||
downloadButton.setText("游戏安装中");
|
||||
downloadButton.setProgress(100);
|
||||
downloadButton.setButtonStyle(DownloadButton.ButtonStyle.INSTALL_NORMAL);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (XapkUnzipStatus.UNZIPPING.name().equals(xapkStatus)) {
|
||||
String percent = downloadEntity.getMeta().get(XapkInstaller.XAPK_UNZIP_PERCENT);
|
||||
downloadButton.setText("游戏解压中 " + percent + "%");
|
||||
downloadButton.setProgress((int) (Float.valueOf(percent) * 10));
|
||||
downloadButton.setButtonStyle(DownloadButton.ButtonStyle.XAPK_UNZIPPING);
|
||||
return true;
|
||||
} else if (XapkUnzipStatus.FAILURE.name().equals(xapkStatus)) {
|
||||
downloadButton.setText(R.string.install);
|
||||
downloadButton.setButtonStyle(DownloadButton.ButtonStyle.XAPK_FAILURE);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ 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;
|
||||
@ -33,6 +34,7 @@ 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;
|
||||
@ -121,7 +123,7 @@ public class DialogUtils {
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public static void checkDownload(Context context, String size, String gameId, String gameName, CheckDownloadCallBack callBack) {
|
||||
public static void checkDownload(Context context, String size, String gameId, String gameName, String gameCategoryChinese, CheckDownloadCallBack callBack) {
|
||||
if (!NetworkUtils.isNetworkConnected(context)) {
|
||||
showNoConnectionDownloadDialog(context, () -> {
|
||||
},
|
||||
@ -138,7 +140,8 @@ public class DialogUtils {
|
||||
() -> callBack.onResponse(false),
|
||||
() -> callBack.onResponse(true),
|
||||
gameId,
|
||||
gameName);
|
||||
gameName,
|
||||
gameCategoryChinese);
|
||||
}
|
||||
}
|
||||
|
||||
@ -167,7 +170,9 @@ public class DialogUtils {
|
||||
DialogHelper.showDialog(context, "下载提示", "网络异常,请检查手机网络状态", "知道了", "WiFi自动下载", listener::onConfirm, cancelListener::onCancel, false, "", "");
|
||||
}
|
||||
|
||||
public static void showDownloadDialog(Context context, ConfirmListener listener, CancelListener cancelListener, String gameId, String gameName) {
|
||||
public static void showDownloadDialog(Context context, ConfirmListener listener, CancelListener cancelListener, String gameId, String gameName, String gameCategoryChinese) {
|
||||
SensorsBridge.trackDownloadMobileDataDialogShow(gameId, gameName, gameCategoryChinese);
|
||||
|
||||
context = checkDialogContext(context);
|
||||
|
||||
NewFlatLogUtils.logDownloadMobileDataDialogShow(gameId, gameName);
|
||||
@ -182,6 +187,7 @@ public class DialogUtils {
|
||||
Context finalContext = context;
|
||||
allowOnce.setOnClickListener(v -> {
|
||||
NewFlatLogUtils.logDownloadMobileDataDialogClick(gameId, gameName, "允许一次");
|
||||
SensorsBridge.trackDownloadMobileDataDialogClick("允许一次", gameId, gameName, gameCategoryChinese);
|
||||
AppExecutor.getUiExecutor().executeWithDelay(() -> {
|
||||
Utils.toast(finalContext, "已使用移动网络下载,请注意流量消耗");
|
||||
}, 500);
|
||||
@ -191,12 +197,14 @@ public class DialogUtils {
|
||||
});
|
||||
wifiAuto.setOnClickListener(v -> {
|
||||
NewFlatLogUtils.logDownloadMobileDataDialogClick(gameId, gameName, "WiFi自动下载");
|
||||
SensorsBridge.trackDownloadMobileDataDialogClick("WiFi自动下载", gameId, gameName, gameCategoryChinese);
|
||||
cancelListener.onCancel();
|
||||
dialog.dismiss();
|
||||
// MtaHelper.onEvent("移动网络下载", NetworkUtils.getMobileNetworkType(finalContext), "连上WiFi后自动下载");
|
||||
});
|
||||
allowAlways.setOnClickListener(v -> {
|
||||
NewFlatLogUtils.logDownloadMobileDataDialogClick(gameId, gameName, "总是允许");
|
||||
SensorsBridge.trackDownloadMobileDataDialogClick("总是允许", gameId, gameName, gameCategoryChinese);
|
||||
SPUtils.setBoolean(getTrafficDownloadHintKey(), false);
|
||||
AppExecutor.getUiExecutor().executeWithDelay(() -> {
|
||||
// 显示了弹窗以后,即便下面这个 toast 放在 listener.onConfirm 后调用也是显示 listener.onConfirm 里的 toast
|
||||
@ -208,7 +216,10 @@ public class DialogUtils {
|
||||
// MtaHelper.onEvent("移动网络下载", NetworkUtils.getMobileNetworkType(finalContext), "总是允许");
|
||||
});
|
||||
|
||||
dialog.setOnCancelListener(downloadDialog -> NewFlatLogUtils.logDownloadMobileDataDialogClick(gameId, gameName, "关闭弹窗"));
|
||||
dialog.setOnCancelListener(downloadDialog -> {
|
||||
NewFlatLogUtils.logDownloadMobileDataDialogClick(gameId, gameName, "关闭弹窗");
|
||||
SensorsBridge.trackDownloadMobileDataDialogClick("关闭弹窗", gameId, gameName, gameCategoryChinese);
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(contentView);
|
||||
@ -730,6 +741,12 @@ public class DialogUtils {
|
||||
|
||||
// 海外下载地址弹窗
|
||||
public static void showOverseaDownloadDialog(Context context, GameEntity gameEntity, @NonNull ConfirmListener listener) {
|
||||
SensorsBridge.trackOverseasAddressDialogShow(
|
||||
gameEntity.getId(),
|
||||
gameEntity.getName() != null ? gameEntity.getName() : "",
|
||||
gameEntity.getCategoryChinese()
|
||||
);
|
||||
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.GhAlertDialog);
|
||||
@ -739,8 +756,19 @@ public class DialogUtils {
|
||||
View contentView = binding.getRoot();
|
||||
|
||||
binding.gameIcon.displayGameIcon(gameEntity);
|
||||
binding.gameNameTv.setText(context.getString(R.string.dialog_oversea_hint, gameEntity.getName()));
|
||||
binding.closeIv.setOnClickListener(v -> dialog.dismiss());
|
||||
|
||||
AtomicBoolean dismissByTouchInside = new AtomicBoolean(false);
|
||||
|
||||
binding.closeIv.setOnClickListener(v -> {
|
||||
dismissByTouchInside.set(true);
|
||||
SensorsBridge.trackOverseasAddressDialogClick(
|
||||
"取消",
|
||||
gameEntity.getId(),
|
||||
gameEntity.getName() != null ? gameEntity.getName() : "",
|
||||
gameEntity.getCategoryChinese()
|
||||
);
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
if ("show&download".equals(gameEntity.getOverseasAddressDialog().getStatus())) {
|
||||
gameEntity.getApk().get(0).setUrl(gameEntity.getOverseasAddressDialog().getLink());
|
||||
@ -748,6 +776,13 @@ public class DialogUtils {
|
||||
binding.urlTv.setText(gameEntity.getOverseasAddressDialog().getLink());
|
||||
binding.downloadBtn.setText("下载(" + gameEntity.getApk().get(0).getSize() + ")");
|
||||
binding.downloadBtn.setOnClickListener(v -> {
|
||||
dismissByTouchInside.set(true);
|
||||
SensorsBridge.trackOverseasAddressDialogClick(
|
||||
"下载",
|
||||
gameEntity.getId(),
|
||||
gameEntity.getName() != null ? gameEntity.getName() : "",
|
||||
gameEntity.getCategoryChinese()
|
||||
);
|
||||
listener.onConfirm();
|
||||
dialog.dismiss();
|
||||
});
|
||||
@ -757,6 +792,17 @@ public class DialogUtils {
|
||||
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
}
|
||||
|
||||
dialog.setOnDismissListener(dialog1 -> {
|
||||
if (!dismissByTouchInside.get()) {
|
||||
SensorsBridge.trackOverseasAddressDialogClick(
|
||||
"关闭弹窗",
|
||||
gameEntity.getId(),
|
||||
gameEntity.getName() != null ? gameEntity.getName() : "",
|
||||
gameEntity.getCategoryChinese()
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(contentView);
|
||||
dialog.show();
|
||||
@ -1209,7 +1255,7 @@ public class DialogUtils {
|
||||
@Override
|
||||
public Unit invoke() {
|
||||
SimpleGameEntity entity = new SimpleGameEntity(gameId, gameName, "");
|
||||
HelpAndFeedbackBridge.startSuggestionActivity(finalContext, SuggestType.gameQuestion, "notfound", "模拟器安装包解析错误", entity, "-");
|
||||
HelpAndFeedbackBridge.startSuggestionActivity(finalContext, SuggestType.GAME, "notfound", "模拟器安装包解析错误", entity);
|
||||
dialog.dismiss();
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -15,6 +15,7 @@ import com.gh.common.constant.Config
|
||||
import com.gh.common.exposure.ExposureManager.log
|
||||
import com.gh.common.exposure.ExposureTraceUtils.appendTrace
|
||||
import com.gh.common.util.EntranceUtils.jumpActivity
|
||||
import com.gh.common.util.EntranceUtils.jumpActivityCompat
|
||||
import com.gh.gamecenter.*
|
||||
import com.gh.gamecenter.amway.AmwayActivity
|
||||
import com.gh.gamecenter.catalog.CatalogActivity
|
||||
@ -24,7 +25,6 @@ import com.gh.gamecenter.common.base.activity.BaseActivity
|
||||
import com.gh.gamecenter.common.base.activity.BaseActivity_TabLayout
|
||||
import com.gh.gamecenter.common.base.activity.ToolBarActivity
|
||||
import com.gh.gamecenter.common.base.fragment.BaseFragment_TabLayout
|
||||
import com.gh.gamecenter.common.constant.CommonConsts
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts.*
|
||||
@ -37,7 +37,10 @@ import com.gh.gamecenter.core.runOnIoThread
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.discovery.DiscoveryActivity
|
||||
import com.gh.gamecenter.download.DownloadFragment.Companion.INDEX_UPDATE
|
||||
import com.gh.gamecenter.entity.*
|
||||
import com.gh.gamecenter.entity.GameCollectionListEntity
|
||||
import com.gh.gamecenter.entity.SubjectData
|
||||
import com.gh.gamecenter.entity.SubjectRecommendEntity
|
||||
import com.gh.gamecenter.entity.VideoLinkEntity
|
||||
import com.gh.gamecenter.eventbus.EBSkip
|
||||
import com.gh.gamecenter.feature.entity.GameDetailServer
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
@ -56,9 +59,12 @@ import com.gh.gamecenter.game.commoncollection.detail.CommonCollectionDetailActi
|
||||
import com.gh.gamecenter.game.upload.GameSubmissionActivity
|
||||
import com.gh.gamecenter.gamecollection.detail.GameCollectionDetailActivity
|
||||
import com.gh.gamecenter.gamecollection.hotlist.GameCollectionHotListActivity
|
||||
import com.gh.gamecenter.gamecollection.hotlist.GameCollectionListDetailActivity
|
||||
import com.gh.gamecenter.gamecollection.square.GameCollectionSquareActivity
|
||||
import com.gh.gamecenter.gamedetail.GameDetailFragment
|
||||
import com.gh.gamecenter.gamedetail.fuli.kaifu.ServersCalendarActivity
|
||||
import com.gh.gamecenter.gamedetail.fuli.kaifu.ServersCalendarManagementActivity
|
||||
import com.gh.gamecenter.gamedetail.fuli.kaifu.ServersSubscribedGameListActivity
|
||||
import com.gh.gamecenter.gamedetail.history.HistoryApkListActivity
|
||||
import com.gh.gamecenter.gamedetail.rating.RatingReplyActivity
|
||||
import com.gh.gamecenter.help.HelpAndFeedbackBridge
|
||||
@ -152,7 +158,8 @@ object DirectUtils {
|
||||
"bbs_video",
|
||||
"explore_column",
|
||||
"game_explore",
|
||||
"column_test_v2"
|
||||
"column_test_v2",
|
||||
"game_list_collection"
|
||||
)
|
||||
|
||||
fun directToLinkPage(
|
||||
@ -187,6 +194,8 @@ object DirectUtils {
|
||||
}
|
||||
}
|
||||
|
||||
"game_server_calendar" -> directToGameServerCalendar(context, linkEntity.link)
|
||||
|
||||
"column", "游戏专题" -> directToSubject(
|
||||
context, linkEntity.link
|
||||
?: "", linkEntity.text, BaseActivity.mergeEntranceAndPath(entrance, path), exposureEvent
|
||||
@ -225,6 +234,7 @@ object DirectUtils {
|
||||
linkEntity.link!!.contains("v.douyin") && PackageHelper.localPackageNameSet.contains("com.ss.android.ugc.aweme") -> {
|
||||
directDouyin(context, "1402577827140941")
|
||||
}
|
||||
|
||||
else -> directToWebView(
|
||||
context,
|
||||
url = linkEntity.link!!,
|
||||
@ -278,7 +288,16 @@ object DirectUtils {
|
||||
)
|
||||
}
|
||||
|
||||
"column_collection", "专题合集" -> directToColumnCollection(context, linkEntity.link!!, -1, entrance, "", exposureEvent)
|
||||
"column_collection", "专题合集" -> directToColumnCollection(
|
||||
context,
|
||||
linkEntity.link!!,
|
||||
-1,
|
||||
entrance,
|
||||
"",
|
||||
linkEntity.blockId,
|
||||
linkEntity.blockName,
|
||||
exposureEvent
|
||||
)
|
||||
|
||||
"server", "game_server", "开服表" -> directToGameServers(context, entrance, path, exposureEvent)
|
||||
|
||||
@ -298,7 +317,7 @@ object DirectUtils {
|
||||
|
||||
"libao", "礼包" -> directToGiftDetail(context, linkEntity.link ?: "", entrance)
|
||||
|
||||
"feedback" -> directToFeedback(context, linkEntity.name, linkEntity.text, false, "", entrance)
|
||||
"feedback" -> directToFeedback(context, linkEntity.name, false, "", false, false, entrance)
|
||||
|
||||
"qa", "qa_content", "Q&A" -> directToQa(context, linkEntity.text ?: "", linkEntity.link ?: "")
|
||||
|
||||
@ -308,7 +327,12 @@ object DirectUtils {
|
||||
?: ""
|
||||
)
|
||||
|
||||
"anliwall", "安利墙" -> directToAmway(context, fixedTopAmwayCommentId = null, entrance = entrance, path = path)
|
||||
"anliwall", "安利墙" -> directToAmway(
|
||||
context,
|
||||
fixedTopAmwayCommentId = null,
|
||||
entrance = entrance,
|
||||
path = path
|
||||
)
|
||||
|
||||
"game_detail_comment" -> directToGameDetail(context, linkEntity.link ?: "", entrance)
|
||||
|
||||
@ -427,9 +451,18 @@ object DirectUtils {
|
||||
|
||||
"qq_mini_game_column" -> directToQGameHome(context)
|
||||
|
||||
"game_list_collection" -> directToGameCollectionListDetail(
|
||||
context,
|
||||
linkEntity.link ?: "",
|
||||
linkEntity.text ?: "",
|
||||
linkEntity.explain,
|
||||
entrance
|
||||
)
|
||||
|
||||
"" -> {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
else -> {
|
||||
if (unknownCallback != null) {
|
||||
unknownCallback.invoke()
|
||||
@ -478,6 +511,8 @@ object DirectUtils {
|
||||
position: Int = -1,
|
||||
entrance: String,
|
||||
columnName: String = "",
|
||||
blockId: String = "",
|
||||
blockName: String = "",
|
||||
exposureEvent: ExposureEvent? = null
|
||||
) {
|
||||
if (id.isEmpty()) return
|
||||
@ -486,9 +521,11 @@ object DirectUtils {
|
||||
bundle.putString(KEY_ENTRANCE, entrance)
|
||||
bundle.putString(KEY_COLLECTION_ID, id)
|
||||
bundle.putString(KEY_COLUMNNAME, columnName)
|
||||
bundle.putString(KEY_BLOCK_ID, blockId)
|
||||
bundle.putString(KEY_BLOCK_NAME, blockName)
|
||||
bundle.putInt(KEY_POSITION, position)
|
||||
if (exposureEvent != null) {
|
||||
bundle.putParcelableArrayList(EntranceConsts.KEY_EXPOSURE_SOURCE_LIST ,ArrayList(exposureEvent.source))
|
||||
bundle.putParcelableArrayList(EntranceConsts.KEY_EXPOSURE_SOURCE_LIST, ArrayList(exposureEvent.source))
|
||||
}
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
@ -510,12 +547,13 @@ object DirectUtils {
|
||||
* 跳转至游戏日历表
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToGameServerCalendar(context: Context, gameId: String?) {
|
||||
fun directToGameServerCalendar(context: Context, gameId: String?, kaifuTime: Long = 0) {
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_TO, ServersCalendarActivity::class.java.name)
|
||||
bundle.putParcelable(GameEntity::class.java.simpleName, GameEntity().apply {
|
||||
id = gameId ?: ""
|
||||
})
|
||||
bundle.putLong(KEY_KAIFU_TIME, kaifuTime)
|
||||
bundle.putParcelable(GameDetailServer::class.java.simpleName, GameDetailServer())
|
||||
bundle.putParcelable(MeEntity::class.java.simpleName, MeEntity())
|
||||
jumpActivity(context, bundle)
|
||||
@ -721,7 +759,8 @@ object DirectUtils {
|
||||
) {
|
||||
if (id.isEmpty()) return
|
||||
val bundle = Bundle()
|
||||
val subjectData = SubjectData(subjectId = id, subjectName = subjectName, isOrder = false, isQQMiniGame = isQQMiniGame)
|
||||
val subjectData =
|
||||
SubjectData(subjectId = id, subjectName = subjectName, isOrder = false, isQQMiniGame = isQQMiniGame)
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
bundle.putString(KEY_TO, SubjectActivity::class.java.name)
|
||||
bundle.putParcelable(EntranceConsts.KEY_SUBJECT_DATA, subjectData)
|
||||
@ -735,72 +774,68 @@ object DirectUtils {
|
||||
// 反馈
|
||||
@JvmStatic
|
||||
fun directToFeedback(context: Context, content: String? = null, entrance: String? = null) {
|
||||
directToFeedback(context, content, null, false, "", entrance)
|
||||
directToFeedback(context, content, false, "", false, false, entrance)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun directToFeedback(
|
||||
context: Context,
|
||||
content: String? = null,
|
||||
hintType: String? = null,
|
||||
isQaFeedback: Boolean = false,
|
||||
qaContentId: String? = "",
|
||||
isPlugin: Boolean = false,
|
||||
isSmoothGame: Boolean = false,
|
||||
entrance: String? = null
|
||||
) {
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
val destination = RouteConsts.activity.suggestionActivity.toDestinationClass()
|
||||
bundle.putString(KEY_TO, destination?.name ?: "")
|
||||
bundle.putBoolean(KEY_PLUGIN, isPlugin)
|
||||
bundle.putBoolean(KEY_SMOOTH_GAME, isSmoothGame)
|
||||
if (isPlugin) {
|
||||
bundle.putString(KEY_HIDE_SUGGEST_HINT, "【插件问题】")
|
||||
}
|
||||
if (isSmoothGame) {
|
||||
bundle.putString(KEY_HIDE_SUGGEST_HINT, "【畅玩问题】")
|
||||
}
|
||||
if (isQaFeedback) {
|
||||
bundle.putBoolean(KEY_IS_QA_FEEDBACK, true)
|
||||
bundle.putString(KEY_QA_CONTENT_ID, qaContentId)
|
||||
bundle.putSerializable(KEY_SUGGESTTYPE, SuggestType.normal)
|
||||
} else {
|
||||
bundle.putString(KEY_CONTENT, content)
|
||||
if (TextUtils.isEmpty(hintType)) {
|
||||
bundle.putSerializable(KEY_SUGGESTTYPE, SuggestType.gameQuestion)
|
||||
bundle.putString(KEY_SUGGEST_HINT_TYPE, KEY_PLUGIN)
|
||||
} else {
|
||||
bundle.putSerializable(KEY_SUGGESTTYPE, SuggestType.normal)
|
||||
bundle.putString(KEY_SUGGEST_HINT_TYPE, hintType)
|
||||
}
|
||||
}
|
||||
|
||||
jumpActivity(context, bundle)
|
||||
context.startActivity(HelpAndFeedbackBridge.getSuggestionCategoryIntent(context, bundle))
|
||||
}
|
||||
|
||||
/**
|
||||
* 畅玩助手反馈跳转
|
||||
* 跳转至使用帮助与反馈,请不要随意修改方法名
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToVGameFeedback(
|
||||
fun directToHelpAndFeedback(
|
||||
context: Context,
|
||||
content: String? = null,
|
||||
hintType: String? = null,
|
||||
isQaFeedback: Boolean = false,
|
||||
qaContentId: String? = "",
|
||||
isPlugin: Boolean = false,
|
||||
isSmoothGame: Boolean = false,
|
||||
entrance: String? = null
|
||||
) {
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
val destination = RouteConsts.activity.suggestionActivity.toDestinationClass()
|
||||
bundle.putString(KEY_TO, destination?.name ?: "")
|
||||
bundle.putBoolean(KEY_PLUGIN, isPlugin)
|
||||
bundle.putBoolean(KEY_SMOOTH_GAME, isSmoothGame)
|
||||
if (isPlugin) {
|
||||
bundle.putString(KEY_HIDE_SUGGEST_HINT, "【插件问题】")
|
||||
}
|
||||
if (isSmoothGame) {
|
||||
bundle.putString(KEY_HIDE_SUGGEST_HINT, "【畅玩问题】")
|
||||
}
|
||||
if (isQaFeedback) {
|
||||
bundle.putBoolean(KEY_IS_QA_FEEDBACK, true)
|
||||
bundle.putString(KEY_QA_CONTENT_ID, qaContentId)
|
||||
bundle.putSerializable(KEY_SUGGESTTYPE, SuggestType.cwzsQuestion)
|
||||
} else {
|
||||
bundle.putString(KEY_CONTENT, content)
|
||||
if (TextUtils.isEmpty(hintType)) {
|
||||
bundle.putSerializable(KEY_SUGGESTTYPE, SuggestType.gameQuestion)
|
||||
bundle.putString(KEY_SUGGEST_HINT_TYPE, KEY_PLUGIN)
|
||||
} else {
|
||||
bundle.putSerializable(KEY_SUGGESTTYPE, SuggestType.cwzsQuestion)
|
||||
bundle.putString(KEY_SUGGEST_HINT_TYPE, hintType)
|
||||
}
|
||||
}
|
||||
|
||||
EntranceUtils.jumpActivityCompat(context, bundle)
|
||||
directToHelpAndFeedback(context, bundle)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@ -811,27 +846,6 @@ object DirectUtils {
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到下载管理器并开始下载 [gameId] 和 [packageName] 用于唯一确定一个下载文件
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToDownloadManagerAndStartDownload(
|
||||
context: Context,
|
||||
gameId: String? = "",
|
||||
packageName: String? = "",
|
||||
entrance: String? = null
|
||||
) {
|
||||
DownloadHelper.createABrandNewDownloadTaskQuietly(gameId, packageName) {
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
bundle.putString(KEY_TO, DownloadManagerActivity.TAG)
|
||||
bundle.putString(KEY_GAMEID, gameId)
|
||||
bundle.putString(KEY_PACKAGENAME, packageName)
|
||||
bundle.putBoolean(KEY_AUTO_DOWNLOAD, true)
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun directToDownloadManagerAndStartUpdate(
|
||||
context: Context,
|
||||
@ -845,7 +859,7 @@ object DirectUtils {
|
||||
bundle.putString(KEY_GAMEID, gameId)
|
||||
bundle.putString(KEY_PACKAGENAME, packageName)
|
||||
bundle.putInt(BaseFragment_TabLayout.PAGE_INDEX, INDEX_UPDATE)
|
||||
jumpActivity(context, bundle)
|
||||
jumpActivityCompat(context, bundle)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@ -1106,7 +1120,8 @@ object DirectUtils {
|
||||
act: String = "",
|
||||
paginationType: String = "",
|
||||
fieldId: String = "",
|
||||
sectionName: String = ""
|
||||
sectionName: String = "",
|
||||
isHomeVideo: Boolean = false
|
||||
) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
val bundle = Bundle()
|
||||
@ -1124,6 +1139,7 @@ object DirectUtils {
|
||||
bundle.putString(KEY_PAGINATION_TYPE, paginationType)
|
||||
bundle.putString(KEY_FIELD_ID, fieldId)
|
||||
bundle.putString(KEY_SECTION_NAME, sectionName)
|
||||
bundle.putBoolean(KEY_IS_HOME_VIDEO, isHomeVideo)
|
||||
jumpActivity(context, bundle)
|
||||
} else {
|
||||
DialogHelper.showVideoUnsupportedDialog(context)
|
||||
@ -1430,7 +1446,7 @@ object DirectUtils {
|
||||
fun directForumDetailSection(
|
||||
context: Context,
|
||||
bbsId: String? = "",
|
||||
sectionId: String = "",
|
||||
sectionId: String? = "",
|
||||
entrance: String? = null
|
||||
) {
|
||||
val bundle = Bundle()
|
||||
@ -1525,15 +1541,14 @@ object DirectUtils {
|
||||
|
||||
/**
|
||||
* 跳转至使用帮助与反馈,请不要随意修改方法名
|
||||
* @param position 使用帮助:[CommonConsts.TAB_MAIN],意见反馈:[CommonConsts.TAB_SUB]
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToHelpAndFeedback(context: Context, position: Int = CommonConsts.TAB_MAIN) {
|
||||
fun directToHelpAndFeedback(context: Context, bundle: Bundle? = null) {
|
||||
val destination = RouteConsts.activity.helpAndFeedbackActivity.toDestinationClass()
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_TO, destination?.name ?: "")
|
||||
bundle.putInt(BaseActivity_TabLayout.PAGE_INDEX, position)
|
||||
jumpActivity(context, bundle)
|
||||
val newBundle = Bundle()
|
||||
newBundle.putString(KEY_TO, destination?.name ?: "")
|
||||
bundle?.let { newBundle.putAll(it) }
|
||||
jumpActivityCompat(context, newBundle)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1914,16 +1929,16 @@ object DirectUtils {
|
||||
@JvmStatic
|
||||
fun directToSuggestion(
|
||||
context: Context,
|
||||
type: SuggestType = SuggestType.normal,
|
||||
type: SuggestType = SuggestType.APP,
|
||||
hiddenHint: String = "",
|
||||
suggestHintType: String? = null,
|
||||
content: String? = null,
|
||||
platform: String = "",
|
||||
game: SimpleGameEntity? = null,
|
||||
isQaFeedback: Boolean = false,
|
||||
qaContentId: String = "",
|
||||
fromRatingKey: Boolean = false,
|
||||
diagnosis: String = "",
|
||||
forceLogin: Boolean = true,
|
||||
requestCode: Int? = null
|
||||
) {
|
||||
val intent = HelpAndFeedbackBridge.getIntent(
|
||||
@ -1932,12 +1947,12 @@ object DirectUtils {
|
||||
hiddenHint,
|
||||
suggestHintType,
|
||||
content,
|
||||
platform,
|
||||
game,
|
||||
isQaFeedback,
|
||||
qaContentId,
|
||||
fromRatingKey,
|
||||
diagnosis
|
||||
diagnosis,
|
||||
forceLogin
|
||||
)
|
||||
if (requestCode != null) {
|
||||
(context as Activity).startActivityForResult(intent, requestCode)
|
||||
@ -1951,8 +1966,14 @@ object DirectUtils {
|
||||
* @param bbsId, 为空时搜索全范围的内容,不为空时搜索该 bbsId 对应的内容
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToForumOrUserSearch(context: Context, bbsId: String, entrance: String) {
|
||||
context.startActivity(ForumOrUserSearchActivity.getIntent(context, bbsId, entrance))
|
||||
fun directToForumOrUserSearch(
|
||||
context: Context,
|
||||
bbsId: String,
|
||||
entrance: String,
|
||||
sourceEntrance: String,
|
||||
forumName: String
|
||||
) {
|
||||
context.startActivity(ForumOrUserSearchActivity.getIntent(context, bbsId, entrance, sourceEntrance, forumName))
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@ -1980,12 +2001,19 @@ object DirectUtils {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun directToSuggestion(context: Context, type: SuggestType, hiddenHint: String, requestCode: Int?) {
|
||||
fun directToSuggestion(
|
||||
context: Context,
|
||||
type: SuggestType,
|
||||
hiddenHint: String,
|
||||
forceLogin: Boolean = true,
|
||||
requestCode: Int?
|
||||
) {
|
||||
directToSuggestion(
|
||||
context = context,
|
||||
type = type,
|
||||
hiddenHint = hiddenHint,
|
||||
suggestHintType = null,
|
||||
forceLogin = forceLogin,
|
||||
requestCode = requestCode,
|
||||
)
|
||||
}
|
||||
@ -2010,26 +2038,6 @@ object DirectUtils {
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun directToSuggestion(
|
||||
context: Context,
|
||||
type: SuggestType,
|
||||
suggestHintType: String? = null,
|
||||
content: String? = null,
|
||||
game: SimpleGameEntity,
|
||||
platform: String = ""
|
||||
) {
|
||||
directToSuggestion(
|
||||
context = context,
|
||||
type = type,
|
||||
hiddenHint = "",
|
||||
suggestHintType = suggestHintType,
|
||||
content = content,
|
||||
game = game,
|
||||
platform = platform
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun directToQGameHome(context: Context) {
|
||||
context.startActivity(QGameHomeWrapperActivity.getIntent(context))
|
||||
@ -2051,6 +2059,11 @@ object DirectUtils {
|
||||
qqGameId: String
|
||||
) {
|
||||
|
||||
if (activity !is AppCompatActivity || activity.supportFragmentManager.isDestroyed) {
|
||||
ToastUtils.toast("启动QQ小游戏失败,请稍后再试")
|
||||
return
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
ToastUtils.toast("该游戏仅支持安卓5.0及以上设备")
|
||||
return
|
||||
@ -2091,4 +2104,42 @@ object DirectUtils {
|
||||
.withInt(BaseActivity_TabLayout.PAGE_INDEX, defaultTabIndex)
|
||||
.navigation()
|
||||
}
|
||||
|
||||
// 跳转游戏单合集详情
|
||||
@JvmStatic
|
||||
fun directToGameCollectionListDetail(
|
||||
context: Context,
|
||||
collectionId: String,
|
||||
collectionName: String,
|
||||
explain: String,
|
||||
entrance: String = ""
|
||||
) {
|
||||
context.startActivity(
|
||||
GameCollectionListDetailActivity.getIntent(
|
||||
context,
|
||||
GameCollectionListEntity(id = collectionId, name = collectionName, explain = explain),
|
||||
entrance
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到游戏订阅页面
|
||||
* @param context 上下文
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToServersSubscribedGameList(context: Context) {
|
||||
context.startActivity(ServersSubscribedGameListActivity.getIntent(context))
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到开服订阅页面
|
||||
* @param context 上下文
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToServersCalendarManagement(context: Context, entrance: String) {
|
||||
CheckLoginUtils.checkLogin(context, entrance) {
|
||||
context.startActivity(ServersCalendarManagementActivity.getIntent(context))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,10 @@ package com.gh.common.util
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.utils.DialogHelper
|
||||
import com.gh.gamecenter.common.utils.SensorsBridge
|
||||
import com.gh.gamecenter.common.utils.toResString
|
||||
import com.gh.gamecenter.core.utils.EmptyCallback
|
||||
import com.gh.gamecenter.feature.entity.ApkEntity
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
@ -21,7 +24,43 @@ object DownloadDialogHelper {
|
||||
) {
|
||||
val dialog = retrieveAvailableDialog(gameEntity, apkEntity)
|
||||
if (dialog != null) {
|
||||
showDownloadDialog(context, dialog, callback)
|
||||
SensorsBridge.trackGameDownloadDialogShow(
|
||||
gameId = gameEntity.id,
|
||||
gameName = gameEntity.name ?: "",
|
||||
gameType = gameEntity.categoryChinese
|
||||
)
|
||||
DialogHelper.showDialogWithHtmlContent(
|
||||
context,
|
||||
dialog.title,
|
||||
dialog.content,
|
||||
"继续下载",
|
||||
"取消",
|
||||
confirmClickCallback = {
|
||||
SensorsBridge.trackGameDownloadDialogClick(
|
||||
buttonName = "继续下载",
|
||||
gameId = gameEntity.id ,
|
||||
gameName = gameEntity.name ?: "",
|
||||
gameType = gameEntity.categoryChinese
|
||||
)
|
||||
callback.onCallback()
|
||||
},
|
||||
cancelClickCallback = {
|
||||
SensorsBridge.trackGameDownloadDialogClick(
|
||||
buttonName = "取消",
|
||||
gameId = gameEntity.id ,
|
||||
gameName = gameEntity.name ?: "",
|
||||
gameType = gameEntity.categoryChinese
|
||||
)
|
||||
},
|
||||
touchOutsideCallback = {
|
||||
SensorsBridge.trackGameDownloadDialogClick(
|
||||
buttonName = "关闭弹窗",
|
||||
gameId = gameEntity.id ,
|
||||
gameName = gameEntity.name ?: "",
|
||||
gameType = gameEntity.categoryChinese
|
||||
)
|
||||
}
|
||||
)
|
||||
} else {
|
||||
callback.onCallback()
|
||||
}
|
||||
@ -109,14 +148,4 @@ object DownloadDialogHelper {
|
||||
return null
|
||||
}
|
||||
|
||||
private fun showDownloadDialog(context: Context, dialog: GameEntity.Dialog, callback: EmptyCallback) {
|
||||
DialogHelper.showDialogWithHtmlContent(
|
||||
context,
|
||||
dialog.title,
|
||||
dialog.content,
|
||||
"继续下载",
|
||||
"取消",
|
||||
{ callback.onCallback() })
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,63 +0,0 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import com.gh.common.filter.RegionSettingHelper
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.common.retrofit.Response
|
||||
import com.gh.gamecenter.feature.utils.ApkActiveUtils
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import retrofit2.HttpException
|
||||
|
||||
/**
|
||||
* 不想写这个类的,但是与其在一个糟糕的类里插入同样的代码,我想独立写一个类相较而已还没那么糟糕
|
||||
*/
|
||||
object DownloadHelper {
|
||||
|
||||
/**
|
||||
* 根据 game_id 和 packageName 悄悄地开启一个下载任务,如果可以的话
|
||||
* @param block 成功添加下载任务后执行的代码块
|
||||
*/
|
||||
fun createABrandNewDownloadTaskQuietly(gameId: String? = "", packageName: String? = "", block: () -> Unit) {
|
||||
if (RegionSettingHelper.shouldThisGameBeFiltered(gameId)) {
|
||||
return
|
||||
}
|
||||
|
||||
RetrofitManager.getInstance()
|
||||
.api
|
||||
.getGameDigest(gameId)
|
||||
.map(ApkActiveUtils.filterMapper)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : Response<GameEntity>() {
|
||||
override fun onResponse(response: GameEntity?) {
|
||||
response?.let {
|
||||
if (response.getApk().size > 1) {
|
||||
for (apk in response.getApk()) {
|
||||
if (packageName == apk.packageName) {
|
||||
DownloadManager.createDownload(
|
||||
HaloApp.getInstance().application,
|
||||
apk, response, "", EntranceConsts.ENTRANCE_RECOMMEND, "", false, null
|
||||
)
|
||||
block.invoke()
|
||||
}
|
||||
}
|
||||
} else if (response.getApk().size == 1) {
|
||||
DownloadManager.createDownload(
|
||||
HaloApp.getInstance().application,
|
||||
response, "", EntranceConsts.ENTRANCE_RECOMMEND, "", false, null
|
||||
)
|
||||
block.invoke()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailure(e: HttpException?) {
|
||||
e?.printStackTrace()
|
||||
block.invoke()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,6 +1,5 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Message
|
||||
import android.text.TextUtils
|
||||
@ -8,7 +7,6 @@ import android.view.View
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.collection.ArrayMap
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.gh.common.chain.*
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.common.dialog.DeviceRemindDialog
|
||||
@ -32,20 +30,16 @@ import com.gh.gamecenter.common.base.GlobalActivityManager
|
||||
import com.gh.gamecenter.common.callback.CancelListener
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.common.entity.LinkEntity
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.core.provider.IQGameProvider
|
||||
import com.gh.gamecenter.core.utils.*
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.entity.PluginLocation
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.gh.gamecenter.feature.view.DownloadButton
|
||||
import com.gh.gamecenter.gamedetail.dialog.GamePermissionDialogFragment
|
||||
import com.gh.gamecenter.login.user.UserManager
|
||||
import com.gh.gamecenter.manager.PackagesManager
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.gh.gamecenter.teenagermode.TeenagerModeActivity
|
||||
import com.gh.vspace.VHelper
|
||||
import com.lightgame.download.DownloadConfig
|
||||
@ -128,7 +122,7 @@ object DownloadItemUtils {
|
||||
fun updateItemWithReserveStatus(holder: GameViewHolder, gameEntity: GameEntity) {
|
||||
if ("download" == gameEntity.reserveStatus) {
|
||||
// 已上线
|
||||
updateItem(holder.gameDownloadBtn.context, gameEntity, holder, false)
|
||||
updateItem(holder.gameDownloadBtn.context, gameEntity, holder)
|
||||
} else if ("appointment" == gameEntity.reserveStatus) {
|
||||
// 已预约
|
||||
holder.gameDownloadBtn.text = "已预约"
|
||||
@ -139,25 +133,35 @@ object DownloadItemUtils {
|
||||
}
|
||||
|
||||
fun updateItem(
|
||||
context: Context, gameEntity: GameEntity, holder: GameViewHolder,
|
||||
isShowPlatform: Boolean, hideDownloadBtnIfNoAvailableContent: Boolean
|
||||
context: Context,
|
||||
gameEntity: GameEntity,
|
||||
holder: GameViewHolder,
|
||||
hideDownloadBtnIfNoAvailableContent: Boolean
|
||||
) {
|
||||
updateItem(
|
||||
context,
|
||||
gameEntity,
|
||||
holder,
|
||||
isShowPlatform,
|
||||
PluginLocation.only_game,
|
||||
hideDownloadBtnIfNoAvailableContent,
|
||||
null
|
||||
context = context,
|
||||
gameEntity = gameEntity,
|
||||
holder = holder,
|
||||
pluginLocation = PluginLocation.only_game,
|
||||
hideDownloadBtnIfNoAvailableContent = hideDownloadBtnIfNoAvailableContent,
|
||||
briefStyle = null
|
||||
)
|
||||
}
|
||||
|
||||
fun updateItem(
|
||||
context: Context, gameEntity: GameEntity, holder: GameViewHolder,
|
||||
isShowPlatform: Boolean, briefStyle: String?
|
||||
context: Context,
|
||||
gameEntity: GameEntity,
|
||||
holder: GameViewHolder,
|
||||
briefStyle: String?
|
||||
) {
|
||||
updateItem(context, gameEntity, holder, isShowPlatform, PluginLocation.only_game, false, briefStyle)
|
||||
updateItem(
|
||||
context = context,
|
||||
gameEntity = gameEntity,
|
||||
holder = holder,
|
||||
pluginLocation = PluginLocation.only_game,
|
||||
hideDownloadBtnIfNoAvailableContent = false,
|
||||
briefStyle = briefStyle
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@ -166,7 +170,6 @@ object DownloadItemUtils {
|
||||
context: Context,
|
||||
gameEntity: GameEntity,
|
||||
holder: GameViewHolder,
|
||||
isShowPlatform: Boolean,
|
||||
pluginLocation: PluginLocation? = PluginLocation.only_game,
|
||||
hideDownloadBtnIfNoAvailableContent: Boolean = false,
|
||||
briefStyle: String? = null,
|
||||
@ -292,12 +295,54 @@ object DownloadItemUtils {
|
||||
}
|
||||
}
|
||||
} else if (gameEntity.getApk().size == 1) {
|
||||
// 优先从下载管理获取 downloadEntity
|
||||
var downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity)
|
||||
// 来自于下载管理的实体快照
|
||||
val entityFromDownloadManager = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity)
|
||||
// 是否正在下载中
|
||||
val isDownloading = entityFromDownloadManager != null && entityFromDownloadManager.status != DownloadStatus.done
|
||||
// 是否已安装至本地
|
||||
val isInstalledLocally = PackagesManager.isInstalled(gameEntity.getUniquePackageName())
|
||||
// 来自于畅玩安装列表的实体快照,若存在,代表游戏已下载并成功安装
|
||||
val entityFromInstalledVGame = VHelper.getVDownloadEntitySnapshot(gameEntity.id, gameEntity.getUniquePackageName())
|
||||
// 是否已安装至畅玩
|
||||
val isInstalledToVSpace = entityFromInstalledVGame != null
|
||||
// 是否处于待安装状态 (仅本地安装有这个状态)
|
||||
val isPendingToInstall = if (entityFromDownloadManager?.status != DownloadStatus.done) {
|
||||
false
|
||||
} else {
|
||||
entityFromDownloadManager.isLocalDownloadInDualDownloadMode()
|
||||
&& (!isInstalledLocally || entityFromDownloadManager.isUpdate)
|
||||
}
|
||||
|
||||
// 找不到时,若类型为畅玩,尝试从畅玩数据库的快照中获取 downloadEntity。若存在,代表游戏已下载并成功安装
|
||||
if (downloadEntity == null && gameEntity.isVGame()) {
|
||||
downloadEntity = VHelper.getVDownloadEntitySnapshot(gameEntity.id, gameEntity.getUniquePackageName())
|
||||
// 列表按钮显示的优先级
|
||||
// 1. 都未安装,且不存在下载任务,按后台配置显示的状态优先
|
||||
// 2. 存在未完成的下载任务时,下载任务优先
|
||||
// 3. 存在待安装任务时,待安装任务优先
|
||||
// 4. 存在一个已安装,已安装的显示优先
|
||||
// 5. 都已安装,按后台配置显示的状态优先
|
||||
val isVGamePreferred = if (!isInstalledLocally && !isInstalledToVSpace && entityFromDownloadManager == null) {
|
||||
gameEntity.isVGamePreferred()
|
||||
} else if (isDownloading || isPendingToInstall) {
|
||||
entityFromDownloadManager?.isVGameDownloadInDualDownloadMode() == true
|
||||
} else if (isInstalledLocally && isInstalledToVSpace) {
|
||||
gameEntity.isVGamePreferred()
|
||||
} else if (isInstalledLocally) {
|
||||
false
|
||||
} else if (isInstalledToVSpace) {
|
||||
true
|
||||
} else {
|
||||
gameEntity.isVGamePreferred()
|
||||
}
|
||||
|
||||
val downloadEntity: DownloadEntity? = if (isDownloading) {
|
||||
entityFromDownloadManager
|
||||
} else if (isPendingToInstall) {
|
||||
entityFromDownloadManager
|
||||
} else {
|
||||
if (isVGamePreferred) {
|
||||
entityFromInstalledVGame ?: entityFromDownloadManager
|
||||
} else {
|
||||
entityFromDownloadManager
|
||||
}
|
||||
}
|
||||
|
||||
if (downloadEntity != null) {
|
||||
@ -306,11 +351,12 @@ object DownloadItemUtils {
|
||||
DownloadStatus.done -> {
|
||||
if (downloadEntity.isSimulatorGame() && gameEntity.simulator != null) {
|
||||
GameUtils.setDownloadBtnStatus(context, gameEntity, downloadBtn, pluginLocation)
|
||||
} else if (downloadEntity.isVGame()) {
|
||||
} else if (isVGamePreferred) {
|
||||
buttonStyle =
|
||||
if (PackagesManager.isCanUpdate(
|
||||
downloadEntity.gameId,
|
||||
downloadEntity.packageName
|
||||
downloadEntity.packageName,
|
||||
asVGame = true
|
||||
)
|
||||
) {
|
||||
setText(R.string.update)
|
||||
@ -339,8 +385,19 @@ object DownloadItemUtils {
|
||||
return
|
||||
}
|
||||
|
||||
buttonStyle = DownloadButton.ButtonStyle.INSTALL_NORMAL
|
||||
setText(R.string.install)
|
||||
if (PackagesManager.isInstalled(downloadEntity.packageName) && !downloadEntity.isUpdate) {
|
||||
// 双下载按钮快速安装时存在已下载的安装包过时,需要重新下载的情况
|
||||
if (PackagesManager.isCanUpdate(downloadEntity.gameId, downloadEntity.packageName)) {
|
||||
buttonStyle = DownloadButton.ButtonStyle.NORMAL
|
||||
setText(R.string.update)
|
||||
} else {
|
||||
buttonStyle = DownloadButton.ButtonStyle.LAUNCH_OR_OPEN
|
||||
setText(R.string.launch)
|
||||
}
|
||||
} else {
|
||||
buttonStyle = DownloadButton.ButtonStyle.INSTALL_NORMAL
|
||||
setText(R.string.install)
|
||||
}
|
||||
}
|
||||
buttonStyle =
|
||||
if (downloadEntity.isPluggable && PackagesManager.isInstalled(downloadEntity.packageName)) {
|
||||
@ -642,15 +699,43 @@ object DownloadItemUtils {
|
||||
gamePermissionDialogFragment?.dismissAllowingStateLoss()
|
||||
if (SPUtils.getBoolean(Constants.SP_TEENAGER_MODE)) {
|
||||
downloadBtn.setOnClickListener {
|
||||
SensorsBridge.trackAdolescentModeDialogShow(
|
||||
gameId = gameEntity.id,
|
||||
gameName = gameEntity.name ?: "",
|
||||
gameType = gameEntity.categoryChinese
|
||||
)
|
||||
DialogHelper.showDialog(
|
||||
context,
|
||||
"提示",
|
||||
"当前处于儿童/青少年模式, \n暂不提供游戏下载",
|
||||
"退出青少年模式",
|
||||
"关闭",
|
||||
{ context.startActivity(TeenagerModeActivity.getIntent(context)) },
|
||||
{},
|
||||
DialogHelper.Config(
|
||||
confirmClickCallback = {
|
||||
context.startActivity(TeenagerModeActivity.getIntent(context))
|
||||
SensorsBridge.trackAdolescentModeDialogClick(
|
||||
buttonName = "退出青少年模式",
|
||||
gameId = gameEntity.id,
|
||||
gameName = gameEntity.name ?: "",
|
||||
gameType = gameEntity.categoryChinese
|
||||
)
|
||||
},
|
||||
cancelClickCallback = {
|
||||
SensorsBridge.trackAdolescentModeDialogClick(
|
||||
buttonName = "关闭",
|
||||
gameId = gameEntity.id,
|
||||
gameName = gameEntity.name ?: "",
|
||||
gameType = gameEntity.categoryChinese
|
||||
)
|
||||
},
|
||||
touchOutsideCallback = {
|
||||
SensorsBridge.trackAdolescentModeDialogClick(
|
||||
buttonName = "关闭弹窗",
|
||||
gameId = gameEntity.id,
|
||||
gameName = gameEntity.name ?: "",
|
||||
gameType = gameEntity.categoryChinese
|
||||
)
|
||||
},
|
||||
extraConfig = DialogHelper.Config(
|
||||
centerTitle = true,
|
||||
centerContent = true
|
||||
)
|
||||
@ -677,7 +762,7 @@ object DownloadItemUtils {
|
||||
}
|
||||
},
|
||||
{},
|
||||
DialogHelper.Config(
|
||||
extraConfig = DialogHelper.Config(
|
||||
centerTitle = true,
|
||||
centerContent = true
|
||||
)
|
||||
@ -800,7 +885,13 @@ object DownloadItemUtils {
|
||||
if (downloadBtn is DownloadButton && downloadBtn.text == context.getString(R.string.launch)) {
|
||||
clickRunnable.onCallback()
|
||||
} else {
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(context, clickRunnable)
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(
|
||||
context,
|
||||
gameEntity.id,
|
||||
gameEntity.name ?: "",
|
||||
gameEntity.categoryChinese,
|
||||
clickRunnable
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -808,17 +899,21 @@ object DownloadItemUtils {
|
||||
allStateClickCallback?.onCallback()
|
||||
clickCallback?.onCallback()
|
||||
|
||||
ChainBuilder().apply {
|
||||
DownloadChainBuilder().apply {
|
||||
addHandler(GamePermissionHandler())
|
||||
addHandler(CheckStoragePermissionHandler())
|
||||
addHandler(CertificationHandler())
|
||||
addHandler(VersionNumberHandler())
|
||||
}
|
||||
.setProcessEndCallback {
|
||||
.setProcessEndCallback { _, _ ->
|
||||
DownloadDialog.showDownloadDialog(view.context, gameEntity, traceEvent, entrance, location)
|
||||
}
|
||||
.buildHandlerChain()
|
||||
?.handleRequest(context, gameEntity)
|
||||
?.handleRequest(
|
||||
context,
|
||||
gameEntity,
|
||||
GameUtils.shouldPerformAsVGame(gameEntity)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -838,8 +933,11 @@ object DownloadItemUtils {
|
||||
val str = if (downloadBtn is DownloadButton) downloadBtn.text else context.getString(R.string.download)
|
||||
if (gameEntity.getApk().isEmpty()) return
|
||||
val apk = gameEntity.getApk().safelyGetInRelease(0) ?: return
|
||||
|
||||
val shouldPerformAsVGame = GameUtils.shouldPerformAsVGame(gameEntity)
|
||||
|
||||
if (str == context.getString(R.string.download)) {
|
||||
ChainBuilder().apply {
|
||||
DownloadChainBuilder().apply {
|
||||
addHandler(UnsupportedFeatureHandler())
|
||||
addHandler(UpdateNewSimulatorHandler())
|
||||
addHandler(GamePermissionHandler())
|
||||
@ -851,14 +949,14 @@ object DownloadItemUtils {
|
||||
addHandler(LandPageAddressHandler())
|
||||
addHandler(CheckDownloadHandler())
|
||||
}
|
||||
.setProcessEndCallback {
|
||||
download(context, gameEntity, downloadBtn, entrance, location, it as Boolean, traceEvent)
|
||||
.setProcessEndCallback { asVGame, isSubscribe ->
|
||||
download(context, gameEntity, downloadBtn, entrance, location, asVGame, isSubscribe as Boolean, traceEvent)
|
||||
}
|
||||
.buildHandlerChain()
|
||||
?.handleRequest(context, gameEntity)
|
||||
?.handleRequest(context, gameEntity, shouldPerformAsVGame)
|
||||
DataLogUtils.uploadGameLog(context, gameEntity.id, gameEntity.name, entrance)
|
||||
} else if (str == context.getString(R.string.attempt)) {
|
||||
ChainBuilder().apply {
|
||||
DownloadChainBuilder().apply {
|
||||
addHandler(UnsupportedFeatureHandler())
|
||||
addHandler(UpdateNewSimulatorHandler())
|
||||
addHandler(GamePermissionHandler())
|
||||
@ -871,14 +969,14 @@ object DownloadItemUtils {
|
||||
addHandler(OverseaDownloadHandler())
|
||||
addHandler(CheckDownloadHandler())
|
||||
}
|
||||
.setProcessEndCallback {
|
||||
download(context, gameEntity, downloadBtn, entrance, location, it as Boolean, traceEvent)
|
||||
.setProcessEndCallback { asVGame, isSubscribe ->
|
||||
download(context, gameEntity, downloadBtn, entrance, location, asVGame, isSubscribe as Boolean, traceEvent)
|
||||
}
|
||||
.buildHandlerChain()
|
||||
?.handleRequest(context, gameEntity)
|
||||
?.handleRequest(context, gameEntity, shouldPerformAsVGame)
|
||||
DataLogUtils.uploadGameLog(context, gameEntity.id, gameEntity.name, entrance)
|
||||
} else if (str == context.getString(R.string.smooth)) {
|
||||
ChainBuilder().apply {
|
||||
DownloadChainBuilder().apply {
|
||||
addHandler(UnsupportedFeatureHandler())
|
||||
addHandler(GamePermissionHandler())
|
||||
addHandler(PackageCheckHandler())
|
||||
@ -891,28 +989,41 @@ object DownloadItemUtils {
|
||||
addHandler(ValidateVSpaceHandler())
|
||||
addHandler(CheckDownloadHandler())
|
||||
}
|
||||
.setProcessEndCallback {
|
||||
download(context, gameEntity, downloadBtn, entrance, location, it as Boolean, traceEvent)
|
||||
.setProcessEndCallback { asVGame, isSubscribe ->
|
||||
download(context, gameEntity, downloadBtn, entrance, location, asVGame, isSubscribe as Boolean, traceEvent)
|
||||
}
|
||||
.buildHandlerChain()
|
||||
?.handleRequest(context, gameEntity)
|
||||
?.handleRequest(context, gameEntity, shouldPerformAsVGame)
|
||||
} else if (str.contains("化")) {
|
||||
if (gameEntity.pluggableCollection != null) {
|
||||
DownloadDialog.showDownloadDialog(context, gameEntity, traceEvent, entrance, location)
|
||||
} else {
|
||||
ChainBuilder().apply {
|
||||
DownloadChainBuilder().apply {
|
||||
addHandler(DownloadDialogHelperHandler())
|
||||
addHandler(CertificationHandler())
|
||||
addHandler(CheckDownloadHandler())
|
||||
}
|
||||
.setProcessEndCallback {
|
||||
plugin(context, gameEntity, downloadBtn, entrance, location, it as Boolean, traceEvent)
|
||||
.setProcessEndCallback { _, isSubscribe ->
|
||||
plugin(context, gameEntity, downloadBtn, entrance, location, isSubscribe as Boolean, traceEvent)
|
||||
}
|
||||
.buildHandlerChain()
|
||||
?.handleRequest(context, gameEntity)
|
||||
?.handleRequest(context, gameEntity, shouldPerformAsVGame)
|
||||
}
|
||||
} else if (str == context.getString(R.string.install)) {
|
||||
val downloadEntity = SimulatorGameManager.findDownloadEntityByUrl(apk.url)
|
||||
|
||||
com.gh.gamecenter.common.utils.NewFlatLogUtils.logGameInstall(
|
||||
gameId = downloadEntity?.gameId ?: "",
|
||||
gameName = downloadEntity?.name ?: "",
|
||||
trigger = "主动安装"
|
||||
)
|
||||
|
||||
SensorsBridge.trackInstallGameClick(
|
||||
gameId = downloadEntity?.gameId ?: "",
|
||||
gameName = downloadEntity?.name ?: "",
|
||||
action = "主动安装"
|
||||
)
|
||||
|
||||
if (gameEntity.simulator != null) {
|
||||
val isInstalled =
|
||||
PackageUtils.isInstalledFromAllPackage(context, gameEntity.simulator!!.apk!!.packageName)
|
||||
@ -925,30 +1036,40 @@ object DownloadItemUtils {
|
||||
}
|
||||
if (downloadEntity != null && SimulatorGameManager.isSimulatorGame(gameEntity) && !isInstalled && !isInstalledNewSimulator) {
|
||||
SimulatorDownloadManager.getInstance().showDownloadDialog(
|
||||
context, simulator,
|
||||
SimulatorDownloadManager.SimulatorLocation.LAUNCH, gameEntity.id, gameEntity.name!!, null
|
||||
context,
|
||||
simulator,
|
||||
SimulatorDownloadManager.SimulatorLocation.LAUNCH,
|
||||
gameEntity.id,
|
||||
gameEntity.name!!,
|
||||
gameEntity.categoryChinese,
|
||||
null
|
||||
)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (gameEntity.isVGame()) {
|
||||
VHelper.installOrLaunch((context as AppCompatActivity), gameEntity)
|
||||
} else {
|
||||
install(context, gameEntity, position, adapter, refreshCallback)
|
||||
}
|
||||
install(context, gameEntity, position, adapter, refreshCallback)
|
||||
} else if (str == context.getString(R.string.launch)) {
|
||||
//启动模拟器游戏
|
||||
if (SimulatorGameManager.isSimulatorGame(gameEntity)) {
|
||||
if (NewSimulatorGameManager.shouldShowUpdateNewSimulatorAlert(context)) {
|
||||
NewSimulatorGameManager.showUpdateNewsSimulator(context, null)
|
||||
NewSimulatorGameManager.showUpdateNewsSimulator(context, gameEntity, null)
|
||||
return
|
||||
}
|
||||
val downloadEntity = SimulatorGameManager.findDownloadEntityByUrl(gameEntity.getApk()[0].url)
|
||||
if (downloadEntity != null) {
|
||||
val file = File(downloadEntity.path)
|
||||
if (!file.exists()) {
|
||||
download(context, gameEntity, downloadBtn, entrance, location, false, traceEvent)
|
||||
download(
|
||||
context = context,
|
||||
gameEntity = gameEntity,
|
||||
downloadBtn = downloadBtn,
|
||||
entrance = entrance,
|
||||
location = location,
|
||||
asVGame = false,
|
||||
isSubscribe = false,
|
||||
traceEvent = traceEvent
|
||||
)
|
||||
return
|
||||
}
|
||||
NewFlatLogUtils.logSimulatorGameCardClick("启动")
|
||||
@ -957,43 +1078,35 @@ object DownloadItemUtils {
|
||||
return
|
||||
}
|
||||
|
||||
if (gameEntity.isVGame()) {
|
||||
VHelper.installOrLaunch((context as AppCompatActivity), gameEntity)
|
||||
return
|
||||
}
|
||||
PackageLauncher.launchApp(context, gameEntity, gameEntity.getApk()[0].packageName)
|
||||
PackageLauncher.launch(context, gameEntity)
|
||||
} else if (str == context.getString(R.string.update)) {
|
||||
if (gameEntity.isVGame()) {
|
||||
if (shouldPerformAsVGame) {
|
||||
VHelper.updateOrReDownload(gameEntity)
|
||||
return
|
||||
}
|
||||
|
||||
ChainBuilder()
|
||||
DownloadChainBuilder()
|
||||
.apply {
|
||||
addHandler(LandPageAddressHandler())
|
||||
}.setProcessEndCallback {
|
||||
}.setProcessEndCallback { asVGame, _ ->
|
||||
DownloadDialogHelper.findAvailableDialogAndShow(context, gameEntity, apk) {
|
||||
DialogUtils.checkDownload(
|
||||
context,
|
||||
apk.size,
|
||||
gameEntity.id,
|
||||
gameEntity.name
|
||||
gameEntity.name,
|
||||
gameEntity.categoryChinese
|
||||
) { isSubscribe: Boolean ->
|
||||
update(context, gameEntity, entrance, location, isSubscribe, traceEvent)
|
||||
update(context, gameEntity, entrance, location, asVGame, isSubscribe, traceEvent)
|
||||
}
|
||||
}
|
||||
}
|
||||
.buildHandlerChain()
|
||||
?.handleRequest(context, gameEntity)
|
||||
?.handleRequest(context, gameEntity, false)
|
||||
} else {
|
||||
var downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity)
|
||||
|
||||
// 找不到时,若类型为畅玩,尝试从畅玩数据库的快照中获取 downloadEntity。若存在,代表游戏已下载并成功安装
|
||||
if (downloadEntity == null && gameEntity.isVGame()) {
|
||||
downloadEntity = VHelper.getVDownloadEntitySnapshot(gameEntity.id, gameEntity.getUniquePackageName())
|
||||
}
|
||||
|
||||
// 还是找不到时,尝试从 gameEntity 里找已绑定的 downloadEntity
|
||||
// 尝试从 gameEntity 里找已绑定的 downloadEntity
|
||||
if (downloadEntity == null) {
|
||||
downloadEntity = gameEntity.getEntryMap().getOrDefault(gameEntity.getUniquePlatform(), null)
|
||||
}
|
||||
@ -1031,6 +1144,7 @@ object DownloadItemUtils {
|
||||
downloadBtn: View?,
|
||||
entrance: String,
|
||||
location: String,
|
||||
asVGame: Boolean,
|
||||
isSubscribe: Boolean,
|
||||
traceEvent: ExposureEvent?
|
||||
) {
|
||||
@ -1041,7 +1155,7 @@ object DownloadItemUtils {
|
||||
DownloadManager.createDownload(
|
||||
context,
|
||||
gameEntity,
|
||||
context.getString(R.string.download),
|
||||
asVGame,
|
||||
entrance,
|
||||
location,
|
||||
isSubscribe,
|
||||
@ -1076,7 +1190,7 @@ object DownloadItemUtils {
|
||||
) {
|
||||
val msg = FileUtils.isCanDownload(context, gameEntity.getApk()[0].size ?: "")
|
||||
if (TextUtils.isEmpty(msg)) {
|
||||
DownloadManager.createDownload(context, gameEntity, "插件化", entrance, location, isSubscribe, traceEvent)
|
||||
DownloadManager.createDownload(context, gameEntity, false, entrance, location, isSubscribe, traceEvent)
|
||||
ToastUtils.toast(gameEntity.name + "已加入下载队列")
|
||||
if (BrowserInstallHelper.shouldAutoSwitchAssistantInstall(gameEntity)) {
|
||||
val toast = context.getString(R.string.unsupported_browser_install_hint)
|
||||
@ -1115,7 +1229,16 @@ object DownloadItemUtils {
|
||||
}
|
||||
|
||||
PackageUtils.isCanPluggable(apkEntity) -> {
|
||||
DialogHelper.showPluginDialog(context, gameEntity.pluginDesc) { PackageInstaller.uninstall(context, path) }
|
||||
DialogHelper.showPluginDialog(
|
||||
context,
|
||||
pluginDesc = gameEntity.pluginDesc,
|
||||
gameId = gameEntity.id,
|
||||
gameName = gameEntity.name ?: "",
|
||||
gameType = gameEntity.categoryChinese,
|
||||
platform = gameEntity.platform ?: ""
|
||||
) {
|
||||
PackageInstaller.uninstall(context, path)
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
@ -1131,9 +1254,19 @@ object DownloadItemUtils {
|
||||
gameEntity: GameEntity,
|
||||
entrance: String,
|
||||
location: String,
|
||||
asVGame: Boolean,
|
||||
isSubscribe: Boolean,
|
||||
traceEvent: ExposureEvent?
|
||||
) {
|
||||
DownloadManager.createDownload(context, gameEntity, "更新", entrance, location, isSubscribe, traceEvent)
|
||||
|
||||
// 执行更新操作前,先清理历史下载任务,避免冲突
|
||||
if (gameEntity.getApk().size == 1 && !asVGame) {
|
||||
val downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity)
|
||||
if (downloadEntity != null) {
|
||||
DownloadManager.getInstance().cancel(downloadEntity.url)
|
||||
}
|
||||
}
|
||||
|
||||
DownloadManager.createDownload(context, gameEntity, asVGame, entrance, location, isSubscribe, traceEvent)
|
||||
}
|
||||
}
|
||||
@ -15,7 +15,7 @@ import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.utils.getMetaExtra
|
||||
import com.gh.gamecenter.common.utils.isSimulatorGame
|
||||
import com.gh.gamecenter.common.utils.isVGame
|
||||
import com.gh.gamecenter.common.utils.asVGame
|
||||
import com.gh.gamecenter.common.utils.tryCatchInRelease
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.core.utils.SpeedUtils
|
||||
@ -57,7 +57,7 @@ object DownloadNotificationHelper {
|
||||
intent.putExtra(EntranceConsts.KEY_URL, entity.url)
|
||||
intent.putExtra(EntranceConsts.KEY_PATH, entity.path)
|
||||
intent.action = ACTION_INSTALL
|
||||
} else if (entity.isVGame()) {
|
||||
} else if (entity.asVGame()) {
|
||||
intent.action = ACTION_VDOWNLOAD
|
||||
} else {
|
||||
intent.action = ACTION_DOWNLOAD
|
||||
|
||||
@ -17,7 +17,11 @@ import com.gh.gamecenter.common.entity.SimpleGameEntity
|
||||
import com.gh.gamecenter.common.entity.SuggestType
|
||||
import com.gh.gamecenter.common.eventbus.EBShowDialog
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.utils.*
|
||||
import com.gh.gamecenter.core.utils.GsonUtils
|
||||
import com.gh.gamecenter.core.utils.MtaHelper
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.common.utils.NewFlatLogUtils
|
||||
import com.gh.gamecenter.eventbus.EBDownloadStatus
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.entity.SimulatorEntity
|
||||
@ -73,19 +77,47 @@ object DownloadObserver {
|
||||
|
||||
val currentActivity = AppManager.getInstance().currentActivity() ?: return
|
||||
|
||||
SensorsBridge.trackDownloadLinkRotDialogShow(
|
||||
gameId = downloadEntity.gameId,
|
||||
gameName = downloadEntity.name,
|
||||
gameType = downloadEntity.categoryChinese
|
||||
)
|
||||
|
||||
DialogHelper.showDialog(
|
||||
currentActivity,
|
||||
"下载失败",
|
||||
"下载链接已失效,建议提交反馈",
|
||||
"立即反馈",
|
||||
"取消",
|
||||
{
|
||||
confirmClickCallback = {
|
||||
HelpAndFeedbackBridge.startSuggestionActivity(
|
||||
currentActivity,
|
||||
SuggestType.gameQuestion, "notfound",
|
||||
StringUtils.buildString(downloadEntity.name, ",问题反馈:下载链接失效"),
|
||||
SuggestType.GAME, "notfound",
|
||||
"问题反馈:下载链接失效",
|
||||
SimpleGameEntity(gameId, downloadEntity.name, "")
|
||||
)
|
||||
SensorsBridge.trackDownloadLinkRotDialogClick(
|
||||
buttonName = "立即反馈",
|
||||
gameId = downloadEntity.gameId,
|
||||
gameName = downloadEntity.name,
|
||||
gameType = downloadEntity.categoryChinese
|
||||
)
|
||||
},
|
||||
cancelClickCallback = {
|
||||
SensorsBridge.trackDownloadLinkRotDialogClick(
|
||||
buttonName = "取消",
|
||||
gameId = downloadEntity.gameId,
|
||||
gameName = downloadEntity.name,
|
||||
gameType = downloadEntity.categoryChinese
|
||||
)
|
||||
},
|
||||
touchOutsideCallback = {
|
||||
SensorsBridge.trackDownloadLinkRotDialogClick(
|
||||
buttonName = "关闭弹窗",
|
||||
gameId = downloadEntity.gameId,
|
||||
gameName = downloadEntity.name,
|
||||
gameType = downloadEntity.categoryChinese
|
||||
)
|
||||
},
|
||||
extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true)
|
||||
)
|
||||
@ -196,6 +228,18 @@ object DownloadObserver {
|
||||
// 会有 ActivityNotFoundException 异常,catch 掉不管了
|
||||
tryWithDefaultCatch {
|
||||
if (Constants.SILENT_UPDATE != downloadEntity.getMetaExtra(Constants.EXTRA_DOWNLOAD_TYPE)) {
|
||||
NewFlatLogUtils.logGameInstall(
|
||||
gameId = downloadEntity.gameId ?: "",
|
||||
gameName = downloadEntity.name ?: "",
|
||||
trigger = "自动安装"
|
||||
)
|
||||
|
||||
SensorsBridge.trackInstallGameClick(
|
||||
gameName = downloadEntity.name,
|
||||
gameId = downloadEntity.gameId,
|
||||
action = "自动安装"
|
||||
)
|
||||
|
||||
// TODO 在 Android 11 上没有授权安装未知应用的权限前第一次调用这个方法系统会杀掉我们的进程...
|
||||
// 没能找到类似的解释,最接近的是这个 https://issuetracker.google.com/issues/154157387,但也只是点授权杀进程而已
|
||||
PackageInstaller.install(mApplication, downloadEntity);
|
||||
@ -219,7 +263,7 @@ object DownloadObserver {
|
||||
EBShowDialog(
|
||||
BaseActivity.PLUGGABLE,
|
||||
downloadEntity.path,
|
||||
downloadEntity.pluginDesc
|
||||
downloadEntity
|
||||
)
|
||||
)
|
||||
|
||||
@ -229,13 +273,13 @@ object DownloadObserver {
|
||||
)
|
||||
|
||||
else -> {
|
||||
if (!downloadEntity.isVGame()) {
|
||||
if (!downloadEntity.asVGame()) {
|
||||
Utils.toast(mApplication, downloadEntity.name + " - 下载完成")
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!downloadEntity.isVGame()) {
|
||||
if (!downloadEntity.asVGame()) {
|
||||
Utils.toast(mApplication, downloadEntity.name + " - 下载完成")
|
||||
}
|
||||
}
|
||||
@ -257,7 +301,7 @@ object DownloadObserver {
|
||||
}
|
||||
SimulatorDownloadManager.getInstance().showDownloadDialog(
|
||||
currentActivity, simulator,
|
||||
SimulatorDownloadManager.SimulatorLocation.LAUNCH, downloadEntity.gameId, gameName, null
|
||||
SimulatorDownloadManager.SimulatorLocation.LAUNCH, downloadEntity.gameId, gameName, downloadEntity.categoryChinese, null
|
||||
)
|
||||
SimulatorGameManager.recordDownloadSimulatorGame(downloadEntity.gameId, simulator.type)
|
||||
SimulatorGameManager.postPlayedGame(downloadEntity.gameId, downloadEntity.packageName)
|
||||
@ -270,14 +314,23 @@ object DownloadObserver {
|
||||
Utils.toast(mApplication, R.string.install_failure_hint)
|
||||
downloadManager.cancel(downloadEntity.url)
|
||||
} else {
|
||||
if (PackageUtils.isCanLaunchSetup(
|
||||
mApplication,
|
||||
downloadEntity.path
|
||||
) || downloadType == Constants.SMOOTH_GAME
|
||||
) {
|
||||
if (PackageUtils.isCanLaunchSetup(mApplication, downloadEntity.path)
|
||||
|| downloadType == Constants.VGAME
|
||||
|| downloadType == Constants.DUAL_DOWNLOAD_VGAME) {
|
||||
downloadEntity.meta[Constants.MARK_ALREADY_TRIGGERED_INSTALLATION] = "YES"
|
||||
tryWithDefaultCatch {
|
||||
PackageInstaller.install(mApplication, downloadEntity, false)
|
||||
NewFlatLogUtils.logGameInstall(
|
||||
gameId = downloadEntity.gameId ?: "",
|
||||
gameName = downloadEntity.name ?: "",
|
||||
trigger = "自动安装"
|
||||
)
|
||||
|
||||
SensorsBridge.trackInstallGameClick(
|
||||
gameId = downloadEntity.gameId,
|
||||
gameName = downloadEntity.name,
|
||||
action = "自动安装"
|
||||
)
|
||||
PackageInstaller.install(mApplication, downloadEntity, false, ignoreAsVGame = false)
|
||||
}
|
||||
} else {
|
||||
// 弹出卸载提示框
|
||||
@ -286,14 +339,15 @@ object DownloadObserver {
|
||||
EBShowDialog(
|
||||
BaseActivity.PLUGGABLE,
|
||||
downloadEntity.path,
|
||||
downloadEntity.pluginDesc
|
||||
downloadEntity
|
||||
)
|
||||
)
|
||||
} else {
|
||||
EventBus.getDefault().post(
|
||||
EBShowDialog(
|
||||
BaseActivity.SIGNATURE_CONFLICT,
|
||||
downloadEntity.path
|
||||
downloadEntity.path,
|
||||
downloadEntity
|
||||
)
|
||||
)
|
||||
}
|
||||
@ -344,7 +398,7 @@ object DownloadObserver {
|
||||
private fun statDoneEvent(downloadEntity: DownloadEntity) {
|
||||
var type: ExposureUtils.DownloadType
|
||||
if (downloadEntity.isUpdate) {
|
||||
if (downloadEntity.isVGame()) {
|
||||
if (downloadEntity.asVGame()) {
|
||||
type = ExposureUtils.DownloadType.FUN_UPDATE
|
||||
} else {
|
||||
type = ExposureUtils.DownloadType.UPDATE
|
||||
@ -353,7 +407,7 @@ object DownloadObserver {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
type = if (downloadEntity.isVGame()) {
|
||||
type = if (downloadEntity.asVGame()) {
|
||||
ExposureUtils.DownloadType.FUN_DOWNLOAD
|
||||
} else {
|
||||
ExposureUtils.DownloadType.DOWNLOAD
|
||||
@ -364,35 +418,6 @@ object DownloadObserver {
|
||||
type = ExposureUtils.DownloadType.PLUGIN_DOWNLOAD
|
||||
}
|
||||
|
||||
if (downloadEntity.isVGame()) {
|
||||
SensorsBridge.trackEvent(
|
||||
"HaloFunGameDownloadDone",
|
||||
"game_name", downloadEntity.name,
|
||||
"game_id", downloadEntity.gameId,
|
||||
"game_schema_type", if (downloadEntity.getMetaExtra(VHelper.KEY_BIT) == "32") "32位" else "64位"
|
||||
)
|
||||
} else if (downloadEntity.gameId == Constants.HALO_FUN_GAME_ID) {
|
||||
SensorsBridge.trackEvent(
|
||||
"HaloFunDownloadDone",
|
||||
"space_schema_type",
|
||||
if (downloadEntity.packageName == VHelper.VSPACE_32BIT_PACKAGENAME) "32位" else "64位"
|
||||
)
|
||||
} else if (downloadEntity.gameId != Constants.GHZS_GAME_ID && downloadEntity.getMetaExtra(Constants.EXTRA_DOWNLOAD_TYPE) != Constants.SIMULATOR_DOWNLOAD) {
|
||||
SensorsBridge.trackEvent(
|
||||
"DownloadProcessFinish",
|
||||
"game_id", downloadEntity.gameId,
|
||||
"game_name", downloadEntity.meta[Constants.GAME_NAME] ?: "",
|
||||
"game_type", downloadEntity.meta[Constants.GAME_CATEGORY_IN_CHINESE] ?: "",
|
||||
"game_schema_type", if (downloadEntity.getMetaExtra(VHelper.KEY_BIT) == "32") "32位" else "64位",
|
||||
"page_name", getCurrentPageEntity().pageName,
|
||||
"page_id", getCurrentPageEntity().pageId,
|
||||
"page_business_id", getCurrentPageEntity().pageBusinessId,
|
||||
"last_page_name", getLastPageEntity().pageName,
|
||||
"last_page_id", getLastPageEntity().pageId,
|
||||
"last_page_business_id", getLastPageEntity().pageBusinessId
|
||||
)
|
||||
}
|
||||
|
||||
var downloadSpeed = 0L
|
||||
val elapsedTimeString = downloadEntity.meta[DownloadConfig.KEY_DOWNLOAD_ELAPSED_TIME]
|
||||
if (elapsedTimeString != null) {
|
||||
@ -405,7 +430,7 @@ object DownloadObserver {
|
||||
|
||||
val isPlatformRecommend =
|
||||
java.lang.Boolean.parseBoolean(downloadEntity.getMetaExtra(Constants.IS_PLATFORM_RECOMMEND))
|
||||
ExposureUtils.logADownloadCompleteExposureEvent(
|
||||
val exposureEvent = ExposureUtils.logADownloadCompleteExposureEvent(
|
||||
GameEntity(
|
||||
id = downloadEntity.gameId,
|
||||
mName = downloadEntity.name.removeSuffix(Constants.GAME_NAME_DECORATOR),
|
||||
@ -422,6 +447,42 @@ object DownloadObserver {
|
||||
type
|
||||
)
|
||||
|
||||
if (downloadEntity.asVGame()) {
|
||||
SensorsBridge.trackEventWithExposureSource(
|
||||
"HaloFunGameDownloadDone",
|
||||
exposureEvent?.source,
|
||||
"game_name", downloadEntity.name,
|
||||
"game_id", downloadEntity.gameId,
|
||||
"game_schema_type", if (downloadEntity.getMetaExtra(VHelper.KEY_BIT) == "32") "32位" else "64位"
|
||||
)
|
||||
} else if (downloadEntity.gameId == Constants.HALO_FUN_GAME_ID) {
|
||||
SensorsBridge.trackEvent(
|
||||
"HaloFunDownloadDone",
|
||||
"space_schema_type",
|
||||
if (downloadEntity.packageName == VHelper.VSPACE_32BIT_PACKAGENAME) "32位" else "64位"
|
||||
)
|
||||
}
|
||||
|
||||
if (downloadEntity.gameId != Constants.GHZS_GAME_ID
|
||||
&& downloadEntity.getMetaExtra(Constants.EXTRA_DOWNLOAD_TYPE) != Constants.SIMULATOR_DOWNLOAD
|
||||
&& downloadEntity.gameId != Constants.HALO_FUN_GAME_ID) {
|
||||
SensorsBridge.trackEventWithExposureSource(
|
||||
"DownloadProcessFinish",
|
||||
exposureEvent?.source,
|
||||
"game_id", downloadEntity.gameId,
|
||||
"game_name", downloadEntity.meta[Constants.GAME_NAME] ?: "",
|
||||
"game_type", downloadEntity.meta[Constants.GAME_CATEGORY_IN_CHINESE] ?: "",
|
||||
"game_schema_type", if (downloadEntity.getMetaExtra(VHelper.KEY_BIT) == "32") "32位" else "64位",
|
||||
"page_name", getCurrentPageEntity().pageName,
|
||||
"page_id", getCurrentPageEntity().pageId,
|
||||
"page_business_id", getCurrentPageEntity().pageBusinessId,
|
||||
"last_page_name", getLastPageEntity().pageName,
|
||||
"last_page_id", getLastPageEntity().pageId,
|
||||
"last_page_business_id", getLastPageEntity().pageBusinessId,
|
||||
"download_type", if (downloadEntity.asVGame()) "畅玩下载" else "本地下载",
|
||||
)
|
||||
}
|
||||
|
||||
DataCollectionUtils.uploadDownload(mApplication, downloadEntity, "完成")
|
||||
}
|
||||
|
||||
|
||||
@ -15,18 +15,19 @@ import android.text.TextUtils;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.gh.gamecenter.common.base.activity.ToolBarActivity;
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.MainActivity;
|
||||
import com.gh.gamecenter.SplashScreenActivity;
|
||||
import com.gh.gamecenter.common.avoidcallback.AvoidOnResultManager;
|
||||
import com.gh.gamecenter.common.avoidcallback.Callback;
|
||||
import com.gh.gamecenter.common.base.activity.ToolBarActivity;
|
||||
import com.gh.gamecenter.common.base.fragment.ToolbarFragment;
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts;
|
||||
import com.gh.gamecenter.core.utils.ClassUtils;
|
||||
import com.gh.gamecenter.core.utils.GsonUtils;
|
||||
import com.gh.gamecenter.core.utils.SPUtils;
|
||||
import com.halo.assistant.HaloApp;
|
||||
import com.lightgame.utils.AppManager;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import org.json.JSONException;
|
||||
@ -66,8 +67,8 @@ public class EntranceUtils {
|
||||
public static void jumpActivity(Context context, Bundle bundle) {
|
||||
bundle.putBoolean(KEY_REQUIRE_REDIRECT, true);
|
||||
|
||||
if (HaloApp.getInstance().isRunningForeground) {
|
||||
// 应用正在运行,前台或后台
|
||||
if (AppManager.getInstance().findActivity(MainActivity.class) != null) {
|
||||
// 应用正在运行,前台或后台,且MainActivity在栈中
|
||||
String to = bundle.getString(KEY_TO);
|
||||
Class<?> clazz = ClassUtils.forName(to);
|
||||
if (clazz == null) clazz = MainActivity.class;
|
||||
@ -92,8 +93,8 @@ public class EntranceUtils {
|
||||
public static void jumpActivity(Context context, Bundle nextToBundle, Bundle bundle, Callback callback) {
|
||||
bundle.putBoolean(KEY_REQUIRE_REDIRECT, true);
|
||||
|
||||
if (HaloApp.getInstance().isRunningForeground) {
|
||||
// 应用正在运行,前台或后台
|
||||
if (AppManager.getInstance().findActivity(MainActivity.class) != null) {
|
||||
// 应用正在运行,前台或后台,且MainActivity在栈中
|
||||
String to = bundle.getString(KEY_TO);
|
||||
Class<?> clazz = ClassUtils.forName(to);
|
||||
if (clazz == null) clazz = MainActivity.class;
|
||||
|
||||
@ -19,25 +19,21 @@ import com.gh.download.server.BrowserInstallHelper
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.WebActivity
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.exposure.ExposureSource
|
||||
import com.gh.gamecenter.common.retrofit.ApiResponse
|
||||
import com.gh.gamecenter.common.retrofit.EmptyResponse
|
||||
import com.gh.gamecenter.common.retrofit.Response
|
||||
import com.gh.gamecenter.common.utils.DataLogUtils
|
||||
import com.gh.gamecenter.common.utils.DialogHelper
|
||||
import com.gh.gamecenter.common.utils.observableToMain
|
||||
import com.gh.gamecenter.common.utils.singleToMain
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.common.view.dsbridge.CompletionHandler
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.core.runOnUiThread
|
||||
import com.gh.gamecenter.core.utils.EmptyCallback
|
||||
import com.gh.gamecenter.core.utils.MtaHelper
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.feature.entity.ApkEntity
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.entity.PluginLocation
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.gh.gamecenter.feature.exposure.ExposureSource
|
||||
import com.gh.gamecenter.feature.exposure.ExposureType
|
||||
import com.gh.gamecenter.feature.utils.ApkActiveUtils
|
||||
import com.gh.gamecenter.gamedetail.dialog.GamePermissionDialogFragment
|
||||
@ -112,15 +108,43 @@ object GameActivityDownloadHelper {
|
||||
// 青少年模式
|
||||
private fun isTeenageMode(context: Context): Boolean {
|
||||
if (SPUtils.getBoolean(Constants.SP_TEENAGER_MODE)) {
|
||||
SensorsBridge.trackAdolescentModeDialogShow(
|
||||
gameId = mGameEntity?.id ?: "",
|
||||
gameName = mGameEntity?.name ?: "",
|
||||
gameType = mGameEntity?.categoryChinese ?: ""
|
||||
)
|
||||
DialogHelper.showDialog(
|
||||
context,
|
||||
"提示",
|
||||
"当前处于儿童/青少年模式, \n暂不提供游戏下载",
|
||||
"退出青少年模式",
|
||||
"关闭",
|
||||
{ context.startActivity(TeenagerModeActivity.getIntent(context)) },
|
||||
{},
|
||||
DialogHelper.Config(
|
||||
confirmClickCallback = {
|
||||
context.startActivity(TeenagerModeActivity.getIntent(context))
|
||||
SensorsBridge.trackAdolescentModeDialogClick(
|
||||
buttonName = "退出青少年模式",
|
||||
gameId = mGameEntity?.id ?: "",
|
||||
gameName = mGameEntity?.name ?: "",
|
||||
gameType = mGameEntity?.categoryChinese ?: ""
|
||||
)
|
||||
},
|
||||
cancelClickCallback = {
|
||||
SensorsBridge.trackAdolescentModeDialogClick(
|
||||
buttonName = "关闭",
|
||||
gameId = mGameEntity?.id ?: "",
|
||||
gameName = mGameEntity?.name ?: "",
|
||||
gameType = mGameEntity?.categoryChinese ?: ""
|
||||
)
|
||||
},
|
||||
touchOutsideCallback = {
|
||||
SensorsBridge.trackAdolescentModeDialogClick(
|
||||
buttonName = "关闭弹窗",
|
||||
gameId = mGameEntity?.id ?: "",
|
||||
gameName = mGameEntity?.name ?: "",
|
||||
gameType = mGameEntity?.categoryChinese ?: ""
|
||||
)
|
||||
},
|
||||
extraConfig = DialogHelper.Config(
|
||||
centerTitle = true,
|
||||
centerContent = true
|
||||
)
|
||||
@ -179,10 +203,16 @@ object GameActivityDownloadHelper {
|
||||
) {
|
||||
val apk = getApk(gameEntity, event, true) ?: return
|
||||
val downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity)
|
||||
val str = GameUtils.getDownloadBtnText(context, gameEntity, PluginLocation.only_game)
|
||||
if (downloadEntity != null &&
|
||||
str != context.getString(R.string.install) &&
|
||||
str != context.getString(R.string.launch)
|
||||
val str = GameUtils.getDownloadBtnText(
|
||||
context = context,
|
||||
gameEntity = gameEntity,
|
||||
isFromList = true,
|
||||
fixedAsVGame = false,
|
||||
pluginLocation = PluginLocation.only_game
|
||||
)
|
||||
if (downloadEntity != null
|
||||
&& str != context.getString(R.string.install)
|
||||
&& str != context.getString(R.string.launch)
|
||||
) {
|
||||
ToastUtils.toast("${gameEntity.name}已加入下载队列")
|
||||
if (BrowserInstallHelper.shouldAutoSwitchAssistantInstall(gameEntity)) {
|
||||
@ -235,8 +265,8 @@ object GameActivityDownloadHelper {
|
||||
) {
|
||||
GamePermissionDialogFragment.show((context as AppCompatActivity), gameEntity, gameEntity.info) {
|
||||
CertificationDialog.showCertificationDialog(context, gameEntity) {
|
||||
DialogUtils.checkDownload(context, apk.size, gameEntity.id, gameEntity.name) { isSubscribe: Boolean ->
|
||||
download(context, gameEntity, apk, isSubscribe, entrance, location, traceEvent)
|
||||
DialogUtils.checkDownload(context, apk.size, gameEntity.id, gameEntity.name, gameEntity.categoryChinese) { isSubscribe: Boolean ->
|
||||
download(context, gameEntity, apk, false, isSubscribe, entrance, location, traceEvent)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -259,9 +289,10 @@ object GameActivityDownloadHelper {
|
||||
context,
|
||||
apk.size,
|
||||
gameEntity.id,
|
||||
gameEntity.name
|
||||
gameEntity.name,
|
||||
gameEntity.categoryChinese
|
||||
) { isSubscribe: Boolean ->
|
||||
download(context, gameEntity, apk, isSubscribe, entrance, location, traceEvent)
|
||||
download(context, gameEntity, apk, true, isSubscribe, entrance, location, traceEvent)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -281,7 +312,7 @@ object GameActivityDownloadHelper {
|
||||
DownloadDialog.showDownloadDialog(context, gameEntity, traceEvent, entrance, location)
|
||||
} else {
|
||||
CertificationDialog.showCertificationDialog(context, gameEntity) {
|
||||
DialogUtils.checkDownload(context, apk.size, gameEntity.id, gameEntity.name) { isSubscribe: Boolean ->
|
||||
DialogUtils.checkDownload(context, apk.size, gameEntity.id, gameEntity.name, gameEntity.categoryChinese) { isSubscribe: Boolean ->
|
||||
plugin(context, gameEntity, apk, entrance, location, isSubscribe, traceEvent)
|
||||
}
|
||||
}
|
||||
@ -295,6 +326,18 @@ object GameActivityDownloadHelper {
|
||||
apk: ApkEntity,
|
||||
downloadEntity: DownloadEntity?
|
||||
) {
|
||||
com.gh.gamecenter.common.utils.NewFlatLogUtils.logGameInstall(
|
||||
gameId = downloadEntity?.gameId ?: "",
|
||||
gameName = downloadEntity?.name ?: "",
|
||||
trigger = "主动安装"
|
||||
)
|
||||
|
||||
SensorsBridge.trackInstallGameClick(
|
||||
gameName = downloadEntity?.name ?: "",
|
||||
gameId = downloadEntity?.gameId ?: "",
|
||||
action = "主动安装"
|
||||
)
|
||||
|
||||
val simulatorDownloadEntity = SimulatorGameManager.findDownloadEntityByUrl(apk.url)
|
||||
if (gameEntity.simulator != null) {
|
||||
val isInstalled =
|
||||
@ -310,18 +353,16 @@ object GameActivityDownloadHelper {
|
||||
if (simulatorDownloadEntity != null && SimulatorGameManager.isSimulatorGame(gameEntity) && !isInstalled && !isInstalledNewSimulator) {
|
||||
SimulatorDownloadManager.getInstance().showDownloadDialog(
|
||||
context, simulator,
|
||||
SimulatorDownloadManager.SimulatorLocation.LAUNCH, gameEntity.id, gameEntity.name!!, null
|
||||
SimulatorDownloadManager.SimulatorLocation.LAUNCH, gameEntity.id, gameEntity.name!!, gameEntity.categoryChinese, null
|
||||
)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (gameEntity.isVGame()) {
|
||||
if (downloadEntity?.isVGameDownloadInDualDownloadMode() == true) {
|
||||
VHelper.installOrLaunch((context as AppCompatActivity), gameEntity)
|
||||
} else {
|
||||
downloadEntity?.run {
|
||||
install(context, gameEntity, apk, this)
|
||||
}
|
||||
downloadEntity?.run { install(context, gameEntity, apk, this) }
|
||||
}
|
||||
}
|
||||
|
||||
@ -337,7 +378,7 @@ object GameActivityDownloadHelper {
|
||||
//启动模拟器游戏
|
||||
if (SimulatorGameManager.isSimulatorGame(gameEntity)) {
|
||||
if (NewSimulatorGameManager.shouldShowUpdateNewSimulatorAlert(context)) {
|
||||
NewSimulatorGameManager.showUpdateNewsSimulator(context, null)
|
||||
NewSimulatorGameManager.showUpdateNewsSimulator(context, gameEntity, null)
|
||||
return
|
||||
}
|
||||
val simulatorDownloadEntity =
|
||||
@ -345,7 +386,16 @@ object GameActivityDownloadHelper {
|
||||
if (simulatorDownloadEntity != null) {
|
||||
val file = File(simulatorDownloadEntity.path)
|
||||
if (!file.exists()) {
|
||||
download(context, gameEntity, apk, false, entrance, location, traceEvent)
|
||||
download(
|
||||
context = context,
|
||||
gameEntity = gameEntity,
|
||||
apk = apk,
|
||||
asVGame = false,
|
||||
isSubscribe = false,
|
||||
entrance = entrance,
|
||||
location = location,
|
||||
traceEvent = traceEvent
|
||||
)
|
||||
return
|
||||
}
|
||||
NewFlatLogUtils.logSimulatorGameCardClick("启动")
|
||||
@ -354,15 +404,7 @@ object GameActivityDownloadHelper {
|
||||
return
|
||||
}
|
||||
|
||||
if (gameEntity.isVGame()) {
|
||||
VHelper.installOrLaunch((context as AppCompatActivity), gameEntity)
|
||||
return
|
||||
}
|
||||
|
||||
if (entrance.contains("我的游戏")) {
|
||||
MtaHelper.onEvent("我的游戏_启动", "启动", gameEntity.name)
|
||||
}
|
||||
PackageLauncher.launchApp(context, gameEntity, gameEntity.getApk()[0].packageName)
|
||||
PackageLauncher.launch(context, gameEntity)
|
||||
}
|
||||
|
||||
// 处理更新状态
|
||||
@ -374,7 +416,7 @@ object GameActivityDownloadHelper {
|
||||
location: String,
|
||||
traceEvent: ExposureEvent
|
||||
) {
|
||||
DialogUtils.checkDownload(context, apk.size, gameEntity.id, gameEntity.name) { isSubscribe: Boolean ->
|
||||
DialogUtils.checkDownload(context, apk.size, gameEntity.id, gameEntity.name, gameEntity.categoryChinese) { isSubscribe: Boolean ->
|
||||
update(context, gameEntity, apk, entrance, location, isSubscribe, traceEvent)
|
||||
}
|
||||
}
|
||||
@ -425,6 +467,7 @@ object GameActivityDownloadHelper {
|
||||
context: Context,
|
||||
gameEntity: GameEntity,
|
||||
apk: ApkEntity,
|
||||
asVGame: Boolean,
|
||||
isSubscribe: Boolean,
|
||||
entrance: String,
|
||||
location: String,
|
||||
@ -432,11 +475,7 @@ object GameActivityDownloadHelper {
|
||||
) {
|
||||
val msg = FileUtils.isCanDownload(context, apk.size)
|
||||
if (TextUtils.isEmpty(msg)) {
|
||||
DownloadManager.createDownload(
|
||||
context, apk, gameEntity, context.getString(
|
||||
R.string.download
|
||||
), entrance, location, isSubscribe, traceEvent
|
||||
)
|
||||
DownloadManager.createDownload(context, apk, gameEntity, asVGame, gameEntity.isDualBtnModeEnabled(), entrance, location, isSubscribe, traceEvent)
|
||||
ToastUtils.toast("${gameEntity.name}已加入下载队列")
|
||||
if (BrowserInstallHelper.shouldAutoSwitchAssistantInstall(gameEntity)) {
|
||||
val toast = context.getString(R.string.unsupported_browser_install_hint)
|
||||
@ -461,7 +500,7 @@ object GameActivityDownloadHelper {
|
||||
) {
|
||||
val msg = FileUtils.isCanDownload(context, apk.size)
|
||||
if (TextUtils.isEmpty(msg)) {
|
||||
DownloadManager.createDownload(context, apk, gameEntity, "插件化", entrance, location, isSubscribe, traceEvent)
|
||||
DownloadManager.createDownload(context, apk, gameEntity, false, false, entrance, location, isSubscribe, traceEvent)
|
||||
ToastUtils.toast("${gameEntity.name}已加入下载队列")
|
||||
if (BrowserInstallHelper.shouldAutoSwitchAssistantInstall(gameEntity)) {
|
||||
val toast = context.getString(R.string.unsupported_browser_install_hint)
|
||||
@ -489,7 +528,16 @@ object GameActivityDownloadHelper {
|
||||
gameEntity.getEntryMap().remove(apkEntity.getPlatform())
|
||||
}
|
||||
PackageUtils.isCanPluggable(apkEntity) -> {
|
||||
DialogHelper.showPluginDialog(context, gameEntity.pluginDesc) { PackageInstaller.uninstall(context, path) }
|
||||
DialogHelper.showPluginDialog(
|
||||
context,
|
||||
pluginDesc = gameEntity.pluginDesc,
|
||||
gameId = gameEntity.id,
|
||||
gameName = gameEntity.name ?: "",
|
||||
gameType = gameEntity.categoryChinese,
|
||||
platform = gameEntity.platform ?: ""
|
||||
) {
|
||||
PackageInstaller.uninstall(context, path)
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
PackageInstaller.install(context, downloadEntity)
|
||||
@ -507,7 +555,7 @@ object GameActivityDownloadHelper {
|
||||
isSubscribe: Boolean,
|
||||
traceEvent: ExposureEvent?
|
||||
) {
|
||||
DownloadManager.createDownload(context, apk, gameEntity, "更新", entrance, location, isSubscribe, traceEvent)
|
||||
DownloadManager.createDownload(context, apk, gameEntity, false, false, entrance, location, isSubscribe, traceEvent)
|
||||
ToastUtils.toast("${gameEntity.name}已加入下载队列")
|
||||
if (BrowserInstallHelper.shouldAutoSwitchAssistantInstall(gameEntity)) {
|
||||
val toast = context.getString(R.string.unsupported_browser_install_hint)
|
||||
|
||||
@ -1,272 +0,0 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.WorkerThread;
|
||||
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.simulator.SimulatorGameManager;
|
||||
import com.gh.gamecenter.common.constant.Constants;
|
||||
import com.gh.gamecenter.feature.view.DownloadButton;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.core.AppExecutor;
|
||||
import com.gh.gamecenter.feature.entity.ApkEntity;
|
||||
import com.gh.gamecenter.feature.entity.ApkLink;
|
||||
import com.gh.gamecenter.feature.entity.GameCollectionEntity;
|
||||
import com.gh.gamecenter.feature.entity.GameEntity;
|
||||
import com.gh.gamecenter.entity.GameUpdateEntity;
|
||||
import com.gh.gamecenter.feature.entity.PluginLocation;
|
||||
import com.gh.gamecenter.feature.entity.SettingsEntity;
|
||||
import com.gh.gamecenter.manager.PackagesManager;
|
||||
import com.gh.vspace.VHelper;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
import com.lightgame.download.DownloadStatus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GameUtils {
|
||||
|
||||
/**
|
||||
* 去除与重复sourceList相同的数据
|
||||
*/
|
||||
public static List<GameEntity> removeDuplicateData(List<GameEntity> sourceList, List<GameEntity> rawList) {
|
||||
if (sourceList == null || sourceList.isEmpty()
|
||||
|| rawList == null || rawList.isEmpty()) {
|
||||
return rawList;
|
||||
}
|
||||
String id;
|
||||
for (int i = 0; i < rawList.size(); i++) {
|
||||
id = rawList.get(i).getId();
|
||||
for (GameEntity gameEntity : sourceList) {
|
||||
if (id.equals(gameEntity.getId())) {
|
||||
rawList.remove(i);
|
||||
i--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return rawList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置下载按钮状态
|
||||
*/
|
||||
public static void setDownloadBtnStatus(Context context, GameEntity gameEntity, DownloadButton downloadBtn, PluginLocation pluginLocation) {
|
||||
// getDownloadBtnText 里包括查询数据库、根据包名读取包体 meta 信息等
|
||||
AppExecutor.getLightWeightIoExecutor().execute(() -> {
|
||||
String status = getDownloadBtnText(context, gameEntity, pluginLocation);
|
||||
AppExecutor.getUiExecutor().execute(() -> {
|
||||
downloadBtn.setText(status);
|
||||
if (context.getString(R.string.pluggable).equals(status)) {
|
||||
downloadBtn.setButtonStyle(DownloadButton.ButtonStyle.PLUGIN);
|
||||
String pluginDesc = gameEntity.getPluginDesc();
|
||||
if (pluginDesc.length() > 3) pluginDesc = pluginDesc.substring(0, 3);
|
||||
downloadBtn.setText((pluginDesc + "化"));
|
||||
} else {
|
||||
downloadBtn.setButtonStyle(DownloadButton.ButtonStyle.NORMAL);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下载按钮文案 (相对耗时,请优先在子线程调用)
|
||||
*/
|
||||
@WorkerThread
|
||||
public static String getDownloadBtnText(Context context, GameEntity gameEntity, PluginLocation pluginLocation) {
|
||||
if (gameEntity.getApk().size() > 1) {
|
||||
return "";
|
||||
}
|
||||
|
||||
int doneCount = 0; // 下载完成数量
|
||||
int pluginCount = 0; // 可插件化数量
|
||||
int updateCount = 0; // 可更新数量
|
||||
int installCount = 0; // 已安装数量
|
||||
|
||||
boolean isRelatedEmulatorInstalled = false; // 若该游戏是模拟器游戏时其对应的模拟器是否已经安装
|
||||
boolean isInstalledNewSimulator = false;// 是否安装新模拟器
|
||||
DownloadEntity downloadEntity = null;
|
||||
Object gh_id;
|
||||
apkFor:
|
||||
for (ApkEntity apkEntity : gameEntity.getApk()) {
|
||||
|
||||
// filter by packageName
|
||||
SettingsEntity settings = Config.getSettings();
|
||||
if (settings != null && gameEntity.getApk().size() > 1) {
|
||||
for (String pkgName : settings.getGameDownloadBlackList()) {
|
||||
if (pkgName.equals(apkEntity.getPackageName())) {
|
||||
continue apkFor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity);
|
||||
|
||||
// 在下载管理找不到下载实体,并且为畅玩游戏的时候到畅玩数据库里找
|
||||
if (downloadEntity == null && gameEntity.isVGame()) {
|
||||
downloadEntity = VHelper.getVDownloadEntitySnapshot(gameEntity.getId(), apkEntity.getPackageName());
|
||||
}
|
||||
|
||||
if (downloadEntity != null) {
|
||||
if (downloadEntity.getStatus().equals(DownloadStatus.done)) {
|
||||
doneCount++;
|
||||
} else if (downloadEntity.isPluggable()) {
|
||||
pluginCount++;
|
||||
} else if (downloadEntity.isUpdate()) {
|
||||
updateCount++;
|
||||
}
|
||||
}
|
||||
if (PackagesManager.INSTANCE.isCanUpdate(gameEntity.getId(), apkEntity.getPackageName())) {
|
||||
updateCount++;
|
||||
}
|
||||
if (PackagesManager.isInstalled(apkEntity.getPackageName())) {
|
||||
gh_id = PackageUtils.getMetaData(context, apkEntity.getPackageName(), "gh_id");
|
||||
if (!TextUtils.isEmpty(apkEntity.getGhVersion())
|
||||
&& !PackageUtils.isSignedByGh(context, apkEntity.getPackageName())
|
||||
&& apkEntity.isShowPlugin(pluginLocation)) {
|
||||
pluginCount++;
|
||||
} else if (gh_id == null
|
||||
|| gh_id.equals(gameEntity.getId())
|
||||
// 当使用镜像时,可能会存在镜像 gh_id 与当前游戏 id 不一样的情况,这时也让它通过,避免装完还是显示`下载`
|
||||
|| gameEntity.shouldUseMirrorInfo()) {
|
||||
installCount++;
|
||||
}
|
||||
}
|
||||
if (SimulatorGameManager.isSimulatorGame(gameEntity)) {
|
||||
isInstalledNewSimulator = SimulatorGameManager.isNewSimulatorInstalled(context);
|
||||
DownloadEntity simulatorDownloadEntity = SimulatorGameManager.findDownloadEntityByUrl(apkEntity.getUrl());
|
||||
if (simulatorDownloadEntity != null && gameEntity.getSimulator() != null) {
|
||||
boolean isInstalled = PackageUtils.isInstalledFromAllPackage(context, gameEntity.getSimulator().getApk().getPackageName());
|
||||
if (isInstalled) {
|
||||
installCount++;
|
||||
isRelatedEmulatorInstalled = true;
|
||||
} else {
|
||||
doneCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((isRelatedEmulatorInstalled || isInstalledNewSimulator) && doneCount != 0) {
|
||||
return context.getString(R.string.launch);
|
||||
}
|
||||
|
||||
if (gameEntity.isVGame()) {
|
||||
// 如果 doneCount 为 0 或者数据库为空
|
||||
// 表明本地并没有此游戏的数据库数据,需要重新下载
|
||||
if (doneCount == 0
|
||||
|| downloadEntity == null
|
||||
|| !VHelper.isInstalled(downloadEntity.getPackageName())) {
|
||||
installCount = 0;
|
||||
} else {
|
||||
doneCount = 0;
|
||||
installCount = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (doneCount != 0) {
|
||||
return context.getString(R.string.install);
|
||||
} else if (pluginCount != 0 && !SimulatorGameManager.isSimulatorGame(gameEntity)) {
|
||||
return context.getString(R.string.pluggable);
|
||||
} else if (updateCount != 0 && !SimulatorGameManager.isSimulatorGame(gameEntity)) {
|
||||
return context.getString(R.string.update);
|
||||
} else if (installCount != 0) {
|
||||
return context.getString(R.string.launch);
|
||||
} else if ("demo".equals(gameEntity.getDownloadStatus())) {
|
||||
return context.getString(R.string.attempt);
|
||||
} else {
|
||||
if (gameEntity.isVGame()) {
|
||||
return context.getString(R.string.smooth);
|
||||
} else {
|
||||
if (Constants.V_GAME.equals(gameEntity.getDownloadStatus())
|
||||
|| Constants.V_GAME_32.equals(gameEntity.getDownloadStatus())) {
|
||||
GameEntity.GameCategory gameCategory = gameEntity.getGameCategory();
|
||||
if (gameCategory.equals(GameEntity.GameCategory.ONLINE_GAME)
|
||||
|| gameCategory.equals(GameEntity.GameCategory.INTERNATIONAL_ONLINE_GAME)) {
|
||||
return context.getString(R.string.download);
|
||||
} else {
|
||||
return context.getString(R.string.attempt);
|
||||
}
|
||||
} else {
|
||||
return context.getString(R.string.download);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取GameUpdateEntity(插件化)
|
||||
*/
|
||||
public static GameUpdateEntity getGameUpdateEntity(GameEntity gameEntity, ApkEntity apkEntity) {
|
||||
GameUpdateEntity gameUpdateEntity = new GameUpdateEntity();
|
||||
gameUpdateEntity.setId(gameEntity.getId());
|
||||
gameUpdateEntity.setIcon(gameEntity.getIcon());
|
||||
gameUpdateEntity.setRawIcon(gameEntity.getRawIcon());
|
||||
gameUpdateEntity.setIconSubscript(gameEntity.getIconSubscript());
|
||||
gameUpdateEntity.setIconFloat(gameEntity.getIconFloat());
|
||||
gameUpdateEntity.setName(gameEntity.getName());
|
||||
gameUpdateEntity.setPackageName(apkEntity.getPackageName());
|
||||
gameUpdateEntity.setSize(apkEntity.getSize());
|
||||
gameUpdateEntity.setVersion(apkEntity.getVersion());
|
||||
gameUpdateEntity.setGhVersion(apkEntity.getGhVersion());
|
||||
gameUpdateEntity.setUrl(apkEntity.getUrl());
|
||||
gameUpdateEntity.setPlatform(apkEntity.getPlatform());
|
||||
gameUpdateEntity.setEtag(apkEntity.getEtag());
|
||||
gameUpdateEntity.setPluggable(true);
|
||||
gameUpdateEntity.setTagStyle(gameEntity.getTagStyle());
|
||||
gameUpdateEntity.setBrief(gameEntity.getBrief());
|
||||
gameUpdateEntity.setPlugin(apkEntity.getPlugin());
|
||||
gameUpdateEntity.setDownload(gameEntity.getDownload());
|
||||
gameUpdateEntity.setIndexPlugin(gameEntity.getIndexPlugin());
|
||||
gameUpdateEntity.setPluginDesc(gameEntity.getPluginDesc());
|
||||
gameUpdateEntity.setFormat(apkEntity.getFormat());
|
||||
gameUpdateEntity.setCurrentVersion(PackageUtils.getVersionNameByPackageName(apkEntity.getPackageName()));
|
||||
gameUpdateEntity.setCategory(gameEntity.getCategory());
|
||||
|
||||
GameCollectionEntity pluggableCollection = getPluggableCollectionFromGameEntity(gameEntity, apkEntity.getPackageName());
|
||||
if (pluggableCollection != null) {
|
||||
gameUpdateEntity.setPluggableCollection(pluggableCollection);
|
||||
}
|
||||
return gameUpdateEntity;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static GameCollectionEntity getPluggableCollectionFromGameEntity(GameEntity gameEntity, String targetPkg) {
|
||||
// 添加插件化包所在的合集
|
||||
for (GameCollectionEntity collectionEntity : gameEntity.getCollection()) {
|
||||
if (collectionEntity.getPackages().contains(targetPkg)) {
|
||||
ArrayList<ApkEntity> saveApkEntity = new ArrayList<>();
|
||||
for (String pkg : collectionEntity.getPackages()) {
|
||||
for (ApkEntity apk : gameEntity.getApk()) {
|
||||
if (pkg.equals(apk.getPackageName())) {
|
||||
saveApkEntity.add(apk);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<ApkLink> apkLinks = gameEntity.getApkLink();
|
||||
if (apkLinks != null) {
|
||||
for (ApkLink apkLink : apkLinks) {
|
||||
if (apkLink.getCollection().equals(collectionEntity.getId())) {
|
||||
ApkEntity element = new ApkEntity();
|
||||
element.setApkLink(apkLink);
|
||||
if (saveApkEntity.size() > apkLink.getSort()) {
|
||||
saveApkEntity.add(apkLink.getSort(), element);
|
||||
} else {
|
||||
saveApkEntity.add(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
collectionEntity.setSaveApkEntity(saveApkEntity);
|
||||
return collectionEntity;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
343
app/src/main/java/com/gh/common/util/GameUtils.kt
Normal file
343
app/src/main/java/com/gh/common/util/GameUtils.kt
Normal file
@ -0,0 +1,343 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.content.Context
|
||||
import android.text.TextUtils
|
||||
import androidx.annotation.WorkerThread
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.common.simulator.SimulatorGameManager.findDownloadEntityByUrl
|
||||
import com.gh.common.simulator.SimulatorGameManager.isNewSimulatorInstalled
|
||||
import com.gh.common.simulator.SimulatorGameManager.isSimulatorGame
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.utils.isLocalDownloadInDualDownloadMode
|
||||
import com.gh.gamecenter.common.utils.isVGameDownloadInDualDownloadMode
|
||||
import com.gh.gamecenter.core.AppExecutor.lightWeightIoExecutor
|
||||
import com.gh.gamecenter.core.AppExecutor.uiExecutor
|
||||
import com.gh.gamecenter.entity.GameUpdateEntity
|
||||
import com.gh.gamecenter.feature.entity.*
|
||||
import com.gh.gamecenter.feature.view.DownloadButton
|
||||
import com.gh.gamecenter.manager.PackagesManager
|
||||
import com.gh.gamecenter.manager.PackagesManager.isCanUpdate
|
||||
import com.gh.vspace.VHelper
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import com.lightgame.download.DownloadStatus
|
||||
|
||||
object GameUtils {
|
||||
/**
|
||||
* 去除与重复sourceList相同的数据
|
||||
*/
|
||||
fun removeDuplicateData(sourceList: MutableList<GameEntity>?, rawList: MutableList<GameEntity>?): MutableList<GameEntity>? {
|
||||
if (sourceList.isNullOrEmpty() || rawList.isNullOrEmpty()) {
|
||||
return rawList
|
||||
}
|
||||
var id: String
|
||||
var i = 0
|
||||
while (i < rawList.size) {
|
||||
id = rawList[i].id
|
||||
for (gameEntity in sourceList) {
|
||||
if (id == gameEntity.id) {
|
||||
rawList.removeAt(i)
|
||||
i--
|
||||
break
|
||||
}
|
||||
}
|
||||
i++
|
||||
}
|
||||
return rawList
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置下载按钮状态
|
||||
*/
|
||||
fun setDownloadBtnStatus(
|
||||
context: Context,
|
||||
gameEntity: GameEntity,
|
||||
downloadBtn: DownloadButton,
|
||||
pluginLocation: PluginLocation?
|
||||
) {
|
||||
// getDownloadBtnText 里包括查询数据库、根据包名读取包体 meta 信息等
|
||||
lightWeightIoExecutor.execute {
|
||||
val status = getDownloadBtnText(
|
||||
context = context,
|
||||
gameEntity = gameEntity,
|
||||
isFromList = true,
|
||||
fixedAsVGame = false,
|
||||
pluginLocation = pluginLocation
|
||||
)
|
||||
uiExecutor.execute {
|
||||
downloadBtn.text = status
|
||||
if (context.getString(R.string.pluggable) == status) {
|
||||
downloadBtn.buttonStyle = DownloadButton.ButtonStyle.PLUGIN
|
||||
var pluginDesc = gameEntity.pluginDesc
|
||||
if (pluginDesc.length > 3) pluginDesc = pluginDesc.substring(0, 3)
|
||||
downloadBtn.text = pluginDesc + "化"
|
||||
} else {
|
||||
downloadBtn.buttonStyle = DownloadButton.ButtonStyle.NORMAL
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下载按钮文案 (相对耗时,请优先在子线程调用)
|
||||
*
|
||||
* @param isFromList 调用方是否来源自普通列表 (普通列表根据优先级确定是显示成畅玩状态还是普通下载状态)
|
||||
* @param fixedAsVGame 固定以畅玩游戏的类型来获取状态
|
||||
*/
|
||||
@WorkerThread
|
||||
@JvmStatic
|
||||
fun getDownloadBtnText(context: Context,
|
||||
gameEntity: GameEntity,
|
||||
isFromList: Boolean,
|
||||
fixedAsVGame: Boolean,
|
||||
pluginLocation: PluginLocation?): String {
|
||||
if (gameEntity.getApk().size > 1) {
|
||||
return ""
|
||||
}
|
||||
var doneCount = 0 // 下载完成数量
|
||||
var pluginCount = 0 // 可插件化数量
|
||||
var updateCount = 0 // 可更新数量
|
||||
var installCount = 0 // 已安装数量
|
||||
var isRelatedEmulatorInstalled = false // 若该游戏是模拟器游戏时其对应的模拟器是否已经安装
|
||||
var isInstalledNewSimulator = false // 是否安装新模拟器
|
||||
var downloadEntity: DownloadEntity? = null
|
||||
var performAsVGame = false // 是否使用了畅玩作为 downloadEntity
|
||||
var gh_id: Any?
|
||||
apkFor@ for (apkEntity in gameEntity.getApk()) {
|
||||
|
||||
val isInstalledLocally = PackagesManager.isInstalled(apkEntity.packageName)
|
||||
|
||||
// filter by packageName
|
||||
val settings = Config.getSettings()
|
||||
if (settings != null && gameEntity.getApk().size > 1) {
|
||||
for (pkgName in settings.gameDownloadBlackList) {
|
||||
if (pkgName == apkEntity.packageName) {
|
||||
continue@apkFor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity)
|
||||
|
||||
// 已安装的畅玩游戏实体
|
||||
val vGameDownloadEntity = VHelper.getVDownloadEntitySnapshot(gameEntity.id, apkEntity.packageName)
|
||||
performAsVGame = if (fixedAsVGame) {
|
||||
true
|
||||
} else if (isFromList) {
|
||||
if (vGameDownloadEntity == null && isInstalledLocally) {
|
||||
false
|
||||
} else {
|
||||
gameEntity.isVGamePreferred()
|
||||
}
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
||||
// 畅玩状态优先,且畅玩实体不为空时将 downloadEntity 置为畅玩实体
|
||||
if (performAsVGame && vGameDownloadEntity != null) {
|
||||
downloadEntity = vGameDownloadEntity
|
||||
} else if (!performAsVGame && !isFromList && downloadEntity?.isVGameDownloadInDualDownloadMode() == true) {
|
||||
// 下载的任务是由畅玩触发的,游戏详情页不需判定为需要安装
|
||||
downloadEntity = null
|
||||
} else if (performAsVGame && !isFromList && downloadEntity?.isLocalDownloadInDualDownloadMode() == true) {
|
||||
// 下载的任务是由下载安装触发的,游戏详情页不需判定为需要安装
|
||||
downloadEntity = null
|
||||
}
|
||||
|
||||
if (downloadEntity != null) {
|
||||
if (downloadEntity.status == DownloadStatus.done) {
|
||||
doneCount++
|
||||
} else if (downloadEntity.isPluggable) {
|
||||
pluginCount++
|
||||
} else if (downloadEntity.isUpdate) {
|
||||
updateCount++
|
||||
}
|
||||
}
|
||||
|
||||
if (isCanUpdate(gameEntity.id, apkEntity.packageName, performAsVGame)) {
|
||||
updateCount++
|
||||
}
|
||||
|
||||
if (isInstalledLocally) {
|
||||
gh_id = PackageUtils.getMetaData(context, apkEntity.packageName, "gh_id")
|
||||
if (!TextUtils.isEmpty(apkEntity.ghVersion)
|
||||
&& !PackageUtils.isSignedByGh(context, apkEntity.packageName)
|
||||
&& apkEntity.isShowPlugin(pluginLocation!!)
|
||||
) {
|
||||
pluginCount++
|
||||
} else if (gh_id == null || gh_id == gameEntity.id || gameEntity.shouldUseMirrorInfo()) {
|
||||
installCount++
|
||||
}
|
||||
}
|
||||
|
||||
if (isSimulatorGame(gameEntity)) {
|
||||
isInstalledNewSimulator = isNewSimulatorInstalled(context)
|
||||
val simulatorDownloadEntity = findDownloadEntityByUrl(apkEntity.url)
|
||||
if (simulatorDownloadEntity != null && gameEntity.simulator != null) {
|
||||
val isInstalled =
|
||||
PackageUtils.isInstalledFromAllPackage(context, gameEntity.simulator!!.apk!!.packageName)
|
||||
if (isInstalled) {
|
||||
installCount++
|
||||
isRelatedEmulatorInstalled = true
|
||||
} else {
|
||||
doneCount++
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((isRelatedEmulatorInstalled || isInstalledNewSimulator) && doneCount != 0) {
|
||||
return context.getString(R.string.launch)
|
||||
}
|
||||
|
||||
if (performAsVGame) {
|
||||
// 如果 doneCount 为 0 或者数据库为空
|
||||
// 表明本地并没有此游戏的数据库数据,需要重新下载
|
||||
if (doneCount == 0 || downloadEntity == null || !VHelper.isInstalled(downloadEntity.packageName)) {
|
||||
installCount = 0
|
||||
} else {
|
||||
doneCount = 0
|
||||
installCount = 1
|
||||
}
|
||||
} else {
|
||||
if (gameEntity.isDualBtnModeEnabled()) {
|
||||
// 双下载按钮模式下,若非更新,排除已安装的情况来影响按钮状态
|
||||
if (installCount != 0 && doneCount != 0 && downloadEntity?.isUpdate == false) {
|
||||
doneCount = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return if (doneCount != 0) {
|
||||
context.getString(R.string.install)
|
||||
} else if (pluginCount != 0 && !isSimulatorGame(gameEntity)) {
|
||||
context.getString(R.string.pluggable)
|
||||
} else if (updateCount != 0 && !isSimulatorGame(gameEntity)) {
|
||||
context.getString(R.string.update)
|
||||
} else if (installCount != 0) {
|
||||
context.getString(R.string.launch)
|
||||
} else if ("demo" == gameEntity.downloadStatus) {
|
||||
context.getString(R.string.attempt)
|
||||
} else {
|
||||
if (performAsVGame) {
|
||||
context.getString(R.string.smooth)
|
||||
} else {
|
||||
// if (Constants.V_GAME == gameEntity.downloadStatus || Constants.V_GAME_32 == gameEntity.downloadStatus) {
|
||||
// val gameCategory = gameEntity.getGameCategory()
|
||||
// if (gameCategory == GameEntity.GameCategory.ONLINE_GAME
|
||||
// || gameCategory == GameEntity.GameCategory.INTERNATIONAL_ONLINE_GAME) {
|
||||
// context.getString(R.string.download)
|
||||
// } else {
|
||||
// context.getString(R.string.attempt)
|
||||
// }
|
||||
// } else {
|
||||
context.getString(R.string.download)
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取GameUpdateEntity(插件化)
|
||||
*/
|
||||
fun getGameUpdateEntity(gameEntity: GameEntity, apkEntity: ApkEntity): GameUpdateEntity {
|
||||
val gameUpdateEntity = GameUpdateEntity()
|
||||
gameUpdateEntity.id = gameEntity.id
|
||||
gameUpdateEntity.icon = gameEntity.icon
|
||||
gameUpdateEntity.rawIcon = gameEntity.rawIcon
|
||||
gameUpdateEntity.iconSubscript = gameEntity.iconSubscript
|
||||
gameUpdateEntity.iconFloat = gameEntity.iconFloat
|
||||
gameUpdateEntity.name = gameEntity.name
|
||||
gameUpdateEntity.packageName = apkEntity.packageName
|
||||
gameUpdateEntity.size = apkEntity.size
|
||||
gameUpdateEntity.version = apkEntity.version
|
||||
gameUpdateEntity.ghVersion = apkEntity.ghVersion
|
||||
gameUpdateEntity.url = apkEntity.url
|
||||
gameUpdateEntity.platform = apkEntity.getPlatform()
|
||||
gameUpdateEntity.etag = apkEntity.etag
|
||||
gameUpdateEntity.isPluggable = true
|
||||
gameUpdateEntity.tagStyle = gameEntity.tagStyle
|
||||
gameUpdateEntity.brief = gameEntity.brief
|
||||
gameUpdateEntity.plugin = apkEntity.plugin
|
||||
gameUpdateEntity.download = gameEntity.download
|
||||
gameUpdateEntity.indexPlugin = gameEntity.indexPlugin
|
||||
gameUpdateEntity.pluginDesc = gameEntity.pluginDesc
|
||||
gameUpdateEntity.format = apkEntity.format
|
||||
gameUpdateEntity.currentVersion = PackageUtils.getVersionNameByPackageName(apkEntity.packageName)
|
||||
gameUpdateEntity.category = gameEntity.category
|
||||
val pluggableCollection = getPluggableCollectionFromGameEntity(gameEntity, apkEntity.packageName)
|
||||
if (pluggableCollection != null) {
|
||||
gameUpdateEntity.pluggableCollection = pluggableCollection
|
||||
}
|
||||
return gameUpdateEntity
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getPluggableCollectionFromGameEntity(gameEntity: GameEntity, targetPkg: String?): GameCollectionEntity? {
|
||||
// 添加插件化包所在的合集
|
||||
for (collectionEntity in gameEntity.collection) {
|
||||
if (collectionEntity.packages.contains(targetPkg)) {
|
||||
val saveApkEntity = ArrayList<ApkEntity>()
|
||||
for (pkg in collectionEntity.packages) {
|
||||
for (apk in gameEntity.getApk()) {
|
||||
if (pkg == apk.packageName) {
|
||||
saveApkEntity.add(apk)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
val apkLinks = gameEntity.apkLink
|
||||
if (apkLinks != null) {
|
||||
for (apkLink in apkLinks) {
|
||||
if (apkLink.collection == collectionEntity.id) {
|
||||
val element = ApkEntity()
|
||||
element.apkLink = apkLink
|
||||
if (saveApkEntity.size > apkLink.sort) {
|
||||
saveApkEntity.add(apkLink.sort, element)
|
||||
} else {
|
||||
saveApkEntity.add(element)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
collectionEntity.saveApkEntity = saveApkEntity
|
||||
return collectionEntity
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否以畅玩游戏的形式来处理
|
||||
*/
|
||||
@JvmStatic
|
||||
fun shouldPerformAsVGame(gameEntity: GameEntity): Boolean {
|
||||
var performActionAsVGame = false
|
||||
|
||||
if (gameEntity.getApk().size != 1) {
|
||||
performActionAsVGame = false
|
||||
} else {
|
||||
when (gameEntity.getGameDownloadButtonMode()) {
|
||||
GameEntity.GAME_DOWNLOAD_BUTTON_MODE_VGAME -> performActionAsVGame = true
|
||||
GameEntity.GAME_DOWNLOAD_BUTTON_MODE_DOWNLOAD -> performActionAsVGame = false
|
||||
GameEntity.GAME_DOWNLOAD_BUTTON_MODE_DUAL -> {
|
||||
val packageName = gameEntity.getApk().first().packageName
|
||||
val isInstalledAtDevice = PackagesManager.isInstalled(packageName)
|
||||
val isInstalledAtVSpace = VHelper.getVDownloadEntitySnapshot(gameEntity.id, packageName) != null
|
||||
|
||||
performActionAsVGame = if (isInstalledAtDevice && isInstalledAtVSpace) {
|
||||
gameEntity.isVGamePreferred()
|
||||
} else if (isInstalledAtDevice) {
|
||||
false
|
||||
} else if (isInstalledAtVSpace) {
|
||||
true
|
||||
} else {
|
||||
gameEntity.isVGamePreferred()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return performActionAsVGame
|
||||
}
|
||||
}
|
||||
@ -1,14 +1,15 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import com.gh.gamecenter.common.entity.Display
|
||||
import com.gh.gamecenter.common.utils.toJson
|
||||
import com.gh.gamecenter.core.utils.GsonUtils
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.common.utils.toJson
|
||||
import com.gh.gamecenter.common.entity.Display
|
||||
import com.gh.gamecenter.entity.SubjectRecommendEntity
|
||||
import com.halo.assistant.HaloApp
|
||||
|
||||
object HomeBottomBarHelper {
|
||||
private const val GAME_BAR_KEY = "game_bar_key"
|
||||
private const val VIDEO_BAR_KEY = "video_bar_key"
|
||||
|
||||
@JvmStatic
|
||||
fun getDefaultGameBarData(): SubjectRecommendEntity {
|
||||
@ -28,6 +29,7 @@ object HomeBottomBarHelper {
|
||||
type = "block",
|
||||
text = "游戏库",
|
||||
name = "游戏库",
|
||||
position = 2,
|
||||
iconSelect = "https://resource.ghzs.com/image/game/library/entrance/5e183202913fbd002c75f247.png",
|
||||
iconUnselect = "https://resource.ghzs.com/image/game/library/entrance/5e1831fd913fbd003024641e.png",
|
||||
animationCode = animationCode,
|
||||
@ -36,8 +38,42 @@ object HomeBottomBarHelper {
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getDefaultVideoData(): SubjectRecommendEntity {
|
||||
try {
|
||||
val json = SPUtils.getString(VIDEO_BAR_KEY)
|
||||
if (json.isNotEmpty()) {
|
||||
return GsonUtils.fromJson(json, SubjectRecommendEntity::class.java)
|
||||
}
|
||||
} catch (ignore: Exception) {
|
||||
|
||||
}
|
||||
return getDefaultVideoEntity()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getDefaultVideoEntity(): SubjectRecommendEntity {
|
||||
val animationCode = HaloApp.getInstance().application.assets
|
||||
.open("lottie/tab_video.json")
|
||||
.bufferedReader().use { it.readText() }
|
||||
return SubjectRecommendEntity(
|
||||
type = "video_stream",
|
||||
text = "视频",
|
||||
name = "视频",
|
||||
position = 4,
|
||||
animationCode = animationCode,
|
||||
default = false,
|
||||
display = Display()
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun updateDefaultGameBarData(data: SubjectRecommendEntity) {
|
||||
SPUtils.setString(GAME_BAR_KEY, data.toJson())
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun updateDefaultVideoBarData(data: SubjectRecommendEntity) {
|
||||
SPUtils.setString(VIDEO_BAR_KEY, data.toJson())
|
||||
}
|
||||
}
|
||||
@ -11,6 +11,7 @@ import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.common.constant.Constants;
|
||||
import com.gh.gamecenter.common.entity.CommunityEntity;
|
||||
import com.gh.gamecenter.common.entity.ExposureEntity;
|
||||
import com.gh.gamecenter.common.exposure.ExposureSource;
|
||||
import com.gh.gamecenter.common.exposure.meta.Meta;
|
||||
import com.gh.gamecenter.common.exposure.meta.MetaUtil;
|
||||
import com.gh.gamecenter.common.loghub.LoghubUtils;
|
||||
@ -24,7 +25,6 @@ import com.gh.gamecenter.feature.entity.GameEntity;
|
||||
import com.gh.gamecenter.feature.entity.PackageDialogEntity;
|
||||
import com.gh.gamecenter.feature.entity.Questions;
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent;
|
||||
import com.gh.gamecenter.feature.exposure.ExposureSource;
|
||||
import com.gh.gamecenter.login.user.UserManager;
|
||||
import com.halo.assistant.HaloApp;
|
||||
import com.lightgame.utils.Utils;
|
||||
@ -262,6 +262,7 @@ public class LogUtils {
|
||||
object.put("version", PackageUtils.getGhVersionName());
|
||||
object.put("channel", HaloApp.getInstance().getChannel());
|
||||
object.put("dia", MetaUtil.getBase64EncodedAndroidId());
|
||||
object.put("oaid", MetaUtil.INSTANCE.getMeta().getOaid());
|
||||
object.put("time", Utils.getTime(context));
|
||||
object.put("network", DeviceUtils.getNetwork(context));
|
||||
object.put("user_id", UserManager.getInstance().getUserId());
|
||||
@ -286,6 +287,7 @@ public class LogUtils {
|
||||
metaObject.put("appVersion", meta.getAppVersion());
|
||||
metaObject.put("channel", meta.getChannel());
|
||||
metaObject.put("gid", meta.getGid());
|
||||
metaObject.put("oaid", meta.getOaid());
|
||||
metaObject.put("jnfj", MetaUtil.getBase64EncodedIMEI());
|
||||
metaObject.put("mac", meta.getMac());
|
||||
metaObject.put("manufacturer", meta.getManufacturer());
|
||||
@ -568,7 +570,7 @@ public class LogUtils {
|
||||
}
|
||||
|
||||
public static void uploadSearchGame(String event, String location, String key, String searchType) {
|
||||
uploadSearchClick(event, location, key, searchType, "", "", 0, false);
|
||||
uploadSearchClick(event, location, key, searchType, "", "", 0, false, "", "");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -581,7 +583,9 @@ public class LogUtils {
|
||||
String gameId,
|
||||
String gameName,
|
||||
int mirrorDataPosition,
|
||||
Boolean isAdData) {
|
||||
Boolean isAdData,
|
||||
String adSpaceId,
|
||||
String gameAdSourceId) {
|
||||
JSONObject object = new JSONObject();
|
||||
JSONObject payload = new JSONObject();
|
||||
try {
|
||||
@ -602,6 +606,8 @@ public class LogUtils {
|
||||
payload.put("is_mirror2_data", true);
|
||||
}
|
||||
payload.put("is_ad_data", isAdData);
|
||||
payload.put("ad_space_id", adSpaceId);
|
||||
payload.put("game_ad_source_id", gameAdSourceId);
|
||||
object.put(KEY_PAY_LOAD, payload);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@ -566,6 +566,153 @@ object NewFlatLogUtils {
|
||||
log(json)
|
||||
}
|
||||
|
||||
// 进入社区搜索页面事件
|
||||
@JvmStatic
|
||||
fun logAccessToBbsSearch(
|
||||
location: String,
|
||||
bbsId: String
|
||||
) {
|
||||
json {
|
||||
KEY_EVENT to "access_to_bbs_search"
|
||||
"location" to location
|
||||
"bbs_id" to bbsId
|
||||
parseAndPutMeta()()
|
||||
}.let(::log)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun logSearchingContent(
|
||||
location: String,
|
||||
bbsId: String,
|
||||
searchType: String,
|
||||
key: String
|
||||
) {
|
||||
json {
|
||||
KEY_EVENT to "searching_content"
|
||||
"location" to location
|
||||
"bbs_id" to bbsId
|
||||
"search_type" to searchType
|
||||
"key" to key
|
||||
parseAndPutMeta()()
|
||||
}.let(::log)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun logSearchContentClick(
|
||||
location: String,
|
||||
bbsId: String,
|
||||
searchType: String,
|
||||
key: String,
|
||||
contentId: String,
|
||||
type: String,
|
||||
title: String,
|
||||
sequence: Int,
|
||||
button: String
|
||||
) {
|
||||
json {
|
||||
KEY_EVENT to "search_content_click"
|
||||
"location" to location
|
||||
"bbs_id" to bbsId
|
||||
"search_type" to searchType
|
||||
"key" to key
|
||||
"content_id" to contentId
|
||||
"type" to type
|
||||
"title" to title
|
||||
"sequence" to sequence
|
||||
"button" to button
|
||||
parseAndPutMeta()()
|
||||
}.let(::log)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun logSearchContentExposure(
|
||||
location: String,
|
||||
bbsId: String,
|
||||
searchType: String,
|
||||
searchKey: String,
|
||||
contentId: String,
|
||||
type: String,
|
||||
title: String,
|
||||
sequence: Int
|
||||
) {
|
||||
json {
|
||||
KEY_EVENT to "search_content_exposure"
|
||||
"location" to location
|
||||
"bbs_id" to bbsId
|
||||
"search_type" to searchType
|
||||
"key" to searchKey
|
||||
"content_id" to contentId
|
||||
"type" to type
|
||||
"title" to title
|
||||
"sequence" to sequence
|
||||
parseAndPutMeta()()
|
||||
}.let(::log)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun logSearchBbs(
|
||||
searchType: String,
|
||||
searchKey: String
|
||||
) {
|
||||
json {
|
||||
KEY_EVENT to "search_bbs"
|
||||
"search_type" to searchType
|
||||
"key" to searchKey
|
||||
parseAndPutMeta()()
|
||||
}.let(::log)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun logSearchBbsClick(
|
||||
searchType: String,
|
||||
searchKey: String,
|
||||
bbsId: String,
|
||||
sequence: Int,
|
||||
name: String
|
||||
) {
|
||||
json {
|
||||
KEY_EVENT to "search_bbs_click"
|
||||
"search_type" to searchType
|
||||
"key" to searchKey
|
||||
"bbs_id" to bbsId
|
||||
"sequence" to sequence
|
||||
"name" to name
|
||||
parseAndPutMeta()()
|
||||
}.let(::log)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun logSearchUser(
|
||||
searchType: String,
|
||||
searchKey: String
|
||||
) {
|
||||
json {
|
||||
KEY_EVENT to "search_user"
|
||||
"search_type" to searchType
|
||||
"key" to searchKey
|
||||
parseAndPutMeta()()
|
||||
}.let(::log)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun logSearchUserClick(
|
||||
searchType: String,
|
||||
searchKey: String,
|
||||
userId: String,
|
||||
name: String,
|
||||
sequence: Int
|
||||
) {
|
||||
json {
|
||||
KEY_EVENT to "search_user_click"
|
||||
"search_type" to searchType
|
||||
"key" to searchKey
|
||||
"user_id" to userId
|
||||
"name" to name
|
||||
"sequence" to sequence
|
||||
parseAndPutMeta()()
|
||||
}.let(::log)
|
||||
}
|
||||
|
||||
//点击社区-搜索页返回按钮
|
||||
@JvmStatic
|
||||
fun logClickSearchReturn(searchKey: String) {
|
||||
@ -1623,12 +1770,13 @@ object NewFlatLogUtils {
|
||||
}
|
||||
|
||||
//新游开测详情页点击游戏类型
|
||||
fun logGameTestDetailGameCategoryClick(tabName: String, gameCategory: String, gameTestStartType: String) {
|
||||
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
|
||||
KEY_GAME_CATEGORY to gameCategory
|
||||
"game_test_start_type" to gameTestStartType
|
||||
"is_on" to isOn
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
@ -2326,7 +2474,10 @@ object NewFlatLogUtils {
|
||||
blockId: String,
|
||||
collectionName: String,
|
||||
collectionId: String,
|
||||
text: String
|
||||
text: String,
|
||||
linkType: String = "",
|
||||
linkId: String = "",
|
||||
linkText: String = ""
|
||||
) {
|
||||
val json = json {
|
||||
KEY_EVENT to "game_list_collection_click"
|
||||
@ -2336,6 +2487,9 @@ object NewFlatLogUtils {
|
||||
"game_list_collection_id" to collectionId
|
||||
"game_list_collection_name" to collectionName
|
||||
"text" to text
|
||||
"link_type" to linkType
|
||||
"link_id" to linkId
|
||||
"link_text" to linkText
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json)
|
||||
@ -2400,6 +2554,34 @@ object NewFlatLogUtils {
|
||||
log(json)
|
||||
}
|
||||
|
||||
// QA视频事件
|
||||
@JvmStatic
|
||||
fun logQAVideo(
|
||||
event: String,
|
||||
contentId: String,
|
||||
contentTitle: String,
|
||||
type: String,
|
||||
sequence: Int,
|
||||
videoId: String,
|
||||
playAction: String,
|
||||
playProcess: Float,
|
||||
playTime: Int
|
||||
) {
|
||||
val json = json {
|
||||
KEY_EVENT to event
|
||||
"content_id" to contentId
|
||||
"content_title" to contentTitle
|
||||
"type" to type
|
||||
"sequence" to sequence
|
||||
"video_id" to videoId
|
||||
"play_action" to playAction
|
||||
"play_process" to playProcess
|
||||
"play_time" to playTime
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun logQGameClick(qqGameId: String, qqGameName: String?) {
|
||||
val json = json {
|
||||
@ -2410,4 +2592,69 @@ object NewFlatLogUtils {
|
||||
}
|
||||
log(json)
|
||||
}
|
||||
|
||||
// 点击个人主页的认证文案事件
|
||||
@JvmStatic
|
||||
fun logClickAuthText(linkType: String, linkId: String, linkText: String, userId: String, text: String) {
|
||||
val json = json {
|
||||
KEY_EVENT to "click_authentication_text"
|
||||
"link_type" to linkType
|
||||
"link_id" to linkId
|
||||
"link_text" to linkText
|
||||
"link_user_id" to userId
|
||||
"text" to text
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json)
|
||||
}
|
||||
|
||||
// 关闭游戏广告
|
||||
@JvmStatic
|
||||
fun logCloseGameAd(
|
||||
adSpaceId: String,
|
||||
name: String,
|
||||
position: String,
|
||||
type: String,
|
||||
gameAdSourceId: String,
|
||||
gameAdSourceName: String
|
||||
) {
|
||||
val json = json {
|
||||
KEY_EVENT to "close_game_ad"
|
||||
"ad_space_id" to adSpaceId
|
||||
"name" to name
|
||||
"position" to position
|
||||
"type" to type
|
||||
"game_ad_source_id" to gameAdSourceId
|
||||
"game_ad_source_name" to gameAdSourceName
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json)
|
||||
}
|
||||
|
||||
// 点击游戏广告
|
||||
@JvmStatic
|
||||
fun logClickGameAd(
|
||||
adSpaceId: String,
|
||||
name: String,
|
||||
position: String,
|
||||
type: String,
|
||||
gameAdSourceId: String,
|
||||
gameAdSourceName: String,
|
||||
gameId: String,
|
||||
gameName: String
|
||||
) {
|
||||
val json = json {
|
||||
KEY_EVENT to "click_game_ad"
|
||||
"ad_space_id" to adSpaceId
|
||||
"name" to name
|
||||
"position" to position
|
||||
"type" to type
|
||||
"game_ad_source_id" to gameAdSourceId
|
||||
"game_ad_source_name" to gameAdSourceName
|
||||
"game_id" to gameId
|
||||
"game_name" to gameName
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json)
|
||||
}
|
||||
}
|
||||
@ -1646,7 +1646,7 @@ object NewLogUtils {
|
||||
}
|
||||
|
||||
//进入创建游戏单
|
||||
fun logEnterGameCollectionEdit(entrance: String) {
|
||||
fun logEnterGameCollectionCreate(entrance: String) {
|
||||
val json = json {
|
||||
KEY_EVENT to "enter_game_collect_create_location"
|
||||
KEY_ENTRANCE to entrance
|
||||
@ -2158,7 +2158,7 @@ object NewLogUtils {
|
||||
|
||||
//点击底部导航栏
|
||||
@JvmStatic
|
||||
fun logBottomNavigationClick(navigationName: String, linkType: String, linkText: String, linkId: String = "") {
|
||||
fun logBottomNavigationClick(navigationName: String, linkType: String, linkText: String, linkId: String = "", sequence: Int) {
|
||||
val json = json {
|
||||
KEY_EVENT to "bottom_navigation_click"
|
||||
"navigation_name" to navigationName
|
||||
@ -2169,6 +2169,7 @@ object NewLogUtils {
|
||||
"link_text" to linkText
|
||||
}
|
||||
"link_id" to linkId
|
||||
"sequence" to sequence
|
||||
KEY_TIMESTAMP to System.currentTimeMillis() / 1000
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
@ -2486,4 +2487,209 @@ object NewLogUtils {
|
||||
}
|
||||
log(json, LOG_STORE_EVENT)
|
||||
}
|
||||
|
||||
/**
|
||||
* 埋点序号:117
|
||||
* 事件ID:message_inform_push
|
||||
* 事件名称:消息推送事件
|
||||
* 触发时机:系统触发消息推送
|
||||
* @param gameId 游戏ID
|
||||
* @param gameName 游戏名称
|
||||
* @param sessionMessageType 会话类型
|
||||
* @param messageType 消息类型
|
||||
*/
|
||||
@JvmStatic
|
||||
fun logMessageInformPush(
|
||||
gameId: String,
|
||||
gameName: String,
|
||||
sessionMessageType: String,
|
||||
messageType: String
|
||||
) {
|
||||
val json = json {
|
||||
KEY_EVENT to "message_inform_push"
|
||||
KEY_GAME_ID to gameId
|
||||
KEY_GAME_NAME to gameName
|
||||
"session_message_type" to sessionMessageType
|
||||
"message_type" to messageType
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, LOG_STORE_EVENT)
|
||||
}
|
||||
|
||||
/**
|
||||
* 埋点序号:118
|
||||
* 事件ID:launch_server_subscribe_add
|
||||
* 事件名称:加入开服订阅事件
|
||||
* 触发时机:点击开服表加入订阅
|
||||
* @param gameId 游戏ID
|
||||
* @param gameName 游戏名称
|
||||
*/
|
||||
@JvmStatic
|
||||
fun logLaunchServerSubscribeAdd(
|
||||
gameId: String,
|
||||
gameName: String
|
||||
) {
|
||||
val json = json {
|
||||
KEY_EVENT to "launch_server_subscribe_add"
|
||||
KEY_GAME_ID to gameId
|
||||
KEY_GAME_NAME to gameName
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, LOG_STORE_EVENT)
|
||||
}
|
||||
|
||||
/**
|
||||
* 埋点序号:119
|
||||
* 事件ID:launch_server_subscribe_cancel
|
||||
* 事件名称:取消开服订阅事件
|
||||
* 触发时机:点击开服表取消订阅
|
||||
* @param gameId 游戏ID
|
||||
* @param gameName 游戏名称
|
||||
*/
|
||||
@JvmStatic
|
||||
fun logLaunchServerSubscribeCancel(
|
||||
gameId: String,
|
||||
gameName: String
|
||||
) {
|
||||
val json = json {
|
||||
KEY_EVENT to "launch_server_subscribe_cancel"
|
||||
KEY_GAME_ID to gameId
|
||||
KEY_GAME_NAME to gameName
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, LOG_STORE_EVENT)
|
||||
}
|
||||
|
||||
/**
|
||||
* 埋点序号:120
|
||||
* 事件ID:launch_server_subscribe_click
|
||||
* 事件名称:点击开服订阅事件
|
||||
* 触发时机:点击开服管理的开服记录
|
||||
* @param gameId 游戏ID
|
||||
* @param gameName 游戏名称
|
||||
* @param launchServerTime 以秒为单位的时间戳,若为日期则是当天0点的时间戳
|
||||
*/
|
||||
@JvmStatic
|
||||
fun logLaunchServerSubscribeClick(
|
||||
gameId: String,
|
||||
gameName: String,
|
||||
launchServerTime: Int
|
||||
) {
|
||||
val json = json {
|
||||
KEY_EVENT to "launch_server_subscribe_click"
|
||||
KEY_GAME_ID to gameId
|
||||
KEY_GAME_NAME to gameName
|
||||
"launch_server_time" to launchServerTime
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, LOG_STORE_EVENT)
|
||||
}
|
||||
|
||||
/**
|
||||
* 埋点序号:121
|
||||
* 事件ID:launch_server_reminder_add
|
||||
* 事件名称:添加开服提醒事件
|
||||
* 触发时机:点击开服表的添加提醒
|
||||
* @param gameId 游戏ID
|
||||
* @param gameName 游戏名称
|
||||
* @param reminderTime 设置提醒时间: 已知服是上传以秒为单位的时间戳,未知服则是当天0点的时间戳
|
||||
* @param reminderType 提醒类型: 已知服/未知服
|
||||
* @param launchServerTime 设置开服时间: 已知服是上传以秒为单位的时间戳,未知服则是当天0点的时间戳
|
||||
* @param serverName 服务器名字
|
||||
* @param isWechat 是否微信提醒
|
||||
* @param isApp 是否APP提醒
|
||||
*/
|
||||
@JvmStatic
|
||||
fun logLaunchServerReminderAdd(
|
||||
gameId: String,
|
||||
gameName: String,
|
||||
reminderTime: Int,
|
||||
reminderType: String,
|
||||
launchServerTime: Int,
|
||||
serverName: String,
|
||||
isWechat: Boolean,
|
||||
isApp: Boolean
|
||||
) {
|
||||
val json = json {
|
||||
KEY_EVENT to "launch_server_reminder_add"
|
||||
KEY_GAME_ID to gameId
|
||||
KEY_GAME_NAME to gameName
|
||||
"reminder_time" to reminderTime
|
||||
"reminder_type" to reminderType
|
||||
"launch_server_time" to launchServerTime
|
||||
"server_name" to serverName
|
||||
"is_wechat" to isWechat
|
||||
"is_app" to isApp
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, LOG_STORE_EVENT)
|
||||
}
|
||||
|
||||
/**
|
||||
* 埋点序号:122
|
||||
* 事件ID:launch_server_reminder_cancel
|
||||
* 事件名称:取消开服提醒事件
|
||||
* 触发时机:点击开服表的取消提醒
|
||||
* @param gameId 游戏ID
|
||||
* @param gameName 游戏名称
|
||||
* @param reminderTime 设置提醒时间: 已知服是上传以秒为单位的时间戳,未知服则是当天0点的时间戳
|
||||
* @param reminderType 提醒类型: 已知服/未知服
|
||||
* @param launchServerTime 设置开服时间: 已知服是上传以秒为单位的时间戳,未知服则是当天0点的时间戳
|
||||
* @param serverName 服务器名字
|
||||
* @param isWechat 是否微信提醒
|
||||
* @param isApp 是否APP提醒
|
||||
*/
|
||||
@JvmStatic
|
||||
fun logLaunchServerReminderCancel(
|
||||
gameId: String,
|
||||
gameName: String,
|
||||
reminderTime: Int,
|
||||
reminderType: String,
|
||||
launchServerTime: Int,
|
||||
serverName: String,
|
||||
isWechat: Boolean,
|
||||
isApp: Boolean
|
||||
) {
|
||||
val json = json {
|
||||
KEY_EVENT to "launch_server_reminder_cancel"
|
||||
KEY_GAME_ID to gameId
|
||||
KEY_GAME_NAME to gameName
|
||||
"reminder_time" to reminderTime
|
||||
"reminder_type" to reminderType
|
||||
"launch_server_time" to launchServerTime
|
||||
"server_name" to serverName
|
||||
"is_wechat" to isWechat
|
||||
"is_app" to isApp
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, LOG_STORE_EVENT)
|
||||
}
|
||||
|
||||
/**
|
||||
* 埋点序号:123
|
||||
* 事件ID:launch_server_reminder_click
|
||||
* 事件名称:点击开服提醒事件
|
||||
* 触发时机:点击开服管理的提醒记录
|
||||
* @param gameId 游戏ID
|
||||
* @param gameName 游戏名称
|
||||
* @param reminderTime 设置提醒时间: 已知服是上传以秒为单位的时间戳,未知服则是当天0点的时间戳
|
||||
* @param status 记录状态: todo 待提醒 coming 即将开服 opened 已开服 has_new 有新服 expired 已过期
|
||||
*/
|
||||
@JvmStatic
|
||||
fun logLaunchServerReminderClick(
|
||||
gameId: String,
|
||||
gameName: String,
|
||||
reminderTime: Int,
|
||||
status: String,
|
||||
) {
|
||||
val json = json {
|
||||
KEY_EVENT to "launch_server_reminder_click"
|
||||
KEY_GAME_ID to gameId
|
||||
KEY_GAME_NAME to gameName
|
||||
"reminder_time" to reminderTime
|
||||
"status" to status
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, LOG_STORE_EVENT)
|
||||
}
|
||||
}
|
||||
@ -15,9 +15,7 @@ import com.gh.common.xapk.XapkInstaller
|
||||
import com.gh.download.server.BrowserInstallHelper
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.utils.DialogHelper
|
||||
import com.gh.gamecenter.common.utils.getExtension
|
||||
import com.gh.gamecenter.common.utils.getMetaExtra
|
||||
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
|
||||
@ -36,7 +34,7 @@ object PackageInstaller {
|
||||
*/
|
||||
@JvmStatic
|
||||
fun install(context: Context, downloadEntity: DownloadEntity?) {
|
||||
downloadEntity?.let { install(context, downloadEntity, true) }
|
||||
downloadEntity?.let { install(context, downloadEntity, showUnzipToast = true, ignoreAsVGame = false) }
|
||||
}
|
||||
|
||||
/**
|
||||
@ -45,16 +43,25 @@ object PackageInstaller {
|
||||
* 兼容所有包安装(apk,xapk),后续可加上apks
|
||||
*
|
||||
* 主动点击安装如果是xapk则需要toast提示
|
||||
*
|
||||
* @param ignoreAsVGame 是否不需要以畅玩形式安装
|
||||
*
|
||||
*
|
||||
*/
|
||||
@JvmStatic
|
||||
fun install(context: Context, downloadEntity: DownloadEntity, showUnzipToast: Boolean) {
|
||||
fun install(context: Context,
|
||||
downloadEntity: DownloadEntity,
|
||||
showUnzipToast: Boolean,
|
||||
ignoreAsVGame: Boolean,
|
||||
) {
|
||||
val pkgPath = downloadEntity.path
|
||||
val isXapk = XapkInstaller.XAPK_EXTENSION_NAME == pkgPath.getExtension()
|
||||
val isVGame = downloadEntity.getMetaExtra(Constants.SMOOTH_GAME) == "true"
|
||||
val isDownloadAsVGame = downloadEntity.getMetaExtra(Constants.EXTRA_DOWNLOAD_TYPE) == Constants.VGAME
|
||||
|| downloadEntity.getMetaExtra(Constants.EXTRA_DOWNLOAD_TYPE) == Constants.DUAL_DOWNLOAD_VGAME
|
||||
|
||||
val currentActivity = CurrentActivityHolder.getCurrentActivity() ?: return
|
||||
|
||||
if (isVGame) {
|
||||
if (!ignoreAsVGame && isDownloadAsVGame) {
|
||||
VHelper.install(currentActivity, downloadEntity)
|
||||
return
|
||||
}
|
||||
@ -120,12 +127,24 @@ object PackageInstaller {
|
||||
}
|
||||
} else {
|
||||
if (isPluggin) {
|
||||
DialogHelper.showPluginDialog(context, downloadEntity?.pluginDesc) {
|
||||
DialogHelper.showPluginDialog(
|
||||
context,
|
||||
pluginDesc = downloadEntity?.pluginDesc,
|
||||
gameId = downloadEntity?.gameId ?: "",
|
||||
gameName = downloadEntity?.name ?: "",
|
||||
gameType = downloadEntity?.categoryChinese ?: "",
|
||||
platform = downloadEntity?.platform ?: ""
|
||||
) {
|
||||
uninstall(context, pkgPath)
|
||||
}
|
||||
} else {
|
||||
// 非插件化的同包名不同签名冲突
|
||||
DialogHelper.showSignatureConflictDialog(context) {
|
||||
DialogHelper.showSignatureConflictDialog(
|
||||
context,
|
||||
gameId = downloadEntity?.gameId ?: "",
|
||||
gameName = downloadEntity?.name ?: "",
|
||||
gameType = downloadEntity?.categoryChinese ?: ""
|
||||
) {
|
||||
uninstall(context, pkgPath)
|
||||
}
|
||||
}
|
||||
@ -317,11 +336,13 @@ object PackageInstaller {
|
||||
showCloseIcon = true,
|
||||
showAlternativeCancelStyle = !isTheFirstTimeToShowVpnHintDialog
|
||||
),
|
||||
uiModificationCallback = { binding, dialog ->
|
||||
uiModificationCallback = { binding ->
|
||||
binding.cancelTv.visibility = View.GONE
|
||||
binding.closeContainer.setOnClickListener {
|
||||
binding.markDismissByTouchInside()
|
||||
|
||||
install(currentActivity, pkgPath)
|
||||
dialog.dismiss()
|
||||
binding.dismiss()
|
||||
|
||||
downloadEntity?.let {
|
||||
NewFlatLogUtils.logVpnHintDialogClick(it.gameId, it.name, "关闭按钮")
|
||||
|
||||
@ -1,13 +1,77 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.content.Context
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.common.utils.isVGameDownloadInDualDownloadMode
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.feature.entity.GameInstall
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.entity.GameInstall
|
||||
import com.gh.gamecenter.packagehelper.PackageRepository
|
||||
import com.gh.vspace.VHelper
|
||||
|
||||
object PackageLauncher {
|
||||
|
||||
/**
|
||||
* 自动选择启动已安装的畅玩或本地已安装的游戏
|
||||
* 仅适用于 gameEntity 只有一个 apk 的情况
|
||||
*/
|
||||
@JvmStatic
|
||||
fun launch(
|
||||
context: Context,
|
||||
gameEntity: GameEntity,
|
||||
location: String? = null
|
||||
) {
|
||||
if (gameEntity.getApk().isEmpty() || gameEntity.getApk().size > 1) {
|
||||
return
|
||||
}
|
||||
|
||||
val packageName = gameEntity.getApk().first().packageName
|
||||
|
||||
// 根据下载按钮类型进行进行不一样的处理
|
||||
when (gameEntity.getGameDownloadButtonMode()) {
|
||||
GameEntity.GAME_DOWNLOAD_BUTTON_MODE_DOWNLOAD -> {
|
||||
launchApp(context, gameEntity, packageName)
|
||||
}
|
||||
|
||||
GameEntity.GAME_DOWNLOAD_BUTTON_MODE_VGAME -> {
|
||||
VHelper.installOrLaunch(context as AppCompatActivity, gameEntity, location)
|
||||
}
|
||||
|
||||
GameEntity.GAME_DOWNLOAD_BUTTON_MODE_DUAL -> {
|
||||
val vGameIsInstalled = VHelper.isInstalled(packageName)
|
||||
val localGameIsInstalled = PackageUtils.isInstalled(context, packageName)
|
||||
|
||||
when {
|
||||
vGameIsInstalled && localGameIsInstalled -> {
|
||||
if (gameEntity.isVGamePreferred()) {
|
||||
VHelper.installOrLaunch(context as AppCompatActivity, gameEntity, location)
|
||||
} else {
|
||||
launchApp(context, gameEntity, packageName)
|
||||
}
|
||||
}
|
||||
|
||||
vGameIsInstalled -> {
|
||||
VHelper.installOrLaunch(context as AppCompatActivity, gameEntity, location)
|
||||
}
|
||||
|
||||
localGameIsInstalled -> {
|
||||
launchApp(context, gameEntity, packageName)
|
||||
}
|
||||
|
||||
else -> {
|
||||
val downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity)
|
||||
if (downloadEntity?.isVGameDownloadInDualDownloadMode() == true) {
|
||||
VHelper.installOrLaunch(context as AppCompatActivity, gameEntity, location)
|
||||
} else {
|
||||
ToastUtils.toast("下载异常,请重新下载")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 启动应用
|
||||
*/
|
||||
|
||||
@ -41,7 +41,6 @@ import com.gh.gamecenter.manager.PackagesManager;
|
||||
import com.gh.vspace.VHelper;
|
||||
import com.gh.vspace.db.VGameEntity;
|
||||
import com.halo.assistant.HaloApp;
|
||||
import com.lg.vspace.VirtualAppManager;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import net.dongliu.apk.parser.ApkFile;
|
||||
@ -110,10 +109,12 @@ public class PackageUtils {
|
||||
return !(MD5Str.equals(MD5Utils.calculateMD5(file)));
|
||||
}
|
||||
|
||||
/*
|
||||
* 判断是否可以更新,只判断gh_version的大小
|
||||
/**
|
||||
* 判断是否可以更新
|
||||
* @param gameEntity 游戏摘要实体
|
||||
* @param isVGame 是否为畅玩游戏(走特殊的判断更新逻辑)
|
||||
*/
|
||||
public static List<GameUpdateEntity> getUpdateData(GameEntity gameEntity) {
|
||||
public static List<GameUpdateEntity> getUpdateData(GameEntity gameEntity, boolean isVGame) {
|
||||
|
||||
List<GameUpdateEntity> updateList = new ArrayList<>();
|
||||
|
||||
@ -169,7 +170,7 @@ public class PackageUtils {
|
||||
boolean shouldShowUpdate = apkEntity.getForce();
|
||||
// 普通游戏根据本地是否有安装来确定是否 qualified,畅玩游戏直接进判断
|
||||
boolean isUpdateQualified =
|
||||
gameEntity.isVGame() || (!TextUtils.isEmpty(versionFromRequest) && !TextUtils.isEmpty(versionFromInstalledApp));
|
||||
isVGame || (!TextUtils.isEmpty(versionFromRequest) && !TextUtils.isEmpty(versionFromInstalledApp));
|
||||
|
||||
if (shouldShowUpdate && isUpdateQualified) {
|
||||
|
||||
@ -182,12 +183,11 @@ public class PackageUtils {
|
||||
}
|
||||
|
||||
// 畅玩游戏根据 md5 是否一致确定是否需要更新
|
||||
if (gameEntity.isVGame()) {
|
||||
if (isVGame) {
|
||||
VGameEntity vGameEntity = VHelper.getVGameSnapshot(gameEntity.getId(), apkEntity.getPackageName());
|
||||
if (vGameEntity != null) {
|
||||
String md5FromInstalledVGame = ExtensionsKt.getMetaExtra(vGameEntity.getDownloadEntity(), Constants.APK_MD5);
|
||||
String md5FromRequest = apkEntity.getMd5();
|
||||
apkEntity.setPlatform(VHelper.PLATFORM_V);
|
||||
|
||||
shouldShowUpdate = md5FromRequest != null && !md5FromRequest.equals(md5FromInstalledVGame);
|
||||
} else {
|
||||
@ -219,6 +219,7 @@ public class PackageUtils {
|
||||
updateEntity.setFormat(apkEntity.getFormat());
|
||||
updateEntity.setSignature(apkEntity.getSignature());
|
||||
updateEntity.setCategory(gameEntity.getCategory());
|
||||
updateEntity.setVGameUpdate(isVGame);
|
||||
updateEntity.setCurrentVersion(PackageUtils.getVersionNameByPackageName(apkEntity.getPackageName()));
|
||||
if (gameEntity.isLandPageAddressDialog()) {
|
||||
updateEntity.setLandPageAddressDialog(gameEntity.getLandPageAddressDialog());
|
||||
|
||||
@ -23,7 +23,13 @@ object RecommendPopupHelper {
|
||||
//判断是否为多版本游戏
|
||||
if (gameEntity.getApk().isEmpty() || gameEntity.getApk().size > 1) return null
|
||||
|
||||
val downloadBtnText = GameUtils.getDownloadBtnText(HaloApp.getInstance(), gameEntity, PluginLocation.only_game)
|
||||
val downloadBtnText = GameUtils.getDownloadBtnText(
|
||||
context = HaloApp.getInstance(),
|
||||
gameEntity = gameEntity,
|
||||
isFromList = false,
|
||||
fixedAsVGame = false,
|
||||
pluginLocation = PluginLocation.only_game
|
||||
)
|
||||
val filterEntities = arrayListOf<RecommendPopupEntity>()
|
||||
|
||||
loop@ for (entity in popups) {
|
||||
|
||||
@ -83,8 +83,8 @@ class FlexLinearLayout @JvmOverloads constructor(context: Context, attrs: Attrib
|
||||
|
||||
private fun addTags() {
|
||||
removeAllViews()
|
||||
mTags.forEach {
|
||||
addView(createView(it))
|
||||
mTags.forEachIndexed { index, tag ->
|
||||
addView(createView(tag, index))
|
||||
}
|
||||
if (mTotalCount != mTags.size) {
|
||||
val imageView = ImageView(context).apply {
|
||||
@ -102,7 +102,7 @@ class FlexLinearLayout @JvmOverloads constructor(context: Context, attrs: Attrib
|
||||
}
|
||||
}
|
||||
|
||||
private fun createView(tag: TagStyleEntity): View {
|
||||
private fun createView(tag: TagStyleEntity, position: Int): View {
|
||||
return TextView(context).apply {
|
||||
text = tag.name
|
||||
includeFontPadding = false
|
||||
@ -117,7 +117,7 @@ class FlexLinearLayout @JvmOverloads constructor(context: Context, attrs: Attrib
|
||||
setTextColor(if (tag.isTop) "#${tag.color}".hexStringToIntColor() else R.color.text_title.toColor(context))
|
||||
background = if (tag.isTop) createTopBackgroundDrawable(tag) else createNormalBackgroundDrawable()
|
||||
setOnClickListener {
|
||||
onClickListener?.onItemClickListener(tag)
|
||||
onClickListener?.onItemClickListener(tag, position)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -140,6 +140,6 @@ class FlexLinearLayout @JvmOverloads constructor(context: Context, attrs: Attrib
|
||||
|
||||
interface OnItemClickListener {
|
||||
fun onMoreClickListener()
|
||||
fun onItemClickListener(tag: TagStyleEntity)
|
||||
fun onItemClickListener(tag: TagStyleEntity, position: Int)
|
||||
}
|
||||
}
|
||||
@ -75,7 +75,7 @@ class ImageContainerView : LinearLayout {
|
||||
calculateWidth()
|
||||
}
|
||||
|
||||
fun bindData(entity: AnswerEntity, entrance: String = "", path: String = "") {
|
||||
fun bindData(entity: AnswerEntity, entrance: String = "", path: String = "", imageClick: (() -> Unit)? = null) {
|
||||
imageViewList.clear()
|
||||
if (entity.id != mAnswerEntity?.id) {
|
||||
removeAllViews()
|
||||
@ -103,13 +103,15 @@ class ImageContainerView : LinearLayout {
|
||||
images.forEachIndexed { index, url ->
|
||||
val width = if (index <= entity.imagesInfo.size - 1) imagesInfo[index].width else 0
|
||||
val height = if (index <= entity.imagesInfo.size - 1) imagesInfo[index].height else 0
|
||||
bindImage(url, width, height, images.size == 1)
|
||||
bindImage(url, width, height, images.size == 1, imageClick)
|
||||
}
|
||||
}
|
||||
|
||||
entity.getPassVideos().isNotEmpty() -> {
|
||||
val video = entity.getPassVideos()[0]
|
||||
bindVideo(video, video.width, video.height, true)
|
||||
}
|
||||
|
||||
else -> {
|
||||
// do noting
|
||||
}
|
||||
@ -125,7 +127,7 @@ class ImageContainerView : LinearLayout {
|
||||
val imagesInfo = entity.imagesInfo
|
||||
val width = if (index <= entity.imagesInfo.size - 1) imagesInfo[index].width else 0
|
||||
val height = if (index <= entity.imagesInfo.size - 1) imagesInfo[index].height else 0
|
||||
bindImage(url, width, height, false)
|
||||
bindImage(url, width, height, false, imageClick)
|
||||
}
|
||||
} else {
|
||||
val images = entity.images.take(3)
|
||||
@ -133,7 +135,7 @@ class ImageContainerView : LinearLayout {
|
||||
val imagesInfo = entity.imagesInfo
|
||||
val width = if (index <= entity.imagesInfo.size - 1) imagesInfo[index].width else 0
|
||||
val height = if (index <= entity.imagesInfo.size - 1) imagesInfo[index].height else 0
|
||||
bindImage(url, width, height, images.size == 1)
|
||||
bindImage(url, width, height, images.size == 1, imageClick)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -171,7 +173,13 @@ class ImageContainerView : LinearLayout {
|
||||
index++
|
||||
}
|
||||
|
||||
private fun bindImage(url: String, width: Int, height: Int, isChangeRatio: Boolean) {
|
||||
private fun bindImage(
|
||||
url: String,
|
||||
width: Int,
|
||||
height: Int,
|
||||
isChangeRatio: Boolean,
|
||||
imageClick: (() -> Unit)?
|
||||
) {
|
||||
val oldView = if (childCount == 0 || index >= childCount) null else getChildAt(index)
|
||||
val binding = if (oldView != null) {
|
||||
ItemCommunityImageBinding.bind(oldView)
|
||||
@ -188,7 +196,7 @@ class ImageContainerView : LinearLayout {
|
||||
displayImage(binding, url, width.toFloat(), height.toFloat(), isChangeRatio)
|
||||
binding.root.setOnClickListener {
|
||||
if (mAnswerEntity?.status == "pending" || mAnswerEntity?.status == "fail") return@setOnClickListener
|
||||
|
||||
imageClick?.invoke()
|
||||
debounceActionWithInterval(it.id, 1000) {
|
||||
if (mAnswerEntity == null) return@debounceActionWithInterval
|
||||
val position = if (mAnswerEntity?.type == "community_article") {
|
||||
@ -232,10 +240,12 @@ class ImageContainerView : LinearLayout {
|
||||
ImageUtils.display(binding.image, url, false, TopCutProcess(mMinRatio))
|
||||
}
|
||||
}
|
||||
|
||||
picRatio >= mMaxRatio -> {
|
||||
params.height = (mFixdWidth / mMaxRatio).toInt()
|
||||
ImageUtils.display(binding.image, url, false)
|
||||
}
|
||||
|
||||
else -> {
|
||||
params.height = (mFixdWidth / picRatio).toInt()
|
||||
ImageUtils.display(binding.image, url, false)
|
||||
|
||||
@ -11,9 +11,12 @@ import android.util.AttributeSet;
|
||||
import android.view.Gravity;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebResourceResponse;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.common.constant.Config;
|
||||
@ -60,6 +63,12 @@ import java.util.Locale;
|
||||
*/
|
||||
|
||||
public class RichEditor extends WebView {
|
||||
|
||||
/**
|
||||
* 默认的编辑器换行符
|
||||
*/
|
||||
public final static String DEFAULT_PARAGRAPH_SEPARATOR = "p";
|
||||
|
||||
private boolean mContentOwner;
|
||||
private boolean mInputEnabled;
|
||||
|
||||
@ -87,7 +96,7 @@ public class RichEditor extends WebView {
|
||||
UNORDEREDLIST,
|
||||
JUSTIFYCENTER,
|
||||
JUSTIFYFULL,
|
||||
JUSTUFYLEFT,
|
||||
JUSTIFYLEFT,
|
||||
JUSTIFYRIGHT
|
||||
}
|
||||
|
||||
@ -116,8 +125,13 @@ public class RichEditor extends WebView {
|
||||
private OnDecorationStateListener mDecorationStateListener;
|
||||
private AfterInitialLoadListener mLoadListener;
|
||||
private WebChromeClientListener mChromeClientListener;
|
||||
private WebResourceRequestInterceptor mWebResourceRequestInterceptor;
|
||||
private PageFinishedListener mPageFinishedListener;
|
||||
|
||||
private OnLinkClickListener mOnLinkClickListener;
|
||||
|
||||
private ImageListener mImageListener;
|
||||
|
||||
public RichEditor(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
@ -136,6 +150,8 @@ public class RichEditor extends WebView {
|
||||
ExtensionsKt.fixUiModeIfNeeded(this);
|
||||
|
||||
addJavascriptInterface(new NativeCallBack(), "NativeCallBack");
|
||||
addJavascriptInterface(new LinkClickNativeCallback(), "OnLinkClickListener");
|
||||
addJavascriptInterface(new ImageNativeCallback(), "imagelistener");
|
||||
|
||||
setVerticalScrollBarEnabled(false);
|
||||
setHorizontalScrollBarEnabled(false);
|
||||
@ -173,6 +189,10 @@ public class RichEditor extends WebView {
|
||||
mChromeClientListener = chromeClientListener;
|
||||
}
|
||||
|
||||
public void setWebResourceRequestInterceptor(WebResourceRequestInterceptor interceptor) {
|
||||
mWebResourceRequestInterceptor = interceptor;
|
||||
}
|
||||
|
||||
public void setPageFinishedListener(PageFinishedListener pageFinishedListener) {
|
||||
mPageFinishedListener = pageFinishedListener;
|
||||
}
|
||||
@ -181,6 +201,14 @@ public class RichEditor extends WebView {
|
||||
mInitialLayoutCallback = layoutCallback;
|
||||
}
|
||||
|
||||
public void setOnLinkClickListener(OnLinkClickListener onLinkClickListener) {
|
||||
this.mOnLinkClickListener = onLinkClickListener;
|
||||
}
|
||||
|
||||
public void setImageListener(ImageListener imageListener) {
|
||||
this.mImageListener = imageListener;
|
||||
}
|
||||
|
||||
private void callback(String text) {
|
||||
mContents = text.replaceFirst(CALLBACK_SCHEME, "");
|
||||
if (mTextChangeListener != null) {
|
||||
@ -396,6 +424,14 @@ public class RichEditor extends WebView {
|
||||
exec("javascript:RE.insertImage('" + url + "');");
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入分割线
|
||||
*/
|
||||
public void insertDivider() {
|
||||
exec("javascript:RE.prepareInsert();");
|
||||
exec("javascript:RE.insertHorizontalRule();");
|
||||
}
|
||||
|
||||
public void insertHtml(String html) {
|
||||
exec("javascript:RE.prepareInsert();");
|
||||
exec("javascript:RE.insertHTML('" + html + "');");
|
||||
@ -447,6 +483,14 @@ public class RichEditor extends WebView {
|
||||
exec("javascript:RE.setBaseTextColor('" + hex + "');");
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置编辑器默认换行符
|
||||
* @param separator 换行符
|
||||
*/
|
||||
public void setDefaultParagraphSeparator(String separator) {
|
||||
exec("javascript:RE.setDefaultParagraphSeparator('" + separator + "')");
|
||||
}
|
||||
|
||||
public void insertPlaceholderImage(String id) {
|
||||
exec("javascript:RE.prepareInsert();");
|
||||
exec("javascript:RE.insertPlaceholderImage('" + id + "');");
|
||||
@ -625,6 +669,9 @@ public class RichEditor extends WebView {
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
isReady = url.equalsIgnoreCase(SETUP_HTML);
|
||||
if (isReady) {
|
||||
setDefaultParagraphSeparator(DEFAULT_PARAGRAPH_SEPARATOR);
|
||||
}
|
||||
if (mLoadListener != null) {
|
||||
mLoadListener.onAfterInitialLoad(isReady);
|
||||
}
|
||||
@ -658,6 +705,16 @@ public class RichEditor extends WebView {
|
||||
|
||||
return super.shouldOverrideUrlLoading(view, url);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
|
||||
if (mWebResourceRequestInterceptor != null) {
|
||||
return mWebResourceRequestInterceptor.shouldInterceptRequest(view, url);
|
||||
}
|
||||
|
||||
return super.shouldInterceptRequest(view, url);
|
||||
}
|
||||
}
|
||||
|
||||
public void setContentOwner(boolean contentOwner) {
|
||||
@ -674,6 +731,10 @@ public class RichEditor extends WebView {
|
||||
boolean shouldOverrideUrlLoading(WebView view, String url);
|
||||
}
|
||||
|
||||
public interface WebResourceRequestInterceptor {
|
||||
WebResourceResponse shouldInterceptRequest(WebView view, String url);
|
||||
}
|
||||
|
||||
public interface PageFinishedListener {
|
||||
void onPageFinished();
|
||||
}
|
||||
@ -817,6 +878,96 @@ public class RichEditor extends WebView {
|
||||
}
|
||||
}
|
||||
|
||||
class LinkClickNativeCallback {
|
||||
|
||||
/**
|
||||
* 链接点击回调
|
||||
* @param content 回调内容
|
||||
*/
|
||||
@JavascriptInterface
|
||||
public void onClick(String content) {
|
||||
if (mOnLinkClickListener != null) {
|
||||
mOnLinkClickListener.onClick(content);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 视频点击回调
|
||||
* @param content 回调内容
|
||||
*/
|
||||
@JavascriptInterface
|
||||
public void onVideoClick(String content) {
|
||||
if (mOnLinkClickListener != null) {
|
||||
mOnLinkClickListener.onVideoClick(content);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 视频点击回调
|
||||
* @param url 视频链接
|
||||
* @param poster 视频封面
|
||||
*/
|
||||
@JavascriptInterface
|
||||
public void onVideoClick(String url, String poster) {
|
||||
if (mOnLinkClickListener != null) {
|
||||
mOnLinkClickListener.onVideoClick(url, poster);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 视频点击回调
|
||||
* @param url 视频链接
|
||||
* @param poster 视频封面
|
||||
* @param position 视频下标位置
|
||||
*/
|
||||
@JavascriptInterface
|
||||
public void onVideoClick(String url, String poster, long position) {
|
||||
if (mOnLinkClickListener != null) {
|
||||
mOnLinkClickListener.onVideoClick(url, poster, position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ImageNativeCallback {
|
||||
/**
|
||||
* 图片点击回调
|
||||
* @param url 图片链接
|
||||
*/
|
||||
@JavascriptInterface
|
||||
public void imageClick(String url) {
|
||||
if (mImageListener != null) {
|
||||
mImageListener.onImageClick(url);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 图片加载回调
|
||||
* @param url 图片链接
|
||||
*/
|
||||
@JavascriptInterface
|
||||
public void imageArr(String url) {
|
||||
if (mImageListener != null) {
|
||||
mImageListener.onImageLoad(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface OnLinkClickListener {
|
||||
void onClick(String content);
|
||||
|
||||
void onVideoClick(String content);
|
||||
|
||||
void onVideoClick(String url, String poster);
|
||||
|
||||
void onVideoClick(String url, String poster, long position);
|
||||
}
|
||||
|
||||
public interface ImageListener {
|
||||
void onImageLoad(String url);
|
||||
|
||||
void onImageClick(String url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
|
||||
@ -14,9 +14,7 @@ import com.gh.gamecenter.common.activityresult.ActResultRequest
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.entity.SimpleGameEntity
|
||||
import com.gh.gamecenter.common.entity.SuggestType
|
||||
import com.gh.gamecenter.common.utils.DialogHelper
|
||||
import com.gh.gamecenter.common.utils.PermissionHelper
|
||||
import com.gh.gamecenter.common.utils.dip2px
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.help.HelpAndFeedbackBridge
|
||||
import com.lightgame.download.DownloadEntity
|
||||
@ -31,11 +29,18 @@ object XapkDialogHelper {
|
||||
val trigger = if (isManualAction) "手动触发" else "自动触发"
|
||||
NewFlatLogUtils.logXApkUnzipFailedDialogShowed(trigger, downloadEntity.gameId, downloadEntity.name)
|
||||
|
||||
SensorsBridge.trackGameDecompressionFailedDialogShow(
|
||||
downloadEntity.gameId,
|
||||
downloadEntity.name,
|
||||
downloadEntity.categoryChinese
|
||||
)
|
||||
|
||||
val previousShowedDialog = mUnzipFailureDialogRef?.get()
|
||||
|
||||
if (previousShowedDialog != null
|
||||
&& previousShowedDialog.isShowing
|
||||
&& context == previousShowedDialog.ownerActivity) {
|
||||
&& context == previousShowedDialog.ownerActivity
|
||||
) {
|
||||
// 上一个解压失败弹窗还在显示,当前 activity 不用再显示新的弹窗了
|
||||
return
|
||||
}
|
||||
@ -57,6 +62,13 @@ object XapkDialogHelper {
|
||||
downloadEntity.name
|
||||
)
|
||||
|
||||
SensorsBridge.trackGameDecompressionFailedDialogClick(
|
||||
buttonName = "开启权限",
|
||||
downloadEntity.gameId,
|
||||
downloadEntity.name,
|
||||
downloadEntity.categoryChinese
|
||||
)
|
||||
|
||||
// 记录应用重启前需要重解压的信息
|
||||
SPUtils.setString(Constants.SP_XAPK_UNZIP_ACTIVITY, context.javaClass.name)
|
||||
SPUtils.setString(Constants.SP_XAPK_URL, downloadEntity.url)
|
||||
@ -88,10 +100,10 @@ object XapkDialogHelper {
|
||||
}
|
||||
},
|
||||
cancelClickCallback = {
|
||||
val hint = "《" + downloadEntity.name + "》游戏安装包解压失败,问题反馈:"
|
||||
val hint = "游戏安装包解压失败,问题反馈:"
|
||||
HelpAndFeedbackBridge.startSuggestionActivity(
|
||||
context,
|
||||
SuggestType.normal,
|
||||
SuggestType.GAME,
|
||||
null,
|
||||
hint,
|
||||
SimpleGameEntity(downloadEntity.gameId, downloadEntity.name, downloadEntity.icon)
|
||||
@ -102,23 +114,47 @@ object XapkDialogHelper {
|
||||
downloadEntity.gameId,
|
||||
downloadEntity.name
|
||||
)
|
||||
|
||||
SensorsBridge.trackGameDecompressionFailedDialogClick(
|
||||
buttonName = "提交反馈",
|
||||
downloadEntity.gameId,
|
||||
downloadEntity.name,
|
||||
downloadEntity.categoryChinese
|
||||
)
|
||||
},
|
||||
uiModificationCallback = { binding, dialog ->
|
||||
uiModificationCallback = { binding ->
|
||||
binding.headIv.setBackgroundResource(R.drawable.dialog_unzip_failure_head_background)
|
||||
binding.titleTv.visibility = View.GONE
|
||||
// VectorDrawable 的动态颜色设置只在支持 Vector 的系统版本上生效,为了能方便复用资源不支持的就用默认颜色,又不是不能用!
|
||||
binding.closeIv.setColorFilter(Color.WHITE)
|
||||
binding.contentTv.setLineSpacing(5.0F.dip2px().toFloat(), 1.0F)
|
||||
binding.closeContainer.setOnClickListener {
|
||||
binding.markDismissByTouchInside()
|
||||
|
||||
NewFlatLogUtils.logXApkUnzipFailedDialogClick(
|
||||
"关闭",
|
||||
false,
|
||||
downloadEntity.gameId,
|
||||
downloadEntity.name
|
||||
)
|
||||
dialog.dismiss()
|
||||
|
||||
SensorsBridge.trackGameDecompressionFailedDialogClick(
|
||||
buttonName = "关闭",
|
||||
downloadEntity.gameId,
|
||||
downloadEntity.name,
|
||||
downloadEntity.categoryChinese
|
||||
)
|
||||
binding.dismiss()
|
||||
}
|
||||
},
|
||||
touchOutsideCallback = {
|
||||
SensorsBridge.trackGameDecompressionFailedDialogClick(
|
||||
buttonName = "关闭弹窗",
|
||||
downloadEntity.gameId,
|
||||
downloadEntity.name,
|
||||
downloadEntity.categoryChinese
|
||||
)
|
||||
},
|
||||
extraConfig = DialogHelper.Config(showCloseIcon = true)
|
||||
)
|
||||
|
||||
|
||||
@ -79,6 +79,7 @@ object XapkInstaller : XApkUnZipCallback, XApkUnZipOutputFactory {
|
||||
if (MiuiUtils.isMiui() && !MiuiUtils.isMiuiOptimizationDisabled() && downloadEntity.format == Constants.XAPK_APKS_FORMAT) {// 小米手机开启miui以后,需要引导用户关闭miui优化
|
||||
DialogHelper.showMiuiOptimizationWarning(
|
||||
context,
|
||||
downloadEntity,
|
||||
onHintClick = {
|
||||
val guides = Config.getNewApiSettingsEntity()?.install
|
||||
val miuiOptimizationGuide = guides?.guides?.findLast {
|
||||
@ -99,6 +100,7 @@ object XapkInstaller : XApkUnZipCallback, XApkUnZipOutputFactory {
|
||||
Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
)
|
||||
it.markDismissByTouchInside()
|
||||
it.dismiss()
|
||||
} else {
|
||||
ToastUtils.showToast(context.getString(R.string.miui_open_adb_hint))
|
||||
@ -135,7 +137,7 @@ object XapkInstaller : XApkUnZipCallback, XApkUnZipOutputFactory {
|
||||
|
||||
override fun onProgress(apk: XApkFile, progress: Float) {
|
||||
val downloadEntity = mDownloadEntityMap[apk.file.path] ?: return
|
||||
downloadEntity.meta[XAPK_UNZIP_PERCENT] = String.format("%.2f", progress * 100)
|
||||
downloadEntity.meta[XAPK_UNZIP_PERCENT] = String.format(Locale.CHINA, "%.2f", progress * 100)
|
||||
downloadEntity.meta[XAPK_UNZIP_STATUS] = XapkUnzipStatus.UNZIPPING.name
|
||||
|
||||
AppExecutor.ioExecutor.execute {
|
||||
@ -184,6 +186,12 @@ object XapkInstaller : XApkUnZipCallback, XApkUnZipOutputFactory {
|
||||
}
|
||||
|
||||
DownloadDataHelper.uploadDownloadStatusEvent(downloadEntity, "xapk解压失败")
|
||||
|
||||
SensorsBridge.trackGameDecompressionFailed(
|
||||
downloadEntity.gameId,
|
||||
downloadEntity.name,
|
||||
downloadEntity.categoryChinese
|
||||
)
|
||||
}
|
||||
|
||||
debugOnly {
|
||||
|
||||
@ -123,6 +123,7 @@ object DownloadDataHelper {
|
||||
payloadObject.put("package", downloadEntity.packageName)
|
||||
payloadObject.put("certification", RealNameHelper.getCertificationStatus())
|
||||
payloadObject.put("filename", getFileName(downloadEntity))
|
||||
payloadObject.put("download_type", if (downloadEntity.asVGame()) "畅玩下载" else "本地下载")
|
||||
payloadObject.put("task_num", NDataChanger.downloadingTaskUrlSet.size)
|
||||
jsonObject.put("payload", payloadObject)
|
||||
} catch (e: Exception) {
|
||||
@ -250,6 +251,7 @@ object DownloadDataHelper {
|
||||
payloadObject.put("certification", RealNameHelper.getCertificationStatus())
|
||||
payloadObject.put("filename", getFileName(downloadEntity))
|
||||
payloadObject.put("total_size", sizeInMB)
|
||||
payloadObject.put("download_type", if (downloadEntity.asVGame()) "畅玩下载" else "本地下载")
|
||||
if (parallel != null) {
|
||||
payloadObject.put("parallel", parallel)
|
||||
}
|
||||
@ -353,6 +355,7 @@ object DownloadDataHelper {
|
||||
sheet.put("package", downloadEntity.packageName)
|
||||
sheet.put("certification", RealNameHelper.getCertificationStatus())
|
||||
sheet.put("filename", getFileName(downloadEntity))
|
||||
sheet.put("download_type", if (downloadEntity.asVGame()) "畅玩下载" else "本地下载")
|
||||
sheet.put("total_size", downloadEntity.size / 1024 / 1024)
|
||||
sheet.put("current_progress_size", downloadEntity.progress / 1024)
|
||||
mDownloadHeartbeatSheet[downloadEntity.url] = sheet
|
||||
@ -410,6 +413,7 @@ object DownloadDataHelper {
|
||||
metaObject.put("appVersion", meta.appVersion)
|
||||
metaObject.put("channel", meta.channel)
|
||||
metaObject.put("gid", meta.gid)
|
||||
metaObject.put("oaid", meta.oaid)
|
||||
metaObject.put("manufacturer", meta.manufacturer)
|
||||
metaObject.put("model", meta.model)
|
||||
metaObject.put("network", DeviceUtils.getNetwork(context))
|
||||
|
||||
@ -25,7 +25,6 @@ import com.gh.common.exposure.ExposureUtils;
|
||||
import com.gh.gamecenter.common.exposure.meta.MetaUtil;
|
||||
import com.gh.common.history.HistoryHelper;
|
||||
import com.gh.common.simulator.SimulatorGameManager;
|
||||
import com.gh.gamecenter.core.utils.AppDebugConfig;
|
||||
import com.gh.common.util.DataCollectionUtils;
|
||||
import com.gh.gamecenter.common.utils.DeviceUtils;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
@ -233,7 +232,7 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
*
|
||||
* @param context 上下文
|
||||
* @param gameEntity 游戏实体 (取 apk 里的第一个来进行下载)
|
||||
* @param method 下载类型
|
||||
* @param asVGame 是否以畅玩游戏的形式下载
|
||||
* @param entrance 来源 (细节见 https://git.ghzs.com/halo/android/assistant-android/-/wikis/entrance)
|
||||
* @param location 跟来源是类似的东西,我也不知道具体规则是怎么样的 :C
|
||||
* @param isSubscribe 是否是订阅下载(在WiFi环境下才下载)
|
||||
@ -241,30 +240,32 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
*/
|
||||
public static void createDownload(Context context,
|
||||
GameEntity gameEntity,
|
||||
String method,
|
||||
boolean asVGame,
|
||||
String entrance,
|
||||
String location,
|
||||
boolean isSubscribe,
|
||||
@Nullable ExposureEvent traceEvent) {
|
||||
createDownload(context, gameEntity.getApk().get(0), gameEntity, method, entrance, location, isSubscribe, traceEvent);
|
||||
createDownload(context, gameEntity.getApk().get(0), gameEntity, asVGame, gameEntity.isDualBtnModeEnabled(), entrance, location, isSubscribe, traceEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建下载任务
|
||||
*
|
||||
* @param context 上下文
|
||||
* @param gameEntity 游戏实体 (信息用于)
|
||||
* @param apkEntity 安装包实体,实际用于下载的信息文件
|
||||
* @param method 下载类型
|
||||
* @param entrance 来源 (细节见 https://git.ghzs.com/halo/android/assistant-android/-/wikis/entrance)
|
||||
* @param location 跟来源是类似的东西,我也不知道具体规则是怎么样的 :C
|
||||
* @param isSubscribe 是否是订阅下载(在WiFi环境下才下载)
|
||||
* @param traceEvent 曝光来源实体,用于记录一些简单的下载路径
|
||||
* @param context 上下文
|
||||
* @param gameEntity 游戏实体 (信息用于)
|
||||
* @param apkEntity 安装包实体,实际用于下载的信息文件
|
||||
* @param entrance 来源 (细节见 https://git.ghzs.com/halo/android/assistant-android/-/wikis/entrance)
|
||||
* @param location 跟来源是类似的东西,我也不知道具体规则是怎么样的 :C
|
||||
* @param isSubscribe 是否是订阅下载(在WiFi环境下才下载)
|
||||
* @param traceEvent 曝光来源实体,用于记录一些简单的下载路径
|
||||
* @param asVGame 作为畅玩游戏下载
|
||||
* @param isDualDownloadTypeEnabled 双下载按钮模式是否启用
|
||||
*/
|
||||
public static void createDownload(final Context context,
|
||||
ApkEntity apkEntity,
|
||||
GameEntity gameEntity,
|
||||
String method,
|
||||
boolean asVGame,
|
||||
boolean isDualDownloadTypeEnabled,
|
||||
String entrance,
|
||||
String location,
|
||||
boolean isSubscribe,
|
||||
@ -340,30 +341,20 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
ExtensionsKt.addMetaExtra(downloadEntity, Constants.SIMULATOR, GsonUtils.toJson(gameEntity.getSimulator()));
|
||||
}
|
||||
|
||||
if (gameEntity.isVGame()) {
|
||||
ExtensionsKt.addMetaExtra(downloadEntity, Constants.SMOOTH_GAME, "true");
|
||||
ExtensionsKt.addMetaExtra(downloadEntity, Constants.EXTRA_DOWNLOAD_TYPE, Constants.SMOOTH_GAME);
|
||||
if (asVGame) {
|
||||
ExtensionsKt.addMetaExtra(downloadEntity, Constants.EXTRA_DOWNLOAD_TYPE, Constants.VGAME);
|
||||
ExtensionsKt.addMetaExtra(downloadEntity, DownloadConfig.KEY_PROGRESS_CALLBACK_INTERVAL, "200");
|
||||
ExtensionsKt.addMetaExtra(downloadEntity, VHelper.KEY_REQUIRED_G_APPS, gameEntity.getGAppsSwitch());
|
||||
ExtensionsKt.addMetaExtra(downloadEntity, VHelper.KEY_BIT, apkEntity.getBit());
|
||||
}
|
||||
|
||||
SensorsBridge.trackEvent("HaloFunGameDownloadClick",
|
||||
"game_name", gameEntity.getName(),
|
||||
"game_id", gameEntity.getId(),
|
||||
"game_schema_type", gameEntity.getGameBitChinese());
|
||||
} else {
|
||||
SensorsBridge.trackEvent("DownloadProcessBegin",
|
||||
"game_id", gameEntity.getId(),
|
||||
"game_name", gameEntity.getName(),
|
||||
"game_type", gameEntity.getCategoryChinese(),
|
||||
"game_schema_type", gameEntity.getGameBitChinese(),
|
||||
"page_name", GlobalActivityManager.getCurrentPageEntity().getPageName(),
|
||||
"page_id", GlobalActivityManager.getCurrentPageEntity().getPageId(),
|
||||
"page_business_id", GlobalActivityManager.getCurrentPageEntity().getPageBusinessId(),
|
||||
"last_page_name", GlobalActivityManager.getLastPageEntity().getPageName(),
|
||||
"last_page_id", GlobalActivityManager.getLastPageEntity().getPageId(),
|
||||
"last_page_business_id", GlobalActivityManager.getLastPageEntity().getPageBusinessId()
|
||||
);
|
||||
// 记录是否为双下载按钮模式
|
||||
if (isDualDownloadTypeEnabled) {
|
||||
if (asVGame) {
|
||||
ExtensionsKt.setVGameDownloadModeInDualDownloadMode(downloadEntity);
|
||||
} else {
|
||||
ExtensionsKt.setLocalDownloadModeInDualDownloadMode(downloadEntity);
|
||||
}
|
||||
}
|
||||
|
||||
HashMap<String, String> map = PageSwitchDataHelper.popLastPageData();
|
||||
@ -389,7 +380,7 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
|
||||
downloadEntity.setPlugin(!TextUtils.isEmpty(apkEntity.getGhVersion()));
|
||||
|
||||
ExposureUtils.DownloadType downloadType = ExposureUtils.getDownloadType(apkEntity, gameEntity.getId(), gameEntity.isVGame());
|
||||
ExposureUtils.DownloadType downloadType = ExposureUtils.getDownloadType(apkEntity, gameEntity.getId(), asVGame);
|
||||
gameEntity.setIsPlatformRecommend(apkEntity.getRecommend() != null);
|
||||
ExposureEvent downloadExposureEvent = ExposureUtils.logADownloadExposureEvent(gameEntity, apkEntity.getPlatform(), traceEvent, downloadType);
|
||||
|
||||
@ -403,10 +394,36 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
DownloadManager.getInstance().add(downloadEntity);
|
||||
}
|
||||
|
||||
if (AppDebugConfig.IS_DEBUG) {
|
||||
AppDebugConfig.logMethodWithParams(DownloadManager.class, apkEntity.getUrl(), downloadEntity.getUrl(), method, entrance, location);
|
||||
if (asVGame) {
|
||||
SensorsBridge.trackEventWithExposureSource("HaloFunGameDownloadClick",
|
||||
downloadExposureEvent.getSource(),
|
||||
"game_name", gameEntity.getName(),
|
||||
"game_id", gameEntity.getId(),
|
||||
"game_schema_type", gameEntity.getGameBitChinese());
|
||||
}
|
||||
|
||||
String trackDownloadType = "";
|
||||
if (asVGame) {
|
||||
trackDownloadType = "畅玩下载";
|
||||
} else {
|
||||
trackDownloadType = "本地下载";
|
||||
}
|
||||
|
||||
SensorsBridge.trackEventWithExposureSource("DownloadProcessBegin",
|
||||
downloadExposureEvent.getSource(),
|
||||
"game_id", gameEntity.getId(),
|
||||
"game_name", gameEntity.getName(),
|
||||
"game_type", gameEntity.getCategoryChinese(),
|
||||
"game_schema_type", gameEntity.getGameBitChinese(),
|
||||
"page_name", GlobalActivityManager.getCurrentPageEntity().getPageName(),
|
||||
"page_id", GlobalActivityManager.getCurrentPageEntity().getPageId(),
|
||||
"page_business_id", GlobalActivityManager.getCurrentPageEntity().getPageBusinessId(),
|
||||
"last_page_name", GlobalActivityManager.getLastPageEntity().getPageName(),
|
||||
"last_page_id", GlobalActivityManager.getLastPageEntity().getPageId(),
|
||||
"last_page_business_id", GlobalActivityManager.getLastPageEntity().getPageBusinessId(),
|
||||
"download_type", trackDownloadType
|
||||
);
|
||||
|
||||
//TODO remove
|
||||
DownloadManager.getInstance().putStatus(downloadEntity.getUrl(), DownloadStatus.downloading);
|
||||
|
||||
@ -431,7 +448,6 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
SentryHelper.INSTANCE.onEvent("CLEAR_DELETED_TASK_ERROR", "exception_digest", e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加一个下载任务
|
||||
* <p>
|
||||
@ -439,13 +455,25 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
*/
|
||||
@Deprecated
|
||||
public void add(DownloadEntity downloadEntity) {
|
||||
add(downloadEntity, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加一个下载任务
|
||||
* <p>
|
||||
* 请优先使用 createDownload()
|
||||
*
|
||||
* @param ignoreDownloaded 忽略已经下载的内容
|
||||
*/
|
||||
@Deprecated
|
||||
public void add(DownloadEntity downloadEntity, boolean ignoreDownloaded) {
|
||||
updateDownloadMetaMap();
|
||||
|
||||
if (downloadEntity != null) {
|
||||
String url = downloadEntity.getUrl();
|
||||
checkDownloadEntryRecordValidate(url);
|
||||
|
||||
if (isDownloadCompleted(url)) {
|
||||
if (isDownloadCompleted(url) && !ignoreDownloaded) {
|
||||
downloadEntity.setStatus(DownloadStatus.done);
|
||||
NDataChanger.INSTANCE.notifyDataChanged(downloadEntity);
|
||||
} else if (!isTaskDownloading(url)) {
|
||||
@ -604,24 +632,23 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
@Nullable
|
||||
public DownloadEntity getDownloadEntitySnapshot(GameEntity gameEntity) {
|
||||
if (gameEntity == null || gameEntity.getApk().size() == 0) return null;
|
||||
return getDownloadEntitySnapshot(gameEntity.getApk().get(0).getUrl(), gameEntity.getId(), gameEntity.isVGame());
|
||||
return getDownloadEntitySnapshot(gameEntity.getApk().get(0).getUrl(), gameEntity.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取快照
|
||||
* <p>
|
||||
* 畅玩游戏优先根据游戏 ID 获取,非畅玩游戏根据 url 获取
|
||||
* 优先根据游戏 ID 获取,次选根据 url 获取
|
||||
*
|
||||
* @param url 下载链接
|
||||
* @param isVGame 是不是畅玩游戏
|
||||
* @param gameId 游戏 ID
|
||||
* @param url 下载链接
|
||||
* @param gameId 游戏 ID
|
||||
* @return null表示下载列表中不存在该任务,否则返回下载任务
|
||||
*/
|
||||
@Nullable
|
||||
public DownloadEntity getDownloadEntitySnapshot(String url, String gameId, boolean isVGame) {
|
||||
public DownloadEntity getDownloadEntitySnapshot(String url, String gameId) {
|
||||
DownloadEntity snapshot = null;
|
||||
|
||||
if (isVGame && !TextUtils.isEmpty(gameId)) {
|
||||
if (!TextUtils.isEmpty(gameId)) {
|
||||
snapshot = mDownloadDao.getSnapshotByGameId(gameId);
|
||||
}
|
||||
|
||||
@ -749,7 +776,8 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
ArrayList<DownloadEntity> filteredDownloadEntityList = new ArrayList<>();
|
||||
|
||||
for (DownloadEntity downloadEntity : downloadList) {
|
||||
if (Constants.SMOOTH_GAME.equals(ExtensionsKt.getMetaExtra(downloadEntity, Constants.EXTRA_DOWNLOAD_TYPE))) {
|
||||
if (Constants.VGAME.equals(ExtensionsKt.getMetaExtra(downloadEntity, Constants.EXTRA_DOWNLOAD_TYPE))
|
||||
|| Constants.DUAL_DOWNLOAD_VGAME.equals(ExtensionsKt.getMetaExtra(downloadEntity, Constants.EXTRA_DOWNLOAD_TYPE))) {
|
||||
filteredDownloadEntityList.add(downloadEntity);
|
||||
}
|
||||
}
|
||||
@ -764,9 +792,11 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
|
||||
for (DownloadEntity downloadEntity : downloadEntityList) {
|
||||
if (!ExtensionsKt.isSimulatorGame(downloadEntity)) {
|
||||
if (!Constants.SILENT_UPDATE.equals(ExtensionsKt.getMetaExtra(downloadEntity, Constants.EXTRA_DOWNLOAD_TYPE))
|
||||
&& !Constants.SIMULATOR_DOWNLOAD.equals(ExtensionsKt.getMetaExtra(downloadEntity, Constants.EXTRA_DOWNLOAD_TYPE))
|
||||
&& !Constants.SMOOTH_GAME.equals(ExtensionsKt.getMetaExtra(downloadEntity, Constants.EXTRA_DOWNLOAD_TYPE))
|
||||
String extraDownloadType = ExtensionsKt.getMetaExtra(downloadEntity, Constants.EXTRA_DOWNLOAD_TYPE);
|
||||
if (!Constants.SILENT_UPDATE.equals(extraDownloadType)
|
||||
&& !Constants.SIMULATOR_DOWNLOAD.equals(extraDownloadType)
|
||||
&& !Constants.VGAME.equals(extraDownloadType)
|
||||
&& !Constants.DUAL_DOWNLOAD_VGAME.equals(extraDownloadType)
|
||||
) {
|
||||
filteredDownloadEntityList.add(downloadEntity);
|
||||
}
|
||||
@ -854,6 +884,8 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
|
||||
initGameMap();
|
||||
|
||||
entry.setUpdate(false);
|
||||
|
||||
if (cancelSilently) {
|
||||
entry.setStatus(DownloadStatus.cancel);
|
||||
cancelAndNotify(entry, true);
|
||||
@ -920,7 +952,7 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
for (DownloadEntity downloadEntity : getAllDownloadEntity()) {
|
||||
if (!urlSet.contains(downloadEntity.getUrl())
|
||||
&& (downloadEntity.getStatus().equals(DownloadStatus.downloading)
|
||||
|| downloadEntity.getStatus().equals(DownloadStatus.waiting))) {
|
||||
|| downloadEntity.getStatus().equals(DownloadStatus.waiting))) {
|
||||
downloadEntity.setStatus(DownloadStatus.subscribe);
|
||||
mDownloadDao.newOrUpdate(downloadEntity);
|
||||
NDataChanger.INSTANCE.notifyDataChanged(downloadEntity);
|
||||
@ -1286,7 +1318,7 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
public void resumeAllInvisiblePendingTask() {
|
||||
for (DownloadEntity task : mInvisiblePendingTaskList) {
|
||||
if ("false".equals(task.getMeta().get("force_real_name"))) {
|
||||
add(task);
|
||||
add(task, false);
|
||||
}
|
||||
}
|
||||
mInvisiblePendingTaskList.clear();
|
||||
@ -1325,6 +1357,8 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
map.put(HttpDnsManager.TOKEN, UserManager.getInstance().getToken());
|
||||
map.put(HttpDnsManager.IS_OVERWRITE, isOverwrite);
|
||||
map.put(HttpDnsManager.INSTALL_TYPE, installType);
|
||||
map.put(HttpDnsManager.ANDROID_ID, MetaUtil.getBase64EncodedAndroidId());
|
||||
map.put(HttpDnsManager.ANDROID_SDK_VERSION, String.valueOf(Build.VERSION.SDK_INT));
|
||||
|
||||
HttpDnsManager.metaMap = map;
|
||||
}
|
||||
|
||||
@ -2,17 +2,16 @@ package com.gh.download
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.text.TextUtils
|
||||
import com.gh.common.util.*
|
||||
import com.gh.gamecenter.feature.utils.ConcernUtils
|
||||
import com.gh.common.util.DataCollectionUtils
|
||||
import com.gh.common.util.PackageInstaller
|
||||
import com.gh.common.util.PackageUtils
|
||||
import com.gh.common.xapk.XapkInstaller
|
||||
import com.gh.download.server.BrowserInstallHelper
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.loghub.LoghubUtils
|
||||
import com.gh.gamecenter.common.retrofit.EmptyResponse
|
||||
import com.gh.gamecenter.common.retrofit.Response
|
||||
import com.gh.gamecenter.common.utils.isVGame
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.common.utils.NewFlatLogUtils
|
||||
import com.gh.gamecenter.core.runOnIoThread
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.core.utils.ThirdPartyPackageHelper
|
||||
@ -20,12 +19,13 @@ import com.gh.gamecenter.core.utils.UrlFilterUtils
|
||||
import com.gh.gamecenter.entity.GameDigestEntity
|
||||
import com.gh.gamecenter.eventbus.EBPackage
|
||||
import com.gh.gamecenter.login.user.UserManager
|
||||
import com.gh.gamecenter.manager.PackagesManager
|
||||
import com.gh.gamecenter.packagehelper.PackageRepository
|
||||
import com.gh.gamecenter.packagehelper.PackageViewModel
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.gh.vspace.VHelper
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import com.lightgame.download.FileUtils
|
||||
import com.lightgame.utils.Utils
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
@ -106,16 +106,24 @@ object PackageObserver {
|
||||
if (gh_id == null) {
|
||||
ThirdPartyPackageHelper.saveGameId(mDownloadEntity.packageName, mDownloadEntity.gameId)
|
||||
}
|
||||
if (mDownloadEntity.isVGame()) {
|
||||
// 畅玩游戏安装完成的同时直接删除文件
|
||||
runOnIoThread { FileUtils.deleteFile(mDownloadEntity.path) }
|
||||
}
|
||||
|
||||
if (mDownloadEntity.format == Constants.XAPK_FORMAT) {
|
||||
XapkInstaller.onInstalled(mDownloadEntity.path)
|
||||
}
|
||||
|
||||
DownloadManager.getInstance().cancel(mDownloadEntity.url, false, true, false)
|
||||
// 双下载模式
|
||||
if (mDownloadEntity.isVGameDownloadInDualDownloadMode() || mDownloadEntity.isLocalDownloadInDualDownloadMode()) {
|
||||
// 当双下载都完成或者是更新下载的时候清理任务
|
||||
// 畅玩下载不需要实名,如果用户没有本地实名信息,安装完成后也清理任务,避免可以免实名安装到本地
|
||||
if (mDownloadEntity.isUpdate
|
||||
|| (PackagesManager.isInstalled(packageName) && VHelper.isInstalled(packageName))
|
||||
|| (busFour.isVGame && RealNameHelper.getCertificationStatus() != 2)
|
||||
) {
|
||||
DownloadManager.getInstance().cancel(mDownloadEntity.url, true, true, false)
|
||||
}
|
||||
} else {
|
||||
DownloadManager.getInstance().cancel(mDownloadEntity.url, true, true, false)
|
||||
}
|
||||
|
||||
if (SPUtils.getBoolean(Constants.SP_CONCERN_GAME, true)) { //设置页面控制是否安装后自动关注
|
||||
// 安装后关注游戏
|
||||
@ -146,12 +154,23 @@ object PackageObserver {
|
||||
}
|
||||
|
||||
if (EBPackage.TYPE_UNINSTALLED == busFour.type) {
|
||||
mPackageViewModel.addUninstalledGame(packageName)
|
||||
mPackageViewModel.addUninstalledGame(packageName, busFour.isVGame)
|
||||
|
||||
mDownloadEntity?.let {
|
||||
if (it.isVGame()) return@let
|
||||
if (it.asVGame()) return@let
|
||||
|
||||
if (it.isPluggable
|
||||
|| (it.isUpdate && !PackageUtils.isInstalled(application, it.packageName))) {
|
||||
NewFlatLogUtils.logGameInstall(
|
||||
gameId = mDownloadEntity.gameId,
|
||||
gameName = mDownloadEntity.name,
|
||||
trigger = "自动安装"
|
||||
)
|
||||
SensorsBridge.trackInstallGameClick(
|
||||
gameId = mDownloadEntity.gameId,
|
||||
gameName = mDownloadEntity.name,
|
||||
action = "自动安装"
|
||||
)
|
||||
PackageInstaller.install(application, mDownloadEntity)
|
||||
}
|
||||
}
|
||||
@ -180,6 +199,7 @@ object PackageObserver {
|
||||
try {
|
||||
dataObject.put("type", "POST")
|
||||
dataObject.put("device_id", HaloApp.getInstance().gid)
|
||||
dataObject.put("oaid", HaloApp.getInstance().oaid)
|
||||
dataObject.put("app", packageObject)
|
||||
dataObject.put("time", Utils.getTime(HaloApp.getInstance().application))
|
||||
wrapperObject.put("content", dataObject.toString())
|
||||
@ -217,6 +237,7 @@ object PackageObserver {
|
||||
try {
|
||||
dataObject.put("type", "DELETE")
|
||||
dataObject.put("device_id", HaloApp.getInstance().gid)
|
||||
dataObject.put("oaid", HaloApp.getInstance().oaid)
|
||||
dataObject.put("package", packageName)
|
||||
dataObject.put("time", Utils.getTime(HaloApp.getInstance().application))
|
||||
wrapperObject.put("content", dataObject.toString())
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user