Compare commits
5 Commits
release
...
pack/test-
| Author | SHA1 | Date | |
|---|---|---|---|
| 1023e0492b | |||
| 0fda3ecfcd | |||
| 166abd5c9b | |||
| af3102f6be | |||
| 93363f23b4 |
4
.gitignore
vendored
4
.gitignore
vendored
@ -9,6 +9,4 @@ build/
|
|||||||
release-app/
|
release-app/
|
||||||
test-app/
|
test-app/
|
||||||
scripts/apk-channel/
|
scripts/apk-channel/
|
||||||
app/src/test/java/com/gh/gamecenter
|
app/src/test/java/com/gh/gamecenter
|
||||||
app/src/main/assets-debug/
|
|
||||||
app/src/main/assets-release/
|
|
||||||
@ -71,14 +71,14 @@ android_build:
|
|||||||
exit_codes: 137
|
exit_codes: 137
|
||||||
only:
|
only:
|
||||||
- dev
|
- dev
|
||||||
- release
|
- feat/GHZSCY-5250
|
||||||
|
|
||||||
# 代码检查
|
# 代码检查
|
||||||
sonarqube_analysis:
|
sonarqube_analysis:
|
||||||
tags:
|
tags:
|
||||||
- offline-test
|
- offline-test
|
||||||
stage: build&analyze
|
stage: build&analyze
|
||||||
image: hub.shanqu.cc/library/sonar-scanner-cli:latest
|
image: sonarsource/sonar-scanner-cli:latest
|
||||||
dependencies: [] #禁止传递来的artifact
|
dependencies: [] #禁止传递来的artifact
|
||||||
script:
|
script:
|
||||||
## 获取项目的一级组和二级组和项目名作为projectKey,例如projectKey=platform-backend-eci-monitor
|
## 获取项目的一级组和二级组和项目名作为projectKey,例如projectKey=platform-backend-eci-monitor
|
||||||
@ -127,9 +127,6 @@ oss-upload&send-email:
|
|||||||
- sysadm-devops
|
- sysadm-devops
|
||||||
stage: oss-upload&send-email
|
stage: oss-upload&send-email
|
||||||
image: hub.shanqu.cc/devops/android-apk-oss-upload:latest
|
image: hub.shanqu.cc/devops/android-apk-oss-upload:latest
|
||||||
id_tokens:
|
|
||||||
VAULT_ID_TOKEN:
|
|
||||||
aud: https://vault.shanqu.cc
|
|
||||||
variables:
|
variables:
|
||||||
GIT_STRATEGY: none
|
GIT_STRATEGY: none
|
||||||
VAULT_ADDR: https://vault.shanqu.cc # 固定值
|
VAULT_ADDR: https://vault.shanqu.cc # 固定值
|
||||||
@ -148,7 +145,6 @@ oss-upload&send-email:
|
|||||||
artifacts: true
|
artifacts: true
|
||||||
script:
|
script:
|
||||||
### 绑定上传参数 ###
|
### 绑定上传参数 ###
|
||||||
|
|
||||||
- export OSS_PATH="release/dev/${CI_PROJECT_NAME}/$(date "+%Y/%m/%d")"
|
- export OSS_PATH="release/dev/${CI_PROJECT_NAME}/$(date "+%Y/%m/%d")"
|
||||||
### 开启上传 ###
|
### 开启上传 ###
|
||||||
- /usr/local/bin/python /upload.py
|
- /usr/local/bin/python /upload.py
|
||||||
@ -156,5 +152,4 @@ oss-upload&send-email:
|
|||||||
- /usr/local/bin/python /ci-android-mail-jira-comment.py
|
- /usr/local/bin/python /ci-android-mail-jira-comment.py
|
||||||
only:
|
only:
|
||||||
- dev
|
- dev
|
||||||
- release
|
- feat/GHZSCY-5250
|
||||||
|
|
||||||
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -8,6 +8,3 @@
|
|||||||
[submodule "ndownload"]
|
[submodule "ndownload"]
|
||||||
path = ndownload
|
path = ndownload
|
||||||
url = ../../../android/ndownload.git
|
url = ../../../android/ndownload.git
|
||||||
[submodule "vasdk"]
|
|
||||||
path = vasdk
|
|
||||||
url = ../../../sdg/android/vasdk.git
|
|
||||||
|
|||||||
@ -44,4 +44,5 @@
|
|||||||
|
|
||||||
### 混淆配置
|
### 混淆配置
|
||||||
|
|
||||||
|
* 本项目使用了微信的 [AndResGuard](https://github.com/shwenzhang/AndResGuard) 作为资源混淆压缩方案,新增需要使用 `getIdentifier` 获取的资源文件时需要添加至白名单
|
||||||
* 本项目默认使用 R8 作为混淆工具,往 proguard-rules.txt 添加 proguard 新配置项时请检查可用性(如语法等)
|
* 本项目默认使用 R8 作为混淆工具,往 proguard-rules.txt 添加 proguard 新配置项时请检查可用性(如语法等)
|
||||||
|
|||||||
317
app/build.gradle
317
app/build.gradle
@ -2,9 +2,8 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
apply plugin: 'kotlin-android' // kotlin
|
apply plugin: 'kotlin-android' // kotlin
|
||||||
apply plugin: 'kotlin-parcelize'
|
apply plugin: 'kotlin-parcelize'
|
||||||
apply plugin: 'com.google.devtools.ksp'
|
|
||||||
apply plugin: 'kotlin-kapt'
|
apply plugin: 'kotlin-kapt'
|
||||||
apply plugin: 'therouter'
|
apply plugin: 'AndResGuard'
|
||||||
|
|
||||||
import groovy.xml.XmlUtil
|
import groovy.xml.XmlUtil
|
||||||
|
|
||||||
@ -53,10 +52,6 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ksp {
|
|
||||||
arg("ROUTER_MODULE_NAME", project.getName())
|
|
||||||
}
|
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
vectorDrawables.useSupportLibrary = true
|
vectorDrawables.useSupportLibrary = true
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
@ -80,7 +75,7 @@ android {
|
|||||||
versionName rootProject.ext.versionName
|
versionName rootProject.ext.versionName
|
||||||
applicationId rootProject.ext.applicationId
|
applicationId rootProject.ext.applicationId
|
||||||
|
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt', 'proguard-fresco.txt', rootProject.ext.va_proguard_rules
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt', 'proguard-fresco.txt'
|
||||||
|
|
||||||
String CORE_EVENT_GAME_CATEGORY = ""
|
String CORE_EVENT_GAME_CATEGORY = ""
|
||||||
|
|
||||||
@ -107,15 +102,10 @@ android {
|
|||||||
buildConfigField "String", "NEW_API_HOST", "\"${NEW_API_HOST}\""
|
buildConfigField "String", "NEW_API_HOST", "\"${NEW_API_HOST}\""
|
||||||
buildConfigField "String", "LOG_HUB_PROJECT", "\"${LOG_HUB_PROJECT}\""
|
buildConfigField "String", "LOG_HUB_PROJECT", "\"${LOG_HUB_PROJECT}\""
|
||||||
buildConfigField "String", "VAPI_HOST", "\"${VAPI_HOST}\""
|
buildConfigField "String", "VAPI_HOST", "\"${VAPI_HOST}\""
|
||||||
buildConfigField "String", "WGAME_CPM_BUSIAPPID", "\"${WGAME_CPM_BUSIAPPID}\""
|
|
||||||
buildConfigField "String", "WGAME_CPM_API_HOST", "\"${WGAME_CPM_API_HOST}\""
|
|
||||||
buildConfigField "String", "WECHAT_APPID", "\"${WECHAT_APPID}\""
|
buildConfigField "String", "WECHAT_APPID", "\"${WECHAT_APPID}\""
|
||||||
buildConfigField "String", "WECHAT_SECRET", "\"${WECHAT_SECRET}\""
|
buildConfigField "String", "WECHAT_SECRET", "\"${WECHAT_SECRET}\""
|
||||||
buildConfigField "String", "TENCENT_APPID", "\"${TENCENT_APPID}\""
|
buildConfigField "String", "TENCENT_APPID", "\"${TENCENT_APPID}\""
|
||||||
buildConfigField "String", "WEIBO_APPKEY", "\"${WEIBO_APPKEY}\""
|
buildConfigField "String", "WEIBO_APPKEY", "\"${WEIBO_APPKEY}\""
|
||||||
buildConfigField "String", "DSP_API_HOST","\"${DSP_API_HOST}\""
|
|
||||||
// 一体包的32位畅玩游戏助手包名
|
|
||||||
buildConfigField "String", "EXT_PACKAGE_NAME", "\"${rootProject.ext.EXT_PACKAGE_NAME}\""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// gradle 2.2以上默认同时启用v1和v2(优先用于Android N)
|
// gradle 2.2以上默认同时启用v1和v2(优先用于Android N)
|
||||||
@ -130,21 +120,10 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
packagingOptions {
|
kapt {
|
||||||
// exclude 部分冗余的文件
|
arguments {
|
||||||
exclude 'META-INF/gradle/incremental.annotation.processors'
|
arg("AROUTER_MODULE_NAME", project.name)
|
||||||
exclude 'darwin/x86_64/liblz4-java.dylib'
|
}
|
||||||
|
|
||||||
exclude 'assets/libwbsafeedit_x86'
|
|
||||||
exclude 'assets/libwbsafeedit_x86_64'
|
|
||||||
|
|
||||||
exclude 'lib/armeabi-v7a/libRSSupport.so'
|
|
||||||
exclude 'lib/arm64-v8a/libRSSupport.so'
|
|
||||||
exclude 'lib/armeabi-v7a/librsjni.so'
|
|
||||||
exclude 'lib/arm64-v8a/librsjni.so'
|
|
||||||
|
|
||||||
resources.excludes += "com/j256/*"
|
|
||||||
resources.excludes += "org/apache/commons/codec/language/bm/*"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
@ -154,7 +133,7 @@ android {
|
|||||||
zipAlignEnabled false
|
zipAlignEnabled false
|
||||||
signingConfig signingConfigs.debug
|
signingConfig signingConfigs.debug
|
||||||
|
|
||||||
buildConfigField "String", "EXPOSURE_REPO", "\"exposure\""
|
buildConfigField "String", "EXPOSURE_REPO", "\"test\""
|
||||||
buildConfigField "String", "EXPOSURE_VERSION", "\"E4\""
|
buildConfigField "String", "EXPOSURE_VERSION", "\"E4\""
|
||||||
|
|
||||||
multiDexKeepProguard file("tinker_multidexkeep.pro")
|
multiDexKeepProguard file("tinker_multidexkeep.pro")
|
||||||
@ -185,20 +164,11 @@ android {
|
|||||||
flavorDimensions("env", "region")
|
flavorDimensions("env", "region")
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
|
|
||||||
debug {
|
|
||||||
assets.srcDirs += 'src/main/assets-debug'
|
|
||||||
}
|
|
||||||
|
|
||||||
release {
|
|
||||||
assets.srcDirs += 'src/main/assets-release'
|
|
||||||
}
|
|
||||||
|
|
||||||
publish {
|
publish {
|
||||||
java.srcDirs = ['src/main/java', "src/default/java"]
|
java.srcDirs = ['src/main/java', "src/default/java"]
|
||||||
}
|
}
|
||||||
internal {
|
internal {
|
||||||
java.srcDirs = ['src/main/java', "src/default/java", "src/internal/java"]
|
java.srcDirs = ['src/main/java', "src/default/java"]
|
||||||
}
|
}
|
||||||
tea {
|
tea {
|
||||||
java.srcDirs = ['src/main/java', 'src/tea/java']
|
java.srcDirs = ['src/main/java', 'src/tea/java']
|
||||||
@ -233,9 +203,6 @@ android {
|
|||||||
buildConfigField "String", "QUICK_LOGIN_APPKEY", "\"${DEV_QUICK_LOGIN_APPKEY}\""
|
buildConfigField "String", "QUICK_LOGIN_APPKEY", "\"${DEV_QUICK_LOGIN_APPKEY}\""
|
||||||
buildConfigField "String", "DEV_CSJ_APPID", "\"${DEV_CSJ_APPID}\""
|
buildConfigField "String", "DEV_CSJ_APPID", "\"${DEV_CSJ_APPID}\""
|
||||||
buildConfigField "String", "CSJ_APPID", "\"${CSJ_APPID}\""
|
buildConfigField "String", "CSJ_APPID", "\"${CSJ_APPID}\""
|
||||||
|
|
||||||
buildConfigField "String", "VA_VERSION_NAME", "\"${rootProject.ext.VA_VERSION}-debug\""
|
|
||||||
manifestPlaceholders.put("VA_VERSION_NAME", "${rootProject.ext.VA_VERSION}-debug")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// publish, 发布时候使用的 flavor,接口仅包含正式环境
|
// publish, 发布时候使用的 flavor,接口仅包含正式环境
|
||||||
@ -249,9 +216,6 @@ android {
|
|||||||
buildConfigField "String", "QUICK_LOGIN_APPKEY", "\"${QUICK_LOGIN_APPKEY}\""
|
buildConfigField "String", "QUICK_LOGIN_APPKEY", "\"${QUICK_LOGIN_APPKEY}\""
|
||||||
buildConfigField "String", "DEV_CSJ_APPID", "\"${CSJ_APPID}\""
|
buildConfigField "String", "DEV_CSJ_APPID", "\"${CSJ_APPID}\""
|
||||||
buildConfigField "String", "CSJ_APPID", "\"${CSJ_APPID}\""
|
buildConfigField "String", "CSJ_APPID", "\"${CSJ_APPID}\""
|
||||||
|
|
||||||
buildConfigField "String", "VA_VERSION_NAME", "\"${rootProject.ext.VA_VERSION}\""
|
|
||||||
manifestPlaceholders.put("VA_VERSION_NAME", "${rootProject.ext.VA_VERSION}")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tea {
|
tea {
|
||||||
@ -265,10 +229,7 @@ android {
|
|||||||
buildConfigField "String", "DEV_CSJ_APPID", "\"${CSJ_APPID}\""
|
buildConfigField "String", "DEV_CSJ_APPID", "\"${CSJ_APPID}\""
|
||||||
buildConfigField "String", "CSJ_APPID", "\"${CSJ_APPID}\""
|
buildConfigField "String", "CSJ_APPID", "\"${CSJ_APPID}\""
|
||||||
|
|
||||||
buildConfigField "String", "VA_VERSION_NAME", "\"${rootProject.ext.VA_VERSION}\""
|
|
||||||
|
|
||||||
manifestPlaceholders.put("APPLOG_SCHEME", "rangersapplog.byAx6uYt".toLowerCase())
|
manifestPlaceholders.put("APPLOG_SCHEME", "rangersapplog.byAx6uYt".toLowerCase())
|
||||||
manifestPlaceholders.put("VA_VERSION_NAME", "${rootProject.ext.VA_VERSION}")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
kuaishou {
|
kuaishou {
|
||||||
@ -281,9 +242,6 @@ android {
|
|||||||
buildConfigField "String", "QUICK_LOGIN_APPKEY", "\"${QUICK_LOGIN_APPKEY}\""
|
buildConfigField "String", "QUICK_LOGIN_APPKEY", "\"${QUICK_LOGIN_APPKEY}\""
|
||||||
buildConfigField "String", "DEV_CSJ_APPID", "\"${CSJ_APPID}\""
|
buildConfigField "String", "DEV_CSJ_APPID", "\"${CSJ_APPID}\""
|
||||||
buildConfigField "String", "CSJ_APPID", "\"${CSJ_APPID}\""
|
buildConfigField "String", "CSJ_APPID", "\"${CSJ_APPID}\""
|
||||||
|
|
||||||
buildConfigField "String", "VA_VERSION_NAME", "\"${rootProject.ext.VA_VERSION}\""
|
|
||||||
manifestPlaceholders.put("VA_VERSION_NAME", "${rootProject.ext.VA_VERSION}")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gdt {
|
gdt {
|
||||||
@ -296,9 +254,6 @@ android {
|
|||||||
buildConfigField "String", "QUICK_LOGIN_APPKEY", "\"${QUICK_LOGIN_APPKEY}\""
|
buildConfigField "String", "QUICK_LOGIN_APPKEY", "\"${QUICK_LOGIN_APPKEY}\""
|
||||||
buildConfigField "String", "DEV_CSJ_APPID", "\"${CSJ_APPID}\""
|
buildConfigField "String", "DEV_CSJ_APPID", "\"${CSJ_APPID}\""
|
||||||
buildConfigField "String", "CSJ_APPID", "\"${CSJ_APPID}\""
|
buildConfigField "String", "CSJ_APPID", "\"${CSJ_APPID}\""
|
||||||
|
|
||||||
buildConfigField "String", "VA_VERSION_NAME", "\"${rootProject.ext.VA_VERSION}\""
|
|
||||||
manifestPlaceholders.put("VA_VERSION_NAME", "${rootProject.ext.VA_VERSION}")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sm {
|
sm {
|
||||||
@ -311,9 +266,6 @@ android {
|
|||||||
buildConfigField "String", "QUICK_LOGIN_APPKEY", "\"${QUICK_LOGIN_APPKEY}\""
|
buildConfigField "String", "QUICK_LOGIN_APPKEY", "\"${QUICK_LOGIN_APPKEY}\""
|
||||||
buildConfigField "String", "DEV_CSJ_APPID", "\"${CSJ_APPID}\""
|
buildConfigField "String", "DEV_CSJ_APPID", "\"${CSJ_APPID}\""
|
||||||
buildConfigField "String", "CSJ_APPID", "\"${CSJ_APPID}\""
|
buildConfigField "String", "CSJ_APPID", "\"${CSJ_APPID}\""
|
||||||
|
|
||||||
buildConfigField "String", "VA_VERSION_NAME", "\"${rootProject.ext.VA_VERSION}\""
|
|
||||||
manifestPlaceholders.put("VA_VERSION_NAME", "${rootProject.ext.VA_VERSION}")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 港澳台
|
// 港澳台
|
||||||
@ -343,21 +295,6 @@ repositories {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除不需要的 assets
|
|
||||||
android.applicationVariants.configureEach { variant ->
|
|
||||||
variant.mergeAssets.doLast {
|
|
||||||
def assetDir = variant.mergeAssetsProvider.get().outputDir.get()
|
|
||||||
def unwantedAssets = ['1832823466', 'gdt_plugin/gdtadv2.jar']
|
|
||||||
|
|
||||||
unwantedAssets.each { assetPath ->
|
|
||||||
def file = new File([assetDir, assetPath].join(File.separator))
|
|
||||||
if (file.exists()) {
|
|
||||||
file.delete()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
||||||
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
|
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
|
||||||
@ -366,6 +303,7 @@ dependencies {
|
|||||||
kuaishouImplementation fileTree(include: ['*.jar', '*.aar'], dir: 'src/kuaishou/libs')
|
kuaishouImplementation fileTree(include: ['*.jar', '*.aar'], dir: 'src/kuaishou/libs')
|
||||||
gdtImplementation fileTree(include: ['*.jar', '*.aar'], dir: 'src/gdt/libs')
|
gdtImplementation fileTree(include: ['*.jar', '*.aar'], dir: 'src/gdt/libs')
|
||||||
smImplementation fileTree(include: ['*.jar', '*.aar'], dir: 'src/sm/libs')
|
smImplementation fileTree(include: ['*.jar', '*.aar'], dir: 'src/sm/libs')
|
||||||
|
testImplementation 'junit:junit:4.12'
|
||||||
|
|
||||||
debugImplementation "com.squareup.leakcanary:leakcanary-android:${leakcanary}"
|
debugImplementation "com.squareup.leakcanary:leakcanary-android:${leakcanary}"
|
||||||
debugImplementation "com.squareup.leakcanary:leakcanary-android-process:${leakcanary}"
|
debugImplementation "com.squareup.leakcanary:leakcanary-android-process:${leakcanary}"
|
||||||
@ -379,7 +317,9 @@ dependencies {
|
|||||||
implementation "androidx.annotation:annotation:${annotation}"
|
implementation "androidx.annotation:annotation:${annotation}"
|
||||||
|
|
||||||
implementation "androidx.viewpager2:viewpager2:${viewpager2}"
|
implementation "androidx.viewpager2:viewpager2:${viewpager2}"
|
||||||
ksp("androidx.room:room-compiler:${room}")
|
kapt "androidx.room:room-compiler:${room}"
|
||||||
|
|
||||||
|
implementation "com.kyleduo.switchbutton:library:${switchButton}"
|
||||||
|
|
||||||
implementation "com.tencent.vasdolly:helper:${apkChannelPackage}"
|
implementation "com.tencent.vasdolly:helper:${apkChannelPackage}"
|
||||||
implementation "com.tencent.vasdolly:writer:${apkChannelPackage}"
|
implementation "com.tencent.vasdolly:writer:${apkChannelPackage}"
|
||||||
@ -403,14 +343,12 @@ dependencies {
|
|||||||
exclude module: "gsyvideoplayer-androidvideocache"
|
exclude module: "gsyvideoplayer-androidvideocache"
|
||||||
exclude group: "tv.danmaku.ijk.media"
|
exclude group: "tv.danmaku.ijk.media"
|
||||||
})
|
})
|
||||||
implementation("com.github.CarGuo.GSYVideoPlayer:gsyVideoPlayer-exo_player2:$gsyVideo") {
|
implementation "com.github.CarGuo.GSYVideoPlayer:gsyVideoPlayer-exo_player2:$gsyVideo"
|
||||||
exclude group: 'com.google.android.exoplayer', module: 'extension-rtmp'
|
|
||||||
}
|
|
||||||
|
|
||||||
implementation "com.llew.huawei:verifier:${verifier}"
|
implementation "com.llew.huawei:verifier:${verifier}"
|
||||||
|
|
||||||
teaImplementation "com.bytedance.applog:RangersAppLog-Lite-cn:${bytedanceApplog}"
|
teaImplementation "com.bytedance.applog:RangersAppLog-Lite-cn:${bytedanceApplog}"
|
||||||
teaImplementation "com.bytedance.ads:AppConvert:${bytedanceAppConvert}"
|
teaImplementation "com.bytedance.applog:RangersAppLog-All-convert:${bytedanceApplog}"
|
||||||
|
|
||||||
implementation "net.lingala.zip4j:zip4j:${zip4j}"
|
implementation "net.lingala.zip4j:zip4j:${zip4j}"
|
||||||
|
|
||||||
@ -419,9 +357,7 @@ dependencies {
|
|||||||
|
|
||||||
implementation "com.lg:easyfloat:${easyFloat}"
|
implementation "com.lg:easyfloat:${easyFloat}"
|
||||||
|
|
||||||
implementation("com.lg:apksig:${apksig}") {
|
implementation "com.lg:apksig:${apksig}"
|
||||||
exclude group: 'com.google.protobuf'
|
|
||||||
}
|
|
||||||
|
|
||||||
implementation "com.lg:gid:${gid}"
|
implementation "com.lg:gid:${gid}"
|
||||||
|
|
||||||
@ -429,118 +365,56 @@ dependencies {
|
|||||||
|
|
||||||
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:${desugarJdkLibs}"
|
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:${desugarJdkLibs}"
|
||||||
|
|
||||||
kapt "com.google.auto.service:auto-service:${autoServiceVersion}"
|
kapt "com.alibaba:arouter-compiler:$arouterVersion"
|
||||||
ksp "cn.therouter:apt:${routerVersion}"
|
|
||||||
|
|
||||||
implementation project(':ndownload')
|
implementation project(':ndownload')
|
||||||
implementation project(':vspace-bridge:vspace')
|
implementation project(':vspace-bridge:vspace')
|
||||||
implementation(project(':feature:xapk-installer'))
|
|
||||||
|
|
||||||
implementation(project(':module_common')) {
|
implementation (project(':module_common')) {
|
||||||
exclude group: 'androidx.swiperefreshlayout'
|
exclude group: 'androidx.swiperefreshlayout'
|
||||||
}
|
}
|
||||||
|
|
||||||
implementation(project(':module_login')) {
|
implementation(project(':module_login')) {
|
||||||
exclude group: 'androidx.swiperefreshlayout'
|
exclude group: 'androidx.swiperefreshlayout'
|
||||||
}
|
}
|
||||||
|
|
||||||
implementation(project(':module_core_feature')) {
|
|
||||||
exclude group: 'androidx.swiperefreshlayout'
|
|
||||||
}
|
|
||||||
|
|
||||||
implementation(project(':module_setting')) {
|
implementation(project(':module_setting')) {
|
||||||
exclude group: 'androidx.swiperefreshlayout'
|
exclude group: 'androidx.swiperefreshlayout'
|
||||||
}
|
}
|
||||||
|
|
||||||
// implementation(project(':module_setting_compose')) {
|
// implementation(project(':module_setting_compose')) {
|
||||||
// exclude group: 'androidx.swiperefreshlayout'
|
// exclude group: 'androidx.swiperefreshlayout'
|
||||||
// }
|
// }
|
||||||
|
implementation(project(':module_core_feature')) {
|
||||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enablePkg) {
|
exclude group: 'androidx.swiperefreshlayout'
|
||||||
implementation(project(':feature:pkg'))
|
|
||||||
}
|
}
|
||||||
|
// implementation(project(':module_feedback')) {
|
||||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enableFeedback) {
|
// exclude group: 'androidx.swiperefreshlayout'
|
||||||
implementation(project(':feature:new_feedback')) {
|
// }
|
||||||
exclude group: 'androidx.swiperefreshlayout'
|
implementation(project(':feature:new_feedback',)) {
|
||||||
}
|
exclude group: 'androidx.swiperefreshlayout'
|
||||||
}
|
}
|
||||||
|
implementation(project(':module_sensors_data')) {
|
||||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enableMessage) {
|
exclude group: 'androidx.swiperefreshlayout'
|
||||||
implementation(project(':module_message')) {
|
|
||||||
exclude group: 'androidx.swiperefreshlayout'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
implementation(project(':module_message')) {
|
||||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enableOaid) {
|
exclude group: 'androidx.swiperefreshlayout'
|
||||||
implementation(project(':feature:oaid'))
|
|
||||||
}
|
}
|
||||||
|
// implementation(project(':feature:vpn'))
|
||||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enableFloatingWindow) {
|
implementation(project(':feature:pkg'))
|
||||||
implementation(project(':feature:floating-window'))
|
implementation(project(':feature:oaid'))
|
||||||
|
implementation(project(':feature:floating-window'))
|
||||||
|
implementation(project(':feature:csj_ad'))
|
||||||
|
// implementation(project(':feature:beizi_startup_ad'))
|
||||||
|
implementation(project(':feature:xapk-installer'))
|
||||||
|
implementation(project(':feature:qq_game')) {
|
||||||
|
exclude group: 'androidx.swiperefreshlayout'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enableSensorData) {
|
|
||||||
implementation(project(':module_sensors_data')) {
|
|
||||||
exclude group: 'androidx.swiperefreshlayout'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enableCsjAd) {
|
|
||||||
implementation(project(':feature:csj_ad'))
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enableQQGame) {
|
|
||||||
implementation(project(':feature:qq_game')) {
|
|
||||||
exclude group: 'androidx.swiperefreshlayout'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enablePush) {
|
|
||||||
def pushProperty = findProperty('BUILD_PUSH_TYPE')
|
|
||||||
// 根据BUILD_PUSH_TYPE决定使用哪个推送SDK,目前默认使用极光推送
|
|
||||||
def pushProject = (pushProperty == null || pushProperty == 'jg')
|
|
||||||
? project(':feature:jg_push') : project(':feature:acloud_push')
|
|
||||||
|
|
||||||
implementation(pushProject) {
|
|
||||||
exclude group: 'androidx.swiperefreshlayout'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enableSentry) {
|
|
||||||
implementation(project(':feature:sentry'))
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gradle.ext.enableRouteDoc) {
|
|
||||||
ksp project(":feature:route_doc")
|
|
||||||
}
|
|
||||||
|
|
||||||
implementation(project(':feature:media_select'))
|
|
||||||
|
|
||||||
implementation(project(":module_va_api"))
|
|
||||||
implementation(project(":va-archive-common"))
|
|
||||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enableVa) {
|
|
||||||
implementation(project(":module_va_impl"))
|
|
||||||
}
|
|
||||||
debugImplementation "com.bytedance.tools.codelocator:codelocator-core:2.0.3"
|
|
||||||
internalImplementation(project(':module_internal_test'))
|
internalImplementation(project(':module_internal_test'))
|
||||||
|
|
||||||
debugImplementation 'com.bytedance.android:shadowhook:1.0.9'
|
// 根据BUILD_PUSH_TYPE决定使用哪个推送SDK,目前默认使用阿里云推送
|
||||||
debugImplementation 'io.github.shiqos:wytrace:1.0.1'
|
def pushProject = findProperty('BUILD_PUSH_TYPE') == 'jg'
|
||||||
|
? project(':feature:jg_push') : project(':feature:acloud_push')
|
||||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enableAccelerator) {
|
implementation(pushProject) {
|
||||||
implementation(project(":feature:accelerator"))
|
exclude group: 'androidx.swiperefreshlayout'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gradle.ext.excludeOptionalModules || gradle.ext.enableAliPay) {
|
|
||||||
implementation(project(":feature:ali_pay"))
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!gradle.ext.excludeOptionalModules || gradle.ext.enableWechatPay){
|
|
||||||
implementation(project(":feature:wechat_pay"))
|
|
||||||
}
|
|
||||||
|
|
||||||
implementation "me.xdrop:fuzzywuzzy:${fuzzyVersion}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
File propFile = file('sign.properties')
|
File propFile = file('sign.properties')
|
||||||
@ -600,6 +474,113 @@ if (propFile.exists()) {
|
|||||||
// }.each { t -> t.dependsOn generateMetaJson }
|
// }.each { t -> t.dependsOn generateMetaJson }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
andResGuard {
|
||||||
|
mappingFile = null
|
||||||
|
use7zip = true
|
||||||
|
useSign = true
|
||||||
|
// 打开这个开关,会keep住所有资源的原始路径,只混淆资源的名字
|
||||||
|
keepRoot = false
|
||||||
|
// 设置这个值,会把arsc name列混淆成相同的名字,减少string常量池的大小
|
||||||
|
fixedResName = "arg"
|
||||||
|
// 打开这个开关会合并所有哈希值相同的资源,但请不要过度依赖这个功能去除去冗余资源
|
||||||
|
mergeDuplicatedRes = true
|
||||||
|
whiteList = [
|
||||||
|
"R.xml.jpush*",
|
||||||
|
"R.drawable.jpush*",
|
||||||
|
"R.layout.jpush*",
|
||||||
|
"R.layout.push*",
|
||||||
|
"R.string.jg*",
|
||||||
|
"R.style.MyDialogStyle",
|
||||||
|
"R.style.JPushTheme",
|
||||||
|
"R.drawable.icon",
|
||||||
|
"R.drawable.ic_bar_back",
|
||||||
|
"R.drawable.toolbar_search_icon",
|
||||||
|
"R.drawable.bg_notification_answer_style_1",
|
||||||
|
"R.drawable.bg_notification_answer_style_2",
|
||||||
|
"R.drawable.bg_notification_article_style_1",
|
||||||
|
"R.drawable.bg_notification_article_style_2",
|
||||||
|
"R.drawable.bg_notification_feedback_style_1",
|
||||||
|
"R.drawable.bg_notification_feedback_style_2",
|
||||||
|
"R.drawable.bg_notification_gift_style_1",
|
||||||
|
"R.drawable.bg_notification_gift_style_2",
|
||||||
|
"R.drawable.bg_notification_login_style_1",
|
||||||
|
"R.drawable.bg_notification_login_style_2",
|
||||||
|
"R.drawable.bg_notification_question_style_1",
|
||||||
|
"R.drawable.bg_notification_question_style_2",
|
||||||
|
"R.drawable.bg_notification_rating_style_1",
|
||||||
|
"R.drawable.bg_notification_rating_style_2",
|
||||||
|
"R.drawable.bg_notification_reserve_game_style_1",
|
||||||
|
"R.drawable.bg_notification_reserve_game_style_2",
|
||||||
|
"R.drawable.bg_notification_video_style_1",
|
||||||
|
"R.drawable.bg_notification_video_style_2",
|
||||||
|
"R.drawable.ic_recommend_activity",
|
||||||
|
"R.drawable.ic_recommend_discount",
|
||||||
|
"R.drawable.ic_recommend_function",
|
||||||
|
"R.drawable.ic_recommend_gift",
|
||||||
|
"R.drawable.ic_recommend_role",
|
||||||
|
"R.drawable.download_button_normal_style",
|
||||||
|
"R.drawable.ic_selector_selected",
|
||||||
|
"R.drawable.ic_selector_default",
|
||||||
|
"R.id.download_speed",
|
||||||
|
"R.id.download_percentage",
|
||||||
|
"R.id.comment",
|
||||||
|
"R.id.vote",
|
||||||
|
"R.id.watermark_hint",
|
||||||
|
"R.id.watermark_sb",
|
||||||
|
"R.id.bottomShareIv",
|
||||||
|
"R.id.bottomShareTv",
|
||||||
|
"R.id.recommendStarPref",
|
||||||
|
"R.id.recommendStar",
|
||||||
|
"R.id.iv_vmode_badge",
|
||||||
|
"R.id.tv_vmode",
|
||||||
|
"R.id.iv_vmode",
|
||||||
|
"R.drawable.help_search_delete",
|
||||||
|
"R.drawable.suggest_type_normal",
|
||||||
|
"R.drawable.suggest_type_crash",
|
||||||
|
"R.drawable.suggest_type_game_question",
|
||||||
|
"R.drawable.suggest_type_game_collect",
|
||||||
|
"R.drawable.suggest_type_function_suggest",
|
||||||
|
"R.drawable.suggest_type_article_collect",
|
||||||
|
"R.drawable.suggest_type_copyright",
|
||||||
|
"R.drawable.news_comment_detail_read",
|
||||||
|
"R.drawable.news_comment_detail_comment",
|
||||||
|
"R.drawable.news_comment_detail_share",
|
||||||
|
"R.drawable.ic_libao",
|
||||||
|
"R.drawable.ic_link",
|
||||||
|
"R.drawable.concern_message_icon",
|
||||||
|
"R.drawable.reuse_blank_hint",
|
||||||
|
"R.drawable.ic_concern",
|
||||||
|
"R.drawable.concern_down",
|
||||||
|
"R.drawable.concern_up",
|
||||||
|
"R.drawable.ic_libao_more",
|
||||||
|
"R.drawable.ic_libao_delete",
|
||||||
|
"R.drawable.ic_dialog_close",
|
||||||
|
"R.drawable.occupy2",
|
||||||
|
"R.drawable.kc_checkbox_unselect",
|
||||||
|
"R.drawable.kc_checkbox_select",
|
||||||
|
"R.drawable.ic_type_unselect",
|
||||||
|
"R.drawable.ic_type_selected",
|
||||||
|
"R.drawable.suggest_add_pic_icon",
|
||||||
|
"R.drawable.icon_pic_add",
|
||||||
|
"R.drawable.ask_search_input_delete",
|
||||||
|
"R.drawable.suggest_pic_delete",
|
||||||
|
"R.id.cardIv",
|
||||||
|
"R.id.cardMask",
|
||||||
|
"R.id.cardGradientMask",
|
||||||
|
"R.id.gameIconIv",
|
||||||
|
"R.id.titleContainer"
|
||||||
|
]
|
||||||
|
compressFilePattern = [
|
||||||
|
"*.png",
|
||||||
|
"*.jpg",
|
||||||
|
"*.jpeg",
|
||||||
|
"*.gif",
|
||||||
|
]
|
||||||
|
sevenzip {
|
||||||
|
artifact = 'io.github.leon406:SevenZip:1.2.22.5'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
project.afterEvaluate {
|
project.afterEvaluate {
|
||||||
def variants = null
|
def variants = null
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -20,7 +20,6 @@
|
|||||||
-keep class com.gh.gamecenter.db.info.* {*;}
|
-keep class com.gh.gamecenter.db.info.* {*;}
|
||||||
-keep class com.gh.gamecenter.entity.** {<fields>;}
|
-keep class com.gh.gamecenter.entity.** {<fields>;}
|
||||||
-keep class com.gh.gamecenter.qa.entity.** {<fields>;}
|
-keep class com.gh.gamecenter.qa.entity.** {<fields>;}
|
||||||
-keep class com.gh.gamecenter.gamedetail.entity.** {<fields>;}
|
|
||||||
-keep class com.gh.download.DownloadDataSimpleEntity {<fields>;}
|
-keep class com.gh.download.DownloadDataSimpleEntity {<fields>;}
|
||||||
-keep class com.gh.gamecenter.floatingwindow.FloatingWindowEntity {<fields>;}
|
-keep class com.gh.gamecenter.floatingwindow.FloatingWindowEntity {<fields>;}
|
||||||
-keep class com.gh.gamecenter.BR
|
-keep class com.gh.gamecenter.BR
|
||||||
@ -77,7 +76,6 @@
|
|||||||
|
|
||||||
### TEA
|
### TEA
|
||||||
-keep class com.gh.gamecenter.TeaHelper { *; }
|
-keep class com.gh.gamecenter.TeaHelper { *; }
|
||||||
-keep class com.bytedance.ads.convert.broadcast.common.EncryptionTools {*;}
|
|
||||||
|
|
||||||
### EasyFloat
|
### EasyFloat
|
||||||
-keep class com.lzf.easyfloat.* {*;}
|
-keep class com.lzf.easyfloat.* {*;}
|
||||||
|
|||||||
@ -28,9 +28,6 @@ object GdtHelper {
|
|||||||
} else {
|
} else {
|
||||||
GDTAction.init(application, USER_ACTION_SET_ID, APP_SECRET_ID, channel)
|
GDTAction.init(application, USER_ACTION_SET_ID, APP_SECRET_ID, channel)
|
||||||
}
|
}
|
||||||
|
|
||||||
GDTAction.start()
|
|
||||||
|
|
||||||
Utils.log("init GdtHelper")
|
Utils.log("init GdtHelper")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
BIN
app/src/gdt/libs/GDTActionSDK.min.1.8.8.aar
Normal file
BIN
app/src/gdt/libs/GDTActionSDK.min.1.8.8.aar
Normal file
Binary file not shown.
Binary file not shown.
@ -6,37 +6,27 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.annotation.Keep
|
import androidx.annotation.Keep
|
||||||
import com.gh.gamecenter.R
|
import com.gh.gamecenter.R
|
||||||
import com.gh.gamecenter.core.utils.ToastUtils
|
|
||||||
import com.gh.gamecenter.databinding.LayoutPersonalOtherItemBinding
|
import com.gh.gamecenter.databinding.LayoutPersonalOtherItemBinding
|
||||||
import com.gh.vspace.installexternalgames.InstallExternalGameActivity
|
import com.gh.vspace.installexternalgames.InstallExternalGameActivity
|
||||||
import com.lightgame.utils.Utils
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
@Keep
|
@Keep
|
||||||
class ExternalGameUsage : ITestCase {
|
class ExternalGameUsage : IExternalGamesUsage {
|
||||||
|
override fun addInstallExternalGameButton(viewParent: ViewGroup) {
|
||||||
private fun buttonTemplate(viewParent: ViewGroup, id: Int, fn: (LayoutPersonalOtherItemBinding) -> Unit) {
|
|
||||||
val context = viewParent.context
|
val context = viewParent.context
|
||||||
viewParent.findViewById<View>(id) ?: run {
|
viewParent.findViewById<View>(R.id.install_game_from_external) ?: run {
|
||||||
val binding = LayoutPersonalOtherItemBinding.inflate(LayoutInflater.from(context)).apply {
|
val binding = LayoutPersonalOtherItemBinding.inflate(LayoutInflater.from(context)).apply {
|
||||||
root.id = id
|
root.id = R.id.install_game_from_external
|
||||||
fn(this)
|
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)
|
viewParent.addView(binding.root, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun addInstallExternalGameButton(viewParent: ViewGroup) {
|
|
||||||
val context = viewParent.context
|
|
||||||
buttonTemplate(viewParent, R.id.install_game_from_external) {
|
|
||||||
it.titleTv.text = context.getString(R.string.title_install_external_game)
|
|
||||||
it.iconIv.setImageResource(R.drawable.ic_personal_my_game)
|
|
||||||
it.root.setOnClickListener {
|
|
||||||
context.startActivity(
|
|
||||||
InstallExternalGameActivity.getIntent(context)
|
|
||||||
.apply { flags = flags or Intent.FLAG_ACTIVITY_NEW_TASK })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -25,11 +25,6 @@ class ExternalGameAdapter(private val games: List<ExternalGameUiState>, private
|
|||||||
路径:${item.apkPath}
|
路径:${item.apkPath}
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.update.setOnClickListener {
|
|
||||||
onItemClickListener.onItemClick(item, OnItemClickListener.ClickType.CLICK_INSTALL)
|
|
||||||
}
|
|
||||||
|
|
||||||
holder.install.goneIf(item.isInstalled) {
|
holder.install.goneIf(item.isInstalled) {
|
||||||
holder.install.setOnClickListener {
|
holder.install.setOnClickListener {
|
||||||
onItemClickListener.onItemClick(item, OnItemClickListener.ClickType.CLICK_INSTALL)
|
onItemClickListener.onItemClick(item, OnItemClickListener.ClickType.CLICK_INSTALL)
|
||||||
|
|||||||
@ -8,5 +8,4 @@ class ExternalGameViewHolder(binding: LayoutExternalGameItemBinding) : RecyclerV
|
|||||||
val install = binding.btnInstall
|
val install = binding.btnInstall
|
||||||
val uninstall = binding.btnUninstall
|
val uninstall = binding.btnUninstall
|
||||||
val start = binding.btnStart
|
val start = binding.btnStart
|
||||||
val update = binding.btnUpdate
|
|
||||||
}
|
}
|
||||||
@ -1,19 +1,10 @@
|
|||||||
package com.gh.vspace.installexternalgames
|
package com.gh.vspace.installexternalgames
|
||||||
|
|
||||||
import android.Manifest
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.content.ComponentName
|
|
||||||
import android.content.Intent
|
|
||||||
import android.content.pm.PackageManager
|
|
||||||
import android.os.Build
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Environment
|
|
||||||
import android.provider.Settings
|
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
|
||||||
import androidx.appcompat.app.AlertDialog
|
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.gh.common.util.DialogUtils
|
import com.gh.common.util.DialogUtils
|
||||||
|
import com.gh.gamecenter.R
|
||||||
import com.gh.gamecenter.common.base.fragment.ToolbarFragment
|
import com.gh.gamecenter.common.base.fragment.ToolbarFragment
|
||||||
import com.gh.gamecenter.common.exposure.meta.MetaUtil
|
import com.gh.gamecenter.common.exposure.meta.MetaUtil
|
||||||
import com.gh.gamecenter.common.utils.dip2px
|
import com.gh.gamecenter.common.utils.dip2px
|
||||||
@ -25,7 +16,6 @@ import com.gh.gamecenter.databinding.FragmentInstallExternalGamesBinding
|
|||||||
import com.gh.vspace.VHelper
|
import com.gh.vspace.VHelper
|
||||||
import com.halo.assistant.HaloApp
|
import com.halo.assistant.HaloApp
|
||||||
import com.lg.vspace.VirtualAppManager
|
import com.lg.vspace.VirtualAppManager
|
||||||
import com.lightgame.download.DownloadEntity
|
|
||||||
import io.reactivex.Single
|
import io.reactivex.Single
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
import io.reactivex.disposables.Disposable
|
import io.reactivex.disposables.Disposable
|
||||||
@ -42,9 +32,6 @@ class InstallExternalGameFragment : ToolbarFragment(), OnItemClickListener {
|
|||||||
|
|
||||||
private var uninstallDisposable: Disposable? = null
|
private var uninstallDisposable: Disposable? = null
|
||||||
|
|
||||||
|
|
||||||
private var shouldScan = false
|
|
||||||
|
|
||||||
override fun getLayoutId() = 0
|
override fun getLayoutId() = 0
|
||||||
|
|
||||||
override fun getInflatedLayout() =
|
override fun getInflatedLayout() =
|
||||||
@ -52,19 +39,6 @@ class InstallExternalGameFragment : ToolbarFragment(), OnItemClickListener {
|
|||||||
|
|
||||||
private lateinit var dialog: Dialog
|
private lateinit var dialog: Dialog
|
||||||
|
|
||||||
|
|
||||||
private val requestPermissionLauncher = registerForActivityResult<String, Boolean>(
|
|
||||||
ActivityResultContracts.RequestPermission()
|
|
||||||
) { result ->
|
|
||||||
if (result == true) {
|
|
||||||
// grant
|
|
||||||
mViewModel.scanPaths()
|
|
||||||
} else {
|
|
||||||
// not grant
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setNavigationTitle(getString(com.gh.gamecenter.R.string.title_install_external_game))
|
setNavigationTitle(getString(com.gh.gamecenter.R.string.title_install_external_game))
|
||||||
@ -81,51 +55,9 @@ class InstallExternalGameFragment : ToolbarFragment(), OnItemClickListener {
|
|||||||
)
|
)
|
||||||
adapter.notifyDataSetChanged()
|
adapter.notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
mViewModel.scanPaths()
|
||||||
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
||||||
if (!Environment.isExternalStorageManager()) {
|
|
||||||
shouldScan = true
|
|
||||||
AlertDialog.Builder(requireContext()).setMessage("请在设置页面允许光环助手")
|
|
||||||
.setNegativeButton("去") { dialog, which ->
|
|
||||||
val intent = Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION)
|
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
||||||
startActivity(intent)
|
|
||||||
}.show()
|
|
||||||
} else {
|
|
||||||
mViewModel.scanPaths()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
requestStoragePermission()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun requestStoragePermission() {
|
|
||||||
when {
|
|
||||||
ContextCompat.checkSelfPermission(
|
|
||||||
requireContext(),
|
|
||||||
Manifest.permission.READ_EXTERNAL_STORAGE
|
|
||||||
) == PackageManager.PERMISSION_GRANTED -> {
|
|
||||||
mViewModel.scanPaths()
|
|
||||||
}
|
|
||||||
|
|
||||||
shouldShowRequestPermissionRationale(Manifest.permission.READ_EXTERNAL_STORAGE) -> {
|
|
||||||
requestPermissionLauncher.launch(Manifest.permission.READ_EXTERNAL_STORAGE)
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> {
|
|
||||||
requestPermissionLauncher.launch(Manifest.permission.READ_EXTERNAL_STORAGE)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onStart() {
|
|
||||||
super.onStart()
|
|
||||||
if (shouldScan) {
|
|
||||||
mViewModel.scanPaths()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initView() {
|
private fun initView() {
|
||||||
@ -135,7 +67,7 @@ class InstallExternalGameFragment : ToolbarFragment(), OnItemClickListener {
|
|||||||
it.layoutManager = LinearLayoutManager(requireContext())
|
it.layoutManager = LinearLayoutManager(requireContext())
|
||||||
val itemDecoration = HorizontalDividerItemDecoration.Builder(requireContext())
|
val itemDecoration = HorizontalDividerItemDecoration.Builder(requireContext())
|
||||||
.size(2F.dip2px())
|
.size(2F.dip2px())
|
||||||
.color(com.gh.gamecenter.common.R.color.ui_divider.toColor(requireContext()))
|
.color(R.color.ui_divider.toColor(requireContext()))
|
||||||
.build()
|
.build()
|
||||||
if (it.itemDecorationCount != 0) {
|
if (it.itemDecorationCount != 0) {
|
||||||
it.removeItemDecorationAt(0)
|
it.removeItemDecorationAt(0)
|
||||||
@ -161,11 +93,9 @@ class InstallExternalGameFragment : ToolbarFragment(), OnItemClickListener {
|
|||||||
OnItemClickListener.ClickType.CLICK_INSTALL -> {
|
OnItemClickListener.ClickType.CLICK_INSTALL -> {
|
||||||
install(externalGameUiState)
|
install(externalGameUiState)
|
||||||
}
|
}
|
||||||
|
|
||||||
OnItemClickListener.ClickType.CLICK_UNINSTALL -> {
|
OnItemClickListener.ClickType.CLICK_UNINSTALL -> {
|
||||||
uninstall(externalGameUiState)
|
uninstall(externalGameUiState)
|
||||||
}
|
}
|
||||||
|
|
||||||
OnItemClickListener.ClickType.CLICK_START -> {
|
OnItemClickListener.ClickType.CLICK_START -> {
|
||||||
start(externalGameUiState)
|
start(externalGameUiState)
|
||||||
}
|
}
|
||||||
@ -173,21 +103,21 @@ class InstallExternalGameFragment : ToolbarFragment(), OnItemClickListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun install(externalGameUiState: ExternalGameUiState) {
|
private fun install(externalGameUiState: ExternalGameUiState) {
|
||||||
|
val bit =
|
||||||
VHelper.disableLaunchGameAfterInstallation()
|
externalGameUiState.externalGameEntity.cpuAbi.let { if (it.size == 1 && it.contains("armeabi-v7a")) "32" else "64" }
|
||||||
VHelper.install(requireContext(), DownloadEntity().apply {
|
if (VHelper.showDialogIfVSpaceIsNeeded(
|
||||||
externalGameUiState.externalGameEntity.apply {
|
requireContext(),
|
||||||
packageName = apkPackageName
|
"",
|
||||||
path = apkPath
|
externalGameUiState.externalGameEntity.appName,
|
||||||
}
|
"",
|
||||||
}, true)
|
bit = bit
|
||||||
|
)
|
||||||
VHelper.newCwValidateVspaceBeforeAction(
|
) return
|
||||||
requireContext(), null,
|
dialog.show()
|
||||||
) {
|
externalGameUiState.externalGameEntity.let {
|
||||||
dialog.show()
|
val intent = VirtualAppManager.getInstallIntent(context, it.apkPath, it.apkPackageName)
|
||||||
|
requireActivity().startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun uninstall(externalGameUiState: ExternalGameUiState) {
|
private fun uninstall(externalGameUiState: ExternalGameUiState) {
|
||||||
@ -214,15 +144,7 @@ class InstallExternalGameFragment : ToolbarFragment(), OnItemClickListener {
|
|||||||
com.gh.gamecenter.BuildConfig.VERSION_NAME,
|
com.gh.gamecenter.BuildConfig.VERSION_NAME,
|
||||||
HaloApp.getInstance().channel,
|
HaloApp.getInstance().channel,
|
||||||
"",
|
"",
|
||||||
"",
|
""
|
||||||
com.gh.gamecenter.BuildConfig.VA_VERSION_NAME,
|
|
||||||
HaloApp.getInstance().oaid
|
|
||||||
)
|
|
||||||
intent.setComponent(
|
|
||||||
ComponentName(
|
|
||||||
com.gh.gamecenter.BuildConfig.APPLICATION_ID,
|
|
||||||
VirtualAppManager.AIDL_SERVER_REMOTE_GUIDE_ACTIVITY
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
requireActivity().startActivity(intent)
|
requireActivity().startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,14 +24,6 @@
|
|||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/btn_update"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/text_update"
|
|
||||||
android:visibility="visible"
|
|
||||||
tools:visibility="visible" />
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btn_uninstall"
|
android:id="@+id/btn_uninstall"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="title_install_external_game">從SD卡安裝</string>
|
<string name="title_install_external_game">從SD卡安裝</string>
|
||||||
<string name="text_install">安裝</string>
|
<string name="text_install">安裝</string>
|
||||||
<string name="text_update">更新</string>
|
|
||||||
<string name="text_uninstall">卸載</string>
|
<string name="text_uninstall">卸載</string>
|
||||||
<string name="text_start">啟動</string>
|
<string name="text_start">啟動</string>
|
||||||
</resources>
|
</resources>
|
||||||
@ -2,7 +2,6 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="title_install_external_game">从SD卡安装</string>
|
<string name="title_install_external_game">从SD卡安装</string>
|
||||||
<string name="text_install">安装</string>
|
<string name="text_install">安装</string>
|
||||||
<string name="text_update">更新</string>
|
|
||||||
<string name="text_uninstall">卸载</string>
|
<string name="text_uninstall">卸载</string>
|
||||||
<string name="text_start">启动</string>
|
<string name="text_start">启动</string>
|
||||||
</resources>
|
</resources>
|
||||||
BIN
app/src/kuaishou/libs/channelsdk-0.2.2.aar
Normal file
BIN
app/src/kuaishou/libs/channelsdk-0.2.2.aar
Normal file
Binary file not shown.
Binary file not shown.
@ -7,28 +7,17 @@
|
|||||||
<package android:name="com.gh.gamecenter" />
|
<package android:name="com.gh.gamecenter" />
|
||||||
</queries>
|
</queries>
|
||||||
|
|
||||||
<queries>
|
|
||||||
<package android:name="com.gh.toolmap" />
|
|
||||||
<intent>
|
|
||||||
<action android:name="android.intent.action.VIEW" />
|
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
|
||||||
<data android:scheme="ghtoolmap" />
|
|
||||||
</intent>
|
|
||||||
</queries>
|
|
||||||
|
|
||||||
<queries>
|
<queries>
|
||||||
<package android:name="com.lg.vspace" />
|
<package android:name="com.lg.vspace" />
|
||||||
<package android:name="com.gh.gamecenter.addon" />
|
|
||||||
</queries>
|
</queries>
|
||||||
|
|
||||||
<!-- 华为/荣耀角标 -->
|
<!-- 华为/荣耀角标 -->
|
||||||
<uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE " />
|
<uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE "/>
|
||||||
<uses-permission android:name="com.hihonor.android.launcher.permission.CHANGE_BADGE" />
|
<uses-permission android:name="com.hihonor.android.launcher.permission.CHANGE_BADGE" />
|
||||||
<!-- vivo角标 -->
|
<!-- vivo角标 -->
|
||||||
<uses-permission android:name="com.vivo.notification.permission.BADGE_ICON" />
|
<uses-permission android:name="com.vivo.notification.permission.BADGE_ICON" />
|
||||||
|
|
||||||
<uses-permission
|
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
|
||||||
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
|
|
||||||
tools:ignore="ScopedStorage" />
|
tools:ignore="ScopedStorage" />
|
||||||
<!-- 允许应用程序访问网络连接 -->
|
<!-- 允许应用程序访问网络连接 -->
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
@ -50,7 +39,7 @@
|
|||||||
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
|
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
|
||||||
<!-- 应用安装相关 -->
|
<!-- 应用安装相关 -->
|
||||||
<uses-permission android:name="com.android.permission.GET_INSTALLED_APPS" />
|
<uses-permission android:name="com.android.permission.GET_INSTALLED_APPS" />
|
||||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
|
|
||||||
<!-- 前台服务权限-->
|
<!-- 前台服务权限-->
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
|
|
||||||
@ -65,16 +54,6 @@
|
|||||||
<!-- 如果有视频相关的广告且使用textureView播放,请务必添加,否则黑屏 -->
|
<!-- 如果有视频相关的广告且使用textureView播放,请务必添加,否则黑屏 -->
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
|
|
||||||
<!-- 悬浮窗 -->
|
|
||||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
|
||||||
|
|
||||||
<!-- 适配 双开/分身 游戏授权登录 -->
|
|
||||||
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" />
|
|
||||||
|
|
||||||
<!-- 日历 -->
|
|
||||||
<uses-permission android:name="android.permission.READ_CALENDAR" />
|
|
||||||
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
|
|
||||||
|
|
||||||
<uses-sdk tools:overrideLibrary="
|
<uses-sdk tools:overrideLibrary="
|
||||||
com.shuyu.gsyvideoplayer,
|
com.shuyu.gsyvideoplayer,
|
||||||
com.shuyu.gsyvideoplayer.lib,
|
com.shuyu.gsyvideoplayer.lib,
|
||||||
@ -113,33 +92,7 @@
|
|||||||
com.tencent.qqmini,
|
com.tencent.qqmini,
|
||||||
com.tencent.qqmini.minigame.external,
|
com.tencent.qqmini.minigame.external,
|
||||||
com.tencent.qqmini.minigame.opensdk,
|
com.tencent.qqmini.minigame.opensdk,
|
||||||
com.tencent.qqmini.union.ad,
|
com.tencent.qqmini.union.ad" />
|
||||||
com.lg.vspace,
|
|
||||||
io.lg.va.common,
|
|
||||||
com.va.floating,
|
|
||||||
com.lg.cloud,
|
|
||||||
com.lg.archive,
|
|
||||||
com.lg.vclient,
|
|
||||||
com.va.realname,
|
|
||||||
com.lg.vspace.flavor,
|
|
||||||
com.lg.update,
|
|
||||||
com.lg.login,
|
|
||||||
com.lg.accelerator,
|
|
||||||
com.lody.virtual,
|
|
||||||
com.lg.core,
|
|
||||||
com.lg.ads,
|
|
||||||
com.lg.common,
|
|
||||||
com.lg.vspace.network,
|
|
||||||
com.lody.virtual.lib.res,
|
|
||||||
com.va.host,
|
|
||||||
com.lg.vspace.plugin.host,
|
|
||||||
com.lg.plugin.constant,
|
|
||||||
com.bytedance.tools.codelocator,
|
|
||||||
org.chickenhook.restrictionbypass,
|
|
||||||
com.lody.virtual.sandhook,
|
|
||||||
com.lg.vspace.common,
|
|
||||||
com.lg.vspace.archive.common,
|
|
||||||
com.wy.lib.wytrace" />
|
|
||||||
|
|
||||||
<!-- 去掉 SDK 一些流氓权限 -->
|
<!-- 去掉 SDK 一些流氓权限 -->
|
||||||
<uses-permission
|
<uses-permission
|
||||||
@ -158,14 +111,6 @@
|
|||||||
android:name="android.permission.ACCESS_COARSE_LOCATION"
|
android:name="android.permission.ACCESS_COARSE_LOCATION"
|
||||||
tools:node="remove" />
|
tools:node="remove" />
|
||||||
|
|
||||||
<uses-permission
|
|
||||||
android:name="android.permission.ACCESS_BACKGROUND_LOCATION"
|
|
||||||
tools:node="remove" />
|
|
||||||
|
|
||||||
<uses-permission
|
|
||||||
android:name="android.permission.ACCESS_FINE_LOCATION"
|
|
||||||
tools:node="remove" />
|
|
||||||
|
|
||||||
<supports-screens
|
<supports-screens
|
||||||
android:anyDensity="true"
|
android:anyDensity="true"
|
||||||
android:largeScreens="true"
|
android:largeScreens="true"
|
||||||
@ -201,10 +146,6 @@
|
|||||||
android:name="io.sentry.breadcrumbs.system-events"
|
android:name="io.sentry.breadcrumbs.system-events"
|
||||||
android:value="false" />
|
android:value="false" />
|
||||||
|
|
||||||
<meta-data
|
|
||||||
android:name="module_version"
|
|
||||||
android:value="${VA_VERSION_NAME}" />
|
|
||||||
|
|
||||||
<service android:name="com.gh.ndownload.NDownloadService" />
|
<service android:name="com.gh.ndownload.NDownloadService" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
@ -329,6 +270,10 @@
|
|||||||
android:name="com.gh.gamecenter.CleanApkActivity"
|
android:name="com.gh.gamecenter.CleanApkActivity"
|
||||||
android:screenOrientation="portrait" />
|
android:screenOrientation="portrait" />
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name="com.gh.gamecenter.SelectUserIconActivity"
|
||||||
|
android:screenOrientation="portrait" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.gh.gamecenter.CommentDetailActivity"
|
android:name="com.gh.gamecenter.CommentDetailActivity"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
@ -353,6 +298,14 @@
|
|||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:windowSoftInputMode="stateHidden" />
|
android:windowSoftInputMode="stateHidden" />
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".category.CategoryDirectoryActivity"
|
||||||
|
android:screenOrientation="portrait" />
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".category.CategoryListActivity"
|
||||||
|
android:screenOrientation="portrait" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.gh.gamecenter.UserInfoActivity"
|
android:name="com.gh.gamecenter.UserInfoActivity"
|
||||||
android:screenOrientation="portrait" />
|
android:screenOrientation="portrait" />
|
||||||
@ -474,6 +427,9 @@
|
|||||||
android:name="com.gh.gamecenter.video.game.GameVideoActivity"
|
android:name="com.gh.gamecenter.video.game.GameVideoActivity"
|
||||||
android:screenOrientation="portrait" />
|
android:screenOrientation="portrait" />
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name="com.gh.gamecenter.qa.editor.LocalMediaActivity"
|
||||||
|
android:screenOrientation="portrait" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.gh.gamecenter.servers.GameServersActivity"
|
android:name="com.gh.gamecenter.servers.GameServersActivity"
|
||||||
@ -506,6 +462,9 @@
|
|||||||
android:configChanges="orientation|screenSize|keyboardHidden"
|
android:configChanges="orientation|screenSize|keyboardHidden"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:theme="@style/TransparentStatusBarAndNavigationBar" />
|
android:theme="@style/TransparentStatusBarAndNavigationBar" />
|
||||||
|
<activity
|
||||||
|
android:name=".gamedetail.myrating.MyRatingActivity"
|
||||||
|
android:screenOrientation="portrait" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.gh.gamecenter.gamedetail.fuli.kaifu.ServersCalendarActivity"
|
android:name="com.gh.gamecenter.gamedetail.fuli.kaifu.ServersCalendarActivity"
|
||||||
@ -526,6 +485,10 @@
|
|||||||
android:name=".video.data.VideoDataActivity"
|
android:name=".video.data.VideoDataActivity"
|
||||||
android:screenOrientation="portrait" />
|
android:screenOrientation="portrait" />
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".video.poster.PosterEditActivity"
|
||||||
|
android:screenOrientation="portrait" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".forum.detail.ForumDetailActivity"
|
android:name=".forum.detail.ForumDetailActivity"
|
||||||
android:screenOrientation="portrait" />
|
android:screenOrientation="portrait" />
|
||||||
@ -567,6 +530,14 @@
|
|||||||
android:name=".simulatorgame.SimulatorManagementActivity"
|
android:name=".simulatorgame.SimulatorManagementActivity"
|
||||||
android:screenOrientation="portrait" />
|
android:screenOrientation="portrait" />
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".catalog.CatalogActivity"
|
||||||
|
android:screenOrientation="portrait" />
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".catalog.NewCatalogListActivity"
|
||||||
|
android:screenOrientation="portrait" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".forum.search.ForumOrUserSearchActivity"
|
android:name=".forum.search.ForumOrUserSearchActivity"
|
||||||
android:screenOrientation="portrait" />
|
android:screenOrientation="portrait" />
|
||||||
@ -587,6 +558,10 @@
|
|||||||
android:name=".personal.DeliveryInfoActivity"
|
android:name=".personal.DeliveryInfoActivity"
|
||||||
android:screenOrientation="portrait" />
|
android:screenOrientation="portrait" />
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".qa.editor.PreviewVideoActivity"
|
||||||
|
android:screenOrientation="portrait" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".qa.video.publish.VideoPublishActivity"
|
android:name=".qa.video.publish.VideoPublishActivity"
|
||||||
android:screenOrientation="portrait" />
|
android:screenOrientation="portrait" />
|
||||||
@ -643,9 +618,8 @@
|
|||||||
<!-- android:theme="@android:style/Theme.Translucent" />-->
|
<!-- android:theme="@android:style/Theme.Translucent" />-->
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.gh.gamecenter.SkipCompatActivity"
|
android:name="com.gh.gamecenter.SkipActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:launchMode="singleTask"
|
|
||||||
android:theme="@style/Theme.AppCompat.Light.Fullscreen.Transparent">
|
android:theme="@style/Theme.AppCompat.Light.Fullscreen.Transparent">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<data android:scheme="ghzhushou" />
|
<data android:scheme="ghzhushou" />
|
||||||
@ -669,8 +643,7 @@
|
|||||||
android:name=".authorization.AuthorizationActivity"
|
android:name=".authorization.AuthorizationActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:launchMode="singleTask"
|
android:launchMode="singleTask"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait">
|
||||||
android:taskAffinity=".auth">
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<data android:scheme="ghzhushou_authorization" />
|
<data android:scheme="ghzhushou_authorization" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
@ -774,11 +747,11 @@
|
|||||||
android:screenOrientation="portrait" />
|
android:screenOrientation="portrait" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.gh.gamecenter.minigame.qq.QGameHomeWrapperActivity"
|
android:name="com.gh.gamecenter.qgame.QGameHomeWrapperActivity"
|
||||||
android:screenOrientation="portrait" />
|
android:screenOrientation="portrait" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.gh.gamecenter.minigame.MiniGameSearchActivity"
|
android:name="com.gh.gamecenter.qgame.QGameSearchActivity"
|
||||||
android:screenOrientation="portrait" />
|
android:screenOrientation="portrait" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
@ -797,32 +770,8 @@
|
|||||||
android:name="com.gh.gamecenter.wrapper.ToolbarWrapperActivity"
|
android:name="com.gh.gamecenter.wrapper.ToolbarWrapperActivity"
|
||||||
android:screenOrientation="portrait" />
|
android:screenOrientation="portrait" />
|
||||||
|
|
||||||
<activity
|
<activity android:name=".forum.home.CommunityActivity"
|
||||||
android:name=".forum.home.CommunityActivity"
|
android:screenOrientation="portrait"/>
|
||||||
android:screenOrientation="portrait" />
|
|
||||||
|
|
||||||
<activity
|
|
||||||
android:name=".forum.home.follow.FollowDynamicActivity"
|
|
||||||
android:theme="@style/Theme.Transparent" />
|
|
||||||
|
|
||||||
<activity
|
|
||||||
android:name=".forum.home.follow.AllFollowedActivity"
|
|
||||||
android:screenOrientation="portrait"
|
|
||||||
android:theme="@style/AppCompatTheme.APP" />
|
|
||||||
|
|
||||||
<activity
|
|
||||||
android:name=".search.SearchTabActivity"
|
|
||||||
android:configChanges="keyboardHidden"
|
|
||||||
android:screenOrientation="portrait"
|
|
||||||
android:theme="@style/AppCompatTheme.APP" />
|
|
||||||
|
|
||||||
<activity
|
|
||||||
android:name=".video.poster.PosterEditActivity"
|
|
||||||
android:screenOrientation="portrait" />
|
|
||||||
|
|
||||||
<activity
|
|
||||||
android:name="com.halo.assistant.accelerator.MyAssetsActivity"
|
|
||||||
android:screenOrientation="portrait" />
|
|
||||||
|
|
||||||
<!-- <activity-->
|
<!-- <activity-->
|
||||||
<!-- android:name="${applicationId}.douyinapi.DouYinEntryActivity"-->
|
<!-- android:name="${applicationId}.douyinapi.DouYinEntryActivity"-->
|
||||||
@ -834,8 +783,7 @@
|
|||||||
android:name="androidx.core.content.FileProvider"
|
android:name="androidx.core.content.FileProvider"
|
||||||
android:authorities="${applicationId}"
|
android:authorities="${applicationId}"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:grantUriPermissions="true"
|
android:grantUriPermissions="true">
|
||||||
tools:replace="android:authorities">
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||||
android:resource="@xml/provider_paths" />
|
android:resource="@xml/provider_paths" />
|
||||||
@ -879,6 +827,8 @@
|
|||||||
<!-- tools:node="remove" />-->
|
<!-- tools:node="remove" />-->
|
||||||
<!-- </provider>-->
|
<!-- </provider>-->
|
||||||
|
|
||||||
|
<service android:name="com.gh.gamecenter.install.InstallService" />
|
||||||
|
|
||||||
<receiver
|
<receiver
|
||||||
android:name="com.gh.gamecenter.receiver.DownloadReceiver"
|
android:name="com.gh.gamecenter.receiver.DownloadReceiver"
|
||||||
android:exported="false">
|
android:exported="false">
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
app/src/main/assets/lottie/tab_forum.json
Normal file
1
app/src/main/assets/lottie/tab_forum.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"v":"5.6.9","fr":30,"ip":0,"op":20,"w":66,"h":66,"nm":"bottom bar tab/论坛/选中/E","ddd":0,"assets":[{"id":"comp_0","layers":[{"ddd":0,"ind":1,"ty":4,"nm":"白-修正","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[33,33,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":0,"s":[100,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":4,"s":[80,80,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":9,"s":[110,110,100]},{"t":13,"s":[100,100,100]}],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":1,"k":[{"i":{"x":0.667,"y":1},"o":{"x":1,"y":0},"t":0,"s":[{"i":[[0,-0.66],[0,0],[1.38,0],[0,1.38],[0,0],[-0.66,0],[0,0]],"o":[[0,0],[0,1.38],[-1.38,0],[0,0],[0,-0.66],[0,0],[0.66,0]],"v":[[2.5,-1.3],[2.5,0],[0,2.5],[-2.5,0],[-2.5,-1.3],[-1.3,-2.5],[1.3,-2.5]],"c":true}]},{"i":{"x":0,"y":1},"o":{"x":0.333,"y":0},"t":4,"s":[{"i":[[0,-0.66],[0,0],[1.38,0],[0,1.38],[0,0],[-0.66,0],[0,0]],"o":[[0,0],[0,1.38],[-1.38,0],[0,0],[0,-0.66],[0,0],[0.66,0]],"v":[[2.5,-0.102],[2.5,0],[0,2.109],[-2.5,0],[-2.5,-0.102],[-1.3,-1.302],[1.3,-1.302]],"c":true}]},{"i":{"x":0.667,"y":1},"o":{"x":1,"y":0},"t":9,"s":[{"i":[[0,-0.66],[0,0],[1.38,0],[0,1.38],[0,0],[-0.66,0],[0,0]],"o":[[0,0],[0,1.38],[-1.38,0],[0,0],[0,-0.66],[0,0],[0.66,0]],"v":[[2.498,-1.845],[2.5,0],[0,2.734],[-2.5,0],[-2.502,-1.845],[-1.302,-3.045],[1.298,-3.045]],"c":true}]},{"t":13,"s":[{"i":[[0,-0.66],[0,0],[1.38,0],[0,1.38],[0,0],[-0.66,0],[0,0]],"o":[[0,0],[0,1.38],[-1.38,0],[0,0],[0,-0.66],[0,0],[0.66,0]],"v":[[2.5,-1.3],[2.5,0],[0,2.5],[-2.5,0],[-2.5,-1.3],[-1.3,-2.5],[1.3,-2.5]],"c":true}]}],"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[300,300],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"矩形","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":150,"st":0,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"蓝","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[33,33.76,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-1.8,0.42],[-3.44,-0.79],[-0.09,-1.71],[0,0],[0,0],[1.98,-0.1],[0,0],[0,0],[0,0],[0.62,0.57],[0,0],[0,0],[0,0],[0,0],[0,0],[0.2,1.89],[0,0],[0,0],[0,0]],"o":[[3.44,-0.79],[1.74,0.41],[0,0],[0,0],[0,2],[0,0],[0,0],[0,0],[-0.69,0.52],[0,0],[0,0],[0,0],[0,0],[0,0],[-1.94,0],[0,0],[0,0],[0,0],[0,-1.8]],"v":[[-6.39,-8.971],[6.39,-8.971],[9.49,-5.471],[9.5,-5.271],[9.5,3.249],[5.95,6.989],[5.75,6.999],[3.25,6.999],[0.3,9.209],[-1.95,9.089],[-2.06,8.969],[-2.17,8.849],[-2.21,8.779],[-3.4,6.999],[-5.75,6.999],[-9.48,3.639],[-9.49,3.449],[-9.5,3.249],[-9.5,-5.271]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"gf","o":{"a":0,"k":100,"ix":10},"r":1,"bm":0,"g":{"p":3,"k":{"a":0,"k":[0,0.266,0.638,1,0.5,0.242,0.595,1,1,0.217,0.552,1],"ix":9}},"s":{"a":0,"k":[-9.5,-9.561],"ix":5},"e":{"a":0,"k":[9.5,9.561],"ix":6},"t":1,"nm":"color","mn":"ADBE Vector Graphic - G-Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[300,300],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"路径","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":150,"st":0,"bm":0}]}],"layers":[{"ddd":0,"ind":1,"ty":0,"nm":"预合成 1","refId":"comp_0","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[33,33,0],"ix":2},"a":{"a":0,"k":[33,33,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":0,"s":[100,100,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":4,"s":[70,70,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":9,"s":[110,110,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":13,"s":[90,90,100]},{"t":16,"s":[100,100,100]}],"ix":6}},"ao":0,"w":66,"h":66,"ip":0,"op":20,"st":0,"bm":0}],"markers":[]}
|
||||||
1
app/src/main/assets/lottie/tab_game.json
Normal file
1
app/src/main/assets/lottie/tab_game.json
Normal file
File diff suppressed because one or more lines are too long
1
app/src/main/assets/lottie/tab_video.json
Normal file
1
app/src/main/assets/lottie/tab_video.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"v":"5.5.9","fr":30,"ip":0,"op":20,"w":66,"h":66,"nm":"tab_video","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"形状图层 1","parent":2,"sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.771],"y":[0]},"t":0,"s":[0]},{"t":5,"s":[100]}],"ix":11},"r":{"a":0,"k":90,"ix":10},"p":{"a":0,"k":[-3.742,6.835,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[30.937,31.042,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"sr","sy":2,"d":1,"pt":{"a":0,"k":3,"ix":3},"p":{"a":0,"k":[0,0],"ix":4},"r":{"a":0,"k":0,"ix":5},"or":{"a":0,"k":29.286,"ix":7},"os":{"a":0,"k":75,"ix":9},"ix":1,"nm":"多边星形路径 1","mn":"ADBE Vector Shape - Star","hd":false},{"ty":"st","c":{"a":0,"k":[1,1,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":13,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[-20.75,-13.25],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[102.743,88.578],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"多边星形 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":0,"k":0,"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.657],"y":[0]},"t":0,"s":[0]},{"t":8,"s":[100]}],"ix":2},"o":{"a":0,"k":-115,"ix":3},"m":1,"ix":2,"nm":"修剪路径 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":0,"op":60,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"路径 2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[33,33.004,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.508,0.508,0.333],"y":[0,0,0]},"t":0,"s":[100,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.488,0.488,0.333],"y":[0,0,0]},"t":4,"s":[80,80,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.502,0.502,0.333],"y":[0,0,0]},"t":9,"s":[110,110,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.534,0.534,0.333],"y":[0,0,0]},"t":13,"s":[95,95,100]},{"t":16,"s":[100,100,100]}],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[2.16,0.38],[3.22,-0.55],[0.38,-2.16],[-0.55,-3.22],[-2.16,-0.38],[-1.63,0],[-1.61,0.27],[-0.38,2.16],[0.55,3.22]],"o":[[-0.38,-2.16],[-3.22,-0.55],[-2.16,0.38],[-0.55,3.22],[0.38,2.16],[1.61,0.27],[1.63,0],[2.16,-0.38],[0.55,-3.22],[0,0]],"v":[[9.09,-4.86],[4.86,-9.09],[-4.86,-9.09],[-9.09,-4.86],[-9.09,4.86],[-4.86,9.09],[0,9.5],[4.86,9.09],[9.09,4.86],[9.09,-4.86]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"gf","o":{"a":0,"k":100,"ix":10},"r":1,"bm":0,"g":{"p":3,"k":{"a":0,"k":[0,0.266,0.638,1,0.5,0.242,0.595,1,1,0.217,0.552,1],"ix":9}},"s":{"a":0,"k":[-5.174,-4.43],"ix":5},"e":{"a":0,"k":[8.612,8.214],"ix":6},"t":1,"nm":"Gradient Fill 3","mn":"ADBE Vector Graphic - G-Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[300,300],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"路径","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":60,"st":0,"bm":0}],"markers":[]}
|
||||||
@ -588,7 +588,7 @@ document.addEventListener("selectionchange", function(e) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
document.addEventListener("selectionchange", function(e) {
|
document.addEventListener("selectionchange", function(e) {
|
||||||
setTimeout(() => RE.enabledEditingItems(e), 10)
|
RE.enabledEditingItems(e)
|
||||||
});
|
});
|
||||||
|
|
||||||
RE.recursion = function(dom) {
|
RE.recursion = function(dom) {
|
||||||
|
|||||||
@ -4,8 +4,6 @@ import android.annotation.SuppressLint
|
|||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.graphics.drawable.Animatable
|
|
||||||
import android.os.Build
|
|
||||||
import android.os.Message
|
import android.os.Message
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@ -14,26 +12,23 @@ import android.widget.FrameLayout
|
|||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.appcompat.content.res.AppCompatResources
|
import androidx.appcompat.content.res.AppCompatResources
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import com.therouter.TheRouter
|
import com.alibaba.android.arouter.launcher.ARouter
|
||||||
import com.facebook.drawee.controller.BaseControllerListener
|
|
||||||
import com.facebook.drawee.view.SimpleDraweeView
|
import com.facebook.drawee.view.SimpleDraweeView
|
||||||
import com.facebook.imagepipeline.image.ImageInfo
|
|
||||||
import com.g00fy2.versioncompare.Version
|
|
||||||
import com.gh.common.exposure.ExposureManager
|
import com.gh.common.exposure.ExposureManager
|
||||||
import com.gh.common.util.DirectUtils.directToLinkPage
|
import com.gh.common.util.DirectUtils.directToLinkPage
|
||||||
import com.gh.common.util.LogUtils
|
import com.gh.common.util.LogUtils
|
||||||
import com.gh.common.util.NewFlatLogUtils
|
import com.gh.common.util.NewFlatLogUtils.logOpenScreenAdSkip
|
||||||
import com.gh.common.util.PackageUtils
|
import com.gh.common.util.PackageUtils
|
||||||
import com.gh.gamecenter.BuildConfig
|
import com.gh.gamecenter.BuildConfig
|
||||||
import com.gh.gamecenter.MainActivity
|
import com.gh.gamecenter.MainActivity
|
||||||
import com.gh.gamecenter.R
|
import com.gh.gamecenter.R
|
||||||
import com.gh.gamecenter.common.base.activity.BaseActivity
|
import com.gh.gamecenter.common.base.activity.BaseActivity
|
||||||
import com.gh.gamecenter.common.constant.Constants
|
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.exposure.ExposureSource
|
||||||
import com.gh.gamecenter.common.exposure.meta.MetaUtil
|
|
||||||
import com.gh.gamecenter.common.retrofit.BiResponse
|
import com.gh.gamecenter.common.retrofit.BiResponse
|
||||||
import com.gh.gamecenter.common.utils.*
|
import com.gh.gamecenter.common.utils.*
|
||||||
import com.gh.gamecenter.core.AppExecutor
|
import com.gh.gamecenter.core.provider.IBeiziAdProvider
|
||||||
import com.gh.gamecenter.core.provider.ICsjAdProvider
|
import com.gh.gamecenter.core.provider.ICsjAdProvider
|
||||||
import com.gh.gamecenter.core.utils.CurrentActivityHolder
|
import com.gh.gamecenter.core.utils.CurrentActivityHolder
|
||||||
import com.gh.gamecenter.core.utils.SPUtils
|
import com.gh.gamecenter.core.utils.SPUtils
|
||||||
@ -45,18 +40,20 @@ import com.gh.gamecenter.feature.exposure.ExposureType
|
|||||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||||
import com.halo.assistant.HaloApp
|
import com.halo.assistant.HaloApp
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
import java.util.Locale
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 广告实现代理类
|
* 广告实现代理类
|
||||||
*
|
*
|
||||||
* 由它来分发功能实现到具体的实现
|
* 由它来分发功能实现到具体的实现
|
||||||
*
|
*
|
||||||
* 以开屏广告为例,有两种实现(1. 自有的广告实现 2. 穿山甲的开屏广告实现 )
|
* 以最复杂的开屏广告为例,有三种实现(1. 自有的广告实现 2. 穿山甲的开屏广告实现 3. Beizi 的开屏广告实现)
|
||||||
|
*
|
||||||
|
* 由于两个广告 SDK 有可能在一次启动中都被使用,所以会根据获取到的广告配置 config 来决定是否需要出是很好两个 SDK
|
||||||
*/
|
*/
|
||||||
object AdDelegateHelper {
|
object AdDelegateHelper {
|
||||||
|
|
||||||
private var mCsjAdImpl: ICsjAdProvider? = null
|
private var mCsjAdImpl: ICsjAdProvider? = null
|
||||||
|
private var mBeiziAdImpl: IBeiziAdProvider? = null
|
||||||
|
|
||||||
private val mAdConfigList: ArrayList<AdConfig> by lazy { arrayListOf() }
|
private val mAdConfigList: ArrayList<AdConfig> by lazy { arrayListOf() }
|
||||||
|
|
||||||
@ -65,15 +62,11 @@ object AdDelegateHelper {
|
|||||||
private val mGameSearchAdList: ArrayList<AdConfig> by lazy { arrayListOf() }
|
private val mGameSearchAdList: ArrayList<AdConfig> by lazy { arrayListOf() }
|
||||||
private var mVGameLaunchAd: AdConfig? = null
|
private var mVGameLaunchAd: AdConfig? = null
|
||||||
|
|
||||||
private var ownerSplashAdLoadTime = 0L
|
|
||||||
|
|
||||||
val vGameLaunchAd: AdConfig?
|
val vGameLaunchAd: AdConfig?
|
||||||
get() = mVGameLaunchAd
|
get() = mVGameLaunchAd
|
||||||
|
|
||||||
val splashAdDisplayInterval: Int
|
|
||||||
get() = mSplashAd?.ownerAd?.startAd?.displayInterval ?: 3
|
|
||||||
|
|
||||||
private const val AD_SDK_CSJ = "穿山甲"
|
private const val AD_SDK_CSJ = "穿山甲"
|
||||||
|
private const val AD_SDK_BEIZI = "倍孜"
|
||||||
const val AD_TYPE_SDK = "third_party_ads" // 第三方 SDK 广告
|
const val AD_TYPE_SDK = "third_party_ads" // 第三方 SDK 广告
|
||||||
const val AD_TYPE_OWNER = "owner_ads" // 自有广告
|
const val AD_TYPE_OWNER = "owner_ads" // 自有广告
|
||||||
|
|
||||||
@ -84,26 +77,20 @@ object AdDelegateHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var isShowingSplashAd = false // 是否正在显示开屏广告
|
var isShowingSplashAd = false // 是否正在显示开屏广告
|
||||||
var isOwnerSplashAdShown = false // 自有开屏广告是否展示
|
|
||||||
var gameSearchKeyword = ""
|
var gameSearchKeyword = ""
|
||||||
|
|
||||||
fun initAdSdk(context: Context) {
|
fun initAdSdk(context: Context) {
|
||||||
if (AdPluginDownloadHelper.isCsjPluginDownloaded()) {
|
// 初始化 Beizi
|
||||||
initAdSdkInternal(context)
|
if (mBeiziAdImpl == null) {
|
||||||
} else {
|
mBeiziAdImpl =
|
||||||
// 首次启动,为了不影响首页加载,延迟 3 秒再下载广告插件并初始化
|
ARouter.getInstance().build(RouteConsts.provider.beiziAd).navigation() as? IBeiziAdProvider
|
||||||
AppExecutor.uiExecutor.executeWithDelay({
|
mBeiziAdImpl?.initSDK(context)
|
||||||
AdPluginDownloadHelper.downloadPluginIfNeeded(isCsj = true) {
|
|
||||||
initAdSdkInternal(context)
|
|
||||||
}
|
|
||||||
}, 3000L)
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private fun initAdSdkInternal(context: Context) {
|
|
||||||
// 初始化穿山甲
|
// 初始化穿山甲
|
||||||
if (mCsjAdImpl == null) {
|
if (mCsjAdImpl == null) {
|
||||||
mCsjAdImpl = TheRouter.get(ICsjAdProvider::class.java)
|
mCsjAdImpl =
|
||||||
|
ARouter.getInstance().build(RouteConsts.provider.csjAd).navigation() as? ICsjAdProvider
|
||||||
val csjAppId = if (EnvHelper.isDevEnv) BuildConfig.DEV_CSJ_APPID else BuildConfig.CSJ_APPID
|
val csjAppId = if (EnvHelper.isDevEnv) BuildConfig.DEV_CSJ_APPID else BuildConfig.CSJ_APPID
|
||||||
mCsjAdImpl?.initSDK(context, csjAppId, HaloApp.getInstance().oaid)
|
mCsjAdImpl?.initSDK(context, csjAppId, HaloApp.getInstance().oaid)
|
||||||
// 监听亮色/暗色模式切换
|
// 监听亮色/暗色模式切换
|
||||||
@ -123,12 +110,7 @@ object AdDelegateHelper {
|
|||||||
if (isFromRetry && mAdConfigList.isNotEmpty()) {
|
if (isFromRetry && mAdConfigList.isNotEmpty()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
val paramsMap = if (keyword.isNotEmpty()) mapOf("keyword" to keyword) else mapOf()
|
||||||
val paramsMap = if (keyword.isNotEmpty()) {
|
|
||||||
mapOf("keyword" to keyword, "android_sdk_version" to Build.VERSION.SDK_INT)
|
|
||||||
} else {
|
|
||||||
mapOf("android_sdk_version" to Build.VERSION.SDK_INT)
|
|
||||||
}
|
|
||||||
RetrofitManager.getInstance()
|
RetrofitManager.getInstance()
|
||||||
.newApi
|
.newApi
|
||||||
.getAdConfig(paramsMap)
|
.getAdConfig(paramsMap)
|
||||||
@ -186,20 +168,6 @@ object AdDelegateHelper {
|
|||||||
when (config.location) {
|
when (config.location) {
|
||||||
"halo_launch" -> {
|
"halo_launch" -> {
|
||||||
config.ownerAd?.startAd?.let { it.id = config.ownerAd.id }
|
config.ownerAd?.startAd?.let { it.id = config.ownerAd.id }
|
||||||
|
|
||||||
// HarmonyOS 4.2.0 版本不展示第三方开屏广告 (因为会引起奇怪的闪退)
|
|
||||||
if (MetaUtil.getRom().romName == "HarmonyOS"
|
|
||||||
&& Version(MetaUtil.getRom().romVersion).isLowerThan(Version("4.2.0"))
|
|
||||||
&& config.displayRule.adSource == AD_TYPE_SDK
|
|
||||||
) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 华为系 Android 10 不展示第三方开屏广告 (因为会引起奇怪的闪退)
|
|
||||||
if (isBuggyHuaweiDevice() && config.displayRule.adSource == AD_TYPE_SDK) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
mSplashAd = config
|
mSplashAd = config
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,12 +191,10 @@ object AdDelegateHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 热启动是否需要显示开屏广告(目前只展示第三方广告)
|
* 热启动是否需要显示开屏广告
|
||||||
*/
|
*/
|
||||||
private fun shouldShowStartUpAdWhenHotLaunch() = (mCsjAdImpl != null)
|
private fun shouldShowStartUpAdWhenHotLaunch() =
|
||||||
&& mSplashAd?.displayRule?.hotStartSplashAd?.type == AD_TYPE_SDK
|
mSplashAd?.displayRule?.hotStartSplashAd?.type == AD_TYPE_SDK && mSplashAd?.hotStartThirdPartyAd != null
|
||||||
&& mSplashAd?.hotStartThirdPartyAd != null
|
|
||||||
&& !isBuggyHuaweiDevice()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否需要显示下载管理广告
|
* 是否需要显示下载管理广告
|
||||||
@ -237,10 +203,6 @@ object AdDelegateHelper {
|
|||||||
return mDownloadManagerAd != null && !isMatchAdFreeRule(mDownloadManagerAd) && isMatchDownloadManagerAdDisplayRule()
|
return mDownloadManagerAd != null && !isMatchAdFreeRule(mDownloadManagerAd) && isMatchDownloadManagerAdDisplayRule()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun shouldShowHelperLaunchAd(): Boolean {
|
|
||||||
return mVGameLaunchAd != null && !isMatchAdFreeRule(mVGameLaunchAd) && isMatchAdDisplayRule(mVGameLaunchAd, Constants.SP_LAST_HELPER_LAUNCH_AD_SHOW_TIME)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否需要显示游戏搜索广告
|
* 是否需要显示游戏搜索广告
|
||||||
*/
|
*/
|
||||||
@ -269,16 +231,26 @@ object AdDelegateHelper {
|
|||||||
/**
|
/**
|
||||||
* 是否大于开屏广告展示间隔时长
|
* 是否大于开屏广告展示间隔时长
|
||||||
*/
|
*/
|
||||||
private fun isMatchStartUpAdDisplayRule(): Boolean = isMatchAdDisplayRule(mSplashAd, Constants.SP_LAST_SPLASH_AD_SHOW_TIME)
|
private fun isMatchStartUpAdDisplayRule(): Boolean {
|
||||||
|
mSplashAd?.displayRule?.run {
|
||||||
|
if (adDisplayInterval > 0) {
|
||||||
|
val lastShowTime = SPUtils.getLong(Constants.SP_LAST_SPLASH_AD_SHOW_TIME, 0L)
|
||||||
|
val durationInMinutes = (System.currentTimeMillis() - lastShowTime).toFloat() / 1000 / 60
|
||||||
|
return durationInMinutes > adDisplayInterval
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否大于广告管理展示间隔时长
|
* 是否大于广告管理展示间隔时长
|
||||||
*/
|
*/
|
||||||
private fun isMatchDownloadManagerAdDisplayRule(): Boolean = isMatchAdDisplayRule(mDownloadManagerAd, Constants.SP_LAST_DOWNLOAD_MANAGER_AD_SHOW_TIME)
|
private fun isMatchDownloadManagerAdDisplayRule(): Boolean {
|
||||||
private fun isMatchAdDisplayRule(adConfig: AdConfig?, spKey: String): Boolean {
|
mDownloadManagerAd?.displayRule?.run {
|
||||||
adConfig?.displayRule?.run {
|
|
||||||
if (adDisplayInterval > 0) {
|
if (adDisplayInterval > 0) {
|
||||||
val lastShowTime = SPUtils.getLong(spKey, 0L)
|
val lastShowTime = SPUtils.getLong(Constants.SP_LAST_DOWNLOAD_MANAGER_AD_SHOW_TIME, 0L)
|
||||||
val durationInMinutes = (System.currentTimeMillis() - lastShowTime).toFloat() / 1000 / 60
|
val durationInMinutes = (System.currentTimeMillis() - lastShowTime).toFloat() / 1000 / 60
|
||||||
return durationInMinutes > adDisplayInterval
|
return durationInMinutes > adDisplayInterval
|
||||||
} else {
|
} else {
|
||||||
@ -323,7 +295,6 @@ object AdDelegateHelper {
|
|||||||
adViewHeightInDp: Float,
|
adViewHeightInDp: Float,
|
||||||
startAdContainer: ViewGroup,
|
startAdContainer: ViewGroup,
|
||||||
sdkStartAdContainer: ViewGroup,
|
sdkStartAdContainer: ViewGroup,
|
||||||
sdkJumpBtn: TextView,
|
|
||||||
adsViewGroup: FrameLayout,
|
adsViewGroup: FrameLayout,
|
||||||
handler: BaseActivity.BaseHandler,
|
handler: BaseActivity.BaseHandler,
|
||||||
isHotLaunch: Boolean,
|
isHotLaunch: Boolean,
|
||||||
@ -331,7 +302,6 @@ object AdDelegateHelper {
|
|||||||
) {
|
) {
|
||||||
val hideCallback = {
|
val hideCallback = {
|
||||||
isShowingSplashAd = false
|
isShowingSplashAd = false
|
||||||
isOwnerSplashAdShown = false
|
|
||||||
hideAction.invoke()
|
hideAction.invoke()
|
||||||
}
|
}
|
||||||
if (mSplashAd != null) {
|
if (mSplashAd != null) {
|
||||||
@ -346,7 +316,6 @@ object AdDelegateHelper {
|
|||||||
adViewHeightInDp,
|
adViewHeightInDp,
|
||||||
startAdContainer,
|
startAdContainer,
|
||||||
sdkStartAdContainer,
|
sdkStartAdContainer,
|
||||||
sdkJumpBtn,
|
|
||||||
adsViewGroup,
|
adsViewGroup,
|
||||||
handler,
|
handler,
|
||||||
isHotLaunch,
|
isHotLaunch,
|
||||||
@ -364,7 +333,6 @@ object AdDelegateHelper {
|
|||||||
adViewHeightInDp,
|
adViewHeightInDp,
|
||||||
startAdContainer,
|
startAdContainer,
|
||||||
sdkStartAdContainer,
|
sdkStartAdContainer,
|
||||||
sdkJumpBtn,
|
|
||||||
adsViewGroup,
|
adsViewGroup,
|
||||||
handler,
|
handler,
|
||||||
isHotLaunch,
|
isHotLaunch,
|
||||||
@ -388,7 +356,6 @@ object AdDelegateHelper {
|
|||||||
adViewHeightInDp: Float,
|
adViewHeightInDp: Float,
|
||||||
startAdContainer: ViewGroup,
|
startAdContainer: ViewGroup,
|
||||||
sdkStartAdContainer: ViewGroup,
|
sdkStartAdContainer: ViewGroup,
|
||||||
sdkJumpBtn: TextView,
|
|
||||||
adsViewGroup: FrameLayout,
|
adsViewGroup: FrameLayout,
|
||||||
handler: BaseActivity.BaseHandler,
|
handler: BaseActivity.BaseHandler,
|
||||||
isHotLaunch: Boolean,
|
isHotLaunch: Boolean,
|
||||||
@ -410,7 +377,6 @@ object AdDelegateHelper {
|
|||||||
adViewHeightInDp,
|
adViewHeightInDp,
|
||||||
startAdContainer,
|
startAdContainer,
|
||||||
sdkStartAdContainer,
|
sdkStartAdContainer,
|
||||||
sdkJumpBtn,
|
|
||||||
adsViewGroup,
|
adsViewGroup,
|
||||||
handler,
|
handler,
|
||||||
isHotLaunch,
|
isHotLaunch,
|
||||||
@ -436,18 +402,20 @@ object AdDelegateHelper {
|
|||||||
((mSplashAd?.displayRule?.timeout ?: 3.5F) * 1000).toInt()
|
((mSplashAd?.displayRule?.timeout ?: 3.5F) * 1000).toInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thirdPartyAd.sourceName == AD_SDK_CSJ) {
|
if (thirdPartyAd.sourceName == AD_SDK_BEIZI) {
|
||||||
|
sdkStartAdContainer.visibility = View.VISIBLE
|
||||||
|
requestBeiziSplashAd(sdkStartAdContainer, adsViewGroup, adViewWidthInPx, adViewHeightInPx, timeout.toLong(), sdkSplashCallback)
|
||||||
|
} else if (thirdPartyAd.sourceName == AD_SDK_CSJ) {
|
||||||
sdkStartAdContainer.visibility = View.VISIBLE
|
sdkStartAdContainer.visibility = View.VISIBLE
|
||||||
requestCsjSplashAd(
|
requestCsjSplashAd(
|
||||||
activity,
|
activity,
|
||||||
|
thirdPartyAd.slotId,
|
||||||
adViewWidthInPx,
|
adViewWidthInPx,
|
||||||
adViewHeightInPx,
|
adViewHeightInPx,
|
||||||
adViewWidthInDp,
|
adViewWidthInDp,
|
||||||
adViewHeightInDp,
|
adViewHeightInDp,
|
||||||
sdkStartAdContainer,
|
sdkStartAdContainer,
|
||||||
sdkJumpBtn,
|
|
||||||
timeout,
|
timeout,
|
||||||
isHotLaunch,
|
|
||||||
sdkSplashCallback
|
sdkSplashCallback
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -458,70 +426,50 @@ object AdDelegateHelper {
|
|||||||
*/
|
*/
|
||||||
private fun requestCsjSplashAd(
|
private fun requestCsjSplashAd(
|
||||||
activity: Activity,
|
activity: Activity,
|
||||||
|
slotId: String,
|
||||||
adViewWidthInPx: Int,
|
adViewWidthInPx: Int,
|
||||||
adViewHeightInPx: Int,
|
adViewHeightInPx: Int,
|
||||||
adViewWidthInDp: Float,
|
adViewWidthInDp: Float,
|
||||||
adViewHeightInDp: Float,
|
adViewHeightInDp: Float,
|
||||||
startAdContainer: ViewGroup,
|
startAdContainer: ViewGroup,
|
||||||
sdkJumpBtn: TextView,
|
|
||||||
timeout: Int,
|
timeout: Int,
|
||||||
isHotLaunch: Boolean,
|
|
||||||
callback: (isSuccess: Boolean) -> Unit,
|
callback: (isSuccess: Boolean) -> Unit,
|
||||||
) {
|
) {
|
||||||
val thirdPartyAd = if (isHotLaunch) mSplashAd?.hotStartThirdPartyAd else mSplashAd?.thirdPartyAd
|
if (mCsjAdImpl == null) {
|
||||||
if (mCsjAdImpl == null || thirdPartyAd == null) {
|
|
||||||
callback.invoke(false)
|
callback.invoke(false)
|
||||||
} else {
|
} else {
|
||||||
sdkJumpBtn.setOnClickListener {
|
|
||||||
callback.invoke(true)
|
|
||||||
if (activity is BaseActivity) {
|
|
||||||
activity.baseHandler.removeMessages(MainActivity.COUNTDOWN_SDK_AD)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val onAdShowAction = {
|
|
||||||
sdkJumpBtn.visibility = View.VISIBLE
|
|
||||||
if (activity is BaseActivity) {
|
|
||||||
activity.baseHandler.sendEmptyMessageDelayed(MainActivity.COUNTDOWN_SDK_AD, 1000)
|
|
||||||
}
|
|
||||||
SensorsBridge.trackEvent("ThirdPartyAdShow",
|
|
||||||
"ad_source", thirdPartyAd.sourceName,
|
|
||||||
"ad_id", thirdPartyAd.slotId,
|
|
||||||
"ad_format", mSplashAd?.typeChinese ?: "",
|
|
||||||
"ad_placement", "光环启动",
|
|
||||||
"launch_type", if (isHotLaunch) "热启动" else "冷启动",
|
|
||||||
"ad_space_id", mSplashAd?.id ?: "",
|
|
||||||
"ad_space_name", mSplashAd?.name ?: ""
|
|
||||||
)
|
|
||||||
}
|
|
||||||
val onAdClickAction = {
|
|
||||||
callback.invoke(true)
|
|
||||||
SensorsBridge.trackEvent("ThirdPartyAdClick",
|
|
||||||
"ad_source", thirdPartyAd.sourceName,
|
|
||||||
"ad_id", thirdPartyAd.slotId,
|
|
||||||
"ad_format", mSplashAd?.typeChinese ?: "",
|
|
||||||
"ad_placement", "光环启动",
|
|
||||||
"launch_type", if (isHotLaunch) "热启动" else "冷启动",
|
|
||||||
"ad_space_id", mSplashAd?.id ?: "",
|
|
||||||
"ad_space_name", mSplashAd?.name ?: ""
|
|
||||||
)
|
|
||||||
}
|
|
||||||
mCsjAdImpl?.requestSplashAd(
|
mCsjAdImpl?.requestSplashAd(
|
||||||
activity,
|
activity,
|
||||||
thirdPartyAd.slotId,
|
slotId,
|
||||||
adViewWidthInPx,
|
adViewWidthInPx,
|
||||||
adViewHeightInPx,
|
adViewHeightInPx,
|
||||||
adViewWidthInDp,
|
adViewWidthInDp,
|
||||||
adViewHeightInDp,
|
adViewHeightInDp,
|
||||||
startAdContainer,
|
startAdContainer,
|
||||||
timeout,
|
timeout,
|
||||||
onAdShowAction,
|
|
||||||
onAdClickAction,
|
|
||||||
callback,
|
callback,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 Beizi 的开屏广告
|
||||||
|
*/
|
||||||
|
private fun requestBeiziSplashAd(
|
||||||
|
startAdContainer: View,
|
||||||
|
adsFl: FrameLayout,
|
||||||
|
adViewWidthInPx: Int,
|
||||||
|
adViewHeightInPx: Int,
|
||||||
|
timeout: Long,
|
||||||
|
callback: (isSuccess: Boolean) -> Unit,
|
||||||
|
) {
|
||||||
|
if (mBeiziAdImpl == null) {
|
||||||
|
callback.invoke(false)
|
||||||
|
} else {
|
||||||
|
mBeiziAdImpl?.requestSplashAd(startAdContainer, adsFl, adViewWidthInPx, adViewHeightInPx, timeout, callback)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 显示自有的开屏广告
|
* 显示自有的开屏广告
|
||||||
*/
|
*/
|
||||||
@ -533,7 +481,6 @@ object AdDelegateHelper {
|
|||||||
adViewHeightInDp: Float,
|
adViewHeightInDp: Float,
|
||||||
startAdContainer: ViewGroup,
|
startAdContainer: ViewGroup,
|
||||||
sdkStartAdContainer: ViewGroup,
|
sdkStartAdContainer: ViewGroup,
|
||||||
sdkJumpBtn: TextView,
|
|
||||||
adsViewGroup: FrameLayout,
|
adsViewGroup: FrameLayout,
|
||||||
handler: BaseActivity.BaseHandler,
|
handler: BaseActivity.BaseHandler,
|
||||||
isHotLaunch: Boolean,
|
isHotLaunch: Boolean,
|
||||||
@ -551,7 +498,6 @@ object AdDelegateHelper {
|
|||||||
adViewHeightInDp,
|
adViewHeightInDp,
|
||||||
startAdContainer,
|
startAdContainer,
|
||||||
sdkStartAdContainer,
|
sdkStartAdContainer,
|
||||||
sdkJumpBtn,
|
|
||||||
adsViewGroup,
|
adsViewGroup,
|
||||||
handler,
|
handler,
|
||||||
isHotLaunch,
|
isHotLaunch,
|
||||||
@ -604,17 +550,12 @@ object AdDelegateHelper {
|
|||||||
handler: BaseActivity.BaseHandler,
|
handler: BaseActivity.BaseHandler,
|
||||||
hideCallback: () -> Unit
|
hideCallback: () -> Unit
|
||||||
) {
|
) {
|
||||||
isOwnerSplashAdShown = false
|
val jumpBtn: View = startAdContainer.findViewById(R.id.jumpBtn)
|
||||||
|
|
||||||
val jumpBtn = startAdContainer.findViewById<TextView>(R.id.jumpBtn)
|
|
||||||
val jumpDetailBtn: TextView = startAdContainer.findViewById(R.id.jumpDetailBtn)
|
val jumpDetailBtn: TextView = startAdContainer.findViewById(R.id.jumpDetailBtn)
|
||||||
val adImage: SimpleDraweeView = startAdContainer.findViewById(R.id.adImage)
|
val adImage: SimpleDraweeView = startAdContainer.findViewById(R.id.adImage)
|
||||||
val adVideo = startAdContainer.findViewById<SplashAdVideoView>(R.id.ad_video)
|
|
||||||
val icpContainer: View? = startAdContainer.findViewById(R.id.startAdIcpContainer)
|
val icpContainer: View? = startAdContainer.findViewById(R.id.startAdIcpContainer)
|
||||||
startAdContainer.visibility = View.VISIBLE
|
startAdContainer.visibility = View.VISIBLE
|
||||||
icpContainer?.visibility = View.VISIBLE
|
icpContainer?.visibility = View.VISIBLE
|
||||||
jumpBtn.text = startAdContainer.context.getString(R.string.splash_jump, splashAdDisplayInterval)
|
|
||||||
|
|
||||||
jumpDetailBtn.text = ad.desc
|
jumpDetailBtn.text = ad.desc
|
||||||
jumpDetailBtn.setDrawableEnd(
|
jumpDetailBtn.setDrawableEnd(
|
||||||
AppCompatResources.getDrawable(
|
AppCompatResources.getDrawable(
|
||||||
@ -622,64 +563,31 @@ object AdDelegateHelper {
|
|||||||
R.drawable.ic_startup_ad_arrow
|
R.drawable.ic_startup_ad_arrow
|
||||||
), null, null
|
), null, null
|
||||||
)
|
)
|
||||||
|
ImageUtils.display(adImage, ad.img)
|
||||||
if (ad.isImageType) {
|
|
||||||
adVideo.visibleIf(false)
|
|
||||||
adImage.visibleIf(true)
|
|
||||||
ImageUtils.displayWithCallback(adImage, ad.img, true, object : BaseControllerListener<ImageInfo>() {
|
|
||||||
override fun onSubmit(id: String?, callerContext: Any?) {
|
|
||||||
super.onSubmit(id, callerContext)
|
|
||||||
adImage.post {
|
|
||||||
ownerSplashAdLoadTime = System.currentTimeMillis()
|
|
||||||
NewFlatLogUtils.logSplashAdLoad(ad.id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onFinalImageSet(id: String?, imageInfo: ImageInfo?, animatable: Animatable?) {
|
|
||||||
isOwnerSplashAdShown = true
|
|
||||||
adImage.post {
|
|
||||||
NewFlatLogUtils.logSplashAdShow(ad.id, System.currentTimeMillis() - ownerSplashAdLoadTime)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onFailure(id: String?, throwable: Throwable?) {
|
|
||||||
super.onFailure(id, throwable)
|
|
||||||
NewFlatLogUtils.logSplashAdFail(ad.id, "启动广告图加载失败")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
adImage.visibleIf(false)
|
|
||||||
adVideo.startPlay(ad.video.url)
|
|
||||||
}
|
|
||||||
startAdContainer.setOnClickListener {
|
startAdContainer.setOnClickListener {
|
||||||
// 拦截点击事件传递
|
// 拦截点击事件传递
|
||||||
}
|
}
|
||||||
jumpBtn.setOnClickListener {
|
jumpBtn.setOnClickListener {
|
||||||
it.debounceActionWithInterval(1000L) {
|
handler.removeMessages(MainActivity.COUNTDOWN_AD)
|
||||||
if (!isOwnerSplashAdShown) {
|
hideCallback.invoke()
|
||||||
NewFlatLogUtils.logSplashAdFail(ad.id, "加载过程中点击跳过广告")
|
val linkEntity = ad.jump
|
||||||
}
|
logOpenScreenAdSkip(
|
||||||
handler.removeMessages(MainActivity.COUNTDOWN_AD)
|
ad.id,
|
||||||
hideCallback.invoke()
|
(if (linkEntity.text != null) linkEntity.text else "")!!,
|
||||||
val linkEntity = ad.jump
|
(if (linkEntity.type != null) linkEntity.type else "")!!,
|
||||||
NewFlatLogUtils.logOpenScreenAdSkip(
|
(if (linkEntity.link != null) linkEntity.link else "")!!
|
||||||
ad.id,
|
)
|
||||||
(if (linkEntity.text != null) linkEntity.text else "")!!,
|
SensorsBridge.trackEvent(
|
||||||
(if (linkEntity.type != null) linkEntity.type else "")!!,
|
"SplashAdOwnSkip",
|
||||||
(if (linkEntity.link != null) linkEntity.link else "")!!
|
"splash_ad_id",
|
||||||
)
|
ad.id,
|
||||||
SensorsBridge.trackEvent(
|
"link_type",
|
||||||
"SplashAdOwnSkip",
|
linkEntity.type ?: "",
|
||||||
"splash_ad_id",
|
"link_id",
|
||||||
ad.id,
|
linkEntity.link ?: "",
|
||||||
"link_type",
|
"link_text",
|
||||||
linkEntity.type ?: "",
|
linkEntity.text ?: ""
|
||||||
"link_id",
|
)
|
||||||
linkEntity.link ?: "",
|
|
||||||
"link_text",
|
|
||||||
linkEntity.text ?: ""
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
val sources: MutableList<ExposureSource> = ArrayList()
|
val sources: MutableList<ExposureSource> = ArrayList()
|
||||||
sources.add(ExposureSource("开屏广告", ad.id))
|
sources.add(ExposureSource("开屏广告", ad.id))
|
||||||
@ -725,11 +633,9 @@ object AdDelegateHelper {
|
|||||||
slotId: String,
|
slotId: String,
|
||||||
adContainerView: ViewGroup,
|
adContainerView: ViewGroup,
|
||||||
expressViewWidth: Float,
|
expressViewWidth: Float,
|
||||||
onAdShowAction: () -> Unit,
|
|
||||||
onAdClickAction: () -> Unit,
|
|
||||||
callback: (isSuccess: Boolean) -> Unit,
|
callback: (isSuccess: Boolean) -> Unit,
|
||||||
) {
|
) {
|
||||||
mCsjAdImpl?.requestFlowAd(fragment, adContainerView, slotId, expressViewWidth, onAdShowAction, onAdClickAction, callback)
|
mCsjAdImpl?.requestFlowAd(fragment, adContainerView, slotId, expressViewWidth, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -740,8 +646,6 @@ object AdDelegateHelper {
|
|||||||
containerView: ViewGroup,
|
containerView: ViewGroup,
|
||||||
ad: AdConfig.ThirdPartyAd,
|
ad: AdConfig.ThirdPartyAd,
|
||||||
expressViewWidthInDp: Float,
|
expressViewWidthInDp: Float,
|
||||||
onAdShowAction: () -> Unit,
|
|
||||||
onAdClickAction: () -> Unit,
|
|
||||||
callback: (isSuccess: Boolean) -> Unit
|
callback: (isSuccess: Boolean) -> Unit
|
||||||
) {
|
) {
|
||||||
|
|
||||||
@ -764,28 +668,6 @@ object AdDelegateHelper {
|
|||||||
slotId,
|
slotId,
|
||||||
expressViewWidthInDp,
|
expressViewWidthInDp,
|
||||||
expressViewHeightInDp,
|
expressViewHeightInDp,
|
||||||
onAdShowAction,
|
|
||||||
onAdClickAction,
|
|
||||||
callback
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取第三方 全屏/插屏 广告
|
|
||||||
*/
|
|
||||||
fun requestFullScreenAd(
|
|
||||||
fragment: Fragment,
|
|
||||||
ad: AdConfig.ThirdPartyAd,
|
|
||||||
onAdShowAction: () -> Unit,
|
|
||||||
onAdClickAction: () -> Unit,
|
|
||||||
callback: (isSuccess: Boolean) -> Unit
|
|
||||||
) {
|
|
||||||
val slotId = ad.slotId
|
|
||||||
mCsjAdImpl?.requestFullScreenAd(
|
|
||||||
fragment,
|
|
||||||
slotId,
|
|
||||||
onAdShowAction,
|
|
||||||
onAdClickAction,
|
|
||||||
callback
|
callback
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -794,19 +676,8 @@ object AdDelegateHelper {
|
|||||||
* 取消开屏广告
|
* 取消开屏广告
|
||||||
*/
|
*/
|
||||||
fun cancelSplashAd(context: Context) {
|
fun cancelSplashAd(context: Context) {
|
||||||
|
mBeiziAdImpl?.cancelSplashAd(context)
|
||||||
mCsjAdImpl?.cancelSplashAd(context)
|
mCsjAdImpl?.cancelSplashAd(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否为有问题的华为系 Android 10 设备
|
|
||||||
*/
|
|
||||||
private fun isBuggyHuaweiDevice(): Boolean {
|
|
||||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.Q) {
|
|
||||||
val manufacturer = Build.MANUFACTURER.lowercase(Locale.CHINA) ?: ""
|
|
||||||
return manufacturer == "huawei" || manufacturer == "honor"
|
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,149 +0,0 @@
|
|||||||
package com.gh.ad
|
|
||||||
|
|
||||||
import com.gh.download.simple.DownloadMessageHandler
|
|
||||||
import com.gh.download.simple.SimpleDownloadDatabase
|
|
||||||
import com.gh.download.simple.SimpleDownloadManager
|
|
||||||
import com.gh.gamecenter.core.runOnIoThread
|
|
||||||
import com.gh.gamecenter.core.utils.PluginRedirectHelper
|
|
||||||
import com.gh.gamecenter.core.utils.SPUtils
|
|
||||||
import com.lg.download.DownloadError
|
|
||||||
import com.lg.download.DownloadStatus
|
|
||||||
import com.lg.download.httpclient.DefaultHttpClient
|
|
||||||
import com.lg.download.listener.InnerDownloadListener
|
|
||||||
import com.lg.ndownload.DownloadConfig
|
|
||||||
import com.lg.ndownload.DownloadConfigBuilder
|
|
||||||
import com.lg.ndownload.DownloadIoExecutor
|
|
||||||
import com.lightgame.utils.Utils
|
|
||||||
import java.lang.Exception
|
|
||||||
import java.net.URLConnection
|
|
||||||
|
|
||||||
object AdPluginDownloadHelper : InnerDownloadListener {
|
|
||||||
|
|
||||||
private const val CSJ_FILE_NAME = "1832823466"
|
|
||||||
private const val GDT_FILE_NAME = "gdt_plugin/gdtadv2.jar"
|
|
||||||
|
|
||||||
private const val CSJ_PLUGIN_URL = "https://and-static.ghzs66.com/android/static/1832823466"
|
|
||||||
private const val GDT_PLUGIN_URL = "https://and-static.ghzs66.com/android/static/gdtadv2.jar"
|
|
||||||
|
|
||||||
private var csjDownloadedCallback: (() -> Unit)? = null
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否已经下载了广告插件
|
|
||||||
*/
|
|
||||||
fun isCsjPluginDownloaded(): Boolean {
|
|
||||||
return SPUtils.getBoolean(CSJ_FILE_NAME, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 下载广告插件并初始化 (初始化限定穿山甲)
|
|
||||||
*/
|
|
||||||
fun downloadPluginIfNeeded(isCsj: Boolean = false, isGdt: Boolean = false, csjCallback: (() -> Unit)? = null) {
|
|
||||||
val isCsjPluginDownloaded = SPUtils.getBoolean(CSJ_FILE_NAME, false)
|
|
||||||
val isGdtPluginDownloaded = SPUtils.getBoolean(GDT_FILE_NAME, false)
|
|
||||||
|
|
||||||
if (isCsj && isCsjPluginDownloaded) {
|
|
||||||
csjCallback?.invoke()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isGdt && isGdtPluginDownloaded) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
runOnIoThread {
|
|
||||||
csjDownloadedCallback = csjCallback
|
|
||||||
|
|
||||||
DownloadMessageHandler.init(SimpleDownloadDatabase.instance.downloadDao())
|
|
||||||
|
|
||||||
if (!isCsjPluginDownloaded && isCsj) {
|
|
||||||
val csjPluginConfig = DownloadConfigBuilder()
|
|
||||||
.setUniqueId(CSJ_FILE_NAME)
|
|
||||||
.setUrl(CSJ_PLUGIN_URL)
|
|
||||||
.setFileName(CSJ_FILE_NAME)
|
|
||||||
.setHttpClient(DefaultHttpClient())
|
|
||||||
.setDownloadThreadSize(2)
|
|
||||||
.setPathToStore(PluginRedirectHelper.getAssetDir())
|
|
||||||
.setDownloadExecutor(DownloadIoExecutor.getInstance())
|
|
||||||
.setDownloadListener(this).build()
|
|
||||||
|
|
||||||
SimpleDownloadManager.download(csjPluginConfig)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isGdtPluginDownloaded && isGdt) {
|
|
||||||
val gdtPluginConfig = DownloadConfigBuilder()
|
|
||||||
.setUniqueId(GDT_FILE_NAME)
|
|
||||||
.setUrl(GDT_PLUGIN_URL)
|
|
||||||
.setFileName(GDT_FILE_NAME)
|
|
||||||
.setHttpClient(DefaultHttpClient())
|
|
||||||
.setDownloadThreadSize(2)
|
|
||||||
.setPathToStore(PluginRedirectHelper.getAssetDir())
|
|
||||||
.setDownloadExecutor(DownloadIoExecutor.getInstance())
|
|
||||||
.setDownloadListener(this).build()
|
|
||||||
|
|
||||||
SimpleDownloadManager.download(gdtPluginConfig)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onError(id: String?, error: DownloadError?, exception: Exception?) {
|
|
||||||
Utils.log("下载广告插件失败 $id")
|
|
||||||
id?.let {
|
|
||||||
if (it == CSJ_FILE_NAME) {
|
|
||||||
csjDownloadedCallback = null
|
|
||||||
}
|
|
||||||
SimpleDownloadManager.cancel(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onProgress(id: String?, progress: Float) {
|
|
||||||
Utils.log("下载广告插件进度 $id $progress")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onProgressWithoutThrottle(id: String?, progress: Float) {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onSizeReceived(id: String?, fileSize: Long) {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onReadyToDownload(id: String?, actualThreadSize: Int) {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onStatusChanged(id: String?, status: DownloadStatus?) {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDownloadComplete(id: String?, elapsedTime: Long) {
|
|
||||||
id?.let {
|
|
||||||
// id 即为插件名
|
|
||||||
SPUtils.setBoolean(it, true)
|
|
||||||
if (it == CSJ_FILE_NAME) {
|
|
||||||
csjDownloadedCallback?.invoke()
|
|
||||||
csjDownloadedCallback = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onSpeedChanged(id: String?, speed: Float) {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onRedirectingUrl(
|
|
||||||
id: String?,
|
|
||||||
connection: URLConnection?,
|
|
||||||
config: DownloadConfig?
|
|
||||||
) {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onRedirectedUrl(
|
|
||||||
id: String?,
|
|
||||||
connection: URLConnection?,
|
|
||||||
redirectedUrl: String?
|
|
||||||
) {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,102 +0,0 @@
|
|||||||
package com.gh.ad
|
|
||||||
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.view.ViewStub
|
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import com.gh.gamecenter.common.constant.Constants
|
|
||||||
import com.gh.gamecenter.common.provider.ILaunchAd
|
|
||||||
import com.gh.gamecenter.common.utils.SensorsBridge
|
|
||||||
import com.gh.gamecenter.common.utils.goneIf
|
|
||||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
|
||||||
import com.gh.gamecenter.core.utils.SPUtils
|
|
||||||
import com.gh.gamecenter.entity.AdConfig
|
|
||||||
|
|
||||||
@com.therouter.inject.ServiceProvider
|
|
||||||
class LaunchAdImpl : ILaunchAd {
|
|
||||||
|
|
||||||
override fun requestAd(fragment: Fragment, container: ViewGroup, maskView: View, topViewStub: ViewStub, bottomViewStub: ViewStub, adClickAction: () -> Unit): View {
|
|
||||||
if (AdDelegateHelper.shouldShowHelperLaunchAd()) {
|
|
||||||
val launchAd = AdDelegateHelper.vGameLaunchAd
|
|
||||||
val showThirdPartyAd = launchAd?.displayRule?.adSource == AdDelegateHelper.AD_TYPE_SDK
|
|
||||||
val thirdPartyAd = launchAd?.thirdPartyAd
|
|
||||||
if (showThirdPartyAd && thirdPartyAd != null) {
|
|
||||||
val onAdShowAction = {
|
|
||||||
SensorsBridge.trackEvent("ThirdPartyAdShow",
|
|
||||||
"ad_source", thirdPartyAd.sourceName,
|
|
||||||
"ad_id", thirdPartyAd.slotId,
|
|
||||||
"ad_format", launchAd.typeChinese,
|
|
||||||
"ad_placement", AD_PLACEMENT,
|
|
||||||
"ad_space_id", launchAd.id,
|
|
||||||
"ad_space_name", launchAd.name
|
|
||||||
)
|
|
||||||
}
|
|
||||||
val onAdClickAction = {
|
|
||||||
SensorsBridge.trackEvent("ThirdPartyAdClick",
|
|
||||||
"ad_source", thirdPartyAd.sourceName,
|
|
||||||
"ad_id", thirdPartyAd.slotId,
|
|
||||||
"ad_format", launchAd.typeChinese,
|
|
||||||
"ad_placement", AD_PLACEMENT,
|
|
||||||
"ad_space_id", launchAd.id,
|
|
||||||
"ad_space_name", launchAd.name
|
|
||||||
)
|
|
||||||
adClickAction.invoke()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (launchAd.type == AdConfig.TYPE_BANNER) {
|
|
||||||
requestBannerAd(fragment, container, maskView, thirdPartyAd, onAdShowAction, onAdClickAction)
|
|
||||||
return topViewStub.inflate()
|
|
||||||
} else if (launchAd.type == AdConfig.TYPE_INTERSTITIAL) {
|
|
||||||
requestFullScreenAd(fragment, thirdPartyAd, onAdShowAction, onAdClickAction)
|
|
||||||
return bottomViewStub.inflate()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return bottomViewStub.inflate()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun requestBannerAd(
|
|
||||||
fragment: Fragment,
|
|
||||||
container: ViewGroup,
|
|
||||||
maskView: View,
|
|
||||||
thirdPartyAd: AdConfig.ThirdPartyAd,
|
|
||||||
onAdShowAction: () -> Unit,
|
|
||||||
onAdClickAction: () -> Unit,
|
|
||||||
) {
|
|
||||||
AdDelegateHelper.requestThirdPartyBannerAd(
|
|
||||||
fragment,
|
|
||||||
container,
|
|
||||||
thirdPartyAd,
|
|
||||||
DisplayUtils.getScreenWidthInDp(fragment.requireActivity()),
|
|
||||||
onAdShowAction,
|
|
||||||
onAdClickAction
|
|
||||||
) { isSuccess ->
|
|
||||||
maskView.goneIf(!isSuccess)
|
|
||||||
if (isSuccess) {
|
|
||||||
SPUtils.setLong(Constants.SP_LAST_HELPER_LAUNCH_AD_SHOW_TIME, System.currentTimeMillis())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun requestFullScreenAd(
|
|
||||||
fragment: Fragment,
|
|
||||||
thirdPartyAd: AdConfig.ThirdPartyAd,
|
|
||||||
onAdShowAction: () -> Unit,
|
|
||||||
onAdClickAction: () -> Unit
|
|
||||||
) {
|
|
||||||
AdDelegateHelper.requestFullScreenAd(
|
|
||||||
fragment,
|
|
||||||
thirdPartyAd,
|
|
||||||
onAdShowAction,
|
|
||||||
onAdClickAction
|
|
||||||
) { isSuccess ->
|
|
||||||
if (isSuccess) {
|
|
||||||
SPUtils.setLong(Constants.SP_LAST_HELPER_LAUNCH_AD_SHOW_TIME, System.currentTimeMillis())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
private const val AD_PLACEMENT = "畅玩启动"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,88 +0,0 @@
|
|||||||
package com.gh.ad
|
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import android.content.Context
|
|
||||||
import android.util.AttributeSet
|
|
||||||
import android.view.WindowManager
|
|
||||||
import com.gh.gamecenter.R
|
|
||||||
import com.gh.gamecenter.video.detail.CustomManager
|
|
||||||
import com.shuyu.gsyvideoplayer.utils.GSYVideoType
|
|
||||||
import com.shuyu.gsyvideoplayer.utils.GSYVideoType.SCREEN_TYPE_FULL
|
|
||||||
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer
|
|
||||||
import com.shuyu.gsyvideoplayer.video.base.GSYVideoViewBridge
|
|
||||||
|
|
||||||
class SplashAdVideoView @JvmOverloads constructor(
|
|
||||||
context: Context,
|
|
||||||
attrs: AttributeSet? = null
|
|
||||||
) :
|
|
||||||
StandardGSYVideoPlayer(context, attrs) {
|
|
||||||
|
|
||||||
fun startPlay(url: String) {
|
|
||||||
GSYVideoType.setShowType(SCREEN_TYPE_FULL)
|
|
||||||
GSYVideoType.setRenderType(GSYVideoType.SUFRACE)
|
|
||||||
CustomManager.getCustomManager(getKey()).isNeedMute = true
|
|
||||||
|
|
||||||
setUp(url, true, "")
|
|
||||||
|
|
||||||
setNeedAutoAdaptation(false)
|
|
||||||
startPlayLogic()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getGSYVideoManager(): GSYVideoViewBridge {
|
|
||||||
CustomManager.getCustomManager(getKey()).initContext(context.applicationContext)
|
|
||||||
return CustomManager.getCustomManager(getKey())
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getKey() = "splash_ad"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 覆盖父类方法,防止在是视频 Preparing 阶段封面图被隐藏,导致白屏
|
|
||||||
*/
|
|
||||||
override fun changeUiToPreparingShow() = Unit
|
|
||||||
|
|
||||||
override fun getLayoutId(): Int {
|
|
||||||
return R.layout.layout_splash_ad_video
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun touchSurfaceMoveFullLogic(absDeltaX: Float, absDeltaY: Float) {
|
|
||||||
// no nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onPrepared() {
|
|
||||||
super.onPrepared()
|
|
||||||
|
|
||||||
visibility = VISIBLE
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onAutoCompletion() {
|
|
||||||
setStateAndUi(CURRENT_STATE_AUTO_COMPLETE);
|
|
||||||
|
|
||||||
mSaveChangeViewTIme = 0
|
|
||||||
mCurrentPosition = 0
|
|
||||||
|
|
||||||
if (!mIfCurrentIsFullscreen) {
|
|
||||||
getGSYVideoManager().setLastListener(null)
|
|
||||||
}
|
|
||||||
mAudioManager.abandonAudioFocus(onAudioFocusChangeListener);
|
|
||||||
if (mContext is Activity) {
|
|
||||||
try {
|
|
||||||
(mContext as Activity).getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
e.printStackTrace()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
releaseNetWorkState()
|
|
||||||
|
|
||||||
if (mVideoAllCallBack != null && isCurrentMediaListener()) {
|
|
||||||
mVideoAllCallBack.onAutoComplete(mOriginUrl, mTitle, this)
|
|
||||||
}
|
|
||||||
mHadPlay = false
|
|
||||||
}
|
|
||||||
|
|
||||||
fun clearAll() {
|
|
||||||
GSYVideoType.setShowType(GSYVideoType.SCREEN_TYPE_DEFAULT)
|
|
||||||
GSYVideoType.setRenderType(GSYVideoType.TEXTURE)
|
|
||||||
release()
|
|
||||||
CustomManager.removeManager(getKey())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -21,31 +21,23 @@ import com.gh.common.view.RichEditor
|
|||||||
import com.gh.gamecenter.CropImageActivity
|
import com.gh.gamecenter.CropImageActivity
|
||||||
import com.gh.gamecenter.R
|
import com.gh.gamecenter.R
|
||||||
import com.gh.gamecenter.common.base.activity.ToolBarActivity
|
import com.gh.gamecenter.common.base.activity.ToolBarActivity
|
||||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
|
||||||
import com.gh.gamecenter.common.constant.RouteConsts
|
|
||||||
import com.gh.gamecenter.common.entity.LocalVideoEntity
|
|
||||||
import com.gh.gamecenter.common.utils.*
|
import com.gh.gamecenter.common.utils.*
|
||||||
import com.gh.gamecenter.core.AppExecutor
|
import com.gh.gamecenter.core.AppExecutor
|
||||||
import com.gh.gamecenter.core.runOnIoThread
|
import com.gh.gamecenter.core.runOnIoThread
|
||||||
import com.gh.gamecenter.core.utils.*
|
import com.gh.gamecenter.core.utils.*
|
||||||
import com.gh.gamecenter.entity.GamesCollectionEntity
|
import com.gh.gamecenter.entity.*
|
||||||
import com.gh.gamecenter.entity.MyVideoEntity
|
import com.gh.gamecenter.feature.entity.GameEntity
|
||||||
import com.gh.gamecenter.entity.VideoEntity
|
import com.gh.gamecenter.qa.editor.*
|
||||||
import com.gh.gamecenter.feature.entity.AnswerEntity
|
import com.gh.gamecenter.feature.entity.AnswerEntity
|
||||||
import com.gh.gamecenter.feature.entity.ArticleEntity
|
import com.gh.gamecenter.feature.entity.ArticleEntity
|
||||||
import com.gh.gamecenter.feature.entity.GameEntity
|
|
||||||
import com.gh.gamecenter.feature.selector.ChooseType
|
|
||||||
import com.gh.gamecenter.feature.selector.LocalMediaActivity
|
|
||||||
import com.gh.gamecenter.qa.editor.*
|
|
||||||
import com.gh.gamecenter.qa.entity.EditorInsertEntity
|
import com.gh.gamecenter.qa.entity.EditorInsertEntity
|
||||||
import com.gh.gamecenter.video.poster.video.VideoPosterFragment
|
import com.gh.gamecenter.video.poster.PosterEditActivity
|
||||||
import com.gh.gamecenter.video.upload.UploadManager
|
import com.gh.gamecenter.video.upload.UploadManager
|
||||||
import com.google.gson.JsonObject
|
import com.google.gson.JsonObject
|
||||||
import com.halo.assistant.HaloApp
|
import com.halo.assistant.HaloApp
|
||||||
import com.lightgame.utils.Util_System_Keyboard
|
import com.lightgame.utils.Util_System_Keyboard
|
||||||
import com.lightgame.utils.Utils
|
import com.lightgame.utils.Utils
|
||||||
import com.lightgame.view.CheckableImageView
|
import com.lightgame.view.CheckableImageView
|
||||||
import com.therouter.TheRouter
|
|
||||||
import io.reactivex.disposables.Disposable
|
import io.reactivex.disposables.Disposable
|
||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
@ -234,7 +226,6 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> constructor(
|
|||||||
@SuppressLint("AddJavascriptInterface", "ClickableViewAccessibility")
|
@SuppressLint("AddJavascriptInterface", "ClickableViewAccessibility")
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
VideoPosterFragment.createVideoCoverFile(this)
|
|
||||||
findView()
|
findView()
|
||||||
onRichClick()
|
onRichClick()
|
||||||
mViewModel = provideViewModel()
|
mViewModel = provideViewModel()
|
||||||
@ -242,7 +233,7 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> constructor(
|
|||||||
mKeyboardHeightProvider = KeyboardHeightProvider(this)
|
mKeyboardHeightProvider = KeyboardHeightProvider(this)
|
||||||
mRichEditor.post { mKeyboardHeightProvider?.start() }
|
mRichEditor.post { mKeyboardHeightProvider?.start() }
|
||||||
mRichEditor.enableForceDark(DarkModeUtils.isDarkModeOn(this))
|
mRichEditor.enableForceDark(DarkModeUtils.isDarkModeOn(this))
|
||||||
mRichEditor.setEditorBackgroundColor(com.gh.gamecenter.common.R.color.ui_surface.toColor(this))
|
mRichEditor.setEditorBackgroundColor(R.color.ui_surface.toColor(this))
|
||||||
mRichEditor.setEditorFontColor(if (mIsDarkModeOn) Color.parseColor("#C2C2C2") else Color.parseColor("#4A4A4A"))
|
mRichEditor.setEditorFontColor(if (mIsDarkModeOn) Color.parseColor("#C2C2C2") else Color.parseColor("#4A4A4A"))
|
||||||
// 防止个别手机在Js里无法获取粘贴内容
|
// 防止个别手机在Js里无法获取粘贴内容
|
||||||
mRichEditor.addJavascriptInterface(OnPasteListener(), "onPasteListener")
|
mRichEditor.addJavascriptInterface(OnPasteListener(), "onPasteListener")
|
||||||
@ -511,7 +502,7 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> constructor(
|
|||||||
startActivityForResult(
|
startActivityForResult(
|
||||||
LocalMediaActivity.getIntent(
|
LocalMediaActivity.getIntent(
|
||||||
this@BaseRichEditorActivity,
|
this@BaseRichEditorActivity,
|
||||||
ChooseType.VIDEO,
|
LocalMediaActivity.ChooseType.VIDEO,
|
||||||
maxChooseCount,
|
maxChooseCount,
|
||||||
if (mtaEventName() == "提问帖") "发提问帖" else "发帖子"
|
if (mtaEventName() == "提问帖") "发提问帖" else "发帖子"
|
||||||
), INSERT_MEDIA_VIDEO_CODE
|
), INSERT_MEDIA_VIDEO_CODE
|
||||||
@ -540,7 +531,7 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> constructor(
|
|||||||
val maxChooseCount = if (imageCount + 10 <= MAX_IMAGE_COUNT) 10 else MAX_IMAGE_COUNT - imageCount
|
val maxChooseCount = if (imageCount + 10 <= MAX_IMAGE_COUNT) 10 else MAX_IMAGE_COUNT - imageCount
|
||||||
val intent = LocalMediaActivity.getIntent(
|
val intent = LocalMediaActivity.getIntent(
|
||||||
this@BaseRichEditorActivity,
|
this@BaseRichEditorActivity,
|
||||||
ChooseType.IMAGE,
|
LocalMediaActivity.ChooseType.IMAGE,
|
||||||
maxChooseCount,
|
maxChooseCount,
|
||||||
if (mtaEventName() == "提问帖") "发提问帖" else "发帖子"
|
if (mtaEventName() == "提问帖") "发提问帖" else "发帖子"
|
||||||
)
|
)
|
||||||
@ -745,9 +736,9 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> constructor(
|
|||||||
mViewModel.id = id
|
mViewModel.id = id
|
||||||
mViewModel.videoId = videoId
|
mViewModel.videoId = videoId
|
||||||
val videoEntity = VideoEntity(url = url)
|
val videoEntity = VideoEntity(url = url)
|
||||||
TheRouter.build(RouteConsts.activity.videoCoverEditActivity)
|
val intent =
|
||||||
.withParcelable(EntranceConsts.KEY_VIDEO_ENTITY, videoEntity)
|
PosterEditActivity.getIntentByVideo(this@BaseRichEditorActivity, videoEntity)
|
||||||
.navigation(this@BaseRichEditorActivity, REQUEST_CODE_IMAGE_CROP)
|
startActivityForResult(intent, REQUEST_CODE_IMAGE_CROP)
|
||||||
}
|
}
|
||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
@ -806,9 +797,9 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> constructor(
|
|||||||
|
|
||||||
override fun onDarkModeChanged() {
|
override fun onDarkModeChanged() {
|
||||||
super.onDarkModeChanged()
|
super.onDarkModeChanged()
|
||||||
updateStatusBarColor(com.gh.gamecenter.common.R.color.ui_surface, com.gh.gamecenter.common.R.color.ui_surface)
|
updateStatusBarColor(R.color.ui_surface, R.color.ui_surface)
|
||||||
mRichEditor.enableForceDark(DarkModeUtils.isDarkModeOn(this))
|
mRichEditor.enableForceDark(DarkModeUtils.isDarkModeOn(this))
|
||||||
mRichEditor.setEditorBackgroundColor(com.gh.gamecenter.common.R.color.ui_surface.toColor(this))
|
mRichEditor.setEditorBackgroundColor(R.color.ui_surface.toColor(this))
|
||||||
mRichEditor.setEditorFontColor(if (mIsDarkModeOn) Color.parseColor("#C2C2C2") else Color.parseColor("#4A4A4A"))
|
mRichEditor.setEditorFontColor(if (mIsDarkModeOn) Color.parseColor("#C2C2C2") else Color.parseColor("#4A4A4A"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import android.text.TextUtils
|
|||||||
import androidx.lifecycle.AndroidViewModel
|
import androidx.lifecycle.AndroidViewModel
|
||||||
import androidx.lifecycle.MediatorLiveData
|
import androidx.lifecycle.MediatorLiveData
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import com.gh.gamecenter.R
|
||||||
import com.gh.gamecenter.common.base.fragment.WaitingDialogFragment
|
import com.gh.gamecenter.common.base.fragment.WaitingDialogFragment
|
||||||
import com.gh.gamecenter.common.entity.ErrorEntity
|
import com.gh.gamecenter.common.entity.ErrorEntity
|
||||||
import com.gh.gamecenter.common.retrofit.BiResponse
|
import com.gh.gamecenter.common.retrofit.BiResponse
|
||||||
@ -19,7 +20,7 @@ import com.gh.gamecenter.core.runOnUiThread
|
|||||||
import com.gh.gamecenter.core.utils.MD5Utils
|
import com.gh.gamecenter.core.utils.MD5Utils
|
||||||
import com.gh.gamecenter.core.utils.ToastUtils
|
import com.gh.gamecenter.core.utils.ToastUtils
|
||||||
import com.gh.gamecenter.entity.ForumDetailEntity
|
import com.gh.gamecenter.entity.ForumDetailEntity
|
||||||
import com.gh.gamecenter.common.entity.LocalVideoEntity
|
import com.gh.gamecenter.entity.LocalVideoEntity
|
||||||
import com.gh.gamecenter.entity.QuoteCountEntity
|
import com.gh.gamecenter.entity.QuoteCountEntity
|
||||||
import com.gh.gamecenter.qa.BbsType
|
import com.gh.gamecenter.qa.BbsType
|
||||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||||
@ -38,6 +39,8 @@ import retrofit2.HttpException
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import kotlin.collections.ArrayList
|
||||||
|
import kotlin.collections.HashMap
|
||||||
import kotlin.collections.LinkedHashMap
|
import kotlin.collections.LinkedHashMap
|
||||||
import kotlin.collections.set
|
import kotlin.collections.set
|
||||||
|
|
||||||
@ -83,7 +86,7 @@ abstract class BaseRichEditorViewModel(application: Application) : AndroidViewMo
|
|||||||
val application: Application = getApplication()
|
val application: Application = getApplication()
|
||||||
Utils.toast(
|
Utils.toast(
|
||||||
getApplication(),
|
getApplication(),
|
||||||
application.getString(com.gh.gamecenter.common.R.string.pic_max_hint, count)
|
application.getString(R.string.pic_max_hint, count)
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,9 +2,9 @@ package com.gh.base
|
|||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.res.Configuration
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import com.alibaba.android.arouter.launcher.ARouter
|
||||||
import com.gh.ad.AdDelegateHelper
|
import com.gh.ad.AdDelegateHelper
|
||||||
import com.gh.common.util.FloatingBackViewManager
|
import com.gh.common.util.FloatingBackViewManager
|
||||||
import com.gh.common.xapk.XapkInstaller
|
import com.gh.common.xapk.XapkInstaller
|
||||||
@ -15,37 +15,16 @@ import com.gh.gamecenter.SplashAdActivity
|
|||||||
import com.gh.gamecenter.SplashScreenActivity
|
import com.gh.gamecenter.SplashScreenActivity
|
||||||
import com.gh.gamecenter.authorization.AuthorizationActivity
|
import com.gh.gamecenter.authorization.AuthorizationActivity
|
||||||
import com.gh.gamecenter.common.base.GlobalActivityManager
|
import com.gh.gamecenter.common.base.GlobalActivityManager
|
||||||
import com.gh.gamecenter.common.provider.IHelpAndFeedbackProvider
|
import com.gh.gamecenter.common.constant.RouteConsts
|
||||||
import com.gh.gamecenter.common.utils.PackageFlavorHelper
|
import com.gh.gamecenter.common.utils.PackageFlavorHelper
|
||||||
import com.gh.gamecenter.core.provider.IPushProvider
|
import com.gh.gamecenter.core.provider.IPushProvider
|
||||||
import com.gh.gamecenter.login.utils.QuickLoginHelper
|
|
||||||
import com.gh.gamecenter.login.view.LoginActivity
|
|
||||||
import com.gh.gamecenter.va.VCore
|
|
||||||
import com.gh.vspace.VHelper
|
import com.gh.vspace.VHelper
|
||||||
import com.halo.assistant.HaloApp
|
import com.halo.assistant.HaloApp
|
||||||
import com.therouter.TheRouter
|
|
||||||
|
|
||||||
// TODO:移动到对应的模块
|
// TODO:移动到对应的模块
|
||||||
class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
||||||
private var isFromBackgroundToForeground = false // 是否后台回到前台
|
private var isFromBackgroundToForeground = false // 是否后台回到前台
|
||||||
|
private var activityCount = 0
|
||||||
override fun onActivityPreCreated(activity: Activity, savedInstanceState: Bundle?) {
|
|
||||||
if (QuickLoginHelper.isLoginAuthPage(activity)) {
|
|
||||||
try {
|
|
||||||
val resources = activity.resources
|
|
||||||
val config = Configuration(resources.configuration)
|
|
||||||
config.fontScale = 1.0f
|
|
||||||
|
|
||||||
// 更新Resources配置
|
|
||||||
val metrics = resources.displayMetrics
|
|
||||||
metrics.scaledDensity = metrics.density
|
|
||||||
resources.updateConfiguration(config, metrics)
|
|
||||||
|
|
||||||
} catch (e: Exception) {
|
|
||||||
// 设置字体失败
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
|
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
|
||||||
// do nothing
|
// do nothing
|
||||||
@ -53,31 +32,19 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
|||||||
|
|
||||||
override fun onActivityStarted(activity: Activity) {
|
override fun onActivityStarted(activity: Activity) {
|
||||||
GlobalActivityManager.currentActivity = activity
|
GlobalActivityManager.currentActivity = activity
|
||||||
GlobalActivityManager.activityCount++
|
activityCount ++
|
||||||
if (GlobalActivityManager.activityCount == 1 && isFromBackgroundToForeground) {
|
if (activityCount == 1 && isFromBackgroundToForeground) {
|
||||||
if (AdDelegateHelper.shouldShowStartUpAd(true)
|
if (AdDelegateHelper.shouldShowStartUpAd(true)
|
||||||
&& !HaloApp.getInstance().isDisableSplashAdTemporarily
|
&& !HaloApp.getInstance().isSkippingThirdParty
|
||||||
&& activity !is SplashScreenActivity
|
&& activity !is SplashScreenActivity
|
||||||
&& activity !is SkipActivity
|
&& activity !is SkipActivity
|
||||||
&& activity !is AuthorizationActivity
|
&& activity !is AuthorizationActivity
|
||||||
&& activity !is SplashAdActivity
|
&& activity !is SplashAdActivity
|
||||||
&& !isSuggestionActivity(activity)
|
|
||||||
) {
|
) {
|
||||||
activity.startActivity(SplashAdActivity.getIntent(activity))
|
activity.startActivity(SplashAdActivity.getIntent(activity))
|
||||||
}
|
}
|
||||||
isFromBackgroundToForeground = false
|
isFromBackgroundToForeground = false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GlobalActivityManager.activityCount == 1) {
|
|
||||||
// 清除桌面角标
|
|
||||||
if (activity !is SplashScreenActivity && activity !is AuthorizationActivity) {
|
|
||||||
val pushProvider = TheRouter.get(IPushProvider::class.java)
|
|
||||||
pushProvider?.cleanBadgeNumber(activity.applicationContext)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (QuickLoginHelper.isLoginAuthPage(activity)) {
|
|
||||||
QuickLoginHelper.addCustomViewToLoginAuthPage(activity)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityResumed(activity: Activity) {
|
override fun onActivityResumed(activity: Activity) {
|
||||||
@ -109,8 +76,6 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (activity is AppCompatActivity
|
if (activity is AppCompatActivity
|
||||||
&& !VCore.getInstance().isLaunchActivity(activity)
|
|
||||||
&& activity !is LoginActivity
|
|
||||||
&& activity !is SplashScreenActivity
|
&& activity !is SplashScreenActivity
|
||||||
&& activity !is SkipActivity
|
&& activity !is SkipActivity
|
||||||
&& activity !is AuthorizationActivity
|
&& activity !is AuthorizationActivity
|
||||||
@ -119,6 +84,10 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
XapkInstaller.updateCurrentInstallStatus()
|
XapkInstaller.updateCurrentInstallStatus()
|
||||||
|
|
||||||
|
// 清除桌面角标
|
||||||
|
val pushProvider = ARouter.getInstance().build(RouteConsts.provider.push).navigation() as? IPushProvider
|
||||||
|
pushProvider?.cleanBadgeNumber(activity.applicationContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityPaused(activity: Activity) {
|
override fun onActivityPaused(activity: Activity) {
|
||||||
@ -129,8 +98,8 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityStopped(activity: Activity) {
|
override fun onActivityStopped(activity: Activity) {
|
||||||
GlobalActivityManager.activityCount--
|
activityCount --
|
||||||
isFromBackgroundToForeground = GlobalActivityManager.activityCount <= 0
|
isFromBackgroundToForeground = activityCount <= 0
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {
|
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {
|
||||||
@ -138,14 +107,7 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityDestroyed(activity: Activity) {
|
override fun onActivityDestroyed(activity: Activity) {
|
||||||
if (QuickLoginHelper.isLoginAuthPage(activity)) {
|
// do nothing
|
||||||
QuickLoginHelper.release()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun isSuggestionActivity(activity: Activity): Boolean {
|
|
||||||
val helpAndFeedbackProvider = TheRouter.get(IHelpAndFeedbackProvider::class.java)
|
|
||||||
return helpAndFeedbackProvider?.isSuggestionActivity(activity) ?: false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -3,8 +3,6 @@ package com.gh.common
|
|||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Handler
|
|
||||||
import android.os.Looper
|
|
||||||
import android.util.Base64
|
import android.util.Base64
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.webkit.JavascriptInterface
|
import android.webkit.JavascriptInterface
|
||||||
@ -13,7 +11,7 @@ import androidx.appcompat.app.AppCompatActivity
|
|||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.FragmentActivity
|
import androidx.fragment.app.FragmentActivity
|
||||||
import androidx.fragment.app.FragmentManager
|
import androidx.fragment.app.FragmentManager
|
||||||
import androidx.lifecycle.Lifecycle
|
import com.alibaba.android.arouter.launcher.ARouter
|
||||||
import com.gh.common.exposure.ExposureManager
|
import com.gh.common.exposure.ExposureManager
|
||||||
import com.gh.common.util.*
|
import com.gh.common.util.*
|
||||||
import com.gh.common.util.LogUtils
|
import com.gh.common.util.LogUtils
|
||||||
@ -21,12 +19,10 @@ import com.gh.download.DownloadManager
|
|||||||
import com.gh.download.PackageObserver
|
import com.gh.download.PackageObserver
|
||||||
import com.gh.gamecenter.BuildConfig
|
import com.gh.gamecenter.BuildConfig
|
||||||
import com.gh.gamecenter.ImageViewerActivity
|
import com.gh.gamecenter.ImageViewerActivity
|
||||||
import com.gh.gamecenter.R
|
|
||||||
import com.gh.gamecenter.WebActivity
|
import com.gh.gamecenter.WebActivity
|
||||||
import com.gh.gamecenter.common.callback.BiCallback
|
import com.gh.gamecenter.common.callback.BiCallback
|
||||||
import com.gh.gamecenter.common.constant.Constants
|
import com.gh.gamecenter.common.constant.Constants
|
||||||
import com.gh.gamecenter.common.constant.Constants.SP_MEMBER_PAYMENT_BUTTON_CLICK
|
import com.gh.gamecenter.common.constant.RouteConsts
|
||||||
import com.gh.gamecenter.common.constant.Constants.SP_MEMBER_RECHARGE_BUTTON_CLICK
|
|
||||||
import com.gh.gamecenter.common.entity.NotificationUgc
|
import com.gh.gamecenter.common.entity.NotificationUgc
|
||||||
import com.gh.gamecenter.common.exposure.ExposureSource
|
import com.gh.gamecenter.common.exposure.ExposureSource
|
||||||
import com.gh.gamecenter.common.loghub.LoghubUtils
|
import com.gh.gamecenter.common.loghub.LoghubUtils
|
||||||
@ -34,42 +30,30 @@ import com.gh.gamecenter.common.provider.IHelpAndFeedbackProvider
|
|||||||
import com.gh.gamecenter.common.tracker.Tracker
|
import com.gh.gamecenter.common.tracker.Tracker
|
||||||
import com.gh.gamecenter.common.utils.*
|
import com.gh.gamecenter.common.utils.*
|
||||||
import com.gh.gamecenter.common.utils.NewFlatLogUtils
|
import com.gh.gamecenter.common.utils.NewFlatLogUtils
|
||||||
import com.gh.gamecenter.common.utils.SensorsBridge.EVENT_MEMBER_RECHARGE_BUTTON_CLICK
|
|
||||||
import com.gh.gamecenter.common.utils.SensorsBridge.EVENT_NAME
|
|
||||||
import com.gh.gamecenter.common.utils.SensorsBridge.KEY_IS_FIRST_TIME
|
|
||||||
import com.gh.gamecenter.common.view.dsbridge.CompletionHandler
|
import com.gh.gamecenter.common.view.dsbridge.CompletionHandler
|
||||||
import com.gh.gamecenter.core.AppExecutor
|
import com.gh.gamecenter.core.AppExecutor
|
||||||
import com.gh.gamecenter.core.provider.IAcceleratorProvider
|
|
||||||
import com.gh.gamecenter.core.provider.IPushProvider
|
|
||||||
import com.gh.gamecenter.core.runOnIoThread
|
import com.gh.gamecenter.core.runOnIoThread
|
||||||
import com.gh.gamecenter.core.runOnUiThread
|
import com.gh.gamecenter.core.runOnUiThread
|
||||||
import com.gh.gamecenter.core.utils.*
|
import com.gh.gamecenter.core.utils.*
|
||||||
import com.gh.gamecenter.entity.SensorsEvent
|
import com.gh.gamecenter.entity.SensorsEvent
|
||||||
import com.gh.gamecenter.eventbus.EBDownloadStatus
|
import com.gh.gamecenter.eventbus.EBDownloadStatus
|
||||||
import com.gh.gamecenter.eventbus.EBPackage
|
import com.gh.gamecenter.eventbus.EBPackage
|
||||||
import com.gh.gamecenter.feature.entity.AcctRecordEntity
|
|
||||||
import com.gh.gamecenter.feature.entity.Badge
|
import com.gh.gamecenter.feature.entity.Badge
|
||||||
import com.gh.gamecenter.feature.entity.GameEntity
|
import com.gh.gamecenter.feature.entity.GameEntity
|
||||||
import com.gh.gamecenter.feature.entity.OrderEntity
|
|
||||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||||
import com.gh.gamecenter.login.user.LoginTag
|
import com.gh.gamecenter.login.user.LoginTag
|
||||||
import com.gh.gamecenter.login.user.UserManager
|
import com.gh.gamecenter.login.user.UserManager
|
||||||
import com.gh.gamecenter.login.user.UserRepository
|
import com.gh.gamecenter.login.user.UserRepository
|
||||||
import com.gh.gamecenter.login.utils.LoginHelper
|
import com.gh.gamecenter.login.utils.LoginHelper
|
||||||
import com.gh.gamecenter.login.utils.QuickLoginHelper
|
|
||||||
import com.gh.gamecenter.login.view.LoginActivity
|
import com.gh.gamecenter.login.view.LoginActivity
|
||||||
import com.gh.gamecenter.personalhome.border.AvatarBorderActivity
|
import com.gh.gamecenter.personalhome.border.AvatarBorderActivity
|
||||||
import com.gh.gamecenter.setting.SettingBridge
|
import com.gh.gamecenter.setting.SettingBridge
|
||||||
import com.gh.vspace.VHelper
|
import com.gh.vspace.VHelper
|
||||||
import com.halo.assistant.HaloApp
|
import com.halo.assistant.HaloApp
|
||||||
import com.halo.assistant.accelerator.repository.AccelerationRepository.Companion.PAYMENT_TYPE_ALIPAY
|
|
||||||
import com.halo.assistant.accelerator.repository.AccelerationRepository.Companion.PAYMENT_TYPE_WECHAT
|
|
||||||
import com.halo.assistant.accelerator.repository.AcceleratorDataHolder
|
|
||||||
import com.lightgame.download.DataWatcher
|
import com.lightgame.download.DataWatcher
|
||||||
import com.lightgame.download.DownloadEntity
|
import com.lightgame.download.DownloadEntity
|
||||||
import com.lightgame.download.DownloadStatus.*
|
import com.lightgame.download.DownloadStatus.*
|
||||||
import com.lightgame.utils.Utils
|
import com.lightgame.utils.Utils
|
||||||
import com.therouter.TheRouter
|
|
||||||
import org.greenrobot.eventbus.EventBus
|
import org.greenrobot.eventbus.EventBus
|
||||||
import org.greenrobot.eventbus.Subscribe
|
import org.greenrobot.eventbus.Subscribe
|
||||||
import org.greenrobot.eventbus.ThreadMode
|
import org.greenrobot.eventbus.ThreadMode
|
||||||
@ -82,11 +66,10 @@ import java.util.*
|
|||||||
class DefaultJsApi(
|
class DefaultJsApi(
|
||||||
var context: Context,
|
var context: Context,
|
||||||
val entrance: String = "",
|
val entrance: String = "",
|
||||||
private val mFragment: Fragment? = null,
|
private var mFragment: Fragment? = null,
|
||||||
private var mBbsId: String? = "",
|
private var mBbsId: String? = "",
|
||||||
private var mOriginUrl: String? = "",
|
private var mOriginUrl: String? = "",
|
||||||
private val mForumName: String? = "",
|
private val mForumName: String? = ""
|
||||||
private val listener: OnWebClickListener? = null
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@ -99,8 +82,6 @@ class DefaultJsApi(
|
|||||||
private var mDownloadHandler: CompletionHandler<Any>? = null // 下载信息回调
|
private var mDownloadHandler: CompletionHandler<Any>? = null // 下载信息回调
|
||||||
private var mExposureEvent: ExposureEvent? = null // 活动曝光实体
|
private var mExposureEvent: ExposureEvent? = null // 活动曝光实体
|
||||||
|
|
||||||
private val handler = Handler(Looper.getMainLooper())
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (mFragment != null) {
|
if (mFragment != null) {
|
||||||
EventBus.getDefault().register(this)
|
EventBus.getDefault().register(this)
|
||||||
@ -108,11 +89,6 @@ class DefaultJsApi(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@JavascriptInterface
|
|
||||||
fun isEnableForceDark(msg: Any): Boolean {
|
|
||||||
return DarkModeUtils.isWebViewForceDarkEnabled
|
|
||||||
}
|
|
||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
fun isGhzs(msg: Any): String {
|
fun isGhzs(msg: Any): String {
|
||||||
return "true"
|
return "true"
|
||||||
@ -153,12 +129,12 @@ class DefaultJsApi(
|
|||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
fun login(msg: Any) {
|
fun login(msg: Any) {
|
||||||
if (NetworkUtils.isQuickLoginEnabled(context)) {
|
// if (SPUtils.getBoolean(Constants.SP_HAS_GET_PHONE_INFO) || NetworkUtils.isOpenMobileData(context)) {
|
||||||
QuickLoginHelper.startLogin(context, "浏览器")
|
// QuickLoginHelper.startLogin(context, "浏览器")
|
||||||
} else {
|
// } else {
|
||||||
val intent = LoginActivity.getIntent(context, "浏览器")
|
val intent = LoginActivity.getIntent(context, "浏览器")
|
||||||
context.startActivity(intent)
|
context.startActivity(intent)
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
@ -243,16 +219,10 @@ class DefaultJsApi(
|
|||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
// 若畅玩列表中安装了,优先启动畅玩游戏
|
// 若畅玩列表中安装了,优先启动畅玩游戏
|
||||||
if (VHelper.isInstalled(packageName)) {
|
if (VHelper.isInstalled(packageName)) {
|
||||||
VHelper.validateVSpaceBeforeAction(context, packageName, null) {
|
if (!VHelper.showDialogIfVSpaceIsNeeded(context, "", "", "", "")) {
|
||||||
VHelper.launch(context, packageName)
|
VHelper.launch(context, packageName)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val wechatPkgName = "com.tencent.mm"
|
|
||||||
if (packageName == wechatPkgName && !PackageUtils.isInstalled(context, wechatPkgName)) {
|
|
||||||
// 如果是微信客户端,需要检查是否安装微信
|
|
||||||
ToastUtils.showToast(R.string.wechat_app_not_install_tips.toResString())
|
|
||||||
return@runOnUiThread
|
|
||||||
}
|
|
||||||
PackageLauncher.launchApp(context, packageName = packageName)
|
PackageLauncher.launchApp(context, packageName = packageName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -276,7 +246,7 @@ class DefaultJsApi(
|
|||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
fun isInstalled(event: Any): String {
|
fun isInstalled(event: Any): String {
|
||||||
val localInstalledPackageList = PackageHelper.getInstalledPackageNameList(HaloApp.getInstance().application, 0)
|
val localInstalledPackageList = PackageUtils.getAllPackageName(HaloApp.getInstance().application)
|
||||||
val packageNameList: ArrayList<String> = event.toString().toObject() ?: ArrayList()
|
val packageNameList: ArrayList<String> = event.toString().toObject() ?: ArrayList()
|
||||||
|
|
||||||
for (packageName in packageNameList) {
|
for (packageName in packageNameList) {
|
||||||
@ -363,12 +333,6 @@ class DefaultJsApi(
|
|||||||
return HaloApp.getInstance().oaid
|
return HaloApp.getInstance().oaid
|
||||||
}
|
}
|
||||||
|
|
||||||
@JavascriptInterface
|
|
||||||
fun getPushId(): String {
|
|
||||||
val pushProvider = TheRouter.get(IPushProvider::class.java)
|
|
||||||
return pushProvider?.getRegistrationId(HaloApp.getInstance()) ?: "unknown"
|
|
||||||
}
|
|
||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
fun showIncompatibleVersionDialog(msg: Any) {
|
fun showIncompatibleVersionDialog(msg: Any) {
|
||||||
DialogHelper.showUpgradeDialog(context)
|
DialogHelper.showUpgradeDialog(context)
|
||||||
@ -444,7 +408,8 @@ class DefaultJsApi(
|
|||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
fun showQaFeedbackDialog(msg: Any) {
|
fun showQaFeedbackDialog(msg: Any) {
|
||||||
val mHelpAndFeedbackHelp = TheRouter.get(IHelpAndFeedbackProvider::class.java)
|
val mHelpAndFeedbackHelp =
|
||||||
|
ARouter.getInstance().build(RouteConsts.provider.helpAndFeedback).navigation() as? IHelpAndFeedbackProvider
|
||||||
mHelpAndFeedbackHelp?.showQaFeedbackDialogFragment(context as AppCompatActivity, msg.toString())
|
mHelpAndFeedbackHelp?.showQaFeedbackDialogFragment(context as AppCompatActivity, msg.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -515,44 +480,6 @@ class DefaultJsApi(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@JavascriptInterface
|
|
||||||
fun saveWechatQRCode(msg: Any) {
|
|
||||||
val base64StringData = msg.toString()
|
|
||||||
runOnUiThread {
|
|
||||||
(context as? FragmentActivity)?.checkStoragePermissionBeforeAction {
|
|
||||||
runOnIoThread {
|
|
||||||
val base64String = base64StringData.replace("data:image/png;base64", "")
|
|
||||||
tryWithDefaultCatch {
|
|
||||||
val imageFile =
|
|
||||||
File(HaloApp.getInstance().cacheDir.absolutePath + File.separator + System.currentTimeMillis() + ".png")
|
|
||||||
val decodedString = Base64.decode(base64String, Base64.DEFAULT)
|
|
||||||
val bos = BufferedOutputStream(FileOutputStream(imageFile))
|
|
||||||
bos.write(decodedString)
|
|
||||||
bos.flush()
|
|
||||||
bos.close()
|
|
||||||
|
|
||||||
ImageUtils.saveImageToFile(imageFile, "", true) {
|
|
||||||
// 这里是 ui 线程
|
|
||||||
// 保存微信二维码成功,1s 以后跳转微信
|
|
||||||
if (mFragment != null && mFragment.lifecycle.currentState.isAtLeast(Lifecycle.State.STARTED)) {
|
|
||||||
handler.removeCallbacksAndMessages(null)
|
|
||||||
handler.postDelayed({
|
|
||||||
val wechatPkgName = "com.tencent.mm"
|
|
||||||
if (!PackageUtils.isInstalled(context, wechatPkgName)) {
|
|
||||||
ToastUtils.showToast(R.string.wechat_app_not_install_tips.toResString())
|
|
||||||
return@postDelayed
|
|
||||||
}
|
|
||||||
PackageLauncher.launchApp(context, packageName = wechatPkgName)
|
|
||||||
}, 1000)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
fun loginWithCallback(msg: Any, handler: CompletionHandler<Any>) {
|
fun loginWithCallback(msg: Any, handler: CompletionHandler<Any>) {
|
||||||
mLoginHandler = handler
|
mLoginHandler = handler
|
||||||
@ -612,7 +539,7 @@ class DefaultJsApi(
|
|||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
fun getInstallStatus(event: Any): String {
|
fun getInstallStatus(event: Any): String {
|
||||||
val localInstalledPackageList = PackageHelper.getInstalledPackageNameList(HaloApp.getInstance().application, 0)
|
val localInstalledPackageList = PackageUtils.getAllPackageName(HaloApp.getInstance().application)
|
||||||
val packageNameList: ArrayList<String> = event.toString().toObject() ?: ArrayList()
|
val packageNameList: ArrayList<String> = event.toString().toObject() ?: ArrayList()
|
||||||
val installStatusMap: HashMap<String, Boolean> = hashMapOf()
|
val installStatusMap: HashMap<String, Boolean> = hashMapOf()
|
||||||
|
|
||||||
@ -757,86 +684,6 @@ class DefaultJsApi(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@JavascriptInterface
|
|
||||||
fun preOrderWithAli(json: Any) {
|
|
||||||
val order = json.toString().toObject<OrderEntity>() ?: return
|
|
||||||
trackMemberPaymentButtonClick(order, PAYMENT_TYPE_ALIPAY)
|
|
||||||
listener?.onPreOrderWithAli(order)
|
|
||||||
}
|
|
||||||
|
|
||||||
@JavascriptInterface
|
|
||||||
fun preOrderWithWechat(json: Any) {
|
|
||||||
val order = json.toString().toObject<OrderEntity>() ?: return
|
|
||||||
trackMemberPaymentButtonClick(order, PAYMENT_TYPE_WECHAT)
|
|
||||||
listener?.onPreOrderWithWechat(order)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun trackMemberPaymentButtonClick(order: OrderEntity, paymentType: String) {
|
|
||||||
val isFirstTime = SPUtils.getBoolean(SP_MEMBER_PAYMENT_BUTTON_CLICK, true)
|
|
||||||
SPUtils.setBoolean(SP_MEMBER_PAYMENT_BUTTON_CLICK, false)
|
|
||||||
SensorsBridge.trackMemberPaymentButtonClick(
|
|
||||||
isFirstTime,
|
|
||||||
paymentType,
|
|
||||||
order.setMenuName,
|
|
||||||
order.paymentAmount
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
@JavascriptInterface
|
|
||||||
fun startGameAccelerate(acctJson: Any) {
|
|
||||||
if (acctJson is String) {
|
|
||||||
val acctRecord = GsonUtils.fromJson(acctJson, AcctRecordEntity::class.java)
|
|
||||||
val accInfo = acctRecord.accInfo
|
|
||||||
listener?.onStartGameAccelerate(accInfo)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@JavascriptInterface
|
|
||||||
fun getCurAcctGameId(): String {
|
|
||||||
return AcceleratorDataHolder.instance.getAcceleratingGameId()
|
|
||||||
}
|
|
||||||
|
|
||||||
@JavascriptInterface
|
|
||||||
fun stopGameAccelerate() {
|
|
||||||
listener?.onStopGameAccelerate()
|
|
||||||
}
|
|
||||||
|
|
||||||
@JavascriptInterface
|
|
||||||
fun getDurationRemainingTime(msg: Any, handler: CompletionHandler<Any>) {
|
|
||||||
TheRouter.get(IAcceleratorProvider::class.java)?.loadQyUserPermissionData {
|
|
||||||
val durationExpiredMinute = AcceleratorDataHolder.instance.vipEntity?.durationExpiredTime ?: 0L
|
|
||||||
handler.complete(durationExpiredMinute)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@JavascriptInterface
|
|
||||||
fun refreshToken(token: Any, handler: CompletionHandler<Any>) {
|
|
||||||
val accessToken = token.toString()
|
|
||||||
UserManager.getInstance().refreshToken(accessToken, object : UserManager.refreshCallBack {
|
|
||||||
override fun onLogin() {
|
|
||||||
handler.complete(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onLoginFailure(errorMessage: String?) {
|
|
||||||
handler.complete(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
@JavascriptInterface
|
|
||||||
fun trackSensorsAnalytics(json: Any) {
|
|
||||||
val hashMap = json.toString().toObject<HashMap<String, Any>>() ?: return
|
|
||||||
val eventName = hashMap.remove(EVENT_NAME) ?: return
|
|
||||||
when (eventName) {
|
|
||||||
EVENT_MEMBER_RECHARGE_BUTTON_CLICK -> {
|
|
||||||
hashMap[KEY_IS_FIRST_TIME] = SPUtils.getBoolean(SP_MEMBER_RECHARGE_BUTTON_CLICK, true)
|
|
||||||
SPUtils.setBoolean(SP_MEMBER_RECHARGE_BUTTON_CLICK, false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SensorsBridge.trackSensorsAnalyticsFromWeb(eventName.toString(), hashMap)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取 ExposureEvent,可能为空
|
* 获取 ExposureEvent,可能为空
|
||||||
*/
|
*/
|
||||||
@ -857,8 +704,6 @@ class DefaultJsApi(
|
|||||||
}
|
}
|
||||||
|
|
||||||
EventBus.getDefault().unregister(this@DefaultJsApi)
|
EventBus.getDefault().unregister(this@DefaultJsApi)
|
||||||
|
|
||||||
handler.removeCallbacksAndMessages(null)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -955,15 +800,4 @@ class DefaultJsApi(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface OnWebClickListener {
|
|
||||||
|
|
||||||
fun onPreOrderWithAli(order: OrderEntity)
|
|
||||||
|
|
||||||
fun onPreOrderWithWechat(order: OrderEntity)
|
|
||||||
|
|
||||||
fun onStartGameAccelerate(accInfo: AcctRecordEntity.AccInfo)
|
|
||||||
|
|
||||||
fun onStopGameAccelerate()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,6 @@ import com.gh.common.util.DirectUtils.directToLegacyVideoDetail
|
|||||||
import com.gh.common.util.DirectUtils.directToLinkPage
|
import com.gh.common.util.DirectUtils.directToLinkPage
|
||||||
import com.gh.common.util.DirectUtils.directToQa
|
import com.gh.common.util.DirectUtils.directToQa
|
||||||
import com.gh.common.util.PackageUtils
|
import com.gh.common.util.PackageUtils
|
||||||
import com.gh.gamecenter.SkipCompatActivity
|
|
||||||
import com.gh.gamecenter.WebActivity
|
import com.gh.gamecenter.WebActivity
|
||||||
import com.gh.gamecenter.common.constant.Constants
|
import com.gh.gamecenter.common.constant.Constants
|
||||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||||
@ -67,10 +66,6 @@ object DefaultUrlHandler {
|
|||||||
bringAppToFront: Boolean = false,
|
bringAppToFront: Boolean = false,
|
||||||
sourceEntrance: String = ""): Boolean {
|
sourceEntrance: String = ""): Boolean {
|
||||||
val uri = Uri.parse(url)
|
val uri = Uri.parse(url)
|
||||||
|
|
||||||
// 优先交给新的路由拦截处理
|
|
||||||
if (SkipCompatActivity.handleSkip(context, uri)) return true
|
|
||||||
|
|
||||||
if ("ghzhushou" == uri.scheme) {
|
if ("ghzhushou" == uri.scheme) {
|
||||||
Utils.log("url = $url")
|
Utils.log("url = $url")
|
||||||
Utils.log("url = " + uri.scheme!!)
|
Utils.log("url = " + uri.scheme!!)
|
||||||
@ -273,6 +268,10 @@ object DefaultUrlHandler {
|
|||||||
directToGameVideo(context, id, entrance, "")
|
directToGameVideo(context, id, entrance, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EntranceConsts.HOST_CATEGORY -> {
|
||||||
|
val title = uri.getQueryParameter("title")
|
||||||
|
DirectUtils.directCategoryDirectory(context, id, title ?: "", entrance, "")
|
||||||
|
}
|
||||||
EntranceConsts.HOST_COLUMN_COLLECTION -> {
|
EntranceConsts.HOST_COLUMN_COLLECTION -> {
|
||||||
val name = uri.getQueryParameter("name")
|
val name = uri.getQueryParameter("name")
|
||||||
DirectUtils.directToColumnCollection(context, id, -1, entrance, name ?: "")
|
DirectUtils.directToColumnCollection(context, id, -1, entrance, name ?: "")
|
||||||
@ -379,7 +378,7 @@ object DefaultUrlHandler {
|
|||||||
val iconSubscript = uri.getQueryParameter("game_icon_subscript") ?: ""
|
val iconSubscript = uri.getQueryParameter("game_icon_subscript") ?: ""
|
||||||
val gameEntity =
|
val gameEntity =
|
||||||
if (forumType == BbsType.OFFICIAL_BBS.value && gameId.isNotEmpty() && gameName.isNotEmpty() && icon.isNotEmpty()) {
|
if (forumType == BbsType.OFFICIAL_BBS.value && gameId.isNotEmpty() && gameName.isNotEmpty() && icon.isNotEmpty()) {
|
||||||
GameEntity(_id = gameId, mName = gameName, mIcon = icon, mIconSubscript = iconSubscript)
|
GameEntity(id = gameId, mName = gameName, mIcon = icon, mIconSubscript = iconSubscript)
|
||||||
} else null
|
} else null
|
||||||
val activityLabelEntity = if (activityId.isNotEmpty() && activityName.isNotEmpty()) {
|
val activityLabelEntity = if (activityId.isNotEmpty() && activityName.isNotEmpty()) {
|
||||||
ActivityLabelEntity(
|
ActivityLabelEntity(
|
||||||
|
|||||||
@ -17,7 +17,7 @@ import kotlin.concurrent.fixedRateTimer
|
|||||||
|
|
||||||
object FixedRateJobHelper {
|
object FixedRateJobHelper {
|
||||||
private const val CHECKER_PERIOD: Long = 15 * 1000L
|
private const val CHECKER_PERIOD: Long = 15 * 1000L
|
||||||
private const val TIME_PERIOD: Long = 24 * 60 * 60 * 1000L
|
private const val TIME_PERIOD: Long = 10 * 60 * 1000L
|
||||||
private const val LOGHUB_PERIOD: Long = 2 * 60 * 1000L
|
private const val LOGHUB_PERIOD: Long = 2 * 60 * 1000L
|
||||||
private const val EXPOSURE_PERIOD: Long = 1 * 60 * 1000L
|
private const val EXPOSURE_PERIOD: Long = 1 * 60 * 1000L
|
||||||
private const val REGION_SETTING_PERIOD: Long = 60 * 1000L
|
private const val REGION_SETTING_PERIOD: Long = 60 * 1000L
|
||||||
@ -35,7 +35,7 @@ object FixedRateJobHelper {
|
|||||||
// 时间检查,每15秒检查一次
|
// 时间检查,每15秒检查一次
|
||||||
fixedRateTimer("Global-Fixed-Rate-Timer", initialDelay = 100, period = CHECKER_PERIOD) {
|
fixedRateTimer("Global-Fixed-Rate-Timer", initialDelay = 100, period = CHECKER_PERIOD) {
|
||||||
val elapsedTime = mExecuteCount * CHECKER_PERIOD
|
val elapsedTime = mExecuteCount * CHECKER_PERIOD
|
||||||
// 时间校对,24 小时一次
|
// 时间校对,10分钟一次
|
||||||
if (elapsedTime % TIME_PERIOD == 0L) {
|
if (elapsedTime % TIME_PERIOD == 0L) {
|
||||||
RetrofitManager.getInstance().api.time
|
RetrofitManager.getInstance().api.time
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
|
|||||||
@ -6,8 +6,8 @@ class DownloadChainBuilder {
|
|||||||
|
|
||||||
private var processEndCallback: ((asVGame: Boolean, Any?) -> Unit)? = null
|
private var processEndCallback: ((asVGame: Boolean, Any?) -> Unit)? = null
|
||||||
|
|
||||||
fun setProcessEndCallback(gameId: String, callback: (asVGame: Boolean, Any?) -> Unit): DownloadChainBuilder {
|
fun setProcessEndCallback(callback: (asVGame: Boolean, Any?) -> Unit): DownloadChainBuilder {
|
||||||
processEndCallback = VaPluginDownloadWrapper(gameId = gameId, callback = callback) // 其他需要添加行为的装饰者可以一直包装A(B(C(callback))), 执行顺序 A->B->C->callback
|
processEndCallback = callback
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import android.app.Activity
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import com.gh.common.util.DialogUtils
|
import com.gh.common.util.DialogUtils
|
||||||
import com.gh.common.util.DirectUtils
|
import com.gh.common.util.DirectUtils
|
||||||
import com.gh.common.util.PackageChangeHelper
|
|
||||||
import com.gh.common.util.TempCertificationUtils
|
import com.gh.common.util.TempCertificationUtils
|
||||||
import com.gh.gamecenter.feature.entity.GameEntity
|
import com.gh.gamecenter.feature.entity.GameEntity
|
||||||
|
|
||||||
@ -26,10 +25,6 @@ class LandPageAddressHandler : DownloadChainHandler() {
|
|||||||
processEndCallback?.invoke(asVGame, null)
|
processEndCallback?.invoke(asVGame, null)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val packageName = gameEntity.getApk().firstOrNull()?.packageName
|
|
||||||
if (packageName?.isNotEmpty() == true) {
|
|
||||||
PackageChangeHelper.addInstallPendingPackage(packageName)
|
|
||||||
}
|
|
||||||
DirectUtils.directToExternalBrowser(context, gameEntity.landPageAddressDialog!!.link!!)
|
DirectUtils.directToExternalBrowser(context, gameEntity.landPageAddressDialog!!.link!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,21 +8,12 @@ import com.gh.gamecenter.feature.entity.GameEntity
|
|||||||
class PackageCheckHandler : DownloadChainHandler() {
|
class PackageCheckHandler : DownloadChainHandler() {
|
||||||
|
|
||||||
override fun handleRequest(context: Context, gameEntity: GameEntity, asVGame: Boolean) {
|
override fun handleRequest(context: Context, gameEntity: GameEntity, asVGame: Boolean) {
|
||||||
fun nextOrProcessEnd() {
|
PackageCheckDialogFragment.show((context as AppCompatActivity), gameEntity) {
|
||||||
if (hasNext()) {
|
if (hasNext()) {
|
||||||
getNext()?.handleRequest(context, gameEntity, asVGame)
|
getNext()?.handleRequest(context, gameEntity, asVGame)
|
||||||
} else {
|
} else {
|
||||||
processEndCallback?.invoke(asVGame, null)
|
processEndCallback?.invoke(asVGame, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gameEntity.canSpeed) {
|
|
||||||
nextOrProcessEnd()
|
|
||||||
} else {
|
|
||||||
PackageCheckDialogFragment.show((context as AppCompatActivity), gameEntity) {
|
|
||||||
nextOrProcessEnd()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,12 +0,0 @@
|
|||||||
package com.gh.common.chain
|
|
||||||
|
|
||||||
import com.gh.vspace.VHelper
|
|
||||||
|
|
||||||
class VaPluginDownloadWrapper(val gameId: String, val callback: (Boolean, Any?) -> Unit) : (Boolean, Any?) -> Unit {
|
|
||||||
override fun invoke(asVGame: Boolean, any: Any?) {
|
|
||||||
callback.invoke(asVGame, any)
|
|
||||||
if (asVGame) {
|
|
||||||
VHelper.initVaPlugin(gameId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -16,7 +16,7 @@ class ValidateVSpaceHandler : DownloadChainHandler() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (asVGame) {
|
if (asVGame) {
|
||||||
VHelper.validateVSpaceBeforeAction(context,gameEntity.getUniquePackageName(), gameEntity) {
|
VHelper.validateVSpaceBeforeAction(context, gameEntity) {
|
||||||
closure.invoke()
|
closure.invoke()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -30,7 +30,7 @@ class VersionNumberHandler : DownloadChainHandler() {
|
|||||||
"温馨提示",
|
"温馨提示",
|
||||||
gameEntity.getVersionNumberString(),
|
gameEntity.getVersionNumberString(),
|
||||||
"继续下载",
|
"继续下载",
|
||||||
com.gh.gamecenter.common.R.string.cancel.toResString(),
|
R.string.cancel.toResString(),
|
||||||
{
|
{
|
||||||
confirmCallback.invoke()
|
confirmCallback.invoke()
|
||||||
SensorsBridge.trackGameDemoDialogClick(
|
SensorsBridge.trackGameDemoDialogClick(
|
||||||
@ -42,7 +42,7 @@ class VersionNumberHandler : DownloadChainHandler() {
|
|||||||
},
|
},
|
||||||
cancelClickCallback = {
|
cancelClickCallback = {
|
||||||
SensorsBridge.trackGameDemoDialogClick(
|
SensorsBridge.trackGameDemoDialogClick(
|
||||||
buttonName = com.gh.gamecenter.common.R.string.cancel.toResString(),
|
buttonName = R.string.cancel.toResString(),
|
||||||
gameId = gameEntity.id,
|
gameId = gameEntity.id,
|
||||||
gameName = gameEntity.name ?: "",
|
gameName = gameEntity.name ?: "",
|
||||||
gameType = gameEntity.categoryChinese
|
gameType = gameEntity.categoryChinese
|
||||||
|
|||||||
@ -1,13 +1,11 @@
|
|||||||
package com.gh.common.constant;
|
package com.gh.common.constant;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.IntentFilter;
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.gh.common.util.PackageHelper;
|
import com.gh.common.util.PackageHelper;
|
||||||
@ -16,28 +14,21 @@ import com.gh.gamecenter.BuildConfig;
|
|||||||
import com.gh.gamecenter.common.constant.CommonConsts;
|
import com.gh.gamecenter.common.constant.CommonConsts;
|
||||||
import com.gh.gamecenter.common.constant.Constants;
|
import com.gh.gamecenter.common.constant.Constants;
|
||||||
import com.gh.gamecenter.common.eventbus.EBReuse;
|
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.retrofit.BiResponse;
|
||||||
import com.gh.gamecenter.common.retrofit.Response;
|
import com.gh.gamecenter.common.retrofit.Response;
|
||||||
import com.gh.gamecenter.common.utils.DarkModeUtils;
|
import com.gh.gamecenter.common.utils.DarkModeUtils;
|
||||||
import com.gh.gamecenter.common.utils.EnvHelper;
|
import com.gh.gamecenter.common.utils.EnvHelper;
|
||||||
import com.gh.gamecenter.core.AppExecutor;
|
|
||||||
import com.gh.gamecenter.core.utils.GsonUtils;
|
import com.gh.gamecenter.core.utils.GsonUtils;
|
||||||
import com.gh.gamecenter.core.utils.SPUtils;
|
import com.gh.gamecenter.core.utils.SPUtils;
|
||||||
import com.gh.gamecenter.core.utils.UrlFilterUtils;
|
import com.gh.gamecenter.core.utils.UrlFilterUtils;
|
||||||
import com.gh.gamecenter.entity.AppEntity;
|
|
||||||
import com.gh.gamecenter.entity.FloatWindowSettingEntity;
|
|
||||||
import com.gh.gamecenter.entity.GameGuidePopupEntity;
|
import com.gh.gamecenter.entity.GameGuidePopupEntity;
|
||||||
import com.gh.gamecenter.entity.NewApiSettingsEntity;
|
import com.gh.gamecenter.entity.NewApiSettingsEntity;
|
||||||
import com.gh.gamecenter.entity.NewSettingsEntity;
|
import com.gh.gamecenter.entity.NewSettingsEntity;
|
||||||
import com.gh.gamecenter.entity.VNewSetting;
|
|
||||||
import com.gh.gamecenter.entity.VSetting;
|
import com.gh.gamecenter.entity.VSetting;
|
||||||
import com.gh.gamecenter.feature.entity.SettingsEntity;
|
import com.gh.gamecenter.feature.entity.SettingsEntity;
|
||||||
import com.gh.gamecenter.feature.entity.SimulatorEntity;
|
import com.gh.gamecenter.feature.entity.SimulatorEntity;
|
||||||
import com.gh.gamecenter.feature.utils.ContentBlockedHelper;
|
import com.gh.gamecenter.feature.utils.ContentBlockedHelper;
|
||||||
import com.gh.gamecenter.receiver.PackageChangeBroadcastReceiver;
|
|
||||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||||
import com.gh.gamecenter.retrofit.service.VApiService;
|
|
||||||
import com.gh.vspace.VHelper;
|
import com.gh.vspace.VHelper;
|
||||||
import com.halo.assistant.HaloApp;
|
import com.halo.assistant.HaloApp;
|
||||||
|
|
||||||
@ -48,12 +39,8 @@ import org.json.JSONObject;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import io.reactivex.Observable;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.Single;
|
|
||||||
import io.reactivex.SingleSource;
|
|
||||||
import io.reactivex.functions.Function;
|
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
import io.reactivex.subjects.BehaviorSubject;
|
|
||||||
import okhttp3.ResponseBody;
|
import okhttp3.ResponseBody;
|
||||||
|
|
||||||
public class Config {
|
public class Config {
|
||||||
@ -63,11 +50,6 @@ public class Config {
|
|||||||
public static final String NEW_API_HOST = EnvHelper.getNewHost();
|
public static final String NEW_API_HOST = EnvHelper.getNewHost();
|
||||||
public static final String VAPI_HOST = EnvHelper.getVHost();
|
public static final String VAPI_HOST = EnvHelper.getVHost();
|
||||||
|
|
||||||
public static final String WGAME_CPM_BUSIAPPID = BuildConfig.WGAME_CPM_BUSIAPPID;
|
|
||||||
public static final String WGAME_CPM_API_HOST = EnvHelper.getWGameCPMHost();
|
|
||||||
|
|
||||||
public static final String DSP_API_HOST = EnvHelper.getDspHost();
|
|
||||||
|
|
||||||
// Third-Party confs
|
// Third-Party confs
|
||||||
public static final String WECHAT_APPID = BuildConfig.WECHAT_APPID;
|
public static final String WECHAT_APPID = BuildConfig.WECHAT_APPID;
|
||||||
public static final String WECHAT_SECRET = BuildConfig.WECHAT_SECRET;
|
public static final String WECHAT_SECRET = BuildConfig.WECHAT_SECRET;
|
||||||
@ -86,12 +68,6 @@ public class Config {
|
|||||||
private static NewApiSettingsEntity.NightMode mNightModeSetting;
|
private static NewApiSettingsEntity.NightMode mNightModeSetting;
|
||||||
private static SimulatorEntity mNewSimulatorEntity;
|
private static SimulatorEntity mNewSimulatorEntity;
|
||||||
private static VSetting mVSetting;
|
private static VSetting mVSetting;
|
||||||
private volatile static VNewSetting mVNewSetting;
|
|
||||||
|
|
||||||
private static FloatWindowSettingEntity mFloatWindowSetting;
|
|
||||||
|
|
||||||
private static AppEntity mNew32UpdateEntity;
|
|
||||||
private static BehaviorSubject<VNewSetting> vNewSettingSubject = BehaviorSubject.create();
|
|
||||||
private static GameGuidePopupEntity mGameGuidePopupEntity;
|
private static GameGuidePopupEntity mGameGuidePopupEntity;
|
||||||
private static SharedPreferences mDefaultSharedPreferences;
|
private static SharedPreferences mDefaultSharedPreferences;
|
||||||
|
|
||||||
@ -101,11 +77,24 @@ public class Config {
|
|||||||
return !SPUtils.getBoolean(Constants.SP_TEENAGER_MODE);
|
return !SPUtils.getBoolean(Constants.SP_TEENAGER_MODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VPN 开关选项是否开启
|
||||||
|
*/
|
||||||
|
public static boolean isVpnOptionEnabled() {
|
||||||
|
if (mNewApiSettingsEntity == null
|
||||||
|
|| mNewApiSettingsEntity.getInstall() == null
|
||||||
|
|| mNewApiSettingsEntity.getInstall().getVpnRequired() == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mNewApiSettingsEntity.getInstall().getVpnRequired().getShouldShowVpnOption();
|
||||||
|
}
|
||||||
|
|
||||||
public static void setSettings(SettingsEntity settingsEntity) {
|
public static void setSettings(SettingsEntity settingsEntity) {
|
||||||
getPreferences().edit().putString(SETTINGS_KEY, GsonUtils.toJson(settingsEntity)).apply();
|
getPreferences().edit().putString(SETTINGS_KEY, GsonUtils.toJson(settingsEntity)).apply();
|
||||||
mSettingsEntity = settingsEntity;
|
mSettingsEntity = settingsEntity;
|
||||||
|
|
||||||
PackageHelper.refreshPackageNameList();
|
PackageHelper.refreshList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@ -116,6 +105,8 @@ public class Config {
|
|||||||
if (!TextUtils.isEmpty(json)) {
|
if (!TextUtils.isEmpty(json)) {
|
||||||
mSettingsEntity = GsonUtils.fromJson(json, SettingsEntity.class);
|
mSettingsEntity = GsonUtils.fromJson(json, SettingsEntity.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mSettingsEntity.setGameSmooth("off");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -204,52 +195,6 @@ public class Config {
|
|||||||
return mVSetting;
|
return mVSetting;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public static VNewSetting getVNewSettingEntity() {
|
|
||||||
if (mVNewSetting == null) {
|
|
||||||
try {
|
|
||||||
String json = SPUtils.getString(Constants.SP_V_NEW_SETTINGS);
|
|
||||||
if (!TextUtils.isEmpty(json)) {
|
|
||||||
mVNewSetting = GsonUtils.fromJson(json, VNewSetting.class);
|
|
||||||
vNewSettingSubject.onNext(mVNewSetting);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return mVNewSetting;
|
|
||||||
}
|
|
||||||
@Nullable
|
|
||||||
public static FloatWindowSettingEntity getFloatWindowSettingEntity() {
|
|
||||||
if (mFloatWindowSetting == null) {
|
|
||||||
try {
|
|
||||||
String json = SPUtils.getString(Constants.SP_FLOAT_WINDOW_SETTINGS);
|
|
||||||
if (!TextUtils.isEmpty(json)) {
|
|
||||||
mFloatWindowSetting = GsonUtils.fromJson(json, FloatWindowSettingEntity.class);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return mFloatWindowSetting;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
public static Observable<VNewSetting> getVNewSettingObservable() {
|
|
||||||
if (mVNewSetting != null) {
|
|
||||||
return Observable.just(mVNewSetting);
|
|
||||||
} else {
|
|
||||||
return vNewSettingSubject.hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public static AppEntity getNew32UpdateEntity() {
|
|
||||||
return mNew32UpdateEntity;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 请求网络数据,尝试刷新畅玩相关配置
|
* 请求网络数据,尝试刷新畅玩相关配置
|
||||||
*/
|
*/
|
||||||
@ -258,41 +203,14 @@ public class Config {
|
|||||||
RetrofitManager.getInstance()
|
RetrofitManager.getInstance()
|
||||||
.getVApi().getSettings(BuildConfig.VERSION_NAME, Build.VERSION.SDK_INT)
|
.getVApi().getSettings(BuildConfig.VERSION_NAME, Build.VERSION.SDK_INT)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(new BiResponse<VSetting>() {
|
.subscribe(new BiResponse<VSetting>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(VSetting data) {
|
public void onSuccess(VSetting data) {
|
||||||
mVSetting = data;
|
mVSetting = data;
|
||||||
SPUtils.setString(Constants.SP_V_SETTINGS, GsonUtils.toJson(data));
|
SPUtils.setString(Constants.SP_V_SETTINGS, GsonUtils.toJson(data));
|
||||||
VHelper.checkVspaceUpdate(HaloApp.getInstance());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("CheckResult")
|
VHelper.init(HaloApp.getInstance());
|
||||||
public static void getNewSetting() {
|
|
||||||
VApiService vApi = RetrofitManager.getInstance().getVApi();
|
|
||||||
vApi.getNewSettings(BuildConfig.VERSION_NAME, Build.VERSION.SDK_INT).flatMap(new Function<VNewSetting, SingleSource<AppEntity>>() {
|
|
||||||
@Override
|
|
||||||
public SingleSource<AppEntity> apply(VNewSetting data) throws Exception {
|
|
||||||
mVNewSetting = data;
|
|
||||||
vNewSettingSubject.onNext(mVNewSetting);
|
|
||||||
SPUtils.setString(Constants.SP_V_NEW_SETTINGS, GsonUtils.toJson(data));
|
|
||||||
if (data.getVa() != null && data.getVa().getArch32() != null) {
|
|
||||||
String versionNameByPackageName = PackageUtils.getVersionNameByPackageName(data.getVa().getArch32().getPackageName());
|
|
||||||
return vApi.getNewPackageUpdate(
|
|
||||||
BuildConfig.VERSION_NAME,
|
|
||||||
versionNameByPackageName != null ? versionNameByPackageName : "",
|
|
||||||
HaloApp.getInstance().getChannel()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return Single.error(new IllegalStateException("VNewSetting entity is not expected"));
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.subscribe(new BiResponse<AppEntity>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(AppEntity data) {
|
|
||||||
mNew32UpdateEntity = data;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -320,6 +238,7 @@ public class Config {
|
|||||||
RetrofitManager.getInstance()
|
RetrofitManager.getInstance()
|
||||||
.getApi().getSettings(PackageUtils.getGhVersionName(), channel)
|
.getApi().getSettings(PackageUtils.getGhVersionName(), channel)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(new Response<SettingsEntity>() {
|
.subscribe(new Response<SettingsEntity>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(SettingsEntity response) {
|
public void onResponse(SettingsEntity response) {
|
||||||
@ -332,7 +251,7 @@ public class Config {
|
|||||||
edit.apply();
|
edit.apply();
|
||||||
|
|
||||||
if (!SPUtils.getBoolean(Constants.SP_TEENAGER_MODE)) {
|
if (!SPUtils.getBoolean(Constants.SP_TEENAGER_MODE)) {
|
||||||
AppExecutor.getUiExecutor().execute(() -> EventBus.getDefault().post(new EBReuse("Refresh")));
|
EventBus.getDefault().post(new EBReuse("Refresh"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -340,6 +259,7 @@ public class Config {
|
|||||||
RetrofitManager.getInstance()
|
RetrofitManager.getInstance()
|
||||||
.getApi().getNewSettings(Build.MANUFACTURER, Build.MODEL, channel, Build.VERSION.SDK_INT, BuildConfig.VERSION_NAME)
|
.getApi().getNewSettings(Build.MANUFACTURER, Build.MODEL, channel, Build.VERSION.SDK_INT, BuildConfig.VERSION_NAME)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(new BiResponse<NewSettingsEntity>() {
|
.subscribe(new BiResponse<NewSettingsEntity>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(NewSettingsEntity data) {
|
public void onSuccess(NewSettingsEntity data) {
|
||||||
@ -349,12 +269,11 @@ public class Config {
|
|||||||
});
|
});
|
||||||
|
|
||||||
refreshVSettingEntity();
|
refreshVSettingEntity();
|
||||||
getNewSetting();
|
|
||||||
getFloatWindowSetting();
|
|
||||||
|
|
||||||
RetrofitManager.getInstance()
|
RetrofitManager.getInstance()
|
||||||
.getApi().getGameGuidePopup(Build.MANUFACTURER, Build.VERSION.RELEASE, Build.MODEL, channel, BuildConfig.VERSION_NAME)
|
.getApi().getGameGuidePopup(Build.MANUFACTURER, Build.VERSION.RELEASE, Build.MODEL, channel, BuildConfig.VERSION_NAME)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(new BiResponse<GameGuidePopupEntity>() {
|
.subscribe(new BiResponse<GameGuidePopupEntity>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(GameGuidePopupEntity data) {
|
public void onSuccess(GameGuidePopupEntity data) {
|
||||||
@ -366,6 +285,7 @@ public class Config {
|
|||||||
if (manufacturer.equals("OPPO") || manufacturer.equals("VIVO")) {
|
if (manufacturer.equals("OPPO") || manufacturer.equals("VIVO")) {
|
||||||
RetrofitManager.getInstance().getNewApi().getBrowserHintUrl(manufacturer)
|
RetrofitManager.getInstance().getNewApi().getBrowserHintUrl(manufacturer)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(new BiResponse<ResponseBody>() {
|
.subscribe(new BiResponse<ResponseBody>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(ResponseBody data) {
|
public void onSuccess(ResponseBody data) {
|
||||||
@ -389,13 +309,12 @@ public class Config {
|
|||||||
String filterString = UrlFilterUtils.getFilterQuery(
|
String filterString = UrlFilterUtils.getFilterQuery(
|
||||||
"manufacturer", Build.MANUFACTURER,
|
"manufacturer", Build.MANUFACTURER,
|
||||||
"model", Build.MODEL,
|
"model", Build.MODEL,
|
||||||
"android_sdk_version", String.valueOf(Build.VERSION.SDK_INT),
|
"android_sdk_version", String.valueOf(Build.VERSION.SDK_INT));
|
||||||
"rom", MetaUtil.INSTANCE.getRom().getRomName() + " " + MetaUtil.INSTANCE.getRom().getRomVersion()
|
|
||||||
);
|
|
||||||
|
|
||||||
RetrofitManager.getInstance()
|
RetrofitManager.getInstance()
|
||||||
.getNewApi().getNewSettings(PackageUtils.getGhVersionName(), channel, filterString)
|
.getNewApi().getNewSettings(PackageUtils.getGhVersionName(), channel, filterString)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(new BiResponse<NewApiSettingsEntity>() {
|
.subscribe(new BiResponse<NewApiSettingsEntity>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(NewApiSettingsEntity data) {
|
public void onSuccess(NewApiSettingsEntity data) {
|
||||||
@ -404,7 +323,7 @@ public class Config {
|
|||||||
mNewSimulatorEntity = data.getSimulator();
|
mNewSimulatorEntity = data.getSimulator();
|
||||||
if (HaloApp.getInstance().isNewForThisVersion && mNightModeSetting != null && mNightModeSetting.getInstall()) {
|
if (HaloApp.getInstance().isNewForThisVersion && mNightModeSetting != null && mNightModeSetting.getInstall()) {
|
||||||
DarkModeUtils.INSTANCE.updateFollowSystemDarkModeToSp(true);
|
DarkModeUtils.INSTANCE.updateFollowSystemDarkModeToSp(true);
|
||||||
AppExecutor.getUiExecutor().execute(DarkModeUtils.INSTANCE::initDarkMode);
|
DarkModeUtils.INSTANCE.initDarkMode();
|
||||||
}
|
}
|
||||||
SPUtils.setString(Constants.SP_NEW_API_SETTINGS, GsonUtils.toJson(data));
|
SPUtils.setString(Constants.SP_NEW_API_SETTINGS, GsonUtils.toJson(data));
|
||||||
|
|
||||||
@ -412,45 +331,8 @@ public class Config {
|
|||||||
if (mNewApiSettingsEntity.getGameShieldContents() != null) {
|
if (mNewApiSettingsEntity.getGameShieldContents() != null) {
|
||||||
ContentBlockedHelper.INSTANCE.init(mNewApiSettingsEntity.getGameShieldContents());
|
ContentBlockedHelper.INSTANCE.init(mNewApiSettingsEntity.getGameShieldContents());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新安装列表是否开启的配置
|
|
||||||
if (mNewApiSettingsEntity.getInstalledComplianceSwitch() != null) {
|
|
||||||
PackageHelper.INSTANCE.updateIsGetInstalledPackagesApiAgreedRequired(mNewApiSettingsEntity.getInstalledComplianceSwitch());
|
|
||||||
} else {
|
|
||||||
PackageHelper.INSTANCE.updateIsGetInstalledPackagesApiAgreedRequired(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 更新包名监听是否开启
|
|
||||||
if (mNewApiSettingsEntity.isPackageObserveEnable()) {
|
|
||||||
AppExecutor.getUiExecutor().execute(() -> observePackageChange(mNewApiSettingsEntity.getPackageObserveActions()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("CheckResult")
|
|
||||||
private static void getFloatWindowSetting() {
|
|
||||||
RetrofitManager.getInstance().getNewApi()
|
|
||||||
.getFloatWindowSettings()
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.subscribe(new BiResponse<FloatWindowSettingEntity>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(FloatWindowSettingEntity data) {
|
|
||||||
mFloatWindowSetting = data;
|
|
||||||
SPUtils.setString(Constants.SP_FLOAT_WINDOW_SETTINGS, GsonUtils.toJson(data));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void observePackageChange(NewApiSettingsEntity.PackageObserveActions packageObserveActions) {
|
|
||||||
PackageChangeBroadcastReceiver receiver = new PackageChangeBroadcastReceiver(packageObserveActions);
|
|
||||||
IntentFilter intentFilter = new IntentFilter();
|
|
||||||
intentFilter.addAction(packageObserveActions.getAdd());
|
|
||||||
intentFilter.addAction(packageObserveActions.getRem());
|
|
||||||
intentFilter.addAction(packageObserveActions.getRep());
|
|
||||||
intentFilter.addDataScheme("package");
|
|
||||||
HaloApp.getInstance().registerReceiver(receiver, intentFilter);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -120,14 +120,14 @@ object AddKaiFuBindingAdapter {
|
|||||||
@BindingAdapter("kaiFuTextColor", "kaiFuTextPosition")
|
@BindingAdapter("kaiFuTextColor", "kaiFuTextPosition")
|
||||||
fun kaiFuTextColor(view: EditText, dataMark: Int, position: Int) {
|
fun kaiFuTextColor(view: EditText, dataMark: Int, position: Int) {
|
||||||
if (dataMark == 1 && view.id == R.id.kaifu_add_time || dataMark == 2 && view.id == R.id.kaifu_add_first_name || dataMark == 3 && view.id == R.id.kaifu_add_server_name || dataMark == 4) {
|
if (dataMark == 1 && view.id == R.id.kaifu_add_time || dataMark == 2 && view.id == R.id.kaifu_add_first_name || dataMark == 3 && view.id == R.id.kaifu_add_server_name || dataMark == 4) {
|
||||||
view.setTextColor(ContextCompat.getColor(view.context, com.gh.gamecenter.common.R.color.secondary_red))
|
view.setTextColor(ContextCompat.getColor(view.context, R.color.secondary_red))
|
||||||
view.setHintTextColor(ContextCompat.getColor(view.context, com.gh.gamecenter.common.R.color.secondary_red))
|
view.setHintTextColor(ContextCompat.getColor(view.context, R.color.secondary_red))
|
||||||
} else if (position == 0) {
|
} else if (position == 0) {
|
||||||
view.setTextColor(ContextCompat.getColor(view.context, com.gh.gamecenter.common.R.color.hint))
|
view.setTextColor(ContextCompat.getColor(view.context, R.color.hint))
|
||||||
view.setHintTextColor(ContextCompat.getColor(view.context, com.gh.gamecenter.common.R.color.hint))
|
view.setHintTextColor(ContextCompat.getColor(view.context, R.color.hint))
|
||||||
} else {
|
} else {
|
||||||
view.setTextColor(ContextCompat.getColor(view.context, com.gh.gamecenter.common.R.color.text_primary))
|
view.setTextColor(ContextCompat.getColor(view.context, R.color.text_primary))
|
||||||
view.setHintTextColor(ContextCompat.getColor(view.context, com.gh.gamecenter.common.R.color.hint))
|
view.setHintTextColor(ContextCompat.getColor(view.context, R.color.hint))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +176,7 @@ object AddKaiFuBindingAdapter {
|
|||||||
popupWindow.isTouchable = true
|
popupWindow.isTouchable = true
|
||||||
popupWindow.inputMethodMode = PopupWindow.INPUT_METHOD_NEEDED
|
popupWindow.inputMethodMode = PopupWindow.INPUT_METHOD_NEEDED
|
||||||
popupWindow.isOutsideTouchable = true
|
popupWindow.isOutsideTouchable = true
|
||||||
popupWindow.animationStyle = com.gh.gamecenter.common.R.style.popwindow_option_anim_style
|
popupWindow.animationStyle = R.style.popwindow_option_anim_style
|
||||||
|
|
||||||
// 设置偏移
|
// 设置偏移
|
||||||
windowPos[1] = windowPos[1] - 12F.dip2px()
|
windowPos[1] = windowPos[1] - 12F.dip2px()
|
||||||
|
|||||||
@ -1,10 +1,5 @@
|
|||||||
package com.gh.common.databind;
|
package com.gh.common.databind;
|
||||||
|
|
||||||
import static com.gh.gamecenter.entity.SubjectEntity.SUBJECT_TAG_SELLING_POINT;
|
|
||||||
import static com.gh.gamecenter.entity.SubjectEntity.SUBJECT_TAG_TEST;
|
|
||||||
import static com.gh.gamecenter.entity.SubjectEntity.SUBJECT_TAG_TYPE;
|
|
||||||
import static com.gh.gamecenter.entity.SubjectEntity.SUBJECT_TAG_UPDATE;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
@ -13,20 +8,17 @@ import android.text.SpannableString;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.style.ForegroundColorSpan;
|
import android.text.style.ForegroundColorSpan;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewParent;
|
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
|
||||||
import androidx.constraintlayout.widget.ConstraintSet;
|
|
||||||
|
|
||||||
import com.gh.common.chain.BrowserInstallHandler;
|
import com.gh.common.chain.BrowserInstallHandler;
|
||||||
import com.gh.common.chain.CheckDownloadHandler;
|
|
||||||
import com.gh.common.chain.CheckStoragePermissionHandler;
|
|
||||||
import com.gh.common.chain.DownloadChainBuilder;
|
import com.gh.common.chain.DownloadChainBuilder;
|
||||||
import com.gh.common.chain.DownloadChainHandler;
|
import com.gh.common.chain.DownloadChainHandler;
|
||||||
|
import com.gh.common.chain.CheckDownloadHandler;
|
||||||
|
import com.gh.common.chain.CheckStoragePermissionHandler;
|
||||||
import com.gh.common.chain.DownloadDialogHelperHandler;
|
import com.gh.common.chain.DownloadDialogHelperHandler;
|
||||||
import com.gh.common.chain.GamePermissionHandler;
|
import com.gh.common.chain.GamePermissionHandler;
|
||||||
import com.gh.common.chain.LandPageAddressHandler;
|
import com.gh.common.chain.LandPageAddressHandler;
|
||||||
@ -35,6 +27,7 @@ import com.gh.common.chain.PackageCheckHandler;
|
|||||||
import com.gh.common.chain.UnsupportedFeatureHandler;
|
import com.gh.common.chain.UnsupportedFeatureHandler;
|
||||||
import com.gh.common.chain.ValidateVSpaceHandler;
|
import com.gh.common.chain.ValidateVSpaceHandler;
|
||||||
import com.gh.common.chain.VersionNumberHandler;
|
import com.gh.common.chain.VersionNumberHandler;
|
||||||
|
import com.gh.common.constant.Config;
|
||||||
import com.gh.common.filter.RegionSetting;
|
import com.gh.common.filter.RegionSetting;
|
||||||
import com.gh.common.filter.RegionSettingHelper;
|
import com.gh.common.filter.RegionSettingHelper;
|
||||||
import com.gh.common.history.HistoryHelper;
|
import com.gh.common.history.HistoryHelper;
|
||||||
@ -56,15 +49,14 @@ import com.gh.download.server.BrowserInstallHelper;
|
|||||||
import com.gh.gamecenter.DownloadManagerActivity;
|
import com.gh.gamecenter.DownloadManagerActivity;
|
||||||
import com.gh.gamecenter.R;
|
import com.gh.gamecenter.R;
|
||||||
import com.gh.gamecenter.WebActivity;
|
import com.gh.gamecenter.WebActivity;
|
||||||
import com.gh.gamecenter.common.databinding.LayoutGameItemSellingPointBinding;
|
|
||||||
import com.gh.gamecenter.common.entity.LinkEntity;
|
import com.gh.gamecenter.common.entity.LinkEntity;
|
||||||
import com.gh.gamecenter.common.utils.DarkModeUtils;
|
import com.gh.gamecenter.common.utils.DarkModeUtils;
|
||||||
import com.gh.gamecenter.common.utils.ExtensionsKt;
|
import com.gh.gamecenter.common.utils.ExtensionsKt;
|
||||||
import com.gh.gamecenter.common.utils.FileUtils;
|
import com.gh.gamecenter.common.utils.FileUtils;
|
||||||
|
import com.gh.gamecenter.common.utils.ImageUtils;
|
||||||
import com.gh.gamecenter.common.utils.NewFlatLogUtils;
|
import com.gh.gamecenter.common.utils.NewFlatLogUtils;
|
||||||
import com.gh.gamecenter.common.utils.SensorsBridge;
|
import com.gh.gamecenter.common.utils.SensorsBridge;
|
||||||
import com.gh.gamecenter.core.utils.MtaHelper;
|
import com.gh.gamecenter.core.utils.MtaHelper;
|
||||||
import com.gh.gamecenter.core.utils.TimeUtils;
|
|
||||||
import com.gh.gamecenter.core.utils.ToastUtils;
|
import com.gh.gamecenter.core.utils.ToastUtils;
|
||||||
import com.gh.gamecenter.feature.entity.ApkEntity;
|
import com.gh.gamecenter.feature.entity.ApkEntity;
|
||||||
import com.gh.gamecenter.feature.entity.GameEntity;
|
import com.gh.gamecenter.feature.entity.GameEntity;
|
||||||
@ -180,7 +172,7 @@ public class BindingAdapters {
|
|||||||
builder.addHandler(new OverseaDownloadHandler());
|
builder.addHandler(new OverseaDownloadHandler());
|
||||||
builder.addHandler(new CheckDownloadHandler());
|
builder.addHandler(new CheckDownloadHandler());
|
||||||
|
|
||||||
builder.setProcessEndCallback(gameEntity.getId(), (asVGame, isSubscribe) -> {
|
builder.setProcessEndCallback((asVGame, isSubscribe) -> {
|
||||||
download(v.getContext(),
|
download(v.getContext(),
|
||||||
progressBar,
|
progressBar,
|
||||||
gameEntity,
|
gameEntity,
|
||||||
@ -205,14 +197,13 @@ public class BindingAdapters {
|
|||||||
builder.addHandler(new GamePermissionHandler());
|
builder.addHandler(new GamePermissionHandler());
|
||||||
builder.addHandler(new VersionNumberHandler());
|
builder.addHandler(new VersionNumberHandler());
|
||||||
|
|
||||||
builder.setProcessEndCallback(gameEntity.getId(), (asVGame, isSubscribe) -> {
|
builder.setProcessEndCallback((asVGame, isSubscribe) -> {
|
||||||
DownloadDialog.showDownloadDialog(
|
DownloadDialog.showDownloadDialog(
|
||||||
v.getContext(),
|
v.getContext(),
|
||||||
gameEntity,
|
gameEntity,
|
||||||
traceEvent,
|
traceEvent,
|
||||||
entrance,
|
entrance,
|
||||||
location + ":" + gameEntity.getName(),
|
location + ":" + gameEntity.getName());
|
||||||
null);
|
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
final DownloadChainHandler chainHandler = builder.buildHandlerChain();
|
final DownloadChainHandler chainHandler = builder.buildHandlerChain();
|
||||||
@ -257,8 +248,7 @@ public class BindingAdapters {
|
|||||||
gameEntity,
|
gameEntity,
|
||||||
traceEvent,
|
traceEvent,
|
||||||
entrance,
|
entrance,
|
||||||
location + ":" + gameEntity.getName(),
|
location + ":" + gameEntity.getName());
|
||||||
null);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case INSTALL_PLUGIN:
|
case INSTALL_PLUGIN:
|
||||||
@ -274,9 +264,7 @@ public class BindingAdapters {
|
|||||||
SensorsBridge.trackInstallGameClick(
|
SensorsBridge.trackInstallGameClick(
|
||||||
gameEntity.getId(),
|
gameEntity.getId(),
|
||||||
gameEntity.getName() != null ? gameEntity.getName() : "",
|
gameEntity.getName() != null ? gameEntity.getName() : "",
|
||||||
"主动安装",
|
"主动安装"
|
||||||
gameEntity.isDspGame(),
|
|
||||||
gameEntity.getDspAdId()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
DownloadEntity downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity);
|
DownloadEntity downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity);
|
||||||
@ -301,11 +289,19 @@ public class BindingAdapters {
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case RESERVED:
|
case RESERVED:
|
||||||
ReservationHelper.showCancelReservationDialog(progressBar.getContext(), gameEntity, () -> {
|
if ("download".equals(gameEntity.getReserveStatus())) {
|
||||||
ReservationHelper.cancelReservation(gameEntity, () -> {
|
ReservationHelper.showDeleteReservationDialog(progressBar.getContext(), () -> {
|
||||||
updateReservation(progressBar, gameEntity);
|
ReservationHelper.deleteReservation(gameEntity, () -> {
|
||||||
|
updateReservation(progressBar, gameEntity);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
} else {
|
||||||
|
ReservationHelper.showCancelReservationDialog(progressBar.getContext(), () -> {
|
||||||
|
ReservationHelper.cancelReservation(gameEntity, () -> {
|
||||||
|
updateReservation(progressBar, gameEntity);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case H5_GAME:
|
case H5_GAME:
|
||||||
LinkEntity linkEntity = gameEntity.getH5Link();
|
LinkEntity linkEntity = gameEntity.getH5Link();
|
||||||
@ -351,9 +347,9 @@ public class BindingAdapters {
|
|||||||
}
|
}
|
||||||
progressBar.setButtonStyle(DownloadButton.ButtonStyle.H5_GAME);
|
progressBar.setButtonStyle(DownloadButton.ButtonStyle.H5_GAME);
|
||||||
} else {
|
} else {
|
||||||
if (("dialog".equals(offStatus) || "third_party".equals(offStatus))) {
|
if (offStatus != null && "dialog".equals(offStatus)) {
|
||||||
progressBar.setText("查看");
|
progressBar.setText("查看");
|
||||||
progressBar.setButtonStyle(DownloadButton.ButtonStyle.NONE_WITH_HINT);
|
progressBar.setButtonStyle(DownloadButton.ButtonStyle.NONE);
|
||||||
} else if ("updating".equals(offStatus)) {
|
} else if ("updating".equals(offStatus)) {
|
||||||
progressBar.setText("更新中");
|
progressBar.setText("更新中");
|
||||||
progressBar.setButtonStyle(DownloadButton.ButtonStyle.UPDATING);
|
progressBar.setButtonStyle(DownloadButton.ButtonStyle.UPDATING);
|
||||||
@ -393,7 +389,7 @@ public class BindingAdapters {
|
|||||||
case diskisfull:
|
case diskisfull:
|
||||||
case diskioerror:
|
case diskioerror:
|
||||||
case waiting:
|
case waiting:
|
||||||
progressBar.setText(com.gh.gamecenter.feature.R.string.downloading);
|
progressBar.setText(R.string.downloading);
|
||||||
if (downloadEntity.isPluggable() && PackagesManager.isInstalled(downloadEntity.getPackageName())) {
|
if (downloadEntity.isPluggable() && PackagesManager.isInstalled(downloadEntity.getPackageName())) {
|
||||||
progressBar.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_PLUGIN);
|
progressBar.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_PLUGIN);
|
||||||
} else {
|
} else {
|
||||||
@ -401,7 +397,7 @@ public class BindingAdapters {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case done:
|
case done:
|
||||||
progressBar.setText(com.gh.gamecenter.feature.R.string.install);
|
progressBar.setText(R.string.install);
|
||||||
if (downloadEntity.isPluggable()
|
if (downloadEntity.isPluggable()
|
||||||
&& PackagesManager.isInstalled(downloadEntity.getPackageName())) {
|
&& PackagesManager.isInstalled(downloadEntity.getPackageName())) {
|
||||||
progressBar.setButtonStyle(DownloadButton.ButtonStyle.INSTALL_PLUGIN);
|
progressBar.setButtonStyle(DownloadButton.ButtonStyle.INSTALL_PLUGIN);
|
||||||
@ -484,37 +480,39 @@ public class BindingAdapters {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// 包含测试开服标签
|
||||||
* 包含测试开服标签
|
public static void setGameTags(LinearLayout layout, GameEntity gameEntity) {
|
||||||
*
|
|
||||||
* @param layout
|
|
||||||
* @param gameEntity
|
|
||||||
* @param subjectTag 默认为 “”,只有游戏专题可以配置subjectTag
|
|
||||||
*/
|
|
||||||
public static void setGameTags(LinearLayout layout, GameEntity gameEntity, String subjectTag) {
|
|
||||||
try {
|
try {
|
||||||
if (layout.getVisibility() == View.GONE) return;
|
if (layout.getVisibility() == View.GONE) return;
|
||||||
ArrayList<TagStyleEntity> tagStyle = new ArrayList<>();
|
ArrayList<TagStyleEntity> tagStyle = new ArrayList<>();
|
||||||
TestEntity test = gameEntity.getTest();
|
TestEntity test = gameEntity.getTest();
|
||||||
if (test != null && subjectTag.equals(SUBJECT_TAG_TEST)) {
|
if (test != null
|
||||||
// 显示开测表标签
|
// 这个判断用于开测表列表
|
||||||
TagStyleEntity typeTag = new TagStyleEntity();
|
&& !"type_tag".equals(test.getGameTag())) {
|
||||||
boolean isDarkModeOn = DarkModeUtils.INSTANCE.isDarkModeOn(layout.getContext());
|
if ("custom".equals(test.getGameTag())) {
|
||||||
typeTag.setName(test.getType() != null ? test.getType() : "");
|
TagStyleEntity typeTag = new TagStyleEntity();
|
||||||
typeTag.setBackground("1AFFA142");
|
if (!TextUtils.isEmpty(test.getText())) {
|
||||||
typeTag.setColor(isDarkModeOn ? "EB9238" : "FFA142");
|
typeTag.setName(test.getText() != null ? test.getText() : "");
|
||||||
tagStyle.add(typeTag);
|
} else {
|
||||||
|
typeTag.setName(test.getType() != null ? test.getType() : "");
|
||||||
TagStyleEntity timeTag = new TagStyleEntity();
|
}
|
||||||
if (test.getStartPending()) {
|
typeTag.setBackground("E8F3FF");
|
||||||
timeTag.setName(test.getStartText());
|
typeTag.setColor("1383EB");
|
||||||
|
tagStyle.add(typeTag);
|
||||||
} else {
|
} else {
|
||||||
timeTag.setName(GameViewUtils.getGameTestDate(test.getStart()));
|
TagStyleEntity typeTag = new TagStyleEntity();
|
||||||
}
|
boolean isDarkModeOn = DarkModeUtils.INSTANCE.isDarkModeOn(layout.getContext());
|
||||||
timeTag.setBackground("1A06CEA8");
|
typeTag.setName(test.getType() != null ? test.getType() : "");
|
||||||
timeTag.setColor(isDarkModeOn ? "07A385" : "06CEA8");
|
typeTag.setBackground("1AFFA142");
|
||||||
tagStyle.add(timeTag);
|
typeTag.setColor(isDarkModeOn ? "EB9238" : "FFA142");
|
||||||
|
tagStyle.add(typeTag);
|
||||||
|
|
||||||
|
TagStyleEntity timeTag = new TagStyleEntity();
|
||||||
|
timeTag.setName(GameViewUtils.getGameTestDate(test.getStart()));
|
||||||
|
timeTag.setBackground("1A06CEA8");
|
||||||
|
timeTag.setColor(isDarkModeOn ? "07A385" : "06CEA8");
|
||||||
|
tagStyle.add(timeTag);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
tagStyle = gameEntity.getTagStyle();
|
tagStyle = gameEntity.getTagStyle();
|
||||||
}
|
}
|
||||||
@ -524,68 +522,6 @@ public class BindingAdapters {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setGameTagsWithSellingPoint(LinearLayout layout, LayoutGameItemSellingPointBinding binding, GameEntity gameEntity, String subjectTag) {
|
|
||||||
if (subjectTag.equals(SUBJECT_TAG_SELLING_POINT)) {
|
|
||||||
layout.setVisibility(View.GONE);
|
|
||||||
binding.getRoot().setVisibility(View.VISIBLE);
|
|
||||||
GameEntity.SellingPoints sellingPoints = gameEntity.getSellingPoints();
|
|
||||||
if (sellingPoints != null) {
|
|
||||||
binding.tvSellingPoints.setVisibility(View.VISIBLE);
|
|
||||||
binding.tvSellingPoints.setText(sellingPoints.getText());
|
|
||||||
} else {
|
|
||||||
binding.tvSellingPoints.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayList<TagStyleEntity> tagStyle = gameEntity.getTagStyle();
|
|
||||||
StringBuilder tagText = new StringBuilder();
|
|
||||||
for (int i = 0; i < tagStyle.size(); i++) {
|
|
||||||
if (i < 3) {
|
|
||||||
tagText.append(i == 0 ? "" : "·").append(tagStyle.get(i).getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
binding.gtcvTags.setText(tagText);
|
|
||||||
} else {
|
|
||||||
layout.setVisibility(View.VISIBLE);
|
|
||||||
binding.getRoot().setVisibility(View.GONE);
|
|
||||||
switch (subjectTag) {
|
|
||||||
case SUBJECT_TAG_UPDATE:
|
|
||||||
List<TagStyleEntity> updateTags = new ArrayList<>();
|
|
||||||
TagStyleEntity updateTag = new TagStyleEntity(
|
|
||||||
"local_generated",
|
|
||||||
TimeUtils.getFormatTime(gameEntity.getUpdateTime(), "MM-dd") + " 更新",
|
|
||||||
"",
|
|
||||||
"1383EB",
|
|
||||||
"E8F3FF",
|
|
||||||
"1383EB",
|
|
||||||
false
|
|
||||||
);
|
|
||||||
updateTags.add(updateTag);
|
|
||||||
GameViewUtils.setLabelList(layout.getContext(), layout, updateTags);
|
|
||||||
break;
|
|
||||||
case SUBJECT_TAG_TYPE:
|
|
||||||
GameViewUtils.setLabelList(layout.getContext(), layout, gameEntity.getTagStyle());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
setGameTags(layout, gameEntity, subjectTag);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ViewParent parent = binding.getRoot().getParent();
|
|
||||||
if (parent instanceof ConstraintLayout) {
|
|
||||||
ConstraintLayout constraintLayout = (ConstraintLayout) parent;
|
|
||||||
ConstraintSet constraintSet = new ConstraintSet();
|
|
||||||
constraintSet.clone(constraintLayout);
|
|
||||||
constraintSet.clear(R.id.gameDesSpace, ConstraintSet.BOTTOM);
|
|
||||||
if (subjectTag.equals(SUBJECT_TAG_SELLING_POINT)) {
|
|
||||||
constraintSet.connect(R.id.gameDesSpace, ConstraintSet.BOTTOM, R.id.layout_selling_points, ConstraintSet.TOP);
|
|
||||||
} else {
|
|
||||||
constraintSet.connect(R.id.gameDesSpace, ConstraintSet.BOTTOM, R.id.label_list, ConstraintSet.TOP);
|
|
||||||
}
|
|
||||||
constraintSet.applyTo(constraintLayout);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setVideoDetailGameTags(LinearLayout layout, GameEntity gameEntity) {
|
public static void setVideoDetailGameTags(LinearLayout layout, GameEntity gameEntity) {
|
||||||
try {
|
try {
|
||||||
ArrayList<TagStyleEntity> tagStyle = new ArrayList<>();
|
ArrayList<TagStyleEntity> tagStyle = new ArrayList<>();
|
||||||
@ -619,15 +555,15 @@ public class BindingAdapters {
|
|||||||
gameName = String.format("%s - %s", game.getName(),
|
gameName = String.format("%s - %s", game.getName(),
|
||||||
PlatformUtils.getInstance(view.getContext()).getPlatformName(
|
PlatformUtils.getInstance(view.getContext()).getPlatformName(
|
||||||
game.getApk().get(0).getPlatform()));
|
game.getApk().get(0).getPlatform()));
|
||||||
if (!gameName.equals((String) view.getTag(com.gh.gamecenter.common.R.string.tag_game_name_id))) {
|
if (!gameName.equals((String) view.getTag(R.string.tag_game_name_id))) {
|
||||||
view.setText(gameName);
|
view.setText(gameName);
|
||||||
view.setTag(com.gh.gamecenter.common.R.string.tag_game_name_id, gameName);
|
view.setTag(R.string.tag_game_name_id, gameName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
gameName = game.getName();
|
gameName = game.getName();
|
||||||
if (gameName != null && !gameName.equals((String) view.getTag(com.gh.gamecenter.common.R.string.tag_game_name_id))) {
|
if (gameName != null && !gameName.equals((String) view.getTag(R.string.tag_game_name_id))) {
|
||||||
view.setText(gameName);
|
view.setText(gameName);
|
||||||
view.setTag(com.gh.gamecenter.common.R.string.tag_game_name_id, gameName);
|
view.setTag(R.string.tag_game_name_id, gameName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,294 +0,0 @@
|
|||||||
package com.gh.common.dialog
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.os.Parcelable
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import com.gh.common.util.DirectUtils
|
|
||||||
import com.gh.gamecenter.R
|
|
||||||
import com.gh.gamecenter.common.HaloApp
|
|
||||||
import com.gh.gamecenter.common.base.fragment.BaseDialogFragment
|
|
||||||
import com.gh.gamecenter.common.constant.Constants
|
|
||||||
import com.gh.gamecenter.common.utils.SensorsBridge
|
|
||||||
import com.gh.gamecenter.common.utils.dip2px
|
|
||||||
import com.gh.gamecenter.core.utils.CurrentActivityHolder
|
|
||||||
import com.gh.gamecenter.core.utils.SPUtils
|
|
||||||
import com.gh.gamecenter.databinding.DialogFragmentAccelerateExporationBinding
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
|
|
||||||
public class AccelerateExpirationDialogFragment : BaseDialogFragment() {
|
|
||||||
|
|
||||||
private lateinit var binding: DialogFragmentAccelerateExporationBinding
|
|
||||||
|
|
||||||
private var _reminder: ExpirationReminder? = null
|
|
||||||
|
|
||||||
override fun onBack(): Boolean {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
_reminder = arguments?.getParcelable(KEY_EXPIRATION_REMINDER)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
|
||||||
return DialogFragmentAccelerateExporationBinding.inflate(inflater, container, false)
|
|
||||||
.also {
|
|
||||||
binding = it
|
|
||||||
}.root
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
||||||
super.onViewCreated(view, savedInstanceState)
|
|
||||||
|
|
||||||
val reminder = _reminder ?: return
|
|
||||||
val (title, content) = when (reminder) {
|
|
||||||
is ExpirationReminder.UserExpired -> {
|
|
||||||
SensorsBridge.trackMonthlyPackageExpiresDialogShow(
|
|
||||||
reminder.gameId, reminder.gameName, reminder.pkgName, reminder.sourceEntrance
|
|
||||||
)
|
|
||||||
getString(
|
|
||||||
R.string.membership_expiration_reminder_title,
|
|
||||||
"${reminder.days}"
|
|
||||||
) to getString(R.string.membership_expiration_reminder_content)
|
|
||||||
}
|
|
||||||
|
|
||||||
is ExpirationReminder.InsufficientDuration -> {
|
|
||||||
SensorsBridge.trackInsufficientDurationDialogShow(
|
|
||||||
reminder.gameId,
|
|
||||||
reminder.gameName,
|
|
||||||
reminder.pkgName,
|
|
||||||
reminder.sourceEntrance
|
|
||||||
)
|
|
||||||
getString(
|
|
||||||
R.string.duration_time_out_reminder_title,
|
|
||||||
"${reminder.hours}"
|
|
||||||
) to getString(R.string.duration_time_out_reminder_content)
|
|
||||||
}
|
|
||||||
|
|
||||||
is ExpirationReminder.DurationExpired -> {
|
|
||||||
SensorsBridge.trackTimedPackageExpiresDialogShow(
|
|
||||||
reminder.gameId,
|
|
||||||
reminder.gameName,
|
|
||||||
reminder.pkgName,
|
|
||||||
reminder.sourceEntrance
|
|
||||||
)
|
|
||||||
getString(
|
|
||||||
R.string.duration_expiration_reminder_title,
|
|
||||||
"${reminder.days}"
|
|
||||||
) to getString(R.string.duration_expiration_reminder_content)
|
|
||||||
}
|
|
||||||
|
|
||||||
is ExpirationReminder.TimeRunsOut -> {
|
|
||||||
SensorsBridge.trackDurationExhaustedDialogShow()
|
|
||||||
getString(R.string.accelerator_member_expired_title) to getString(R.string.accelerator_member_expired_content)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.tvTitle.text = title
|
|
||||||
binding.tvContent.text = content
|
|
||||||
binding.tvCancel.setOnClickListener {
|
|
||||||
when (reminder) {
|
|
||||||
is ExpirationReminder.UserExpired -> {
|
|
||||||
SensorsBridge.trackMonthlyPackageExpiresDialogClick(
|
|
||||||
reminder.gameId, reminder.gameName, reminder.pkgName, reminder.sourceEntrance, BUTTON_NAME_KNOW
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
is ExpirationReminder.InsufficientDuration -> {
|
|
||||||
SensorsBridge.trackInsufficientDurationDialogClick(
|
|
||||||
reminder.gameId, reminder.gameName, reminder.pkgName, reminder.sourceEntrance, BUTTON_NAME_KNOW
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
is ExpirationReminder.DurationExpired -> {
|
|
||||||
SensorsBridge.trackTimedPackageExpiresDialogClick(
|
|
||||||
reminder.gameId, reminder.gameName, reminder.pkgName, reminder.sourceEntrance, BUTTON_NAME_KNOW
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
is ExpirationReminder.TimeRunsOut -> {
|
|
||||||
SensorsBridge.trackDurationExhaustedDialogClick(BUTTON_NAME_KNOW)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dismissAllowingStateLoss()
|
|
||||||
}
|
|
||||||
binding.tvSubmit.setOnClickListener {
|
|
||||||
when (reminder) {
|
|
||||||
is ExpirationReminder.UserExpired -> {
|
|
||||||
SensorsBridge.trackMonthlyPackageExpiresDialogClick(
|
|
||||||
reminder.gameId, reminder.gameName, reminder.pkgName, reminder.sourceEntrance, BUTTON_NAME_BUY
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
is ExpirationReminder.InsufficientDuration -> {
|
|
||||||
SensorsBridge.trackInsufficientDurationDialogClick(
|
|
||||||
reminder.gameId, reminder.gameName, reminder.pkgName, reminder.sourceEntrance, BUTTON_NAME_BUY
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
is ExpirationReminder.DurationExpired -> {
|
|
||||||
SensorsBridge.trackTimedPackageExpiresDialogClick(
|
|
||||||
reminder.gameId, reminder.gameName, reminder.pkgName, reminder.sourceEntrance, BUTTON_NAME_BUY
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
is ExpirationReminder.TimeRunsOut -> {
|
|
||||||
SensorsBridge.trackDurationExhaustedDialogClick(BUTTON_NAME_BUY)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SensorsBridge.trackMyAssetsPageShow(
|
|
||||||
reminder.pkgName,
|
|
||||||
reminder.gameId,
|
|
||||||
reminder.gameName,
|
|
||||||
reminder.dialogName
|
|
||||||
)
|
|
||||||
dismissAllowingStateLoss()
|
|
||||||
|
|
||||||
DirectUtils.navigateToMyAssetsPage(requireContext(), reminder.sourceEntrance)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onStart() {
|
|
||||||
super.onStart()
|
|
||||||
val width = HaloApp.getInstance().resources.displayMetrics.widthPixels - 60F.dip2px()
|
|
||||||
val height = dialog?.window?.attributes?.height ?: ViewGroup.LayoutParams.WRAP_CONTENT
|
|
||||||
dialog?.window?.setLayout(width, height)
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
const val KEY_EXPIRATION_REMINDER = "key_expiration_reminder"
|
|
||||||
|
|
||||||
private const val BUTTON_NAME_KNOW = "知道了"
|
|
||||||
private const val BUTTON_NAME_BUY = "前往购买"
|
|
||||||
|
|
||||||
fun checkDialogShown(context: Context, reminder: ExpirationReminder, callback: ((Boolean) -> Unit)? = null) {
|
|
||||||
|
|
||||||
when (reminder) {
|
|
||||||
is ExpirationReminder.UserExpired -> {
|
|
||||||
val days = SPUtils.getLong(Constants.SP_ACCELERATOR_USER_REMAINING_REMIND)
|
|
||||||
if (reminder.days != days) {
|
|
||||||
SPUtils.setLong(Constants.SP_ACCELERATOR_USER_REMAINING_REMIND, reminder.days)
|
|
||||||
show(context, reminder)
|
|
||||||
callback?.invoke(true)
|
|
||||||
} else {
|
|
||||||
callback?.invoke(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
is ExpirationReminder.InsufficientDuration -> {
|
|
||||||
val hours = SPUtils.getLong(Constants.SP_ACCELERATOR_DURATION_REMAINING_HOURS)
|
|
||||||
if (reminder.hours != hours) {
|
|
||||||
SPUtils.setLong(Constants.SP_ACCELERATOR_DURATION_REMAINING_HOURS, reminder.hours)
|
|
||||||
show(context, reminder)
|
|
||||||
callback?.invoke(true)
|
|
||||||
} else {
|
|
||||||
callback?.invoke(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
is ExpirationReminder.DurationExpired -> {
|
|
||||||
val days = SPUtils.getLong(Constants.SP_ACCELERATOR_DURATION_REMAINING_DAYS)
|
|
||||||
if (reminder.days != days) {
|
|
||||||
SPUtils.setLong(Constants.SP_ACCELERATOR_DURATION_REMAINING_DAYS, reminder.days)
|
|
||||||
show(context, reminder)
|
|
||||||
callback?.invoke(true)
|
|
||||||
} else {
|
|
||||||
callback?.invoke(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
is ExpirationReminder.TimeRunsOut -> {
|
|
||||||
val hasShow = SPUtils.getBoolean(Constants.SP_ACCELERATOR_MEMBERSHIP_EXPIRED)
|
|
||||||
if (!hasShow) {
|
|
||||||
SPUtils.setBoolean(Constants.SP_ACCELERATOR_MEMBERSHIP_EXPIRED, true)
|
|
||||||
show(context, reminder)
|
|
||||||
callback?.invoke(true)
|
|
||||||
} else {
|
|
||||||
callback?.invoke(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun show(context: Context, reminder: ExpirationReminder) {
|
|
||||||
if (context is AppCompatActivity) {
|
|
||||||
context.supportFragmentManager
|
|
||||||
} else {
|
|
||||||
(CurrentActivityHolder.getCurrentActivity() as? AppCompatActivity)?.supportFragmentManager
|
|
||||||
}?.let {
|
|
||||||
val fragment = AccelerateExpirationDialogFragment().apply {
|
|
||||||
arguments = Bundle().apply {
|
|
||||||
putParcelable(KEY_EXPIRATION_REMINDER, reminder)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fragment.show(it, AcceleratorPermissionGuideDialogFragment::class.java.name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sealed class ExpirationReminder(
|
|
||||||
val gameId: String,
|
|
||||||
val gameName: String,
|
|
||||||
val pkgName: String,
|
|
||||||
val sourceEntrance: String
|
|
||||||
) :
|
|
||||||
Parcelable {
|
|
||||||
|
|
||||||
abstract val dialogName: String
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
data class InsufficientDuration(
|
|
||||||
val hours: Long,
|
|
||||||
private val _gameId: String,
|
|
||||||
private val _gameName: String,
|
|
||||||
private val _pkgName: String,
|
|
||||||
private val _sourceEntrance: String,
|
|
||||||
) :
|
|
||||||
ExpirationReminder(_gameId, _gameName, _pkgName, _sourceEntrance) {
|
|
||||||
|
|
||||||
override val dialogName: String
|
|
||||||
get() = "时长不足提示弹窗"
|
|
||||||
}
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
data class DurationExpired(
|
|
||||||
val days: Long,
|
|
||||||
private val _gameId: String,
|
|
||||||
private val _gameName: String,
|
|
||||||
private val _pkgName: String,
|
|
||||||
private val _sourceEntrance: String,
|
|
||||||
) :
|
|
||||||
ExpirationReminder(_gameId, _gameName, _pkgName, _sourceEntrance) {
|
|
||||||
|
|
||||||
override val dialogName: String
|
|
||||||
get() = "计时套餐临期提示弹窗"
|
|
||||||
}
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
data class UserExpired(
|
|
||||||
val days: Long,
|
|
||||||
private val _gameId: String,
|
|
||||||
private val _gameName: String,
|
|
||||||
private val _pkgName: String,
|
|
||||||
private val _sourceEntrance: String,
|
|
||||||
) :
|
|
||||||
ExpirationReminder(_gameId, _gameName, _pkgName, _sourceEntrance) {
|
|
||||||
|
|
||||||
override val dialogName: String
|
|
||||||
get() = "包月套餐临期提示弹窗"
|
|
||||||
}
|
|
||||||
|
|
||||||
@Parcelize
|
|
||||||
data class TimeRunsOut(
|
|
||||||
private val _sourceEntrance: String,
|
|
||||||
) : ExpirationReminder("", "", "", _sourceEntrance) {
|
|
||||||
|
|
||||||
override val dialogName: String
|
|
||||||
get() = "时长耗尽提示弹窗"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,68 +0,0 @@
|
|||||||
package com.gh.common.dialog
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import com.gh.gamecenter.common.HaloApp
|
|
||||||
import com.gh.gamecenter.common.base.fragment.BaseDialogFragment
|
|
||||||
import com.gh.gamecenter.common.constant.Constants
|
|
||||||
import com.gh.gamecenter.common.utils.dip2px
|
|
||||||
import com.gh.gamecenter.core.utils.CurrentActivityHolder
|
|
||||||
import com.gh.gamecenter.core.utils.SPUtils
|
|
||||||
import com.gh.gamecenter.databinding.DialogFragmentAcceleratorPermissionGuideBinding
|
|
||||||
|
|
||||||
class AcceleratorPermissionGuideDialogFragment : BaseDialogFragment() {
|
|
||||||
|
|
||||||
private lateinit var binding: DialogFragmentAcceleratorPermissionGuideBinding
|
|
||||||
|
|
||||||
private var callback: (() -> Unit)? = null
|
|
||||||
|
|
||||||
override fun onBack(): Boolean {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
|
||||||
return DialogFragmentAcceleratorPermissionGuideBinding.inflate(inflater, container, false)
|
|
||||||
.also {
|
|
||||||
binding = it
|
|
||||||
}.root
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
||||||
super.onViewCreated(view, savedInstanceState)
|
|
||||||
SPUtils.setBoolean(Constants.SP_ACCELERATOR_PERMISSION_GUIDE_SHOW, true)
|
|
||||||
binding.tvSubmit.setOnClickListener {
|
|
||||||
dismiss()
|
|
||||||
callback?.invoke()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setOnCallback(block: () -> Unit) {
|
|
||||||
this.callback = block
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onStart() {
|
|
||||||
super.onStart()
|
|
||||||
val width = HaloApp.getInstance().resources.displayMetrics.widthPixels - 60F.dip2px()
|
|
||||||
val height = dialog?.window?.attributes?.height ?: ViewGroup.LayoutParams.WRAP_CONTENT
|
|
||||||
dialog?.window?.setLayout(width, height)
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
|
|
||||||
fun show(context: Context, callback: () -> Unit) {
|
|
||||||
if (context is AppCompatActivity) {
|
|
||||||
context.supportFragmentManager
|
|
||||||
} else {
|
|
||||||
(CurrentActivityHolder.getCurrentActivity() as? AppCompatActivity)?.supportFragmentManager
|
|
||||||
}?.let {
|
|
||||||
val fragment = AcceleratorPermissionGuideDialogFragment()
|
|
||||||
fragment.setOnCallback(callback)
|
|
||||||
fragment.show(it, AcceleratorPermissionGuideDialogFragment::class.java.name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -7,6 +7,7 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import com.gh.common.util.DirectUtils
|
import com.gh.common.util.DirectUtils
|
||||||
|
import com.gh.gamecenter.R
|
||||||
import com.gh.gamecenter.common.base.fragment.BaseDialogFragment
|
import com.gh.gamecenter.common.base.fragment.BaseDialogFragment
|
||||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||||
import com.gh.gamecenter.common.utils.dip2px
|
import com.gh.gamecenter.common.utils.dip2px
|
||||||
@ -48,7 +49,7 @@ class ApplyModeratorDialogFragment : BaseDialogFragment() {
|
|||||||
requireContext(),
|
requireContext(),
|
||||||
startText.length,
|
startText.length,
|
||||||
startText.length + mGroupNumber.length,
|
startText.length + mGroupNumber.length,
|
||||||
com.gh.gamecenter.common.R.color.text_theme,
|
R.color.text_theme,
|
||||||
true
|
true
|
||||||
) {
|
) {
|
||||||
DirectUtils.directToQqGroup(
|
DirectUtils.directToQqGroup(
|
||||||
|
|||||||
@ -40,7 +40,7 @@ import java.lang.ref.WeakReference
|
|||||||
* 设备提醒弹窗
|
* 设备提醒弹窗
|
||||||
*/
|
*/
|
||||||
class DeviceRemindDialog(context: Context, val entity: DeviceDialogEntity, val gameEntity: GameEntity) :
|
class DeviceRemindDialog(context: Context, val entity: DeviceDialogEntity, val gameEntity: GameEntity) :
|
||||||
Dialog(context, com.gh.gamecenter.common.R.style.GhAlertDialog) {
|
Dialog(context, R.style.GhAlertDialog) {
|
||||||
private val mBinding: DialogDeviceRemindBinding by lazy { DialogDeviceRemindBinding.inflate(layoutInflater) }
|
private val mBinding: DialogDeviceRemindBinding by lazy { DialogDeviceRemindBinding.inflate(layoutInflater) }
|
||||||
private var currentPage = 0
|
private var currentPage = 0
|
||||||
private var mSlideLooperInterval = 3000L
|
private var mSlideLooperInterval = 3000L
|
||||||
@ -136,13 +136,13 @@ class DeviceRemindDialog(context: Context, val entity: DeviceDialogEntity, val g
|
|||||||
val isFirst = SPUtils.getBoolean(Constants.SP_FIRST_DEVICE_REMIND, false)
|
val isFirst = SPUtils.getBoolean(Constants.SP_FIRST_DEVICE_REMIND, false)
|
||||||
if (!isFirst) {
|
if (!isFirst) {
|
||||||
mBinding.cancelTv.isEnabled = false
|
mBinding.cancelTv.isEnabled = false
|
||||||
mBinding.cancelTv.background = ContextCompat.getDrawable(context, com.gh.gamecenter.common.R.drawable.button_round_f5f5f5)
|
mBinding.cancelTv.background = ContextCompat.getDrawable(context, R.drawable.button_round_f5f5f5)
|
||||||
disposable = countDownTimer(3) { finish, time ->
|
disposable = countDownTimer(3) { finish, time ->
|
||||||
if (finish) {
|
if (finish) {
|
||||||
mBinding.cancelTv.isEnabled = true
|
mBinding.cancelTv.isEnabled = true
|
||||||
mBinding.cancelTv.background = ContextCompat.getDrawable(context, com.gh.gamecenter.common.R.drawable.button_blue_oval)
|
mBinding.cancelTv.background = ContextCompat.getDrawable(context, R.drawable.button_blue_oval)
|
||||||
mBinding.cancelTv.text = "我知道了"
|
mBinding.cancelTv.text = "我知道了"
|
||||||
mBinding.cancelTv.setTextColor(ContextCompat.getColor(context, com.gh.gamecenter.common.R.color.white))
|
mBinding.cancelTv.setTextColor(ContextCompat.getColor(context, R.color.white))
|
||||||
} else {
|
} else {
|
||||||
mBinding.cancelTv.text = "我知道了(${time}S)"
|
mBinding.cancelTv.text = "我知道了(${time}S)"
|
||||||
}
|
}
|
||||||
@ -153,8 +153,8 @@ class DeviceRemindDialog(context: Context, val entity: DeviceDialogEntity, val g
|
|||||||
mBinding.noRemindAgainCb.visibility = View.VISIBLE
|
mBinding.noRemindAgainCb.visibility = View.VISIBLE
|
||||||
mBinding.cancelTv.text = "我知道了"
|
mBinding.cancelTv.text = "我知道了"
|
||||||
mBinding.cancelTv.isEnabled = true
|
mBinding.cancelTv.isEnabled = true
|
||||||
mBinding.cancelTv.setTextColor(ContextCompat.getColor(context, com.gh.gamecenter.common.R.color.white))
|
mBinding.cancelTv.setTextColor(ContextCompat.getColor(context, R.color.white))
|
||||||
mBinding.cancelTv.background = ContextCompat.getDrawable(context, com.gh.gamecenter.common.R.drawable.button_blue_oval)
|
mBinding.cancelTv.background = ContextCompat.getDrawable(context, R.drawable.button_blue_oval)
|
||||||
}
|
}
|
||||||
mBinding.cancelTv.setOnClickListener {
|
mBinding.cancelTv.setOnClickListener {
|
||||||
SPUtils.setBoolean(Constants.SP_NO_REMIND_AGAIN, mBinding.noRemindAgainCb.isChecked)
|
SPUtils.setBoolean(Constants.SP_NO_REMIND_AGAIN, mBinding.noRemindAgainCb.isChecked)
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import com.gh.gamecenter.common.base.fragment.BaseDialogFragment
|
|||||||
import com.gh.common.util.DirectUtils
|
import com.gh.common.util.DirectUtils
|
||||||
import com.gh.gamecenter.common.utils.dip2px
|
import com.gh.gamecenter.common.utils.dip2px
|
||||||
import com.gh.gamecenter.common.utils.toColor
|
import com.gh.gamecenter.common.utils.toColor
|
||||||
|
import com.gh.gamecenter.R
|
||||||
import com.gh.gamecenter.databinding.DialogGameOffServiceBinding
|
import com.gh.gamecenter.databinding.DialogGameOffServiceBinding
|
||||||
import com.gh.gamecenter.feature.entity.GameEntity
|
import com.gh.gamecenter.feature.entity.GameEntity
|
||||||
|
|
||||||
@ -61,7 +62,7 @@ class GameOffServiceDialogFragment : BaseDialogFragment() {
|
|||||||
if (index == notEmptySite.size - 1) bottomMargin = 8F.dip2px()
|
if (index == notEmptySite.size - 1) bottomMargin = 8F.dip2px()
|
||||||
}
|
}
|
||||||
siteTv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14F)
|
siteTv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14F)
|
||||||
siteTv.setTextColor(com.gh.gamecenter.common.R.color.text_theme.toColor(requireContext()))
|
siteTv.setTextColor(R.color.text_theme.toColor(requireContext()))
|
||||||
siteTv.text = site.text
|
siteTv.text = site.text
|
||||||
siteTv.paintFlags = siteTv.paintFlags or Paint.UNDERLINE_TEXT_FLAG
|
siteTv.paintFlags = siteTv.paintFlags or Paint.UNDERLINE_TEXT_FLAG
|
||||||
siteTv.setOnClickListener {
|
siteTv.setOnClickListener {
|
||||||
|
|||||||
@ -158,7 +158,7 @@ class InstallPermissionDialogFragment : BaseDialogFragment() {
|
|||||||
}
|
}
|
||||||
if (isXapk) {
|
if (isXapk) {
|
||||||
val xapkUnzipVersions = Config.getSettings()?.permissionPopupAppliedVersions?.xapkUnzip
|
val xapkUnzipVersions = Config.getSettings()?.permissionPopupAppliedVersions?.xapkUnzip
|
||||||
if (xapkUnzipVersions?.contains(Build.VERSION.SDK_INT.toString()) == false || XapkInstaller.systemHasFlaw) {
|
if (xapkUnzipVersions?.contains(Build.VERSION.SDK_INT.toString()) == false) {
|
||||||
callBack?.invoke(false)
|
callBack?.invoke(false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
package com.gh.gamecenter.common.dialog
|
package com.gh.common.dialog
|
||||||
|
|
||||||
import android.content.DialogInterface
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
@ -12,18 +11,14 @@ import android.view.LayoutInflater
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.fragment.app.FragmentActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import com.therouter.TheRouter
|
|
||||||
import com.gh.gamecenter.common.base.fragment.BaseDialogFragment
|
|
||||||
import com.gh.gamecenter.common.constant.RouteConsts
|
|
||||||
import com.gh.gamecenter.common.databinding.DialogAlertDefaultBinding
|
import com.gh.gamecenter.common.databinding.DialogAlertDefaultBinding
|
||||||
import com.gh.gamecenter.core.AppExecutor
|
import com.lightgame.dialog.BaseDialogFragment
|
||||||
import com.gh.gamecenter.core.provider.IAppProvider
|
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.R)
|
@RequiresApi(Build.VERSION_CODES.R)
|
||||||
class ManageExternalStoragePermissionDialogFragment : BaseDialogFragment() {
|
class ManagerAllFilesPermissionDialogFragment : BaseDialogFragment() {
|
||||||
private val mBinding by lazy { DialogAlertDefaultBinding.inflate(layoutInflater) }
|
private val mBinding by lazy { DialogAlertDefaultBinding.inflate(layoutInflater) }
|
||||||
private var mCallBack: ((Boolean) -> Unit)? = null
|
private var mCallBack: (() -> Unit)? = null
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||||
return mBinding.root
|
return mBinding.root
|
||||||
@ -37,8 +32,6 @@ class ManageExternalStoragePermissionDialogFragment : BaseDialogFragment() {
|
|||||||
contentTv.text = "需要所有文件访问权限,请打开权限设置页面"
|
contentTv.text = "需要所有文件访问权限,请打开权限设置页面"
|
||||||
|
|
||||||
confirmTv.setOnClickListener {
|
confirmTv.setOnClickListener {
|
||||||
val appProvider = TheRouter.get(IAppProvider::class.java)
|
|
||||||
appProvider?.setDisableSplashAdTemporarily(true)
|
|
||||||
val intent = Intent().apply {
|
val intent = Intent().apply {
|
||||||
action = Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION
|
action = Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION
|
||||||
data = Uri.fromParts("package", requireContext().packageName, null)
|
data = Uri.fromParts("package", requireContext().packageName, null)
|
||||||
@ -46,24 +39,15 @@ class ManageExternalStoragePermissionDialogFragment : BaseDialogFragment() {
|
|||||||
requireActivity().startActivityForResult(intent, REQUEST_CODE)
|
requireActivity().startActivityForResult(intent, REQUEST_CODE)
|
||||||
}
|
}
|
||||||
cancelTv.setOnClickListener {
|
cancelTv.setOnClickListener {
|
||||||
mCallBack?.invoke(false)
|
|
||||||
dismissAllowingStateLoss()
|
dismissAllowingStateLoss()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDismiss(dialog: DialogInterface) {
|
|
||||||
super.onDismiss(dialog)
|
|
||||||
AppExecutor.uiExecutor.executeWithDelay({
|
|
||||||
val appProvider = TheRouter.get(IAppProvider::class.java)
|
|
||||||
appProvider?.setDisableSplashAdTemporarily(false)
|
|
||||||
}, 100)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
super.onActivityResult(requestCode, resultCode, data)
|
super.onActivityResult(requestCode, resultCode, data)
|
||||||
if (requestCode == REQUEST_CODE && Environment.isExternalStorageManager()) {
|
if (requestCode == REQUEST_CODE && Environment.isExternalStorageManager()) {
|
||||||
mCallBack?.invoke(true)
|
mCallBack?.invoke()
|
||||||
dismissAllowingStateLoss()
|
dismissAllowingStateLoss()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -72,12 +56,12 @@ class ManageExternalStoragePermissionDialogFragment : BaseDialogFragment() {
|
|||||||
const val REQUEST_CODE = 1000
|
const val REQUEST_CODE = 1000
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun show(activity: FragmentActivity, callback: (Boolean) -> Unit) {
|
fun show(activity: AppCompatActivity, callback: () -> Unit) {
|
||||||
ManageExternalStoragePermissionDialogFragment().apply {
|
ManagerAllFilesPermissionDialogFragment().apply {
|
||||||
mCallBack = callback
|
mCallBack = callback
|
||||||
}.show(
|
}.show(
|
||||||
activity.supportFragmentManager,
|
activity.supportFragmentManager,
|
||||||
ManageExternalStoragePermissionDialogFragment::class.java.name
|
ManagerAllFilesPermissionDialogFragment::class.java.name
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -76,12 +76,12 @@ class NewPrivacyPolicyDialogFragment : BaseDialogFragment() {
|
|||||||
contentText.setSpan(object : ClickableSpan() {
|
contentText.setSpan(object : ClickableSpan() {
|
||||||
override fun updateDrawState(ds: TextPaint) {
|
override fun updateDrawState(ds: TextPaint) {
|
||||||
super.updateDrawState(ds)
|
super.updateDrawState(ds)
|
||||||
ds.color = ContextCompat.getColor(requireContext(), com.gh.gamecenter.common.R.color.text_theme)
|
ds.color = ContextCompat.getColor(requireContext(), R.color.text_theme)
|
||||||
ds.isUnderlineText = false
|
ds.isUnderlineText = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onClick(widget: View) {
|
override fun onClick(widget: View) {
|
||||||
val privacyPolicyUrl = requireContext().getString(com.gh.gamecenter.common.R.string.privacy_policy_url)
|
val privacyPolicyUrl = requireContext().getString(R.string.privacy_policy_url)
|
||||||
val childrenPrivacyPolicyUrl = requireContext().getString(R.string.children_policy_url)
|
val childrenPrivacyPolicyUrl = requireContext().getString(R.string.children_policy_url)
|
||||||
val thirdPartySdkUrl = requireContext().getString(R.string.sdk_list_url)
|
val thirdPartySdkUrl = requireContext().getString(R.string.sdk_list_url)
|
||||||
val permissionListUrl = requireContext().getString(R.string.permission_and_usage_url)
|
val permissionListUrl = requireContext().getString(R.string.permission_and_usage_url)
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package com.gh.common.dialog
|
|||||||
import android.animation.ValueAnimator
|
import android.animation.ValueAnimator
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.DialogInterface
|
import android.content.DialogInterface
|
||||||
|
import android.content.pm.PackageInfo
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@ -18,8 +19,10 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
|||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.gh.common.util.DirectUtils
|
import com.gh.common.util.DirectUtils
|
||||||
import com.gh.common.util.LogUtils
|
import com.gh.common.util.LogUtils
|
||||||
|
import com.gh.common.util.PackageHelper
|
||||||
import com.gh.common.util.PackageUtils
|
import com.gh.common.util.PackageUtils
|
||||||
import com.gh.download.DownloadManager
|
import com.gh.download.DownloadManager
|
||||||
|
import com.gh.gamecenter.R
|
||||||
import com.gh.gamecenter.common.base.BaseRecyclerViewHolder
|
import com.gh.gamecenter.common.base.BaseRecyclerViewHolder
|
||||||
import com.gh.gamecenter.common.callback.ConfirmListener
|
import com.gh.gamecenter.common.callback.ConfirmListener
|
||||||
import com.gh.gamecenter.common.constant.Constants
|
import com.gh.gamecenter.common.constant.Constants
|
||||||
@ -57,6 +60,7 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
|||||||
private val mDuration = 3000
|
private val mDuration = 3000
|
||||||
private var mDisposable: Disposable? = null
|
private var mDisposable: Disposable? = null
|
||||||
private var mAdapter: PackageCheckAdapter? = null
|
private var mAdapter: PackageCheckAdapter? = null
|
||||||
|
private var mAllInstalledPackages = PackageHelper.getInstalledPackages(HaloApp.getInstance().application, 0)
|
||||||
var gameEntity: GameEntity? = null
|
var gameEntity: GameEntity? = null
|
||||||
var callBack: ConfirmListener? = null
|
var callBack: ConfirmListener? = null
|
||||||
|
|
||||||
@ -122,7 +126,7 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
|||||||
requireContext(),
|
requireContext(),
|
||||||
0,
|
0,
|
||||||
(link.title ?: "").length,
|
(link.title ?: "").length,
|
||||||
com.gh.gamecenter.common.R.color.text_theme,
|
R.color.text_theme,
|
||||||
true
|
true
|
||||||
) {
|
) {
|
||||||
LogUtils.uploadPackageCheck(
|
LogUtils.uploadPackageCheck(
|
||||||
@ -192,7 +196,7 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
|||||||
if (binding.noRemindAgainCb.isChecked) {
|
if (binding.noRemindAgainCb.isChecked) {
|
||||||
saveRecord(entity)
|
saveRecord(entity)
|
||||||
}
|
}
|
||||||
val isAllPackageInstalled = isAllPackageInstalled(entity)
|
val isAllPackageInstalled = isAllPackageInstalled(mAllInstalledPackages, entity)
|
||||||
if (isAllPackageInstalled) {
|
if (isAllPackageInstalled) {
|
||||||
mDismissByTouchInside = true
|
mDismissByTouchInside = true
|
||||||
callBack?.onConfirm()
|
callBack?.onConfirm()
|
||||||
@ -281,7 +285,7 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
|||||||
if (it >= mDuration) {
|
if (it >= mDuration) {
|
||||||
mDisposable?.dispose()
|
mDisposable?.dispose()
|
||||||
binding.downloadBtn.isEnabled = true
|
binding.downloadBtn.isEnabled = true
|
||||||
binding.downloadBtn.background = com.gh.gamecenter.common.R.drawable.bg_notification_open_btn_style_2.toDrawable()
|
binding.downloadBtn.background = R.drawable.bg_notification_open_btn_style_2.toDrawable()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val animator = ValueAnimator.ofInt(0, 100)
|
val animator = ValueAnimator.ofInt(0, 100)
|
||||||
@ -296,7 +300,7 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
|||||||
private fun getNotInstalledLink(packageDialogEntity: PackageDialogEntity): LinkEntity? {
|
private fun getNotInstalledLink(packageDialogEntity: PackageDialogEntity): LinkEntity? {
|
||||||
val links = LinkedHashSet<LinkEntity>()
|
val links = LinkedHashSet<LinkEntity>()
|
||||||
packageDialogEntity.detectionObjects.forEach { obj ->
|
packageDialogEntity.detectionObjects.forEach { obj ->
|
||||||
if (!checkDetectionsInstalled(obj.packages)) {
|
if (!checkDetectionsInstalled(mAllInstalledPackages, obj.packages)) {
|
||||||
obj.assignDownload.forEach {
|
obj.assignDownload.forEach {
|
||||||
links.add(packageDialogEntity.links[it])
|
links.add(packageDialogEntity.links[it])
|
||||||
}
|
}
|
||||||
@ -322,8 +326,9 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
|||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
|
mAllInstalledPackages = PackageHelper.getInstalledPackages(HaloApp.getInstance().application, 0)
|
||||||
gameEntity?.packageDialog?.let {
|
gameEntity?.packageDialog?.let {
|
||||||
if (isAllPackageInstalled(it)) {
|
if (isAllPackageInstalled(mAllInstalledPackages, it)) {
|
||||||
callBack?.onConfirm()
|
callBack?.onConfirm()
|
||||||
dismissAllowingStateLoss()
|
dismissAllowingStateLoss()
|
||||||
}
|
}
|
||||||
@ -359,6 +364,7 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
|||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
fun onEventMainThread(busFour: EBPackage) {
|
fun onEventMainThread(busFour: EBPackage) {
|
||||||
if (busFour.isInstalledOrUninstalled()) {
|
if (busFour.isInstalledOrUninstalled()) {
|
||||||
|
mAllInstalledPackages = PackageHelper.getInstalledPackages(HaloApp.getInstance().application, 0)
|
||||||
mAdapter?.notifyDataSetChanged()
|
mAdapter?.notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -383,13 +389,13 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
|||||||
val entity = entities[position]
|
val entity = entities[position]
|
||||||
holder.binding.gameNameTv.text = entity.text
|
holder.binding.gameNameTv.text = entity.text
|
||||||
if (position <= index) {
|
if (position <= index) {
|
||||||
val isAllInstalled = checkDetectionsInstalled(entity.packages)
|
val isAllInstalled = checkDetectionsInstalled(mAllInstalledPackages, entity.packages)
|
||||||
if (isAllInstalled) {
|
if (isAllInstalled) {
|
||||||
holder.binding.statusTv.text = "已安装"
|
holder.binding.statusTv.text = "已安装"
|
||||||
holder.binding.statusTv.setTextColor(ContextCompat.getColor(context, com.gh.gamecenter.common.R.color.text_theme))
|
holder.binding.statusTv.setTextColor(ContextCompat.getColor(context, R.color.text_theme))
|
||||||
} else {
|
} else {
|
||||||
holder.binding.statusTv.text = "未安装"
|
holder.binding.statusTv.text = "未安装"
|
||||||
holder.binding.statusTv.setTextColor(ContextCompat.getColor(context, com.gh.gamecenter.common.R.color.secondary_red))
|
holder.binding.statusTv.setTextColor(ContextCompat.getColor(context, R.color.secondary_red))
|
||||||
}
|
}
|
||||||
holder.binding.statusTv.visibility = View.VISIBLE
|
holder.binding.statusTv.visibility = View.VISIBLE
|
||||||
} else {
|
} else {
|
||||||
@ -411,7 +417,8 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAllPackageInstalled(packageDialogEntity)) {
|
val allInstalledPackages = PackageHelper.getInstalledPackages(HaloApp.getInstance().application, 0)
|
||||||
|
if (isAllPackageInstalled(allInstalledPackages, packageDialogEntity)) {
|
||||||
callBack.onConfirm()
|
callBack.onConfirm()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -447,11 +454,13 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun checkDetectionsInstalled(
|
private fun checkDetectionsInstalled(
|
||||||
|
allInstalledPackages: List<PackageInfo>,
|
||||||
packages: ArrayList<String>
|
packages: ArrayList<String>
|
||||||
): Boolean {
|
): Boolean {
|
||||||
var isPackagesInstalled = false
|
var isPackagesInstalled = false
|
||||||
packages.forEach { packageName ->
|
packages.forEach { packageName ->
|
||||||
if (PackageUtils.isInstalledFromAllPackage(HaloApp.getInstance(), packageName)) {
|
val isInstalled = allInstalledPackages.find { it.packageName == packageName } != null
|
||||||
|
if (isInstalled) {
|
||||||
isPackagesInstalled = true
|
isPackagesInstalled = true
|
||||||
return@forEach
|
return@forEach
|
||||||
}
|
}
|
||||||
@ -461,14 +470,17 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
|||||||
|
|
||||||
|
|
||||||
fun isAllPackageInstalled(
|
fun isAllPackageInstalled(
|
||||||
|
allInstalledPackages: List<PackageInfo>,
|
||||||
packageDialogEntity: PackageDialogEntity
|
packageDialogEntity: PackageDialogEntity
|
||||||
): Boolean {
|
): Boolean {
|
||||||
|
var isAllInstalled = true
|
||||||
packageDialogEntity.detectionObjects.forEach loop@{ obj ->
|
packageDialogEntity.detectionObjects.forEach loop@{ obj ->
|
||||||
if (!checkDetectionsInstalled(obj.packages)) {
|
if (!checkDetectionsInstalled(allInstalledPackages, obj.packages)) {
|
||||||
return false
|
isAllInstalled = false
|
||||||
|
return isAllInstalled
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true
|
return isAllInstalled
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -12,6 +12,7 @@ import android.view.*
|
|||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.fragment.app.FragmentActivity
|
import androidx.fragment.app.FragmentActivity
|
||||||
import androidx.fragment.app.FragmentTransaction
|
import androidx.fragment.app.FragmentTransaction
|
||||||
|
import com.gh.gamecenter.R
|
||||||
import com.gh.gamecenter.WebActivity
|
import com.gh.gamecenter.WebActivity
|
||||||
import com.gh.gamecenter.common.base.fragment.BaseDialogFragment
|
import com.gh.gamecenter.common.base.fragment.BaseDialogFragment
|
||||||
import com.gh.gamecenter.common.constant.Constants
|
import com.gh.gamecenter.common.constant.Constants
|
||||||
@ -67,13 +68,13 @@ class PrivacyPolicyDialogFragment : BaseDialogFragment() {
|
|||||||
skipText.setSpan(object : ClickableSpan() {
|
skipText.setSpan(object : ClickableSpan() {
|
||||||
override fun updateDrawState(ds: TextPaint) {
|
override fun updateDrawState(ds: TextPaint) {
|
||||||
super.updateDrawState(ds)
|
super.updateDrawState(ds)
|
||||||
ds.color = ContextCompat.getColor(requireContext(), com.gh.gamecenter.common.R.color.text_theme)
|
ds.color = ContextCompat.getColor(requireContext(), R.color.text_theme)
|
||||||
ds.isUnderlineText = false
|
ds.isUnderlineText = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onClick(widget: View) {
|
override fun onClick(widget: View) {
|
||||||
val intent =
|
val intent =
|
||||||
WebActivity.getIntent(requireContext(), context!!.getString(com.gh.gamecenter.common.R.string.privacy_policy_url), true)
|
WebActivity.getIntent(requireContext(), context!!.getString(R.string.privacy_policy_url), true)
|
||||||
context?.startActivity(intent)
|
context?.startActivity(intent)
|
||||||
}
|
}
|
||||||
}, skipText.length - 6, skipText.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
}, skipText.length - 6, skipText.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||||
@ -109,13 +110,13 @@ class PrivacyPolicyDialogFragment : BaseDialogFragment() {
|
|||||||
skipText.setSpan(object : ClickableSpan() {
|
skipText.setSpan(object : ClickableSpan() {
|
||||||
override fun updateDrawState(ds: TextPaint) {
|
override fun updateDrawState(ds: TextPaint) {
|
||||||
super.updateDrawState(ds)
|
super.updateDrawState(ds)
|
||||||
ds.color = ContextCompat.getColor(requireContext(), com.gh.gamecenter.common.R.color.text_theme)
|
ds.color = ContextCompat.getColor(requireContext(), R.color.text_theme)
|
||||||
ds.isUnderlineText = false
|
ds.isUnderlineText = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onClick(widget: View) {
|
override fun onClick(widget: View) {
|
||||||
val intent =
|
val intent =
|
||||||
WebActivity.getIntent(requireContext(), context!!.getString(com.gh.gamecenter.common.R.string.privacy_policy_url), true)
|
WebActivity.getIntent(requireContext(), context!!.getString(R.string.privacy_policy_url), true)
|
||||||
context?.startActivity(intent)
|
context?.startActivity(intent)
|
||||||
}
|
}
|
||||||
}, skipText.length - 9, skipText.length - 5, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
}, skipText.length - 9, skipText.length - 5, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||||
@ -123,12 +124,12 @@ class PrivacyPolicyDialogFragment : BaseDialogFragment() {
|
|||||||
skipText.setSpan(object : ClickableSpan() {
|
skipText.setSpan(object : ClickableSpan() {
|
||||||
override fun updateDrawState(ds: TextPaint) {
|
override fun updateDrawState(ds: TextPaint) {
|
||||||
super.updateDrawState(ds)
|
super.updateDrawState(ds)
|
||||||
ds.color = ContextCompat.getColor(requireContext(), com.gh.gamecenter.common.R.color.text_theme)
|
ds.color = ContextCompat.getColor(requireContext(), R.color.text_theme)
|
||||||
ds.isUnderlineText = false
|
ds.isUnderlineText = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onClick(widget: View) {
|
override fun onClick(widget: View) {
|
||||||
val intent = WebActivity.getIntent(requireContext(), context!!.getString(com.gh.gamecenter.common.R.string.disclaimer_url), true)
|
val intent = WebActivity.getIntent(requireContext(), context!!.getString(R.string.disclaimer_url), true)
|
||||||
context?.startActivity(intent)
|
context?.startActivity(intent)
|
||||||
}
|
}
|
||||||
}, skipText.length - 4, skipText.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
}, skipText.length - 4, skipText.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||||
|
|||||||
@ -1,40 +1,27 @@
|
|||||||
package com.gh.common.dialog
|
package com.gh.common.dialog
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.DialogInterface
|
|
||||||
import android.graphics.Color
|
|
||||||
import android.graphics.drawable.ColorDrawable
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.gh.common.exposure.ExposureListener
|
|
||||||
import com.gh.common.exposure.IExposable
|
|
||||||
import com.gh.gamecenter.DownloadManagerActivity
|
|
||||||
import com.gh.gamecenter.GameDetailActivity
|
|
||||||
import com.gh.gamecenter.R
|
|
||||||
import com.gh.gamecenter.common.base.BaseRecyclerViewHolder
|
import com.gh.gamecenter.common.base.BaseRecyclerViewHolder
|
||||||
import com.gh.gamecenter.common.base.fragment.BaseDialogFragment
|
import com.gh.gamecenter.common.base.fragment.BaseDialogFragment
|
||||||
import com.gh.gamecenter.common.exposure.ExposureSource
|
import com.gh.gamecenter.common.utils.ImageUtils
|
||||||
import com.gh.gamecenter.common.utils.*
|
import com.gh.gamecenter.common.utils.fromHtml
|
||||||
|
import com.gh.gamecenter.GameDetailActivity
|
||||||
|
import com.gh.gamecenter.R
|
||||||
import com.gh.gamecenter.common.view.FixLinearLayoutManager
|
import com.gh.gamecenter.common.view.FixLinearLayoutManager
|
||||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
|
||||||
import com.gh.gamecenter.databinding.DialogReserveBinding
|
import com.gh.gamecenter.databinding.DialogReserveBinding
|
||||||
import com.gh.gamecenter.databinding.DialogReserveItemBinding
|
import com.gh.gamecenter.databinding.DialogReserveItemBinding
|
||||||
import com.gh.gamecenter.feature.entity.GameEntity
|
import com.gh.gamecenter.common.entity.SimpleGameEntity
|
||||||
import com.gh.gamecenter.feature.entity.ReserveOnlineEntity
|
|
||||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
|
||||||
import com.gh.gamecenter.mygame.MyGameActivity
|
import com.gh.gamecenter.mygame.MyGameActivity
|
||||||
import com.halo.assistant.HaloApp
|
|
||||||
import com.lightgame.adapter.BaseRecyclerAdapter
|
import com.lightgame.adapter.BaseRecyclerAdapter
|
||||||
|
|
||||||
class ReserveDialog : BaseDialogFragment() {
|
class ReserveDialog : BaseDialogFragment() {
|
||||||
|
|
||||||
private lateinit var reserveOnlineEntity: ReserveOnlineEntity
|
private lateinit var mReserveList: List<SimpleGameEntity>
|
||||||
val games: List<GameEntity>
|
|
||||||
get() = reserveOnlineEntity.games
|
|
||||||
|
|
||||||
private var mDismissListener: (() -> Unit)? = null
|
private var mDismissListener: (() -> Unit)? = null
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
@ -49,162 +36,66 @@ class ReserveDialog : BaseDialogFragment() {
|
|||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||||
val binding: DialogReserveBinding = DialogReserveBinding.inflate(layoutInflater, null, false)
|
val binding: DialogReserveBinding = DialogReserveBinding.inflate(layoutInflater, null, false)
|
||||||
|
|
||||||
reserveOnlineEntity = arguments?.getParcelable(RESERVE_ONLINE) ?: ReserveOnlineEntity()
|
mReserveList = arguments?.getParcelableArrayList(RESERVE_LIST) ?: arrayListOf()
|
||||||
|
|
||||||
binding.tvTitle.text =
|
binding.title.text = resources.getString(R.string.dialog_reserve_title, mReserveList.size).fromHtml()
|
||||||
resources.getString(R.string.dialog_reserve_title, reserveOnlineEntity.gamesTotal).fromHtml()
|
binding.more.visibility = if (mReserveList.size > 4) {
|
||||||
binding.tvViewAllAppointment.setOnClickListener {
|
View.VISIBLE
|
||||||
SensorsBridge.trackAppointmentGameOnlineDialogClick(buttonName = "查看全部预约")
|
} else View.GONE
|
||||||
val intent = MyGameActivity.getIntentWithConfig(requireContext(), MyGameActivity.RESERVATION_INDEX)
|
binding.more.setOnClickListener {
|
||||||
|
val intent = MyGameActivity.getIntentWithConfig(requireContext(), 2)
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
}
|
|
||||||
|
|
||||||
val adapter = ReserveDialogAdapter(requireContext(), games)
|
|
||||||
binding.rvGames.layoutManager = FixLinearLayoutManager(context, RecyclerView.HORIZONTAL, false)
|
|
||||||
binding.rvGames.adapter = adapter
|
|
||||||
|
|
||||||
val exposureListener = ExposureListener(this, adapter)
|
|
||||||
binding.rvGames.addOnScrollListener(exposureListener)
|
|
||||||
|
|
||||||
binding.ivClose.setOnClickListener {
|
|
||||||
dismissAllowingStateLoss()
|
dismissAllowingStateLoss()
|
||||||
}
|
}
|
||||||
|
binding.recyclerView.layoutManager = if (mReserveList.size > 4) {
|
||||||
|
GridLayoutManager(context, 4)
|
||||||
|
} else {
|
||||||
|
FixLinearLayoutManager(context, RecyclerView.HORIZONTAL, false)
|
||||||
|
}
|
||||||
|
binding.recyclerView.adapter = object : BaseRecyclerAdapter<ReserveDialogItemViewHolder>(context) {
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ReserveDialogItemViewHolder {
|
||||||
|
val inflate = mLayoutInflater.inflate(R.layout.dialog_reserve_item, parent, false)
|
||||||
|
return ReserveDialogItemViewHolder(DialogReserveItemBinding.bind(inflate))
|
||||||
|
}
|
||||||
|
|
||||||
checkHasAutoDownload(binding)
|
override fun getItemCount(): Int {
|
||||||
|
return if (mReserveList.size > 4) 4 else mReserveList.size
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: ReserveDialogItemViewHolder, position: Int) {
|
||||||
|
val entity = mReserveList[position]
|
||||||
|
ImageUtils.display(holder.binding.icon, entity.icon)
|
||||||
|
holder.binding.gameNameTv.text = entity.name
|
||||||
|
holder.itemView.setOnClickListener {
|
||||||
|
GameDetailActivity.startGameDetailActivity(mContext, entity.id, "(预约弹窗)")
|
||||||
|
dismissAllowingStateLoss()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dialog?.setCanceledOnTouchOutside(true)
|
dialog?.setCanceledOnTouchOutside(true)
|
||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkHasAutoDownload(binding: DialogReserveBinding) {
|
|
||||||
if (reserveOnlineEntity.wifiAutoDownloadTotal > 0) {
|
|
||||||
// 开启自动下载
|
|
||||||
binding.tvAutoDownloadTips.goneIf(false)
|
|
||||||
var firstAutoDownloadGameName =
|
|
||||||
reserveOnlineEntity.games.find { it.wifiAutoDownload && !it.isLandPageAddressDialog() }?.name
|
|
||||||
|
|
||||||
if(!firstAutoDownloadGameName.isNullOrBlank() && firstAutoDownloadGameName.length > GAME_NAME_SHOW_MAX_LENGTH){
|
|
||||||
firstAutoDownloadGameName = "${firstAutoDownloadGameName.take(GAME_NAME_SHOW_MAX_LENGTH-1)}..."
|
|
||||||
}
|
|
||||||
val isWifiOpen = NetworkUtils.isWifiConnected(HaloApp.getInstance())
|
|
||||||
binding.tvAutoDownloadTips.text =
|
|
||||||
if (isWifiOpen) {
|
|
||||||
if (firstAutoDownloadGameName.isNullOrBlank()) {
|
|
||||||
getString(
|
|
||||||
R.string.reserve_reminder_auto_download,
|
|
||||||
"${reserveOnlineEntity.wifiAutoDownloadTotal}"
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
getString(
|
|
||||||
R.string.reserve_reminder_auto_download_with_name,
|
|
||||||
firstAutoDownloadGameName,
|
|
||||||
"${reserveOnlineEntity.wifiAutoDownloadTotal}"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (firstAutoDownloadGameName.isNullOrBlank()) {
|
|
||||||
getString(
|
|
||||||
R.string.reserve_reminder_wait_for_wifi_to_auto_download,
|
|
||||||
"${reserveOnlineEntity.wifiAutoDownloadTotal}"
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
getString(
|
|
||||||
R.string.reserve_reminder_wait_for_wifi_to_auto_download_with_name,
|
|
||||||
firstAutoDownloadGameName,
|
|
||||||
"${reserveOnlineEntity.wifiAutoDownloadTotal}"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.tvAutoDownloadTips.setOnClickListener {
|
|
||||||
SensorsBridge.trackAppointmentGameOnlineDialogClick(buttonName = "查看进度")
|
|
||||||
val intent = DownloadManagerActivity.getDownloadMangerIntent(requireContext(), "")
|
|
||||||
startActivity(intent)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
binding.tvAutoDownloadTips.goneIf(true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fun setOnDismissListener(dismissListener: () -> Unit) {
|
fun setOnDismissListener(dismissListener: () -> Unit) {
|
||||||
mDismissListener = dismissListener
|
mDismissListener = dismissListener
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDismiss(dialog: DialogInterface) {
|
|
||||||
super.onDismiss(dialog)
|
|
||||||
SensorsBridge.trackAppointmentGameOnlineDialogClick(buttonName = "关闭弹窗")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onStart() {
|
|
||||||
super.onStart()
|
|
||||||
dialog?.window?.let {
|
|
||||||
it.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
|
|
||||||
val params = it.attributes
|
|
||||||
params.width = DisplayUtils.dip2px(300F)
|
|
||||||
it.attributes = params
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
mDismissListener?.invoke()
|
mDismissListener?.invoke()
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val RESERVE_ONLINE = "reserve_online"
|
const val RESERVE_LIST = "reserve_list"
|
||||||
private const val GAME_NAME_SHOW_MAX_LENGTH = 8
|
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getInstance(reserveOnlineEntity: ReserveOnlineEntity?) = ReserveDialog().apply {
|
fun getInstance(reserveList: List<SimpleGameEntity>) = ReserveDialog().apply {
|
||||||
arguments = Bundle().apply {
|
arguments = Bundle()
|
||||||
putParcelable(RESERVE_ONLINE, reserveOnlineEntity)
|
arguments?.putParcelableArrayList(RESERVE_LIST, ArrayList(reserveList))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ReserveDialogAdapter(
|
|
||||||
context: Context,
|
|
||||||
private val games: List<GameEntity>
|
|
||||||
) :
|
|
||||||
BaseRecyclerAdapter<ReserveDialogItemViewHolder>(context), IExposable {
|
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ReserveDialogItemViewHolder {
|
|
||||||
return ReserveDialogItemViewHolder(parent.toBinding())
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
|
||||||
return if (games.size > 8) 8 else games.size
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ReserveDialogItemViewHolder, position: Int) {
|
|
||||||
val entity = games[position]
|
|
||||||
holder.binding.icon.displayGameIcon(entity)
|
|
||||||
holder.binding.gameNameTv.text = entity.name
|
|
||||||
holder.itemView.setOnClickListener {
|
|
||||||
SensorsBridge.trackAppointmentGameOnlineDialogClick(
|
|
||||||
"游戏",
|
|
||||||
entity.id,
|
|
||||||
entity.name ?: "",
|
|
||||||
entity.categoryChinese,
|
|
||||||
)
|
|
||||||
GameDetailActivity.startGameDetailActivity(mContext, entity.id, "(预约弹窗)", entity.exposureEvent)
|
|
||||||
}
|
|
||||||
entity.exposureEvent = ExposureEvent.createEvent(
|
|
||||||
entity,
|
|
||||||
listOf(ExposureSource("预约上线弹窗", ""))
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getEventByPosition(pos: Int): ExposureEvent? {
|
|
||||||
return games.getOrNull(pos)?.exposureEvent
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getEventListByPosition(pos: Int): List<ExposureEvent>? {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class ReserveDialogItemViewHolder(val binding: DialogReserveItemBinding) : BaseRecyclerViewHolder<Any>(binding.root)
|
class ReserveDialogItemViewHolder(val binding: DialogReserveItemBinding) : BaseRecyclerViewHolder<Any>(binding.root)
|
||||||
@ -1,278 +0,0 @@
|
|||||||
package com.gh.common.dialog
|
|
||||||
|
|
||||||
import android.app.Dialog
|
|
||||||
import android.content.Context
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.text.InputFilter
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import androidx.core.widget.addTextChangedListener
|
|
||||||
import com.gh.gamecenter.R
|
|
||||||
import com.gh.gamecenter.common.retrofit.BiResponse
|
|
||||||
import com.gh.gamecenter.common.retrofit.Response
|
|
||||||
import com.gh.gamecenter.common.utils.singleToMain
|
|
||||||
import com.gh.gamecenter.common.utils.toColor
|
|
||||||
import com.gh.gamecenter.common.utils.toResString
|
|
||||||
import com.gh.gamecenter.core.utils.ToastUtils
|
|
||||||
import com.gh.gamecenter.databinding.DialogReserveReminderPhoneNumberBinding
|
|
||||||
import com.gh.gamecenter.entity.ReserveModifyEntity
|
|
||||||
import com.gh.gamecenter.entity.ValidateCodeResponse
|
|
||||||
import com.halo.assistant.fragment.reserve.OnReserveReminderListener
|
|
||||||
import com.halo.assistant.fragment.reserve.ReserveReminderRepository
|
|
||||||
import io.reactivex.Observable
|
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
|
||||||
import io.reactivex.disposables.Disposable
|
|
||||||
import io.reactivex.schedulers.Schedulers
|
|
||||||
import okhttp3.ResponseBody
|
|
||||||
import org.json.JSONObject
|
|
||||||
import retrofit2.HttpException
|
|
||||||
import java.util.concurrent.TimeUnit
|
|
||||||
|
|
||||||
|
|
||||||
class ReserveReminderPhoneNumberDialog(
|
|
||||||
context: Context,
|
|
||||||
themeResId: Int,
|
|
||||||
private val dialogType: Int,
|
|
||||||
private val phoneNumber: String,
|
|
||||||
private var serviceId: String,
|
|
||||||
private val gameId: String,
|
|
||||||
private val repository: ReserveReminderRepository,
|
|
||||||
private val listener: OnReserveReminderListener
|
|
||||||
) :
|
|
||||||
Dialog(context, themeResId) {
|
|
||||||
|
|
||||||
private val compositeDisposable = CompositeDisposable()
|
|
||||||
|
|
||||||
private lateinit var binding: DialogReserveReminderPhoneNumberBinding
|
|
||||||
|
|
||||||
private var hasValidated = false
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
|
|
||||||
binding = DialogReserveReminderPhoneNumberBinding.inflate(LayoutInflater.from(context))
|
|
||||||
setContentView(binding.root)
|
|
||||||
initView()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun initView() {
|
|
||||||
binding.vClose.setOnClickListener {
|
|
||||||
dismiss()
|
|
||||||
}
|
|
||||||
|
|
||||||
setSubmitState(phoneNumber)
|
|
||||||
binding.etInput.addTextChangedListener {
|
|
||||||
val content = binding.etInput.text?.toString() ?: ""
|
|
||||||
if (dialogType == DIALOG_TYPE_BIND_PHONE || dialogType == DIALOG_TYPE_CHANGE_PHONE) {
|
|
||||||
setSubmitState(content)
|
|
||||||
} else {
|
|
||||||
val length = content.length
|
|
||||||
if (length == VALIDATE_CODE_LENGTH) {
|
|
||||||
verifyPhoneNumber(content)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
when (dialogType) {
|
|
||||||
DIALOG_TYPE_BIND_PHONE -> {
|
|
||||||
binding.tvTitle.setText(R.string.enable_sms_reminder)
|
|
||||||
binding.tvDescription.setText(R.string.enable_sms_reminder_description)
|
|
||||||
binding.etInput.setText(phoneNumber)
|
|
||||||
binding.etInput.setHint(com.gh.gamecenter.login.R.string.input_phone_hint)
|
|
||||||
}
|
|
||||||
|
|
||||||
DIALOG_TYPE_CHANGE_PHONE -> {
|
|
||||||
binding.tvTitle.setText(R.string.change_phone_number_2)
|
|
||||||
binding.tvDescription.setText(R.string.enable_sms_reminder_description)
|
|
||||||
binding.etInput.setText(phoneNumber)
|
|
||||||
binding.etInput.setHint(com.gh.gamecenter.login.R.string.input_phone_hint)
|
|
||||||
}
|
|
||||||
|
|
||||||
DIALOG_TYPE_VERIFY_PHONE -> {
|
|
||||||
startCountDown()
|
|
||||||
binding.tvTitle.setText(R.string.please_input_sms_verify_code)
|
|
||||||
if (phoneNumber.length == PHONE_NUMBER_LENGTH) {
|
|
||||||
val phoneNumberWithMask = phoneNumber.substring(0, 3) + MASK + phoneNumber.substring(7)
|
|
||||||
binding.tvDescription.text =
|
|
||||||
context.getString(R.string.verify_code_send_with_phone_number, phoneNumberWithMask)
|
|
||||||
}
|
|
||||||
binding.tvSubmit.alpha = 1.0F
|
|
||||||
binding.etInput.filters = arrayOf<InputFilter>(InputFilter.LengthFilter(VALIDATE_CODE_LENGTH))
|
|
||||||
binding.etInput.setHint(R.string.please_input_verify_code)
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
binding.tvSubmit.setOnClickListener {
|
|
||||||
val text = binding.etInput.text?.toString() ?: ""
|
|
||||||
if (dialogType == DIALOG_TYPE_VERIFY_PHONE) {
|
|
||||||
resendValidateCode()
|
|
||||||
} else {
|
|
||||||
if (isEnableSubmit(text)) {
|
|
||||||
when (dialogType) {
|
|
||||||
DIALOG_TYPE_BIND_PHONE -> bindPhoneNumber(text)
|
|
||||||
DIALOG_TYPE_CHANGE_PHONE -> bindPhoneNumber(text)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (text != phoneNumber) {
|
|
||||||
ToastUtils.toast(R.string.invalid_phone_number_format.toResString())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private fun resendValidateCode() {
|
|
||||||
repository.sendVerifyCode(phoneNumber)
|
|
||||||
.compose(singleToMain())
|
|
||||||
.subscribe(object : BiResponse<ValidateCodeResponse>() {
|
|
||||||
override fun onSuccess(data: ValidateCodeResponse) {
|
|
||||||
serviceId = data.serviceId
|
|
||||||
startCountDown()
|
|
||||||
}
|
|
||||||
|
|
||||||
}).let(compositeDisposable::add)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun verifyPhoneNumber(content: String) {
|
|
||||||
repository.verifyPhoneNumber(phoneNumber, content, serviceId)
|
|
||||||
.compose(singleToMain())
|
|
||||||
.subscribe(object : BiResponse<ResponseBody>() {
|
|
||||||
override fun onSuccess(data: ResponseBody) {
|
|
||||||
hasValidated = true
|
|
||||||
listener.phoneNumberValidateSuccessfully()
|
|
||||||
ToastUtils.toast(R.string.phone_number_validate_successfully.toResString())
|
|
||||||
dismiss()
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onFailure(exception: Exception) {
|
|
||||||
super.onFailure(exception)
|
|
||||||
binding.etInput.text = null
|
|
||||||
ToastUtils.toast(R.string.phone_number_validate_failure.toResString())
|
|
||||||
}
|
|
||||||
}).let(compositeDisposable::add)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private fun bindPhoneNumber(phone: String) {
|
|
||||||
repository.bindPhone(gameId, phone)
|
|
||||||
.compose(singleToMain())
|
|
||||||
.subscribe(object : BiResponse<ReserveModifyEntity>() {
|
|
||||||
override fun onSuccess(data: ReserveModifyEntity) {
|
|
||||||
listener.bindPhoneSuccessfully(data.smsConfig.mobileValidated, phone)
|
|
||||||
dismiss()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onFailure(exception: Exception) {
|
|
||||||
super.onFailure(exception)
|
|
||||||
if (exception is HttpException) {
|
|
||||||
try {
|
|
||||||
val string = exception.response().errorBody()?.string()
|
|
||||||
if (!string.isNullOrBlank()) {
|
|
||||||
val json = JSONObject(string)
|
|
||||||
val message = json.getJSONObject("toast").getString("sms_config.mobile")
|
|
||||||
ToastUtils.showToast(message)
|
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
|
||||||
// no implement
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}).let(compositeDisposable::add)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private fun startCountDown() {
|
|
||||||
binding.tvSubmit.isEnabled = false
|
|
||||||
binding.tvSubmit.setBackgroundResource(com.gh.gamecenter.common.R.drawable.bg_common_button_light_fill_gray)
|
|
||||||
binding.tvSubmit.setTextColor(com.gh.gamecenter.common.R.color.text_tertiary.toColor(context))
|
|
||||||
Observable.interval(0, 1, TimeUnit.SECONDS)
|
|
||||||
.take(COUNT_DOWN_DURATION)
|
|
||||||
.map {
|
|
||||||
COUNT_DOWN_DURATION - it
|
|
||||||
}
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(object : Response<Long>() {
|
|
||||||
override fun onSubscribe(d: Disposable) {
|
|
||||||
compositeDisposable.add(d)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
override fun onNext(time: Long) {
|
|
||||||
binding.tvSubmit.text = context.getString(R.string.resend_with_time, "$time")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onComplete() {
|
|
||||||
binding.tvSubmit.isEnabled = true
|
|
||||||
binding.tvSubmit.setBackgroundResource(com.gh.gamecenter.common.R.drawable.bg_common_button_fill_blue)
|
|
||||||
binding.tvSubmit.setTextColor(com.gh.gamecenter.common.R.color.text_aw_primary.toColor(context))
|
|
||||||
binding.tvSubmit.setText(R.string.resend)
|
|
||||||
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun dismiss() {
|
|
||||||
compositeDisposable.clear()
|
|
||||||
if (dialogType == DIALOG_TYPE_VERIFY_PHONE && !hasValidated) {
|
|
||||||
ToastUtils.toast(R.string.phone_number_validate_cancel.toResString())
|
|
||||||
}
|
|
||||||
super.dismiss()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun isEnableSubmit(phone: String) =
|
|
||||||
PHONE_NUMBER_PATTERN.toRegex().matches(phone)
|
|
||||||
&& if (dialogType == DIALOG_TYPE_CHANGE_PHONE) phone != phoneNumber else true
|
|
||||||
|
|
||||||
private fun setSubmitState(phone: String) {
|
|
||||||
val isEnable = isEnableSubmit(phone)
|
|
||||||
binding.tvSubmit.alpha = if (isEnable) {
|
|
||||||
TV_SUBMIT_ENABLE_ALPHA
|
|
||||||
} else {
|
|
||||||
TV_SUBMIT_UNABLE_ALPHA
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
|
|
||||||
private const val PHONE_NUMBER_PATTERN = "^1\\d{10}$"
|
|
||||||
private const val MASK = "****"
|
|
||||||
private const val PHONE_NUMBER_LENGTH = 11
|
|
||||||
private const val VALIDATE_CODE_LENGTH = 6
|
|
||||||
|
|
||||||
const val DIALOG_TYPE_BIND_PHONE = 0
|
|
||||||
const val DIALOG_TYPE_CHANGE_PHONE = 1
|
|
||||||
const val DIALOG_TYPE_VERIFY_PHONE = 2
|
|
||||||
|
|
||||||
private const val COUNT_DOWN_DURATION = 60L
|
|
||||||
|
|
||||||
private const val TV_SUBMIT_ENABLE_ALPHA = 1F
|
|
||||||
private const val TV_SUBMIT_UNABLE_ALPHA = 0.4F
|
|
||||||
|
|
||||||
fun create(
|
|
||||||
context: Context,
|
|
||||||
dialogType: Int,
|
|
||||||
phoneNumber: String,
|
|
||||||
serviceId: String,
|
|
||||||
gameId: String,
|
|
||||||
repository: ReserveReminderRepository,
|
|
||||||
listener: OnReserveReminderListener
|
|
||||||
) =
|
|
||||||
ReserveReminderPhoneNumberDialog(
|
|
||||||
context,
|
|
||||||
com.gh.gamecenter.common.R.style.DialogWindowTransparent,
|
|
||||||
dialogType,
|
|
||||||
phoneNumber,
|
|
||||||
serviceId,
|
|
||||||
gameId,
|
|
||||||
repository,
|
|
||||||
listener
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,499 +0,0 @@
|
|||||||
package com.gh.common.dialog
|
|
||||||
|
|
||||||
import android.app.Dialog
|
|
||||||
import android.content.Context
|
|
||||||
import android.graphics.Color
|
|
||||||
import android.graphics.drawable.ColorDrawable
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.os.Handler
|
|
||||||
import android.os.Looper
|
|
||||||
import android.text.TextUtils
|
|
||||||
import android.view.*
|
|
||||||
import android.view.ViewGroup.MarginLayoutParams
|
|
||||||
import androidx.core.view.updateLayoutParams
|
|
||||||
import com.gh.common.pop.EditBindPhoneInfoPop
|
|
||||||
import com.gh.common.pop.EditBindWechatPop
|
|
||||||
import com.gh.common.pop.RealNameTipsPop
|
|
||||||
import com.gh.gamecenter.R
|
|
||||||
import com.gh.gamecenter.common.constant.Constants
|
|
||||||
import com.gh.gamecenter.common.entity.WechatConfigEntity
|
|
||||||
import com.gh.gamecenter.common.utils.dip2px
|
|
||||||
import com.gh.gamecenter.common.utils.goneIf
|
|
||||||
import com.gh.gamecenter.common.utils.toObject
|
|
||||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
|
||||||
import com.gh.gamecenter.core.utils.SPUtils
|
|
||||||
import com.gh.gamecenter.databinding.*
|
|
||||||
import com.gh.gamecenter.entity.ReserveReminderEntity
|
|
||||||
import com.gh.gamecenter.login.entity.UserInfoEntity
|
|
||||||
import com.gh.gamecenter.login.user.UserManager
|
|
||||||
import com.halo.assistant.HaloApp
|
|
||||||
import com.halo.assistant.fragment.reserve.OnReserveReminderListener
|
|
||||||
|
|
||||||
class ReserveSuccessReminderDialog(
|
|
||||||
context: Context,
|
|
||||||
themeResId: Int,
|
|
||||||
private val listener: OnReserveReminderListener
|
|
||||||
) :
|
|
||||||
Dialog(context, themeResId), OnReserveSuccessListener {
|
|
||||||
|
|
||||||
private var reserveReminder = ReserveReminderEntity()
|
|
||||||
|
|
||||||
private val handler = Handler(Looper.getMainLooper())
|
|
||||||
|
|
||||||
private val handlers = arrayListOf<ReminderContentHandler>()
|
|
||||||
|
|
||||||
private lateinit var binding: DialogReserveSuccessWithSmsBinding
|
|
||||||
|
|
||||||
private val realNameQuestionPop by lazy {
|
|
||||||
RealNameTipsPop.create(context, listener)
|
|
||||||
}
|
|
||||||
|
|
||||||
private var hasAutoPopped = false
|
|
||||||
private var isInit = true
|
|
||||||
|
|
||||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
|
||||||
if (event.action == MotionEvent.ACTION_UP) {
|
|
||||||
if (realNameQuestionPop.isShowing) {
|
|
||||||
realNameQuestionPop.dismiss()
|
|
||||||
return true
|
|
||||||
} else if (handlers.any { it.hasPopShowing }) {
|
|
||||||
handlers.forEach {
|
|
||||||
it.dismissPop()
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return super.onTouchEvent(event)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
binding = DialogReserveSuccessWithSmsBinding.inflate(LayoutInflater.from(context))
|
|
||||||
setContentView(binding.root)
|
|
||||||
|
|
||||||
binding.ivClose.setOnClickListener {
|
|
||||||
dismiss()
|
|
||||||
}
|
|
||||||
binding.ivQuestion.setOnClickListener {
|
|
||||||
realNameQuestionPop.showAtLocation(binding.cbAutoDownload, Gravity.BOTTOM, 0, 4F.dip2px())
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun initView() {
|
|
||||||
handlers.clear()
|
|
||||||
binding.flContentContainer.removeAllViews()
|
|
||||||
|
|
||||||
val configTypes = mutableListOf<Int>()
|
|
||||||
// 短信
|
|
||||||
if (reserveReminder.hasSmsConfig) {
|
|
||||||
if (reserveReminder.smsConfig.notice) {
|
|
||||||
configTypes.add(SMS_REMINDER_ENABLE_TYPE)
|
|
||||||
} else {
|
|
||||||
configTypes.add(SMS_REMINDER_UNABLE_TYPE)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 微信
|
|
||||||
if (reserveReminder.wechatConfig.isReminderEnable) {
|
|
||||||
configTypes.add(WECHAT_REMINDER_ENABLE_TYPE)
|
|
||||||
} else {
|
|
||||||
configTypes.add(WECHAT_REMINDER_UNABLE_TYPE)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 日历
|
|
||||||
if (reserveReminder.hasCalendarConfig) {
|
|
||||||
if (reserveReminder.calendarConfig.notice) {
|
|
||||||
configTypes.add(CALENDAR_REMINDER_ENABLE_TYPE)
|
|
||||||
} else {
|
|
||||||
configTypes.add(CALENDAR_REMINDER_UNABLE_TYPE)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (configTypes.size == 1) {
|
|
||||||
// 只有微信提醒
|
|
||||||
if (configTypes.first() == WECHAT_REMINDER_ENABLE_TYPE) {
|
|
||||||
binding.tvContent.setText(R.string.reverse_success_with_reminder_tips)
|
|
||||||
handlers.add(
|
|
||||||
WechatReminderEnableHandler(reserveReminder.wechatConfig, 8.dp, binding.flContentContainer, this)
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
binding.tvContent.setText(R.string.reverse_success_without_reminder_tips)
|
|
||||||
handlers.add(OnlyWechatReminderUnableHandler(16.dp, binding.flContentContainer, this))
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
binding.tvContent.setText(R.string.reverse_success_with_reminder_tips)
|
|
||||||
var isLargerSpacing = true
|
|
||||||
fun getPaddingTop(): Int {
|
|
||||||
val paddingTop = if (isLargerSpacing) 16.dp else 8.dp
|
|
||||||
isLargerSpacing = false
|
|
||||||
return paddingTop
|
|
||||||
}
|
|
||||||
configTypes.sorted().forEach {
|
|
||||||
when (it) {
|
|
||||||
SMS_REMINDER_ENABLE_TYPE -> {
|
|
||||||
isLargerSpacing = true
|
|
||||||
SmsReminderEnableHandler(reserveReminder.smsConfig, 8.dp, binding.flContentContainer, this)
|
|
||||||
}
|
|
||||||
|
|
||||||
SMS_REMINDER_UNABLE_TYPE -> {
|
|
||||||
SmsReminderUnableHandler(getPaddingTop(), binding.flContentContainer, this)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WECHAT_REMINDER_ENABLE_TYPE -> {
|
|
||||||
isLargerSpacing = true
|
|
||||||
WechatReminderEnableHandler(
|
|
||||||
reserveReminder.wechatConfig,
|
|
||||||
8.dp,
|
|
||||||
binding.flContentContainer,
|
|
||||||
this
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WECHAT_REMINDER_UNABLE_TYPE ->
|
|
||||||
WechatReminderUnableHandler(getPaddingTop(), binding.flContentContainer, this)
|
|
||||||
|
|
||||||
CALENDAR_REMINDER_ENABLE_TYPE -> {
|
|
||||||
isLargerSpacing = true
|
|
||||||
CalendarReminderEnableHandler(8.dp, binding.flContentContainer, this)
|
|
||||||
}
|
|
||||||
|
|
||||||
CALENDAR_REMINDER_UNABLE_TYPE ->
|
|
||||||
CalendarReminderUnableHandler(getPaddingTop(), binding.flContentContainer, this)
|
|
||||||
|
|
||||||
else -> null
|
|
||||||
}?.let(handlers::add)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handlers.forEach {
|
|
||||||
binding.flContentContainer.addView(it.init())
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isInit) {
|
|
||||||
isInit = false
|
|
||||||
binding.gAutoDownload.goneIf(!reserveReminder.isEnableAutoDownload)
|
|
||||||
if (reserveReminder.isEnableAutoDownload) {
|
|
||||||
binding.cbAutoDownload.isChecked = reserveReminder.wifiAutoDownload
|
|
||||||
checkIfShowRealNamePop()
|
|
||||||
}
|
|
||||||
binding.cbAutoDownload.setOnCheckedChangeListener { _, isChecked ->
|
|
||||||
listener.enableAutoDownload(isChecked)
|
|
||||||
checkIfShowRealNamePop()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun checkIfShowRealNamePop() {
|
|
||||||
if (hasAutoPopped) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
hasAutoPopped = true
|
|
||||||
handler.postDelayed({
|
|
||||||
val idCard = UserManager.getInstance().userInfoEntity?.idCard
|
|
||||||
if (idCard != null && idCard.status != 1 && idCard.minor != true) {
|
|
||||||
// 账号已实名
|
|
||||||
return@postDelayed
|
|
||||||
}
|
|
||||||
|
|
||||||
val deviceCertificationInfoString =
|
|
||||||
SPUtils.getString(Constants.SP_DEVICE_CERTIFICATION_PREFIX + HaloApp.getInstance().gid)
|
|
||||||
if (!TextUtils.isEmpty(deviceCertificationInfoString)) {
|
|
||||||
val deviceIdCard = deviceCertificationInfoString.toObject<UserInfoEntity>()?.idCard
|
|
||||||
if (deviceIdCard != null && deviceIdCard.status != 1 && deviceIdCard.minor != true) {
|
|
||||||
// 设备已实名
|
|
||||||
return@postDelayed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
realNameQuestionPop.showAtLocation(binding.cbAutoDownload, Gravity.BOTTOM, 0, 0)
|
|
||||||
}, 16)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun updateSmsReminder(isEnable: Boolean) {
|
|
||||||
listener.updateSmsReminder(isEnable)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun updateWechatReminder() {
|
|
||||||
listener.updateWechatReminder()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun changePhoneNumber() {
|
|
||||||
listener.changedPhoneNumber()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun verifyPhoneNumber() {
|
|
||||||
listener.verifyPhoneNumber()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun changeWechatBinding() {
|
|
||||||
listener.changeWechatBinding()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun updateCalendarReminder() {
|
|
||||||
listener.updateCalendarReminder()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onStart() {
|
|
||||||
super.onStart()
|
|
||||||
window?.let {
|
|
||||||
it.setDimAmount(0.4F)
|
|
||||||
it.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
|
|
||||||
val params = it.attributes
|
|
||||||
params.width = DisplayUtils.dip2px(300F)
|
|
||||||
it.attributes = params
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun updateReserveReminder(reserveReminder: ReserveReminderEntity) {
|
|
||||||
this.reserveReminder = reserveReminder
|
|
||||||
initView()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun dismiss() {
|
|
||||||
handler.removeCallbacksAndMessages(null)
|
|
||||||
super.dismiss()
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
private val Int.dp: Int
|
|
||||||
get() = DisplayUtils.dip2px(this.toFloat())
|
|
||||||
|
|
||||||
private const val SMS_REMINDER_ENABLE_TYPE = 1
|
|
||||||
private const val WECHAT_REMINDER_ENABLE_TYPE = 2
|
|
||||||
private const val CALENDAR_REMINDER_ENABLE_TYPE = 3
|
|
||||||
private const val SMS_REMINDER_UNABLE_TYPE = 4
|
|
||||||
private const val WECHAT_REMINDER_UNABLE_TYPE = 5
|
|
||||||
private const val CALENDAR_REMINDER_UNABLE_TYPE = 6
|
|
||||||
|
|
||||||
fun create(context: Context, listener: OnReserveReminderListener) =
|
|
||||||
ReserveSuccessReminderDialog(
|
|
||||||
context,
|
|
||||||
com.gh.gamecenter.common.R.style.DialogWindowTransparent,
|
|
||||||
listener
|
|
||||||
).apply {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class ReminderContentHandler(
|
|
||||||
val topMargin: Int,
|
|
||||||
val parent: ViewGroup,
|
|
||||||
val listener: OnReserveSuccessListener
|
|
||||||
) {
|
|
||||||
|
|
||||||
open val hasPopShowing: Boolean = false
|
|
||||||
|
|
||||||
fun init(): View {
|
|
||||||
val root = createView(LayoutInflater.from(parent.context))
|
|
||||||
root.updateLayoutParams<MarginLayoutParams> {
|
|
||||||
this.topMargin = this@ReminderContentHandler.topMargin
|
|
||||||
}
|
|
||||||
initView()
|
|
||||||
return root
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract fun createView(inflater: LayoutInflater): View
|
|
||||||
|
|
||||||
protected abstract fun initView()
|
|
||||||
|
|
||||||
open fun dismissPop() = Unit
|
|
||||||
}
|
|
||||||
|
|
||||||
class SmsReminderUnableHandler(topMargin: Int, parent: ViewGroup, listener: OnReserveSuccessListener) :
|
|
||||||
ReminderContentHandler(topMargin, parent, listener) {
|
|
||||||
|
|
||||||
private lateinit var binding: LayoutReserveSmsReminderUnableBinding
|
|
||||||
|
|
||||||
override fun createView(inflater: LayoutInflater): View {
|
|
||||||
return LayoutReserveSmsReminderUnableBinding.inflate(inflater, parent, false)
|
|
||||||
.also {
|
|
||||||
binding = it
|
|
||||||
}.root
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun initView() {
|
|
||||||
binding.vSmsAdd.setOnClickListener {
|
|
||||||
listener.updateSmsReminder(true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class WechatReminderUnableHandler(topMargin: Int, parent: ViewGroup, listener: OnReserveSuccessListener) :
|
|
||||||
ReminderContentHandler(topMargin, parent, listener) {
|
|
||||||
|
|
||||||
private lateinit var binding: LayoutReserveWechatReminderUnableBinding
|
|
||||||
|
|
||||||
override fun createView(inflater: LayoutInflater): View {
|
|
||||||
return LayoutReserveWechatReminderUnableBinding.inflate(inflater, parent, false)
|
|
||||||
.also {
|
|
||||||
binding = it
|
|
||||||
}.root
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun initView() {
|
|
||||||
binding.vWechatAdd.setOnClickListener {
|
|
||||||
listener.updateWechatReminder()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class SmsReminderEnableHandler(
|
|
||||||
private val smsConfig: ReserveReminderEntity.SmsConfig,
|
|
||||||
topMargin: Int,
|
|
||||||
parent: ViewGroup, listener:
|
|
||||||
OnReserveSuccessListener
|
|
||||||
) :
|
|
||||||
ReminderContentHandler(topMargin, parent, listener) {
|
|
||||||
|
|
||||||
private lateinit var binding: LayoutReserveSmsReminderEnableBinding
|
|
||||||
|
|
||||||
override val hasPopShowing: Boolean
|
|
||||||
get() = editBindPhoneInfoPop.isShowing
|
|
||||||
|
|
||||||
override fun dismissPop() {
|
|
||||||
if (hasPopShowing) {
|
|
||||||
editBindPhoneInfoPop.dismiss()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private val editBindPhoneInfoPop by lazy {
|
|
||||||
EditBindPhoneInfoPop.create(parent.context, smsConfig.mobileValidated, listener)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun createView(inflater: LayoutInflater) =
|
|
||||||
LayoutReserveSmsReminderEnableBinding.inflate(inflater, parent, false)
|
|
||||||
.also {
|
|
||||||
binding = it
|
|
||||||
}.root
|
|
||||||
|
|
||||||
override fun initView() {
|
|
||||||
binding.tvPhone.text = smsConfig.mobile
|
|
||||||
binding.vSmsEdit.setOnClickListener {
|
|
||||||
editBindPhoneInfoPop.showAsDropDown(
|
|
||||||
binding.ivSmsEdit,
|
|
||||||
(-104).dp,
|
|
||||||
0,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class WechatReminderEnableHandler(
|
|
||||||
private val wechatConfig: WechatConfigEntity,
|
|
||||||
topMargin: Int,
|
|
||||||
parent: ViewGroup,
|
|
||||||
listener: OnReserveSuccessListener
|
|
||||||
) :
|
|
||||||
ReminderContentHandler(topMargin, parent, listener) {
|
|
||||||
|
|
||||||
private lateinit var binding: LayoutReserveWechatReminderEnableBinding
|
|
||||||
|
|
||||||
private val editWechatPop by lazy {
|
|
||||||
EditBindWechatPop.create(parent.context, listener)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun createView(inflater: LayoutInflater) =
|
|
||||||
LayoutReserveWechatReminderEnableBinding.inflate(inflater, parent, false)
|
|
||||||
.also {
|
|
||||||
binding = it
|
|
||||||
}.root
|
|
||||||
|
|
||||||
override fun initView() {
|
|
||||||
binding.tvWechat.text = wechatConfig.nickName
|
|
||||||
binding.vModifyWechat.setOnClickListener {
|
|
||||||
editWechatPop.showAsDropDown(
|
|
||||||
binding.ivModifyWechat,
|
|
||||||
(-104).dp,
|
|
||||||
0
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class OnlyWechatReminderUnableHandler(topMargin: Int, parent: ViewGroup, listener: OnReserveSuccessListener) :
|
|
||||||
ReminderContentHandler(topMargin, parent, listener) {
|
|
||||||
|
|
||||||
private lateinit var binding: LayoutReserveOnlyWechatUnableBinding
|
|
||||||
|
|
||||||
override fun createView(inflater: LayoutInflater) =
|
|
||||||
LayoutReserveOnlyWechatUnableBinding.inflate(inflater, parent, false)
|
|
||||||
.also {
|
|
||||||
binding = it
|
|
||||||
}.root
|
|
||||||
|
|
||||||
override fun initView() {
|
|
||||||
binding.vSubmitBackground.setOnClickListener {
|
|
||||||
listener.updateWechatReminder()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class CalendarReminderUnableHandler(
|
|
||||||
topMargin: Int,
|
|
||||||
parent: ViewGroup,
|
|
||||||
listener: OnReserveSuccessListener
|
|
||||||
) : ReminderContentHandler(topMargin, parent, listener) {
|
|
||||||
|
|
||||||
private lateinit var binding: LayoutReserveWechatReminderUnableBinding
|
|
||||||
|
|
||||||
// 复用微信提醒未开启状态布局
|
|
||||||
override fun createView(inflater: LayoutInflater) =
|
|
||||||
LayoutReserveWechatReminderUnableBinding.inflate(inflater, parent, false)
|
|
||||||
.also {
|
|
||||||
binding = it
|
|
||||||
}.root
|
|
||||||
|
|
||||||
override fun initView() {
|
|
||||||
binding.tvWechatReminderTitle.setText(R.string.calendar_reminders)
|
|
||||||
binding.tvWechatReminderDescription.setText(R.string.calendar_reminders_description)
|
|
||||||
binding.vWechatAdd.setOnClickListener {
|
|
||||||
listener.updateCalendarReminder()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class CalendarReminderEnableHandler(
|
|
||||||
topMargin: Int,
|
|
||||||
parent: ViewGroup,
|
|
||||||
listener: OnReserveSuccessListener
|
|
||||||
) : ReminderContentHandler(topMargin, parent, listener) {
|
|
||||||
|
|
||||||
private lateinit var binding: LayoutReserveCalendarReminderUnableBinding
|
|
||||||
|
|
||||||
override fun createView(inflater: LayoutInflater) =
|
|
||||||
LayoutReserveCalendarReminderUnableBinding.inflate(inflater, parent, false)
|
|
||||||
.also {
|
|
||||||
binding = it
|
|
||||||
}.root
|
|
||||||
|
|
||||||
override fun initView() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
interface OnReserveSuccessListener {
|
|
||||||
|
|
||||||
fun updateSmsReminder(isEnable: Boolean)
|
|
||||||
|
|
||||||
fun updateWechatReminder()
|
|
||||||
|
|
||||||
fun changePhoneNumber()
|
|
||||||
|
|
||||||
fun verifyPhoneNumber()
|
|
||||||
|
|
||||||
fun changeWechatBinding()
|
|
||||||
|
|
||||||
fun updateCalendarReminder()
|
|
||||||
}
|
|
||||||
@ -1,63 +0,0 @@
|
|||||||
package com.gh.common.dialog
|
|
||||||
|
|
||||||
import android.app.Dialog
|
|
||||||
import android.content.Context
|
|
||||||
import android.graphics.Color
|
|
||||||
import android.graphics.drawable.ColorDrawable
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import com.gh.gamecenter.common.base.fragment.BaseDialogFragment
|
|
||||||
import com.gh.gamecenter.core.utils.CurrentActivityHolder
|
|
||||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
|
||||||
import com.gh.gamecenter.databinding.DialogWechatBindingConflictBinding
|
|
||||||
|
|
||||||
class WechatBindingConflictDialogFragment : BaseDialogFragment() {
|
|
||||||
|
|
||||||
private lateinit var binding: DialogWechatBindingConflictBinding
|
|
||||||
|
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
|
||||||
return super.onCreateDialog(savedInstanceState).apply {
|
|
||||||
setCanceledOnTouchOutside(true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
|
||||||
return DialogWechatBindingConflictBinding.inflate(inflater, container, false)
|
|
||||||
.also {
|
|
||||||
binding = it
|
|
||||||
}.root
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
||||||
super.onViewCreated(view, savedInstanceState)
|
|
||||||
binding.tvIKnow.setOnClickListener {
|
|
||||||
dismiss()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onStart() {
|
|
||||||
super.onStart()
|
|
||||||
dialog?.window?.let {
|
|
||||||
it.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
|
|
||||||
val params = it.attributes
|
|
||||||
params.width = DisplayUtils.dip2px(300F)
|
|
||||||
it.attributes = params
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
|
|
||||||
fun show(context: Context) {
|
|
||||||
if (context is AppCompatActivity) {
|
|
||||||
context.supportFragmentManager
|
|
||||||
} else {
|
|
||||||
(CurrentActivityHolder.getCurrentActivity() as? AppCompatActivity)?.supportFragmentManager
|
|
||||||
}?.let {
|
|
||||||
WechatBindingConflictDialogFragment().show(it, WechatBindingConflictDialogFragment::class.java.name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,125 +0,0 @@
|
|||||||
package com.gh.common.dialog
|
|
||||||
|
|
||||||
import android.app.Dialog
|
|
||||||
import android.content.ClipData
|
|
||||||
import android.content.ClipboardManager
|
|
||||||
import android.content.Context
|
|
||||||
import android.graphics.Color
|
|
||||||
import android.graphics.drawable.ColorDrawable
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import com.gh.gamecenter.R
|
|
||||||
import com.gh.gamecenter.common.base.fragment.BaseDialogFragment
|
|
||||||
import com.gh.gamecenter.common.entity.ErrorEntity
|
|
||||||
import com.gh.gamecenter.core.utils.CurrentActivityHolder
|
|
||||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
|
||||||
import com.gh.gamecenter.databinding.DialogWechatBindingFailedBinding
|
|
||||||
import com.gh.gamecenter.login.user.UserManager
|
|
||||||
import com.lightgame.utils.Utils
|
|
||||||
|
|
||||||
class WechatBindingFailedDialogFragment : BaseDialogFragment() {
|
|
||||||
|
|
||||||
private lateinit var binding: DialogWechatBindingFailedBinding
|
|
||||||
|
|
||||||
private var currentUserId: String? = null
|
|
||||||
private lateinit var userConflict: ErrorEntity.Data.UserConflict
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
userConflict = arguments?.getParcelable(KEY_USER_CONFLICT) ?: ErrorEntity.Data.UserConflict()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
|
||||||
return super.onCreateDialog(savedInstanceState).apply {
|
|
||||||
setCanceledOnTouchOutside(true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
|
||||||
return DialogWechatBindingFailedBinding.inflate(inflater, container, false)
|
|
||||||
.also {
|
|
||||||
binding = it
|
|
||||||
}.root
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
||||||
super.onViewCreated(view, savedInstanceState)
|
|
||||||
|
|
||||||
UserManager.getInstance().userInfoEntity?.let {
|
|
||||||
currentUserId = it.getShortUserId()
|
|
||||||
binding.tvCurrentName.text = it.name ?: ""
|
|
||||||
binding.ivCurrentAvatar.displayAvatar(it.icon)
|
|
||||||
binding.tvUserId.text = getString(R.string.user_id, currentUserId)
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.tvConflictName.text = userConflict.name
|
|
||||||
binding.ivConflictAvatar.displayAvatar(userConflict.icon)
|
|
||||||
binding.tvConflictUserId.text = getString(R.string.user_id, userConflict.seq)
|
|
||||||
|
|
||||||
|
|
||||||
binding.tvConflictProblem.setOnClickListener {
|
|
||||||
dismiss()
|
|
||||||
WechatBindingConflictDialogFragment.show(requireContext())
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.tvIKnow.setOnClickListener {
|
|
||||||
dismiss()
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.tvUserId.setOnLongClickListener {
|
|
||||||
currentUserId?.let {
|
|
||||||
copyTextToClipboard(it)
|
|
||||||
true
|
|
||||||
} ?: false
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.tvConflictUserId.setOnLongClickListener {
|
|
||||||
copyTextToClipboard(userConflict.id)
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun copyTextToClipboard(text: String) {
|
|
||||||
val clipboardManager = context?.getSystemService(Context.CLIPBOARD_SERVICE) as? ClipboardManager
|
|
||||||
if (clipboardManager != null) {
|
|
||||||
val clip = ClipData.newPlainText(COPY_ID_TEXT, text)
|
|
||||||
clipboardManager.setPrimaryClip(clip)
|
|
||||||
Utils.toast(requireContext(), R.string.copy_user_id_successfully)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onStart() {
|
|
||||||
super.onStart()
|
|
||||||
dialog?.window?.let {
|
|
||||||
it.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
|
|
||||||
val params = it.attributes
|
|
||||||
params.width = DisplayUtils.dip2px(300F)
|
|
||||||
it.attributes = params
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
|
|
||||||
private const val COPY_ID_TEXT = "user_id"
|
|
||||||
private const val KEY_USER_CONFLICT = "key_user_conflict"
|
|
||||||
|
|
||||||
fun show(context: Context, userConflict: ErrorEntity.Data.UserConflict?) {
|
|
||||||
if (context is AppCompatActivity) {
|
|
||||||
context.supportFragmentManager
|
|
||||||
} else {
|
|
||||||
(CurrentActivityHolder.getCurrentActivity() as? AppCompatActivity)?.supportFragmentManager
|
|
||||||
}?.let {
|
|
||||||
val fragment = WechatBindingFailedDialogFragment().apply {
|
|
||||||
arguments = Bundle().apply {
|
|
||||||
putParcelable(KEY_USER_CONFLICT, userConflict)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fragment.show(it, WechatBindingFailedDialogFragment::class.java.name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,61 +0,0 @@
|
|||||||
package com.gh.common.exposure
|
|
||||||
|
|
||||||
import com.gh.gamecenter.common.constant.Constants
|
|
||||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
|
||||||
import com.gh.gamecenter.feature.exposure.IExposureStateChangeListener
|
|
||||||
import com.gh.gamecenter.feature.exposure.RecyclerViewExposureHelper
|
|
||||||
import com.lightgame.utils.Utils
|
|
||||||
|
|
||||||
class DefaultExposureStateChangeListener : IExposureStateChangeListener {
|
|
||||||
|
|
||||||
override fun onExposureStateChange(
|
|
||||||
exposureEvent: ExposureEvent,
|
|
||||||
position: Int,
|
|
||||||
inExposure: Boolean
|
|
||||||
) {
|
|
||||||
val exposureStatus = if (inExposure) "曝光中" else "结束曝光"
|
|
||||||
|
|
||||||
val isCPMExposureEvent = exposureEvent.payload.miniGameType == Constants.WECHAT_MINI_GAME_CPM
|
|
||||||
val isDSPExposureEvent = exposureEvent.payload.miniGameType == Constants.DSP_GAME
|
|
||||||
|
|
||||||
Utils.log(
|
|
||||||
RecyclerViewExposureHelper.TAG,
|
|
||||||
"onExposureStateChange: 名称 ${exposureEvent.payload.gameName} 位置 $position, $exposureStatus"
|
|
||||||
)
|
|
||||||
|
|
||||||
// 如果是 CPM 曝光事件,且在曝光中,直接上报 CPM 曝光 (内部有做简单的去重处理,CPM 曝光追求一个及时上报,不用理会曝光时长)
|
|
||||||
if (isCPMExposureEvent && inExposure) {
|
|
||||||
Utils.log(
|
|
||||||
RecyclerViewExposureHelper.TAG,
|
|
||||||
"上报 CPM 曝光 ${exposureEvent.payload.gameName} ${exposureEvent.id}"
|
|
||||||
)
|
|
||||||
ExposureManager.logCPM(exposureEvent)
|
|
||||||
} else if (isDSPExposureEvent && inExposure) {
|
|
||||||
Utils.log(
|
|
||||||
RecyclerViewExposureHelper.TAG,
|
|
||||||
"上报 DSP 曝光 ${exposureEvent.payload.gameName} ${exposureEvent.id}"
|
|
||||||
)
|
|
||||||
ExposureManager.logDSP(exposureEvent)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!inExposure
|
|
||||||
&& System.currentTimeMillis() - exposureEvent.timeInMillisecond > DEFAULT_VALID_EXPOSURE_THRESHOLD
|
|
||||||
) {
|
|
||||||
Utils.log(
|
|
||||||
RecyclerViewExposureHelper.TAG,
|
|
||||||
"上报曝光 ${exposureEvent.payload.gameName} ${exposureEvent.id},是否为 CPM 小游戏 -> ${isCPMExposureEvent}," +
|
|
||||||
"曝光时长为 ${System.currentTimeMillis() - exposureEvent.timeInMillisecond}ms"
|
|
||||||
)
|
|
||||||
|
|
||||||
// 标记当前 ExposureEvent 已经被使用过
|
|
||||||
exposureEvent.markIsUsed()
|
|
||||||
ExposureManager.log(exposureEvent)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
// 默认曝光有效时长
|
|
||||||
const val DEFAULT_VALID_EXPOSURE_THRESHOLD = 1000L
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -6,7 +6,6 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
|||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.recyclerview.widget.RecyclerView.LayoutManager
|
import androidx.recyclerview.widget.RecyclerView.LayoutManager
|
||||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
||||||
import com.gh.gamecenter.common.constant.Constants
|
|
||||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||||
import io.reactivex.functions.Consumer
|
import io.reactivex.functions.Consumer
|
||||||
|
|
||||||
@ -17,9 +16,8 @@ class ExposureListener(var fragment: Fragment, var exposable: IExposable) : Recy
|
|||||||
|
|
||||||
val throttleBus: ExposureThrottleBus by lazy {
|
val throttleBus: ExposureThrottleBus by lazy {
|
||||||
ExposureThrottleBus(
|
ExposureThrottleBus(
|
||||||
{ commitExposure(it) },
|
Consumer { commitExposure(it) },
|
||||||
Consumer(Throwable::printStackTrace),
|
Consumer(Throwable::printStackTrace)
|
||||||
{ commitExternalExposure(it) }
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
var layoutManager: LayoutManager? = null
|
var layoutManager: LayoutManager? = null
|
||||||
@ -31,7 +29,6 @@ class ExposureListener(var fragment: Fragment, var exposable: IExposable) : Recy
|
|||||||
override fun onFragmentPaused(fm: FragmentManager, f: Fragment) {
|
override fun onFragmentPaused(fm: FragmentManager, f: Fragment) {
|
||||||
if (fragment == f) {
|
if (fragment == f) {
|
||||||
visibleState?.let { commitExposure(it) }
|
visibleState?.let { commitExposure(it) }
|
||||||
visibleState?.let { commitExternalExposure(it) }
|
|
||||||
throttleBus.clear()
|
throttleBus.clear()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -96,43 +93,4 @@ class ExposureListener(var fragment: Fragment, var exposable: IExposable) : Recy
|
|||||||
ExposureManager.log(eventList)
|
ExposureManager.log(eventList)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 提交第三方的曝光事件 (微信小游戏CPM 和 DSP 游戏)
|
|
||||||
* 由于普通曝光事件的上报通道存在节流特性,不符合CPM接口对于数据上报的实时性和准确性的要求,所以使用额外的通道进行上报
|
|
||||||
*/
|
|
||||||
private fun commitExternalExposure(visibleState: ExposureThrottleBus.VisibleState) {
|
|
||||||
|
|
||||||
val cpmEventList = arrayListOf<ExposureEvent>()
|
|
||||||
val dspEventList = arrayListOf<ExposureEvent>()
|
|
||||||
|
|
||||||
for (pos in visibleState.firstVisiblePosition..visibleState.lastVisiblePosition) {
|
|
||||||
try {
|
|
||||||
exposable.getEventByPosition(pos)?.let {
|
|
||||||
when (it.payload.miniGameType) {
|
|
||||||
Constants.WECHAT_MINI_GAME_CPM -> cpmEventList.add(it)
|
|
||||||
Constants.DSP_GAME -> dspEventList.add(it)
|
|
||||||
else -> {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exposable.getEventListByPosition(pos)?.let { list ->
|
|
||||||
list.forEach {
|
|
||||||
when (it.payload.miniGameType) {
|
|
||||||
Constants.WECHAT_MINI_GAME_CPM -> cpmEventList.add(it)
|
|
||||||
Constants.DSP_GAME -> dspEventList.add(it)
|
|
||||||
else -> {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (ignore: Exception) {
|
|
||||||
// Just ignore the error.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ExposureManager.logExternal(cpmEventList, dspEventList)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,19 +1,13 @@
|
|||||||
package com.gh.common.exposure
|
package com.gh.common.exposure
|
||||||
|
|
||||||
|
import com.aliyun.sls.android.producer.Log
|
||||||
import com.gh.gamecenter.BuildConfig
|
import com.gh.gamecenter.BuildConfig
|
||||||
import com.gh.gamecenter.common.constant.Constants
|
import com.gh.gamecenter.common.loghub.LoghubHelper
|
||||||
import com.gh.gamecenter.common.loghub.TLogHubHelper
|
|
||||||
import com.gh.gamecenter.common.utils.FixedSizeLinkedHashSet
|
import com.gh.gamecenter.common.utils.FixedSizeLinkedHashSet
|
||||||
|
import com.gh.gamecenter.common.utils.toJson
|
||||||
import com.gh.gamecenter.core.AppExecutor
|
import com.gh.gamecenter.core.AppExecutor
|
||||||
import com.gh.gamecenter.dsp.DspReportHelper
|
|
||||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||||
import com.gh.gamecenter.feature.exposure.ExposureType
|
|
||||||
import com.gh.gamecenter.feature.minigame.wechat.WGameSubjectCPMListReportHelper
|
|
||||||
import com.google.gson.ExclusionStrategy
|
|
||||||
import com.google.gson.FieldAttributes
|
|
||||||
import com.google.gson.GsonBuilder
|
|
||||||
import com.lightgame.utils.Utils
|
import com.lightgame.utils.Utils
|
||||||
import com.volcengine.model.tls.LogItem
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A handful tool for committing logs to aliyun loghub.
|
* A handful tool for committing logs to aliyun loghub.
|
||||||
@ -33,32 +27,11 @@ object ExposureManager {
|
|||||||
private val exposureSet by lazy { hashSetOf<ExposureEvent>() }
|
private val exposureSet by lazy { hashSetOf<ExposureEvent>() }
|
||||||
private val exposureCache by lazy { FixedSizeLinkedHashSet<String>(300) }
|
private val exposureCache by lazy { FixedSizeLinkedHashSet<String>(300) }
|
||||||
|
|
||||||
private val gson by lazy {
|
|
||||||
GsonBuilder()
|
|
||||||
.addSerializationExclusionStrategy(object: ExclusionStrategy {
|
|
||||||
override fun shouldSkipClass(clazz: Class<*>): Boolean {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun shouldSkipField(f: FieldAttributes): Boolean {
|
|
||||||
return f.name == "additional"
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.create()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log a single exposure event.
|
* Log a single exposure event.
|
||||||
*/
|
*/
|
||||||
fun log(event: ExposureEvent) {
|
fun log(event: ExposureEvent) {
|
||||||
AppExecutor.logExecutor.execute {
|
AppExecutor.logExecutor.execute {
|
||||||
if (event.payload.miniGameType == Constants.WECHAT_MINI_GAME_CPM) {
|
|
||||||
WGameSubjectCPMListReportHelper.reportExposure(event)
|
|
||||||
} else if (event.payload.miniGameType == Constants.DSP_GAME) {
|
|
||||||
if (event.event == ExposureType.DOWNLOAD_COMPLETE) {
|
|
||||||
DspReportHelper.report(event.payload.downloadUrl)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!exposureCache.contains(event.id)) {
|
if (!exposureCache.contains(event.id)) {
|
||||||
exposureSet.add(event)
|
exposureSet.add(event)
|
||||||
exposureCache.add(event.id)
|
exposureCache.add(event.id)
|
||||||
@ -85,38 +58,6 @@ object ExposureManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Log a collection of exposure event for external use.
|
|
||||||
*/
|
|
||||||
fun logExternal(cpmEventList: List<ExposureEvent>, dspEventList: ArrayList<ExposureEvent>) {
|
|
||||||
AppExecutor.logExecutor.execute {
|
|
||||||
if (cpmEventList.isNotEmpty()) {
|
|
||||||
WGameSubjectCPMListReportHelper.reportExposure(cpmEventList.toSet())
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dspEventList.isNotEmpty()) {
|
|
||||||
for (event in dspEventList) {
|
|
||||||
DspReportHelper.report(event.payload.showUrl)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Log a wechat mini game cpm collection of exposure event.
|
|
||||||
*/
|
|
||||||
fun logCPM(event: ExposureEvent) {
|
|
||||||
AppExecutor.logExecutor.execute {
|
|
||||||
WGameSubjectCPMListReportHelper.reportExposure(event)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun logDSP(event: ExposureEvent) {
|
|
||||||
AppExecutor.logExecutor.execute {
|
|
||||||
DspReportHelper.report(event.payload.showUrl)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param forcedUpload Ignore all restrictions.
|
* @param forcedUpload Ignore all restrictions.
|
||||||
*/
|
*/
|
||||||
@ -137,22 +78,21 @@ object ExposureManager {
|
|||||||
|
|
||||||
private fun uploadExposures(eventSet: HashSet<ExposureEvent>, forced: Boolean) {
|
private fun uploadExposures(eventSet: HashSet<ExposureEvent>, forced: Boolean) {
|
||||||
eventSet.forEach {
|
eventSet.forEach {
|
||||||
TLogHubHelper.sendLog(buildLog(it), LOG_STORE)
|
LoghubHelper.uploadLog(buildLog(it), LOG_STORE, forced)
|
||||||
// LoghubHelper.uploadLog(buildLog(it), LOG_STORE, forced)
|
|
||||||
// it.recycle()
|
// it.recycle()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun buildLog(event: ExposureEvent) = LogItem(System.currentTimeMillis()).apply {
|
private fun buildLog(event: ExposureEvent) = Log().apply {
|
||||||
addContent("__id", event.id)
|
putContent("id", event.id)
|
||||||
addContent("payload", gson.toJson(event.payload))
|
putContent("payload", event.payload.toJson())
|
||||||
addContent("event", event.event.toString())
|
putContent("event", event.event.toString())
|
||||||
addContent("source", eliminateMultipleBrackets(gson.toJson(event.source)))
|
putContent("source", eliminateMultipleBrackets(event.source.toJson()))
|
||||||
addContent("meta", gson.toJson(event.meta))
|
putContent("meta", event.meta.toJson())
|
||||||
addContent("real_millisecond", event.timeInMillisecond.toString())
|
putContent("real_millisecond", event.timeInMillisecond.toString())
|
||||||
addContent(
|
putContent(
|
||||||
"e-traces", if (event.eTrace != null) {
|
"e-traces", if (event.eTrace != null) {
|
||||||
eliminateMultipleBrackets(gson.toJson(event.eTrace))
|
eliminateMultipleBrackets(event.eTrace?.toJson() ?: "")
|
||||||
} else ""
|
} else ""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,20 +3,16 @@ package com.gh.common.exposure
|
|||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.functions.Consumer
|
import io.reactivex.functions.Consumer
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
import io.reactivex.subjects.BehaviorSubject
|
import io.reactivex.subjects.PublishSubject
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
class ExposureThrottleBus(
|
class ExposureThrottleBus(var onSuccess: Consumer<VisibleState>, var onError: Consumer<Throwable>) {
|
||||||
var onSuccess: Consumer<VisibleState>,
|
|
||||||
var onError: Consumer<Throwable>,
|
|
||||||
onPreSuccess: Consumer<VisibleState>
|
|
||||||
) {
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val THRESHOLD_TIME = 300L
|
private const val THRESHOLD_TIME = 300L
|
||||||
}
|
}
|
||||||
|
|
||||||
private val mPublishSubject: BehaviorSubject<VisibleState> = BehaviorSubject.create()
|
private val mPublishSubject: PublishSubject<VisibleState> = PublishSubject.create()
|
||||||
private val mCompositeDisposable: CompositeDisposable = CompositeDisposable()
|
private val mCompositeDisposable: CompositeDisposable = CompositeDisposable()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@ -28,7 +24,6 @@ class ExposureThrottleBus(
|
|||||||
*/
|
*/
|
||||||
val disposable = mPublishSubject
|
val disposable = mPublishSubject
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
.doOnNext(onPreSuccess)
|
|
||||||
.throttleWithTimeout(THRESHOLD_TIME, TimeUnit.MILLISECONDS)
|
.throttleWithTimeout(THRESHOLD_TIME, TimeUnit.MILLISECONDS)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.subscribe(onSuccess, onError)
|
.subscribe(onSuccess, onError)
|
||||||
|
|||||||
@ -8,13 +8,13 @@ object ExposureTraceUtils {
|
|||||||
val traceList = arrayListOf<ExposureEvent>()
|
val traceList = arrayListOf<ExposureEvent>()
|
||||||
|
|
||||||
event?.let {
|
event?.let {
|
||||||
//这里使用 copy,是为了防止循环引用调用hashCode方法触发StackOverflowError错误
|
//这里使用deepCopy,是为了防止循环引用调用hashCode方法触发StackOverflowError错误
|
||||||
val exposureCopy = it.shallowCopy()
|
val deepCopy = it.deepCopy()
|
||||||
if (exposureCopy.eTrace == null) {
|
if (deepCopy.eTrace == null) {
|
||||||
traceList.add(exposureCopy)
|
traceList.add(deepCopy)
|
||||||
} else {
|
} else {
|
||||||
traceList.addAll(exposureCopy.eTrace!!)
|
traceList.addAll(deepCopy.eTrace!!)
|
||||||
traceList.add(flattenTrace(exposureCopy))
|
traceList.add(flattenTrace(deepCopy))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -53,6 +53,7 @@ object ExposureUtils {
|
|||||||
return exposureEvent
|
return exposureEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
fun logADownloadCompleteExposureEvent(
|
fun logADownloadCompleteExposureEvent(
|
||||||
entity: GameEntity,
|
entity: GameEntity,
|
||||||
platform: String?,
|
platform: String?,
|
||||||
@ -60,7 +61,6 @@ object ExposureUtils {
|
|||||||
speed: Long,
|
speed: Long,
|
||||||
host: String? = "unknown",
|
host: String? = "unknown",
|
||||||
path: String? = "unknown",
|
path: String? = "unknown",
|
||||||
redirectedUrlList: String? = "unknown",
|
|
||||||
downloadType: DownloadType
|
downloadType: DownloadType
|
||||||
): ExposureEvent? {
|
): ExposureEvent? {
|
||||||
val gameEntity = entity.copy()
|
val gameEntity = entity.copy()
|
||||||
@ -88,8 +88,6 @@ object ExposureUtils {
|
|||||||
exposureEvent.payload.host = host
|
exposureEvent.payload.host = host
|
||||||
exposureEvent.payload.path = path
|
exposureEvent.payload.path = path
|
||||||
exposureEvent.payload.speed = speed
|
exposureEvent.payload.speed = speed
|
||||||
exposureEvent.payload.redirectedUrlList = redirectedUrlList
|
|
||||||
exposureEvent.payload.downloadUrl = gameEntity.downloadUrl
|
|
||||||
|
|
||||||
ExposureManager.log(exposureEvent)
|
ExposureManager.log(exposureEvent)
|
||||||
ExposureManager.commitSavedExposureEvents(forcedUpload = true)
|
ExposureManager.commitSavedExposureEvents(forcedUpload = true)
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import android.annotation.SuppressLint
|
|||||||
import com.gh.gamecenter.R
|
import com.gh.gamecenter.R
|
||||||
import com.gh.gamecenter.common.constant.Constants
|
import com.gh.gamecenter.common.constant.Constants
|
||||||
import com.gh.gamecenter.common.retrofit.BiResponse
|
import com.gh.gamecenter.common.retrofit.BiResponse
|
||||||
import com.gh.gamecenter.common.utils.PackageFlavorHelper
|
|
||||||
import com.gh.gamecenter.common.utils.debounceActionWithInterval
|
import com.gh.gamecenter.common.utils.debounceActionWithInterval
|
||||||
import com.gh.gamecenter.common.utils.toJson
|
import com.gh.gamecenter.common.utils.toJson
|
||||||
import com.gh.gamecenter.common.utils.toObject
|
import com.gh.gamecenter.common.utils.toObject
|
||||||
@ -73,7 +72,7 @@ object RegionSettingHelper {
|
|||||||
if (list is ArrayList) return list
|
if (list is ArrayList) return list
|
||||||
}
|
}
|
||||||
|
|
||||||
val listCopy: ArrayList<GameEntity> = ArrayList(list)
|
val listCopy: ArrayList<GameEntity> = if (list is ArrayList) list else ArrayList(list)
|
||||||
listCopy.removeAll { mFilterGameIdSet?.contains(it.id) ?: false }
|
listCopy.removeAll { mFilterGameIdSet?.contains(it.id) ?: false }
|
||||||
return listCopy
|
return listCopy
|
||||||
}
|
}
|
||||||
@ -124,16 +123,10 @@ object RegionSettingHelper {
|
|||||||
mIsInit = false
|
mIsInit = false
|
||||||
}
|
}
|
||||||
|
|
||||||
val fakeIp = if (PackageFlavorHelper.IS_TEST_FLAVOR) {
|
|
||||||
SPUtils.getString(Constants.SP_TEST_FLAVOR_IP)
|
|
||||||
} else {
|
|
||||||
""
|
|
||||||
}
|
|
||||||
|
|
||||||
// 使用默认的 Schdulers.io() 可能会触发 OOM
|
// 使用默认的 Schdulers.io() 可能会触发 OOM
|
||||||
RetrofitManager.getInstance()
|
RetrofitManager.getInstance()
|
||||||
.api
|
.api
|
||||||
.getRegionSetting(HaloApp.getInstance().channel, fakeIp)
|
.getRegionSetting(HaloApp.getInstance().channel)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.subscribe(object : BiResponse<RegionSetting>() {
|
.subscribe(object : BiResponse<RegionSetting>() {
|
||||||
override fun onSuccess(data: RegionSetting) {
|
override fun onSuccess(data: RegionSetting) {
|
||||||
|
|||||||
@ -1,45 +0,0 @@
|
|||||||
package com.gh.common.fragment
|
|
||||||
|
|
||||||
import androidx.fragment.app.FragmentManager
|
|
||||||
import java.lang.reflect.Field
|
|
||||||
|
|
||||||
fun FragmentManager.popBackStackAllowStateLoss() {
|
|
||||||
popBackStackAllowStateLoss(-1, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun FragmentManager.popBackStackAllowStateLoss(id: Int, flags: Int) {
|
|
||||||
if (!isStateSaved) {
|
|
||||||
popBackStack(id, flags)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun FragmentManager.popBackStackAllowStateLoss(name: String?, flags: Int) {
|
|
||||||
if (!isStateSaved) {
|
|
||||||
popBackStack(name, flags)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun FragmentManager.popBackStackImmediateAllowStateLoss() = popBackStackAllowStateLoss(-1, 0)
|
|
||||||
|
|
||||||
fun FragmentManager.popBackStackImmediateAllowStateLoss(id: Int, flags: Int) =
|
|
||||||
if (!isStateSaved) {
|
|
||||||
popBackStackImmediate(id, flags)
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
@Throws(NoSuchFieldException::class)
|
|
||||||
private fun getField(clazz: Class<*>, name: String): Field {
|
|
||||||
var cls: Class<*>? = clazz
|
|
||||||
while (cls != null) {
|
|
||||||
try {
|
|
||||||
val declaredField = cls.getDeclaredField(name)
|
|
||||||
declaredField.isAccessible = true
|
|
||||||
return declaredField
|
|
||||||
} catch (e: NoSuchFieldException) {
|
|
||||||
e.printStackTrace()
|
|
||||||
}
|
|
||||||
cls = cls.superclass
|
|
||||||
}
|
|
||||||
throw NoSuchFieldException()
|
|
||||||
}
|
|
||||||
@ -7,20 +7,19 @@ import androidx.room.TypeConverters
|
|||||||
import androidx.room.migration.Migration
|
import androidx.room.migration.Migration
|
||||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||||
import com.gh.gamecenter.entity.GamesCollectionEntity
|
import com.gh.gamecenter.entity.GamesCollectionEntity
|
||||||
import com.gh.gamecenter.entity.HistoryGameDetailEntity
|
|
||||||
import com.gh.gamecenter.entity.HistoryGameEntity
|
import com.gh.gamecenter.entity.HistoryGameEntity
|
||||||
import com.gh.gamecenter.entity.MyVideoEntity
|
import com.gh.gamecenter.entity.MyVideoEntity
|
||||||
|
import com.gh.gamecenter.feature.entity.NewsEntity
|
||||||
import com.gh.gamecenter.feature.entity.AnswerEntity
|
import com.gh.gamecenter.feature.entity.AnswerEntity
|
||||||
import com.gh.gamecenter.feature.entity.ArticleEntity
|
import com.gh.gamecenter.feature.entity.ArticleEntity
|
||||||
import com.gh.gamecenter.feature.entity.NewsEntity
|
|
||||||
import com.gh.gamecenter.feature.room.converter.*
|
import com.gh.gamecenter.feature.room.converter.*
|
||||||
import com.gh.gamecenter.room.converter.*
|
import com.gh.gamecenter.room.converter.*
|
||||||
import com.gh.gamecenter.room.dao.*
|
import com.gh.gamecenter.room.dao.*
|
||||||
import com.halo.assistant.HaloApp
|
import com.halo.assistant.HaloApp
|
||||||
|
|
||||||
@Database(
|
@Database(
|
||||||
entities = [AnswerEntity::class, ArticleEntity::class, NewsEntity::class, HistoryGameEntity::class, MyVideoEntity::class, GamesCollectionEntity::class, HistoryGameDetailEntity::class],
|
entities = [AnswerEntity::class, ArticleEntity::class, NewsEntity::class, HistoryGameEntity::class, MyVideoEntity::class, GamesCollectionEntity::class],
|
||||||
version = 15,
|
version = 14,
|
||||||
exportSchema = false
|
exportSchema = false
|
||||||
)
|
)
|
||||||
@TypeConverters(
|
@TypeConverters(
|
||||||
@ -54,7 +53,6 @@ abstract class HistoryDatabase : RoomDatabase() {
|
|||||||
abstract fun gameDao(): GameDao
|
abstract fun gameDao(): GameDao
|
||||||
abstract fun videoHistoryDao(): VideoHistoryDao
|
abstract fun videoHistoryDao(): VideoHistoryDao
|
||||||
abstract fun gamesCollectionDao(): GamesCollectionDao
|
abstract fun gamesCollectionDao(): GamesCollectionDao
|
||||||
abstract fun gameDetailDao(): GameDetailHistoryDao
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
@ -154,12 +152,6 @@ abstract class HistoryDatabase : RoomDatabase() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val MIGRATION_14_15: Migration = object : Migration(14, 15) {
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
|
||||||
database.execSQL("CREATE TABLE HistoryGameDetailEntity (id TEXT NOT NULL PRIMARY KEY, name TEXT DEFAULT '')")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val instance by lazy {
|
val instance by lazy {
|
||||||
Room.databaseBuilder(
|
Room.databaseBuilder(
|
||||||
HaloApp.getInstance().application,
|
HaloApp.getInstance().application,
|
||||||
@ -178,7 +170,6 @@ abstract class HistoryDatabase : RoomDatabase() {
|
|||||||
.addMigrations(MIGRATION_11_12)
|
.addMigrations(MIGRATION_11_12)
|
||||||
.addMigrations(MIGRATION_12_13)
|
.addMigrations(MIGRATION_12_13)
|
||||||
.addMigrations(MIGRATION_13_14)
|
.addMigrations(MIGRATION_13_14)
|
||||||
.addMigrations(MIGRATION_14_15)
|
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,20 +44,6 @@ object HistoryHelper {
|
|||||||
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.gameDao().addGame(historyGameEntity) } }
|
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.gameDao().addGame(historyGameEntity) } }
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun insertGameDetail(gameEntity: GameEntity) {
|
|
||||||
val historyGameDetailEntity = HistoryGameDetailEntity(gameEntity.id, gameEntity.name)
|
|
||||||
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.gameDetailDao().addGame(historyGameDetailEntity) } }
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun getHistoryGameDetailById(id: String): HistoryGameDetailEntity? =
|
|
||||||
try {
|
|
||||||
HistoryDatabase.instance.gameDetailDao().getHistoryGameDetailById(id)
|
|
||||||
} catch (e: Throwable) {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun convertGameUpdateEntityToHistoryGameEntity(updateEntity: GameUpdateEntity): HistoryGameEntity {
|
private fun convertGameUpdateEntityToHistoryGameEntity(updateEntity: GameUpdateEntity): HistoryGameEntity {
|
||||||
val historyGame = HistoryGameEntity()
|
val historyGame = HistoryGameEntity()
|
||||||
|
|
||||||
@ -156,15 +142,6 @@ object HistoryHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun deleteGameDetailEntity(gameId: String) {
|
|
||||||
runOnIoThread {
|
|
||||||
tryCatchInRelease {
|
|
||||||
HistoryDatabase.instance.gameDetailDao().deleteGame(HistoryGameDetailEntity(id = gameId))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun emptyDatabase() {
|
fun emptyDatabase() {
|
||||||
|
|||||||
@ -5,6 +5,6 @@ import com.gh.gamecenter.entity.BottomTab
|
|||||||
interface ISearchToolbarTab {
|
interface ISearchToolbarTab {
|
||||||
fun onScrollChanged(totalHeight: Int, offset: Int, isDarkModeChanged: Boolean)
|
fun onScrollChanged(totalHeight: Int, offset: Int, isDarkModeChanged: Boolean)
|
||||||
fun changeAppBarColor(color: Int, pageId: String)
|
fun changeAppBarColor(color: Int, pageId: String)
|
||||||
fun updateSearchStyle(searchStyle: BottomTab.SearchStyle)
|
fun setSearchStyle(searchStyle: BottomTab.SearchStyle)
|
||||||
fun getCurrentTabIndex(): Int?
|
fun getCurrentTabIndex(): Int?
|
||||||
}
|
}
|
||||||
@ -1,9 +1,12 @@
|
|||||||
package com.gh.common.iinterface
|
package com.gh.common.iinterface
|
||||||
|
|
||||||
import com.scwang.smartrefresh.layout.api.RefreshLayout
|
|
||||||
import com.scwang.smartrefresh.layout.constant.RefreshState
|
|
||||||
|
|
||||||
interface ISmartRefreshContent {
|
interface ISmartRefreshContent {
|
||||||
|
/**
|
||||||
|
* 启用/关闭 页面滑动
|
||||||
|
* @param isScrollEnabled 是否启用
|
||||||
|
*/
|
||||||
|
fun setScrollEnabled(isScrollEnabled: Boolean)
|
||||||
|
|
||||||
fun onRefresh()
|
fun onRefresh()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -11,6 +14,4 @@ interface ISmartRefreshContent {
|
|||||||
* @param isSwipeRefreshEnabled 是否启用
|
* @param isSwipeRefreshEnabled 是否启用
|
||||||
*/
|
*/
|
||||||
fun setSwipeRefreshEnabled(isSwipeRefreshEnabled: Boolean)
|
fun setSwipeRefreshEnabled(isSwipeRefreshEnabled: Boolean)
|
||||||
|
|
||||||
fun onStateChanged(refreshLayout: RefreshLayout, oldState: RefreshState, newState: RefreshState)
|
|
||||||
}
|
}
|
||||||
@ -1,29 +0,0 @@
|
|||||||
package com.gh.common.interceptor
|
|
||||||
|
|
||||||
import com.gh.gamecenter.common.constant.RouteConsts
|
|
||||||
import com.halo.assistant.HaloApp
|
|
||||||
import com.therouter.router.RouteItem
|
|
||||||
import com.therouter.router.interceptor.RouterReplaceInterceptor
|
|
||||||
import com.therouter.router.matchRouteMap
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主拦截器
|
|
||||||
*/
|
|
||||||
class MainInterceptor: RouterReplaceInterceptor() {
|
|
||||||
|
|
||||||
override fun replace(routeItem: RouteItem?): RouteItem? {
|
|
||||||
if (routeItem == null) return null
|
|
||||||
|
|
||||||
// 用户是否已经同意隐私政策
|
|
||||||
val isUserAcceptPrivacyPolicy = HaloApp.isUserAcceptPrivacyPolicy(HaloApp.getInstance())
|
|
||||||
|
|
||||||
// 如果用户已经同意隐私政策并且应用已经启动,直接返回 routeItem ,运行跳转
|
|
||||||
if (isUserAcceptPrivacyPolicy && HaloApp.getInstance().isAlreadyUpAndRunning) {
|
|
||||||
return routeItem
|
|
||||||
}
|
|
||||||
|
|
||||||
// 指向调整为 SplashScreenActivity
|
|
||||||
return matchRouteMap(RouteConsts.activity.splashActivity)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,44 +0,0 @@
|
|||||||
package com.gh.common.pop
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.core.view.updateLayoutParams
|
|
||||||
import com.gh.gamecenter.R
|
|
||||||
import com.gh.gamecenter.common.databinding.LayoutPopupContainerBinding
|
|
||||||
import com.gh.gamecenter.common.view.BugFixedPopupWindow
|
|
||||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
|
||||||
import com.gh.gamecenter.databinding.LayoutAddKaifuPopupItemBinding
|
|
||||||
|
|
||||||
class BatchManagementPop(
|
|
||||||
binding: LayoutPopupContainerBinding,
|
|
||||||
private val listener: OnBatchManagementListener
|
|
||||||
) :
|
|
||||||
CommonPopupWindow(binding) {
|
|
||||||
override val viewDataList: List<ViewData>
|
|
||||||
get() = listOf(
|
|
||||||
ViewData(R.string.enable_automatic_downloading_in_batches) {
|
|
||||||
listener.enableAutoDownload()
|
|
||||||
},
|
|
||||||
ViewData(R.string.batch_management) {
|
|
||||||
listener.batchManage()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
|
|
||||||
fun create(context: Context, listener: OnBatchManagementListener): BatchManagementPop {
|
|
||||||
val binding = LayoutPopupContainerBinding.inflate(LayoutInflater.from(context))
|
|
||||||
return BatchManagementPop(binding, listener).apply {
|
|
||||||
initView()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface OnBatchManagementListener {
|
|
||||||
|
|
||||||
fun enableAutoDownload()
|
|
||||||
|
|
||||||
fun batchManage()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,49 +0,0 @@
|
|||||||
package com.gh.common.pop
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import com.gh.gamecenter.R
|
|
||||||
import com.gh.gamecenter.common.databinding.LayoutPopupContainerBinding
|
|
||||||
import com.gh.gamecenter.feature.entity.GameEntity
|
|
||||||
|
|
||||||
class CancelReservePop(
|
|
||||||
private val game: GameEntity,
|
|
||||||
binding: LayoutPopupContainerBinding,
|
|
||||||
private val listener: OnCancelReserveListener
|
|
||||||
|
|
||||||
) : CommonPopupWindow(binding) {
|
|
||||||
|
|
||||||
override val viewDataList: List<ViewData>
|
|
||||||
get() {
|
|
||||||
val list = arrayListOf<ViewData>()
|
|
||||||
if (game.wifiAutoDownloadEnable) {
|
|
||||||
list.add(ViewData(if (game.wifiAutoDownload) R.string.cancel_auto_download_with_wifi else R.string.enable_automatic_downloading_with_wifi) {
|
|
||||||
listener.enableAutoDownload(!game.wifiAutoDownload)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
list.add(ViewData(R.string.cancel_reserve, listener::cancelReserve))
|
|
||||||
return list
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
|
|
||||||
fun create(
|
|
||||||
game: GameEntity,
|
|
||||||
context: Context,
|
|
||||||
listener: OnCancelReserveListener
|
|
||||||
): CancelReservePop {
|
|
||||||
val inflater = LayoutInflater.from(context)
|
|
||||||
val binding = LayoutPopupContainerBinding.inflate(inflater)
|
|
||||||
return CancelReservePop(game, binding, listener).apply {
|
|
||||||
initView()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface OnCancelReserveListener {
|
|
||||||
|
|
||||||
fun enableAutoDownload(isEnable: Boolean)
|
|
||||||
|
|
||||||
fun cancelReserve()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,47 +0,0 @@
|
|||||||
package com.gh.common.pop
|
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.core.view.updateLayoutParams
|
|
||||||
import com.gh.gamecenter.common.databinding.LayoutPopupContainerBinding
|
|
||||||
import com.gh.gamecenter.common.view.BugFixedPopupWindow
|
|
||||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
|
||||||
import com.gh.gamecenter.databinding.LayoutAddKaifuPopupBinding
|
|
||||||
import com.gh.gamecenter.databinding.LayoutAddKaifuPopupItemBinding
|
|
||||||
import com.gh.gamecenter.databinding.LayoutPopupOptionItemBinding
|
|
||||||
import com.gh.gamecenter.databinding.LayoutPopupReserveReminderOptionItemBinding
|
|
||||||
|
|
||||||
abstract class CommonPopupWindow(
|
|
||||||
private val binding: LayoutPopupContainerBinding,
|
|
||||||
) : BugFixedPopupWindow(binding.root, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT) {
|
|
||||||
|
|
||||||
private val inflater = LayoutInflater.from(binding.root.context)
|
|
||||||
|
|
||||||
abstract val viewDataList: List<ViewData>
|
|
||||||
|
|
||||||
fun initView() {
|
|
||||||
isFocusable = true
|
|
||||||
binding.container.updateLayoutParams<ViewGroup.LayoutParams> {
|
|
||||||
width = DisplayUtils.dip2px(128F)
|
|
||||||
}
|
|
||||||
viewDataList.forEach {
|
|
||||||
addItemView(it.textResId, it.click)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun addItemView(textResId: Int, click: () -> Unit) =
|
|
||||||
LayoutPopupReserveReminderOptionItemBinding.inflate(inflater, binding.container, false)
|
|
||||||
.also {
|
|
||||||
it.hintText.setText(textResId)
|
|
||||||
binding.container.addView(it.root)
|
|
||||||
it.root.setOnClickListener {
|
|
||||||
dismiss()
|
|
||||||
click()
|
|
||||||
}
|
|
||||||
}.root
|
|
||||||
|
|
||||||
data class ViewData(
|
|
||||||
val textResId: Int,
|
|
||||||
val click: () -> Unit
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@ -1,70 +0,0 @@
|
|||||||
package com.gh.common.pop
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.core.view.updateLayoutParams
|
|
||||||
import com.gh.common.dialog.OnReserveSuccessListener
|
|
||||||
import com.gh.gamecenter.R
|
|
||||||
import com.gh.gamecenter.common.databinding.LayoutPopupContainerBinding
|
|
||||||
import com.gh.gamecenter.common.view.BugFixedPopupWindow
|
|
||||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
|
||||||
import com.gh.gamecenter.databinding.LayoutAddKaifuPopupItemBinding
|
|
||||||
|
|
||||||
class EditBindPhoneInfoPop(
|
|
||||||
private val hasValidated: Boolean,
|
|
||||||
private val binding: LayoutPopupContainerBinding,
|
|
||||||
private val listener: OnReserveSuccessListener
|
|
||||||
) : BugFixedPopupWindow(binding.root, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT) {
|
|
||||||
|
|
||||||
private val context
|
|
||||||
get() = binding.root.context
|
|
||||||
|
|
||||||
init {
|
|
||||||
initView()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun initView() {
|
|
||||||
isOutsideTouchable = false
|
|
||||||
isFocusable = true
|
|
||||||
binding.container.updateLayoutParams<ViewGroup.LayoutParams> {
|
|
||||||
width = DisplayUtils.dip2px(128F)
|
|
||||||
}
|
|
||||||
val inflater = LayoutInflater.from(context)
|
|
||||||
fun createItemView(textResId: Int) =
|
|
||||||
LayoutAddKaifuPopupItemBinding.inflate(inflater, binding.container, false)
|
|
||||||
.also {
|
|
||||||
it.hintText.setText(textResId)
|
|
||||||
binding.container.addView(it.root)
|
|
||||||
}.root
|
|
||||||
|
|
||||||
val tvChangePhoneNumber = createItemView(R.string.change_phone_number)
|
|
||||||
if(!hasValidated){
|
|
||||||
val tvVerifyPhoneNumber = createItemView(R.string.verify_phone_number)
|
|
||||||
tvVerifyPhoneNumber.setOnClickListener {
|
|
||||||
dismiss()
|
|
||||||
listener.verifyPhoneNumber()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val tvTurnOffSmsReminder = createItemView(R.string.turn_off_sms_reminders)
|
|
||||||
|
|
||||||
tvChangePhoneNumber.setOnClickListener {
|
|
||||||
dismiss()
|
|
||||||
listener.changePhoneNumber()
|
|
||||||
}
|
|
||||||
|
|
||||||
tvTurnOffSmsReminder.setOnClickListener {
|
|
||||||
dismiss()
|
|
||||||
listener.updateSmsReminder(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
|
|
||||||
fun create(context: Context, hasValidated: Boolean, listener: OnReserveSuccessListener): EditBindPhoneInfoPop {
|
|
||||||
val binding = LayoutPopupContainerBinding.inflate(LayoutInflater.from(context))
|
|
||||||
return EditBindPhoneInfoPop(hasValidated, binding, listener)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,26 +0,0 @@
|
|||||||
package com.gh.common.pop
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import com.gh.common.dialog.OnReserveSuccessListener
|
|
||||||
import com.gh.gamecenter.R
|
|
||||||
import com.gh.gamecenter.common.databinding.LayoutPopupContainerBinding
|
|
||||||
|
|
||||||
class EditBindWechatPop(
|
|
||||||
binding: LayoutPopupContainerBinding,
|
|
||||||
private val listener: OnReserveSuccessListener
|
|
||||||
) : CommonPopupWindow(binding) {
|
|
||||||
|
|
||||||
override val viewDataList: List<ViewData>
|
|
||||||
get() = listOf(
|
|
||||||
ViewData(R.string.change_the_wechat_binding, listener::changeWechatBinding)
|
|
||||||
)
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
|
|
||||||
fun create(context: Context, listener: OnReserveSuccessListener): EditBindWechatPop {
|
|
||||||
val inflater = LayoutInflater.from(context)
|
|
||||||
return EditBindWechatPop(LayoutPopupContainerBinding.inflate(inflater), listener).apply { initView() }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,69 +0,0 @@
|
|||||||
package com.gh.common.pop
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.graphics.Color
|
|
||||||
import android.text.SpannableString
|
|
||||||
import android.text.TextPaint
|
|
||||||
import android.text.method.LinkMovementMethod
|
|
||||||
import android.text.style.ClickableSpan
|
|
||||||
import android.text.style.ForegroundColorSpan
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.widget.LinearLayout
|
|
||||||
import androidx.core.text.set
|
|
||||||
import com.gh.common.dialog.OnReserveSuccessListener
|
|
||||||
import com.gh.gamecenter.R
|
|
||||||
import com.gh.gamecenter.common.utils.toColor
|
|
||||||
import com.gh.gamecenter.common.utils.toResString
|
|
||||||
import com.gh.gamecenter.common.view.BugFixedPopupWindow
|
|
||||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
|
||||||
import com.gh.gamecenter.databinding.PopRealNameTipsBinding
|
|
||||||
import com.halo.assistant.fragment.reserve.OnReserveReminderListener
|
|
||||||
|
|
||||||
class RealNameTipsPop(
|
|
||||||
private val binding: PopRealNameTipsBinding,
|
|
||||||
private val listener: OnReserveReminderListener
|
|
||||||
) :
|
|
||||||
BugFixedPopupWindow(binding.root, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT) {
|
|
||||||
|
|
||||||
private val context: Context
|
|
||||||
get() = binding.root.context
|
|
||||||
|
|
||||||
init {
|
|
||||||
initView()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun initView() {
|
|
||||||
|
|
||||||
val text = R.string.reserve_real_name_description.toResString()
|
|
||||||
val spannableString = SpannableString(text)
|
|
||||||
val clickSpan = object : ClickableSpan() {
|
|
||||||
override fun updateDrawState(ds: TextPaint) {
|
|
||||||
ds.bgColor = Color.TRANSPARENT
|
|
||||||
ds.setColor(com.gh.gamecenter.common.R.color.text_theme.toColor(context))
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onClick(widget: View) {
|
|
||||||
dismiss()
|
|
||||||
listener.realName()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
spannableString.set(start = text.length - 6, end = text.length, span = clickSpan)
|
|
||||||
binding.tvRealNameDescription.text = spannableString
|
|
||||||
|
|
||||||
binding.tvRealNameDescription.movementMethod = LinkMovementMethod.getInstance()
|
|
||||||
binding.tvRealNameDescription.setHighlightColor(Color.TRANSPARENT)
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun create(context: Context, listener: OnReserveReminderListener): RealNameTipsPop {
|
|
||||||
val pop = RealNameTipsPop(PopRealNameTipsBinding.inflate(LayoutInflater.from(context)), listener)
|
|
||||||
pop.isFocusable = true
|
|
||||||
pop.isOutsideTouchable = false
|
|
||||||
return pop
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,95 +0,0 @@
|
|||||||
package com.gh.common.pop
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.view.Gravity
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.widget.CompoundButton
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import com.gh.gamecenter.R
|
|
||||||
import com.gh.gamecenter.common.utils.dip2px
|
|
||||||
import com.gh.gamecenter.common.view.BugFixedPopupWindow
|
|
||||||
import com.gh.gamecenter.databinding.PopReserveAllSelectBinding
|
|
||||||
import com.gh.gamecenter.mygame.MyReservationFragment
|
|
||||||
|
|
||||||
class ReserveAllSelectPop(
|
|
||||||
val binding: PopReserveAllSelectBinding,
|
|
||||||
private val listener: OnReserveAllSelectListener
|
|
||||||
) : BugFixedPopupWindow(binding.root, ViewGroup.LayoutParams.MATCH_PARENT, 56F.dip2px()) {
|
|
||||||
|
|
||||||
private var pageStatus: MyReservationFragment.ReservePageState =
|
|
||||||
MyReservationFragment.ReservePageState.EnableAutoDownload
|
|
||||||
|
|
||||||
private val onCheckedChangeListener = { _: CompoundButton, isChecked: Boolean ->
|
|
||||||
val count = listener.selectAll(isChecked)
|
|
||||||
updateSelectedCount(count)
|
|
||||||
}
|
|
||||||
|
|
||||||
init {
|
|
||||||
isOutsideTouchable = false
|
|
||||||
binding.cbAll.setOnCheckedChangeListener(onCheckedChangeListener)
|
|
||||||
binding.tvSubmit.setOnClickListener {
|
|
||||||
listener.submit()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun show(state: MyReservationFragment.ReservePageState, context: Context) {
|
|
||||||
enableSubmit(false)
|
|
||||||
binding.tvSubmit.setText(
|
|
||||||
if (state == MyReservationFragment.ReservePageState.EnableAutoDownload) {
|
|
||||||
R.string.enable_automatic_downloading_with_wifi
|
|
||||||
} else {
|
|
||||||
R.string.cancel_reserve
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
// 清空上一次的状态
|
|
||||||
pageStatus = state
|
|
||||||
updateSelectedCount(0)
|
|
||||||
|
|
||||||
if (!isShowing) {
|
|
||||||
showAtLocation((context as AppCompatActivity).window.decorView, Gravity.BOTTOM, 0, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
fun updateSelectedCount(count: Int) {
|
|
||||||
if (count == 0) {
|
|
||||||
enableSubmit(false)
|
|
||||||
|
|
||||||
binding.cbAll.setOnCheckedChangeListener(null)
|
|
||||||
binding.cbAll.isChecked = false
|
|
||||||
binding.cbAll.setOnCheckedChangeListener(onCheckedChangeListener)
|
|
||||||
} else {
|
|
||||||
enableSubmit(true)
|
|
||||||
binding.tvNumber.text = binding.root.context.getString(R.string.count_with_parentheses, "$count")
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun enableSubmit(isEnable: Boolean) {
|
|
||||||
binding.tvSubmit.isEnabled = isEnable
|
|
||||||
if (isEnable) {
|
|
||||||
binding.tvSubmit.alpha = 1F
|
|
||||||
} else {
|
|
||||||
binding.tvSubmit.alpha = 0.4F
|
|
||||||
binding.tvNumber.setText(null)
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
|
|
||||||
fun create(context: Context, listener: OnReserveAllSelectListener): ReserveAllSelectPop {
|
|
||||||
val inflater = LayoutInflater.from(context)
|
|
||||||
return ReserveAllSelectPop(PopReserveAllSelectBinding.inflate(inflater), listener)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface OnReserveAllSelectListener {
|
|
||||||
|
|
||||||
fun selectAll(isChecked: Boolean): Int
|
|
||||||
|
|
||||||
fun submit()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,12 +1,13 @@
|
|||||||
package com.gh.common.prioritychain
|
package com.gh.common.prioritychain
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.os.Handler
|
|
||||||
import android.view.Gravity
|
import android.view.Gravity
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import com.gh.common.util.NewFlatLogUtils
|
import com.gh.common.util.NewFlatLogUtils
|
||||||
import com.gh.gamecenter.GameDetailActivity
|
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.constant.Constants
|
||||||
import com.gh.gamecenter.common.view.BugFixedPopupWindow
|
import com.gh.gamecenter.common.view.BugFixedPopupWindow
|
||||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||||
@ -18,7 +19,7 @@ import com.gh.gamecenter.wrapper.MainWrapperViewModel
|
|||||||
class AccelerateNotificationHandler(priority: Int) : PriorityChainHandler(priority) {
|
class AccelerateNotificationHandler(priority: Int) : PriorityChainHandler(priority) {
|
||||||
|
|
||||||
private var mActivity: Activity? = null
|
private var mActivity: Activity? = null
|
||||||
private var mHandler: Handler? = null
|
private var mBaseHandler: BaseFragment.BaseHandler? = null
|
||||||
private var mGameList: List<GameEntity>? = null
|
private var mGameList: List<GameEntity>? = null
|
||||||
private var mViewModel: MainWrapperViewModel? = null
|
private var mViewModel: MainWrapperViewModel? = null
|
||||||
|
|
||||||
@ -27,13 +28,13 @@ class AccelerateNotificationHandler(priority: Int) : PriorityChainHandler(priori
|
|||||||
*/
|
*/
|
||||||
fun doPreProcess(
|
fun doPreProcess(
|
||||||
activity: Activity,
|
activity: Activity,
|
||||||
handler: Handler,
|
baseHandler: BaseFragment.BaseHandler,
|
||||||
gameEntityList: List<GameEntity>?,
|
gameEntityList: List<GameEntity>?,
|
||||||
viewModel: MainWrapperViewModel
|
viewModel: MainWrapperViewModel
|
||||||
) {
|
) {
|
||||||
mActivity = activity
|
mActivity = activity
|
||||||
mGameList = gameEntityList
|
mGameList = gameEntityList
|
||||||
mHandler = handler
|
mBaseHandler = baseHandler
|
||||||
mViewModel = viewModel
|
mViewModel = viewModel
|
||||||
|
|
||||||
if (getStatus() == STATUS_PENDING) {
|
if (getStatus() == STATUS_PENDING) {
|
||||||
@ -58,7 +59,7 @@ class AccelerateNotificationHandler(priority: Int) : PriorityChainHandler(priori
|
|||||||
val accelerateSet =
|
val accelerateSet =
|
||||||
HashSet(SPUtils.getStringSet(Constants.SP_ACCELERATE_NOTIFICATION_POP_UP_SET))
|
HashSet(SPUtils.getStringSet(Constants.SP_ACCELERATE_NOTIFICATION_POP_UP_SET))
|
||||||
if (!mGameList.isNullOrEmpty() && !accelerateSet.contains(mGameList!![0].messageId)) {
|
if (!mGameList.isNullOrEmpty() && !accelerateSet.contains(mGameList!![0].messageId)) {
|
||||||
showAccelerateNotificationPopupWindow(mActivity!!, mViewModel, mHandler, mGameList!![0]) {
|
showAccelerateNotificationPopupWindow(mActivity!!, mViewModel, mBaseHandler, mGameList!![0]) {
|
||||||
processNext()
|
processNext()
|
||||||
}
|
}
|
||||||
accelerateSet.add(mGameList!![0].messageId)
|
accelerateSet.add(mGameList!![0].messageId)
|
||||||
@ -81,7 +82,7 @@ class AccelerateNotificationHandler(priority: Int) : PriorityChainHandler(priori
|
|||||||
fun showAccelerateNotificationPopupWindow(
|
fun showAccelerateNotificationPopupWindow(
|
||||||
activity: Activity,
|
activity: Activity,
|
||||||
viewModel: MainWrapperViewModel?,
|
viewModel: MainWrapperViewModel?,
|
||||||
handler: Handler?,
|
baseHandler: BaseFragment.BaseHandler?,
|
||||||
gameEntity: GameEntity?,
|
gameEntity: GameEntity?,
|
||||||
dismissCallback: (() -> Unit)?
|
dismissCallback: (() -> Unit)?
|
||||||
) {
|
) {
|
||||||
@ -103,6 +104,7 @@ class AccelerateNotificationHandler(priority: Int) : PriorityChainHandler(priori
|
|||||||
context = activity,
|
context = activity,
|
||||||
gameId = gameEntity.id,
|
gameId = gameEntity.id,
|
||||||
entrance = "首页插件上架弹窗",
|
entrance = "首页插件上架弹窗",
|
||||||
|
defaultTab = -1,
|
||||||
isSkipGameComment = false,
|
isSkipGameComment = false,
|
||||||
scrollToLibao = false,
|
scrollToLibao = false,
|
||||||
openVideoStreaming = false,
|
openVideoStreaming = false,
|
||||||
@ -119,7 +121,7 @@ class AccelerateNotificationHandler(priority: Int) : PriorityChainHandler(priori
|
|||||||
isTouchable = true
|
isTouchable = true
|
||||||
isFocusable = true
|
isFocusable = true
|
||||||
isOutsideTouchable = true
|
isOutsideTouchable = true
|
||||||
animationStyle = com.gh.gamecenter.common.R.style.popup_window_ease_in_and_out_anim_style
|
animationStyle = R.style.popup_window_ease_in_and_out_anim_style
|
||||||
showAtLocation(
|
showAtLocation(
|
||||||
activity.window.decorView,
|
activity.window.decorView,
|
||||||
Gravity.TOP,
|
Gravity.TOP,
|
||||||
@ -129,7 +131,7 @@ class AccelerateNotificationHandler(priority: Int) : PriorityChainHandler(priori
|
|||||||
setOnDismissListener {
|
setOnDismissListener {
|
||||||
dismissCallback?.invoke()
|
dismissCallback?.invoke()
|
||||||
}
|
}
|
||||||
handler?.postDelayed({ dismiss() }, 5000)
|
baseHandler?.postDelayed({ dismiss() }, 5000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,168 +0,0 @@
|
|||||||
package com.gh.common.prioritychain
|
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import android.os.Handler
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.widget.PopupWindow
|
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
import androidx.core.view.updateLayoutParams
|
|
||||||
import com.gh.gamecenter.common.constant.Constants
|
|
||||||
import com.gh.gamecenter.common.utils.dip2px
|
|
||||||
import com.gh.gamecenter.common.view.BugFixedPopupWindow
|
|
||||||
import com.gh.gamecenter.core.utils.SPUtils
|
|
||||||
import com.gh.gamecenter.databinding.PopupBottomTabGuideBinding
|
|
||||||
import com.gh.gamecenter.entity.BottomTab
|
|
||||||
|
|
||||||
class BottomTabGuideHandler(priority: Int): PriorityChainHandler(priority) {
|
|
||||||
private var mActivity: Activity? = null
|
|
||||||
private var mHandler: Handler? = null
|
|
||||||
private var mViewPager: ViewGroup? = null
|
|
||||||
private var mGuide: BottomTab.Guide? = null
|
|
||||||
private var mTriangleTransX = 0F
|
|
||||||
private var mGuideTransX = 0F
|
|
||||||
private var mRestWidth = 0F
|
|
||||||
private var mIsCenterPosition = false
|
|
||||||
private var mIsRightPosition = false
|
|
||||||
|
|
||||||
private var mPopupWindow: PopupWindow? = null
|
|
||||||
|
|
||||||
fun doPreProcess(
|
|
||||||
shouldShow: Boolean,
|
|
||||||
activity: Activity? = null,
|
|
||||||
handler: Handler? = null,
|
|
||||||
viewPager: ViewGroup? = null,
|
|
||||||
guide: BottomTab.Guide? = null,
|
|
||||||
triangleTransX: Float = 0F,
|
|
||||||
guideTransX: Float = 0F,
|
|
||||||
restWidth: Float = 0F,
|
|
||||||
isCenterPosition: Boolean = false,
|
|
||||||
isRightPosition: Boolean = false
|
|
||||||
) {
|
|
||||||
mActivity = activity
|
|
||||||
mHandler = handler
|
|
||||||
mViewPager = viewPager
|
|
||||||
mGuide = guide
|
|
||||||
mTriangleTransX = triangleTransX
|
|
||||||
mGuideTransX = guideTransX
|
|
||||||
mRestWidth = restWidth
|
|
||||||
mIsCenterPosition = isCenterPosition
|
|
||||||
mIsRightPosition = isRightPosition
|
|
||||||
|
|
||||||
if (getStatus() == STATUS_PENDING) {
|
|
||||||
if (shouldShow) {
|
|
||||||
updateStatus(STATUS_VALID)
|
|
||||||
process()
|
|
||||||
} else {
|
|
||||||
processNext()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (shouldShow) {
|
|
||||||
updateStatus(STATUS_VALID)
|
|
||||||
} else {
|
|
||||||
updateStatus(STATUS_INVALID)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onProcess(): Boolean {
|
|
||||||
when (getStatus()) {
|
|
||||||
STATUS_VALID -> {
|
|
||||||
if (mGuide == null || mActivity == null || mViewPager == null) {
|
|
||||||
processNext()
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
val guideSet = HashSet(SPUtils.getStringSet(Constants.SP_BOTTOM_TAB_GUIDE_SET))
|
|
||||||
if (!guideSet.contains(mGuide?.bottomTabId + mGuide?.text)) {
|
|
||||||
mPopupWindow = showBottomTabPopupWindow(
|
|
||||||
mActivity!!,
|
|
||||||
mHandler,
|
|
||||||
mViewPager!!,
|
|
||||||
mGuide!!,
|
|
||||||
mTriangleTransX,
|
|
||||||
mGuideTransX,
|
|
||||||
mRestWidth,
|
|
||||||
mIsCenterPosition,
|
|
||||||
mIsRightPosition
|
|
||||||
) {
|
|
||||||
processNext()
|
|
||||||
}
|
|
||||||
guideSet.add(mGuide?.bottomTabId + mGuide?.text)
|
|
||||||
SPUtils.setStringSet(Constants.SP_BOTTOM_TAB_GUIDE_SET, guideSet)
|
|
||||||
return true
|
|
||||||
} else {
|
|
||||||
processNext()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
STATUS_INVALID -> {
|
|
||||||
processNext()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
fun dismiss() {
|
|
||||||
if (mPopupWindow?.isShowing == true) {
|
|
||||||
mPopupWindow?.dismiss()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
const val KEY_BOTTOM_TAB_GUIDE_AUTO_DISMISS = 100
|
|
||||||
private const val AUTO_DISMISS_DELAY_TIME = 5000L
|
|
||||||
|
|
||||||
fun showBottomTabPopupWindow(
|
|
||||||
activity: Activity,
|
|
||||||
handler: Handler?,
|
|
||||||
viewPager: ViewGroup,
|
|
||||||
guide: BottomTab.Guide,
|
|
||||||
triangleTransX: Float,
|
|
||||||
guideTransX: Float,
|
|
||||||
restWidth: Float,
|
|
||||||
isCenterPosition: Boolean,
|
|
||||||
isRightPosition: Boolean,
|
|
||||||
dismissCallback: (() -> Unit)?
|
|
||||||
): PopupWindow {
|
|
||||||
val binding = PopupBottomTabGuideBinding.inflate(LayoutInflater.from(activity))
|
|
||||||
binding.guideTv.text = guide.text
|
|
||||||
binding.guideTriangleIv.translationX = triangleTransX
|
|
||||||
binding.guideTv.translationX = guideTransX
|
|
||||||
binding.guideIconIv.translationX = guideTransX
|
|
||||||
binding.guideTv.updateLayoutParams<ConstraintLayout.LayoutParams> {
|
|
||||||
horizontalBias = if (isCenterPosition) 0.5F else if (isRightPosition) 1F else 0F
|
|
||||||
}
|
|
||||||
|
|
||||||
val popupWindow = BugFixedPopupWindow(
|
|
||||||
binding.root,
|
|
||||||
ConstraintLayout.LayoutParams.MATCH_PARENT,
|
|
||||||
ConstraintLayout.LayoutParams.WRAP_CONTENT
|
|
||||||
)
|
|
||||||
popupWindow.contentView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED)
|
|
||||||
val measureWidth = popupWindow.contentView.measuredWidth
|
|
||||||
val measureHeight = popupWindow.contentView.measuredHeight
|
|
||||||
if (measureWidth > restWidth) {
|
|
||||||
binding.guideTv.translationX = 0F
|
|
||||||
binding.guideIconIv.translationX = 0F
|
|
||||||
}
|
|
||||||
|
|
||||||
return popupWindow.apply {
|
|
||||||
isFocusable = false
|
|
||||||
isOutsideTouchable = false
|
|
||||||
animationStyle = com.gh.gamecenter.common.R.style.popup_window_ease_in_and_out_anim_style
|
|
||||||
setOnDismissListener {
|
|
||||||
dismissCallback?.invoke()
|
|
||||||
}
|
|
||||||
handler?.post {
|
|
||||||
if (!activity.isFinishing) {
|
|
||||||
showAsDropDown(viewPager, 0, 8F.dip2px() - measureHeight)
|
|
||||||
}
|
|
||||||
handler.sendEmptyMessageDelayed(KEY_BOTTOM_TAB_GUIDE_AUTO_DISMISS, AUTO_DISMISS_DELAY_TIME)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,52 +0,0 @@
|
|||||||
package com.gh.common.prioritychain
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.widget.FrameLayout
|
|
||||||
import com.airbnb.lottie.LottieAnimationView
|
|
||||||
import com.gh.gamecenter.common.constant.Constants
|
|
||||||
import com.gh.gamecenter.core.utils.SPUtils
|
|
||||||
import com.gh.gamecenter.databinding.LayoutCommunityHomeVideoGuideBinding
|
|
||||||
|
|
||||||
class CommunityHomeGuideHandler(
|
|
||||||
priority: Int,
|
|
||||||
private val context: Context,
|
|
||||||
private val decorView: FrameLayout?,
|
|
||||||
private val videoLottie: LottieAnimationView?
|
|
||||||
) : PriorityChainHandler(priority) {
|
|
||||||
|
|
||||||
init {
|
|
||||||
updateStatus(STATUS_VALID)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onProcess(): Boolean {
|
|
||||||
return if (SPUtils.getBoolean(Constants.SP_SHOW_COMMUNITY_HOME_VIDEO_GUIDE, true)) {
|
|
||||||
showHomeVideoGuide(context, decorView, videoLottie)
|
|
||||||
processNext()
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
processNext()
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
fun showHomeVideoGuide(context: Context, decorView: FrameLayout?, videoLottie: LottieAnimationView?) {
|
|
||||||
val guideLayoutBinding = LayoutCommunityHomeVideoGuideBinding.inflate(
|
|
||||||
LayoutInflater.from(context),
|
|
||||||
decorView,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
guideLayoutBinding.root.setOnClickListener { view ->
|
|
||||||
decorView?.removeView(view)
|
|
||||||
SPUtils.setBoolean(Constants.SP_SHOW_COMMUNITY_HOME_VIDEO_GUIDE, false)
|
|
||||||
|
|
||||||
videoLottie?.playAnimation()
|
|
||||||
SPUtils.setLong(
|
|
||||||
Constants.SP_COMMUNITY_HOME_VIDEO_LOTTIE_LAST_PLAY_TIME,
|
|
||||||
System.currentTimeMillis()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -2,7 +2,7 @@ package com.gh.common.prioritychain
|
|||||||
|
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import com.gh.gamecenter.feature.entity.FloatingWindowEntity
|
import com.gh.gamecenter.floatingwindow.FloatingWindowEntity
|
||||||
import com.gh.gamecenter.livedata.Event
|
import com.gh.gamecenter.livedata.Event
|
||||||
|
|
||||||
class CustomFloatingWindowHandler(priority: Int) : PriorityChainHandler(priority) {
|
class CustomFloatingWindowHandler(priority: Int) : PriorityChainHandler(priority) {
|
||||||
@ -59,8 +59,8 @@ class CustomFloatingWindowHandler(priority: Int) : PriorityChainHandler(priority
|
|||||||
override fun onProcess(): Boolean {
|
override fun onProcess(): Boolean {
|
||||||
when (getStatus()) {
|
when (getStatus()) {
|
||||||
STATUS_VALID -> {
|
STATUS_VALID -> {
|
||||||
_showFloatingAction.postValue(Event(data))
|
_showFloatingAction.value = Event(data)
|
||||||
return true
|
processNext()
|
||||||
// floatingWindowProvider.showFloatingWindowOnly(
|
// floatingWindowProvider.showFloatingWindowOnly(
|
||||||
// mFragment!!,
|
// mFragment!!,
|
||||||
// mRecyclerView!!,
|
// mRecyclerView!!,
|
||||||
@ -79,9 +79,4 @@ class CustomFloatingWindowHandler(priority: Int) : PriorityChainHandler(priority
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
fun dismiss() {
|
|
||||||
if (getStatus() == STATUS_HANDLING || getStatus() == STATUS_VALID) {
|
|
||||||
processNext()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -5,35 +5,21 @@ import android.app.Activity
|
|||||||
import android.app.Application.ActivityLifecycleCallbacks
|
import android.app.Application.ActivityLifecycleCallbacks
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.preference.PreferenceManager
|
import android.preference.PreferenceManager
|
||||||
import android.text.TextUtils
|
|
||||||
import androidx.annotation.WorkerThread
|
|
||||||
import androidx.fragment.app.FragmentActivity
|
import androidx.fragment.app.FragmentActivity
|
||||||
import com.gh.common.iinterface.ISuperiorChain
|
import com.gh.common.iinterface.ISuperiorChain
|
||||||
import com.gh.common.util.CheckLoginUtils
|
import com.gh.common.util.CheckLoginUtils
|
||||||
import com.gh.common.util.PackageUtils
|
import com.gh.common.util.PackageUtils
|
||||||
import com.gh.download.DownloadManager
|
|
||||||
import com.gh.gamecenter.SplashAdActivity
|
|
||||||
import com.gh.gamecenter.SplashScreenActivity
|
import com.gh.gamecenter.SplashScreenActivity
|
||||||
import com.gh.gamecenter.common.constant.Constants
|
import com.gh.gamecenter.common.constant.Constants
|
||||||
import com.gh.gamecenter.common.exposure.ExposureSource
|
import com.gh.gamecenter.common.entity.SimpleGameEntity
|
||||||
import com.gh.gamecenter.common.retrofit.BiResponse
|
import com.gh.gamecenter.common.retrofit.BiResponse
|
||||||
import com.gh.gamecenter.common.utils.*
|
|
||||||
import com.gh.gamecenter.core.AppExecutor
|
|
||||||
import com.gh.gamecenter.core.runOnIoThread
|
|
||||||
import com.gh.gamecenter.core.utils.SPUtils
|
import com.gh.gamecenter.core.utils.SPUtils
|
||||||
import com.gh.gamecenter.core.utils.SPUtils.getBoolean
|
|
||||||
import com.gh.gamecenter.core.utils.ToastUtils
|
|
||||||
import com.gh.gamecenter.entity.DialogEntity
|
import com.gh.gamecenter.entity.DialogEntity
|
||||||
import com.gh.gamecenter.feature.entity.GameEntity
|
|
||||||
import com.gh.gamecenter.feature.entity.ReserveOnlineEntity
|
|
||||||
import com.gh.gamecenter.feature.entity.WelcomeDialogEntity
|
import com.gh.gamecenter.feature.entity.WelcomeDialogEntity
|
||||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
|
||||||
import com.gh.gamecenter.hud.PendingInstallHUDHandler
|
|
||||||
import com.gh.gamecenter.hud.ResumeDownloadHudHandler
|
|
||||||
import com.gh.gamecenter.login.entity.UserInfoEntity
|
|
||||||
import com.gh.gamecenter.login.user.UserManager
|
import com.gh.gamecenter.login.user.UserManager
|
||||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||||
import com.halo.assistant.HaloApp
|
import com.halo.assistant.HaloApp
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,7 +31,6 @@ import io.reactivex.schedulers.Schedulers
|
|||||||
object GlobalPriorityChainHelper : ISuperiorChain {
|
object GlobalPriorityChainHelper : ISuperiorChain {
|
||||||
|
|
||||||
private val api = RetrofitManager.getInstance().api
|
private val api = RetrofitManager.getInstance().api
|
||||||
private val newApi = RetrofitManager.getInstance().newApi
|
|
||||||
private var inferiorChain: PriorityChain? = null
|
private var inferiorChain: PriorityChain? = null
|
||||||
private val mainChain: PriorityChain by lazy { PriorityChain { inferiorChain?.start() } }
|
private val mainChain: PriorityChain by lazy { PriorityChain { inferiorChain?.start() } }
|
||||||
|
|
||||||
@ -57,43 +42,30 @@ object GlobalPriorityChainHelper : ISuperiorChain {
|
|||||||
return activity is FragmentActivity
|
return activity is FragmentActivity
|
||||||
&& !activity.isFinishing
|
&& !activity.isFinishing
|
||||||
&& activity !is SplashScreenActivity
|
&& activity !is SplashScreenActivity
|
||||||
&& activity !is SplashAdActivity
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 预启动所有的优先级弹窗管理链
|
* 预启动所有的优先级弹窗管理链
|
||||||
*/
|
*/
|
||||||
fun preStart(withSpecialDelay: Boolean) {
|
fun preStart() {
|
||||||
val launchRedirectHandler = LaunchRedirectHandler(-102)
|
val launchRedirectHandler = LaunchRedirectHandler(-101)
|
||||||
val membershipExpiredHandler = MembershipExpiredHandler(-101)
|
|
||||||
val updateDialogHandler = UpdateDialogHandler(-100)
|
val updateDialogHandler = UpdateDialogHandler(-100)
|
||||||
val privacyPolicyDialogHandler = PrivacyPolicyDialogHandler(-99)
|
val privacyPolicyDialogHandler = PrivacyPolicyDialogHandler(-99)
|
||||||
val notificationPermissionDialogHandler = NotificationPermissionDialogHandler(0)
|
val notificationPermissionDialogHandler = NotificationPermissionDialogHandler(0)
|
||||||
val reserveDialogHandler = ReserveDialogHandler(1)
|
val reserveDialogHandler = ReserveDialogHandler(1)
|
||||||
val welcomeDialogHandler = WelcomeDialogHandler(2)
|
val welcomeDialogHandler = WelcomeDialogHandler(2)
|
||||||
val pendingInstallHandler = PendingInstallHUDHandler(3)
|
|
||||||
val resumeDownloadHandler = ResumeDownloadHudHandler(4)
|
|
||||||
|
|
||||||
mainChain.addHandler(launchRedirectHandler)
|
mainChain.addHandler(launchRedirectHandler)
|
||||||
mainChain.addHandler(membershipExpiredHandler)
|
|
||||||
mainChain.addHandler(updateDialogHandler)
|
mainChain.addHandler(updateDialogHandler)
|
||||||
mainChain.addHandler(privacyPolicyDialogHandler)
|
mainChain.addHandler(privacyPolicyDialogHandler)
|
||||||
mainChain.addHandler(welcomeDialogHandler)
|
mainChain.addHandler(welcomeDialogHandler)
|
||||||
mainChain.addHandler(reserveDialogHandler)
|
mainChain.addHandler(reserveDialogHandler)
|
||||||
mainChain.addHandler(notificationPermissionDialogHandler)
|
mainChain.addHandler(notificationPermissionDialogHandler)
|
||||||
mainChain.addHandler(pendingInstallHandler)
|
|
||||||
mainChain.addHandler(resumeDownloadHandler)
|
|
||||||
|
|
||||||
launchRedirectHandler.doPreProcess()
|
launchRedirectHandler.doPreProcess()
|
||||||
membershipExpiredHandler.doPreProcess()
|
|
||||||
updateDialogHandler.doPreProcess()
|
updateDialogHandler.doPreProcess()
|
||||||
|
requestOpeningDialogData(welcomeDialogHandler, privacyPolicyDialogHandler)
|
||||||
// 首次启动延迟 300ms,保证请求首次启动时已经获取到了 GID 、 OAID 等标记
|
requestReserveDialogData(reserveDialogHandler)
|
||||||
val requestDelay = if (withSpecialDelay) 300L else 0L
|
|
||||||
AppExecutor.uiExecutor.executeWithDelay({
|
|
||||||
requestOpeningDialogData(welcomeDialogHandler, privacyPolicyDialogHandler)
|
|
||||||
requestReserveDialogData(reserveDialogHandler)
|
|
||||||
}, requestDelay)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -151,17 +123,6 @@ object GlobalPriorityChainHelper : ISuperiorChain {
|
|||||||
mainChain.resume()
|
mainChain.resume()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加新的 handler 到优先级弹窗管理链 (插队!)
|
|
||||||
*/
|
|
||||||
fun queueNewHandler(handler: PriorityChainHandler) {
|
|
||||||
if (mainChain.isHandlerQueueEmpty()) {
|
|
||||||
observeLifecycle()
|
|
||||||
}
|
|
||||||
|
|
||||||
mainChain.addHandler(handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 请求首页启动弹窗相关的数据并执行相关 handler 的 preProcess
|
* 请求首页启动弹窗相关的数据并执行相关 handler 的 preProcess
|
||||||
*/
|
*/
|
||||||
@ -237,7 +198,7 @@ object GlobalPriorityChainHelper : ISuperiorChain {
|
|||||||
/**
|
/**
|
||||||
* 请求预约弹窗相关的数据
|
* 请求预约弹窗相关的数据
|
||||||
*/
|
*/
|
||||||
|
@SuppressLint("CheckResult")
|
||||||
private fun requestReserveDialogData(reserveDialogHandler: ReserveDialogHandler) {
|
private fun requestReserveDialogData(reserveDialogHandler: ReserveDialogHandler) {
|
||||||
// debugOnly {
|
// debugOnly {
|
||||||
// reserveDialogHandler.doPreProcess(arrayListOf(SimpleGameEntity(
|
// reserveDialogHandler.doPreProcess(arrayListOf(SimpleGameEntity(
|
||||||
@ -250,145 +211,23 @@ object GlobalPriorityChainHelper : ISuperiorChain {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
if (CheckLoginUtils.isLogin()) {
|
if (CheckLoginUtils.isLogin()) {
|
||||||
val isTeenagerMode = getBoolean(Constants.SP_TEENAGER_MODE)
|
api.getReserveDialog(UserManager.getInstance().userId)
|
||||||
loadReserveDialogOnlineData(isTeenagerMode, reserveDialogHandler)
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(object : BiResponse<List<SimpleGameEntity>>() {
|
||||||
|
override fun onSuccess(data: List<SimpleGameEntity>) {
|
||||||
|
reserveDialogHandler.doPreProcess(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFailure(exception: Exception) {
|
||||||
|
reserveDialogHandler.doPreProcess(null)
|
||||||
|
}
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
reserveDialogHandler.doPreProcess(null)
|
reserveDialogHandler.doPreProcess(null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 由于用户预约的游戏个数没有限制,为避免一次加载游戏过多,这里采用先加载第一页,显示出dialog,后续数据在第二页返回
|
|
||||||
* 注意:当page = 2 时,后台会将后续所有数据一次性返回,所以递归到第三层时,就会结束
|
|
||||||
* @param isTeenagerMode 青少年模式关闭时才需要启动自动下载,所以当 isTeenagerMode == true 时,不需要加载后续数据,也不需要启动自动下载
|
|
||||||
*/
|
|
||||||
@SuppressLint("CheckResult")
|
|
||||||
private fun loadReserveDialogOnlineData(isTeenagerMode: Boolean, handler: ReserveDialogHandler? = null) {
|
|
||||||
newApi.getReserveDialog()
|
|
||||||
.compose(singleToMain())
|
|
||||||
.subscribe(object : BiResponse<ReserveOnlineEntity>() {
|
|
||||||
override fun onSuccess(data: ReserveOnlineEntity) {
|
|
||||||
handler?.doPreProcess(data)
|
|
||||||
// 继续获取后续需要自动下载的游戏
|
|
||||||
runOnIoThread {
|
|
||||||
loadGamesWithAutoDownload(1, 20, isTeenagerMode)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onFailure(exception: Exception) {
|
|
||||||
handler?.doPreProcess(null)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 由于这个方法本身就是在子线程调用的,这里不需要另外在做线程切换
|
|
||||||
*/
|
|
||||||
@SuppressLint("CheckResult")
|
|
||||||
@WorkerThread
|
|
||||||
private fun loadGamesWithAutoDownload(page: Int, pageSize: Int, isTeenagerMode: Boolean) {
|
|
||||||
if (page >= 5) {
|
|
||||||
// 为防止死循环,这里设置最多请求到第5页(正常情况下,第一页就是全部数据)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
val filter = "wifi_auto_download:true"
|
|
||||||
newApi.loadGamesWithAutoDownload(page, pageSize, filter)
|
|
||||||
.doOnSuccess(::trackAppointmentGameOnlineDialogShow)
|
|
||||||
.subscribe(object : BiResponse<List<GameEntity>>() {
|
|
||||||
|
|
||||||
override fun onSuccess(data: List<GameEntity>) {
|
|
||||||
// 请注意,这是在子线程中
|
|
||||||
if (data.isNotEmpty()) {
|
|
||||||
loadGamesWithAutoDownload(page + 1, pageSize, isTeenagerMode)
|
|
||||||
startAutoDownloadIfNeed(data, isTeenagerMode)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("CheckResult")
|
|
||||||
private fun startAutoDownloadIfNeed(games: List<GameEntity>, isTeenagerMode: Boolean) {
|
|
||||||
val autoDownloadGameIds = mutableSetOf<String>()
|
|
||||||
games.forEach {
|
|
||||||
autoDownloadGameIds.add(it.id)
|
|
||||||
if (it.wifiAutoDownload && !it.isLandPageAddressDialog() && !isTeenagerMode) {
|
|
||||||
// 开启了 wifi 自动下载,并且不能为第三方落地页跳转
|
|
||||||
val apk = when (it.getApk().size) {
|
|
||||||
0 -> null
|
|
||||||
1 -> it.getApk().first()
|
|
||||||
else -> {
|
|
||||||
// 自动下载,多版本默认:九游版
|
|
||||||
it.getApk().find { apk -> "9u" == apk.getPlatform() && apk.isActive }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (apk != null) {
|
|
||||||
val updateEntities = PackageUtils.getUpdateData(it, false)
|
|
||||||
val isCanUpdate = if (updateEntities.size == 1) {
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
// 多版本只需要判断九游版是否需要更新
|
|
||||||
updateEntities.any { update -> "9u" == update.platform }
|
|
||||||
}
|
|
||||||
val isCanPluggable = PackageUtils.isCanPluggable(apk)
|
|
||||||
if ((!PackageUtils.isInstalled(HaloApp.getInstance(), apk.packageName)
|
|
||||||
|| isCanUpdate
|
|
||||||
|| isCanPluggable)
|
|
||||||
&& DownloadManager.getInstance().getDownloadEntityByUrl(apk.url) == null
|
|
||||||
) {
|
|
||||||
// 未下载/可更新/可插件化 且 之前没有下载记录
|
|
||||||
val msg = FileUtils.isCanDownload(HaloApp.getInstance(), apk.size ?: "")
|
|
||||||
if (msg.isNullOrBlank()) {
|
|
||||||
val isWifiOpen = NetworkUtils.isWifiConnected(HaloApp.getInstance())
|
|
||||||
val isSubscribe = !isWifiOpen
|
|
||||||
DownloadManager.createDownload(
|
|
||||||
HaloApp.getInstance(),
|
|
||||||
apk,
|
|
||||||
it,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
isSubscribe,
|
|
||||||
ExposureEvent.createEvent(it, listOf(ExposureSource("预约上线弹窗-自动下载", "")))
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
// 存储空间不足,直接跳出循环,放弃后续的所有游戏
|
|
||||||
ToastUtils.showToast(msg)
|
|
||||||
return@forEach
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (autoDownloadGameIds.isNotEmpty()) {
|
|
||||||
val body = hashMapOf(
|
|
||||||
"game_ids" to autoDownloadGameIds,
|
|
||||||
"type" to "wifi_auto_download"
|
|
||||||
)
|
|
||||||
newApi.logAutoDownload(body)
|
|
||||||
.subscribe({}, {})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun trackAppointmentGameOnlineDialogShow(games: List<GameEntity>) {
|
|
||||||
if (games.isNotEmpty()) {
|
|
||||||
val gameIds = arrayListOf<String>()
|
|
||||||
val gameNames = arrayListOf<String>()
|
|
||||||
val gameTypes = arrayListOf<String>()
|
|
||||||
games.forEach { game ->
|
|
||||||
gameIds.add(game.id)
|
|
||||||
gameNames.add(game.name ?: "")
|
|
||||||
gameTypes.add(game.categoryChinese)
|
|
||||||
}
|
|
||||||
val gameId = gameIds.joinToString()
|
|
||||||
val gameName = gameNames.joinToString()
|
|
||||||
val gameType = gameTypes.joinToString()
|
|
||||||
SensorsBridge.trackAppointmentGameOnlineDialogShow(gameId, gameName, gameType)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun registerInferiorChain(chain: PriorityChain) {
|
override fun registerInferiorChain(chain: PriorityChain) {
|
||||||
inferiorChain = chain
|
inferiorChain = chain
|
||||||
if (mainChain.isHandlerQueueEmpty()) {
|
if (mainChain.isHandlerQueueEmpty()) {
|
||||||
|
|||||||
@ -5,7 +5,6 @@ import com.gh.common.util.DirectUtils
|
|||||||
import com.gh.gamecenter.BuildConfig
|
import com.gh.gamecenter.BuildConfig
|
||||||
import com.gh.gamecenter.common.entity.LaunchRedirect
|
import com.gh.gamecenter.common.entity.LaunchRedirect
|
||||||
import com.gh.gamecenter.common.entity.LaunchRedirectWrapper
|
import com.gh.gamecenter.common.entity.LaunchRedirectWrapper
|
||||||
import com.gh.gamecenter.common.pagelevel.PageLevelManager
|
|
||||||
import com.gh.gamecenter.common.retrofit.BiResponse
|
import com.gh.gamecenter.common.retrofit.BiResponse
|
||||||
import com.gh.gamecenter.common.utils.singleToMain
|
import com.gh.gamecenter.common.utils.singleToMain
|
||||||
import com.gh.gamecenter.core.AppExecutor
|
import com.gh.gamecenter.core.AppExecutor
|
||||||
@ -66,11 +65,9 @@ class LaunchRedirectHandler(priority: Int) : PriorityChainHandler(priority) {
|
|||||||
override fun onProcess(): Boolean {
|
override fun onProcess(): Boolean {
|
||||||
val currentActivity = CurrentActivityHolder.getCurrentActivity()
|
val currentActivity = CurrentActivityHolder.getCurrentActivity()
|
||||||
|
|
||||||
if (GlobalPriorityChainHelper.isThisActivityValid(currentActivity) && launchData?.type != "bottom_tab") {
|
if (GlobalPriorityChainHelper.isThisActivityValid(currentActivity)) {
|
||||||
if (getStatus() == STATUS_VALID) {
|
if (getStatus() == STATUS_VALID) {
|
||||||
// 设置下一个页面为顶级页面
|
// 当 type 为 "bottom_tab" 时上面 doPreProcess 中已经处理过了,但再选中一次好像也没有什么问题,先不特殊处理这个 case 了
|
||||||
PageLevelManager.setNextPageAsSupremePageLevel()
|
|
||||||
|
|
||||||
DirectUtils.directToLinkPage(currentActivity!!, launchData!!, "首次启动跳转", "")
|
DirectUtils.directToLinkPage(currentActivity!!, launchData!!, "首次启动跳转", "")
|
||||||
// 跳转页面不管回调,延迟 500ms 后执行下一个 handler
|
// 跳转页面不管回调,延迟 500ms 后执行下一个 handler
|
||||||
AppExecutor.uiExecutor.executeWithDelay({
|
AppExecutor.uiExecutor.executeWithDelay({
|
||||||
|
|||||||
@ -1,80 +0,0 @@
|
|||||||
package com.gh.common.prioritychain
|
|
||||||
|
|
||||||
import android.os.Bundle
|
|
||||||
import androidx.fragment.app.FragmentActivity
|
|
||||||
import com.gh.common.dialog.AccelerateExpirationDialogFragment
|
|
||||||
import com.gh.gamecenter.common.constant.Constants.SP_ACCELERATOR_MEMBERSHIP_EXPIRED
|
|
||||||
import com.gh.gamecenter.core.utils.CurrentActivityHolder
|
|
||||||
import com.gh.gamecenter.core.utils.SPUtils
|
|
||||||
import com.gh.gamecenter.login.user.UserRepository
|
|
||||||
import com.halo.assistant.accelerator.repository.AcceleratorDataHolder
|
|
||||||
|
|
||||||
class MembershipExpiredHandler(priority: Int) : PriorityChainHandler(priority) {
|
|
||||||
|
|
||||||
fun doPreProcess() {
|
|
||||||
UserRepository.getInstance().setAutoLoginListener {
|
|
||||||
val hasShow = SPUtils.getBoolean(SP_ACCELERATOR_MEMBERSHIP_EXPIRED)
|
|
||||||
val vipEntity = AcceleratorDataHolder.instance.vipEntity
|
|
||||||
if (getStatus() == STATUS_PENDING) {
|
|
||||||
if (vipEntity == null ||
|
|
||||||
vipEntity.vipStatus ||
|
|
||||||
vipEntity.isNewUser ||
|
|
||||||
vipEntity.isVipRefundUser ||
|
|
||||||
vipEntity.isDurationRefundUser ||
|
|
||||||
hasShow
|
|
||||||
) {
|
|
||||||
processNext()
|
|
||||||
} else {
|
|
||||||
updateStatus(STATUS_VALID)
|
|
||||||
process()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (vipEntity == null ||
|
|
||||||
vipEntity.vipStatus ||
|
|
||||||
vipEntity.isNewUser ||
|
|
||||||
vipEntity.isVipRefundUser ||
|
|
||||||
vipEntity.isDurationRefundUser ||
|
|
||||||
hasShow
|
|
||||||
) {
|
|
||||||
updateStatus(STATUS_INVALID)
|
|
||||||
} else {
|
|
||||||
updateStatus(STATUS_VALID)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onProcess(): Boolean {
|
|
||||||
val currentActivity = CurrentActivityHolder.getCurrentActivity()
|
|
||||||
if (GlobalPriorityChainHelper.isThisActivityValid(currentActivity)) {
|
|
||||||
when (getStatus()) {
|
|
||||||
STATUS_VALID -> {
|
|
||||||
val reminder = AccelerateExpirationDialogFragment.ExpirationReminder.TimeRunsOut("")
|
|
||||||
SPUtils.setBoolean(SP_ACCELERATOR_MEMBERSHIP_EXPIRED, true)
|
|
||||||
val dialogFragment = AccelerateExpirationDialogFragment().apply {
|
|
||||||
arguments = Bundle().apply {
|
|
||||||
putParcelable(
|
|
||||||
AccelerateExpirationDialogFragment.KEY_EXPIRATION_REMINDER, reminder
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dialogFragment.dialog?.setOnDismissListener {
|
|
||||||
processNext()
|
|
||||||
}
|
|
||||||
dialogFragment.show(
|
|
||||||
(currentActivity as FragmentActivity).supportFragmentManager,
|
|
||||||
AccelerateExpirationDialogFragment::class.java.name
|
|
||||||
)
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
STATUS_INVALID -> {
|
|
||||||
processNext()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,296 +0,0 @@
|
|||||||
package com.gh.common.prioritychain
|
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import android.os.Handler
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.widget.PopupWindow
|
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
import com.gh.gamecenter.common.constant.Constants
|
|
||||||
import com.gh.gamecenter.common.utils.dip2px
|
|
||||||
import com.gh.gamecenter.common.utils.goneIf
|
|
||||||
import com.gh.gamecenter.common.view.BugFixedPopupWindow
|
|
||||||
import com.gh.gamecenter.common.view.NoDefaultMinWidthTabLayout
|
|
||||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
|
||||||
import com.gh.gamecenter.core.utils.SPUtils
|
|
||||||
import com.gh.gamecenter.databinding.PopupMultiTabGuideBinding
|
|
||||||
import com.gh.gamecenter.entity.BottomTab
|
|
||||||
import com.gh.gamecenter.wrapper.BaseTabWrapperFragment
|
|
||||||
import com.gh.gamecenter.wrapper.MainWrapperFragment
|
|
||||||
import com.google.android.material.tabs.TabLayout
|
|
||||||
import com.google.android.material.tabs.TabLayout.TabView
|
|
||||||
|
|
||||||
class MultiTabGuideHandler(priority: Int): PriorityChainHandler(priority) {
|
|
||||||
private var mActivity: Activity? = null
|
|
||||||
private var mHandler: Handler? = null
|
|
||||||
private var mGuide: BottomTab.Guide? = null
|
|
||||||
private var mTabLayout: TabLayout? = null
|
|
||||||
private var mTabView: TabView? = null
|
|
||||||
private var mIsSingleLineTab = false
|
|
||||||
private var mMainWrapperFragment: MainWrapperFragment? = null
|
|
||||||
private var mTabWrapperFragment: BaseTabWrapperFragment? = null
|
|
||||||
|
|
||||||
fun doPreProcess(
|
|
||||||
shouldShow: Boolean,
|
|
||||||
activity: Activity? = null,
|
|
||||||
handler: Handler? = null,
|
|
||||||
guide: BottomTab.Guide? = null,
|
|
||||||
tabLayout: TabLayout? = null,
|
|
||||||
tabView: TabLayout.TabView? = null,
|
|
||||||
isSingleLineTab: Boolean = false,
|
|
||||||
mainWrapperFragment: MainWrapperFragment? = null,
|
|
||||||
tabWrapperFragment: BaseTabWrapperFragment? = null
|
|
||||||
) {
|
|
||||||
mActivity = activity
|
|
||||||
mHandler = handler
|
|
||||||
mGuide = guide
|
|
||||||
mTabLayout = tabLayout
|
|
||||||
mTabView = tabView
|
|
||||||
mIsSingleLineTab = isSingleLineTab
|
|
||||||
mMainWrapperFragment = mainWrapperFragment
|
|
||||||
mTabWrapperFragment = tabWrapperFragment
|
|
||||||
|
|
||||||
if (getStatus() == STATUS_PENDING) {
|
|
||||||
if (shouldShow) {
|
|
||||||
updateStatus(STATUS_VALID)
|
|
||||||
process()
|
|
||||||
} else {
|
|
||||||
processNext()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (shouldShow) {
|
|
||||||
updateStatus(STATUS_VALID)
|
|
||||||
} else {
|
|
||||||
updateStatus(STATUS_INVALID)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onProcess(): Boolean {
|
|
||||||
when (getStatus()) {
|
|
||||||
STATUS_VALID -> {
|
|
||||||
if (mGuide == null || mActivity == null || mTabView == null || mTabLayout == null) {
|
|
||||||
processNext()
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return showMultiTabGuide(
|
|
||||||
true,
|
|
||||||
mActivity!!,
|
|
||||||
mHandler,
|
|
||||||
mGuide!!,
|
|
||||||
mTabLayout!!,
|
|
||||||
mTabView!!,
|
|
||||||
mIsSingleLineTab,
|
|
||||||
mMainWrapperFragment,
|
|
||||||
mTabWrapperFragment
|
|
||||||
) {
|
|
||||||
processNext()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
STATUS_INVALID -> {
|
|
||||||
processNext()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
private const val TAB_GUIDE_TRIANGLE_OFFSET_DP = 5F
|
|
||||||
private const val TAB_GUIDE_START_TRIANGLE_OFFSET_DP = 12F
|
|
||||||
private const val TAB_GUIDE_RIGHT_SIDE_ICON_RIGHT_RESERVED_OFFSET_DP = 51F + TAB_GUIDE_TRIANGLE_OFFSET_DP // 光宝在文案右侧时预留引导到屏幕右侧的距离
|
|
||||||
private const val TAB_GUIDE_RIGHT_SIDE_ICON_LEFT_RESERVED_OFFSET_DP = TAB_GUIDE_START_TRIANGLE_OFFSET_DP + TAB_GUIDE_TRIANGLE_OFFSET_DP // 光宝在文案作侧时预留引导到屏幕右侧的距离
|
|
||||||
|
|
||||||
fun showMultiTabGuide(
|
|
||||||
isImmediately: Boolean,
|
|
||||||
activity: Activity,
|
|
||||||
handler: Handler?,
|
|
||||||
guide: BottomTab.Guide,
|
|
||||||
tabLayout: TabLayout,
|
|
||||||
tabView: TabView,
|
|
||||||
isSingleLineTab: Boolean = false,
|
|
||||||
mainWrapperFragment: MainWrapperFragment? = null,
|
|
||||||
tabWrapperFragment: BaseTabWrapperFragment? = null,
|
|
||||||
dismissCallback: (() -> Unit)? = null
|
|
||||||
): Boolean {
|
|
||||||
val guideSet = HashSet(SPUtils.getStringSet(Constants.SP_MULTI_TAB_NAV_GUIDE_SET))
|
|
||||||
val hasShownGuide = guideSet.contains(guide.multiTabId + guide.text)
|
|
||||||
val isCurrentBottomTab = mainWrapperFragment == null || guide.bottomTabId == mainWrapperFragment.currentTab?.id
|
|
||||||
if (!hasShownGuide && isCurrentBottomTab) {
|
|
||||||
val screenWidth = DisplayUtils.getScreenWidth(activity)
|
|
||||||
val outLocation = IntArray(2)
|
|
||||||
tabView.getLocationOnScreen(outLocation)
|
|
||||||
val tabViewCenterPosX = outLocation.first() + tabView.width / 2F
|
|
||||||
val iconLeftMaxPosX = if (isSingleLineTab) tabLayout.width else tabLayout.width - TAB_GUIDE_RIGHT_SIDE_ICON_LEFT_RESERVED_OFFSET_DP.dip2px()
|
|
||||||
val iconRightMaxPosX = if (isSingleLineTab) tabLayout.width else tabLayout.width - TAB_GUIDE_RIGHT_SIDE_ICON_RIGHT_RESERVED_OFFSET_DP.dip2px()
|
|
||||||
val isIconLeftValid = tabViewCenterPosX <= iconLeftMaxPosX
|
|
||||||
val isIconRightValid = tabViewCenterPosX <= iconRightMaxPosX
|
|
||||||
val isTabViewShowOnScreen = tabViewCenterPosX > 0 && (isIconLeftValid || isIconRightValid)
|
|
||||||
val isTabLayoutScrollStateIdle = (tabLayout as? NoDefaultMinWidthTabLayout)?.isScrollStateIdle == true
|
|
||||||
if (isTabViewShowOnScreen && isTabLayoutScrollStateIdle) {
|
|
||||||
val trianglePosX = tabViewCenterPosX - TAB_GUIDE_TRIANGLE_OFFSET_DP.dip2px()
|
|
||||||
val guideStartPosX = trianglePosX - TAB_GUIDE_START_TRIANGLE_OFFSET_DP.dip2px()
|
|
||||||
val xoff = tabView.width / 2 - TAB_GUIDE_START_TRIANGLE_OFFSET_DP.dip2px() - TAB_GUIDE_TRIANGLE_OFFSET_DP.dip2px()
|
|
||||||
val restGuideWidth = screenWidth - guideStartPosX
|
|
||||||
|
|
||||||
showMultiTabPopupWindow(
|
|
||||||
activity,
|
|
||||||
handler,
|
|
||||||
guide,
|
|
||||||
tabView,
|
|
||||||
xoff,
|
|
||||||
screenWidth,
|
|
||||||
restGuideWidth,
|
|
||||||
isIconRightValid,
|
|
||||||
dismissCallback
|
|
||||||
)
|
|
||||||
guideSet.add(guide.multiTabId + guide.text)
|
|
||||||
SPUtils.setStringSet(Constants.SP_MULTI_TAB_NAV_GUIDE_SET, guideSet)
|
|
||||||
|
|
||||||
return true
|
|
||||||
} else if (isImmediately) {
|
|
||||||
(tabLayout as? NoDefaultMinWidthTabLayout)?.let {
|
|
||||||
it.onScrollListener = object :
|
|
||||||
NoDefaultMinWidthTabLayout.OnScrollListener() {
|
|
||||||
override fun onScrollStateChanged(view: NoDefaultMinWidthTabLayout, scrollState: Int) {
|
|
||||||
if (scrollState == SCROLL_STATE_IDLE) {
|
|
||||||
showMultiTabGuideIfTabViewShow(
|
|
||||||
activity,
|
|
||||||
handler,
|
|
||||||
guide,
|
|
||||||
it,
|
|
||||||
tabView,
|
|
||||||
isSingleLineTab,
|
|
||||||
mainWrapperFragment
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (isImmediately && !isCurrentBottomTab) {
|
|
||||||
tabWrapperFragment?.setResumeAndPauseListener {
|
|
||||||
if (it) {
|
|
||||||
handler?.post {
|
|
||||||
(tabLayout as? NoDefaultMinWidthTabLayout)?.let { tl ->
|
|
||||||
showMultiTabGuideIfBottomTabShow(
|
|
||||||
activity,
|
|
||||||
handler,
|
|
||||||
guide,
|
|
||||||
tl,
|
|
||||||
tabView,
|
|
||||||
isSingleLineTab,
|
|
||||||
mainWrapperFragment,
|
|
||||||
tabWrapperFragment
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dismissCallback?.invoke()
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
fun showMultiTabGuideIfTabViewShow(
|
|
||||||
activity: Activity,
|
|
||||||
handler: Handler?,
|
|
||||||
guide: BottomTab.Guide,
|
|
||||||
tabLayout: NoDefaultMinWidthTabLayout,
|
|
||||||
tabView: TabView,
|
|
||||||
isSingleLineTab: Boolean = false,
|
|
||||||
mainWrapperFragment: MainWrapperFragment?
|
|
||||||
) {
|
|
||||||
if (showMultiTabGuide(
|
|
||||||
false,
|
|
||||||
activity,
|
|
||||||
handler,
|
|
||||||
guide,
|
|
||||||
tabLayout,
|
|
||||||
tabView,
|
|
||||||
isSingleLineTab,
|
|
||||||
mainWrapperFragment
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
tabLayout.onScrollListener = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun showMultiTabGuideIfBottomTabShow(
|
|
||||||
activity: Activity,
|
|
||||||
handler: Handler?,
|
|
||||||
guide: BottomTab.Guide,
|
|
||||||
tabLayout: NoDefaultMinWidthTabLayout,
|
|
||||||
tabView: TabView,
|
|
||||||
isSingleLineTab: Boolean = false,
|
|
||||||
mainWrapperFragment: MainWrapperFragment?,
|
|
||||||
tabWrapperFragment: BaseTabWrapperFragment?
|
|
||||||
) {
|
|
||||||
if (showMultiTabGuide(
|
|
||||||
false,
|
|
||||||
activity,
|
|
||||||
handler,
|
|
||||||
guide,
|
|
||||||
tabLayout,
|
|
||||||
tabView,
|
|
||||||
isSingleLineTab,
|
|
||||||
mainWrapperFragment,
|
|
||||||
tabWrapperFragment
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
tabWrapperFragment?.setResumeAndPauseListener(null)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun showMultiTabPopupWindow(
|
|
||||||
activity: Activity,
|
|
||||||
handler: Handler?,
|
|
||||||
guide: BottomTab.Guide,
|
|
||||||
tabView: TabView,
|
|
||||||
xoff: Int,
|
|
||||||
screenWidth: Int,
|
|
||||||
restGuideWidth: Float,
|
|
||||||
isIconRight: Boolean,
|
|
||||||
dismissCallback: (() -> Unit)?
|
|
||||||
): PopupWindow {
|
|
||||||
val binding = PopupMultiTabGuideBinding.inflate(LayoutInflater.from(activity))
|
|
||||||
binding.guideTv.text = guide.text
|
|
||||||
binding.guideTriangleIv.translationX = 12F.dip2px().toFloat()
|
|
||||||
binding.guideTv.setPadding(if (isIconRight) 8F.dip2px() else 52F.dip2px(), 0, if (isIconRight) 52F.dip2px() else 8F.dip2px(), 0)
|
|
||||||
binding.guideIconIv.goneIf(!isIconRight)
|
|
||||||
binding.guideIconFlipIv.goneIf(isIconRight)
|
|
||||||
|
|
||||||
val popupWindow = BugFixedPopupWindow(
|
|
||||||
binding.root,
|
|
||||||
ConstraintLayout.LayoutParams.WRAP_CONTENT,
|
|
||||||
ConstraintLayout.LayoutParams.WRAP_CONTENT
|
|
||||||
)
|
|
||||||
popupWindow.contentView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED)
|
|
||||||
val measureWidth = popupWindow.contentView.measuredWidth
|
|
||||||
if (measureWidth >= screenWidth) {
|
|
||||||
popupWindow.width = screenWidth
|
|
||||||
binding.guideTriangleIv.translationX += screenWidth - restGuideWidth
|
|
||||||
} else if (measureWidth > restGuideWidth) {
|
|
||||||
binding.guideTriangleIv.translationX += measureWidth - restGuideWidth
|
|
||||||
}
|
|
||||||
|
|
||||||
return popupWindow.apply {
|
|
||||||
isTouchable = false
|
|
||||||
isFocusable = false
|
|
||||||
isOutsideTouchable = true
|
|
||||||
animationStyle = com.gh.gamecenter.common.R.style.popup_window_ease_in_and_out_anim_style
|
|
||||||
setOnDismissListener {
|
|
||||||
dismissCallback?.invoke()
|
|
||||||
}
|
|
||||||
handler?.post {
|
|
||||||
if (!activity.isFinishing) {
|
|
||||||
showAsDropDown(tabView, xoff, (-25F).dip2px())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
package com.gh.common.prioritychain
|
|
||||||
|
|
||||||
import androidx.fragment.app.FragmentActivity
|
|
||||||
import com.gh.common.util.PackageHelper
|
|
||||||
import com.gh.gamecenter.common.base.GlobalActivityManager
|
|
||||||
|
|
||||||
class RequestInstalledListPermissionHandler : PriorityChainHandler(-1000) {
|
|
||||||
|
|
||||||
init {
|
|
||||||
updateStatus(STATUS_VALID)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onProcess(): Boolean {
|
|
||||||
val currentActivity = GlobalActivityManager.currentActivity ?: return false
|
|
||||||
|
|
||||||
if (currentActivity !is FragmentActivity) return false
|
|
||||||
|
|
||||||
PackageHelper.showGetInstallAppsListDialogAndRequestPermissionIfNeeded(
|
|
||||||
activity = currentActivity,
|
|
||||||
ignorePermanentlyDenied = true
|
|
||||||
) {
|
|
||||||
processNext()
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -2,28 +2,28 @@ package com.gh.common.prioritychain
|
|||||||
|
|
||||||
import androidx.fragment.app.FragmentActivity
|
import androidx.fragment.app.FragmentActivity
|
||||||
import com.gh.common.dialog.ReserveDialog
|
import com.gh.common.dialog.ReserveDialog
|
||||||
|
import com.gh.gamecenter.common.entity.SimpleGameEntity
|
||||||
import com.gh.gamecenter.core.utils.CurrentActivityHolder
|
import com.gh.gamecenter.core.utils.CurrentActivityHolder
|
||||||
import com.gh.gamecenter.feature.entity.ReserveOnlineEntity
|
|
||||||
|
|
||||||
class ReserveDialogHandler(priority: Int) : PriorityChainHandler(priority) {
|
class ReserveDialogHandler(priority: Int) : PriorityChainHandler(priority) {
|
||||||
|
|
||||||
private var mReserveData: ReserveOnlineEntity? = null
|
private var mReserveData: List<SimpleGameEntity>? = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提前预处理显示弹窗的内容
|
* 提前预处理显示弹窗的内容
|
||||||
*/
|
*/
|
||||||
fun doPreProcess(reserveData: ReserveOnlineEntity?) {
|
fun doPreProcess(reserveData: List<SimpleGameEntity>?) {
|
||||||
mReserveData = reserveData
|
mReserveData = reserveData
|
||||||
|
|
||||||
if (getStatus() == STATUS_PENDING) {
|
if (getStatus() == STATUS_PENDING) {
|
||||||
if (reserveData?.games.isNullOrEmpty()) {
|
if (reserveData.isNullOrEmpty()) {
|
||||||
processNext()
|
processNext()
|
||||||
} else {
|
} else {
|
||||||
updateStatus(STATUS_VALID)
|
updateStatus(STATUS_VALID)
|
||||||
process()
|
process()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (reserveData?.games.isNullOrEmpty()) {
|
if (reserveData.isNullOrEmpty()) {
|
||||||
updateStatus(STATUS_INVALID)
|
updateStatus(STATUS_INVALID)
|
||||||
} else {
|
} else {
|
||||||
updateStatus(STATUS_VALID)
|
updateStatus(STATUS_VALID)
|
||||||
@ -37,7 +37,7 @@ class ReserveDialogHandler(priority: Int) : PriorityChainHandler(priority) {
|
|||||||
if (GlobalPriorityChainHelper.isThisActivityValid(currentActivity)) {
|
if (GlobalPriorityChainHelper.isThisActivityValid(currentActivity)) {
|
||||||
when (getStatus()) {
|
when (getStatus()) {
|
||||||
STATUS_VALID -> {
|
STATUS_VALID -> {
|
||||||
val reserveDialog = ReserveDialog.getInstance(mReserveData ?:ReserveOnlineEntity())
|
val reserveDialog = ReserveDialog.getInstance(mReserveData!!)
|
||||||
reserveDialog.setOnDismissListener {
|
reserveDialog.setOnDismissListener {
|
||||||
processNext()
|
processNext()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,16 +0,0 @@
|
|||||||
package com.gh.common.prioritychain
|
|
||||||
|
|
||||||
import com.gh.gamecenter.home.video.ScrollCalculatorHelper
|
|
||||||
|
|
||||||
class VideoHandler(priority: Int, val scrollCalculatorHelper: ScrollCalculatorHelper): PriorityChainHandler(priority) {
|
|
||||||
|
|
||||||
init {
|
|
||||||
updateStatus(STATUS_VALID)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onProcess(): Boolean {
|
|
||||||
scrollCalculatorHelper.enableAndPlayIfValid()
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
package com.gh.common.provider
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import com.alibaba.android.arouter.facade.annotation.Route
|
||||||
|
import com.gh.common.util.ActivationHelper
|
||||||
|
import com.gh.gamecenter.common.constant.RouteConsts
|
||||||
|
import com.gh.gamecenter.core.provider.IActivationProvider
|
||||||
|
|
||||||
|
@Route(path = RouteConsts.provider.activation, name = "ActivationHelper暴露服务")
|
||||||
|
class ActivationProviderImpl : IActivationProvider {
|
||||||
|
override fun init(context: Context?) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun sendActivationInfo() {
|
||||||
|
ActivationHelper.sendActivationInfo()
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
package com.gh.common.provider
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import com.alibaba.android.arouter.facade.annotation.Route
|
||||||
|
import com.gh.common.util.AdHelper
|
||||||
|
import com.gh.gamecenter.common.constant.RouteConsts
|
||||||
|
import com.gh.gamecenter.feature.entity.SettingsEntity
|
||||||
|
import com.gh.gamecenter.feature.provider.IAdHelperProvider
|
||||||
|
|
||||||
|
@Route(path = RouteConsts.provider.adHelper, name = "AdHelper暴露服务")
|
||||||
|
class AdHelperProviderImpl : IAdHelperProvider {
|
||||||
|
override fun getSuggestionFunctionAd(): SettingsEntity.AD? {
|
||||||
|
return AdHelper.getAd(AdHelper.LOCATION_SUGGESTION_FUNCTION)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun init(context: Context?) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,15 +1,19 @@
|
|||||||
package com.gh.common.provider
|
package com.gh.common.provider
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import com.alibaba.android.arouter.facade.annotation.Route
|
||||||
import com.gh.gamecenter.BuildConfig
|
import com.gh.gamecenter.BuildConfig
|
||||||
import com.gh.gamecenter.R
|
import com.gh.gamecenter.R
|
||||||
|
import com.gh.gamecenter.common.constant.RouteConsts
|
||||||
import com.gh.gamecenter.core.provider.IAppProvider
|
import com.gh.gamecenter.core.provider.IAppProvider
|
||||||
import com.gh.gamecenter.core.provider.IFlavorProvider
|
import com.gh.gamecenter.core.provider.IFlavorProvider
|
||||||
import com.gh.gamecenter.va.VCore
|
|
||||||
import com.halo.assistant.HaloApp
|
import com.halo.assistant.HaloApp
|
||||||
|
|
||||||
@com.therouter.inject.ServiceProvider
|
@Route(path = RouteConsts.provider.app, name = "Application暴露服务")
|
||||||
class AppProviderImpl : IAppProvider {
|
class AppProviderImpl : IAppProvider {
|
||||||
|
override fun init(context: Context?) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
override fun getAppName(): String {
|
override fun getAppName(): String {
|
||||||
return HaloApp.getInstance().getString(R.string.app_name)
|
return HaloApp.getInstance().getString(R.string.app_name)
|
||||||
@ -79,14 +83,7 @@ class AppProviderImpl : IAppProvider {
|
|||||||
return HaloApp.getInstance().isBrandNewInstall
|
return HaloApp.getInstance().isBrandNewInstall
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setDisableSplashAdTemporarily(isDisable: Boolean) {
|
override fun setSkippingThirdParty(isSkippingThirdParty: Boolean) {
|
||||||
HaloApp.getInstance().isDisableSplashAdTemporarily = isDisable
|
HaloApp.getInstance().isSkippingThirdParty = isSkippingThirdParty
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getPluginVersion(): String = VCore.getInstance().getPluginVersion()
|
|
||||||
|
|
||||||
override fun initImageLoaderIfNeeded() {
|
|
||||||
HaloApp.getInstance().initFresco()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,15 +1,16 @@
|
|||||||
package com.gh.common.provider
|
package com.gh.common.provider
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import com.alibaba.android.arouter.facade.annotation.Route
|
||||||
import com.gh.common.databind.BindingAdapters
|
import com.gh.common.databind.BindingAdapters
|
||||||
import com.gh.gamecenter.common.databinding.LayoutGameItemSellingPointBinding
|
import com.gh.gamecenter.common.constant.RouteConsts
|
||||||
import com.gh.gamecenter.feature.entity.GameEntity
|
import com.gh.gamecenter.feature.entity.GameEntity
|
||||||
import com.gh.gamecenter.feature.provider.IBindingAdaptersProvider
|
import com.gh.gamecenter.feature.provider.IBindingAdaptersProvider
|
||||||
import com.gh.gamecenter.home.custom.adapter.CustomViewExt
|
|
||||||
|
|
||||||
@com.therouter.inject.ServiceProvider
|
@Route(path = RouteConsts.provider.bindingAdapters, name = "BindingAdapters暴露服务")
|
||||||
class BindingAdaptersProviderImpl : IBindingAdaptersProvider {
|
class BindingAdaptersProviderImpl : IBindingAdaptersProvider {
|
||||||
override fun setGameName(
|
override fun setGameName(
|
||||||
view: TextView,
|
view: TextView,
|
||||||
@ -20,7 +21,7 @@ class BindingAdaptersProviderImpl : IBindingAdaptersProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun setGameTags(layout: LinearLayout, gameEntity: GameEntity) {
|
override fun setGameTags(layout: LinearLayout, gameEntity: GameEntity) {
|
||||||
BindingAdapters.setGameTags(layout, gameEntity, "")
|
BindingAdapters.setGameTags(layout, gameEntity)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setMessageUnread(view: TextView, unreadCount: Int) {
|
override fun setMessageUnread(view: TextView, unreadCount: Int) {
|
||||||
@ -31,16 +32,7 @@ class BindingAdaptersProviderImpl : IBindingAdaptersProvider {
|
|||||||
BindingAdapters.setGame(view, gameEntity)
|
BindingAdapters.setGame(view, gameEntity)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setGameTagsWithSellingPoints(
|
override fun init(context: Context?) {
|
||||||
layout: LinearLayout,
|
// Do nothing
|
||||||
sellingPointsBinding: LayoutGameItemSellingPointBinding,
|
|
||||||
gameEntity: GameEntity,
|
|
||||||
subjectTag: String
|
|
||||||
) {
|
|
||||||
BindingAdapters.setGameTagsWithSellingPoint(layout, sellingPointsBinding, gameEntity, subjectTag)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun setGameDescription(tvDesc: TextView, briefStyle: String, game: GameEntity) {
|
|
||||||
CustomViewExt.setDescription(tvDesc, briefStyle, game)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,9 +1,12 @@
|
|||||||
package com.gh.common.provider
|
package com.gh.common.provider
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import com.alibaba.android.arouter.facade.annotation.Route
|
||||||
import com.gh.download.server.BrowserInstallHelper
|
import com.gh.download.server.BrowserInstallHelper
|
||||||
|
import com.gh.gamecenter.common.constant.RouteConsts
|
||||||
import com.gh.gamecenter.core.provider.IBrowserInstallHelperProvider
|
import com.gh.gamecenter.core.provider.IBrowserInstallHelperProvider
|
||||||
|
|
||||||
@com.therouter.inject.ServiceProvider
|
@Route(path = RouteConsts.provider.browserInstallHelper, name = "BrowserInstallHelper暴露服务")
|
||||||
class BrowserInstallHelperProviderImpl : IBrowserInstallHelperProvider {
|
class BrowserInstallHelperProviderImpl : IBrowserInstallHelperProvider {
|
||||||
override fun isUseBrowserToInstallEnabled(): Boolean = BrowserInstallHelper.isUseBrowserToInstallEnabled()
|
override fun isUseBrowserToInstallEnabled(): Boolean = BrowserInstallHelper.isUseBrowserToInstallEnabled()
|
||||||
|
|
||||||
@ -12,4 +15,9 @@ class BrowserInstallHelperProviderImpl : IBrowserInstallHelperProvider {
|
|||||||
override fun logSwitchInstallSettingEvent() {
|
override fun logSwitchInstallSettingEvent() {
|
||||||
BrowserInstallHelper.logOrdinaryBrowserEvent(BrowserInstallHelper.Type.SWITCH_INSTALL_SETTING)
|
BrowserInstallHelper.logOrdinaryBrowserEvent(BrowserInstallHelper.Type.SWITCH_INSTALL_SETTING)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun init(context: Context?) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -1,10 +1,17 @@
|
|||||||
package com.gh.common.provider
|
package com.gh.common.provider
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import com.alibaba.android.arouter.facade.annotation.Route
|
||||||
import com.gh.gamecenter.BuildConfig
|
import com.gh.gamecenter.BuildConfig
|
||||||
|
import com.gh.gamecenter.common.constant.RouteConsts
|
||||||
import com.gh.gamecenter.core.provider.IBuildConfigProvider
|
import com.gh.gamecenter.core.provider.IBuildConfigProvider
|
||||||
|
|
||||||
@com.therouter.inject.ServiceProvider
|
@Route(path = RouteConsts.provider.buildConfig, name = "BuildConfig暴露服务")
|
||||||
class BuildConfigImpl : IBuildConfigProvider {
|
class BuildConfigImpl : IBuildConfigProvider {
|
||||||
|
override fun init(context: Context?) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
override fun getApplicationId(): String = BuildConfig.APPLICATION_ID
|
override fun getApplicationId(): String = BuildConfig.APPLICATION_ID
|
||||||
|
|
||||||
override fun getVersionName(): String = BuildConfig.VERSION_NAME
|
override fun getVersionName(): String = BuildConfig.VERSION_NAME
|
||||||
@ -25,12 +32,5 @@ class BuildConfigImpl : IBuildConfigProvider {
|
|||||||
override fun getVApiHost(): String = BuildConfig.VAPI_HOST
|
override fun getVApiHost(): String = BuildConfig.VAPI_HOST
|
||||||
|
|
||||||
override fun getVDevApiHost(): String = BuildConfig.DEV_VAPI_HOST
|
override fun getVDevApiHost(): String = BuildConfig.DEV_VAPI_HOST
|
||||||
|
|
||||||
override fun getWGameCPMApiHost(): String = BuildConfig.WGAME_CPM_API_HOST
|
|
||||||
|
|
||||||
override fun getWGameCPMBusiAppId(): String = BuildConfig.WGAME_CPM_BUSIAPPID
|
|
||||||
|
|
||||||
override fun getLogProducerProject(): String = BuildConfig.LOG_HUB_PROJECT
|
override fun getLogProducerProject(): String = BuildConfig.LOG_HUB_PROJECT
|
||||||
|
|
||||||
override fun getDspApiHost(): String = BuildConfig.DSP_API_HOST
|
|
||||||
}
|
}
|
||||||
@ -1,12 +1,18 @@
|
|||||||
package com.gh.common.provider
|
package com.gh.common.provider
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import com.alibaba.android.arouter.facade.annotation.Route
|
||||||
import com.gh.common.util.CheckLoginUtils
|
import com.gh.common.util.CheckLoginUtils
|
||||||
|
import com.gh.gamecenter.common.constant.RouteConsts
|
||||||
import com.gh.gamecenter.core.provider.ICheckLoginProvider
|
import com.gh.gamecenter.core.provider.ICheckLoginProvider
|
||||||
|
|
||||||
@com.therouter.inject.ServiceProvider
|
@Route(path = RouteConsts.provider.checkLogin, name = "CheckLoginUtils暴露服务")
|
||||||
class CheckLoginProviderImpl : ICheckLoginProvider {
|
class CheckLoginProviderImpl : ICheckLoginProvider {
|
||||||
override fun checkLogin(context: Context, entrance: String, action: (() -> Unit)?) {
|
override fun checkLogin(context: Context, entrance: String, action: (() -> Unit)?) {
|
||||||
CheckLoginUtils.checkLogin(context, entrance, action)
|
CheckLoginUtils.checkLogin(context, entrance, action)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun init(context: Context?) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -3,16 +3,20 @@ package com.gh.common.provider
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import com.therouter.router.Route
|
import com.alibaba.android.arouter.facade.annotation.Route
|
||||||
import com.gh.gamecenter.CommentDetailActivity
|
import com.gh.gamecenter.CommentDetailActivity
|
||||||
import com.gh.gamecenter.common.constant.RouteConsts
|
import com.gh.gamecenter.common.constant.RouteConsts
|
||||||
import com.gh.gamecenter.feature.provider.ICommentDetailProvider
|
import com.gh.gamecenter.feature.provider.ICommentDetailProvider
|
||||||
import com.gh.gamecenter.feature.entity.MessageEntity
|
import com.gh.gamecenter.feature.entity.MessageEntity
|
||||||
|
|
||||||
@com.therouter.inject.ServiceProvider
|
@Route(path = RouteConsts.provider.commentDetail, name = "CommentDetailActivity暴露服务")
|
||||||
class CommentDetailProviderImpl : ICommentDetailProvider {
|
class CommentDetailProviderImpl : ICommentDetailProvider {
|
||||||
|
|
||||||
override fun getIntent(context: Context, commentId: String?, message: Parcelable): Intent {
|
override fun getIntent(context: Context, commentId: String?, message: Parcelable): Intent {
|
||||||
return CommentDetailActivity.getIntent(context, commentId, message as MessageEntity.Article)
|
return CommentDetailActivity.getIntent(context, commentId, message as MessageEntity.Article)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
override fun init(context: Context?) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,14 +1,18 @@
|
|||||||
package com.gh.common.provider
|
package com.gh.common.provider
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import com.therouter.router.Route
|
import com.alibaba.android.arouter.facade.annotation.Route
|
||||||
import com.gh.gamecenter.common.constant.RouteConsts
|
import com.gh.gamecenter.common.constant.RouteConsts
|
||||||
import com.gh.gamecenter.core.provider.ICommentManagerProvider
|
import com.gh.gamecenter.core.provider.ICommentManagerProvider
|
||||||
import com.gh.gamecenter.manager.CommentManager
|
import com.gh.gamecenter.manager.CommentManager
|
||||||
|
|
||||||
@com.therouter.inject.ServiceProvider
|
@Route(path = RouteConsts.provider.commentManager, name = "CommentManager暴露服务")
|
||||||
class CommentManagerProviderImpl : ICommentManagerProvider {
|
class CommentManagerProviderImpl : ICommentManagerProvider {
|
||||||
override fun addUrl(ids: String) {
|
override fun addUrl(ids: String) {
|
||||||
CommentManager.getInstance().addUrl(ids)
|
CommentManager.getInstance().addUrl(ids)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun init(context: Context?) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -2,12 +2,12 @@ package com.gh.common.provider
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import com.therouter.router.Route
|
import com.alibaba.android.arouter.facade.annotation.Route
|
||||||
import com.gh.common.util.CommentUtils
|
import com.gh.common.util.CommentUtils
|
||||||
import com.gh.gamecenter.common.constant.RouteConsts
|
import com.gh.gamecenter.common.constant.RouteConsts
|
||||||
import com.gh.gamecenter.feature.provider.ICommentUtilsProvider
|
import com.gh.gamecenter.feature.provider.ICommentUtilsProvider
|
||||||
|
|
||||||
@com.therouter.inject.ServiceProvider
|
@Route(path = RouteConsts.provider.commentUtils, name = "CommentUtils暴露服务")
|
||||||
class CommentUtilsProviderImpl : ICommentUtilsProvider {
|
class CommentUtilsProviderImpl : ICommentUtilsProvider {
|
||||||
override fun setCommentTime(textView: TextView, time: Long) {
|
override fun setCommentTime(textView: TextView, time: Long) {
|
||||||
CommentUtils.setCommentTime(textView, time)
|
CommentUtils.setCommentTime(textView, time)
|
||||||
@ -16,4 +16,8 @@ class CommentUtilsProviderImpl : ICommentUtilsProvider {
|
|||||||
override fun getCommentTime(timestamp: Long): String {
|
override fun getCommentTime(timestamp: Long): String {
|
||||||
return CommentUtils.getCommentTime(timestamp)
|
return CommentUtils.getCommentTime(timestamp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun init(context: Context?) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user