Compare commits
228 Commits
delete
...
v5.29.0-93
| Author | SHA1 | Date | |
|---|---|---|---|
| 3a15f9af33 | |||
| 6920d682b2 | |||
| b0493502e4 | |||
| 723202d4ce | |||
| 6e0628b478 | |||
| 7f14555886 | |||
| c2477d2a3f | |||
| 8ff4945cfa | |||
| fcc65fdbfe | |||
| d4b0ecce98 | |||
| 848ca0b5c6 | |||
| 4f0c81420e | |||
| 0c437d32bd | |||
| 25d9771a3c | |||
| 668b54ac6d | |||
| 92b0f8fe73 | |||
| f689dfce07 | |||
| 42d5d46e53 | |||
| cdccc35703 | |||
| d3e2fea019 | |||
| f343841233 | |||
| f62083eff2 | |||
| 8594e998c2 | |||
| 6865706b0f | |||
| bfb8b46ce8 | |||
| b6d8ca4d84 | |||
| 455e1f0432 | |||
| ba27c09096 | |||
| 15276cc4b3 | |||
| 130a7cdf2a | |||
| 164ec0c368 | |||
| 756bc66f26 | |||
| e589bce5c6 | |||
| 991bd22511 | |||
| df1ab5221d | |||
| 70916fd0f7 | |||
| 226d6c4f2c | |||
| 896adc9d36 | |||
| 0e33abebdd | |||
| c8ed126605 | |||
| b510a329b6 | |||
| 2de1ba4e1d | |||
| e4a0f0e68b | |||
| c064f9d3a6 | |||
| 759401d9ae | |||
| e56209d15e | |||
| c466ff1f21 | |||
| e09cf299f0 | |||
| 25352ba609 | |||
| 3cd065cb6e | |||
| 5a483bb5db | |||
| 3b380c6fe3 | |||
| 919a98ffe6 | |||
| eff84218a8 | |||
| 7c9c363422 | |||
| add6448f44 | |||
| efccfaaa7f | |||
| a61057ae10 | |||
| 9472cafe48 | |||
| be83e1a2b4 | |||
| e48d7745b4 | |||
| 8b1a38214c | |||
| 2acde0af00 | |||
| daab20424e | |||
| 63f2adade2 | |||
| 201c1207f9 | |||
| 75d86b5a91 | |||
| f30d647936 | |||
| c7dd449899 | |||
| 0e9f7feff9 | |||
| 3697cd720e | |||
| 07a3c06804 | |||
| 2fce492689 | |||
| d87d12e1ec | |||
| a595730c50 | |||
| 7976355e34 | |||
| a9097793ac | |||
| 86e4ddd3f7 | |||
| b9abf2009d | |||
| a7dfd6c16c | |||
| 07dcb4aca2 | |||
| 48123ff991 | |||
| 8312d8e5fe | |||
| 98b4901d55 | |||
| a6a411f2e3 | |||
| 59976dcccd | |||
| e22a3ddcdb | |||
| ecfd133ce2 | |||
| d13ef56eb8 | |||
| 66f2d1df99 | |||
| 8555673d71 | |||
| cfe4c243e6 | |||
| c999ddf914 | |||
| f9004bf884 | |||
| 7794ef4acf | |||
| 1ef9c1fc23 | |||
| 1b1b753feb | |||
| 2561767b9a | |||
| 8bda0e178e | |||
| f634d60605 | |||
| 1dcc7654e8 | |||
| 3579b9d808 | |||
| c74663c082 | |||
| 848d352c60 | |||
| 5176766b29 | |||
| 0a90a7ddd9 | |||
| 27ca5073d7 | |||
| e3eb8178a3 | |||
| 10104812d6 | |||
| 12cb9a4883 | |||
| a30cc8c273 | |||
| 0f0620586b | |||
| b9e86dd67a | |||
| 9ce793d47e | |||
| 43cb18d6e0 | |||
| 1e87610899 | |||
| d04d486425 | |||
| 843aa4d1c8 | |||
| 1745ac91b7 | |||
| 20bc4a0dc8 | |||
| 1105f1b92a | |||
| 53f00f00d3 | |||
| b66827e216 | |||
| 485c34d402 | |||
| 330bcd72d7 | |||
| b04231772b | |||
| ec1bbdc7d5 | |||
| c685a02653 | |||
| 6594bf14df | |||
| 5a4f19dd8a | |||
| b54be8cb79 | |||
| 655380d547 | |||
| da3948228f | |||
| 5c03119c32 | |||
| 2a496b680b | |||
| db535cf281 | |||
| c199582efc | |||
| b53677a118 | |||
| 76ba3a5938 | |||
| db596a6c75 | |||
| 043f3c5d17 | |||
| 68006dda38 | |||
| b5cab193be | |||
| 6f2692296c | |||
| 0bb7a53046 | |||
| 25fe362912 | |||
| 6749d94c34 | |||
| 51f5ea1cd9 | |||
| 50a6d5e204 | |||
| 044e5646ec | |||
| 0ebf3d191d | |||
| bb81d91fd5 | |||
| 7442da80e0 | |||
| 96c28907ec | |||
| e9e7c2043e | |||
| eb5c55f046 | |||
| 8f2a1ecaa1 | |||
| 8dbe9c5772 | |||
| 6c911e09d3 | |||
| df557099ec | |||
| fedc91d37e | |||
| 27484a8306 | |||
| 42193d222a | |||
| 0a433566b1 | |||
| ff02ccd839 | |||
| d1cc0853d4 | |||
| 51eb814a42 | |||
| 6534c17cc0 | |||
| 749a76a09e | |||
| 0f59f79495 | |||
| af66a967b5 | |||
| 9a9095bcf0 | |||
| 225f2becf3 | |||
| a502fb64cb | |||
| 724fe8142c | |||
| dee5a0822d | |||
| e826346ca9 | |||
| 06b43cde77 | |||
| ae5edad87b | |||
| c8916f5f33 | |||
| 04cca95435 | |||
| 1bd3d8b044 | |||
| 4e79466cca | |||
| 88093d0a8e | |||
| 26adcc48f8 | |||
| e94e86d901 | |||
| 73355a4103 | |||
| 794377fdad | |||
| 1bff098369 | |||
| 45c7638dee | |||
| 4c57092300 | |||
| 1ddf9a667e | |||
| 84972e7ba7 | |||
| 03692ad753 | |||
| bb138fa25f | |||
| c5024e670a | |||
| fe5c92e988 | |||
| 9b31bf4164 | |||
| c670ab722f | |||
| fd4f3c25e7 | |||
| a14ea3708a | |||
| c003240f16 | |||
| 891e3d93fb | |||
| af5ec74b9e | |||
| d2c4483455 | |||
| 3a156aa8c1 | |||
| 60bd3ee9b2 | |||
| dacda1a858 | |||
| 265b5f6b57 | |||
| b4bd6f250b | |||
| 0f3ae5f085 | |||
| 3ab6cc202e | |||
| 7a154bc130 | |||
| 7cd6f2b0f4 | |||
| 8db2519f61 | |||
| 6b2902a73b | |||
| df7618bbda | |||
| 246983a097 | |||
| ca6146ad9a | |||
| c647320abc | |||
| afd738454e | |||
| 134cb327ec | |||
| f50ce741ae | |||
| 4547ba969e | |||
| 0a4af78ac8 | |||
| d38e1d1637 | |||
| 0d3456cf97 | |||
| f56529aa5b |
@ -71,8 +71,7 @@ android_build:
|
||||
exit_codes: 137
|
||||
only:
|
||||
- dev
|
||||
- dev-5.26.0
|
||||
- dev-5.27.0
|
||||
- dev-5.29.0
|
||||
|
||||
# 代码检查
|
||||
sonarqube_analysis:
|
||||
@ -103,8 +102,7 @@ sonarqube_analysis:
|
||||
exit_codes: 137
|
||||
only:
|
||||
- dev
|
||||
- dev-5.26.0
|
||||
- dev-5.27.0
|
||||
- dev-5.29.0
|
||||
|
||||
## 发送简易检测结果报告
|
||||
send_sonar_report:
|
||||
@ -122,8 +120,7 @@ send_sonar_report:
|
||||
exit_codes: 137
|
||||
only:
|
||||
- dev
|
||||
- dev-5.26.0
|
||||
- dev-5.27.0
|
||||
- dev-5.29.0
|
||||
|
||||
oss-upload&send-email:
|
||||
tags:
|
||||
@ -155,5 +152,4 @@ oss-upload&send-email:
|
||||
- /usr/local/bin/python /ci-android-mail.py
|
||||
only:
|
||||
- dev
|
||||
- dev-5.26.0
|
||||
- dev-5.27.0
|
||||
- dev-5.29.0
|
||||
@ -11,7 +11,10 @@ android {
|
||||
|
||||
String CONFIG_ID = ""
|
||||
String FIRST_LAUNCH = ""
|
||||
int ACTIVATE_REPORTING_RATIO = 0
|
||||
String SDK_VERSION = ""
|
||||
String SDK_APP_ID = ""
|
||||
String SDK_APP_NAME = ""
|
||||
int ACTIVATE_REPORTING_RATIO = 100
|
||||
|
||||
buildFeatures {
|
||||
viewBinding true
|
||||
@ -71,9 +74,19 @@ android {
|
||||
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt', 'proguard-fresco.txt'
|
||||
|
||||
String CORE_EVENT_GAME_CATEGORY = ""
|
||||
|
||||
// 推广用的关键事件游戏类型
|
||||
buildConfigField "String", "CORE_EVENT_GAME_CATEGORY", "\"${CORE_EVENT_GAME_CATEGORY}\""
|
||||
|
||||
// 推广用的配置 id
|
||||
buildConfigField "String", "CONFIG_ID", "\"${CONFIG_ID}\""
|
||||
|
||||
// 推广用的 SDK 版本 (仅记录使用)
|
||||
buildConfigField "String", "SDK_VERSION", "\"${SDK_VERSION}\""
|
||||
buildConfigField "String", "SDK_APP_ID", "\"${SDK_APP_ID}\""
|
||||
buildConfigField "String", "SDK_APP_NAME", "\"${SDK_APP_NAME}\""
|
||||
|
||||
// 首次启动的跳转配置
|
||||
buildConfigField "String", "FIRST_LAUNCH", "\"${FIRST_LAUNCH}\""
|
||||
|
||||
@ -201,17 +214,11 @@ android {
|
||||
kuaishou {
|
||||
dimension "env"
|
||||
|
||||
String KUAI_SHOU_APP_ID = ""
|
||||
String KUAI_SHOU_APP_NAME = ""
|
||||
|
||||
buildConfigField "String", "DEV_API_HOST", "\"${API_HOST}\""
|
||||
buildConfigField "String", "NEW_DEV_API_HOST", "\"${NEW_API_HOST}\""
|
||||
buildConfigField "String", "DEV_VAPI_HOST", "\"${VAPI_HOST}\""
|
||||
buildConfigField "String", "QUICK_LOGIN_APPID", "\"${QUICK_LOGIN_APPID}\""
|
||||
buildConfigField "String", "QUICK_LOGIN_APPKEY", "\"${QUICK_LOGIN_APPKEY}\""
|
||||
|
||||
buildConfigField "String", "KUAI_SHOU_APP_ID", "\"${KUAI_SHOU_APP_ID}\""
|
||||
buildConfigField "String", "KUAI_SHOU_APP_NAME", "\"${KUAI_SHOU_APP_NAME}\""
|
||||
}
|
||||
|
||||
gdt {
|
||||
@ -334,6 +341,7 @@ dependencies {
|
||||
implementation(project(':feature:oaid'))
|
||||
implementation(project(':feature:floating-window'))
|
||||
implementation(project(':feature:beizi_startup_ad'))
|
||||
implementation(project(':feature:xapk-installer'))
|
||||
}
|
||||
|
||||
File propFile = file('sign.properties')
|
||||
|
||||
@ -20,12 +20,13 @@
|
||||
-keep class com.gh.gamecenter.db.info.* {*;}
|
||||
-keep class com.gh.gamecenter.entity.** {<fields>;}
|
||||
-keep class com.gh.gamecenter.qa.entity.** {<fields>;}
|
||||
-keep class com.gh.download.DownloadDataSimpleEntity {<fields>;}
|
||||
-keep class com.gh.gamecenter.floatingwindow.FloatingWindowEntity {<fields>;}
|
||||
-keep class com.gh.gamecenter.BR
|
||||
-keep class com.gh.gamecenter.retrofit.* {*;}
|
||||
-keep class com.gh.gamecenter.eventbus.* {*;}
|
||||
-keep class com.gh.gamecenter.home.gamecollection.GameCollectionStackLayout {*;}
|
||||
-keep class com.gh.gamecenter.home.gamecollection.GameCollectionStackAnimation {*;}
|
||||
-keep class com.gh.gamecenter.home.gamecollection.carousel.GameCollectionStackLayout {*;}
|
||||
-keep class com.gh.gamecenter.home.gamecollection.carousel.GameCollectionStackAnimation {*;}
|
||||
|
||||
# Prevent R8 from leaving Data object members always null
|
||||
-keepclassmembers,allowobfuscation class * {
|
||||
|
||||
@ -33,4 +33,8 @@ class FlavorProviderImp : IFlavorProvider {
|
||||
override fun logEvent(content: String) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
override fun logCoreEvent() {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
@ -42,6 +42,10 @@ class FlavorProviderImp : IFlavorProvider {
|
||||
GdtHelper.logAction(content)
|
||||
}
|
||||
|
||||
override fun logCoreEvent() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val GDT_DEFAULT_CHANNEL = "GDT_GHZS_01"
|
||||
}
|
||||
|
||||
@ -5,8 +5,8 @@ import com.kwai.monitor.log.TurboAgent
|
||||
import com.kwai.monitor.log.TurboConfig
|
||||
|
||||
object KuaishouHelper {
|
||||
private val mAppId by lazy { BuildConfig.KUAI_SHOU_APP_ID.ifEmpty { "81537" } }
|
||||
private val mAppName by lazy { BuildConfig.KUAI_SHOU_APP_NAME.ifEmpty { "guanghuanzhushou_1" } }
|
||||
private val mAppId by lazy { BuildConfig.SDK_APP_ID.ifEmpty { "81537" } }
|
||||
private val mAppName by lazy { BuildConfig.SDK_APP_NAME.ifEmpty { "guanghuanzhushou_1" } }
|
||||
|
||||
@JvmStatic
|
||||
fun init(context: Context, channel: String) {
|
||||
|
||||
@ -3,10 +3,13 @@ package com.gh.gamecenter.provider
|
||||
import android.app.Activity
|
||||
import android.app.Application
|
||||
import android.text.TextUtils
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.gh.gamecenter.KuaishouHelper
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.core.provider.IFlavorProvider
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.core.utils.TimeUtils
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.kwai.monitor.payload.TurboHelper
|
||||
|
||||
@ -42,6 +45,15 @@ class FlavorProviderImp : IFlavorProvider {
|
||||
KuaishouHelper.onEvent(content)
|
||||
}
|
||||
|
||||
override fun logCoreEvent() {
|
||||
logEvent("EVENT_KEY_PATH_OPTIMIZATION")
|
||||
if (BuildConfig.ACTIVATE_REPORTING_RATIO == 1) {
|
||||
AppExecutor.uiExecutor.executeWithDelay({
|
||||
ToastUtils.toast("关键行为 EVENT_KEY_PATH_OPTIMIZATION")
|
||||
}, 500)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val KUAISHOU_CHANNEL = "KS-GHZS-01"
|
||||
}
|
||||
|
||||
@ -106,8 +106,8 @@
|
||||
android:icon="@mipmap/logo"
|
||||
android:label="@string/app_name"
|
||||
android:largeHeap="true"
|
||||
android:resizeableActivity="true"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:resizeableActivity="true"
|
||||
android:theme="@style/AppCompatTheme.APP"
|
||||
tools:replace="android:name,android:allowBackup"
|
||||
tools:targetApi="n">
|
||||
@ -756,6 +756,10 @@
|
||||
android:name=".servers.gametest2.GameServerTestV2Activity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.gamecollection.hotlist.GameCollectionHotListActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
|
||||
<!-- <activity-->
|
||||
<!-- android:name="${applicationId}.douyinapi.DouYinEntryActivity"-->
|
||||
@ -826,6 +830,11 @@
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<activity
|
||||
android:name="com.gh.common.xapk.XapkInstallReceiver"
|
||||
android:theme="@style/Theme.Transparent"
|
||||
android:exported="false" />
|
||||
|
||||
<receiver
|
||||
android:name="com.gh.gamecenter.receiver.ActivitySkipReceiver"
|
||||
android:exported="true">
|
||||
|
||||
1
app/src/main/assets/lottie/icon_fab_change.json
Normal file
1
app/src/main/assets/lottie/icon_fab_change.json
Normal file
@ -0,0 +1 @@
|
||||
{"v":"5.9.1","fr":60,"ip":0,"op":60,"w":144,"h":144,"nm":"icon_change","ddd":0,"assets":[{"id":"comp_0","nm":"icon_change_detail","fr":60,"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"stroke1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[37.04,52.994,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-0.533,-0.143],[0.143,-0.533],[1.487,-1.304],[1.961,-0.258],[1.774,0.875],[0.709,0.661],[0,0],[0,0.445],[0,0],[-0.276,0],[0,0],[-0.013,0],[0,0],[0.315,-0.315],[0,0],[-0.682,-0.336],[-1.569,0.207],[-1.19,1.043],[-0.41,1.528]],"o":[[0.533,0.143],[-0.512,1.91],[-1.487,1.304],[-1.961,0.258],[-0.879,-0.433],[0,0],[-0.315,0.315],[0,0],[0,-0.276],[0,0],[0.013,0],[0,0],[0.445,0],[0,0],[0.555,0.508],[1.419,0.7],[1.569,-0.207],[1.19,-1.043],[0.143,-0.533]],"v":[[8.605,-4.301],[9.312,-3.076],[6.247,1.854],[0.958,4.25],[-4.77,3.304],[-7.163,1.652],[-8.493,2.982],[-9.347,2.628],[-9.347,-1.665],[-8.847,-2.165],[-8.161,-2.165],[-8.122,-2.165],[-4.554,-2.165],[-4.2,-1.311],[-5.748,0.237],[-3.885,1.51],[0.697,2.267],[4.928,0.35],[7.381,-3.594]],"c":true},"ix":2},"nm":"stroke1","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,1,1,1,0.5,1,1,1,1,1,1,1,0,1,0.5,0.8,1,0.6],"ix":9}},"s":{"a":0,"k":[-5.347,-4.665],"ix":5},"e":{"a":0,"k":[8.653,-4.665],"ix":6},"t":1,"nm":"color1","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":"stroke1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":300,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"stroke2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[34.96,19.006,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-1.961,0.258],[-1.774,-0.875],[-0.709,-0.661],[0,0],[0,-0.445],[0,0],[0.276,0],[0,0],[0.012,0],[0,0],[-0.315,0.315],[0,0],[0.682,0.336],[1.569,-0.207],[1.19,-1.043],[0.41,-1.528],[0.533,0.143],[-0.143,0.533],[-1.487,1.304]],"o":[[1.961,-0.258],[0.879,0.433],[0,0],[0.315,-0.315],[0,0],[0,0.276],[0,0],[-0.012,0],[0,0],[-0.445,0],[0,0],[-0.555,-0.508],[-1.419,-0.7],[-1.569,0.207],[-1.19,1.043],[-0.143,0.533],[-0.533,-0.143],[0.512,-1.91],[1.487,-1.304]],"v":[[-0.958,-4.25],[4.77,-3.304],[7.163,-1.652],[8.493,-2.982],[9.347,-2.628],[9.347,1.665],[8.847,2.165],[8.16,2.165],[8.123,2.165],[4.554,2.165],[4.2,1.311],[5.748,-0.237],[3.885,-1.51],[-0.697,-2.267],[-4.928,-0.35],[-7.381,3.594],[-8.605,4.301],[-9.312,3.076],[-6.247,-1.854]],"c":true},"ix":2},"nm":"stroke2","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,1,1,1,0.5,1,1,1,1,1,1,1,0,1,0.5,0.8,1,0.6],"ix":9}},"s":{"a":0,"k":[5.347,4.665],"ix":5},"e":{"a":0,"k":[-8.653,4.665],"ix":6},"t":1,"nm":"color2","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":"stroke2","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":300,"st":0,"bm":0}]}],"layers":[{"ddd":0,"ind":1,"ty":0,"nm":"icon_change_detail","refId":"comp_0","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.5],"y":[1]},"o":{"x":[0.5],"y":[0]},"t":0,"s":[0]},{"t":36,"s":[360]}],"ix":10},"p":{"a":0,"k":[72,72,0],"ix":2,"l":2},"a":{"a":0,"k":[36,36,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"w":72,"h":72,"ip":0,"op":300,"st":0,"bm":0}],"markers":[]}
|
||||
1
app/src/main/assets/lottie/icon_title_change_dark.json
Normal file
1
app/src/main/assets/lottie/icon_title_change_dark.json
Normal file
@ -0,0 +1 @@
|
||||
{"v":"5.9.1","fr":60,"ip":0,"op":60,"w":72,"h":72,"nm":"icon_title_change","ddd":0,"assets":[{"id":"comp_0","nm":"arrow","fr":60,"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"arrow_e_dark","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[29.25,30,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-1.701,0.456],[-1.627,-0.674],[-0.705,-0.667],[0,0],[-0.552,0],[0,-0.552],[0,0],[0.552,0],[0,0],[0.012,0],[0,0],[0,0.552],[-0.552,0],[0,0],[0.615,0.255],[1.276,-0.342],[0.804,-1.048],[0,-1.321],[-0.804,-1.048],[-1.276,-0.342],[-1.22,0.505],[-0.66,1.144],[-0.478,-0.276],[0.276,-0.478],[1.627,-0.674],[1.701,0.456],[1.072,1.397],[0,1.761],[-1.072,1.397]],"o":[[1.701,-0.456],[0.909,0.376],[0,0],[0,-0.552],[0.552,0],[0,0],[0,0.552],[0,0],[-0.012,0],[0,0],[-0.552,0],[0,-0.552],[0,0],[-0.493,-0.435],[-1.22,-0.505],[-1.276,0.342],[-0.804,1.048],[0,1.321],[0.804,1.048],[1.276,0.342],[1.22,-0.505],[0.276,-0.478],[0.478,0.276],[-0.881,1.525],[-1.627,0.674],[-1.701,-0.456],[-1.072,-1.397],[0,-1.761],[1.072,-1.397]],"v":[[-1.821,-7.727],[3.311,-7.391],[5.75,-5.809],[5.75,-6.5],[6.75,-7.5],[7.75,-6.5],[7.75,-3.5],[6.75,-2.5],[6.331,-2.5],[6.295,-2.5],[3.75,-2.5],[2.75,-3.5],[3.75,-4.5],[4.219,-4.5],[2.546,-5.543],[-1.303,-5.796],[-4.51,-3.653],[-5.75,0],[-4.51,3.653],[-1.303,5.796],[2.546,5.543],[5.446,3],[6.812,2.634],[7.178,4],[3.311,7.391],[-1.821,7.727],[-6.097,4.87],[-7.75,0],[-6.097,-4.87]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.158117651939,0.532358944416,0.878431379795,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":"arrow_e_dark","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":300,"st":0,"bm":0}]}],"layers":[{"ddd":0,"ind":1,"ty":0,"nm":"arrow","refId":"comp_0","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.5],"y":[1]},"o":{"x":[0.5],"y":[0]},"t":0,"s":[0]},{"t":36,"s":[360]}],"ix":10},"p":{"a":0,"k":[36,36,0],"ix":2,"l":2},"a":{"a":0,"k":[30,30,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"w":60,"h":60,"ip":0,"op":300,"st":0,"bm":0}],"markers":[]}
|
||||
1
app/src/main/assets/lottie/icon_title_change_light.json
Normal file
1
app/src/main/assets/lottie/icon_title_change_light.json
Normal file
@ -0,0 +1 @@
|
||||
{"v":"5.9.1","fr":60,"ip":0,"op":60,"w":72,"h":72,"nm":"icon_title_change","ddd":0,"assets":[{"id":"comp_0","nm":"arrow","fr":60,"layers":[{"ddd":0,"ind":2,"ty":4,"nm":"arrow_e_light","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[29.25,30,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-1.701,0.456],[-1.627,-0.674],[-0.705,-0.667],[0,0],[-0.552,0],[0,-0.552],[0,0],[0.552,0],[0,0],[0.012,0],[0,0],[0,0.552],[-0.552,0],[0,0],[0.615,0.255],[1.276,-0.342],[0.804,-1.048],[0,-1.321],[-0.804,-1.048],[-1.276,-0.342],[-1.22,0.505],[-0.66,1.144],[-0.478,-0.276],[0.276,-0.478],[1.627,-0.674],[1.701,0.456],[1.072,1.397],[0,1.761],[-1.072,1.397]],"o":[[1.701,-0.456],[0.909,0.376],[0,0],[0,-0.552],[0.552,0],[0,0],[0,0.552],[0,0],[-0.012,0],[0,0],[-0.552,0],[0,-0.552],[0,0],[-0.493,-0.435],[-1.22,-0.505],[-1.276,0.342],[-0.804,1.048],[0,1.321],[0.804,1.048],[1.276,0.342],[1.22,-0.505],[0.276,-0.478],[0.478,0.276],[-0.881,1.525],[-1.627,0.674],[-1.701,-0.456],[-1.072,-1.397],[0,-1.761],[1.072,-1.397]],"v":[[-1.821,-7.727],[3.311,-7.391],[5.75,-5.809],[5.75,-6.5],[6.75,-7.5],[7.75,-6.5],[7.75,-3.5],[6.75,-2.5],[6.331,-2.5],[6.295,-2.5],[3.75,-2.5],[2.75,-3.5],[3.75,-4.5],[4.219,-4.5],[2.546,-5.543],[-1.303,-5.796],[-4.51,-3.653],[-5.75,0],[-4.51,3.653],[-1.303,5.796],[2.546,5.543],[5.446,3],[6.812,2.634],[7.178,4],[3.311,7.391],[-1.821,7.727],[-6.097,4.87],[-7.75,0],[-6.097,-4.87]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.141176477075,0.588235318661,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":"arrow_e_light","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":300,"st":0,"bm":0}]}],"layers":[{"ddd":0,"ind":1,"ty":0,"nm":"arrow","refId":"comp_0","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.5],"y":[1]},"o":{"x":[0.5],"y":[0]},"t":0,"s":[0]},{"t":36,"s":[360]}],"ix":10},"p":{"a":0,"k":[36,36,0],"ix":2,"l":2},"a":{"a":0,"k":[30,30,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"w":60,"h":60,"ip":0,"op":300,"st":0,"bm":0}],"markers":[]}
|
||||
@ -5,6 +5,7 @@ import android.app.Application
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.gh.common.util.FloatingBackViewManager
|
||||
import com.gh.common.xapk.XapkInstaller
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.SingletonWebActivity
|
||||
import com.gh.gamecenter.SkipActivity
|
||||
@ -61,6 +62,8 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
||||
) {
|
||||
VHelper.showFeedbackDialogIfLastSuccessfulLaunchedGameExitUnexpectedly(activity)
|
||||
}
|
||||
|
||||
XapkInstaller.updateCurrentInstallStatus()
|
||||
}
|
||||
|
||||
override fun onActivityPaused(activity: Activity) {
|
||||
|
||||
@ -12,6 +12,7 @@ import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.gh.common.exposure.ExposureManager
|
||||
import com.gh.common.util.*
|
||||
import com.gh.common.util.LogUtils
|
||||
import com.gh.download.DownloadManager
|
||||
@ -37,6 +38,8 @@ import com.gh.gamecenter.eventbus.EBDownloadStatus
|
||||
import com.gh.gamecenter.eventbus.EBPackage
|
||||
import com.gh.gamecenter.feature.entity.Badge
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.gh.gamecenter.feature.exposure.ExposureSource
|
||||
import com.gh.gamecenter.login.user.LoginTag
|
||||
import com.gh.gamecenter.login.user.UserManager
|
||||
import com.gh.gamecenter.login.user.UserRepository
|
||||
@ -71,6 +74,7 @@ class DefaultJsApi(
|
||||
private var mDownloadWatcher: DataWatcher? = null // 下载观察者
|
||||
private var mDownloadUrlSet: HashSet<String>? = null // 下载的 url 集合
|
||||
private var mDownloadHandler: CompletionHandler<Any>? = null // 下载信息回调
|
||||
private var mExposureEvent: ExposureEvent? = null // 活动曝光实体
|
||||
|
||||
init {
|
||||
if (mFragment != null) {
|
||||
@ -213,7 +217,7 @@ class DefaultJsApi(
|
||||
VHelper.launch(context, packageName)
|
||||
}
|
||||
} else {
|
||||
PackageUtils.launchApplicationByPackageName(context, packageName)
|
||||
PackageLauncher.launchApp(context, packageName = packageName)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -624,6 +628,26 @@ class DefaultJsApi(
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun logExposure(event: Any) {
|
||||
val simpleExposureEvent = event.toString().toObject() ?: SimpleExposureEvent()
|
||||
if (simpleExposureEvent.id.isNotEmpty()) {
|
||||
val exposureSource = ExposureSource("游戏活动", "${simpleExposureEvent.title}+${simpleExposureEvent.id}")
|
||||
mExposureEvent = ExposureEvent.createEvent(
|
||||
gameEntity = null,
|
||||
source = arrayListOf(exposureSource),
|
||||
)
|
||||
ExposureManager.log(mExposureEvent!!)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 ExposureEvent,可能为空
|
||||
*/
|
||||
fun getExposureEvent(): ExposureEvent? {
|
||||
return mExposureEvent
|
||||
}
|
||||
|
||||
private fun autoUnregisterDownloadObserverIfNeeded(fragment: Fragment?) {
|
||||
fragment?.parentFragmentManager?.registerFragmentLifecycleCallbacks(
|
||||
object : FragmentManager.FragmentLifecycleCallbacks() {
|
||||
@ -676,6 +700,9 @@ class DefaultJsApi(
|
||||
@Keep
|
||||
internal class TextShareEvent(var text: String = "", var type: String = "")
|
||||
|
||||
@Keep
|
||||
internal class SimpleExposureEvent(var title: String = "", var id: String = "")
|
||||
|
||||
@Keep
|
||||
internal class InviteFriendsEvent(
|
||||
var type: String = "",
|
||||
|
||||
@ -36,6 +36,7 @@ import com.gh.gamecenter.entity.SubjectRecommendEntity
|
||||
import com.gh.gamecenter.entity.VideoLinkEntity
|
||||
import com.gh.gamecenter.eventbus.EBSkip
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.gh.gamecenter.feature.utils.PlatformUtils
|
||||
import com.gh.gamecenter.fragment.MainWrapperFragment
|
||||
import com.gh.gamecenter.gamecollection.publish.GameCollectionEditActivity
|
||||
@ -51,14 +52,21 @@ object DefaultUrlHandler {
|
||||
|
||||
@JvmStatic
|
||||
fun interceptUrl(context: Context, url: String, entrance: String): Boolean {
|
||||
return interceptUrl(context, url, entrance, false)
|
||||
return interceptUrl(context, url, null, entrance, false)
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查并拦截部分内部处理的 url
|
||||
* @param traceEvent 供一些页面用于登记曝光来源的实体
|
||||
* @param bringAppToFront 是否需要在不匹配 host 的时候把 APP 调回到前台 (如微信调起)
|
||||
*
|
||||
* @return 是否已拦截处理
|
||||
*/
|
||||
@JvmStatic
|
||||
fun interceptUrl(context: Context, url: String, entrance: String, bringAppToFront: Boolean = false): Boolean {
|
||||
fun interceptUrl(context: Context, url: String,
|
||||
traceEvent: ExposureEvent? = null,
|
||||
entrance: String,
|
||||
bringAppToFront: Boolean = false): Boolean {
|
||||
val uri = Uri.parse(url)
|
||||
if ("ghzhushou" == uri.scheme) {
|
||||
Utils.log("url = $url")
|
||||
@ -82,6 +90,7 @@ object DefaultUrlHandler {
|
||||
id = id,
|
||||
tab = uri.getQueryParameter("to"),
|
||||
autoDownload = uri.getQueryParameter("auto_download") == "true",
|
||||
traceEvent = traceEvent,
|
||||
entrance = entrance
|
||||
)
|
||||
|
||||
@ -90,6 +99,7 @@ object DefaultUrlHandler {
|
||||
id,
|
||||
uri.getQueryParameter("name"),
|
||||
false,
|
||||
null,
|
||||
entrance
|
||||
)
|
||||
|
||||
@ -467,7 +477,7 @@ object DefaultUrlHandler {
|
||||
}
|
||||
|
||||
EntranceConsts.HOST_GAME_COLLECTION_DETAIL -> {
|
||||
DirectUtils.directToGameCollectionDetail(context, id, entrance)
|
||||
DirectUtils.directToGameCollectionDetail(context, id, entrance, traceEvent = traceEvent)
|
||||
}
|
||||
|
||||
EntranceConsts.HOST_GAME_COLLECTION_SQUARE -> {
|
||||
|
||||
@ -20,7 +20,7 @@ object FixedRateJobHelper {
|
||||
private const val CHECKER_PERIOD: Long = 15 * 1000L
|
||||
private const val TIME_PERIOD: Long = 10 * 60 * 1000L
|
||||
private const val LOGHUB_PERIOD: Long = 2 * 60 * 1000L
|
||||
private const val EXPOSURE_PERIOD: Long = 5 * 60 * 1000L
|
||||
private const val EXPOSURE_PERIOD: Long = 1 * 60 * 1000L
|
||||
private const val REGION_SETTING_PERIOD: Long = 60 * 1000L
|
||||
private const val VIDEO_RECORD_PERIOD: Long = 60 * 1000L
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.gh.common.chain
|
||||
|
||||
import android.content.Context
|
||||
import com.gh.common.xapk.XapkInstaller
|
||||
import com.gh.download.server.BrowserInstallHelper
|
||||
import com.gh.gamecenter.core.utils.EmptyCallback
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
@ -8,14 +9,15 @@ import com.gh.gamecenter.feature.entity.GameEntity
|
||||
class BrowserInstallHandler : ChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity) {
|
||||
BrowserInstallHelper.showBrowserInstallHintDialog(context, gameEntity.isVGame(), object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
} else {
|
||||
processEndCallback?.invoke(null)
|
||||
}
|
||||
BrowserInstallHelper.showBrowserInstallHintDialog(
|
||||
context,
|
||||
gameEntity.isVGame() || gameEntity.isSplitXApk()
|
||||
) {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
} else {
|
||||
processEndCallback?.invoke(null)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package com.gh.common.chain
|
||||
|
||||
import android.content.Context
|
||||
import com.gh.gamecenter.common.utils.DialogHelper
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
|
||||
class UnsupportedFeatureHandler : ChainHandler() {
|
||||
|
||||
override fun handleRequest(
|
||||
context: Context, gameEntity: GameEntity
|
||||
) {
|
||||
if (shouldShowUnsupportedFeatureDialog()) {
|
||||
DialogHelper.showUnsupportedFeatureDialog(context)
|
||||
} else {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
} else {
|
||||
processEndCallback?.invoke(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO 检查某个版本是否支持指定的功能
|
||||
*/
|
||||
private fun shouldShowUnsupportedFeatureDialog(): Boolean = false
|
||||
}
|
||||
@ -205,9 +205,6 @@ public class Config {
|
||||
|
||||
// 加载完设置后刷新下
|
||||
PackageHelper.initList();
|
||||
|
||||
// 初始化畅玩相关的东西
|
||||
VHelper.init(HaloApp.getInstance());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -308,6 +305,26 @@ public class Config {
|
||||
return mVSetting;
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求网络数据,尝试刷新畅玩相关配置
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
public static void refreshVSettingEntity() {
|
||||
RetrofitManager.getInstance()
|
||||
.getVApi().getSettings(BuildConfig.VERSION_NAME, Build.VERSION.SDK_INT)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BiResponse<VSetting>() {
|
||||
@Override
|
||||
public void onSuccess(VSetting data) {
|
||||
mVSetting = data;
|
||||
SPUtils.setString(Constants.SP_V_SETTINGS, GsonUtils.toJson(data));
|
||||
|
||||
VHelper.init(HaloApp.getInstance());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static GameGuidePopupEntity getGameGuidePopupEntity() {
|
||||
return mGameGuidePopupEntity;
|
||||
@ -385,16 +402,7 @@ public class Config {
|
||||
}
|
||||
});
|
||||
|
||||
RetrofitManager.getInstance()
|
||||
.getVApi().getSettings(BuildConfig.VERSION_NAME)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(new BiResponse<VSetting>() {
|
||||
@Override
|
||||
public void onSuccess(VSetting data) {
|
||||
mVSetting = data;
|
||||
SPUtils.setString(Constants.SP_V_SETTINGS, GsonUtils.toJson(data));
|
||||
}
|
||||
});
|
||||
refreshVSettingEntity();
|
||||
|
||||
RetrofitManager.getInstance()
|
||||
.getApi().getGameGuidePopup(Build.MANUFACTURER, Build.VERSION.RELEASE, Build.MODEL, channel, BuildConfig.VERSION_NAME)
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.gh.common.databind;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
@ -29,6 +30,7 @@ import com.gh.common.chain.DownloadDialogHelperHandler;
|
||||
import com.gh.common.chain.GamePermissionHandler;
|
||||
import com.gh.common.chain.OverseaDownloadHandler;
|
||||
import com.gh.common.chain.PackageCheckHandler;
|
||||
import com.gh.common.chain.UnsupportedFeatureHandler;
|
||||
import com.gh.common.chain.ValidateVSpaceHandler;
|
||||
import com.gh.common.chain.VersionNumberHandler;
|
||||
import com.gh.common.constant.Config;
|
||||
@ -45,10 +47,12 @@ import com.gh.common.util.GameViewUtils;
|
||||
import com.gh.common.util.LogUtils;
|
||||
import com.gh.common.util.NewsUtils;
|
||||
import com.gh.common.util.PackageInstaller;
|
||||
import com.gh.common.util.PackageLauncher;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.ReservationHelper;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.download.dialog.DownloadDialog;
|
||||
import com.gh.download.server.BrowserInstallHelper;
|
||||
import com.gh.gamecenter.DownloadManagerActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.WebActivity;
|
||||
@ -63,6 +67,7 @@ import com.gh.gamecenter.common.view.DrawableView;
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils;
|
||||
import com.gh.gamecenter.core.utils.MtaHelper;
|
||||
import com.gh.gamecenter.core.utils.NumberUtils;
|
||||
import com.gh.gamecenter.core.utils.ToastUtils;
|
||||
import com.gh.gamecenter.databinding.KaifuDetailItemRowBinding;
|
||||
import com.gh.gamecenter.feature.entity.ApkEntity;
|
||||
import com.gh.gamecenter.feature.entity.CommunityVideoEntity;
|
||||
@ -398,6 +403,7 @@ public class BindingAdapters {
|
||||
}
|
||||
|
||||
ChainBuilder builder = new ChainBuilder();
|
||||
builder.addHandler(new UnsupportedFeatureHandler());
|
||||
builder.addHandler(new GamePermissionHandler());
|
||||
builder.addHandler(new CheckStoragePermissionHandler());
|
||||
builder.addHandler(new ValidateVSpaceHandler());
|
||||
@ -410,7 +416,7 @@ public class BindingAdapters {
|
||||
builder.addHandler(new CheckDownloadHandler());
|
||||
|
||||
builder.setProcessEndCallback(o -> {
|
||||
download(progressBar, gameEntity, traceEvent, (boolean) o, entrance, location);
|
||||
download(v.getContext(), progressBar, gameEntity, traceEvent, (boolean) o, entrance, location);
|
||||
return null;
|
||||
});
|
||||
final ChainHandler chainHandler = builder.buildHandlerChain();
|
||||
@ -419,6 +425,7 @@ public class BindingAdapters {
|
||||
}
|
||||
} else {
|
||||
ChainBuilder builder = new ChainBuilder();
|
||||
builder.addHandler(new UnsupportedFeatureHandler());
|
||||
builder.addHandler(new GamePermissionHandler());
|
||||
builder.addHandler(new CertificationHandler());
|
||||
builder.addHandler(new VersionNumberHandler());
|
||||
@ -447,7 +454,7 @@ public class BindingAdapters {
|
||||
if (downloadEntity != null) {
|
||||
File file = new File(downloadEntity.getPath());
|
||||
if (!file.exists()) {
|
||||
download(progressBar, gameEntity, traceEvent, false, entrance, location);
|
||||
download(v.getContext(), progressBar, gameEntity, traceEvent, false, entrance, location);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -457,11 +464,11 @@ public class BindingAdapters {
|
||||
}
|
||||
|
||||
if (gameEntity.isVGame()) {
|
||||
VHelper.installOrLaunch((AppCompatActivity) v.getContext(), gameEntity);
|
||||
VHelper.installOrLaunch((AppCompatActivity) v.getContext(), gameEntity, null);
|
||||
return;
|
||||
}
|
||||
|
||||
PackageUtils.launchApplicationByPackageName(v.getContext(), gameEntity.getApk().get(0).getPackageName());
|
||||
PackageLauncher.launchApp(v.getContext(), gameEntity, gameEntity.getApk().get(0).getPackageName());
|
||||
} else {
|
||||
DownloadDialog.showDownloadDialog(
|
||||
v.getContext(),
|
||||
@ -477,7 +484,7 @@ public class BindingAdapters {
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity);
|
||||
|
||||
if (gameEntity.isVGame()) {
|
||||
VHelper.installOrLaunch(v.getContext(), gameEntity);
|
||||
VHelper.installOrLaunch(v.getContext(), gameEntity, null);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -673,12 +680,16 @@ public class BindingAdapters {
|
||||
|
||||
|
||||
// 开始下载
|
||||
private static void download(DownloadButton progressBar,
|
||||
private static void download(Context context,
|
||||
DownloadButton progressBar,
|
||||
GameEntity gameEntity,
|
||||
ExposureEvent traceEvent,
|
||||
boolean isSubscribe,
|
||||
String entrance,
|
||||
String location) {
|
||||
if (BrowserInstallHelper.shouldAutoSwitchAssistantInstall(gameEntity)) {
|
||||
ToastUtils.toast(context.getString(R.string.unsupported_browser_install_hint));
|
||||
}
|
||||
String str = progressBar.getText().toString();
|
||||
String method;
|
||||
if (str.contains("更新")) {
|
||||
|
||||
@ -4,6 +4,8 @@ import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.recyclerview.widget.RecyclerView.LayoutManager
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import io.reactivex.functions.Consumer
|
||||
|
||||
@ -18,7 +20,7 @@ class ExposureListener(var fragment: Fragment, var exposable: IExposable) : Recy
|
||||
Consumer(Throwable::printStackTrace)
|
||||
)
|
||||
}
|
||||
var layoutManager: LinearLayoutManager? = null
|
||||
var layoutManager: LayoutManager? = null
|
||||
var visibleState: ExposureThrottleBus.VisibleState? = null
|
||||
|
||||
init {
|
||||
@ -47,12 +49,28 @@ class ExposureListener(var fragment: Fragment, var exposable: IExposable) : Recy
|
||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||
super.onScrolled(recyclerView, dx, dy)
|
||||
|
||||
if (layoutManager == null) layoutManager = recyclerView.layoutManager as LinearLayoutManager
|
||||
layoutManager = recyclerView.layoutManager
|
||||
|
||||
layoutManager?.run {
|
||||
visibleState =
|
||||
ExposureThrottleBus.VisibleState(findFirstVisibleItemPosition(), findLastVisibleItemPosition())
|
||||
throttleBus.postVisibleState(visibleState!!)
|
||||
if (layoutManager != null) {
|
||||
if (layoutManager is LinearLayoutManager) {
|
||||
(layoutManager as LinearLayoutManager).run {
|
||||
visibleState =
|
||||
ExposureThrottleBus.VisibleState(findFirstVisibleItemPosition(), findLastVisibleItemPosition())
|
||||
throttleBus.postVisibleState(visibleState!!)
|
||||
}
|
||||
} else if (layoutManager is StaggeredGridLayoutManager) {
|
||||
(recyclerView.layoutManager as StaggeredGridLayoutManager).run {
|
||||
val firstVisibleItemArray = IntArray(2)
|
||||
val lastVisibleItemArray = IntArray(2)
|
||||
|
||||
findFirstVisibleItemPositions(firstVisibleItemArray)
|
||||
findLastVisibleItemPositions(lastVisibleItemArray)
|
||||
|
||||
visibleState =
|
||||
ExposureThrottleBus.VisibleState(firstVisibleItemArray.first(), lastVisibleItemArray.first())
|
||||
throttleBus.postVisibleState(visibleState!!)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ object ExposureManager {
|
||||
fun log(eventList: List<ExposureEvent>) {
|
||||
AppExecutor.logExecutor.execute {
|
||||
for (event in eventList) {
|
||||
if (!exposureCache.contains(event.id)) {
|
||||
if (event != null && !exposureCache.contains(event.id)) {
|
||||
exposureSet.add(event)
|
||||
exposureCache.add(event.id)
|
||||
} else {
|
||||
|
||||
@ -48,6 +48,7 @@ object ExposureUtils {
|
||||
}
|
||||
if (!TextUtils.isEmpty(entity.id)) {
|
||||
ExposureManager.log(exposureEvent)
|
||||
ExposureManager.commitSavedExposureEvents(forcedUpload = true)
|
||||
}
|
||||
return exposureEvent
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ 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.R
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.core.provider.IAppProvider
|
||||
@ -70,6 +71,10 @@ class AppProviderImpl : IAppProvider {
|
||||
return HaloApp.getInstance().flavorProvider
|
||||
}
|
||||
|
||||
override fun getFlavor(): String {
|
||||
return BuildConfig.FLAVOR
|
||||
}
|
||||
|
||||
override fun getIsBrandNewInstall(): Boolean {
|
||||
return HaloApp.getInstance().isBrandNewInstall
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@ class DefaultUrlHandlerProviderImpl : IDefaultUrlHandlerProvider {
|
||||
entrance: String,
|
||||
bringAppToFront: Boolean
|
||||
): Boolean {
|
||||
return DefaultUrlHandler.interceptUrl(context, url, entrance, bringAppToFront)
|
||||
return DefaultUrlHandler.interceptUrl(context, url, null, entrance, bringAppToFront)
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
|
||||
@ -0,0 +1,119 @@
|
||||
package com.gh.common.provider
|
||||
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gh.common.util.NewFlatLogUtils
|
||||
import com.gh.gamecenter.common.base.GlobalActivityManager
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.entity.GameUpdateEntity
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.provider.IDownloadButtonClickedProvider
|
||||
import com.gh.gamecenter.feature.view.DownloadButton
|
||||
import com.gh.gamecenter.packagehelper.PackageRepository
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import com.lightgame.utils.Utils
|
||||
|
||||
@Route(path = RouteConsts.provider.downloadButtonClickedHandler, name = "DownloadButton点击事件暴露服务")
|
||||
class DownloadButtonClickedProviderImpl : IDownloadButtonClickedProvider {
|
||||
override fun onClicked(downloadButton: DownloadButton) {
|
||||
var gameId = ""
|
||||
var gameName = ""
|
||||
var gameCategory = ""
|
||||
var gameTypeInChinese = ""
|
||||
var downloadStatus = ""
|
||||
var downloadStatusInChinese = ""
|
||||
var gameSchemaType = ""
|
||||
var packageName = ""
|
||||
|
||||
val boundedObject = downloadButton.getObject()
|
||||
|
||||
Utils.log("DownloadButtonClickedProviderImpl", "$downloadButton onClicked ${boundedObject?.javaClass}")
|
||||
|
||||
if (boundedObject != null) {
|
||||
when (boundedObject) {
|
||||
is GameEntity -> {
|
||||
gameId = boundedObject.id
|
||||
gameName = boundedObject.name ?: ""
|
||||
gameCategory = boundedObject.category ?: ""
|
||||
downloadStatus = if (boundedObject.isVGame()) {
|
||||
"畅玩"
|
||||
} else if (boundedObject.downloadStatus == "demo") {
|
||||
"试玩"
|
||||
} else {
|
||||
"下载"
|
||||
}
|
||||
gameTypeInChinese = boundedObject.categoryChinese
|
||||
downloadStatusInChinese = boundedObject.downloadStatusChinese
|
||||
gameSchemaType = boundedObject.gameBitChinese
|
||||
packageName = boundedObject.getUniquePackageName() ?: ""
|
||||
}
|
||||
|
||||
is GameUpdateEntity -> {
|
||||
gameId = boundedObject.id
|
||||
gameName = boundedObject.name ?: ""
|
||||
// 下载管理-更新页面,把下载状态都置为下载
|
||||
downloadStatus = "下载"
|
||||
gameTypeInChinese = boundedObject.categoryChinese
|
||||
downloadStatusInChinese = boundedObject.downloadStatusChinese
|
||||
packageName = boundedObject.packageName
|
||||
}
|
||||
|
||||
is DownloadEntity -> {
|
||||
gameId = boundedObject.gameId
|
||||
gameName = boundedObject.name ?: ""
|
||||
gameCategory = boundedObject.getGameCategory()
|
||||
downloadStatus = if (boundedObject.isVGame()) "畅玩" else "下载"
|
||||
packageName = boundedObject.packageName
|
||||
}
|
||||
}
|
||||
|
||||
// 上报 UI 状态为启动的点击事件 (样式为启动,或者文案包含启动都算能启动)
|
||||
if (downloadButton.buttonStyle == DownloadButton.ButtonStyle.LAUNCH_OR_OPEN
|
||||
|| downloadButton.text.contains("启动")) {
|
||||
|
||||
// boundedObject 里找不到游戏类型时,尝试从已安装列表中获取
|
||||
if (gameCategory.isEmpty() && packageName.isNotEmpty()) {
|
||||
gameCategory = PackageRepository.gameInstalled.find { it.packageName == packageName }?.category ?: ""
|
||||
}
|
||||
|
||||
NewFlatLogUtils.logGameLaunchButtonClicked(
|
||||
gameId = gameId,
|
||||
gameName = gameName,
|
||||
location = downloadButton.getWidgetBusinessName(),
|
||||
gameCategory = gameCategory,
|
||||
downloadStatus = downloadStatus
|
||||
)
|
||||
}
|
||||
|
||||
// 预约状态不上报
|
||||
if (downloadButton.buttonStyle != DownloadButton.ButtonStyle.RESERVABLE
|
||||
&& downloadButton.buttonStyle != DownloadButton.ButtonStyle.RESERVED
|
||||
) {
|
||||
|
||||
// 上报神策点击事件
|
||||
SensorsBridge.trackEvent(
|
||||
"DownLoadbuttonClick",
|
||||
"game_id", gameId,
|
||||
"game_name", gameName,
|
||||
"game_type", gameTypeInChinese,
|
||||
"download_status", downloadStatusInChinese,
|
||||
"button_name", downloadButton.text,
|
||||
"game_schema_type", gameSchemaType,
|
||||
"page_name", GlobalActivityManager.getCurrentPageEntity().pageName,
|
||||
"page_id", GlobalActivityManager.getCurrentPageEntity().pageId,
|
||||
"page_business_id", GlobalActivityManager.getCurrentPageEntity().pageBusinessId,
|
||||
"last_page_name", GlobalActivityManager.getLastPageEntity().pageName,
|
||||
"last_page_id", GlobalActivityManager.getLastPageEntity().pageId,
|
||||
"last_page_business_id", GlobalActivityManager.getLastPageEntity().pageBusinessId
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
}
|
||||
@ -9,7 +9,7 @@ import com.gh.gamecenter.manager.UpdateManager
|
||||
|
||||
@Route(path = RouteConsts.provider.updateManager, name = "UpdateManager暴露服务")
|
||||
class UpdateManagerProviderImpl: IUpdateManagerProvider {
|
||||
override fun checkUpdate(context: Context, isAutoCheck: Boolean, handler: Handler) {
|
||||
override fun checkUpdate(context: Context, isAutoCheck: Boolean, handler: Handler?) {
|
||||
UpdateManager.getInstance(context).checkUpdate(isAutoCheck, handler)
|
||||
}
|
||||
|
||||
|
||||
@ -57,8 +57,7 @@ public class DataUtils {
|
||||
return;
|
||||
}
|
||||
|
||||
// 初始化 Sentry 约占用 90ms,这里切换到子线程初始化
|
||||
AppExecutor.getIoExecutor().execute(() -> initSentry(context, channel));
|
||||
initSentry(context, channel);
|
||||
}
|
||||
|
||||
private static void initSentry(Context context, String channel) {
|
||||
|
||||
@ -24,6 +24,8 @@ import com.gh.vspace.VHelper;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
import com.lightgame.download.DownloadStatus;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Created by khy on 27/06/17.
|
||||
* 详情下载工具类
|
||||
@ -42,9 +44,7 @@ public class DetailDownloadUtils {
|
||||
viewHolder.mMultiVersionDownloadTv.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (viewHolder.gameEntity != null
|
||||
&& Config.isShowDownload(viewHolder.gameEntity.getId())
|
||||
&& !"光环助手".equals(viewHolder.gameEntity.getName())) {
|
||||
if (viewHolder.gameEntity != null && Config.isShowDownload(viewHolder.gameEntity.getId()) && !"光环助手".equals(viewHolder.gameEntity.getName())) {
|
||||
viewHolder.downloadBottom.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
viewHolder.downloadBottom.setVisibility(View.GONE);
|
||||
@ -233,6 +233,13 @@ public class DetailDownloadUtils {
|
||||
DownloadEntity downloadEntity = viewHolder.downloadEntity;
|
||||
String xapkStatus = downloadEntity.getMeta().get(XapkInstaller.XAPK_UNZIP_STATUS);
|
||||
|
||||
if (XapkUnzipStatus.SUCCESS.name().equals(xapkStatus) && XapkInstaller.INSTANCE.isInstalling(downloadEntity.getPath())) {
|
||||
viewHolder.mDownloadPb.setText("游戏安装中");
|
||||
viewHolder.mDownloadPb.setProgress(100);
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.INSTALL_NORMAL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (XapkUnzipStatus.UNZIPPING.name().equals(xapkStatus)) {
|
||||
String percent = downloadEntity.getMeta().get(XapkInstaller.XAPK_UNZIP_PERCENT);
|
||||
viewHolder.mDownloadPb.setText("游戏解压中 " + percent + "%");
|
||||
@ -286,7 +293,7 @@ public class DetailDownloadUtils {
|
||||
viewHolder.mDownloadPb.setText(R.string.launch);
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.LAUNCH_OR_OPEN);
|
||||
} else {
|
||||
if (SPUtils.getBoolean(Constants.SP_USE_BROWSER_TO_INSTALL)) {
|
||||
if (SPUtils.getBoolean(Constants.SP_USE_BROWSER_TO_INSTALL) && !Objects.equals(Constants.XAPK_APKS_FORMAT, downloadEntity.getFormat())) {
|
||||
viewHolder.mDownloadPb.setText(R.string.browser_install_install);
|
||||
} else {
|
||||
viewHolder.mDownloadPb.setText(R.string.install);
|
||||
@ -307,13 +314,12 @@ public class DetailDownloadUtils {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (SPUtils.getBoolean(Constants.SP_USE_BROWSER_TO_INSTALL)) {
|
||||
if (SPUtils.getBoolean(Constants.SP_USE_BROWSER_TO_INSTALL) && !Objects.equals(Constants.XAPK_APKS_FORMAT, downloadEntity.getFormat())) {
|
||||
viewHolder.mDownloadPb.setText(R.string.browser_install_install);
|
||||
} else {
|
||||
viewHolder.mDownloadPb.setText(R.string.install);
|
||||
}
|
||||
if (downloadEntity.isPluggable()
|
||||
&& PackagesManager.isInstalled(downloadEntity.getPackageName())) {
|
||||
if (downloadEntity.isPluggable() && PackagesManager.isInstalled(downloadEntity.getPackageName())) {
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.INSTALL_PLUGIN);
|
||||
} else {
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.INSTALL_NORMAL);
|
||||
|
||||
@ -51,6 +51,7 @@ import com.gh.gamecenter.game.columncollection.detail.ColumnCollectionDetailActi
|
||||
import com.gh.gamecenter.game.commoncollection.detail.CommonCollectionDetailActivity
|
||||
import com.gh.gamecenter.game.upload.GameSubmissionActivity
|
||||
import com.gh.gamecenter.gamecollection.detail.GameCollectionDetailActivity
|
||||
import com.gh.gamecenter.gamecollection.hotlist.GameCollectionHotListActivity
|
||||
import com.gh.gamecenter.gamecollection.square.GameCollectionSquareActivity
|
||||
import com.gh.gamecenter.gamedetail.GameDetailFragment
|
||||
import com.gh.gamecenter.gamedetail.fuli.kaifu.ServersCalendarActivity
|
||||
@ -90,6 +91,7 @@ import org.greenrobot.eventbus.EventBus
|
||||
import retrofit2.HttpException
|
||||
import java.net.URLEncoder
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
/**
|
||||
@ -219,8 +221,9 @@ object DirectUtils {
|
||||
)
|
||||
} else {
|
||||
directToGameDetail(
|
||||
context, linkEntity.link
|
||||
?: "", BaseActivity.mergeEntranceAndPath(entrance, path)
|
||||
context,
|
||||
linkEntity.link ?: "",
|
||||
entrance = BaseActivity.mergeEntranceAndPath(entrance, path)
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -316,7 +319,7 @@ object DirectUtils {
|
||||
)
|
||||
}
|
||||
|
||||
"column_collection", "专题合集" -> directToColumnCollection(context, linkEntity.link!!, -1, entrance)
|
||||
"column_collection", "专题合集" -> directToColumnCollection(context, linkEntity.link!!, -1, entrance, "", exposureEvent)
|
||||
|
||||
"server", "game_server", "开服表" -> directToGameServers(context, entrance, path, exposureEvent)
|
||||
|
||||
@ -338,7 +341,7 @@ object DirectUtils {
|
||||
|
||||
"feedback" -> directToFeedback(context, linkEntity.name, linkEntity.text, false, "", entrance)
|
||||
|
||||
"qa", "Q&A" -> directToQa(context, linkEntity.text ?: "", linkEntity.link ?: "")
|
||||
"qa", "qa_content", "Q&A" -> directToQa(context, linkEntity.text ?: "", linkEntity.link ?: "")
|
||||
|
||||
"qa_collection", "Q&A合集" -> directToQaCollection(
|
||||
context, linkEntity.text
|
||||
@ -444,7 +447,7 @@ object DirectUtils {
|
||||
context,
|
||||
linkEntity.link ?: "",
|
||||
entrance,
|
||||
exposureEvent = exposureEvent
|
||||
traceEvent = exposureEvent
|
||||
)
|
||||
|
||||
"explore_column", "game_explore" -> context.startActivity(
|
||||
@ -513,7 +516,8 @@ object DirectUtils {
|
||||
id: String,
|
||||
position: Int = -1,
|
||||
entrance: String,
|
||||
columnName: String = ""
|
||||
columnName: String = "",
|
||||
exposureEvent: ExposureEvent? = null
|
||||
) {
|
||||
if (id.isEmpty()) return
|
||||
val bundle = Bundle()
|
||||
@ -522,6 +526,9 @@ object DirectUtils {
|
||||
bundle.putString(KEY_COLLECTION_ID, id)
|
||||
bundle.putString(KEY_COLUMNNAME, columnName)
|
||||
bundle.putInt(KEY_POSITION, position)
|
||||
if (exposureEvent != null) {
|
||||
bundle.putParcelableArrayList(EntranceConsts.KEY_EXPOSURE_SOURCE_LIST ,ArrayList(exposureEvent.source))
|
||||
}
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
|
||||
@ -1877,7 +1884,9 @@ object DirectUtils {
|
||||
entrance: String = "",
|
||||
forumName: String = "",
|
||||
gameCollectionTitle: String = "",
|
||||
gameCollectionId: String = ""
|
||||
gameCollectionId: String = "",
|
||||
collectionName: String = "",
|
||||
collectionId: String = ""
|
||||
) {
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_TO, GameCollectionSquareActivity::class.java.name)
|
||||
@ -1885,6 +1894,19 @@ object DirectUtils {
|
||||
bundle.putString(KEY_FORUM_NAME, forumName)
|
||||
bundle.putString(KEY_GAME_COLLECTION_TITLE, gameCollectionTitle)
|
||||
bundle.putString(KEY_GAME_COLLECTION_ID, gameCollectionId)
|
||||
bundle.putString(KEY_COLLECTION_ID, collectionId)
|
||||
bundle.putString(KEY_COLLECTION_NAME, collectionName)
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至游戏单热榜
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToGameCollectionHotList(context: Context, entrance: String = "") {
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_TO, GameCollectionHotListActivity::class.java.name)
|
||||
bundle.putString(KEY_ENTRANCE, entrance)
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
|
||||
@ -1897,15 +1919,20 @@ object DirectUtils {
|
||||
id: String,
|
||||
entrance: String? = null,
|
||||
path: String? = null,
|
||||
exposureEvent: ExposureEvent? = null
|
||||
traceEvent: ExposureEvent? = null,
|
||||
) {
|
||||
if (id.isEmpty()) return
|
||||
val bundle = Bundle()
|
||||
val exposureSourceList = traceEvent?.source
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
bundle.putString(KEY_PATH, path)
|
||||
bundle.putString(KEY_TO, GameCollectionDetailActivity::class.java.name)
|
||||
bundle.putString(KEY_GAME_COLLECTION_ID, id)
|
||||
exposureEvent?.let { bundle.putParcelableArrayList(KEY_EXPOSURE_SOURCE_LIST, ArrayList(exposureEvent.source)) }
|
||||
if (exposureSourceList is ArrayList) {
|
||||
bundle.putParcelableArrayList(KEY_EXPOSURE_SOURCE_LIST, exposureSourceList)
|
||||
} else if (exposureSourceList != null) {
|
||||
bundle.putParcelableArrayList(KEY_EXPOSURE_SOURCE_LIST, ArrayList(exposureSourceList))
|
||||
}
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
|
||||
|
||||
@ -18,18 +18,20 @@ import com.gh.common.simulator.SimulatorDownloadManager
|
||||
import com.gh.common.simulator.SimulatorGameManager
|
||||
import com.gh.common.xapk.XapkInstaller
|
||||
import com.gh.common.xapk.XapkInstaller.cancelUnzipTask
|
||||
import com.gh.common.xapk.XapkInstaller.isInstalling
|
||||
import com.gh.common.xapk.XapkUnzipStatus
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.download.dialog.DownloadDialog
|
||||
import com.gh.download.server.BrowserInstallHelper
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.WebActivity
|
||||
import com.gh.gamecenter.adapter.viewholder.GameViewHolder
|
||||
import com.gh.gamecenter.common.base.GlobalActivityManager
|
||||
import com.gh.gamecenter.common.callback.CancelListener
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.entity.LinkEntity
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.core.utils.*
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.entity.PluginLocation
|
||||
@ -163,6 +165,8 @@ object DownloadItemUtils {
|
||||
briefStyle: String? = null,
|
||||
isShowRecommendStar: Boolean = false
|
||||
) {
|
||||
holder.gameDownloadBtn.putObject(gameEntity)
|
||||
|
||||
// 显示预约
|
||||
if (gameEntity.isReservable) {
|
||||
holder.multiVersionDownloadTv?.visibility = View.GONE
|
||||
@ -263,18 +267,17 @@ object DownloadItemUtils {
|
||||
}
|
||||
}
|
||||
} else if (gameEntity.getApk().size == 1) {
|
||||
// 优先从下载管理获取 downloadEntity
|
||||
var downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity)
|
||||
|
||||
// 找不到时,若类型为畅玩,尝试从畅玩数据库的快照中获取 downloadEntity。若存在,代表游戏已下载并成功安装
|
||||
if (downloadEntity == null && gameEntity.isVGame()) {
|
||||
downloadEntity = VHelper.getVDownloadEntitySnapshot(gameEntity.id, gameEntity.getUniquePackageName())
|
||||
}
|
||||
|
||||
// 还是找不到时,尝试从 gameEntity 里找已绑定的 downloadEntity
|
||||
if (downloadEntity == null) {
|
||||
val entryMap: ArrayMap<String, DownloadEntity> = gameEntity.getEntryMap()
|
||||
val apkEntity = gameEntity.getApk()[0]
|
||||
if (entryMap.isNotEmpty()) {
|
||||
downloadEntity = entryMap[apkEntity.getPlatform()]
|
||||
}
|
||||
downloadEntity = gameEntity.getEntryMap().getOrDefault(gameEntity.getUniquePlatform(), null)
|
||||
}
|
||||
|
||||
if (downloadEntity != null) {
|
||||
@ -297,6 +300,25 @@ object DownloadItemUtils {
|
||||
DownloadButton.ButtonStyle.LAUNCH_OR_OPEN
|
||||
}
|
||||
} else {
|
||||
val xapkStatus = downloadEntity.meta[XapkInstaller.XAPK_UNZIP_STATUS]
|
||||
if (XapkUnzipStatus.SUCCESS.name == xapkStatus && isInstalling(downloadEntity.path)) {
|
||||
progress = 100
|
||||
setText(R.string.installing)
|
||||
buttonStyle = DownloadButton.ButtonStyle.INSTALL_NORMAL
|
||||
return
|
||||
}
|
||||
if (XapkUnzipStatus.UNZIPPING.name == xapkStatus) {
|
||||
val percent = downloadEntity.meta[XapkInstaller.XAPK_UNZIP_PERCENT]
|
||||
progress = (java.lang.Float.valueOf(percent) * 10).toInt()
|
||||
text = "$percent%"
|
||||
buttonStyle = DownloadButton.ButtonStyle.XAPK_UNZIPPING
|
||||
return
|
||||
} else if (XapkUnzipStatus.FAILURE.name == xapkStatus) {
|
||||
setText(R.string.install)
|
||||
buttonStyle = DownloadButton.ButtonStyle.INSTALL_NORMAL
|
||||
return
|
||||
}
|
||||
|
||||
buttonStyle = DownloadButton.ButtonStyle.INSTALL_NORMAL
|
||||
setText(R.string.install)
|
||||
}
|
||||
@ -307,6 +329,7 @@ object DownloadItemUtils {
|
||||
DownloadButton.ButtonStyle.NORMAL
|
||||
}
|
||||
}
|
||||
|
||||
DownloadStatus.pause,
|
||||
DownloadStatus.timeout,
|
||||
DownloadStatus.neterror,
|
||||
@ -317,9 +340,11 @@ object DownloadItemUtils {
|
||||
buttonStyle = DownloadButton.ButtonStyle.NORMAL
|
||||
setText(R.string.resume)
|
||||
}
|
||||
|
||||
DownloadStatus.cancel -> {
|
||||
GameUtils.setDownloadBtnStatus(context, gameEntity, downloadBtn, pluginLocation)
|
||||
}
|
||||
|
||||
else -> {
|
||||
// do nothing
|
||||
}
|
||||
@ -396,7 +421,7 @@ object DownloadItemUtils {
|
||||
}
|
||||
|
||||
// 更改进度条和提示文本的状态
|
||||
fun changeStatus(
|
||||
private fun changeStatus(
|
||||
context: Context,
|
||||
holder: GameViewHolder,
|
||||
downloadEntity: DownloadEntity,
|
||||
@ -421,6 +446,7 @@ object DownloadItemUtils {
|
||||
holder.gameDownloadBtn.text = downloadEntity.percent.toString() + "%"
|
||||
}
|
||||
}
|
||||
|
||||
DownloadStatus.waiting -> {
|
||||
if (isMultiVersion) {
|
||||
holder.gameDownloadTips?.visibility = View.VISIBLE
|
||||
@ -429,6 +455,7 @@ object DownloadItemUtils {
|
||||
holder.gameDownloadBtn.buttonStyle = DownloadButton.ButtonStyle.WAITING
|
||||
holder.gameDownloadBtn.text = context.getString(R.string.waiting)
|
||||
}
|
||||
|
||||
DownloadStatus.pause,
|
||||
DownloadStatus.timeout,
|
||||
DownloadStatus.neterror,
|
||||
@ -443,6 +470,7 @@ object DownloadItemUtils {
|
||||
holder.gameDownloadBtn.buttonStyle = DownloadButton.ButtonStyle.NORMAL
|
||||
holder.gameDownloadBtn.text = context.getString(R.string.resume)
|
||||
}
|
||||
|
||||
DownloadStatus.done -> {
|
||||
if (isMultiVersion) {
|
||||
holder.gameDownloadTips?.visibility = View.VISIBLE
|
||||
@ -462,6 +490,7 @@ object DownloadItemUtils {
|
||||
holder.gameDownloadBtn.progress = 1000
|
||||
holder.gameDownloadBtn.setText(R.string.hundred_percent)
|
||||
}
|
||||
|
||||
else -> {
|
||||
holder.gameDownloadTips?.visibility = View.GONE
|
||||
}
|
||||
@ -592,13 +621,15 @@ object DownloadItemUtils {
|
||||
refreshCallback: EmptyCallback?,
|
||||
allStateClickCallback: EmptyCallback?
|
||||
) {
|
||||
// 为 downloadButton 添加游戏实体,供点击的时候上报用
|
||||
downloadBtn.putObject(gameEntity)
|
||||
|
||||
val gamePermissionDialogFragment = (context as AppCompatActivity).supportFragmentManager.findFragmentByTag(
|
||||
GamePermissionDialogFragment::class.java.name
|
||||
) as GamePermissionDialogFragment?
|
||||
gamePermissionDialogFragment?.dismissAllowingStateLoss()
|
||||
if (SPUtils.getBoolean(Constants.SP_TEENAGER_MODE)) {
|
||||
downloadBtn.setOnClickListener {
|
||||
logDownloadButtonClick(gameEntity, downloadBtn)
|
||||
DialogHelper.showDialog(
|
||||
context,
|
||||
"提示",
|
||||
@ -618,7 +649,6 @@ object DownloadItemUtils {
|
||||
if (gameEntity.isSpecialDownload()) {
|
||||
val info = RegionSettingHelper.getGameSpecialDownloadInfo(gameEntity.id) ?: return
|
||||
downloadBtn.setOnClickListener {
|
||||
logDownloadButtonClick(gameEntity, downloadBtn)
|
||||
DialogHelper.showDialog(
|
||||
context,
|
||||
"提示",
|
||||
@ -659,14 +689,12 @@ object DownloadItemUtils {
|
||||
ReservationHelper.reserve(
|
||||
context,
|
||||
gameEntity.id,
|
||||
gameEntity.name ?: "",
|
||||
object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
LogUtils.logReservation(gameEntity, traceEvent)
|
||||
adapter?.notifyItemChanged(position)
|
||||
refreshCallback?.onCallback()
|
||||
}
|
||||
})
|
||||
gameEntity.name ?: ""
|
||||
) {
|
||||
LogUtils.logReservation(gameEntity, traceEvent)
|
||||
adapter?.notifyItemChanged(position)
|
||||
refreshCallback?.onCallback()
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -708,16 +736,13 @@ object DownloadItemUtils {
|
||||
val gameH5Download = RegionSettingHelper.getGameH5DownloadByGameId(gameEntity.id)
|
||||
if (gameH5Download != null) {
|
||||
downloadBtn.setOnClickListener {
|
||||
logDownloadButtonClick(gameEntity, downloadBtn)
|
||||
DialogUtils.showGameH5DownloadDialog(context, gameEntity, gameH5Download)
|
||||
}
|
||||
return
|
||||
}
|
||||
if (gameEntity.getApk().size == 0 && gameEntity.h5Link != null) {
|
||||
downloadBtn.setOnClickListener {
|
||||
logDownloadButtonClick(gameEntity, downloadBtn)
|
||||
allStateClickCallback?.onCallback()
|
||||
MtaHelper.onEvent("H5页面", "入口", "列表页_" + gameEntity.name)
|
||||
val linkEntity = gameEntity.h5Link
|
||||
val isPlay = "play" == linkEntity!!.type // 是否为开始玩
|
||||
if (isPlay) {
|
||||
@ -734,7 +759,6 @@ object DownloadItemUtils {
|
||||
}
|
||||
} else if (gameEntity.getApk().size == 1) {
|
||||
downloadBtn.setOnClickListener {
|
||||
logDownloadButtonClick(gameEntity, downloadBtn)
|
||||
val clickRunnable = EmptyCallback {
|
||||
allStateClickCallback?.onCallback()
|
||||
clickCallback?.onCallback()
|
||||
@ -795,6 +819,7 @@ object DownloadItemUtils {
|
||||
val apk = gameEntity.getApk().safelyGetInRelease(0) ?: return
|
||||
if (str == context.getString(R.string.download)) {
|
||||
ChainBuilder().apply {
|
||||
addHandler(UnsupportedFeatureHandler())
|
||||
addHandler(UpdateNewSimulatorHandler())
|
||||
addHandler(GamePermissionHandler())
|
||||
addHandler(BrowserInstallHandler())
|
||||
@ -812,6 +837,7 @@ object DownloadItemUtils {
|
||||
DataLogUtils.uploadGameLog(context, gameEntity.id, gameEntity.name, entrance)
|
||||
} else if (str == context.getString(R.string.attempt)) {
|
||||
ChainBuilder().apply {
|
||||
addHandler(UnsupportedFeatureHandler())
|
||||
addHandler(UpdateNewSimulatorHandler())
|
||||
addHandler(GamePermissionHandler())
|
||||
addHandler(BrowserInstallHandler())
|
||||
@ -830,6 +856,7 @@ object DownloadItemUtils {
|
||||
DataLogUtils.uploadGameLog(context, gameEntity.id, gameEntity.name, entrance)
|
||||
} else if (str == context.getString(R.string.smooth)) {
|
||||
ChainBuilder().apply {
|
||||
addHandler(UnsupportedFeatureHandler())
|
||||
addHandler(GamePermissionHandler())
|
||||
addHandler(PackageCheckHandler())
|
||||
addHandler(DownloadDialogHelperHandler())
|
||||
@ -846,9 +873,6 @@ object DownloadItemUtils {
|
||||
.buildHandlerChain()
|
||||
?.handleRequest(context, gameEntity)
|
||||
} else if (str.contains("化")) {
|
||||
if (entrance.contains("我的游戏")) {
|
||||
MtaHelper.onEvent("我的游戏_启动", "插件化", gameEntity.name)
|
||||
}
|
||||
if (gameEntity.pluggableCollection != null) {
|
||||
DownloadDialog.showDownloadDialog(context, gameEntity, traceEvent, entrance, location)
|
||||
} else {
|
||||
@ -913,42 +937,40 @@ object DownloadItemUtils {
|
||||
VHelper.installOrLaunch((context as AppCompatActivity), gameEntity)
|
||||
return
|
||||
}
|
||||
|
||||
if (entrance.contains("我的游戏")) {
|
||||
MtaHelper.onEvent("我的游戏_启动", "启动", gameEntity.name)
|
||||
}
|
||||
PackageUtils.launchApplicationByPackageName(context, gameEntity.getApk()[0].packageName)
|
||||
PackageLauncher.launchApp(context, gameEntity, gameEntity.getApk()[0].packageName)
|
||||
} else if (str == context.getString(R.string.update)) {
|
||||
if (entrance.contains("我的游戏")) {
|
||||
MtaHelper.onEvent("我的游戏_启动", "更新", gameEntity.name)
|
||||
}
|
||||
if (gameEntity.isVGame()) {
|
||||
VHelper.updateOrReDownload(gameEntity)
|
||||
return
|
||||
}
|
||||
DownloadDialogHelper.findAvailableDialogAndShow(context, gameEntity, apk, object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
DialogUtils.checkDownload(
|
||||
context,
|
||||
apk.size,
|
||||
gameEntity.id,
|
||||
gameEntity.name
|
||||
) { isSubscribe: Boolean ->
|
||||
update(context, gameEntity, entrance, location, isSubscribe, traceEvent)
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
var downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity)
|
||||
if (downloadEntity == null && gameEntity.getApk().size == 1) {
|
||||
val entryMap: ArrayMap<String, DownloadEntity> = gameEntity.getEntryMap()
|
||||
val apkEntity = gameEntity.getApk()[0]
|
||||
if (entryMap.isNotEmpty()) {
|
||||
downloadEntity = entryMap[apkEntity.getPlatform()]
|
||||
DownloadDialogHelper.findAvailableDialogAndShow(context, gameEntity, apk) {
|
||||
DialogUtils.checkDownload(
|
||||
context,
|
||||
apk.size,
|
||||
gameEntity.id,
|
||||
gameEntity.name
|
||||
) { isSubscribe: Boolean ->
|
||||
update(context, gameEntity, entrance, location, isSubscribe, traceEvent)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity)
|
||||
|
||||
// 找不到时,若类型为畅玩,尝试从畅玩数据库的快照中获取 downloadEntity。若存在,代表游戏已下载并成功安装
|
||||
if (downloadEntity == null && gameEntity.isVGame()) {
|
||||
downloadEntity = VHelper.getVDownloadEntitySnapshot(gameEntity.id, gameEntity.getUniquePackageName())
|
||||
}
|
||||
|
||||
// 还是找不到时,尝试从 gameEntity 里找已绑定的 downloadEntity
|
||||
if (downloadEntity == null) {
|
||||
downloadEntity = gameEntity.getEntryMap().getOrDefault(gameEntity.getUniquePlatform(), null)
|
||||
}
|
||||
|
||||
if (downloadEntity != null) {
|
||||
val xapkStatus = downloadEntity.meta[XapkInstaller.XAPK_UNZIP_STATUS]
|
||||
if (XapkUnzipStatus.SUCCESS.name == xapkStatus && isInstalling(downloadEntity.path)) {// 安装过程中避免重复点击
|
||||
return
|
||||
}
|
||||
if (XapkUnzipStatus.UNZIPPING.name == xapkStatus) {
|
||||
cancelUnzipTask(downloadEntity)
|
||||
return
|
||||
@ -957,9 +979,11 @@ object DownloadItemUtils {
|
||||
context.getString(R.string.resume) -> {
|
||||
DownloadManager.getInstance().resume(downloadEntity, true)
|
||||
}
|
||||
|
||||
context.getString(R.string.waiting) -> {
|
||||
Utils.toast(context, "最多只能同时下载三个任务,请稍等")
|
||||
}
|
||||
|
||||
else -> {
|
||||
DownloadManager.getInstance().pause(downloadEntity.url)
|
||||
}
|
||||
@ -980,7 +1004,7 @@ object DownloadItemUtils {
|
||||
) {
|
||||
if (gameEntity.getApk().isEmpty()) return
|
||||
|
||||
val msg = FileUtils.isCanDownload(context, gameEntity.getApk()[0].size)
|
||||
val msg = FileUtils.isCanDownload(context, gameEntity.getApk()[0].size ?: "")
|
||||
if (TextUtils.isEmpty(msg)) {
|
||||
DownloadManager.createDownload(
|
||||
context,
|
||||
@ -991,7 +1015,13 @@ object DownloadItemUtils {
|
||||
isSubscribe,
|
||||
traceEvent
|
||||
)
|
||||
Utils.toast(context, gameEntity.name + "已加入下载队列")
|
||||
ToastUtils.toast(gameEntity.name + "已加入下载队列")
|
||||
if (BrowserInstallHelper.shouldAutoSwitchAssistantInstall(gameEntity)) {
|
||||
val toast = context.getString(R.string.unsupported_browser_install_hint)
|
||||
AppExecutor.uiExecutor.executeWithDelay({
|
||||
ToastUtils.toast(toast)
|
||||
}, 1000)
|
||||
}
|
||||
if (downloadBtn is DownloadButton) {
|
||||
downloadBtn.text = "0%"
|
||||
downloadBtn.buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_NORMAL
|
||||
@ -1012,10 +1042,16 @@ object DownloadItemUtils {
|
||||
isSubscribe: Boolean,
|
||||
traceEvent: ExposureEvent?
|
||||
) {
|
||||
val msg = FileUtils.isCanDownload(context, gameEntity.getApk()[0].size)
|
||||
val msg = FileUtils.isCanDownload(context, gameEntity.getApk()[0].size ?: "")
|
||||
if (TextUtils.isEmpty(msg)) {
|
||||
DownloadManager.createDownload(context, gameEntity, "插件化", entrance, location, isSubscribe, traceEvent)
|
||||
Utils.toast(context, gameEntity.name + "已加入下载队列")
|
||||
ToastUtils.toast(gameEntity.name + "已加入下载队列")
|
||||
if (BrowserInstallHelper.shouldAutoSwitchAssistantInstall(gameEntity)) {
|
||||
val toast = context.getString(R.string.unsupported_browser_install_hint)
|
||||
AppExecutor.uiExecutor.executeWithDelay({
|
||||
ToastUtils.toast(toast)
|
||||
}, 1000)
|
||||
}
|
||||
if (downloadBtn is DownloadButton) {
|
||||
downloadBtn.setText(R.string.downloading)
|
||||
downloadBtn.buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_PLUGIN
|
||||
@ -1045,9 +1081,11 @@ object DownloadItemUtils {
|
||||
adapter?.notifyItemChanged(position)
|
||||
refreshCallback?.onCallback()
|
||||
}
|
||||
|
||||
PackageUtils.isCanPluggable(apkEntity) -> {
|
||||
DialogHelper.showPluginDialog(context) { PackageInstaller.uninstall(context, path) }
|
||||
DialogHelper.showPluginDialog(context, gameEntity.pluginDesc) { PackageInstaller.uninstall(context, path) }
|
||||
}
|
||||
|
||||
else -> {
|
||||
PackageInstaller.install(context, downloadEntity)
|
||||
}
|
||||
@ -1066,23 +1104,4 @@ object DownloadItemUtils {
|
||||
) {
|
||||
DownloadManager.createDownload(context, gameEntity, "更新", entrance, location, isSubscribe, traceEvent)
|
||||
}
|
||||
|
||||
private fun logDownloadButtonClick(gameEntity: GameEntity, downloadBtn: View) {
|
||||
val buttonName = if (downloadBtn is DownloadButton) downloadBtn.text else ""
|
||||
SensorsBridge.trackEvent(
|
||||
"DownLoadbuttonClick",
|
||||
"game_id", gameEntity.id,
|
||||
"game_name", gameEntity.name ?: "",
|
||||
"game_type", gameEntity.categoryChinese,
|
||||
"download_status", gameEntity.downloadStatusChinese,
|
||||
"button_name", buttonName,
|
||||
"game_schema_type", gameEntity.gameBitChinese,
|
||||
"page_name", GlobalActivityManager.getCurrentPageEntity().pageName,
|
||||
"page_id", GlobalActivityManager.getCurrentPageEntity().pageId,
|
||||
"page_business_id", GlobalActivityManager.getCurrentPageEntity().pageBusinessId,
|
||||
"last_page_name", GlobalActivityManager.getLastPageEntity().pageName,
|
||||
"last_page_id", GlobalActivityManager.getLastPageEntity().pageId,
|
||||
"last_page_business_id", GlobalActivityManager.getLastPageEntity().pageBusinessId
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -16,7 +16,6 @@ import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.entity.SimpleGameEntity
|
||||
import com.gh.gamecenter.common.entity.SuggestType
|
||||
import com.gh.gamecenter.common.eventbus.EBShowDialog
|
||||
import com.gh.gamecenter.common.retrofit.Response
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.utils.*
|
||||
import com.gh.gamecenter.eventbus.EBDownloadStatus
|
||||
@ -24,18 +23,13 @@ import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.entity.SimulatorEntity
|
||||
import com.gh.gamecenter.feature.utils.PlatformUtils
|
||||
import com.gh.gamecenter.help.HelpAndFeedbackBridge
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.gh.gamecenter.pkg.PkgHelper
|
||||
import com.gh.vspace.VHelper
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.download.*
|
||||
import com.lightgame.utils.AppManager
|
||||
import com.lightgame.utils.Utils
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.RequestBody
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.json.JSONObject
|
||||
|
||||
object DownloadObserver {
|
||||
|
||||
@ -45,7 +39,10 @@ object DownloadObserver {
|
||||
// TODO 修复因为更改内存对象造成的双重下载完成事件问题,具体触发代码见 DownloadDao.updateSnapshotList
|
||||
private var mDoneDebouncePair: Pair<String, Long>? = null
|
||||
|
||||
private const val TEA_EVENT_DOWNLOAD_COMPLETE = "game_addiction"
|
||||
private const val TAG = "DownloadObserver"
|
||||
private const val CORE_EVENT_DOWNLOAD_COMPLETE_LOGGED = "CORE_EVENT_DOWNLOAD_COMPLETE_LOGGED"
|
||||
|
||||
private val mRetryableHashMap = hashMapOf<String, Boolean>()
|
||||
|
||||
// 如果在WIFI状态下,下载自动暂停,则再重试一遍
|
||||
@JvmStatic
|
||||
@ -76,28 +73,34 @@ object DownloadObserver {
|
||||
|
||||
val currentActivity = AppManager.getInstance().currentActivity() ?: return
|
||||
|
||||
DialogHelper.showDialog(currentActivity, "下载失败", "下载链接已失效,建议提交反馈", "立即反馈", "取消", {
|
||||
HelpAndFeedbackBridge.startSuggestionActivity(
|
||||
currentActivity,
|
||||
SuggestType.gameQuestion, "notfound",
|
||||
StringUtils.buildString(downloadEntity.name, ",问题反馈:下载链接失效"),
|
||||
SimpleGameEntity(gameId, downloadEntity.name, "")
|
||||
)
|
||||
}, extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true))
|
||||
DialogHelper.showDialog(
|
||||
currentActivity,
|
||||
"下载失败",
|
||||
"下载链接已失效,建议提交反馈",
|
||||
"立即反馈",
|
||||
"取消",
|
||||
{
|
||||
HelpAndFeedbackBridge.startSuggestionActivity(
|
||||
currentActivity,
|
||||
SuggestType.gameQuestion, "notfound",
|
||||
StringUtils.buildString(downloadEntity.name, ",问题反馈:下载链接失效"),
|
||||
SimpleGameEntity(gameId, downloadEntity.name, "")
|
||||
)
|
||||
},
|
||||
extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true)
|
||||
)
|
||||
return
|
||||
} else if (DownloadStatus.neterror == downloadEntity.status
|
||||
|| DownloadStatus.timeout == downloadEntity.status
|
||||
|| DownloadStatus.diskioerror == downloadEntity.status
|
||||
|| DownloadStatus.diskisfull == downloadEntity.status) {
|
||||
if (downloadEntity.meta[Constants.MARK_RETRY_DOWNLOAD].isNullOrEmpty()
|
||||
|| DownloadStatus.diskisfull == downloadEntity.status
|
||||
) {
|
||||
if (mRetryableHashMap[downloadEntity.url] == true
|
||||
&& NetworkUtils.isWifiConnected(HaloApp.getInstance().application)
|
||||
) {
|
||||
downloadEntity.meta[Constants.MARK_RETRY_DOWNLOAD] = downloadEntity.progress.toString()
|
||||
downloadManager.updateDownloadEntity(downloadEntity)
|
||||
downloadManager.resumeDownload(downloadEntity.url)
|
||||
debugOnly {
|
||||
Utils.log("DownloadObserver", "下载重试->" + downloadEntity.toJson())
|
||||
}
|
||||
mRetryableHashMap[downloadEntity.url] = false
|
||||
Utils.log(TAG, "下载重试->" + downloadEntity.toJson())
|
||||
} else {
|
||||
if (DownloadStatus.diskisfull == downloadEntity.status) {
|
||||
ToastUtils.toast("磁盘已满,请清理空间后重试下载")
|
||||
@ -108,13 +111,10 @@ object DownloadObserver {
|
||||
}
|
||||
|
||||
DataLogUtils.uploadNeterrorLog(mApplication, downloadEntity)
|
||||
|
||||
debugOnly {
|
||||
Utils.log("DownloadObserver", "下载自动暂停->" + downloadEntity.toJson())
|
||||
}
|
||||
Utils.log(TAG, "下载自动暂停->" + downloadEntity.toJson())
|
||||
}
|
||||
} else if (DownloadStatus.redirected == downloadEntity.status) {
|
||||
debugOnly { Utils.log("重定向完毕") }
|
||||
Utils.log(TAG, "重定向完毕")
|
||||
DownloadDataHelper.uploadRedirectEvent(downloadEntity)
|
||||
} else if (DownloadStatus.unqualified == downloadEntity.status) {
|
||||
// 未成年
|
||||
@ -159,40 +159,35 @@ object DownloadObserver {
|
||||
if (DownloadStatus.done == downloadEntity.status) {
|
||||
if (mDoneDebouncePair?.first != downloadEntity.url) {
|
||||
mDoneDebouncePair = Pair(downloadEntity.url, System.currentTimeMillis())
|
||||
performDownloadCompleteAction(downloadEntity, gameId, downloadManager)
|
||||
performDownloadCompleteAction(downloadEntity, downloadManager)
|
||||
} else {
|
||||
if (mDoneDebouncePair?.second == 0L
|
||||
|| System.currentTimeMillis() - (mDoneDebouncePair?.second ?: 0) > 500
|
||||
) {
|
||||
performDownloadCompleteAction(downloadEntity, gameId, downloadManager)
|
||||
performDownloadCompleteAction(downloadEntity, downloadManager)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (downloadEntity.status == DownloadStatus.done) {
|
||||
mRetryableHashMap.remove(downloadEntity.url)
|
||||
|
||||
EventBus.getDefault().post(EBDownloadStatus("done", "", "", "", downloadEntity.packageName, ""))
|
||||
}
|
||||
|
||||
DownloadNotificationHelper.addOrUpdateDownloadNotification(downloadEntity)
|
||||
|
||||
// 如果已下载大小发生变化,表示成功恢复下载,则重置重试标记
|
||||
if (downloadEntity.status == DownloadStatus.downloading &&
|
||||
downloadEntity.progress.toString() != downloadEntity.meta[Constants.MARK_RETRY_DOWNLOAD]
|
||||
) {
|
||||
downloadEntity.meta[Constants.MARK_RETRY_DOWNLOAD] = ""
|
||||
downloadManager.updateDownloadEntity(downloadEntity)
|
||||
if (downloadEntity.status == DownloadStatus.downloading) {
|
||||
mRetryableHashMap[downloadEntity.url] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 添加观察者
|
||||
DownloadManager.getInstance().addObserver(dataWatcher)
|
||||
|
||||
}
|
||||
|
||||
private fun performDownloadCompleteAction(
|
||||
downloadEntity: DownloadEntity,
|
||||
gameId: String,
|
||||
downloadManager: DownloadManager
|
||||
) {
|
||||
if (downloadEntity.name.contains(mApplication.getString(R.string.app_name))) {
|
||||
@ -210,10 +205,7 @@ object DownloadObserver {
|
||||
} else {
|
||||
statDoneEvent(downloadEntity)
|
||||
|
||||
if (!SPUtils.getBoolean(TEA_EVENT_DOWNLOAD_COMPLETE)) {
|
||||
HaloApp.getInstance().flavorProvider.logEvent(TEA_EVENT_DOWNLOAD_COMPLETE)
|
||||
SPUtils.setBoolean(TEA_EVENT_DOWNLOAD_COMPLETE, true)
|
||||
}
|
||||
logCoreEventIfNeeded(downloadEntity.getGameCategory())
|
||||
|
||||
GameActivityDownloadHelper.clear()
|
||||
|
||||
@ -226,13 +218,16 @@ object DownloadObserver {
|
||||
EventBus.getDefault().post(
|
||||
EBShowDialog(
|
||||
BaseActivity.PLUGGABLE,
|
||||
downloadEntity.path
|
||||
downloadEntity.path,
|
||||
downloadEntity.pluginDesc
|
||||
)
|
||||
)
|
||||
|
||||
downloadEntity.isPlugin -> Utils.toast(
|
||||
mApplication,
|
||||
downloadEntity.name + " - " + platform + " - 下载完成"
|
||||
)
|
||||
|
||||
else -> {
|
||||
if (!downloadEntity.isVGame()) {
|
||||
Utils.toast(mApplication, downloadEntity.name + " - 下载完成")
|
||||
@ -250,15 +245,10 @@ object DownloadObserver {
|
||||
val gameName = downloadEntity.getMetaExtra(Constants.GAME_NAME)
|
||||
if (simulatorJson.isEmpty()) return
|
||||
var simulator = GsonUtils.fromJson(simulatorJson, SimulatorEntity::class.java)
|
||||
val isInstalled = PackageUtils.isInstalledFromAllPackage(
|
||||
HaloApp.getInstance().application,
|
||||
simulator.apk?.packageName
|
||||
)
|
||||
val isInstalledNewSimulator =
|
||||
SimulatorGameManager.isNewSimulatorInstalled(HaloApp.getInstance().application)
|
||||
val isInstalledOldSimulator =
|
||||
SimulatorGameManager.isOldSimulatorInstalled(HaloApp.getInstance().application)
|
||||
// if (!isInstalled && !isInstalledNewSimulator) {
|
||||
val currentActivity = AppManager.getInstance().currentActivity()
|
||||
?: return
|
||||
val newSimulator = Config.getNewSimulatorEntitySetting()
|
||||
@ -269,7 +259,6 @@ object DownloadObserver {
|
||||
currentActivity, simulator,
|
||||
SimulatorDownloadManager.SimulatorLocation.LAUNCH, downloadEntity.gameId, gameName, null
|
||||
)
|
||||
// }
|
||||
SimulatorGameManager.recordDownloadSimulatorGame(downloadEntity.gameId, simulator.type)
|
||||
SimulatorGameManager.postPlayedGame(downloadEntity.gameId, downloadEntity.packageName)
|
||||
} else {
|
||||
@ -296,7 +285,8 @@ object DownloadObserver {
|
||||
EventBus.getDefault().post(
|
||||
EBShowDialog(
|
||||
BaseActivity.PLUGGABLE,
|
||||
downloadEntity.path
|
||||
downloadEntity.path,
|
||||
downloadEntity.pluginDesc
|
||||
)
|
||||
)
|
||||
} else {
|
||||
@ -392,7 +382,7 @@ object DownloadObserver {
|
||||
"DownloadProcessFinish",
|
||||
"game_id", downloadEntity.gameId,
|
||||
"game_name", downloadEntity.meta[Constants.GAME_NAME] ?: "",
|
||||
"game_type", downloadEntity.meta[Constants.GAME_TYPE] ?: "",
|
||||
"game_type", downloadEntity.meta[Constants.GAME_CATEGORY_IN_CHINESE] ?: "",
|
||||
"game_schema_type", if (downloadEntity.getMetaExtra(VHelper.KEY_BIT) == "32") "32位" else "64位",
|
||||
"page_name", getCurrentPageEntity().pageName,
|
||||
"page_id", getCurrentPageEntity().pageId,
|
||||
@ -452,4 +442,21 @@ object DownloadObserver {
|
||||
DataLogUtils.uploadHijack(mApplication, downloadEntity)
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据预设的游戏类型上报关键事件(下载完成事件)
|
||||
*/
|
||||
private fun logCoreEventIfNeeded(gameCategory: String) {
|
||||
val category = PkgHelper.getCoreEventGameCategory()
|
||||
val categoryMatched = if (category == "standard" || category.isNullOrEmpty()) {
|
||||
true
|
||||
} else {
|
||||
gameCategory == category
|
||||
}
|
||||
|
||||
if (!SPUtils.getBoolean(CORE_EVENT_DOWNLOAD_COMPLETE_LOGGED) && categoryMatched) {
|
||||
HaloApp.getInstance().flavorProvider.logCoreEvent()
|
||||
SPUtils.setBoolean(CORE_EVENT_DOWNLOAD_COMPLETE_LOGGED, true)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -15,6 +15,7 @@ import com.gh.common.simulator.SimulatorDownloadManager
|
||||
import com.gh.common.simulator.SimulatorGameManager
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.download.dialog.DownloadDialog
|
||||
import com.gh.download.server.BrowserInstallHelper
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.WebActivity
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
@ -26,6 +27,7 @@ import com.gh.gamecenter.common.utils.DialogHelper
|
||||
import com.gh.gamecenter.common.utils.observableToMain
|
||||
import com.gh.gamecenter.common.utils.singleToMain
|
||||
import com.gh.gamecenter.common.view.dsbridge.CompletionHandler
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.core.runOnUiThread
|
||||
import com.gh.gamecenter.core.utils.EmptyCallback
|
||||
import com.gh.gamecenter.core.utils.MtaHelper
|
||||
@ -183,6 +185,12 @@ object GameActivityDownloadHelper {
|
||||
str != context.getString(R.string.launch)
|
||||
) {
|
||||
ToastUtils.toast("${gameEntity.name}已加入下载队列")
|
||||
if (BrowserInstallHelper.shouldAutoSwitchAssistantInstall(gameEntity)) {
|
||||
val toast = context.getString(R.string.unsupported_browser_install_hint)
|
||||
AppExecutor.uiExecutor.executeWithDelay({
|
||||
ToastUtils.toast(toast)
|
||||
}, 1000)
|
||||
}
|
||||
} else {
|
||||
when {
|
||||
str == context.getString(R.string.download) || str == context.getString(R.string.attempt) -> {
|
||||
@ -205,6 +213,12 @@ object GameActivityDownloadHelper {
|
||||
}
|
||||
else -> {
|
||||
ToastUtils.toast("${gameEntity.name}已加入下载队列")
|
||||
if (BrowserInstallHelper.shouldAutoSwitchAssistantInstall(gameEntity)) {
|
||||
val toast = context.getString(R.string.unsupported_browser_install_hint)
|
||||
AppExecutor.uiExecutor.executeWithDelay({
|
||||
ToastUtils.toast(toast)
|
||||
}, 1000)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -348,7 +362,7 @@ object GameActivityDownloadHelper {
|
||||
if (entrance.contains("我的游戏")) {
|
||||
MtaHelper.onEvent("我的游戏_启动", "启动", gameEntity.name)
|
||||
}
|
||||
PackageUtils.launchApplicationByPackageName(context, gameEntity.getApk()[0].packageName)
|
||||
PackageLauncher.launchApp(context, gameEntity, gameEntity.getApk()[0].packageName)
|
||||
}
|
||||
|
||||
// 处理更新状态
|
||||
@ -424,6 +438,12 @@ object GameActivityDownloadHelper {
|
||||
), entrance, location, isSubscribe, traceEvent
|
||||
)
|
||||
ToastUtils.toast("${gameEntity.name}已加入下载队列")
|
||||
if (BrowserInstallHelper.shouldAutoSwitchAssistantInstall(gameEntity)) {
|
||||
val toast = context.getString(R.string.unsupported_browser_install_hint)
|
||||
AppExecutor.uiExecutor.executeWithDelay({
|
||||
ToastUtils.toast(toast)
|
||||
}, 1000)
|
||||
}
|
||||
} else {
|
||||
ToastUtils.toast(msg)
|
||||
}
|
||||
@ -443,6 +463,12 @@ object GameActivityDownloadHelper {
|
||||
if (TextUtils.isEmpty(msg)) {
|
||||
DownloadManager.createDownload(context, apk, gameEntity, "插件化", entrance, location, isSubscribe, traceEvent)
|
||||
ToastUtils.toast("${gameEntity.name}已加入下载队列")
|
||||
if (BrowserInstallHelper.shouldAutoSwitchAssistantInstall(gameEntity)) {
|
||||
val toast = context.getString(R.string.unsupported_browser_install_hint)
|
||||
AppExecutor.uiExecutor.executeWithDelay({
|
||||
ToastUtils.toast(toast)
|
||||
}, 1000)
|
||||
}
|
||||
} else {
|
||||
ToastUtils.toast(msg)
|
||||
}
|
||||
@ -463,7 +489,7 @@ object GameActivityDownloadHelper {
|
||||
gameEntity.getEntryMap().remove(apkEntity.getPlatform())
|
||||
}
|
||||
PackageUtils.isCanPluggable(apkEntity) -> {
|
||||
DialogHelper.showPluginDialog(context) { PackageInstaller.uninstall(context, path) }
|
||||
DialogHelper.showPluginDialog(context, gameEntity.pluginDesc) { PackageInstaller.uninstall(context, path) }
|
||||
}
|
||||
else -> {
|
||||
PackageInstaller.install(context, downloadEntity)
|
||||
@ -483,6 +509,12 @@ object GameActivityDownloadHelper {
|
||||
) {
|
||||
DownloadManager.createDownload(context, apk, gameEntity, "更新", entrance, location, isSubscribe, traceEvent)
|
||||
ToastUtils.toast("${gameEntity.name}已加入下载队列")
|
||||
if (BrowserInstallHelper.shouldAutoSwitchAssistantInstall(gameEntity)) {
|
||||
val toast = context.getString(R.string.unsupported_browser_install_hint)
|
||||
AppExecutor.uiExecutor.executeWithDelay({
|
||||
ToastUtils.toast(toast)
|
||||
}, 1000)
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
|
||||
@ -8,6 +8,7 @@ import androidx.annotation.WorkerThread;
|
||||
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.simulator.SimulatorGameManager;
|
||||
import com.gh.gamecenter.common.constant.Constants;
|
||||
import com.gh.gamecenter.feature.view.DownloadButton;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.gamecenter.R;
|
||||
@ -180,7 +181,8 @@ public class GameUtils {
|
||||
if (gameEntity.isVGame()) {
|
||||
return context.getString(R.string.smooth);
|
||||
} else {
|
||||
if ("smooth".equals(gameEntity.getDownloadStatus())) {
|
||||
if (Constants.V_GAME.equals(gameEntity.getDownloadStatus())
|
||||
|| Constants.V_GAME_32.equals(gameEntity.getDownloadStatus())) {
|
||||
GameEntity.GameCategory gameCategory = gameEntity.getGameCategory();
|
||||
if (gameCategory.equals(GameEntity.GameCategory.ONLINE_GAME)
|
||||
|| gameCategory.equals(GameEntity.GameCategory.INTERNATIONAL_ONLINE_GAME)) {
|
||||
|
||||
@ -786,7 +786,7 @@ public class LibaoUtils {
|
||||
, "关闭", "启动游戏"
|
||||
, () -> {
|
||||
if (LibaoUtils.isAppInstalled(context, libaoEntity.getPackageName())) {
|
||||
PackageUtils.launchApplicationByPackageName(context, libaoEntity.getPackageName());
|
||||
PackageLauncher.launchApp(context, null, libaoEntity.getPackageName());
|
||||
} else {
|
||||
Utils.toast(context, "请安装游戏:" + libaoEntity.getGame().getName()
|
||||
+ PlatformUtils.getInstance(context).getPlatformName(libaoEntity.getPlatform()) + "版");
|
||||
|
||||
@ -23,6 +23,9 @@ object NewFlatLogUtils {
|
||||
private const val KEY_TEXT = "text"
|
||||
private const val KEY_BUTTON_TYPE = "button_type"
|
||||
private const val KEY_BBS_ID = "bbs_id"
|
||||
private const val KEY_GAME_CATEGORY = "game_category"
|
||||
private const val KEY_DOWNLOAD_STATE = "download_state"
|
||||
private const val KEY_LOCATION = "location"
|
||||
|
||||
private const val EVENT_LOGIN_FROM_GHZS_SHOW = "halo_fun_login_from_ghzs_show"
|
||||
private const val EVENT_LOGIN_FROM_GHZS_CLICK = "halo_fun_login_from_ghzs_click"
|
||||
@ -118,7 +121,7 @@ object NewFlatLogUtils {
|
||||
fun logHaloFunGameDetailJumpClick(downloadStatus: String, gameId: String) {
|
||||
val json = json {
|
||||
KEY_EVENT to "halo_fun_game_detail_jump_click"
|
||||
"download_state" to downloadStatus
|
||||
KEY_DOWNLOAD_STATE to downloadStatus
|
||||
KEY_GAME_ID to gameId
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
@ -684,7 +687,7 @@ object NewFlatLogUtils {
|
||||
val json = json {
|
||||
KEY_EVENT to "halo_self_publish_content"
|
||||
"tab_name" to tabName
|
||||
"location" to location
|
||||
KEY_LOCATION to location
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json)
|
||||
@ -1052,10 +1055,11 @@ object NewFlatLogUtils {
|
||||
}
|
||||
|
||||
//游戏单广场浏览时长
|
||||
fun logGameCollectSquareStayTime(interval: Long) {
|
||||
fun logGameCollectSquareStayTime(interval: Long, source: String) {
|
||||
val json = json {
|
||||
KEY_EVENT to "game_collect_square_stay_time"
|
||||
"interval" to interval
|
||||
"source" to source
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json)
|
||||
@ -1479,7 +1483,7 @@ object NewFlatLogUtils {
|
||||
) {
|
||||
val json = json {
|
||||
KEY_EVENT to "game_detail_comment_tab_game_comment_click"
|
||||
"location" to location
|
||||
KEY_LOCATION to location
|
||||
"tag" to tag
|
||||
"filter_tag_name" to filter
|
||||
"button" to button
|
||||
@ -1521,7 +1525,7 @@ object NewFlatLogUtils {
|
||||
) {
|
||||
val json = json {
|
||||
KEY_EVENT to "game_detail_comment_tab_game_comment_detail_click"
|
||||
"location" to location
|
||||
KEY_LOCATION to location
|
||||
"tag" to tag
|
||||
"filter_tag_name" to filter
|
||||
"button" to button
|
||||
@ -1623,7 +1627,7 @@ object NewFlatLogUtils {
|
||||
val json = json {
|
||||
"event" to "game_test_detail_game_category_click"
|
||||
"tab_name" to tabName
|
||||
"game_category" to gameCategory
|
||||
KEY_GAME_CATEGORY to gameCategory
|
||||
"game_test_start_type" to gameTestStartType
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
@ -1658,7 +1662,7 @@ object NewFlatLogUtils {
|
||||
val json = json {
|
||||
"event" to "game_test_home_more_click"
|
||||
"text" to text //右上角文案,包括:全部、更多
|
||||
"location" to location //新游开测所处位置,包括:首页、版块
|
||||
KEY_LOCATION to location //新游开测所处位置,包括:首页、版块
|
||||
"block_id" to blockId //新游开测所处位置为“版块”,上报版块ID
|
||||
"block_name" to blockName //新游开测所处位置为“版块”,上报版块名称
|
||||
"link_type" to linkType //右上角文案为“更多”时的链接类型
|
||||
@ -1685,7 +1689,7 @@ object NewFlatLogUtils {
|
||||
) {
|
||||
val json = json {
|
||||
"event" to "game_test_home_recommend_tag_click"
|
||||
"location" to location //新游开测所处位置,包括:首页、版块
|
||||
KEY_LOCATION to location //新游开测所处位置,包括:首页、版块
|
||||
"block_id" to blockId //新游开测所处位置为“版块”,上报版块ID
|
||||
"block_name" to blockName //新游开测所处位置为“版块”,上报版块名称
|
||||
"tag_id" to tagId //点击推荐标签的ID
|
||||
@ -1733,7 +1737,7 @@ object NewFlatLogUtils {
|
||||
) {
|
||||
val json = json {
|
||||
"event" to "game_test_home_view"
|
||||
"location" to location //新游开测所处位置,包括:首页、版块
|
||||
KEY_LOCATION to location //新游开测所处位置,包括:首页、版块
|
||||
"block_id" to blockId //新游开测所处位置为“版块”,上报版块ID
|
||||
"block_name" to blockName //新游开测所处位置为“版块”,上报版块名称
|
||||
"interval" to interval //内容在屏幕可见范围完整展示的时长
|
||||
@ -1988,7 +1992,7 @@ object NewFlatLogUtils {
|
||||
"type" to homeSubSlide.cardType
|
||||
"text" to homeSubSlide.cardText
|
||||
"count_num" to countNum
|
||||
"location" to location
|
||||
KEY_LOCATION to location
|
||||
"link_type" to homeSubSlide.linkType
|
||||
"link_id" to homeSubSlide.linkId
|
||||
"link_text" to homeSubSlide.linkText
|
||||
@ -2185,4 +2189,155 @@ object NewFlatLogUtils {
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
// 游戏单广场刷新
|
||||
@JvmStatic
|
||||
fun logGameCollectionSquareFlush(action: String, countNum: Int) {
|
||||
val json = json {
|
||||
KEY_EVENT to "game_list_square_flush"
|
||||
"action" to action
|
||||
"count_num" to countNum
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json)
|
||||
}
|
||||
|
||||
// 游戏详情点击公告文章
|
||||
@JvmStatic
|
||||
fun logGameDetailNoticeClick(gameId: String, gameName: String, linkId: String, linkType: String, linkText: String) {
|
||||
val json = json {
|
||||
KEY_EVENT to "game_detail_notice_click"
|
||||
KEY_GAME_ID to gameId
|
||||
KEY_GAME_NAME to gameName
|
||||
"link_id" to linkId
|
||||
"link_type" to linkType
|
||||
"link_text" to linkText
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json)
|
||||
}
|
||||
|
||||
// 启动游戏(UI被点击)
|
||||
fun logGameLaunchButtonClicked(
|
||||
gameId: String,
|
||||
gameName: String,
|
||||
location: String,
|
||||
gameCategory: String,
|
||||
downloadStatus: String
|
||||
) {
|
||||
val json = json {
|
||||
KEY_EVENT to "game_launch_button_click"
|
||||
KEY_GAME_ID to gameId
|
||||
KEY_GAME_NAME to gameName
|
||||
KEY_LOCATION to location
|
||||
KEY_GAME_CATEGORY to gameCategory
|
||||
KEY_DOWNLOAD_STATE to downloadStatus
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json)
|
||||
}
|
||||
|
||||
// 启动游戏(具体实现逻辑)
|
||||
fun logGameLaunch(
|
||||
gameId: String,
|
||||
gameName: String,
|
||||
gameCategory: String,
|
||||
downloadStatus: String
|
||||
) {
|
||||
val json = json {
|
||||
KEY_EVENT to "game_launch"
|
||||
KEY_GAME_ID to gameId
|
||||
KEY_GAME_NAME to gameName
|
||||
KEY_GAME_CATEGORY to gameCategory
|
||||
KEY_DOWNLOAD_STATE to downloadStatus
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json)
|
||||
}
|
||||
|
||||
// 进入游戏单热榜
|
||||
@JvmStatic
|
||||
fun logGameCollectionHotListEnter(entrance: String) {
|
||||
val json = json {
|
||||
KEY_EVENT to "game_list_hot_rank_enter"
|
||||
"entrance" to entrance
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json)
|
||||
}
|
||||
|
||||
// 离开游戏单热榜
|
||||
@JvmStatic
|
||||
fun logGameCollectionHotListExit(interval: Long, tabName: String) {
|
||||
val json = json {
|
||||
KEY_EVENT to "game_list_hot_rank_exit"
|
||||
"interval" to interval
|
||||
"tab_name" to tabName
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json)
|
||||
}
|
||||
|
||||
// 游戏热榜点击tab
|
||||
@JvmStatic
|
||||
fun logGameCollectionHotListTabClick(tabName: String, collectionId: String, collectionName: String) {
|
||||
val json = json {
|
||||
KEY_EVENT to "game_hot_rank_tab_click"
|
||||
"tab_name" to tabName
|
||||
"game_list_collection_id" to collectionId
|
||||
"game_list_collection_name" to collectionName
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json)
|
||||
}
|
||||
|
||||
// 游戏热榜tab浏览
|
||||
@JvmStatic
|
||||
fun logGameCollectionHotListTabView(interval: Int, tabName: String, collectionId: String, collectionName: String) {
|
||||
val json = json {
|
||||
KEY_EVENT to "game_hot_rank_tab_view"
|
||||
"interval" to interval
|
||||
"tab_name" to tabName
|
||||
"game_list_collection_id" to collectionId
|
||||
"game_list_collection_name" to collectionName
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json)
|
||||
}
|
||||
|
||||
// 游戏单热榜点击
|
||||
@JvmStatic
|
||||
fun logGameCollectionHotListClick(tabName: String, collectionId: String, collectionName: String, text: String) {
|
||||
val json = json {
|
||||
KEY_EVENT to "game_list_hot_rank_click"
|
||||
"tab_name" to tabName
|
||||
"game_list_collection_id" to collectionId
|
||||
"game_list_collection_name" to collectionName
|
||||
"text" to text
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json)
|
||||
}
|
||||
|
||||
// 游戏单合集点击
|
||||
fun logGameListCollectionClick(
|
||||
source: String,
|
||||
blockName: String,
|
||||
blockId: String,
|
||||
collectionName: String,
|
||||
collectionId: String,
|
||||
text: String
|
||||
) {
|
||||
val json = json {
|
||||
KEY_EVENT to "game_list_collection_click"
|
||||
"source" to source
|
||||
"block_name" to blockName
|
||||
"block_id" to blockId
|
||||
"game_list_collection_id" to collectionId
|
||||
"game_list_collection_name" to collectionName
|
||||
"text" to text
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json)
|
||||
}
|
||||
}
|
||||
@ -1657,13 +1657,22 @@ object NewLogUtils {
|
||||
}
|
||||
|
||||
//进入游戏单广场
|
||||
fun logEnterGameCollectionSquare(entrance: String, forumName: String = "", title: String = "", id: String = "") {
|
||||
fun logEnterGameCollectionSquare(
|
||||
entrance: String,
|
||||
forumName: String = "",
|
||||
gameCollectionTitle: String = "",
|
||||
gameCollectionId: String = "",
|
||||
collectionName: String = "",
|
||||
collectionId: String = ""
|
||||
) {
|
||||
val json = json {
|
||||
KEY_EVENT to "enter_game_collect_square"
|
||||
KEY_ENTRANCE to entrance
|
||||
"forum_name" to forumName
|
||||
"game_collect_title" to title
|
||||
"game_collect_id" to id
|
||||
"game_collect_title" to gameCollectionTitle
|
||||
"game_collect_id" to gameCollectionId
|
||||
"game_list_collection_name" to collectionName
|
||||
"game_list_collection_id" to collectionId
|
||||
KEY_TIMESTAMP to System.currentTimeMillis() / 1000
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
@ -1671,9 +1680,10 @@ object NewLogUtils {
|
||||
}
|
||||
|
||||
//进入选择标签
|
||||
fun logEnterGameCollectionTag() {
|
||||
fun logEnterGameCollectionTag(source: String) {
|
||||
val json = json {
|
||||
KEY_EVENT to "enter_game_collect_tag_location"
|
||||
"source" to source
|
||||
KEY_TIMESTAMP to System.currentTimeMillis() / 1000
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
@ -1681,11 +1691,12 @@ object NewLogUtils {
|
||||
}
|
||||
|
||||
//筛选游戏单标签
|
||||
fun logFilterGameCollectionTag(tagCategory: String, tagName: String) {
|
||||
fun logFilterGameCollectionTag(tagCategory: String, tagName: String, source: String) {
|
||||
val json = json {
|
||||
KEY_EVENT to "filter_game_collect_tag"
|
||||
"filter_tag_category" to tagCategory
|
||||
"filter_tag_name" to tagName
|
||||
"source" to source
|
||||
KEY_TIMESTAMP to System.currentTimeMillis() / 1000
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
@ -1693,9 +1704,10 @@ object NewLogUtils {
|
||||
}
|
||||
|
||||
//点击安利墙卡片
|
||||
fun logClickGameCollectionAmway() {
|
||||
fun logClickGameCollectionAmway(tabName: String) {
|
||||
val json = json {
|
||||
KEY_EVENT to "click_game_collect_recommend_card"
|
||||
"tab_name" to tabName
|
||||
KEY_TIMESTAMP to System.currentTimeMillis() / 1000
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.PendingIntent
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
@ -9,6 +10,7 @@ import android.view.View
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.FileProvider
|
||||
import com.gh.common.dialog.InstallPermissionDialogFragment
|
||||
import com.gh.common.xapk.XapkInstallReceiver
|
||||
import com.gh.common.xapk.XapkInstaller
|
||||
import com.gh.download.server.BrowserInstallHelper
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
@ -118,7 +120,7 @@ object PackageInstaller {
|
||||
}
|
||||
} else {
|
||||
if (isPluggin) {
|
||||
DialogHelper.showPluginDialog(context) {
|
||||
DialogHelper.showPluginDialog(context, downloadEntity?.pluginDesc) {
|
||||
uninstall(context, pkgPath)
|
||||
}
|
||||
} else {
|
||||
@ -142,6 +144,32 @@ object PackageInstaller {
|
||||
context.startActivity(installIntent)
|
||||
}
|
||||
|
||||
fun installMultiple(
|
||||
context: Context,
|
||||
pkgPath: String,
|
||||
sessionId: Int = -1
|
||||
) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
return
|
||||
}
|
||||
val installer = context.packageManager.packageInstaller
|
||||
val session = installer.openSession(sessionId)
|
||||
// 监听安装回调的组件,可以是Activity、Service或者是BroadcastReceiver
|
||||
val intent = Intent(context, XapkInstallReceiver::class.java)
|
||||
.also {
|
||||
it.putExtra(XapkInstallReceiver.KEY_PACKAGE_PATH, pkgPath)
|
||||
}
|
||||
|
||||
val flags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_CANCEL_CURRENT
|
||||
} else {
|
||||
PendingIntent.FLAG_CANCEL_CURRENT
|
||||
}
|
||||
val pendingIntent = PendingIntent.getActivity(context, sessionId, intent, flags)
|
||||
// 提交数据流并执行安装
|
||||
session.commit(pendingIntent.intentSender)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取启动安装意图
|
||||
*
|
||||
@ -216,7 +244,8 @@ object PackageInstaller {
|
||||
}
|
||||
|
||||
private fun getFileSuffixByFormat(format: String?): String {
|
||||
return if (format == XapkInstaller.XAPK_EXTENSION_NAME) {
|
||||
return if (format == Constants.XAPK_FORMAT
|
||||
|| format == Constants.XAPK_APKS_FORMAT) {
|
||||
XapkInstaller.XAPK_EXTENSION_NAME
|
||||
} else {
|
||||
"apk"
|
||||
|
||||
54
app/src/main/java/com/gh/common/util/PackageLauncher.kt
Normal file
54
app/src/main/java/com/gh/common/util/PackageLauncher.kt
Normal file
@ -0,0 +1,54 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.content.Context
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.entity.GameInstall
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.packagehelper.PackageRepository
|
||||
|
||||
object PackageLauncher {
|
||||
|
||||
/*
|
||||
* 启动应用
|
||||
*/
|
||||
@JvmStatic
|
||||
fun launchApp(
|
||||
context: Context,
|
||||
gameEntity: GameEntity? = null,
|
||||
packageName: String?
|
||||
) {
|
||||
|
||||
if (packageName.isNullOrEmpty()) {
|
||||
ToastUtils.toast("启动失败")
|
||||
return
|
||||
}
|
||||
|
||||
// 获取 GameInstall 实体,用于记录启动日志用
|
||||
val gameInstall = if (gameEntity != null) {
|
||||
GameInstall.transformGameInstall(gameEntity, packageName)
|
||||
} else {
|
||||
PackageRepository.gameInstalled.find { it.packageName == packageName }
|
||||
}
|
||||
|
||||
if (gameInstall != null) {
|
||||
NewFlatLogUtils.logGameLaunch(
|
||||
gameId = gameInstall.id ?: "unknown",
|
||||
gameName = gameInstall.name ?: "unknown",
|
||||
gameCategory = gameInstall.category ?: "unknown",
|
||||
downloadStatus = if (gameInstall.downloadStatus == "demo") "试玩" else "下载"
|
||||
)
|
||||
}
|
||||
|
||||
try {
|
||||
val intent = context.applicationContext.packageManager.getLaunchIntentForPackage(packageName)
|
||||
if (intent != null) {
|
||||
context.startActivity(intent)
|
||||
} else {
|
||||
ToastUtils.toast("启动失败")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
ToastUtils.toast( "启动失败")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -746,9 +746,11 @@ public class PackageUtils {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
/**
|
||||
* 启动应用
|
||||
* 请使用 PackageLauncher.launchApp()
|
||||
*/
|
||||
@Deprecated
|
||||
public static void launchApplicationByPackageName(Context context, String packageName) {
|
||||
try {
|
||||
Intent intent = context.getApplicationContext().getPackageManager().getLaunchIntentForPackage(packageName);
|
||||
|
||||
@ -66,7 +66,7 @@ object RealNameHelper {
|
||||
"game_name",
|
||||
downloadEntity.name ?: "",
|
||||
"game_type",
|
||||
downloadEntity.meta[Constants.GAME_TYPE] ?: ""
|
||||
downloadEntity.meta[Constants.GAME_CATEGORY_IN_CHINESE] ?: ""
|
||||
)
|
||||
|
||||
val contentText = if (downloadEntity.status == DownloadStatus.done) {
|
||||
|
||||
59
app/src/main/java/com/gh/common/xapk/XapkInstallReceiver.kt
Normal file
59
app/src/main/java/com/gh/common/xapk/XapkInstallReceiver.kt
Normal file
@ -0,0 +1,59 @@
|
||||
package com.gh.common.xapk
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageInstaller
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
class XapkInstallReceiver : Activity() {
|
||||
|
||||
companion object {
|
||||
const val KEY_PACKAGE_PATH = "package_path"
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
overridePendingTransition(0, 0)
|
||||
handleIntent(this, intent)
|
||||
|
||||
}
|
||||
|
||||
private fun handleIntent(context: Context, intent: Intent) {
|
||||
when (intent.getIntExtra(PackageInstaller.EXTRA_STATUS, -999)) {
|
||||
PackageInstaller.STATUS_PENDING_USER_ACTION -> {
|
||||
val installIntent = intent.getParcelableExtra<Intent>(Intent.EXTRA_INTENT)
|
||||
if (installIntent != null) {
|
||||
context.startActivity(installIntent)
|
||||
updatePendingSessionInfoStatus(intent, XapkPendingSessionInfo.STATUS_PENDING_USER_ACTION)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
PackageInstaller.STATUS_FAILURE,
|
||||
PackageInstaller.STATUS_FAILURE_ABORTED,
|
||||
PackageInstaller.STATUS_FAILURE_BLOCKED,
|
||||
PackageInstaller.STATUS_FAILURE_CONFLICT,
|
||||
PackageInstaller.STATUS_FAILURE_INCOMPATIBLE,
|
||||
PackageInstaller.STATUS_FAILURE_INVALID,
|
||||
PackageInstaller.STATUS_FAILURE_STORAGE -> {
|
||||
updatePendingSessionInfoStatus(intent, XapkPendingSessionInfo.STATUS_INSTALL_CANCELED)
|
||||
finish()
|
||||
}
|
||||
else -> {
|
||||
updatePendingSessionInfoStatus(intent, XapkPendingSessionInfo.STATUS_INSTALL_SUCCESS)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updatePendingSessionInfoStatus(intent: Intent, status: Int) {
|
||||
val installPackagePath = intent.getStringExtra(KEY_PACKAGE_PATH)
|
||||
if (!installPackagePath.isNullOrEmpty()) {
|
||||
val pendingSessionInfo = XapkInstaller.getPendingSessionInfo(installPackagePath)
|
||||
pendingSessionInfo?.updateStatus(status)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2,20 +2,34 @@ package com.gh.common.xapk
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.provider.Settings
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.common.util.*
|
||||
import com.gh.download.DownloadDataHelper
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.common.utils.debugOnly
|
||||
import com.gh.gamecenter.common.utils.getExtension
|
||||
import com.gh.gamecenter.common.utils.throwExceptionInDebug
|
||||
import com.gh.gamecenter.common.utils.tryCatchInRelease
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.core.utils.SentryHelper
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.xapk.XApkUnZipper
|
||||
import com.gh.gamecenter.xapk.core.XApkFile
|
||||
import com.gh.gamecenter.xapk.core.XApkUnZipCallback
|
||||
import com.gh.gamecenter.xapk.core.XApkUnZipEntry
|
||||
import com.gh.gamecenter.xapk.core.XApkUnZipOutputFactory
|
||||
import com.gh.gamecenter.xapk.io.NonSplitApksOutput
|
||||
import com.gh.gamecenter.xapk.io.OBBFileOutput
|
||||
import com.gh.gamecenter.xapk.io.SplitApksOutput
|
||||
import com.gh.gamecenter.xapk.io.XApkFileOutput
|
||||
import com.gh.gamecenter.xapk.pi.IPackageInstaller
|
||||
import com.gh.ndownload.NDataChanger
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import com.lightgame.utils.Utils
|
||||
import java.text.DecimalFormat
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@ -28,7 +42,8 @@ import java.util.*
|
||||
* apk文件这解压的gh-files文件夹中
|
||||
*/
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
object XapkInstaller : IXapkUnzipListener {
|
||||
object XapkInstaller : XApkUnZipCallback, XApkUnZipOutputFactory {
|
||||
|
||||
private const val XAPK_PACKAGE_PATH_TAG = "xapk_package_path"
|
||||
|
||||
const val XAPK_EXTENSION_NAME = "xapk"
|
||||
@ -40,10 +55,19 @@ object XapkInstaller : IXapkUnzipListener {
|
||||
const val XAPK_DATA_EXTENSION_NAME = "obb"
|
||||
const val PACKAGE_EXTENSION_NAME = "apk"
|
||||
|
||||
private const val GUIDE_TYPE_MIUI_OPTIMIZATION = "miui_optimization"
|
||||
private const val MIUI_OPTIMIZATION_WARNING_DIALOG_ENTRANCE = "MIUI优化关闭提示弹窗"
|
||||
|
||||
private var mContext = HaloApp.getInstance().application.applicationContext
|
||||
|
||||
// 是否需要开启特定线程处理
|
||||
private val mXapkUnzipThreadMap = Collections.synchronizedMap(HashMap<String, XapkUnzipThread>())
|
||||
private val mXApkUnZipper = XApkUnZipper(this)
|
||||
.also {
|
||||
it.registerCallback(this)
|
||||
}
|
||||
|
||||
private val mDownloadEntityMap = Collections.synchronizedMap(HashMap<String, DownloadEntity>())
|
||||
|
||||
private val mPendingSessionInfoMap = HashMap<String, XapkPendingSessionInfo>()
|
||||
|
||||
// 按并行解压
|
||||
@JvmStatic
|
||||
@ -52,6 +76,35 @@ object XapkInstaller : IXapkUnzipListener {
|
||||
|
||||
val filePath = downloadEntity.path
|
||||
if (XAPK_EXTENSION_NAME == filePath.getExtension()) {
|
||||
if (MiuiUtils.isMiui() && !MiuiUtils.isMiuiOptimizationDisabled() && downloadEntity.format == Constants.XAPK_APKS_FORMAT) {// 小米手机开启miui以后,需要引导用户关闭miui优化
|
||||
DialogHelper.showMiuiOptimizationWarning(
|
||||
context,
|
||||
onHintClick = {
|
||||
val guides = Config.getNewApiSettingsEntity()?.install
|
||||
val miuiOptimizationGuide = guides?.guides?.findLast {
|
||||
it.type == GUIDE_TYPE_MIUI_OPTIMIZATION
|
||||
}
|
||||
if (miuiOptimizationGuide != null) {
|
||||
DirectUtils.directToLinkPage(
|
||||
context,
|
||||
miuiOptimizationGuide.link,
|
||||
MIUI_OPTIMIZATION_WARNING_DIALOG_ENTRANCE,
|
||||
""
|
||||
)
|
||||
}
|
||||
},
|
||||
onConfirmClick = {
|
||||
if (SystemUtils.isDevelopmentSettingsEnabled(context)) {
|
||||
context.startActivity(Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS))
|
||||
it.dismiss()
|
||||
} else {
|
||||
ToastUtils.showToast(context.getString(R.string.miui_open_adb_hint))
|
||||
}
|
||||
}
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
unzipXapkFile(downloadEntity)
|
||||
if (showUnzipToast) {
|
||||
Utils.toast(mContext, "解压过程请勿退出光环助手!")
|
||||
@ -63,122 +116,230 @@ object XapkInstaller : IXapkUnzipListener {
|
||||
}
|
||||
|
||||
private fun unzipXapkFile(downloadEntity: DownloadEntity) {
|
||||
if (mXapkUnzipThreadMap[downloadEntity.path] == null) {
|
||||
DownloadDataHelper.uploadDownloadStatusEvent(downloadEntity, "xapk解压开始")
|
||||
val xapkUnzipThread = XapkUnzipThread(downloadEntity, this)
|
||||
xapkUnzipThread.start()
|
||||
mXapkUnzipThreadMap[downloadEntity.path] = xapkUnzipThread
|
||||
} else {
|
||||
debugOnly {
|
||||
Utils.log("unzip", "重复解压,该文件解压已在队列中")
|
||||
}
|
||||
}
|
||||
mXApkUnZipper.unzip(
|
||||
XApkUnZipEntry(
|
||||
downloadEntity.path,
|
||||
File(downloadEntity.path)
|
||||
)
|
||||
)
|
||||
mDownloadEntityMap[downloadEntity.path] = downloadEntity
|
||||
}
|
||||
|
||||
override fun onProgress(downloadEntity: DownloadEntity, unzipPath: String, unzipSize: Long, unzipProgress: Long) {
|
||||
AppExecutor.uiExecutor.execute {
|
||||
val df = DecimalFormat("#.0")
|
||||
var percent = 0.0
|
||||
tryCatchInRelease {
|
||||
percent = df.format((unzipProgress / unzipSize.toFloat()) * 100).toDouble()
|
||||
}
|
||||
downloadEntity.meta[XAPK_UNZIP_PERCENT] = percent.toString()
|
||||
downloadEntity.meta[XAPK_UNZIP_STATUS] = XapkUnzipStatus.UNZIPPING.name
|
||||
@JvmStatic
|
||||
fun cancelUnzipTask(downloadEntity: DownloadEntity) {
|
||||
mXApkUnZipper.cancel(downloadEntity.path)
|
||||
}
|
||||
|
||||
override fun onProgress(apk: XApkFile, progress: Float) {
|
||||
val downloadEntity = mDownloadEntityMap[apk.file.path] ?: return
|
||||
downloadEntity.meta[XAPK_UNZIP_PERCENT] = String.format("%.2f", progress * 100)
|
||||
downloadEntity.meta[XAPK_UNZIP_STATUS] = XapkUnzipStatus.UNZIPPING.name
|
||||
|
||||
AppExecutor.ioExecutor.execute {
|
||||
NDataChanger.notifyDataChanged(downloadEntity)
|
||||
}
|
||||
|
||||
debugOnly {
|
||||
Utils.log("unzip", "onProgress->" + (unzipProgress / unzipSize.toFloat()))
|
||||
Utils.log("unzip", "onProgress->$progress")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onNext(downloadEntity: DownloadEntity, unzipPath: String) {
|
||||
if (PACKAGE_EXTENSION_NAME == unzipPath.getExtension()) {
|
||||
downloadEntity.meta[XAPK_PACKAGE_PATH_TAG] = unzipPath
|
||||
override fun onSuccess(apk: XApkFile, installer: IPackageInstaller) {
|
||||
val downloadEntity = mDownloadEntityMap[apk.file.path] ?: return
|
||||
|
||||
downloadEntity.meta[XAPK_UNZIP_PERCENT] = "100.0"
|
||||
downloadEntity.meta[XAPK_UNZIP_STATUS] = XapkUnzipStatus.SUCCESS.name
|
||||
|
||||
AppExecutor.ioExecutor.execute {
|
||||
NDataChanger.notifyDataChanged(downloadEntity)
|
||||
DownloadManager.getInstance().updateDownloadEntity(downloadEntity)
|
||||
DownloadDataHelper.uploadDownloadStatusEvent(downloadEntity, "xapk解压成功")
|
||||
}
|
||||
|
||||
debugOnly {
|
||||
Utils.log("unzip", "onNext->$unzipPath")
|
||||
Utils.log("unzip", "onSuccess->${downloadEntity.path}")
|
||||
}
|
||||
|
||||
installer.install(mContext)
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消解压回调
|
||||
*
|
||||
* 取消后的表现与下载完成一致
|
||||
*/
|
||||
override fun onCancel(downloadEntity: DownloadEntity) {
|
||||
mXapkUnzipThreadMap.remove(downloadEntity.path)
|
||||
override fun onError(apk: XApkFile, exception: Throwable) {
|
||||
val downloadEntity = mDownloadEntityMap[apk.file.path] ?: return
|
||||
downloadEntity.meta[XAPK_UNZIP_STATUS] = XapkUnzipStatus.FAILURE.name
|
||||
|
||||
AppExecutor.uiExecutor.execute {
|
||||
downloadEntity.meta[XAPK_UNZIP_PERCENT] = "0.0"
|
||||
downloadEntity.meta[XAPK_UNZIP_STATUS] = XapkUnzipStatus.CANCEL.name
|
||||
NDataChanger.notifyDataChanged(downloadEntity)
|
||||
DownloadManager.getInstance().updateDownloadEntity(downloadEntity)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailure(downloadEntity: DownloadEntity, exception: Exception) {
|
||||
mXapkUnzipThreadMap.remove(downloadEntity.path)
|
||||
|
||||
AppExecutor.uiExecutor.execute {
|
||||
downloadEntity.meta[XAPK_UNZIP_STATUS] = XapkUnzipStatus.FAILURE.name
|
||||
AppExecutor.ioExecutor.execute {
|
||||
DownloadNotificationHelper.addOrUpdateDownloadNotification(downloadEntity)
|
||||
NDataChanger.notifyDataChanged(downloadEntity)
|
||||
DownloadManager.getInstance().updateDownloadEntity(downloadEntity)
|
||||
}
|
||||
// 仅官网渠道上报 XAPK 异常信息
|
||||
if (HaloApp.getInstance().channel == "GH_206") {
|
||||
SentryHelper.onEvent(
|
||||
"XAPK_UNZIP_ERROR",
|
||||
"gameName", downloadEntity.name,
|
||||
"errorDigest", exception.localizedMessage
|
||||
)
|
||||
}
|
||||
|
||||
// 仅官网渠道上报 XAPK 异常信息
|
||||
if (HaloApp.getInstance().channel == "GH_206") {
|
||||
SentryHelper.onEvent(
|
||||
"XAPK_UNZIP_ERROR",
|
||||
"gameName", downloadEntity.name,
|
||||
"errorDigest", exception.localizedMessage
|
||||
)
|
||||
DownloadDataHelper.uploadDownloadStatusEvent(downloadEntity, "xapk解压失败")
|
||||
}
|
||||
|
||||
DownloadDataHelper.uploadDownloadStatusEvent(downloadEntity, "xapk解压失败")
|
||||
|
||||
debugOnly {
|
||||
Utils.log("unzip", "onFailure->$exception")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSuccess(downloadEntity: DownloadEntity) {
|
||||
mXapkUnzipThreadMap.remove(downloadEntity.path)
|
||||
|
||||
AppExecutor.uiExecutor.execute {
|
||||
val pkgPath = downloadEntity.meta[XAPK_PACKAGE_PATH_TAG]
|
||||
|
||||
if (pkgPath == null) {
|
||||
Utils.toast(mContext, "下载出错,请重新下载!")
|
||||
|
||||
return@execute
|
||||
}
|
||||
|
||||
PackageInstaller.install(mContext, downloadEntity.isPlugin, pkgPath, downloadEntity)
|
||||
|
||||
downloadEntity.meta[XAPK_UNZIP_PERCENT] = "100.0"
|
||||
downloadEntity.meta[XAPK_UNZIP_STATUS] = XapkUnzipStatus.SUCCESS.name
|
||||
override fun onCancel(apk: XApkFile) {
|
||||
val downloadEntity = mDownloadEntityMap.remove(apk.file.path) ?: return
|
||||
downloadEntity.meta[XAPK_UNZIP_PERCENT] = "0.0"
|
||||
downloadEntity.meta[XAPK_UNZIP_STATUS] = XapkUnzipStatus.CANCEL.name
|
||||
AppExecutor.ioExecutor.execute {
|
||||
NDataChanger.notifyDataChanged(downloadEntity)
|
||||
DownloadManager.getInstance().updateDownloadEntity(downloadEntity)
|
||||
}
|
||||
}
|
||||
|
||||
DownloadDataHelper.uploadDownloadStatusEvent(downloadEntity, "xapk解压成功")
|
||||
|
||||
override fun onNext(apk: XApkFile, fileName: String) {
|
||||
debugOnly {
|
||||
Utils.log("unzip", "onSuccess->${downloadEntity.path}")
|
||||
Utils.log("unzip", "onNext->$fileName")
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun cancelUnzipTask(downloadEntity: DownloadEntity) {
|
||||
val xapkUnzipThread = mXapkUnzipThreadMap[downloadEntity.path]
|
||||
if (xapkUnzipThread != null) {
|
||||
xapkUnzipThread.canceled = true
|
||||
fun getPendingSessionInfo(packagePath: String): XapkPendingSessionInfo? = mPendingSessionInfoMap[packagePath]
|
||||
|
||||
fun isInstalling(packagePath: String): Boolean = mPendingSessionInfoMap.containsKey(packagePath)
|
||||
|
||||
/**
|
||||
* 通知XAPK安装完成
|
||||
*/
|
||||
fun onInstalled(packagePath: String) {
|
||||
val downloadEntity = mDownloadEntityMap.remove(packagePath) ?: return
|
||||
|
||||
mPendingSessionInfoMap.remove(packagePath)
|
||||
|
||||
downloadEntity.meta[XAPK_UNZIP_PERCENT] = "100.0"
|
||||
downloadEntity.meta[XAPK_UNZIP_STATUS] = XapkUnzipStatus.INSTALLED.name
|
||||
|
||||
AppExecutor.ioExecutor.execute {
|
||||
NDataChanger.notifyDataChanged(downloadEntity)
|
||||
DownloadManager.getInstance().updateDownloadEntity(downloadEntity)
|
||||
DownloadDataHelper.uploadDownloadStatusEvent(downloadEntity, "xapk安装成功")
|
||||
}
|
||||
}
|
||||
|
||||
fun onInstallCanceled(packagePath: String) {
|
||||
|
||||
val downloadEntity = mDownloadEntityMap.remove(packagePath) ?: return
|
||||
|
||||
mPendingSessionInfoMap.remove(packagePath)
|
||||
|
||||
downloadEntity.meta[XAPK_UNZIP_PERCENT] = "0.0"
|
||||
downloadEntity.meta[XAPK_UNZIP_STATUS] = XapkUnzipStatus.CANCEL.name
|
||||
|
||||
AppExecutor.ioExecutor.execute {
|
||||
NDataChanger.notifyDataChanged(downloadEntity)
|
||||
DownloadManager.getInstance().updateDownloadEntity(downloadEntity)
|
||||
DownloadDataHelper.uploadDownloadStatusEvent(downloadEntity, "xapk安装取消")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新当前XAPK安装状态, 主要针对以下出现安装结果回调异常的情况:
|
||||
* 1. 用户触碰安装弹窗(原生Android系统)区域外导致安装取消
|
||||
*/
|
||||
fun updateCurrentInstallStatus() {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP || mPendingSessionInfoMap.isEmpty()) {
|
||||
return
|
||||
}
|
||||
|
||||
val updateList = mutableListOf<XapkPendingSessionInfo>()
|
||||
|
||||
for (pendingSessionInfoEntry in mPendingSessionInfoMap) {
|
||||
|
||||
val pendingSessionInfo = pendingSessionInfoEntry.value
|
||||
|
||||
if (pendingSessionInfo.getStatus() == XapkPendingSessionInfo.STATUS_PENDING_USER_ACTION) {// 用户触摸安装弹窗外部区域取消安装后,更新安装状态
|
||||
val installer = mContext.packageManager.packageInstaller
|
||||
val sessionId = pendingSessionInfo.sessionId
|
||||
if (sessionId != -1) {
|
||||
val sessionInfo = installer.getSessionInfo(sessionId)
|
||||
// 表示用户点击了安装弹窗外部区域
|
||||
if (sessionInfo == null) {
|
||||
pendingSessionInfo.updateStatus(XapkPendingSessionInfo.STATUS_INSTALL_CANCELED)
|
||||
} else if (sessionInfo.progress <= 0.8F) {
|
||||
AppExecutor.ioExecutor.execute {
|
||||
installer.abandonSession(sessionInfo.sessionId)
|
||||
}
|
||||
pendingSessionInfo.updateStatus(XapkPendingSessionInfo.STATUS_INSTALL_CANCELED)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val installStatus = pendingSessionInfo.getStatus()
|
||||
if (installStatus == XapkPendingSessionInfo.STATUS_INSTALL_CANCELED
|
||||
|| installStatus == XapkPendingSessionInfo.STATUS_INSTALL_SUCCESS
|
||||
) {
|
||||
updateList.add(pendingSessionInfo)
|
||||
}
|
||||
}
|
||||
|
||||
for (pendingSessionInfo in updateList) {
|
||||
val downloadEntity = mDownloadEntityMap[pendingSessionInfo.path] ?: continue
|
||||
val installStatus = pendingSessionInfo.getStatus()
|
||||
if (installStatus == XapkPendingSessionInfo.STATUS_INSTALL_SUCCESS) {
|
||||
onInstalled(downloadEntity.path)
|
||||
} else if (installStatus == XapkPendingSessionInfo.STATUS_INSTALL_CANCELED) {
|
||||
onInstallCanceled(downloadEntity.path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateOBBOutput(apk: XApkFile): XApkFileOutput<Unit> {
|
||||
return OBBFileOutput()
|
||||
}
|
||||
|
||||
override fun onCreateApkOutput(apk: XApkFile): XApkFileOutput<IPackageInstaller> {
|
||||
val isMultiApks = apk.manifest.isMultiApks
|
||||
return if (isMultiApks) {
|
||||
SplitApksOutput(mContext.applicationContext) {
|
||||
SplitApksInstaller(apk, it)
|
||||
}
|
||||
} else {
|
||||
onCancel(downloadEntity) // 刷新页面
|
||||
NonSplitApksOutput {
|
||||
NonSplitApkInstaller(apk, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class SplitApksInstaller(
|
||||
private val xApkFile: XApkFile,
|
||||
private val sessionId: Int,
|
||||
) : IPackageInstaller {
|
||||
|
||||
override fun install(context: Context) {
|
||||
val applicationContext = context.applicationContext
|
||||
val downloadEntity = mDownloadEntityMap[xApkFile.file.path] ?: return
|
||||
|
||||
mPendingSessionInfoMap[downloadEntity.path] = XapkPendingSessionInfo(downloadEntity.path, sessionId)
|
||||
AppExecutor.ioExecutor.execute {// 有可能卡顿造成anr
|
||||
PackageInstaller.installMultiple(applicationContext, downloadEntity.path, sessionId)
|
||||
NDataChanger.notifyDataChanged(downloadEntity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class NonSplitApkInstaller(
|
||||
private val xApkFile: XApkFile,
|
||||
private val file: File
|
||||
) : IPackageInstaller {
|
||||
|
||||
override fun install(context: Context) {
|
||||
val downloadEntity = mDownloadEntityMap[xApkFile.file.path] ?: return
|
||||
PackageInstaller.install(
|
||||
context,
|
||||
downloadEntity.isPlugin,
|
||||
file.absolutePath,
|
||||
downloadEntity
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -187,5 +348,6 @@ enum class XapkUnzipStatus(status: String) {
|
||||
UNZIPPING("unzipping"),
|
||||
SUCCESS("success"),
|
||||
CANCEL("cancel"),
|
||||
INSTALLED("installed"),
|
||||
FAILURE("failure");
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package com.gh.common.xapk
|
||||
|
||||
class XapkPendingSessionInfo(
|
||||
val path: String,
|
||||
val sessionId: Int = -1
|
||||
) {
|
||||
companion object {
|
||||
const val STATUS_INIT = -1
|
||||
const val STATUS_PENDING_USER_ACTION = 0
|
||||
const val STATUS_INSTALL_SUCCESS = 1
|
||||
const val STATUS_INSTALL_CANCELED = 2
|
||||
}
|
||||
|
||||
private var status = STATUS_INIT
|
||||
|
||||
internal fun updateStatus(status: Int) {
|
||||
this.status = status
|
||||
}
|
||||
|
||||
fun getStatus(): Int = status
|
||||
}
|
||||
@ -23,9 +23,6 @@ import org.json.JSONObject
|
||||
object DownloadDataHelper {
|
||||
private const val TAG = "DownloadDataHelper"
|
||||
|
||||
private const val DOWNLOAD_SPEED_TIME = "download_speed_time"
|
||||
private const val DOWNLOAD_SPEED_SIZE = "download_speed_size"
|
||||
|
||||
const val DOWNLOAD_RESUME_WAY = "download_resume_way"
|
||||
const val DOWNLOAD_RESUME_MANUAL = "manual"
|
||||
const val DOWNLOAD_RESUME_AUTO = "auto"
|
||||
@ -34,8 +31,6 @@ object DownloadDataHelper {
|
||||
const val DOWNLOAD_CANCEL_MANUAL = "manual"
|
||||
const val DOWNLOAD_CANCEL_AUTO = "auto"
|
||||
|
||||
const val DOWNLOAD_FIRST_START = "download_first_start"
|
||||
|
||||
const val DOWNLOAD_THREAD_SIZE = "download_thread_size" // 线程数量,0为传统单线程模式; 1为多线程的单线程; >1为多线程的实际线程数量
|
||||
|
||||
private val mDownloadSpeedMap = HashMap<String, MutableList<Long>>()
|
||||
@ -128,7 +123,7 @@ object DownloadDataHelper {
|
||||
payloadObject.put("package", downloadEntity.packageName)
|
||||
payloadObject.put("certification", RealNameHelper.getCertificationStatus())
|
||||
payloadObject.put("filename", getFileName(downloadEntity))
|
||||
payloadObject.put("task_num", NDataChanger.downloadingTasks.size)
|
||||
payloadObject.put("task_num", NDataChanger.downloadingTaskUrlSet.size)
|
||||
jsonObject.put("payload", payloadObject)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
@ -140,26 +135,28 @@ object DownloadDataHelper {
|
||||
|
||||
@JvmStatic
|
||||
fun uploadDownloadEvent(downloadEntity: DownloadEntity) {
|
||||
val downloadSimpleEntity = DownloadDataSimpleHelper.getDownloadDataSimpleEntity(downloadEntity.url)
|
||||
|
||||
if (downloadEntity.status != DownloadStatus.downloading) {
|
||||
uploadDownloadStatusEvent(downloadEntity)
|
||||
}
|
||||
|
||||
if (downloadEntity.status == DownloadStatus.downloading) {
|
||||
val startupTime = downloadEntity.meta[DownloadEntity.DOWNLOAD_STARTUP_TIME_KEY]
|
||||
val startupTime =
|
||||
downloadSimpleEntity?.downloadStartUpTime
|
||||
if (startupTime != null) {
|
||||
uploadDownloadStartupTimeEvent(downloadEntity, startupTime.toInt())
|
||||
downloadEntity.meta.remove(DownloadEntity.DOWNLOAD_STARTUP_TIME_KEY)
|
||||
DownloadManager.getInstance().updateDownloadEntity(downloadEntity)
|
||||
uploadDownloadStartupTimeEvent(downloadEntity, startupTime)
|
||||
DownloadDataSimpleHelper.updateDownloadDataSimpleEntity(downloadEntity.url, downloadStartUpTime = null)
|
||||
}
|
||||
}
|
||||
|
||||
if (downloadEntity.status == DownloadStatus.downloading || downloadEntity.status == DownloadStatus.done) {
|
||||
val time = downloadEntity.meta[DOWNLOAD_SPEED_TIME]
|
||||
val size = downloadEntity.meta[DOWNLOAD_SPEED_SIZE]
|
||||
val time = downloadSimpleEntity?.downloadSpeedTime
|
||||
val size = downloadSimpleEntity?.downloadSpeedSize
|
||||
if (downloadEntity.speed == 0L || time == null || size == null) {
|
||||
downloadEntity.meta[DOWNLOAD_SPEED_TIME] = System.currentTimeMillis().toString()
|
||||
downloadEntity.meta[DOWNLOAD_SPEED_SIZE] = downloadEntity.progress.toString()
|
||||
DownloadManager.getInstance().updateDownloadEntity(downloadEntity)
|
||||
val currentTime = System.currentTimeMillis()
|
||||
val currentProgress = downloadEntity.progress
|
||||
DownloadDataSimpleHelper.updateDownloadDataSimpleEntity(downloadEntity.url, downloadSpeedTime = currentTime, downloadSpeedSize = currentProgress)
|
||||
} else {
|
||||
val offset = System.currentTimeMillis() - time.toLong()
|
||||
if (offset > 5000) {
|
||||
@ -180,15 +177,15 @@ object DownloadDataHelper {
|
||||
}
|
||||
}
|
||||
}
|
||||
downloadEntity.meta[DOWNLOAD_SPEED_TIME] = System.currentTimeMillis().toString()
|
||||
downloadEntity.meta[DOWNLOAD_SPEED_SIZE] = downloadEntity.progress.toString()
|
||||
DownloadManager.getInstance().updateDownloadEntity(downloadEntity)
|
||||
val currentTime = System.currentTimeMillis()
|
||||
val currentProgress = downloadEntity.progress
|
||||
DownloadDataSimpleHelper.updateDownloadDataSimpleEntity(downloadEntity.url, downloadSpeedTime = currentTime, downloadSpeedSize = currentProgress)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun uploadDownloadStartupTimeEvent(downloadEntity: DownloadEntity, startupTime: Int) {
|
||||
private fun uploadDownloadStartupTimeEvent(downloadEntity: DownloadEntity, startupTime: Long) {
|
||||
val jsonObject = JSONObject()
|
||||
|
||||
try {
|
||||
@ -214,7 +211,7 @@ object DownloadDataHelper {
|
||||
payloadObject.put("certification", RealNameHelper.getCertificationStatus())
|
||||
payloadObject.put("filename", getFileName(downloadEntity))
|
||||
payloadObject.put("launch_ms", startupTime)
|
||||
payloadObject.put("task_num", NDataChanger.downloadingTasks.size)
|
||||
payloadObject.put("task_num", NDataChanger.downloadingTaskUrlSet.size)
|
||||
if (parallel != null) {
|
||||
payloadObject.put("parallel", parallel)
|
||||
}
|
||||
@ -276,11 +273,11 @@ object DownloadDataHelper {
|
||||
payloadObject.put("speed", speed)
|
||||
}
|
||||
} else {
|
||||
payloadObject.put("task_num", NDataChanger.downloadingTasks.size)
|
||||
payloadObject.put("task_num", NDataChanger.downloadingTaskUrlSet.size)
|
||||
}
|
||||
payloadObject.put("completed_size", downloadEntity.progress / 1024 / 1024)
|
||||
if (downloadEntity.status == DownloadStatus.resume) {
|
||||
if (downloadEntity.meta[DOWNLOAD_FIRST_START] == "YES") {
|
||||
if (DownloadDataSimpleHelper.getDownloadDataSimpleEntity(downloadEntity.url)?.isFirstTimeDownload == true) {
|
||||
payloadObject.put("is_first_start", true)
|
||||
} else {
|
||||
payloadObject.put("is_first_start", false)
|
||||
@ -288,8 +285,7 @@ object DownloadDataHelper {
|
||||
}
|
||||
|
||||
if (downloadEntity.status == DownloadStatus.resume || downloadEntity.status == DownloadStatus.add) {
|
||||
downloadEntity.meta[DOWNLOAD_FIRST_START] = "NO"
|
||||
DownloadManager.getInstance().updateDownloadEntity(downloadEntity)
|
||||
DownloadDataSimpleHelper.updateDownloadSimpleEntityFirstTimeDownload(downloadEntity.url, false)
|
||||
}
|
||||
jsonObject.put("payload", payloadObject)
|
||||
} catch (e: Exception) {
|
||||
@ -329,7 +325,7 @@ object DownloadDataHelper {
|
||||
if (parallel != null) {
|
||||
payloadObject.put("parallel", parallel)
|
||||
}
|
||||
payloadObject.put("task_num", NDataChanger.downloadingTasks.size)
|
||||
payloadObject.put("task_num", NDataChanger.downloadingTaskUrlSet.size)
|
||||
jsonObject.put("payload", payloadObject)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
@ -342,7 +338,7 @@ object DownloadDataHelper {
|
||||
/**
|
||||
* 分片检测下载进度,每隔15秒内记录一次,60秒上传一次
|
||||
*
|
||||
* 请见:https://gitlab.ghzs.com/stats/stats-issues/-/issues/188#note_66919
|
||||
* 请见:https://git.shanqu.cc/stats/stats-issues/-/issues/188#note_66919
|
||||
*/
|
||||
fun uploadDownloadHeartbeat(upload: Boolean) {
|
||||
val allDownloadEntity = DownloadManager.getInstance().allDownloadEntity
|
||||
@ -352,7 +348,8 @@ object DownloadDataHelper {
|
||||
* 在后台唤醒的情况下 下载状态可能无法修正
|
||||
* see [DownloadManager.initDownloadService]
|
||||
*/
|
||||
if (downloadEntity.status == DownloadStatus.downloading && NDataChanger.downloadingTasks[downloadEntity.url] != null) {
|
||||
if (downloadEntity.status == DownloadStatus.downloading
|
||||
&& NDataChanger.downloadingTaskUrlSet.contains(downloadEntity.url)) {
|
||||
var sheet = mDownloadHeartbeatSheet[downloadEntity.url]
|
||||
if (sheet == null) {
|
||||
sheet = JSONObject()
|
||||
|
||||
@ -0,0 +1,60 @@
|
||||
package com.gh.download
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import com.gh.gamecenter.common.HaloApp
|
||||
import com.gh.gamecenter.common.utils.toJsonIgnoredNull
|
||||
import com.gh.gamecenter.common.utils.toObject
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
|
||||
/**
|
||||
* 用来简单保存/获取下载时一些额外信息的辅助类,避免下载时反复修改原始下载实体的糟糕操作
|
||||
* 使用 SP 来实现,只适用于相对较为低频的调用
|
||||
*/
|
||||
object DownloadDataSimpleHelper {
|
||||
|
||||
private val mSp: SharedPreferences by lazy {
|
||||
HaloApp.getInstance().getSharedPreferences("DownloadDataSimpleDao", Context.MODE_PRIVATE)
|
||||
}
|
||||
|
||||
fun getDownloadDataSimpleEntity(url: String): DownloadDataSimpleEntity? {
|
||||
return mSp.getString(url, "")?.toObject()
|
||||
}
|
||||
|
||||
fun updateDownloadDataSimpleEntity(
|
||||
url: String,
|
||||
downloadStartUpTime: Long? = null,
|
||||
downloadSpeedTime: Long? = null,
|
||||
downloadSpeedSize: Long? = null,
|
||||
) {
|
||||
val entity = getDownloadDataSimpleEntity(url) ?: DownloadDataSimpleEntity()
|
||||
entity.downloadStartUpTime = downloadStartUpTime
|
||||
|
||||
entity.downloadSpeedTime = downloadSpeedTime
|
||||
entity.downloadSpeedSize = downloadSpeedSize
|
||||
|
||||
SPUtils.setString(mSp, url, entity.toJsonIgnoredNull())
|
||||
}
|
||||
|
||||
fun updateDownloadSimpleEntityFirstTimeDownload(url: String, isFirstTimeDownload: Boolean) {
|
||||
val entity = getDownloadDataSimpleEntity(url) ?: DownloadDataSimpleEntity()
|
||||
|
||||
entity.isFirstTimeDownload = isFirstTimeDownload
|
||||
|
||||
SPUtils.setString(mSp, url, entity.toJsonIgnoredNull())
|
||||
}
|
||||
|
||||
fun removeDownloadSimpleEntity(url: String) {
|
||||
SPUtils.remove(mSp, url)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class DownloadDataSimpleEntity(
|
||||
var downloadStartUpTime: Long? = null,
|
||||
|
||||
var downloadSpeedTime: Long? = null,
|
||||
var downloadSpeedSize: Long? = null,
|
||||
|
||||
var isFirstTimeDownload: Boolean? = true
|
||||
)
|
||||
@ -61,7 +61,6 @@ import com.lightgame.download.DownloadDao;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
import com.lightgame.download.DownloadStatus;
|
||||
import com.lightgame.download.DownloadStatusListener;
|
||||
import com.lightgame.download.DownloadTask;
|
||||
import com.lightgame.download.FileUtils;
|
||||
import com.lightgame.download.HttpDnsManager;
|
||||
import com.lightgame.utils.Utils;
|
||||
@ -284,6 +283,7 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
|
||||
String path;
|
||||
String downloadId = PackageInstaller.createDownloadId(gameEntity.getName());
|
||||
String gameCategory = gameEntity.getCategory();
|
||||
if (SimulatorGameManager.isSimulatorGame(gameEntity)) {
|
||||
path = SimulatorGameManager.getPathByType(gameEntity.getSimulatorType()) + "/" + gameEntity.getName() + "." + apkEntity.getFormat();
|
||||
|
||||
@ -309,6 +309,7 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
downloadEntity.setUrl(apkEntity.getUrl());
|
||||
downloadEntity.setName(gameEntity.getName());
|
||||
downloadEntity.setPath(path);
|
||||
downloadEntity.setPluginDesc(gameEntity.getPluginDesc());
|
||||
downloadEntity.setETag(apkEntity.getEtag());
|
||||
downloadEntity.setIcon(gameEntity.getIcon());
|
||||
downloadEntity.setPlatform(apkEntity.getPlatform());
|
||||
@ -316,6 +317,7 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
downloadEntity.setGameId(gameEntity.getId());
|
||||
downloadEntity.setEntrance(entrance);
|
||||
downloadEntity.setLocation(location);
|
||||
downloadEntity.setFormat(apkEntity.getFormat());
|
||||
downloadEntity.setVersionName(apkEntity.getVersion());
|
||||
ExtensionsKt.addMetaExtra(downloadEntity, Constants.APK_MD5, apkEntity.getMd5());
|
||||
ExtensionsKt.addMetaExtra(downloadEntity, Constants.DOWNLOAD_ID, downloadId);
|
||||
@ -323,9 +325,11 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
ExtensionsKt.addMetaExtra(downloadEntity, Constants.GAME_ICON_SUBSCRIPT, gameEntity.getIconSubscript());
|
||||
ExtensionsKt.addMetaExtra(downloadEntity, Constants.IS_PLATFORM_RECOMMEND, apkEntity.getRecommend() != null ? "true" : "false");
|
||||
ExtensionsKt.addMetaExtra(downloadEntity, Constants.GAME_NAME, gameEntity.getName());
|
||||
ExtensionsKt.addMetaExtra(downloadEntity, Constants.GAME_TYPE, gameEntity.getCategoryChinese());
|
||||
ExtensionsKt.addMetaExtra(downloadEntity, Constants.GAME_CATEGORY_IN_CHINESE, gameEntity.getCategoryChinese());
|
||||
ExtensionsKt.addMetaExtra(downloadEntity, Constants.AD_ICON_ACTIVE, String.valueOf(gameEntity.getAdIconActive()));
|
||||
ExtensionsKt.addMetaExtra(downloadEntity, Constants.IS_AD_DATA, String.valueOf(gameEntity.isAdData()));
|
||||
ExtensionsKt.putGameCategory(downloadEntity, gameCategory != null ? gameCategory : "");
|
||||
ExtensionsKt.addMetaExtra(downloadEntity, Constants.APK_SIZE, apkEntity.getSize());
|
||||
if (gameEntity.getIconFloat() != null) {
|
||||
ExtensionsKt.addMetaExtra(downloadEntity, Constants.GAME_ICON_FLOAT_TOP_TEXT, gameEntity.getIconFloat().getUpperLeftText());
|
||||
ExtensionsKt.addMetaExtra(downloadEntity, Constants.GAME_ICON_FLOAT_TOP_COLOR, gameEntity.getIconFloat().getUpperLeftColor());
|
||||
@ -545,7 +549,7 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
* 任务是否已经下载中
|
||||
*/
|
||||
public boolean isTaskDownloading(String url) {
|
||||
if (NDataChanger.INSTANCE.getDownloadingTasks().get(url) != null) {
|
||||
if (NDataChanger.INSTANCE.getDownloadingTaskUrlSet().contains(url)) {
|
||||
Utils.log(DownloadManager.class.getSimpleName(), url + "正在下载!");
|
||||
return true;
|
||||
}
|
||||
@ -830,6 +834,7 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
*/
|
||||
public void cancel(String url, boolean isDeleteFile, boolean automatic, boolean cancelSilently) {
|
||||
DownloadEntity entry = mDownloadDao.getSnapshot(url);
|
||||
DownloadDataSimpleHelper.INSTANCE.removeDownloadSimpleEntity(url);
|
||||
if (entry != null) {
|
||||
AppExecutor.getIoExecutor().execute(() -> {
|
||||
NDownloadBridge.INSTANCE.cancel(url);
|
||||
@ -867,12 +872,8 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
private void cancelAndNotify(DownloadEntity entry, boolean cancelSilently) {
|
||||
mDownloadDao.removeErrorMessage(entry.getUrl());
|
||||
|
||||
DownloadTask task = NDataChanger.INSTANCE.getDownloadingTasks().get(entry.getUrl());
|
||||
if (task != null) {
|
||||
task.cancel();
|
||||
// 改任务队列的状态
|
||||
NDataChanger.INSTANCE.getDownloadingTasks().remove(entry.getUrl());
|
||||
}
|
||||
// 改任务队列的状态
|
||||
NDataChanger.INSTANCE.getDownloadingTaskUrlSet().remove(entry.getUrl());
|
||||
NDataChanger.INSTANCE.getDownloadEntries().remove(entry.getUrl());
|
||||
if (!cancelSilently) {
|
||||
NDataChanger.INSTANCE.notifyDataChanged(entry);
|
||||
@ -886,8 +887,10 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
* 暂停所有正在下载的任务
|
||||
*/
|
||||
public void pauseAll() {
|
||||
for (DownloadEntity entity : NDataChanger.INSTANCE.getDownloadEntries().values()) {
|
||||
pause(entity.getUrl());
|
||||
synchronized (NDataChanger.INSTANCE.getDownloadEntries()) {
|
||||
for (DownloadEntity entity : NDataChanger.INSTANCE.getDownloadEntries().values()) {
|
||||
pause(entity.getUrl());
|
||||
}
|
||||
}
|
||||
Utils.log(DownloadManager.class.getSimpleName(), "pause all");
|
||||
}
|
||||
@ -913,10 +916,10 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
* 3.检查是否显示下载通知栏
|
||||
*/
|
||||
public void initDownloadService() {
|
||||
final List<String> urlList = new ArrayList<>(NDataChanger.INSTANCE.getDownloadingTasks().keySet());
|
||||
final Set<String> urlSet = NDataChanger.INSTANCE.getDownloadingTaskUrlSet();
|
||||
for (DownloadEntity downloadEntity : getAllDownloadEntity()) {
|
||||
if (!urlList.contains(downloadEntity.getUrl()) &&
|
||||
(downloadEntity.getStatus().equals(DownloadStatus.downloading)
|
||||
if (!urlSet.contains(downloadEntity.getUrl())
|
||||
&& (downloadEntity.getStatus().equals(DownloadStatus.downloading)
|
||||
|| downloadEntity.getStatus().equals(DownloadStatus.waiting))) {
|
||||
downloadEntity.setStatus(DownloadStatus.subscribe);
|
||||
mDownloadDao.newOrUpdate(downloadEntity);
|
||||
@ -994,8 +997,11 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
}
|
||||
|
||||
if (status == DownloadStatus.add || status == DownloadStatus.subscribe) {
|
||||
if (downloadEntity.getMeta().get(DownloadDataHelper.DOWNLOAD_FIRST_START) == null) {
|
||||
downloadEntity.getMeta().put(DownloadDataHelper.DOWNLOAD_FIRST_START, "YES");
|
||||
DownloadDataSimpleEntity simpleEntity =
|
||||
DownloadDataSimpleHelper.INSTANCE.getDownloadDataSimpleEntity(downloadEntity.getUrl());
|
||||
|
||||
if (simpleEntity == null || simpleEntity.isFirstTimeDownload() == null) {
|
||||
DownloadDataSimpleHelper.INSTANCE.updateDownloadSimpleEntityFirstTimeDownload(downloadEntity.getUrl(), true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1235,7 +1241,10 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
|
||||
/**
|
||||
* 更新数据库中的下载实体
|
||||
*
|
||||
* @deprecated 随意更新数据库可能会出现意想不到的情况,建议不要随意调用
|
||||
*/
|
||||
@Deprecated()
|
||||
public void updateDownloadEntity(DownloadEntity downloadEntity) {
|
||||
mDownloadDao.update(downloadEntity, false);
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import com.gh.common.util.ConcernUtils
|
||||
import com.gh.common.util.DataCollectionUtils
|
||||
import com.gh.common.util.PackageInstaller
|
||||
import com.gh.common.util.PackageUtils
|
||||
import com.gh.common.xapk.XapkInstaller
|
||||
import com.gh.download.server.BrowserInstallHelper
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.loghub.LoghubUtils
|
||||
@ -110,6 +111,10 @@ object PackageObserver {
|
||||
runOnIoThread { FileUtils.deleteFile(mDownloadEntity.path) }
|
||||
}
|
||||
|
||||
if (mDownloadEntity.format == Constants.XAPK_FORMAT) {
|
||||
XapkInstaller.onInstalled(mDownloadEntity.path)
|
||||
}
|
||||
|
||||
DownloadManager.getInstance().cancel(mDownloadEntity.url, false, true, false)
|
||||
|
||||
if (SPUtils.getBoolean(Constants.SP_CONCERN_GAME, true)) { //设置页面控制是否安装后自动关注
|
||||
|
||||
@ -178,9 +178,18 @@ class DownloadDialog : BaseDraggableDialogFragment() {
|
||||
for (i in 0 until it.itemCount) {
|
||||
val apkEntity = itemList[i].normal ?: continue
|
||||
val apkCollection = apkEntity.apkCollection
|
||||
if (apkCollection != null && apkCollection.name == mPlatformName) {
|
||||
scrollAndDownload(recyclerView, false, i)
|
||||
break
|
||||
if (apkCollection != null) {
|
||||
if (apkCollection.name == mPlatformName) {
|
||||
scrollAndDownload(recyclerView, false, i)
|
||||
break
|
||||
} else {
|
||||
apkCollection.saveApkEntity?.forEach { entity ->
|
||||
if (entity.getPlatformName() == mPlatformName || entity.packageName == mPackageName) {
|
||||
scrollAndDownload(recyclerView, false, i)
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
if (apkEntity.getPlatformName() == mPlatformName || apkEntity.packageName == mPackageName) {
|
||||
scrollAndDownload(recyclerView, true, i)
|
||||
|
||||
@ -10,12 +10,9 @@ import com.gh.common.constant.Config
|
||||
import com.gh.common.dialog.CertificationDialog
|
||||
import com.gh.common.dialog.DeviceRemindDialog
|
||||
import com.gh.common.dialog.PackageCheckDialogFragment
|
||||
import com.gh.common.util.*
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.gh.common.util.DialogUtils
|
||||
import com.gh.common.util.DirectUtils.directToLinkPage
|
||||
import com.gh.common.util.DownloadDialogHelper
|
||||
import com.gh.common.util.PackageInstaller
|
||||
import com.gh.common.util.PackageUtils
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.download.server.BrowserInstallHelper
|
||||
import com.gh.gamecenter.DownloadManagerActivity
|
||||
@ -244,7 +241,7 @@ class DownloadDialogItemViewHolder(val binding: DownloadDialogItemBinding) : Bas
|
||||
mtaValue = gameEntity.name + "_" + apkEntity.getPlatformName() + "_下载"
|
||||
}
|
||||
DownloadDialogItemStatus.LAUNCH -> {
|
||||
PackageUtils.launchApplicationByPackageName(it.context, apkEntity.packageName)
|
||||
PackageLauncher.launchApp(it.context, gameEntity, apkEntity.packageName)
|
||||
|
||||
mtaValue = gameEntity.name + "_" + apkEntity.getPlatformName() + "_启动"
|
||||
}
|
||||
@ -282,7 +279,7 @@ class DownloadDialogItemViewHolder(val binding: DownloadDialogItemBinding) : Bas
|
||||
DownloadManager.getInstance().cancel(apkEntity.url)
|
||||
} else {
|
||||
if (PackageUtils.isCanPluggable(apkEntity)) {
|
||||
DialogHelper.showPluginDialog(it.context) {
|
||||
DialogHelper.showPluginDialog(it.context, gameEntity.pluginDesc) {
|
||||
PackageInstaller.uninstall(it.context, downloadEntity.path)
|
||||
}
|
||||
} else {
|
||||
@ -352,54 +349,46 @@ class DownloadDialogItemViewHolder(val binding: DownloadDialogItemBinding) : Bas
|
||||
if (msg.isNullOrEmpty()) {
|
||||
BrowserInstallHelper.showBrowserInstallHintDialog(
|
||||
context,
|
||||
gameEntity.isVGame(),
|
||||
object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
DownloadDialogHelper.findAvailableDialogAndShow(
|
||||
gameEntity.isVGame() || gameEntity.isSplitXApk()
|
||||
) {
|
||||
DownloadDialogHelper.findAvailableDialogAndShow(
|
||||
context,
|
||||
gameEntity,
|
||||
apkEntity
|
||||
) {
|
||||
PackageCheckDialogFragment.show(
|
||||
context as AppCompatActivity,
|
||||
gameEntity
|
||||
) {
|
||||
CertificationDialog.showCertificationDialog(
|
||||
context,
|
||||
gameEntity,
|
||||
apkEntity,
|
||||
object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
PackageCheckDialogFragment.show(
|
||||
context as AppCompatActivity,
|
||||
gameEntity,
|
||||
object : ConfirmListener {
|
||||
override fun onConfirm() {
|
||||
CertificationDialog.showCertificationDialog(
|
||||
context,
|
||||
gameEntity,
|
||||
object : ConfirmListener {
|
||||
override fun onConfirm() {
|
||||
DialogUtils.checkDownload(
|
||||
context,
|
||||
apkEntity.size,
|
||||
gameEntity.id,
|
||||
gameEntity.name
|
||||
) { isSubscribe ->
|
||||
DownloadManager.createDownload(
|
||||
context,
|
||||
apkEntity,
|
||||
gameEntity,
|
||||
downloadMethod,
|
||||
entrance,
|
||||
location,
|
||||
isSubscribe, traceEvent
|
||||
)
|
||||
gameEntity
|
||||
) {
|
||||
DialogUtils.checkDownload(
|
||||
context,
|
||||
apkEntity.size,
|
||||
gameEntity.id,
|
||||
gameEntity.name
|
||||
) { isSubscribe ->
|
||||
DownloadManager.createDownload(
|
||||
context,
|
||||
apkEntity,
|
||||
gameEntity,
|
||||
downloadMethod,
|
||||
entrance,
|
||||
location,
|
||||
isSubscribe, traceEvent
|
||||
)
|
||||
|
||||
DeviceRemindDialog.showDeviceRemindDialog(
|
||||
context,
|
||||
gameEntity
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
DeviceRemindDialog.showDeviceRemindDialog(
|
||||
context,
|
||||
gameEntity
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Utils.toast(context, msg)
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@ import com.gh.gamecenter.common.utils.tryCatchInRelease
|
||||
import com.gh.gamecenter.core.utils.EmptyCallback
|
||||
import com.gh.gamecenter.core.utils.GsonUtils
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.google.gson.JsonObject
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Utils
|
||||
@ -93,6 +94,10 @@ object BrowserInstallHelper {
|
||||
return false
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun shouldAutoSwitchAssistantInstall(gameEntity: GameEntity): Boolean =
|
||||
isUseBrowserToInstallEnabled() && shouldUseBrowserToInstall() && gameEntity.isSplitXApk()
|
||||
|
||||
/**
|
||||
* 是否显示使用浏览器来安装弹窗
|
||||
*/
|
||||
@ -144,7 +149,8 @@ object BrowserInstallHelper {
|
||||
val manufacturer = Build.MANUFACTURER.toUpperCase(Locale.CHINA)
|
||||
var contentText = "当前安装方式为助手安装,如果出现游戏无法安装的问题,可选择切换安装方式为“浏览器安装”"
|
||||
if (manufacturer == "OPPO" || manufacturer == "VIVO") {
|
||||
contentText = "当前安装方式为助手安装,下载安装游戏需要验证账户密码或指纹。如需免密码安装,可选择切换安装方式为“浏览器安装”"
|
||||
contentText =
|
||||
"当前安装方式为助手安装,下载安装游戏需要验证账户密码或指纹。如需免密码安装,可选择切换安装方式为“浏览器安装”"
|
||||
}
|
||||
|
||||
DialogHelper.showDialog(
|
||||
|
||||
@ -55,23 +55,21 @@ object DownloadMessageHandler : InnerDownloadListener {
|
||||
* @param status 下载状态
|
||||
*/
|
||||
override fun onStatusChanged(id: String, status: DownloadStatus) {
|
||||
val entity = findEntity(id)
|
||||
val entity = findEntity(id) ?: return
|
||||
|
||||
if (entity != null) {
|
||||
entity.status = status
|
||||
entity.status = status
|
||||
|
||||
if (status == DownloadStatus.COMPLETED) {
|
||||
SimpleDownloadManager.resumeQueuedTask()
|
||||
}
|
||||
if (status == DownloadStatus.COMPLETED) {
|
||||
SimpleDownloadManager.resumeQueuedTask()
|
||||
}
|
||||
|
||||
ExecutorProvider.getInstance().backgroundExecutor.execute {
|
||||
updateDownloadToDatabase(entity)
|
||||
updateDownloadList()
|
||||
}
|
||||
ExecutorProvider.getInstance().backgroundExecutor.execute {
|
||||
updateDownloadToDatabase(entity)
|
||||
updateDownloadList()
|
||||
}
|
||||
|
||||
for (listener in mGlobalStatusChangedListenerList) {
|
||||
listener.invoke(entity!!, status)
|
||||
listener.invoke(entity, status)
|
||||
}
|
||||
|
||||
val listenerList = mListenerMap[id] ?: return
|
||||
@ -165,7 +163,7 @@ object DownloadMessageHandler : InnerDownloadListener {
|
||||
* @param error 错误类型
|
||||
* @param exception 包裹错误的 Exception
|
||||
*/
|
||||
override fun onError(id: String, error: DownloadError?, exception: Exception) {
|
||||
override fun onError(id: String, error: DownloadError?, exception: Exception?) {
|
||||
error ?: return
|
||||
|
||||
when (error) {
|
||||
|
||||
@ -7,14 +7,21 @@ import com.gh.base.DownloadToolbarActivity
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.utils.updateStatusBarColor
|
||||
import com.gh.gamecenter.entity.SubjectRecommendEntity
|
||||
import com.gh.gamecenter.feature.exposure.ExposureSource
|
||||
import com.gh.gamecenter.game.GameFragment
|
||||
|
||||
class BlockActivity : DownloadToolbarActivity() {
|
||||
|
||||
companion object {
|
||||
fun getIntent(context: Context, blockData: SubjectRecommendEntity, entrance: String): Intent {
|
||||
fun getIntent(context: Context,
|
||||
blockData: SubjectRecommendEntity,
|
||||
exposureSourceList: ArrayList<ExposureSource>? = null,
|
||||
entrance: String): Intent {
|
||||
val args = Bundle()
|
||||
args.putParcelable(EntranceConsts.KEY_BLOCK_DATA, blockData)
|
||||
if (exposureSourceList != null) {
|
||||
args.putParcelableArrayList(EntranceConsts.KEY_EXPOSURE_SOURCE_LIST, exposureSourceList)
|
||||
}
|
||||
args.putString(EntranceConsts.KEY_ENTRANCE, entrance)
|
||||
return getTargetIntent(context, BlockActivity::class.java, GameFragment::class.java, args)
|
||||
}
|
||||
|
||||
@ -198,7 +198,6 @@ public class MainActivity extends BaseActivity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
showAd = getIntent().getBooleanExtra(SHOW_AD, false) && savedInstanceState == null;
|
||||
|
||||
HaloApp.getInstance().initFresco();
|
||||
HaloApp.getInstance().isAlreadyUpAndRunning = true;
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -319,6 +318,8 @@ public class MainActivity extends BaseActivity {
|
||||
// 默认配置为空时重试
|
||||
if (Config.getSettings() == null) {
|
||||
Config.getGhzsSettings();
|
||||
} else if (Config.getVSettingEntity() == null) {
|
||||
Config.refreshVSettingEntity();
|
||||
}
|
||||
|
||||
// 耗时操作
|
||||
@ -803,6 +804,15 @@ public class MainActivity extends BaseActivity {
|
||||
ToastUtils.showToast("游戏启动失败,请联系客服反馈相关信息");
|
||||
return;
|
||||
}
|
||||
|
||||
VHelper.INSTANCE.logLaunchButtonClicked(
|
||||
gamePackageName,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
"桌面快捷图标"
|
||||
);
|
||||
|
||||
ToastUtils.showToast("游戏启动中,请稍后~");
|
||||
handler.postDelayed(() -> {
|
||||
VHelper.postOnInitialized(() -> {
|
||||
@ -1064,6 +1074,8 @@ public class MainActivity extends BaseActivity {
|
||||
if (busNetworkState.isNetworkConnected()) {
|
||||
if (Config.getSettings() == null) {
|
||||
Config.getGhzsSettings();
|
||||
} else if (Config.getVSettingEntity() == null) {
|
||||
Config.refreshVSettingEntity();
|
||||
}
|
||||
|
||||
mPackageViewModel.checkData();
|
||||
|
||||
@ -320,7 +320,7 @@ public class SkipActivity extends BaseActivity {
|
||||
DirectUtils.directCategoryDirectory(this, path, title, ENTRANCE_BROWSER, "浏览器");
|
||||
break;
|
||||
case HOST_COLUMN_COLLECTION:
|
||||
DirectUtils.directToColumnCollection(this, path, -1, ENTRANCE_BROWSER, "浏览器");
|
||||
DirectUtils.directToColumnCollection(this, path, -1, ENTRANCE_BROWSER, "", null);
|
||||
break;
|
||||
case EntranceConsts.HOST_BLOCK:
|
||||
name = uri.getQueryParameter("name");
|
||||
@ -403,7 +403,7 @@ public class SkipActivity extends BaseActivity {
|
||||
DirectUtils.directToGameCollectionDetail(this, path, ENTRANCE_BROWSER, "", null);
|
||||
break;
|
||||
case HOST_GAME_COLLECTION_SQUARE:
|
||||
DirectUtils.directToGameCollectionSquare(this, ENTRANCE_BROWSER, "", "", "");
|
||||
DirectUtils.directToGameCollectionSquare(this, ENTRANCE_BROWSER, "", "", "", "", "");
|
||||
break;
|
||||
default:
|
||||
EntranceUtils.jumpActivity(this, new Bundle()); // 跳转至首页
|
||||
|
||||
@ -51,6 +51,7 @@ import java.io.IOException
|
||||
import java.io.InputStreamReader
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
/**
|
||||
* 引导页面
|
||||
@ -79,6 +80,7 @@ class SplashScreenActivity : BaseActivity() {
|
||||
mIsNewForThisVersion =
|
||||
mSharedPreferences!!.getBoolean("isNewFirstLaunchV" + PackageUtils.getGhVersionName(), true)
|
||||
HaloApp.getInstance().isNewForThisVersion = mIsNewForThisVersion
|
||||
HaloApp.getInstance().isBrandNewInstall = SPUtils.getBoolean(Constants.SP_BRAND_NEW_USER, true)
|
||||
|
||||
// 用户不是新版本,但应用最后更新时间不是上次的时间代表用户重新安装了当前版本
|
||||
if (!mIsNewForThisVersion) {
|
||||
@ -104,12 +106,11 @@ class SplashScreenActivity : BaseActivity() {
|
||||
guideLayout.adapter = GuidePagerAdapter()
|
||||
|
||||
// 判断是不是光环的新用户
|
||||
if (SPUtils.getBoolean(Constants.SP_BRAND_NEW_USER, true)) {
|
||||
if (HaloApp.getInstance().isBrandNewInstall) {
|
||||
// 引导页需用户点击 “立即体验” 按钮才进入首页,所以这里不能置为true
|
||||
// https://git.ghzs.com/pm/halo-app-issues/-/issues/1422(第3点)
|
||||
// mStartMainActivityDirectly = true;
|
||||
SPUtils.setLong(Constants.SP_INITIAL_USAGE_TIME, System.currentTimeMillis())
|
||||
HaloApp.getInstance().isBrandNewInstall = true
|
||||
if (!PackageFlavorHelper.IS_TEST_FLAVOR) {
|
||||
showPrivacyDialog(guideLayout)
|
||||
} else {
|
||||
@ -188,20 +189,6 @@ class SplashScreenActivity : BaseActivity() {
|
||||
private fun showPrivacyDialog(guideLayout: ViewPager) {
|
||||
NewPrivacyPolicyDialogFragment.show(this, null) { isSuccess: Boolean ->
|
||||
if (isSuccess) {
|
||||
// guideLayout.visibility = View.VISIBLE
|
||||
// SPUtils.setBoolean(Constants.SP_BRAND_NEW_USER, false)
|
||||
//
|
||||
// // 恢复畅玩数据
|
||||
// VHelper.recoverVDataIfPossible()
|
||||
//
|
||||
// requestPermission()
|
||||
//
|
||||
// // 检查是否有旧版本光环,有就删掉
|
||||
// AppExecutor.ioExecutor.execute { deleteOutdatedUpdatePackage() }
|
||||
// if (mStartMainActivityDirectly) {
|
||||
// launchMainActivity()
|
||||
// }
|
||||
|
||||
mShouldPrefetchData = false
|
||||
prefetchData()
|
||||
|
||||
@ -226,12 +213,10 @@ class SplashScreenActivity : BaseActivity() {
|
||||
} else {
|
||||
DialogUtils.showPrivacyPolicyDisallowDialog(
|
||||
this,
|
||||
PrivacyPolicyEntity.createDefaultData(),
|
||||
object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
showPrivacyDialog(guideLayout)
|
||||
}
|
||||
})
|
||||
PrivacyPolicyEntity.createDefaultData()
|
||||
) {
|
||||
showPrivacyDialog(guideLayout)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -312,19 +297,7 @@ class SplashScreenActivity : BaseActivity() {
|
||||
private fun doFlavorInit() {
|
||||
HaloApp.getInstance().flavorProvider.init(HaloApp.getInstance(), this, PkgHelper.getActivateRatio())
|
||||
|
||||
val whiteListChannel = arrayListOf(
|
||||
"GH_206",
|
||||
"KS-GHZS-KY1",
|
||||
"KS-GHZS-MC1",
|
||||
"GDT_GHZS_MC1",
|
||||
"T11-GH-APPDY-ZC01",
|
||||
"T7-GH-APPDY-KY03",
|
||||
"T8-GH-APPUX-KY04",
|
||||
"T1-GHZS-MC01",
|
||||
"T4-GHZS-MC03"
|
||||
)
|
||||
|
||||
if (whiteListChannel.contains(HaloApp.getInstance().channel) || PackageFlavorHelper.IS_TEST_FLAVOR) {
|
||||
if (HaloApp.getInstance().channel == "GH_206" || PackageFlavorHelper.IS_TEST_FLAVOR) {
|
||||
SensorsBridge.init(HaloApp.getInstance(), HaloApp.getInstance().channel)
|
||||
}
|
||||
}
|
||||
@ -440,11 +413,8 @@ class SplashScreenActivity : BaseActivity() {
|
||||
@AfterPermissionGranted(REQUEST_PERMISSION_TAG)
|
||||
private fun checkAndRequestPermission() {
|
||||
if (EasyPermissions.hasPermissions(this, *mPermissions)) {
|
||||
// 恢复畅玩数据
|
||||
VHelper.recoverVDataIfPossible()
|
||||
onPermissionsGranted(REQUEST_PERMISSION_TAG, ArrayList(mPermissions.toList()))
|
||||
|
||||
// 检查是否有旧版本光环,有就删掉
|
||||
runOnIoThread { deleteOutdatedUpdatePackage() }
|
||||
if (mStartMainActivityDirectly) {
|
||||
if (com.gh.gamecenter.common.BuildConfig.BUILD_TIME != 0L) {
|
||||
showGitLogDialogIfNeeded()
|
||||
@ -467,6 +437,17 @@ class SplashScreenActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPermissionsGranted(requestCode: Int, perms: MutableList<String>?) {
|
||||
super.onPermissionsGranted(requestCode, perms)
|
||||
|
||||
if (perms?.contains(Manifest.permission.READ_EXTERNAL_STORAGE) == true) {
|
||||
// 恢复畅玩数据
|
||||
VHelper.recoverVDataIfPossible()
|
||||
// 检查是否有旧版本光环,有就删掉
|
||||
runOnIoThread { deleteOutdatedUpdatePackage() }
|
||||
}
|
||||
}
|
||||
|
||||
// 检查下载文件夹下是否有旧版本的光环助手的包,有则删除
|
||||
private fun deleteOutdatedUpdatePackage() {
|
||||
try {
|
||||
|
||||
@ -259,7 +259,7 @@ public class WeiBoShareActivity extends Activity implements WbShareCallback {
|
||||
if ("NORMAL".equals(mShareStyle)) {
|
||||
com.gh.gamecenter.common.utils.LogUtils.uploadShareResult(ShareUtils.shareType, ShareUtils.shareEntrance.getName(), "success",
|
||||
ShareUtils.shareEntity.getShareUrl(), ShareUtils.shareEntity.getShareTitle(), ShareUtils.shareEntity.getSummary(), ShareUtils.resourceId);
|
||||
EventBus.getDefault().post(new EBShare(ShareUtils.shareEntrance));
|
||||
EventBus.getDefault().post(new EBShare(ShareUtils.shareEntrance, "新浪微博"));
|
||||
if (ShareUtils.shareEntrance == ShareUtils.ShareEntrance.inviteFriends) {
|
||||
IntegralLogHelper.INSTANCE.logInviteResult("成功", "微博");
|
||||
}
|
||||
|
||||
@ -208,9 +208,9 @@ public class LibaoDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
}
|
||||
holder.binding.libaodetailName.setText(mLibaoEntity.getName());
|
||||
if (TextUtils.isEmpty(mLibaoEntity.getPlatform())) {
|
||||
holder.binding.libaodetailName.setText(mLibaoEntity.getGame().getName());
|
||||
holder.binding.libaodetailGameName.setText(mLibaoEntity.getGame().getName());
|
||||
} else {
|
||||
holder.binding.libaodetailName.setText((mLibaoEntity.getGame().getName() + " - " +
|
||||
holder.binding.libaodetailGameName.setText((mLibaoEntity.getGame().getName() + " - " +
|
||||
PlatformUtils.getInstance(mContext).getPlatformName(mLibaoEntity.getPlatform())));
|
||||
}
|
||||
|
||||
|
||||
@ -12,7 +12,6 @@ import androidx.fragment.app.DialogFragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.airbnb.lottie.LottieAnimationView;
|
||||
import com.gh.gamecenter.common.base.GlobalActivityManager;
|
||||
import com.gh.common.chain.BrowserInstallHandler;
|
||||
import com.gh.common.chain.CertificationHandler;
|
||||
import com.gh.common.chain.ChainBuilder;
|
||||
@ -23,14 +22,13 @@ import com.gh.common.chain.DownloadDialogHelperHandler;
|
||||
import com.gh.common.chain.GamePermissionHandler;
|
||||
import com.gh.common.chain.OverseaDownloadHandler;
|
||||
import com.gh.common.chain.PackageCheckHandler;
|
||||
import com.gh.common.chain.UnsupportedFeatureHandler;
|
||||
import com.gh.common.chain.UpdateNewSimulatorHandler;
|
||||
import com.gh.common.chain.ValidateVSpaceHandler;
|
||||
import com.gh.common.chain.VersionNumberHandler;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.dialog.DeviceRemindDialog;
|
||||
import com.gh.common.dialog.GameOffServiceDialogFragment;
|
||||
import com.gh.gamecenter.common.utils.SensorsBridge;
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent;
|
||||
import com.gh.common.filter.RegionSetting;
|
||||
import com.gh.common.filter.RegionSettingHelper;
|
||||
import com.gh.common.history.HistoryHelper;
|
||||
@ -38,41 +36,43 @@ import com.gh.common.simulator.NewSimulatorGameManager;
|
||||
import com.gh.common.simulator.SimulatorDownloadManager;
|
||||
import com.gh.common.simulator.SimulatorGameManager;
|
||||
import com.gh.common.util.CheckLoginUtils;
|
||||
import com.gh.common.util.DetailDownloadUtils;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.DirectUtils;
|
||||
import com.gh.common.util.LogUtils;
|
||||
import com.gh.common.util.PackageInstaller;
|
||||
import com.gh.common.util.PackageLauncher;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.ReservationHelper;
|
||||
import com.gh.common.xapk.XapkInstaller;
|
||||
import com.gh.common.xapk.XapkUnzipStatus;
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts;
|
||||
import com.gh.gamecenter.common.utils.DataLogUtils;
|
||||
import com.gh.common.util.DetailDownloadUtils;
|
||||
import com.gh.gamecenter.common.utils.DialogHelper;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.gamecenter.core.utils.PageSwitchDataHelper;
|
||||
import com.gh.common.util.LogUtils;
|
||||
import com.gh.gamecenter.core.utils.MtaHelper;
|
||||
import com.gh.common.util.PackageInstaller;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.gamecenter.common.utils.PermissionHelper;
|
||||
import com.gh.common.util.ReservationHelper;
|
||||
import com.gh.gamecenter.feature.view.DownloadButton;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.download.dialog.DownloadDialog;
|
||||
import com.gh.gamecenter.DownloadManagerActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.WebActivity;
|
||||
import com.gh.gamecenter.common.constant.Constants;
|
||||
import com.gh.gamecenter.core.utils.StringUtils;
|
||||
import com.gh.gamecenter.feature.entity.ApkEntity;
|
||||
import com.gh.gamecenter.feature.entity.GameEntity;
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts;
|
||||
import com.gh.gamecenter.common.entity.LinkEntity;
|
||||
import com.gh.gamecenter.common.eventbus.EBReuse;
|
||||
import com.gh.gamecenter.feature.entity.SimulatorEntity;
|
||||
import com.gh.gamecenter.common.utils.DataLogUtils;
|
||||
import com.gh.gamecenter.common.utils.DialogHelper;
|
||||
import com.gh.gamecenter.common.utils.ExtensionsKt;
|
||||
import com.gh.gamecenter.common.utils.PermissionHelper;
|
||||
import com.gh.gamecenter.common.utils.SensorsBridge;
|
||||
import com.gh.gamecenter.core.utils.PageSwitchDataHelper;
|
||||
import com.gh.gamecenter.core.utils.StringUtils;
|
||||
import com.gh.gamecenter.eventbus.EBScroll;
|
||||
import com.gh.gamecenter.feature.entity.ApkEntity;
|
||||
import com.gh.gamecenter.feature.entity.GameEntity;
|
||||
import com.gh.gamecenter.feature.entity.SimulatorEntity;
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent;
|
||||
import com.gh.gamecenter.feature.view.DownloadButton;
|
||||
import com.gh.gamecenter.gamedetail.GameDetailFragment;
|
||||
import com.gh.gamecenter.gamedetail.dialog.GamePermissionDialogFragment;
|
||||
import com.gh.gamecenter.teenagermode.TeenagerModeActivity;
|
||||
import com.gh.vspace.VDownloadManagerActivity;
|
||||
import com.gh.vspace.VHelper;
|
||||
import com.gh.vspace.VSpaceLoadingActivity;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
import com.lightgame.download.FileUtils;
|
||||
import com.lightgame.utils.Utils;
|
||||
@ -121,6 +121,8 @@ public class DetailViewHolder {
|
||||
|
||||
final OnDetailDownloadClickListener listener = new OnDetailDownloadClickListener(this, entrance, name, title, traceEvent);
|
||||
mDownloadPb.setOnClickListener(listener);
|
||||
ExtensionsKt.putWidgetBusinessName(mDownloadPb, "游戏详情页");
|
||||
ExtensionsKt.putObject(mDownloadPb, gameEntity);
|
||||
|
||||
restoreDialogFragment();
|
||||
}
|
||||
@ -138,13 +140,13 @@ public class DetailViewHolder {
|
||||
}
|
||||
|
||||
static class OnDetailDownloadClickListener implements View.OnClickListener {
|
||||
private DetailViewHolder mViewHolder;
|
||||
private GameEntity mGameEntity;
|
||||
private final DetailViewHolder mViewHolder;
|
||||
private final GameEntity mGameEntity;
|
||||
private DownloadEntity mDownloadEntity;
|
||||
private String mEntrance;
|
||||
private String mName;
|
||||
private String mTitle;
|
||||
private ExposureEvent mTraceEvent;
|
||||
private final String mEntrance;
|
||||
private final String mName;
|
||||
private final String mTitle;
|
||||
private final ExposureEvent mTraceEvent;
|
||||
|
||||
public OnDetailDownloadClickListener(DetailViewHolder viewHolder, String entrance, String name, String title, ExposureEvent traceEvent) {
|
||||
mViewHolder = viewHolder;
|
||||
@ -158,67 +160,7 @@ public class DetailViewHolder {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mViewHolder.mDownloadPb.getButtonStyle() != DownloadButton.ButtonStyle.RESERVABLE && mViewHolder.mDownloadPb.getButtonStyle() != DownloadButton.ButtonStyle.RESERVED) {
|
||||
SensorsBridge.trackEvent(
|
||||
"DownLoadbuttonClick",
|
||||
"game_id", mGameEntity.getId(),
|
||||
"game_name", mGameEntity.getName(),
|
||||
"game_type", mGameEntity.getCategoryChinese(),
|
||||
"download_status", mGameEntity.getDownloadStatusChinese(),
|
||||
"button_name", mViewHolder.mDownloadPb.getText(),
|
||||
"game_schema_type", mGameEntity.getGameBitChinese(),
|
||||
"page_name", GlobalActivityManager.getCurrentPageEntity().getPageName(),
|
||||
"page_id", GlobalActivityManager.getCurrentPageEntity().getPageId(),
|
||||
"page_business_id", GlobalActivityManager.getCurrentPageEntity().getPageBusinessId(),
|
||||
"last_page_name", GlobalActivityManager.getLastPageEntity().getPageName(),
|
||||
"last_page_id", GlobalActivityManager.getLastPageEntity().getPageId(),
|
||||
"last_page_business_id", GlobalActivityManager.getLastPageEntity().getPageBusinessId()
|
||||
);
|
||||
}
|
||||
|
||||
// 这个 switch 纯粹是为了 MTA和上报光能任务 统计用的
|
||||
switch (mViewHolder.mDownloadPb.getButtonStyle()) {
|
||||
case DOWNLOADING_PLUGIN:
|
||||
MtaHelper.onEvent("游戏详情_新", "插件化中", mGameEntity.getName());
|
||||
break;
|
||||
case DOWNLOADING_NORMAL:
|
||||
MtaHelper.onEvent("游戏详情_新", "下载中", mGameEntity.getName());
|
||||
break;
|
||||
case NONE:
|
||||
MtaHelper.onEvent("游戏详情_新", "关闭下载", mGameEntity.getName());
|
||||
break;
|
||||
case NORMAL:
|
||||
MtaHelper.onEvent("游戏详情_新", "下载", mGameEntity.getName());
|
||||
break;
|
||||
case PLUGIN:
|
||||
MtaHelper.onEvent("游戏详情_新", "插件化", mGameEntity.getName());
|
||||
break;
|
||||
case INSTALL_PLUGIN:
|
||||
MtaHelper.onEvent("游戏详情_新", "安装插件化", mGameEntity.getName());
|
||||
break;
|
||||
case INSTALL_NORMAL:
|
||||
MtaHelper.onEvent("游戏详情_新", "安装", mGameEntity.getName());
|
||||
break;
|
||||
case RESERVABLE:
|
||||
MtaHelper.onEvent("游戏详情_新", "预约", mGameEntity.getName());
|
||||
break;
|
||||
case LAUNCH_OR_OPEN:
|
||||
if (!mGameEntity.getApk().isEmpty()) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
// 由于部分状态不包含在 downloadType 里,所以还是需要手动获取下载按钮文字判断点击时的状态
|
||||
String downloadText = mViewHolder.mDownloadPb.getText().toString();
|
||||
if (downloadText.contains("打开")) {
|
||||
MtaHelper.onEvent("游戏详情_新", "打开", mGameEntity.getName());
|
||||
} else if (downloadText.contains("启动")) {
|
||||
MtaHelper.onEvent("游戏详情_新", "启动", mGameEntity.getName());
|
||||
} else if (downloadText.contains("更新")) {
|
||||
MtaHelper.onEvent("游戏详情_新", "更新", mGameEntity.getName());
|
||||
}
|
||||
|
||||
v.setTag(null);
|
||||
|
||||
if (mViewHolder.mDownloadPb.getButtonStyle() != DownloadButton.ButtonStyle.INSTALL_NORMAL
|
||||
&& mViewHolder.mDownloadPb.getButtonStyle() != DownloadButton.ButtonStyle.INSTALL_PLUGIN
|
||||
&& mViewHolder.mDownloadPb.getButtonStyle() != DownloadButton.ButtonStyle.LAUNCH_OR_OPEN) {
|
||||
@ -236,6 +178,9 @@ public class DetailViewHolder {
|
||||
|
||||
if (mDownloadEntity != null) {
|
||||
String xapkStatus = mDownloadEntity.getMeta().get(XapkInstaller.XAPK_UNZIP_STATUS);
|
||||
if (XapkUnzipStatus.SUCCESS.name().equals(xapkStatus) && XapkInstaller.INSTANCE.isInstalling(mDownloadEntity.getPath())) {// 安装过程中避免重复点击
|
||||
return;
|
||||
}
|
||||
if (XapkUnzipStatus.UNZIPPING.name().equals(xapkStatus)) {
|
||||
XapkInstaller.cancelUnzipTask(mDownloadEntity);
|
||||
return;
|
||||
@ -261,15 +206,12 @@ public class DetailViewHolder {
|
||||
String offStatus = mGameEntity.getDownloadOffStatus();
|
||||
if (offStatus != null && !"off".equals(offStatus)) {
|
||||
if ("dialog".equals(offStatus)) {
|
||||
// MtaHelper.onEvent("游戏下载状态按钮", "查看详情", mGameEntity.getName());
|
||||
showOffServiceDialog(mGameEntity.getDownloadOffDialog());
|
||||
} else if ("toast".equals(offStatus)) {
|
||||
// MtaHelper.onEvent("游戏下载状态按钮", "关闭且toast", mGameEntity.getName());
|
||||
EventBus.getDefault().post(new EBReuse(GameDetailFragment.SKIP_RATING));
|
||||
Utils.toast(mViewHolder.context, "该游戏因故暂不提供下载,具体详情可在相关评论中查看,敬请谅解~");
|
||||
}
|
||||
} else {
|
||||
// MtaHelper.onEvent("游戏下载状态按钮", "暂无下载", mGameEntity.getName());
|
||||
Utils.toast(mViewHolder.context, "该游戏已关闭下载");
|
||||
}
|
||||
break;
|
||||
@ -282,9 +224,8 @@ public class DetailViewHolder {
|
||||
DataLogUtils.uploadGameLog(mViewHolder.context, mGameEntity.getId(), mGameEntity.getName(), mEntrance);
|
||||
}
|
||||
case PLUGIN:
|
||||
|
||||
|
||||
ChainBuilder builder = new ChainBuilder();
|
||||
builder.addHandler(new UnsupportedFeatureHandler());
|
||||
builder.addHandler(new UpdateNewSimulatorHandler());
|
||||
builder.addHandler(new GamePermissionHandler());
|
||||
builder.addHandler(new CheckStoragePermissionHandler());
|
||||
@ -347,11 +288,11 @@ public class DetailViewHolder {
|
||||
}
|
||||
|
||||
if (mGameEntity.isVGame()) {
|
||||
VHelper.installOrLaunch(mViewHolder.context, mGameEntity);
|
||||
VHelper.installOrLaunch(mViewHolder.context, mGameEntity, null);
|
||||
return;
|
||||
}
|
||||
|
||||
PackageUtils.launchApplicationByPackageName(mViewHolder.context, mGameEntity.getApk().get(0).getPackageName());
|
||||
PackageLauncher.launchApp(mViewHolder.context, mGameEntity, mGameEntity.getApk().get(0).getPackageName());
|
||||
} else {
|
||||
GamePermissionDialogFragment.show((AppCompatActivity) mViewHolder.context, mGameEntity, mGameEntity.getInfo(), () -> {
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(mViewHolder.context, () -> {
|
||||
@ -389,7 +330,7 @@ public class DetailViewHolder {
|
||||
}
|
||||
|
||||
if (mGameEntity.isVGame()) {
|
||||
VHelper.installOrLaunch(v.getContext(), mGameEntity);
|
||||
VHelper.installOrLaunch(v.getContext(), mGameEntity, null);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -436,7 +377,6 @@ public class DetailViewHolder {
|
||||
}
|
||||
break;
|
||||
case H5_GAME:
|
||||
MtaHelper.onEvent("H5页面", "入口", "详情页_" + mGameEntity.getName());
|
||||
LinkEntity linkEntity = mGameEntity.getH5Link();
|
||||
|
||||
boolean isPlay = "play".equals(linkEntity.getType()); // 是否为开始玩
|
||||
@ -482,7 +422,7 @@ public class DetailViewHolder {
|
||||
}
|
||||
|
||||
if (mDownloadEntity != null) {
|
||||
if (downloadText.contains("继续加载")) {
|
||||
if (mViewHolder.mDownloadPb.getText().contains("继续加载")) {
|
||||
DownloadManager.getInstance().resume(mDownloadEntity, true);
|
||||
} else {
|
||||
DownloadManager.getInstance().pause(mDownloadEntity.getUrl());
|
||||
|
||||
@ -31,6 +31,8 @@ class GameHeadViewHolder(var binding: GameHeadItemBinding) :
|
||||
binding.arrowIv.visibility = View.GONE
|
||||
val text = if ("change" == subject.home) {
|
||||
"换一批"
|
||||
} else if (subject.type == "game_list_collection" && subject.style?.contains("slide") == true) {
|
||||
"游戏单广场"
|
||||
} else {
|
||||
when (subject.home) {
|
||||
"more" -> "更多"
|
||||
@ -62,7 +64,7 @@ class GameHeadViewHolder(var binding: GameHeadItemBinding) :
|
||||
} else {
|
||||
binding.headMore.visibility = View.VISIBLE
|
||||
}
|
||||
if (binding.headMore.visibility == View.VISIBLE && (binding.headMore.text == "更多" || binding.headMore.text == "全部")) {
|
||||
if (binding.headMore.visibility == View.VISIBLE && (binding.headMore.text == "更多" || binding.headMore.text == "全部" || binding.headMore.text == "游戏单广场")) {
|
||||
binding.arrowIv.visibility = View.VISIBLE
|
||||
}
|
||||
binding.headTitle.setTextColor(R.color.text_title.toColor(binding.root.context))
|
||||
|
||||
@ -42,7 +42,8 @@ import java.util.regex.Pattern
|
||||
class AmwayAdapter(
|
||||
context: Context,
|
||||
private var mViewModel: AmwayViewModel,
|
||||
private var mBasicExposureSource: List<ExposureSource>,
|
||||
private var mBasicExposureSource: ArrayList<ExposureSource>,
|
||||
private var mUseAlternativeLayout: Boolean,
|
||||
private var mLayoutManager: RecyclerView.LayoutManager
|
||||
) : ListAdapter<AmwayListItemData>(context), IExposable {
|
||||
|
||||
@ -102,6 +103,7 @@ class AmwayAdapter(
|
||||
mViewModel,
|
||||
mEntityList[position],
|
||||
mEntityList[position].blockPosition,
|
||||
mUseAlternativeLayout,
|
||||
mBasicExposureSource
|
||||
)
|
||||
}
|
||||
@ -203,6 +205,7 @@ class AmwayAdapter(
|
||||
viewModel: AmwayViewModel,
|
||||
itemData: AmwayListItemData,
|
||||
blockPosition: Int,
|
||||
useAlternativeLayout: Boolean,
|
||||
basicExposureSource: List<ExposureSource>
|
||||
) {
|
||||
val context = binding.root.context
|
||||
@ -269,9 +272,22 @@ class AmwayAdapter(
|
||||
}
|
||||
|
||||
binding.commentContainer.setOnClickListener {
|
||||
val exposureSource = if (useAlternativeLayout) {
|
||||
arrayListOf(ExposureSource("新首页"), ExposureSource("安利墙"))
|
||||
} else {
|
||||
arrayListOf(ExposureSource("安利墙"))
|
||||
}.toJson()
|
||||
|
||||
val intent = RatingReplyActivity.getIntent(
|
||||
context, amway.game.id, amway.comment, false, viewModel.entrance
|
||||
?: "", EntranceConsts.ENTRANCE_AMWAY
|
||||
context = context,
|
||||
gameId = amway.game.id,
|
||||
gameEntity = null,
|
||||
comment = amway.comment,
|
||||
commentId = amway.comment.id,
|
||||
showKeyboardIfReplyListIsEmpty = false,
|
||||
exposureSource = exposureSource,
|
||||
entrance = viewModel.entrance ?: "",
|
||||
path = EntranceConsts.ENTRANCE_AMWAY
|
||||
)
|
||||
SyncDataBetweenPageHelper.startActivityForResult(
|
||||
binding.root.context,
|
||||
|
||||
@ -145,7 +145,8 @@ class AmwayFragment : LazyListFragment<AmwayListItemData, AmwayViewModel>() {
|
||||
}
|
||||
add(ExposureSource("安利墙", ""))
|
||||
}
|
||||
mAdapter = AmwayAdapter(requireContext(), mViewModel, basicExposureSource, mLayoutManager)
|
||||
mAdapter =
|
||||
AmwayAdapter(requireContext(), mViewModel, basicExposureSource, mUseAlternativeLayout, mLayoutManager)
|
||||
}
|
||||
return mAdapter!!
|
||||
}
|
||||
|
||||
@ -184,6 +184,7 @@ class SpecialCatalogAdapter(
|
||||
specialLink.link,
|
||||
specialLink.text,
|
||||
false,
|
||||
null,
|
||||
"(游戏-专题:" + specialLink.text + "-全部)"
|
||||
)
|
||||
}
|
||||
|
||||
@ -193,6 +193,8 @@ class CategoryV2ListAdapter(
|
||||
true,
|
||||
"star&brief"
|
||||
)
|
||||
|
||||
holder.binding.downloadBtn.putWidgetBusinessName("分类列表")
|
||||
} else if (holder is FooterViewHolder) {
|
||||
holder.run {
|
||||
initItemPadding()
|
||||
|
||||
@ -4,6 +4,7 @@ import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.util.SparseArray
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
@ -13,6 +14,7 @@ import android.widget.PopupWindow
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.common.exposure.IExposable
|
||||
import com.gh.gamecenter.common.constant.ItemViewType
|
||||
import com.gh.gamecenter.common.syncpage.ISyncAdapterHandler
|
||||
import com.gh.common.util.*
|
||||
@ -30,6 +32,10 @@ import com.gh.gamecenter.databinding.ItemGameCollectionFlexTagBinding
|
||||
import com.gh.gamecenter.databinding.PopupHistoryOptionBinding
|
||||
import com.gh.gamecenter.entity.GamesCollectionEntity
|
||||
import com.gh.gamecenter.entity.TagInfoEntity
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.gh.gamecenter.feature.exposure.ExposureSource
|
||||
import com.gh.gamecenter.feature.exposure.ExposureType
|
||||
import com.gh.gamecenter.gamecollection.detail.GameCollectionDetailActivity
|
||||
import com.gh.gamecenter.gamecollection.publish.GameCollectionEditActivity
|
||||
import com.gh.gamecenter.history.ManageOption
|
||||
@ -39,12 +45,19 @@ import com.google.android.flexbox.FlexboxLayout
|
||||
class GamesCollectionAdapter(
|
||||
context: Context,
|
||||
private val mViewModel: GamesCollectionViewModel,
|
||||
) : ListAdapter<GamesCollectionEntity>(context), ISyncAdapterHandler {
|
||||
) : ListAdapter<GamesCollectionEntity>(context), ISyncAdapterHandler, IExposable {
|
||||
|
||||
private var mCurrentOption = ManageOption.OPTION_MANAGER
|
||||
private var mPopWindow: PopupWindow? = null
|
||||
private var mPopupBinding: PopupHistoryOptionBinding? = null
|
||||
var selectItems = arrayListOf<String>()
|
||||
private var mExposureEventArray: SparseArray<ExposureEvent>? = null
|
||||
|
||||
|
||||
override fun setListData(updateData: MutableList<GamesCollectionEntity>?) {
|
||||
mExposureEventArray = SparseArray(updateData?.size ?: 0)
|
||||
super.setListData(updateData)
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return if (mEntityList == null || mEntityList.isEmpty()) return 0 else mEntityList.size + 1
|
||||
@ -102,6 +115,19 @@ class GamesCollectionAdapter(
|
||||
when (holder) {
|
||||
is GameCollectionItemViewHolder -> {
|
||||
val itemEntity = mEntityList[position]
|
||||
val exposureEvent = ExposureEvent.createEvent(
|
||||
GameEntity().apply {
|
||||
sequence = position
|
||||
},
|
||||
listOf(
|
||||
ExposureSource("个人主页", ""),
|
||||
ExposureSource("游戏单", "${itemEntity.title}+${itemEntity.id}")
|
||||
),
|
||||
null,
|
||||
ExposureType.EXPOSURE
|
||||
)
|
||||
mExposureEventArray?.put(position, exposureEvent)
|
||||
|
||||
holder.binding.run {
|
||||
ImageUtils.display(poster, itemEntity.cover)
|
||||
nameTv.text = itemEntity.title
|
||||
@ -117,7 +143,7 @@ class GamesCollectionAdapter(
|
||||
gameThree.goneIf(it < 3)
|
||||
}
|
||||
|
||||
moreNumTv.goneIf((itemEntity.count?.game ?: 0) < 4)
|
||||
moreNumTv.goneIf((itemEntity.count?.game ?: 0) < 4 || itemEntity.games?.size == 0)
|
||||
moreNumTv.text = "+ " + ((itemEntity.count?.game ?: 0) - 3)
|
||||
tagContainer.goneIf(itemEntity.count?.game != 0)
|
||||
timeTv.text = TimeUtils.getFormatTime(itemEntity.time?.update ?: 0, "MM - dd")
|
||||
@ -235,7 +261,8 @@ class GamesCollectionAdapter(
|
||||
GameCollectionDetailActivity.getIntent(
|
||||
mContext,
|
||||
itemEntity.id,
|
||||
isScrollToCommentArea = true
|
||||
isScrollToCommentArea = true,
|
||||
exposureSourceList = ArrayList(exposureEvent.source)
|
||||
)
|
||||
)
|
||||
}
|
||||
@ -294,7 +321,13 @@ class GamesCollectionAdapter(
|
||||
} else {
|
||||
if (mCurrentOption == ManageOption.OPTION_MANAGER) {
|
||||
NewLogUtils.logEnterGameCollectionDetail(itemEntity.title, itemEntity.id)
|
||||
mContext.startActivity(GameCollectionDetailActivity.getIntent(mContext, itemEntity.id))
|
||||
mContext.startActivity(
|
||||
GameCollectionDetailActivity.getIntent(
|
||||
mContext,
|
||||
itemEntity.id,
|
||||
exposureSourceList = ArrayList(exposureEvent.source)
|
||||
)
|
||||
)
|
||||
} else {
|
||||
if (selectItems.contains(itemEntity.id)) {
|
||||
selectItems.remove(itemEntity.id)
|
||||
@ -459,4 +492,8 @@ class GamesCollectionAdapter(
|
||||
checkAllCb.isChecked = selectItems.size == mEntityList.size
|
||||
}
|
||||
}
|
||||
|
||||
override fun getEventByPosition(pos: Int): ExposureEvent? = mExposureEventArray!!.get(pos)
|
||||
|
||||
override fun getEventListByPosition(pos: Int): List<ExposureEvent>? = null
|
||||
}
|
||||
@ -3,6 +3,7 @@ package com.gh.gamecenter.collection
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.gh.common.exposure.ExposureListener
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts.*
|
||||
import com.gh.gamecenter.common.view.SpacingItemDecoration
|
||||
import com.gh.gamecenter.R
|
||||
@ -76,6 +77,8 @@ class GamesCollectionFragment : ListFragment<GamesCollectionEntity, GamesCollect
|
||||
mListViewModel.publishLiveData.observe(viewLifecycleOwner) {
|
||||
mListViewModel.load(LoadType.REFRESH)
|
||||
}
|
||||
|
||||
mListRv.addOnScrollListener(ExposureListener(this, provideListAdapter()))
|
||||
}
|
||||
|
||||
override fun onLoadEmpty() {
|
||||
|
||||
@ -223,7 +223,7 @@ class DiscoveryAdapter(
|
||||
val navBar = MainWrapperRepository.getInstance().getNavBarLiveData().value
|
||||
if (navBar == null || mContext is DiscoveryActivity) {
|
||||
val blockData = HomeBottomBarHelper.getDefaultGameBarData()
|
||||
mContext.startActivity(BlockActivity.getIntent(mContext, blockData, mEntrance))
|
||||
mContext.startActivity(BlockActivity.getIntent(mContext, blockData, mBaseExposureSource, mEntrance))
|
||||
} else {
|
||||
EventBus.getDefault()
|
||||
.post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_GAME))
|
||||
|
||||
@ -38,6 +38,7 @@ import com.gh.gamecenter.fragment.MainWrapperFragment;
|
||||
import com.halo.assistant.HaloApp;
|
||||
import com.lightgame.download.DataWatcher;
|
||||
import com.lightgame.download.DownloadConfig;
|
||||
import com.lightgame.download.DownloadDao;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
import com.lightgame.download.DownloadStatus;
|
||||
|
||||
@ -137,8 +138,7 @@ public class GameDownloadFragment extends BaseFragment implements View.OnClickLi
|
||||
}
|
||||
}
|
||||
|
||||
adapter.getUrlMap().put(PackageUtils.getPackageNameByPath(HaloApp.getInstance().getApplication(),
|
||||
downloadEntity.getPath()), downloadEntity.getUrl());
|
||||
adapter.getUrlMap().put(downloadEntity.getPackageName(), downloadEntity.getUrl());
|
||||
|
||||
// 用户焦点在下载管理页面时有任务完成,直接把所有下载完成的任务标记为已读
|
||||
DownloadManager.getInstance().markDownloadedTaskAsRead();
|
||||
@ -222,6 +222,7 @@ public class GameDownloadFragment extends BaseFragment implements View.OnClickLi
|
||||
protected void initView(View view) {
|
||||
super.initView(view);
|
||||
String path = getActivity().getIntent().getStringExtra(EntranceConsts.KEY_PATH);
|
||||
String pluginDesc = getActivity().getIntent().getStringExtra(EntranceConsts.KEY_PLUGIN_DESC);
|
||||
url = getActivity().getIntent().getStringExtra(EntranceConsts.KEY_URL);
|
||||
|
||||
isScroll = false;
|
||||
@ -297,7 +298,7 @@ public class GameDownloadFragment extends BaseFragment implements View.OnClickLi
|
||||
});
|
||||
|
||||
if (path != null) {
|
||||
adapter.showPluginDialog(path);
|
||||
adapter.showPluginDialog(path, pluginDesc);
|
||||
}
|
||||
mBinding.downloadmanagerTvAllstart.setOnClickListener(this);
|
||||
}
|
||||
@ -342,8 +343,8 @@ public class GameDownloadFragment extends BaseFragment implements View.OnClickLi
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEventMainThread(EBMiPush mipush) {
|
||||
if ("plugin_install".equals(mipush.getFrom())) {
|
||||
String path = (String) mipush.getObj();
|
||||
adapter.showPluginDialog(path);
|
||||
DownloadEntity downloadEntity = (DownloadEntity) mipush.getObj();
|
||||
adapter.showPluginDialog(downloadEntity.getPath(), downloadEntity.getPluginDesc());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -16,6 +16,7 @@ import androidx.recyclerview.widget.RecyclerView.ViewHolder;
|
||||
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.PackageInstaller;
|
||||
import com.gh.common.util.PackageLauncher;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.xapk.XapkDialogHelper;
|
||||
import com.gh.gamecenter.common.entity.IconFloat;
|
||||
@ -210,7 +211,11 @@ class GameDownloadFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
} else if (XapkUnzipStatus.SUCCESS.name().equals(xapkStatus)) {
|
||||
viewHolder.binding.dmItemTvStartorpause.setButtonStyle(DownloadButton.ButtonStyle.XAPK_SUCCESS);
|
||||
viewHolder.binding.dmItemTvStartorpause.setProgress(1000);
|
||||
viewHolder.binding.dmItemTvStartorpause.setText(R.string.hundred_percent);
|
||||
if (XapkInstaller.INSTANCE.isInstalling(downloadEntity.getPath())) {
|
||||
viewHolder.binding.dmItemTvStartorpause.setText(R.string.installing);
|
||||
} else {
|
||||
viewHolder.binding.dmItemTvStartorpause.setText(R.string.install);
|
||||
}
|
||||
}
|
||||
if (xapkStatus != null && !xapkStatus.isEmpty()) {
|
||||
xapkStatusMap.put(downloadEntity.getUrl(), xapkStatus);
|
||||
@ -264,17 +269,20 @@ class GameDownloadFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
viewHolder.binding.dmItemTvStartorpause.setOnClickListener(v -> {
|
||||
String str = ((DownloadButton) v).getText();
|
||||
final String url = downloadEntity.getUrl();
|
||||
final String currentXApkStatus = downloadEntity.getMeta().get(XapkInstaller.XAPK_UNZIP_STATUS);
|
||||
DownloadManager.getInstance().put(url, System.currentTimeMillis());
|
||||
if (XapkUnzipStatus.UNZIPPING.name().equals(xapkStatus)) {
|
||||
if (XapkUnzipStatus.SUCCESS.name().equals(currentXApkStatus) && XapkInstaller.INSTANCE.isInstalling(downloadEntity.getPath())) {
|
||||
return;
|
||||
} else if (XapkUnzipStatus.UNZIPPING.name().equals(currentXApkStatus)) {
|
||||
XapkInstaller.cancelUnzipTask(downloadEntity);
|
||||
return;
|
||||
} else if (XapkUnzipStatus.FAILURE.name().equals(xapkStatus)
|
||||
|| XapkUnzipStatus.SUCCESS.name().equals(xapkStatus)) {
|
||||
} else if (XapkUnzipStatus.FAILURE.name().equals(currentXApkStatus)
|
||||
|| XapkUnzipStatus.SUCCESS.name().equals(currentXApkStatus)) {
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(mContext, () -> {
|
||||
final String path = downloadEntity.getPath();
|
||||
if (downloadEntity.isPluggable()
|
||||
&& PackagesManager.isInstalled(downloadEntity.getPackageName())) {
|
||||
showPluginDialog(downloadEntity.getPath());
|
||||
showPluginDialog(downloadEntity.getPath(), downloadEntity.getPluginDesc());
|
||||
} else {
|
||||
if (FileUtils.isEmptyFile(path)) {
|
||||
Utils.toast(mContext, R.string.install_failure_hint);
|
||||
@ -323,7 +331,7 @@ class GameDownloadFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
final String path = downloadEntity.getPath();
|
||||
if (downloadEntity.isPluggable()
|
||||
&& PackagesManager.isInstalled(downloadEntity.getPackageName())) {
|
||||
showPluginDialog(downloadEntity.getPath());
|
||||
showPluginDialog(downloadEntity.getPath(), downloadEntity.getPluginDesc());
|
||||
} else {
|
||||
if (FileUtils.isEmptyFile(path)) {
|
||||
Utils.toast(mContext, R.string.install_failure_hint);
|
||||
@ -334,7 +342,7 @@ class GameDownloadFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
}
|
||||
});
|
||||
} else if (str.equals(mContext.getString(R.string.launch))) {
|
||||
PackageUtils.launchApplicationByPackageName(mContext, downloadEntity.getPackageName());
|
||||
PackageLauncher.launchApp(mContext, null, downloadEntity.getPackageName());
|
||||
}
|
||||
break;
|
||||
case redirected:
|
||||
@ -469,8 +477,8 @@ class GameDownloadFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
}
|
||||
|
||||
// 显示插件化
|
||||
void showPluginDialog(final String path) {
|
||||
DialogHelper.showPluginDialog(mContext, () -> {
|
||||
void showPluginDialog(final String path, final String pluginDesc) {
|
||||
DialogHelper.showPluginDialog(mContext, pluginDesc, () -> {
|
||||
if (FileUtils.isEmptyFile(path)) {
|
||||
Utils.toast(mContext, R.string.install_failure_hint);
|
||||
} else {
|
||||
@ -629,8 +637,7 @@ class GameDownloadFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
statusMap.put(downloadEntity.getUrl(), downloadEntity.getStatus().name());
|
||||
if (DownloadStatus.done.equals(downloadEntity.getStatus())) {
|
||||
if (!ExtensionsKt.isSimulatorGame(downloadEntity)) {
|
||||
urlMap.put(PackageUtils.getPackageNameByPath(mContext,
|
||||
downloadEntity.getPath()), downloadEntity.getUrl());
|
||||
urlMap.put(downloadEntity.getPackageName(), downloadEntity.getUrl());
|
||||
mDownloadedList.add(downloadEntity);
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -15,12 +15,11 @@ import com.gh.gamecenter.feature.exposure.ExposureType
|
||||
import com.gh.common.exposure.IExposable
|
||||
import com.gh.common.simulator.SimulatorGameManager.isSimulatorGame
|
||||
import com.gh.common.util.*
|
||||
import com.gh.common.util.DownloadItemUtils.setOnClickListener
|
||||
import com.gh.common.util.DownloadItemUtils.updateItem
|
||||
import com.gh.gamecenter.GameDetailActivity
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.viewholder.FooterViewHolder
|
||||
import com.gh.gamecenter.adapter.viewholder.GameViewHolder
|
||||
import com.gh.gamecenter.common.utils.putWidgetBusinessName
|
||||
import com.gh.gamecenter.common.utils.safelyGetInRelease
|
||||
import com.gh.gamecenter.feature.databinding.GameItemBinding
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
@ -92,17 +91,18 @@ class NewInstalledGameFragmentAdapter(context: Context, private var mViewModel:
|
||||
}
|
||||
binding.gameName.text = name
|
||||
generateExposureEvent(gameEntity)
|
||||
setOnClickListener(
|
||||
DownloadItemUtils.setOnClickListener(
|
||||
binding.root.context,
|
||||
binding.downloadBtn,
|
||||
gameEntity,
|
||||
1,
|
||||
this@NewInstalledGameFragmentAdapter,
|
||||
"(我的光环-已安装)", "我的光环-已安装" + ":" + gameEntity.name,
|
||||
gameEntity.exposureEvent // , () -> MtaHelper.onEvent("下载管理", "已安装", binding.downloadBtn.getText().toString())
|
||||
gameEntity.exposureEvent
|
||||
)
|
||||
updateItem(binding.root.context, gameEntity, GameViewHolder(binding), !gameEntity.isPluggable)
|
||||
holder.itemView.setOnClickListener { v: View? ->
|
||||
binding.downloadBtn.putWidgetBusinessName("下载管理")
|
||||
DownloadItemUtils.updateItem(binding.root.context, gameEntity, GameViewHolder(binding), !gameEntity.isPluggable)
|
||||
holder.itemView.setOnClickListener {
|
||||
DataCollectionUtils.uploadClick(binding.root.context, "列表", "我的光环-我的游戏", gameEntity.name)
|
||||
GameDetailActivity.startGameDetailActivity(
|
||||
binding.root.context,
|
||||
|
||||
@ -19,8 +19,6 @@ import com.gh.download.DownloadManager
|
||||
import com.gh.download.dialog.DownloadDialog
|
||||
import com.gh.gamecenter.DownloadManagerActivity
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.GlobalActivityManager
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.common.view.BugFixedPopupWindow
|
||||
import com.gh.gamecenter.core.utils.CurrentActivityHolder
|
||||
@ -335,6 +333,8 @@ class UpdatableGameAdapter(private var mViewModel: UpdatableGameViewModel) :
|
||||
}
|
||||
}
|
||||
|
||||
updateBtn.putWidgetBusinessName("下载管理")
|
||||
updateBtn.putObject(update)
|
||||
updateBtn.setOnClickListener {
|
||||
val str: String = updateBtn.text.toString()
|
||||
if ("更新" == str || str.contains("化")) {
|
||||
@ -380,7 +380,7 @@ class UpdatableGameAdapter(private var mViewModel: UpdatableGameViewModel) :
|
||||
}
|
||||
}
|
||||
} else if (updateBtn.context.getString(R.string.launch) == str) {
|
||||
PackageUtils.launchApplicationByPackageName(updateBtn.context, update.packageName)
|
||||
PackageLauncher.launchApp(updateBtn.context, packageName = update.packageName)
|
||||
} else if (updateBtn.context.getString(R.string.resume) == str) {
|
||||
if (downloadEntity != null) {
|
||||
DownloadManager.getInstance().resume(downloadEntity, true)
|
||||
@ -401,21 +401,6 @@ class UpdatableGameAdapter(private var mViewModel: UpdatableGameViewModel) :
|
||||
updateBtn.buttonStyle = DownloadButton.ButtonStyle.NORMAL
|
||||
}
|
||||
}
|
||||
|
||||
SensorsBridge.trackEvent(
|
||||
"DownLoadbuttonClick",
|
||||
"game_id", update.id,
|
||||
"game_name", update.name ?: "",
|
||||
"game_type", update.categoryChinese,
|
||||
"download_status", update.downloadStatusChinese,
|
||||
"button_name", str,
|
||||
"page_name", GlobalActivityManager.getCurrentPageEntity().pageName,
|
||||
"page_id", GlobalActivityManager.getCurrentPageEntity().pageId,
|
||||
"page_business_id", GlobalActivityManager.getCurrentPageEntity().pageBusinessId,
|
||||
"last_page_name", GlobalActivityManager.getLastPageEntity().pageName,
|
||||
"last_page_id", GlobalActivityManager.getLastPageEntity().pageId,
|
||||
"last_page_business_id", GlobalActivityManager.getLastPageEntity().pageBusinessId
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -16,11 +16,8 @@ import com.gh.gamecenter.common.base.GlobalActivityManager.getCurrentPageEntity
|
||||
import com.gh.gamecenter.common.base.GlobalActivityManager.getLastPageEntity
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.retrofit.Response
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.common.utils.SensorsBridge.trackEvent
|
||||
import com.gh.gamecenter.common.utils.addMetaExtra
|
||||
import com.gh.gamecenter.common.utils.secondOrNull
|
||||
import com.gh.gamecenter.common.utils.toProperReadableSize
|
||||
import com.gh.gamecenter.common.utils.tryCatchInRelease
|
||||
import com.gh.gamecenter.core.utils.GsonUtils.toJson
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.core.utils.UrlFilterUtils
|
||||
@ -78,7 +75,9 @@ class UpdatableGameViewModel(
|
||||
// 有闪退日志说这个 update 实体可能为空,实在看不原因 :(
|
||||
if (update == null) continue
|
||||
// 筛选仅下载管理出现的插件化更新
|
||||
if (update.isShowPlugin(PluginLocation.only_index) && update.downloadStatus != "smooth") {
|
||||
if (update.isShowPlugin(PluginLocation.only_index)
|
||||
&& update.downloadStatus != Constants.V_GAME
|
||||
&& update.downloadStatus != Constants.V_GAME_32) {
|
||||
val platform =
|
||||
PlatformUtils.getInstance(getApplication()).getPlatformName(update.platform)
|
||||
if (!platform.isNullOrEmpty() && "官方版" != platform) {
|
||||
@ -585,12 +584,14 @@ class UpdatableGameViewModel(
|
||||
downloadEntity.platform = update.platform
|
||||
downloadEntity.packageName = update.packageName
|
||||
downloadEntity.versionName = update.version
|
||||
downloadEntity.pluginDesc = update.pluginDesc
|
||||
downloadEntity.addMetaExtra(Constants.RAW_GAME_ICON, update.rawIcon)
|
||||
downloadEntity.addMetaExtra(Constants.GAME_ICON_SUBSCRIPT, update.iconSubscript)
|
||||
downloadEntity.addMetaExtra(Constants.DOWNLOAD_ID, downloadId)
|
||||
downloadEntity.addMetaExtra(Constants.APK_MD5, update.md5)
|
||||
downloadEntity.addMetaExtra(Constants.GAME_NAME, update.name)
|
||||
downloadEntity.addMetaExtra(Constants.GAME_TYPE, update.categoryChinese)
|
||||
downloadEntity.addMetaExtra(Constants.GAME_CATEGORY_IN_CHINESE, update.categoryChinese)
|
||||
downloadEntity.putGameCategory(update.category ?: "")
|
||||
if (update.iconFloat != null) {
|
||||
downloadEntity.addMetaExtra(Constants.GAME_ICON_FLOAT_TOP_TEXT, update.iconFloat?.upperLeftText)
|
||||
downloadEntity.addMetaExtra(Constants.GAME_ICON_FLOAT_TOP_COLOR, update.iconFloat?.upperLeftColor)
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
package com.gh.gamecenter.entity
|
||||
|
||||
import android.os.Parcelable
|
||||
import com.gh.gamecenter.common.entity.LinkEntity
|
||||
import com.gh.gamecenter.feature.entity.PersonalEntity
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
data class GameCollectionPlayerCreationEntity(
|
||||
@SerializedName("tip_link")
|
||||
val tipLink: LinkEntity? = null,
|
||||
val data: List<PlayerCreationItem>? = ArrayList()
|
||||
)
|
||||
|
||||
@Parcelize
|
||||
data class GameCollectionHotListTab(
|
||||
@SerializedName("_id")
|
||||
val id: String = "",
|
||||
val name: String = "",
|
||||
var position: Int = -1
|
||||
) : Parcelable
|
||||
|
||||
data class PlayerCreationItem(
|
||||
val user: PersonalEntity? = null,
|
||||
@SerializedName("game_list")
|
||||
val gameList: GamesCollectionEntity? = null
|
||||
)
|
||||
@ -18,6 +18,8 @@ data class GameInstall(
|
||||
var installTime: Long = 0,
|
||||
var version: String = "",
|
||||
var isSmoothGame: Boolean = false, // 是否是畅玩游戏
|
||||
var downloadStatus: String? = "", // 下载状态,对应 GameEntity 的 downloadStatus
|
||||
var category: String? = "", // 类型,对应 GameEntity 的 category
|
||||
var tag: Any? = null
|
||||
) {
|
||||
|
||||
@ -35,6 +37,8 @@ data class GameInstall(
|
||||
gameInstall.version = PackageUtils.getVersionNameByPackageName(installedPkgName) ?: "unknown"
|
||||
gameInstall.packageName = installedPkgName
|
||||
gameInstall.isSmoothGame = game.isVGame()
|
||||
gameInstall.downloadStatus = game.downloadStatus
|
||||
gameInstall.category = game.category
|
||||
return gameInstall
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
package com.gh.gamecenter.entity
|
||||
|
||||
import com.gh.gamecenter.gamecollection.square.GameCollectionListItemData
|
||||
|
||||
data class GameListCollection(
|
||||
var id: String = "",
|
||||
var name: String = "",
|
||||
var style: String = "",
|
||||
var gameCollectionItemDataList: List<GameCollectionListItemData> = arrayListOf(),
|
||||
)
|
||||
@ -1,5 +1,6 @@
|
||||
package com.gh.gamecenter.entity
|
||||
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.entity.IconFloat
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.gh.gamecenter.feature.entity.*
|
||||
@ -60,7 +61,7 @@ data class GameUpdateEntity(
|
||||
val downloadStatusChinese: String
|
||||
get() = when (downloadStatus) {
|
||||
"on" -> "开启"
|
||||
"smooth" -> "畅玩"
|
||||
Constants.V_GAME, Constants.V_GAME_32 -> "畅玩"
|
||||
"appointment" -> "预约"
|
||||
"demo" -> "试玩"
|
||||
else -> ""
|
||||
|
||||
@ -15,7 +15,7 @@ data class HomeContent(
|
||||
@SerializedName("link_column")
|
||||
val linkColumn: SubjectEntity? = null,
|
||||
@SerializedName("game_list")
|
||||
val linkGameCollection: List<GamesCollectionEntity>? = null,
|
||||
var linkGameCollection: List<HomeGameCollectionEntity>? = null,
|
||||
@SerializedName("link_top_game_comment")
|
||||
val linkTopGameComment: List<AmwayCommentEntity>? = null,
|
||||
@SerializedName("display_content")
|
||||
@ -35,4 +35,5 @@ data class HomeContent(
|
||||
val recommendTag: String = "",
|
||||
@SerializedName("ad_icon_active")
|
||||
val adIconActive: Boolean = false,
|
||||
var style: String = "",
|
||||
)
|
||||
@ -0,0 +1,53 @@
|
||||
package com.gh.gamecenter.entity
|
||||
|
||||
import android.os.Parcelable
|
||||
import com.gh.gamecenter.feature.entity.*
|
||||
import com.gh.gamecenter.feature.entity.TimeEntity
|
||||
import com.gh.gamecenter.room.converter.*
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class HomeGameCollectionEntity(
|
||||
@SerializedName("_id")
|
||||
var id: String = "",
|
||||
var games: ArrayList<GameEntity>? = null,
|
||||
var title: String = "",
|
||||
var intro: String = "",
|
||||
var cover: String = "",
|
||||
var display: String = "",//self_only: 仅自己可见
|
||||
var stamp: String = "",//special_choice: 精选 offical: 官方
|
||||
var count: Count? = null,
|
||||
var user: User? = null,
|
||||
var time: TimeEntity? = null,
|
||||
@SerializedName("ad_icon_active")
|
||||
var adIconActive: Boolean = false,
|
||||
) : Parcelable {
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as HomeGameCollectionEntity
|
||||
// 这里只对比游戏单id判断是否相同
|
||||
if (id != other.id) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = id.hashCode()
|
||||
result = 31 * result + (games?.hashCode() ?: 0)
|
||||
result = 31 * result + title.hashCode()
|
||||
result = 31 * result + intro.hashCode()
|
||||
result = 31 * result + cover.hashCode()
|
||||
result = 31 * result + display.hashCode()
|
||||
result = 31 * result + stamp.hashCode()
|
||||
result = 31 * result + (count?.hashCode() ?: 0)
|
||||
result = 31 * result + (user?.hashCode() ?: 0)
|
||||
result = 31 * result + (time?.hashCode() ?: 0)
|
||||
result = 31 * result + adIconActive.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
}
|
||||
@ -2,6 +2,7 @@ package com.gh.gamecenter.entity
|
||||
|
||||
import com.gh.gamecenter.common.entity.Display
|
||||
import com.gh.gamecenter.common.entity.LinkEntity
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
data class HomeRecommend(
|
||||
@ -13,7 +14,10 @@ data class HomeRecommend(
|
||||
val linkText: String = "",
|
||||
val icon: String = "",
|
||||
val name: String = "",
|
||||
val display: Display = Display()
|
||||
val display: Display = Display(),
|
||||
|
||||
// 绑定的曝光实体
|
||||
var exposureEvent: ExposureEvent? = null,
|
||||
) {
|
||||
|
||||
fun transformLinkEntity(): LinkEntity {
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.gh.gamecenter.entity
|
||||
|
||||
import com.gh.gamecenter.common.entity.LinkEntity
|
||||
import com.gh.gamecenter.feature.entity.SimulatorEntity
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
@ -29,7 +30,9 @@ class NewApiSettingsEntity(
|
||||
// VPN 配置
|
||||
class Install(
|
||||
@SerializedName("vpn_required")
|
||||
val vpnRequired: VpnSetting? = null
|
||||
val vpnRequired: VpnSetting? = null,
|
||||
@SerializedName("guides")
|
||||
val guides: List<Guide>? = null
|
||||
)
|
||||
|
||||
class VpnSetting(
|
||||
@ -38,4 +41,9 @@ class NewApiSettingsEntity(
|
||||
@SerializedName("packages")
|
||||
val vpnMatchedPackagesName: HashSet<String>
|
||||
)
|
||||
|
||||
class Guide(
|
||||
val type: String,
|
||||
val link: LinkEntity
|
||||
)
|
||||
}
|
||||
@ -41,7 +41,7 @@ data class SubjectEntity(
|
||||
var verticalLine: String = "", // 竖排时才有数据,代表竖排行数控制
|
||||
|
||||
@SerializedName("game_list_collection")
|
||||
var gameListCollection: List<GamesCollectionEntity>? = null,
|
||||
var gameListCollection: List<HomeGameCollectionEntity>? = null,
|
||||
|
||||
@SerializedName("column_test_v2_data")
|
||||
val testV2Data: HomeItemTestV2Entity? = null,
|
||||
|
||||
@ -3,6 +3,7 @@ package com.gh.gamecenter.entity
|
||||
import android.graphics.Color
|
||||
import android.os.Parcelable
|
||||
import com.gh.gamecenter.common.entity.Display
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@ -52,6 +53,7 @@ data class SubjectRecommendEntity(
|
||||
var currentSelectColor: Int = 0,
|
||||
var isTopViewShow: Boolean = true,
|
||||
var isSlideEmpty: Boolean = false, // 首页轮播图是否为空
|
||||
var exposureEvent: ExposureEvent? = null, // 绑定的曝光实体
|
||||
) : Parcelable {
|
||||
|
||||
/*init {
|
||||
|
||||
@ -3,8 +3,8 @@ package com.gh.gamecenter.entity
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
class VSetting {
|
||||
@SerializedName("va")
|
||||
var va: Va? = null
|
||||
var gsf: GApp? = null
|
||||
|
||||
class Va(
|
||||
@SerializedName("32-bit")
|
||||
@ -23,4 +23,9 @@ class VSetting {
|
||||
val versionCode: Int,
|
||||
val url: String
|
||||
)
|
||||
|
||||
class GApp(
|
||||
val url: String? = null,
|
||||
var md5: String? = null
|
||||
)
|
||||
}
|
||||
@ -83,7 +83,7 @@ class ForumArticleAskListFragment : LazyListFragment<AnswerEntity, ForumArticleA
|
||||
mListRv.setBackgroundColor(R.color.background_white.toColor(requireContext()))
|
||||
mScrollCalculatorHelper = ForumScrollCalculatorHelper(R.id.horizontalVideoView, R.id.verticalVideoView, 0)
|
||||
|
||||
requireView().setBackgroundColor(R.color.background_white.toColor(requireContext()))
|
||||
view?.setBackgroundColor(R.color.background_white.toColor(requireContext()))
|
||||
|
||||
mSkeletonScreen = Skeleton.bind(mBinding.listSkeleton)
|
||||
.shimmer(true)
|
||||
@ -115,11 +115,6 @@ class ForumArticleAskListFragment : LazyListFragment<AnswerEntity, ForumArticleA
|
||||
|
||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||
super.onScrolled(recyclerView, dx, dy)
|
||||
if (dy > Constants.FOLLOW_HINT_TRIGGER_HEIGHT) {
|
||||
EventBus.getDefault().post(EBTypeChange(ForumDetailFragment.EB_HIDE_QUESTION_BUTTON, 0))
|
||||
} else if (dy < -Constants.FOLLOW_HINT_TRIGGER_HEIGHT) {
|
||||
EventBus.getDefault().post(EBTypeChange(ForumDetailFragment.EB_SHOW_QUESTION_BUTTON, 0))
|
||||
}
|
||||
if (dy != 0) scroll()
|
||||
}
|
||||
})
|
||||
@ -142,13 +137,16 @@ class ForumArticleAskListFragment : LazyListFragment<AnswerEntity, ForumArticleA
|
||||
|
||||
override fun onLoadRefresh() {
|
||||
super.onLoadRefresh()
|
||||
requireView().setBackgroundColor(R.color.background_white.toColor(requireContext()))
|
||||
// Fix:https://sentry.shanqu.cc/organizations/lightgame/issues/288994/?project=22&query=LazyListFragment&statsPeriod=14d
|
||||
// Fragment在内存泄露的情况下,调用requireView()会触发崩溃,这里替换为getView()方法
|
||||
// TODO 解决Fragment内存泄露的问题
|
||||
view?.setBackgroundColor(R.color.background_white.toColor(requireContext()))
|
||||
}
|
||||
|
||||
override fun onLoadDone() {
|
||||
super.onLoadDone()
|
||||
requireView().setBackgroundColor(Color.TRANSPARENT)
|
||||
AppExecutor.uiExecutor.executeWithDelay(Runnable {
|
||||
view?.setBackgroundColor(Color.TRANSPARENT)
|
||||
mBaseHandler.postDelayed(Runnable {
|
||||
tryCatchInRelease {
|
||||
scroll()
|
||||
mScrollCalculatorHelper?.onScrollStateChanged(mListRv, RecyclerView.SCROLL_STATE_IDLE)
|
||||
@ -158,12 +156,12 @@ class ForumArticleAskListFragment : LazyListFragment<AnswerEntity, ForumArticleA
|
||||
|
||||
override fun onLoadError() {
|
||||
super.onLoadError()
|
||||
requireView().setBackgroundColor(Color.TRANSPARENT)
|
||||
view?.setBackgroundColor(Color.TRANSPARENT)
|
||||
}
|
||||
|
||||
override fun onLoadEmpty() {
|
||||
super.onLoadEmpty()
|
||||
requireView().setBackgroundColor(Color.TRANSPARENT)
|
||||
view?.setBackgroundColor(Color.TRANSPARENT)
|
||||
}
|
||||
|
||||
override fun hideRefreshingLayout() {
|
||||
|
||||
@ -96,11 +96,6 @@ class ForumArticleListFragment : LazyListFragment<ArticleEntity, ForumArticleLis
|
||||
}
|
||||
|
||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||
if (dy > Constants.FOLLOW_HINT_TRIGGER_HEIGHT) {
|
||||
EventBus.getDefault().post(EBTypeChange(CommunityHomeFragment.EB_HIDE_QUESTION_BUTTON, 0))
|
||||
} else if (dy < -Constants.FOLLOW_HINT_TRIGGER_HEIGHT) {
|
||||
EventBus.getDefault().post(EBTypeChange(CommunityHomeFragment.EB_SHOW_QUESTION_BUTTON, 0))
|
||||
}
|
||||
if (dy != 0) scroll()
|
||||
if (parentFragment is CommunityHomeFragment) {
|
||||
(parentFragment as CommunityHomeFragment).translateTopBg(recyclerView.computeVerticalScrollOffset() - 8F.dip2px())
|
||||
|
||||
@ -773,7 +773,18 @@ class HomeSearchToolWrapperFragment : SearchToolWrapperFragment() {
|
||||
}
|
||||
|
||||
// 这里的 selectedPosition 指的是应该被高亮显示的 position
|
||||
val selectedPosition = (position + positionOffset).roundToInt()
|
||||
val selectedPosition = try {
|
||||
(position + positionOffset).roundToInt()
|
||||
} catch (e: IllegalArgumentException) {
|
||||
// roundToInt() 方法有时候会报 Cannot round NaN value. 错误
|
||||
// https://sentry.shanqu.cc/organizations/lightgame/issues/301377/?project=22
|
||||
SentryHelper.onEvent(
|
||||
"HOME_NAN_POSITION",
|
||||
"value",
|
||||
"$position+$positionOffset=(${position + positionOffset})"
|
||||
)
|
||||
position
|
||||
}
|
||||
val positionOffsetOnRealSelectedPosition = if (positionOffset >= 0.5) {
|
||||
positionOffset - 1
|
||||
} else {
|
||||
@ -797,8 +808,8 @@ class HomeSearchToolWrapperFragment : SearchToolWrapperFragment() {
|
||||
// positionOffset 小于零,表示 indicator 当前位置处于选中的 tab 的左边
|
||||
val indicatorOnLeft = positionOffset < 0F
|
||||
|
||||
val selectedTabBinding = mTabBindingList[selectedPosition]
|
||||
val selectedTabImageStyle = mTabImageStyleList[selectedPosition]
|
||||
val selectedTabBinding = mTabBindingList.safelyGetInRelease(selectedPosition) ?: return
|
||||
val selectedTabImageStyle = mTabImageStyleList.safelyGetInRelease(selectedPosition) ?: return
|
||||
|
||||
// 前一个 tab、当前选中的 tab、后一个 tab 的显示比例
|
||||
val preScaleRatio = 1 + abs(positionOffset) / 4
|
||||
@ -1097,6 +1108,11 @@ class HomeSearchToolWrapperFragment : SearchToolWrapperFragment() {
|
||||
putInt(EntranceConsts.KEY_POSITION, 0)
|
||||
putString(EntranceConsts.KEY_COLUMNNAME, tabEntity.text)
|
||||
putBoolean(EntranceConsts.KEY_IS_COLUMN_COLLECTION, true)
|
||||
putInt(EntranceConsts.KEY_TAB_INDEX, index)
|
||||
putParcelableArrayList(
|
||||
EntranceConsts.KEY_EXPOSURE_SOURCE_LIST,
|
||||
arrayListOf(ExposureSource("顶部tab", tabEntity.name ?: ""))
|
||||
)
|
||||
})
|
||||
|
||||
"column" -> SubjectFragment().with(Bundle().apply {
|
||||
@ -1121,6 +1137,11 @@ class HomeSearchToolWrapperFragment : SearchToolWrapperFragment() {
|
||||
putString(EntranceConsts.KEY_ENTRANCE, "首页顶部Tab栏")
|
||||
putString(EntranceConsts.KEY_COLLECTION_ID, tabEntity.link)
|
||||
putString(EntranceConsts.KEY_COLUMNNAME, tabEntity.text)
|
||||
putInt(EntranceConsts.KEY_TAB_INDEX, index)
|
||||
putParcelableArrayList(
|
||||
EntranceConsts.KEY_EXPOSURE_SOURCE_LIST,
|
||||
arrayListOf(ExposureSource("顶部tab", tabEntity.name ?: ""))
|
||||
)
|
||||
})
|
||||
|
||||
"explore_column" -> DiscoveryFragment().with(Bundle().apply {
|
||||
|
||||
@ -84,6 +84,7 @@ class HomeSearchToolWrapperViewModel(application: Application) : AndroidViewMode
|
||||
if (pkgLinkEntity.type == tab.type
|
||||
&& (pkgLinkEntity.link == tab.link || tab.link == null)) {
|
||||
defaultTabPosition = index
|
||||
PkgHelper.markConfigUsed()
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ class WelcomeDialogFragment : BaseDialogFragment() {
|
||||
DirectUtils.directToGameDetail(
|
||||
requireContext(),
|
||||
mWelcomeEntity?.link!!,
|
||||
EntranceConsts.ENTRANCE_WELCOME
|
||||
entrance = EntranceConsts.ENTRANCE_WELCOME
|
||||
)
|
||||
}
|
||||
EntranceConsts.HOST_COLUMN -> {
|
||||
|
||||
@ -68,19 +68,20 @@ import com.gh.gamecenter.game.rank.RankCollectionViewHolder
|
||||
import com.gh.gamecenter.game.vertical.GameVerticalAdapter
|
||||
import com.gh.gamecenter.game.vertical.GameVerticalSlideViewHolder
|
||||
import com.gh.gamecenter.game.vertical.OnPagerSnapScrollListener
|
||||
import com.gh.gamecenter.home.BlankDividerViewHolder
|
||||
import com.gh.gamecenter.home.HomeDividerViewHolder
|
||||
import com.gh.gamecenter.home.HomeGameItemViewHolder
|
||||
import com.gh.gamecenter.home.*
|
||||
import com.gh.gamecenter.home.discovercard.DiscoverCardGameAdapter
|
||||
import com.gh.gamecenter.home.discovercard.HomeDiscoverCardViewHolder
|
||||
import com.gh.gamecenter.home.gamecollection.HomeGameCollectionViewHolder
|
||||
import com.gh.gamecenter.home.gamecollection.carousel.HomeGameCollectionCarouselViewHolder
|
||||
import com.gh.gamecenter.home.gamecollection.refresh.HomeGameCollectionRefreshAdapter
|
||||
import com.gh.gamecenter.home.gamecollection.refresh.HomeGameCollectionRefreshViewHolder
|
||||
import com.gh.gamecenter.home.gamecollection.slide.HomeGameCollectionSlideAdapter
|
||||
import com.gh.gamecenter.home.gamecollection.slide.HomeGameCollectionSlideViewHolder
|
||||
import com.gh.gamecenter.home.horizontalslidevideo.HomeHorizontalSlideVideoAdapter
|
||||
import com.gh.gamecenter.home.horizontalslidevideo.HomeHorizontalSlideVideoListViewHolder
|
||||
import com.gh.gamecenter.home.test_v2.HomeGameTestV2GameListRvAdapter
|
||||
import com.gh.gamecenter.home.test_v2.HomeGameTestV2ViewModel
|
||||
import com.gh.gamecenter.home.test_v2.HomeItemGameTestV2ViewHolder
|
||||
import com.gh.gamecenter.home.video.ScrollCalculatorHelper
|
||||
import com.gh.gamecenter.servers.GameServersActivity
|
||||
import com.gh.gamecenter.servers.gametest2.GameServerTestV2Activity
|
||||
import com.gh.gamecenter.subject.SubjectActivity
|
||||
import com.lightgame.adapter.BaseRecyclerAdapter
|
||||
@ -91,7 +92,7 @@ class GameFragmentAdapter(
|
||||
model: GameViewModel,
|
||||
private val mLifecycleOwner: LifecycleOwner,
|
||||
private val mHomeGameTestV2ViewModel: HomeGameTestV2ViewModel,
|
||||
private val mBasicExposureSource: List<ExposureSource>,
|
||||
private val mBasicExposureSource: ArrayList<ExposureSource>,
|
||||
private val mLayoutManager: LinearLayoutManager?,
|
||||
private val mScrollCalculatorHelper: ScrollCalculatorHelper? = null
|
||||
) : BaseRecyclerAdapter<ViewHolder>(context), IExposable {
|
||||
@ -140,7 +141,16 @@ class GameFragmentAdapter(
|
||||
if (itemData.gallerySlide != null) return ItemViewType.GALLERY_SLIDE
|
||||
if (itemData.blankDivider != null) return ItemViewType.BLANK_DIVIDER
|
||||
if (itemData.rankCollection != null) return ItemViewType.RANK_COLLECTION
|
||||
if (itemData.gameCollection != null) return ItemViewType.GAME_COLLECTION_ITEM
|
||||
if (itemData.gameCollection != null) {
|
||||
return when (itemData.gameCollection!!.style) {
|
||||
LegacyHomeFragmentAdapterAssistant.GAME_COLLECTION_CAROUSEL_STYLE -> ItemViewType.GAME_COLLECTION_CAROUSEL
|
||||
LegacyHomeFragmentAdapterAssistant.GAME_COLLECTION_BIG_SLIDE_STYLE -> ItemViewType.GAME_COLLECTION_BIG_SLIDE
|
||||
LegacyHomeFragmentAdapterAssistant.GAME_COLLECTION_SMALL_SLIDE_STYLE -> ItemViewType.GAME_COLLECTION_SMALL_SLIDE
|
||||
LegacyHomeFragmentAdapterAssistant.GAME_COLLECTION_HORIZONTAL_REFRESH_STYLE -> ItemViewType.GAME_COLLECTION_HORIZONTAL_REFRESH
|
||||
LegacyHomeFragmentAdapterAssistant.GAME_COLLECTION_VERTICAL_REFRESH_STYLE -> ItemViewType.GAME_COLLECTION_VERTICAL_REFRESH
|
||||
else -> ItemViewType.GAME_COLLECTION_CAROUSEL // style为空时默认展示轮播图
|
||||
}
|
||||
}
|
||||
if (itemData.doubleCardColumn != null) return ItemViewType.DOUBLE_CARD_COLUMN
|
||||
if (itemData.bigImageRecommend != null) return ItemViewType.BIG_IMAGE_RECOMMEND
|
||||
if (itemData.attachGame != null) return ItemViewType.GAME_ITEM
|
||||
@ -160,6 +170,7 @@ class GameFragmentAdapter(
|
||||
GameViewpagerItemBinding.bind(mLayoutInflater.inflate(R.layout.game_viewpager_item, parent, false))
|
||||
GameViewPagerViewHolder(view, displayMetrics)
|
||||
}
|
||||
|
||||
ItemViewType.LOADING -> {
|
||||
FooterViewHolder(mLayoutInflater.inflate(R.layout.refresh_footerview, parent, false))
|
||||
}
|
||||
@ -176,11 +187,12 @@ class GameFragmentAdapter(
|
||||
ItemViewType.GALLERY -> GameGalleryViewHolder(
|
||||
GameGalleryViewHolder.GameGalleryItemCell(mContext).apply { inflate() }
|
||||
)
|
||||
|
||||
ItemViewType.BLANK_DIVIDER -> BlankDividerViewHolder(parent.toBinding())
|
||||
ItemViewType.COMMON_LINK_COLLECTION -> CommonCollectionViewHolder(parent.toBinding())
|
||||
ItemViewType.COMMON_LINK_COLLECTION12 -> CommonCollection12ViewHolder(parent.toBinding())
|
||||
ItemViewType.RANK_COLLECTION -> RankCollectionViewHolder(parent.toBinding())
|
||||
ItemViewType.GAME_COLLECTION_ITEM -> HomeGameCollectionViewHolder(parent.toBinding())
|
||||
ItemViewType.GAME_COLLECTION_CAROUSEL -> HomeGameCollectionCarouselViewHolder(parent.toBinding())
|
||||
ItemViewType.DOUBLE_CARD_COLUMN -> DoubleCardViewHolder(parent.toBinding())
|
||||
ItemViewType.BIG_IMAGE_RECOMMEND -> BigImageRecommendViewHolder(parent.toBinding())
|
||||
ItemViewType.GAME_ITEM -> HomeGameItemViewHolder(parent.toBinding())
|
||||
@ -191,7 +203,13 @@ class GameFragmentAdapter(
|
||||
mHomeGameTestV2ViewModel,
|
||||
mLifecycleOwner
|
||||
)
|
||||
|
||||
ItemViewType.HORIZONTAL_SLIDE_VIDEO -> HomeHorizontalSlideVideoListViewHolder(parent.toBinding())
|
||||
ItemViewType.GAME_COLLECTION_BIG_SLIDE,
|
||||
ItemViewType.GAME_COLLECTION_SMALL_SLIDE -> HomeGameCollectionSlideViewHolder(parent.toBinding())
|
||||
|
||||
ItemViewType.GAME_COLLECTION_HORIZONTAL_REFRESH,
|
||||
ItemViewType.GAME_COLLECTION_VERTICAL_REFRESH -> HomeGameCollectionRefreshViewHolder(parent.toBinding())
|
||||
|
||||
else -> GameItemViewHolder(GameItemBinding.bind(mLayoutInflater.inflate(R.layout.game_item, parent, false)))
|
||||
}
|
||||
@ -215,7 +233,7 @@ class GameFragmentAdapter(
|
||||
is CommonCollectionViewHolder -> bindCommonCollection(holder, position)
|
||||
is CommonCollection12ViewHolder -> bindCommonCollection(holder, position)
|
||||
is RankCollectionViewHolder -> bindRankCollection(holder, position)
|
||||
is HomeGameCollectionViewHolder -> bindGameCollection(holder, position)
|
||||
is HomeGameCollectionCarouselViewHolder -> bindGameCollectionCarousel(holder, position)
|
||||
is DoubleCardViewHolder -> bindGameDoubleCard(holder, position)
|
||||
is BigImageRecommendViewHolder -> bindBigImageRecommend(holder, position)
|
||||
is HomeGameItemViewHolder -> bindAttachGame(holder, position)
|
||||
@ -223,6 +241,8 @@ class GameFragmentAdapter(
|
||||
is HomeDiscoverCardViewHolder -> bindDiscoverCard(holder, position)
|
||||
is HomeItemGameTestV2ViewHolder -> bindGameTestV2ViewHolder(holder, position)
|
||||
is HomeHorizontalSlideVideoListViewHolder -> bindHomeHorizontalSlideVideo(holder, position)
|
||||
is HomeGameCollectionSlideViewHolder -> bindGameCollectionSlide(holder, position)
|
||||
is HomeGameCollectionRefreshViewHolder -> bindGameCollectionRefresh(holder, position)
|
||||
}
|
||||
}
|
||||
|
||||
@ -267,24 +287,27 @@ class GameFragmentAdapter(
|
||||
}
|
||||
|
||||
private fun bindColumnCollection(holder: GameColumnCollectionViewHolder, position: Int) {
|
||||
val itemData = mItemDataList[position]
|
||||
val columnCollection = mItemDataList[position].columnCollection!!
|
||||
|
||||
// 重置曝光列表
|
||||
mItemDataList[position].exposureEventList = arrayListOf()
|
||||
|
||||
val clickClosure: (position: Int, gameEntity: GameEntity) -> Unit = { prefixedPosition, gameEntity ->
|
||||
// 类型为排行榜时点击处理不一样
|
||||
if (columnCollection.style == "top") {
|
||||
MtaHelper.onEvent("游戏专题合集", "首页合集图片", columnCollection.name)
|
||||
DirectUtils.directToColumnCollection(
|
||||
mContext, columnCollection.id
|
||||
?: "", prefixedPosition, "(首页游戏)"
|
||||
)
|
||||
} else {
|
||||
MtaHelper.onEvent("游戏专题合集", "首页合集图片", gameEntity.name)
|
||||
setPageSwitchData()
|
||||
DirectUtils.directToLinkPage(
|
||||
mContext,
|
||||
LinkEntity(link = gameEntity.link, type = gameEntity.type),
|
||||
"(首页游戏)",
|
||||
"游戏-专题"
|
||||
"游戏-专题",
|
||||
gameEntity.exposureEvent
|
||||
)
|
||||
}
|
||||
NewLogUtils.logColumnCategoryHomeContentClick(
|
||||
@ -294,7 +317,10 @@ class GameFragmentAdapter(
|
||||
)
|
||||
}
|
||||
|
||||
holder.bindColumnCollection(columnCollection, clickClosure)
|
||||
holder.bindColumnCollection(columnCollection, mBasicExposureSource, clickClosure) {
|
||||
it.payload.outerSequence = itemData.columnCollection?.outerSequence
|
||||
itemData.exposureEventList?.add(it)
|
||||
}
|
||||
|
||||
val dataList = columnCollection.data!!
|
||||
if (dataList.size == 1) {
|
||||
@ -458,7 +484,13 @@ class GameFragmentAdapter(
|
||||
DataCollectionUtils.uploadClick(mContext, subjectData?.name + "-列表", "游戏-专题", gameEntity.name)
|
||||
GameDetailActivity.startGameDetailActivity(
|
||||
mContext, gameEntity,
|
||||
StringUtils.buildString("(游戏-专题:", subjectData?.name, "-列表[", (subjectData?.position).toString(), "])"),
|
||||
StringUtils.buildString(
|
||||
"(游戏-专题:",
|
||||
subjectData?.name,
|
||||
"-列表[",
|
||||
(subjectData?.position).toString(),
|
||||
"])"
|
||||
),
|
||||
traceEvent = gameEntity.exposureEvent
|
||||
)
|
||||
}
|
||||
@ -697,10 +729,10 @@ class GameFragmentAdapter(
|
||||
val blockData = mViewModel.blockData
|
||||
val clickListener = OnViewClickListener<Int> { v, clickedPosition ->
|
||||
if (clickedPosition is Int) {
|
||||
MtaHelper.onEvent("推荐入口", blockData?.name, (clickedPosition + 1).toString())
|
||||
if (clickedPosition < subjectDigestList?.size!!) {
|
||||
|
||||
val entity = subjectDigestList[clickedPosition]
|
||||
val exposureEvent = entity.exposureEvent
|
||||
|
||||
setPageSwitchData(false)
|
||||
|
||||
@ -715,9 +747,20 @@ class GameFragmentAdapter(
|
||||
mContext,
|
||||
entity.link!!,
|
||||
-1,
|
||||
entrance
|
||||
entrance,
|
||||
"",
|
||||
exposureEvent
|
||||
)
|
||||
"block" -> mContext.startActivity(BlockActivity.getIntent(mContext, entity, entrance))
|
||||
|
||||
"block" -> mContext.startActivity(
|
||||
BlockActivity.getIntent(
|
||||
mContext,
|
||||
entity,
|
||||
exposureEvent?.source?.toArrayList(),
|
||||
entrance
|
||||
)
|
||||
)
|
||||
|
||||
"category" -> mContext.startActivity(
|
||||
CategoryDirectoryActivity.getIntent(
|
||||
mContext,
|
||||
@ -725,12 +768,14 @@ class GameFragmentAdapter(
|
||||
entity.text!!
|
||||
)
|
||||
)
|
||||
|
||||
"column" -> {
|
||||
SubjectActivity.startSubjectActivity(
|
||||
mContext,
|
||||
entity.link,
|
||||
entity.text,
|
||||
entity.order,
|
||||
exposureEvent?.source?.toArrayList(),
|
||||
StringUtils.buildString(
|
||||
"(游戏-专题:",
|
||||
entity.name,
|
||||
@ -741,15 +786,20 @@ class GameFragmentAdapter(
|
||||
)
|
||||
)
|
||||
}
|
||||
"game" -> GameDetailActivity.startGameDetailActivity(mContext, entity.link ?: "", entrance)
|
||||
|
||||
"game" -> GameDetailActivity.startGameDetailActivity(
|
||||
mContext,
|
||||
entity.link ?: "",
|
||||
entrance,
|
||||
exposureEvent
|
||||
)
|
||||
|
||||
EntranceConsts.HOST_COMMUNITY -> DirectUtils.directToCommunity(
|
||||
mContext,
|
||||
CommunityEntity(entity.link!!, entity.text!!)
|
||||
)
|
||||
|
||||
"top_game_comment" -> DirectUtils.directToAmway(mContext, null, entrance, "")
|
||||
"server" -> mContext.startActivity(GameServersActivity.getIntent(mContext, entrance, ""))
|
||||
//entity.type == "h5_game_center" -> DirectUtils.directLetoGameCenter(mContext)
|
||||
// else -> DialogUtils.showLowVersionDialog(mContext)
|
||||
"common_collection" -> {
|
||||
val linkEntity =
|
||||
LinkEntity(
|
||||
@ -761,7 +811,7 @@ class GameFragmentAdapter(
|
||||
blockId = blockData?.link ?: "",
|
||||
blockName = blockData?.name ?: ""
|
||||
)
|
||||
DirectUtils.directToLinkPage(mContext, linkEntity, "板块推荐入口", "")
|
||||
DirectUtils.directToLinkPage(mContext, linkEntity, "板块推荐入口", "", exposureEvent)
|
||||
NewLogUtils.logAccessToCommonCollectionDetail(
|
||||
entity.link ?: "",
|
||||
entity.text ?: "",
|
||||
@ -770,27 +820,29 @@ class GameFragmentAdapter(
|
||||
blockData?.name ?: ""
|
||||
)
|
||||
}
|
||||
|
||||
"game_list_square" -> {
|
||||
DirectUtils.directToGameCollectionSquare(
|
||||
mContext,
|
||||
"版块推荐入口",
|
||||
blockData?.name ?: ""
|
||||
blockData?.name ?: "",
|
||||
)
|
||||
}
|
||||
|
||||
else -> {
|
||||
val linkEntity =
|
||||
LinkEntity(
|
||||
name = entity.name,
|
||||
link = entity.link,
|
||||
text = entity.text,
|
||||
type = entity.type,
|
||||
display = entity.display
|
||||
)
|
||||
val linkEntity = LinkEntity(
|
||||
name = entity.name,
|
||||
link = entity.link,
|
||||
text = entity.text,
|
||||
type = entity.type,
|
||||
display = entity.display
|
||||
)
|
||||
DirectUtils.directToLinkPage(
|
||||
mContext,
|
||||
linkEntity,
|
||||
entrance,
|
||||
"",
|
||||
exposureEvent = exposureEvent
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -802,55 +854,53 @@ class GameFragmentAdapter(
|
||||
}
|
||||
}
|
||||
binding.run {
|
||||
if (mTopViewExposureEventList == null) {
|
||||
mTopViewExposureEventList = arrayListOf()
|
||||
mTopViewExposureEventList = arrayListOf()
|
||||
|
||||
subjectDigestList?.forEachIndexed { index, entity ->
|
||||
val event = ExposureEvent.createEventWithSourceConcat(
|
||||
gameEntity = GameEntity(
|
||||
containerId = blockData?.link ?: "",
|
||||
containerType = ExposureEntity.BLOCK_ID
|
||||
).also {
|
||||
it.sequence = index
|
||||
it.outerSequence = position
|
||||
},
|
||||
basicSource = mBasicExposureSource,
|
||||
source = listOf(
|
||||
ExposureSource(
|
||||
"推荐入口",
|
||||
if (Config.isShowPlugin()) entity.name ?: "" else entity.nameNormal ?: ""
|
||||
)
|
||||
subjectDigestList?.forEachIndexed { index, entity ->
|
||||
val event = ExposureEvent.createEventWithSourceConcat(
|
||||
gameEntity = GameEntity(
|
||||
containerId = blockData?.link ?: "",
|
||||
containerType = ExposureEntity.BLOCK_ID
|
||||
).also {
|
||||
it.sequence = index
|
||||
it.outerSequence = position
|
||||
},
|
||||
basicSource = mBasicExposureSource,
|
||||
source = listOf(
|
||||
ExposureSource(
|
||||
"推荐入口",
|
||||
if (Config.isShowPlugin()) entity.name ?: "" else entity.nameNormal ?: ""
|
||||
)
|
||||
)
|
||||
event.payload.controlType = "推荐入口"
|
||||
event.payload.controlName = if (Config.isShowPlugin()) entity.name else entity.nameNormal
|
||||
event.payload.controlLinkType = entity.type
|
||||
event.payload.controlLinkName = entity.text
|
||||
mTopViewExposureEventList?.add(event)
|
||||
}
|
||||
val slideList = mItemDataList[position].slideList
|
||||
slideList?.forEachIndexed { index, entity ->
|
||||
val event = ExposureEvent.createEventWithSourceConcat(
|
||||
gameEntity = GameEntity(
|
||||
containerId = blockData?.link ?: "",
|
||||
containerType = ExposureEntity.BLOCK_ID
|
||||
).also {
|
||||
it.sequence = index
|
||||
it.outerSequence = position
|
||||
},
|
||||
basicSource = mBasicExposureSource,
|
||||
source = listOf(ExposureSource("轮播图"))
|
||||
)
|
||||
event.payload.controlType = "轮播图"
|
||||
event.payload.controlName = entity.name
|
||||
event.payload.controlLinkType = entity.type
|
||||
event.payload.controlLinkName = entity.text
|
||||
mTopViewExposureEventList?.add(event)
|
||||
}
|
||||
mItemDataList[position].exposureEventList = mTopViewExposureEventList
|
||||
} else {
|
||||
mItemDataList[position].exposureEventList = mTopViewExposureEventList
|
||||
)
|
||||
event.payload.controlType = "推荐入口"
|
||||
event.payload.controlName = if (Config.isShowPlugin()) entity.name else entity.nameNormal
|
||||
event.payload.controlLinkType = entity.type
|
||||
event.payload.controlLinkName = entity.text
|
||||
entity.exposureEvent = event
|
||||
mTopViewExposureEventList?.add(event)
|
||||
}
|
||||
val slideList = mItemDataList[position].slideList
|
||||
slideList?.forEachIndexed { index, entity ->
|
||||
val event = ExposureEvent.createEventWithSourceConcat(
|
||||
gameEntity = GameEntity(
|
||||
containerId = blockData?.link ?: "",
|
||||
containerType = ExposureEntity.BLOCK_ID
|
||||
).also {
|
||||
it.sequence = index
|
||||
it.outerSequence = position
|
||||
},
|
||||
basicSource = mBasicExposureSource,
|
||||
source = listOf(ExposureSource("轮播图"))
|
||||
)
|
||||
event.payload.controlType = "轮播图"
|
||||
event.payload.controlName = entity.name
|
||||
event.payload.controlLinkType = entity.type
|
||||
event.payload.controlLinkName = entity.text
|
||||
mTopViewExposureEventList?.add(event)
|
||||
}
|
||||
|
||||
mItemDataList[position].exposureEventList = mTopViewExposureEventList
|
||||
|
||||
viewpagerTvFailure.goneIf(subjectDigestList != null)
|
||||
viewpagerTvFailure.setOnClickListener {
|
||||
@ -1094,12 +1144,14 @@ class GameFragmentAdapter(
|
||||
holder.binding.headPb.visibility = View.VISIBLE
|
||||
mViewModel.changeSubjectGame(column.id!!)
|
||||
}
|
||||
|
||||
"more" -> {
|
||||
setPageSwitchData()
|
||||
column.moreLink?.let { link ->
|
||||
DirectUtils.directToLinkPage(it.context, link, "(板块)", "(游戏-专题:" + column.name + "-全部)")
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
setPageSwitchData()
|
||||
when (column.type) {
|
||||
@ -1110,6 +1162,7 @@ class GameFragmentAdapter(
|
||||
buttonType, column.name ?: "", column.id ?: "", "板块", mViewModel.blockData?.name ?: ""
|
||||
)
|
||||
}
|
||||
|
||||
"common_collection" -> {
|
||||
val blockData = mViewModel.blockData
|
||||
mContext.startActivity(
|
||||
@ -1136,13 +1189,25 @@ class GameFragmentAdapter(
|
||||
blockData?.name ?: ""
|
||||
)
|
||||
}
|
||||
|
||||
"game_list_collection" -> {
|
||||
NewFlatLogUtils.logGameListCollectionClick(
|
||||
"版块内容列表",
|
||||
mViewModel.blockData?.name ?: "",
|
||||
mViewModel.blockData?.link ?: "",
|
||||
column.name ?: "",
|
||||
column.id ?: "",
|
||||
"游戏单广场"
|
||||
)
|
||||
DirectUtils.directToGameCollectionSquare(
|
||||
mContext,
|
||||
"版块内容列表",
|
||||
mViewModel.blockData?.name ?: ""
|
||||
mViewModel.blockData?.name ?: "",
|
||||
collectionName = column.name ?: "",
|
||||
collectionId = column.id ?: ""
|
||||
)
|
||||
}
|
||||
|
||||
"column_test_v2" -> {
|
||||
//跳转到新游开测页面
|
||||
val link = column.indexRightTopLink
|
||||
@ -1174,6 +1239,7 @@ class GameFragmentAdapter(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
if (column.indexRightTopLink != null) {
|
||||
val link = column.indexRightTopLink!!
|
||||
@ -1191,6 +1257,7 @@ class GameFragmentAdapter(
|
||||
column.id,
|
||||
column.getFilterName(),
|
||||
column.isOrder,
|
||||
mBasicExposureSource,
|
||||
"(游戏-专题:" + column.name + "-全部)"
|
||||
)
|
||||
}
|
||||
@ -1202,36 +1269,95 @@ class GameFragmentAdapter(
|
||||
}
|
||||
}
|
||||
|
||||
private fun bindGameCollection(holder: HomeGameCollectionViewHolder, position: Int) {
|
||||
val gameItemData = mItemDataList[position]
|
||||
val gameCollectionItemDataList = gameItemData.gameCollection ?: listOf()
|
||||
|
||||
private fun getHomeGameCollectionExposureEventList(
|
||||
itemData: GameItemData,
|
||||
refreshCurrentPosition: Int = -1
|
||||
): ArrayList<ExposureEvent> {
|
||||
val exposureList = arrayListOf<ExposureEvent>()
|
||||
for (gameCollectionItemData in gameCollectionItemDataList) {
|
||||
runOnIoThread(true) {
|
||||
val gameCollection = gameCollectionItemData.gameCollectionItem
|
||||
val gameCollectionSource =
|
||||
listOf(ExposureSource("游戏单", "${gameCollection?.title} + ${gameCollection?.id}"))
|
||||
val gameExposureList = arrayListOf<ExposureEvent>()
|
||||
gameCollection?.games?.take(3)?.forEachIndexed { index, game ->
|
||||
gameExposureList.add(
|
||||
ExposureEvent.createEventWithSourceConcat(
|
||||
gameEntity = game.toGameEntity().apply {
|
||||
isAdData = gameCollection.adIconActive
|
||||
outerSequence = gameCollectionItemData.outerSequence; sequence =
|
||||
gameCollectionItemData.gameStartPosition + index + 1
|
||||
},
|
||||
basicSource = mBasicExposureSource,
|
||||
source = gameCollectionSource
|
||||
)
|
||||
)
|
||||
runOnIoThread(true) {
|
||||
itemData.gameCollection?.gameCollectionItemDataList?.run {
|
||||
val currentIndex = if (itemData.gameCollection?.style?.contains("refresh") == true) {
|
||||
refreshCurrentPosition % size
|
||||
} else -1
|
||||
forEachIndexed { index, gameCollectionItemData ->
|
||||
if (itemData.gameCollection?.style?.contains("refresh") == false || currentIndex == index) {
|
||||
gameCollectionItemData.homeGameCollectionItem?.let {
|
||||
val gameCollectionSource =
|
||||
listOf(
|
||||
ExposureSource("游戏单合集", itemData.gameCollection?.id ?: ""),
|
||||
ExposureSource("游戏单", "${it.title} + ${it.id}")
|
||||
)
|
||||
val gameExposureList = arrayListOf<ExposureEvent>()
|
||||
it.games?.forEach { game ->
|
||||
game.isAdData = it.adIconActive
|
||||
game.outerSequence = gameCollectionItemData.outerSequence
|
||||
game.sequence = index
|
||||
|
||||
val exposureEvent = ExposureEvent.createEventWithSourceConcat(
|
||||
gameEntity = game,
|
||||
basicSource = mBasicExposureSource,
|
||||
source = gameCollectionSource
|
||||
)
|
||||
game.exposureEvent = exposureEvent
|
||||
gameExposureList.add(exposureEvent)
|
||||
}
|
||||
exposureList.addAll(gameExposureList)
|
||||
gameCollectionItemData.exposureEvent = ExposureEvent.createEventWithSourceConcat(
|
||||
gameEntity = GameEntity().apply {
|
||||
adIconActive = it.adIconActive
|
||||
outerSequence = gameCollectionItemData.outerSequence
|
||||
sequence = index
|
||||
},
|
||||
basicSource = mBasicExposureSource,
|
||||
source = gameCollectionSource
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
gameCollectionItemData.exposureEventList = gameExposureList
|
||||
exposureList.addAll(gameExposureList)
|
||||
}
|
||||
}
|
||||
gameItemData.exposureEventList = exposureList
|
||||
holder.bindGameCollectionList(gameCollectionItemDataList, "版块内容列表")
|
||||
return exposureList
|
||||
}
|
||||
|
||||
private fun bindGameCollectionCarousel(holder: HomeGameCollectionCarouselViewHolder, position: Int) {
|
||||
val gameItemData = mItemDataList[position]
|
||||
gameItemData.exposureEventList = getHomeGameCollectionExposureEventList(gameItemData)
|
||||
gameItemData.gameCollection?.let {
|
||||
holder.bindGameCollectionList(
|
||||
it,
|
||||
"版块内容列表",
|
||||
mViewModel.blockData?.link ?: "",
|
||||
mViewModel.blockData?.name ?: ""
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun bindGameCollectionSlide(holder: HomeGameCollectionSlideViewHolder, position: Int) {
|
||||
val gameItemData = mItemDataList[position]
|
||||
gameItemData.exposureEventList = getHomeGameCollectionExposureEventList(gameItemData)
|
||||
gameItemData.gameCollection?.let {
|
||||
holder.bindGameCollectionSlide(
|
||||
it,
|
||||
"版块内容列表",
|
||||
mViewModel.blockData?.link ?: "",
|
||||
mViewModel.blockData?.name ?: ""
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun bindGameCollectionRefresh(holder: HomeGameCollectionRefreshViewHolder, position: Int) {
|
||||
val gameItemData = mItemDataList[position]
|
||||
gameItemData.exposureEventList = getHomeGameCollectionExposureEventList(gameItemData, holder.currentPosition)
|
||||
gameItemData.gameCollection?.let {
|
||||
holder.bindGameCollectionRefresh(
|
||||
it,
|
||||
"版块内容列表",
|
||||
mViewModel.blockData?.link ?: "",
|
||||
mViewModel.blockData?.name ?: ""
|
||||
) {
|
||||
mViewModel.changeGameCollectionRefresh(it.id, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun bindGameDoubleCard(holder: DoubleCardViewHolder, position: Int) {
|
||||
@ -1359,6 +1485,8 @@ class GameFragmentAdapter(
|
||||
|| getItemViewType(gameAndPosition.position) == ItemViewType.DISCOVER_CARD
|
||||
|| getItemViewType(gameAndPosition.position) == ItemViewType.COLUMN_TEST_V2
|
||||
|| getItemViewType(gameAndPosition.position) == ItemViewType.HORIZONTAL_SLIDE_VIDEO
|
||||
|| getItemViewType(gameAndPosition.position) == ItemViewType.GAME_COLLECTION_BIG_SLIDE
|
||||
|| getItemViewType(gameAndPosition.position) == ItemViewType.GAME_COLLECTION_VERTICAL_REFRESH
|
||||
) {
|
||||
val view = mLayoutManager?.findViewByPosition(gameAndPosition.position)
|
||||
val recyclerView = view?.findViewById<RecyclerView>(R.id.recycler_view)
|
||||
@ -1368,6 +1496,8 @@ class GameFragmentAdapter(
|
||||
is DiscoverCardGameAdapter -> adapter.notifyItemByDownload(download)
|
||||
is HomeGameTestV2GameListRvAdapter -> adapter.notifyItemByDownload(download)
|
||||
is HomeHorizontalSlideVideoAdapter -> adapter.notifyItemByDownload(download)
|
||||
is HomeGameCollectionSlideAdapter -> adapter.notifyItemByDownload(download)
|
||||
is HomeGameCollectionRefreshAdapter -> adapter.notifyItemByDownload(download)
|
||||
}
|
||||
} else {
|
||||
notifyItemChanged(gameAndPosition.position)
|
||||
@ -1492,6 +1622,20 @@ class GameFragmentAdapter(
|
||||
continue
|
||||
}
|
||||
|
||||
val gameListCollection = mItemDataList[position].gameCollection
|
||||
if (gameListCollection != null) {
|
||||
gameListCollection.gameCollectionItemDataList.forEach { gameCollectionItemData ->
|
||||
gameCollectionItemData.homeGameCollectionItem?.games?.forEach {
|
||||
for (apkEntity in it.getApk()) {
|
||||
if (apkEntity.packageName == packageName) {
|
||||
positionList.add(GameAndPosition(it, position))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
val image = mItemDataList[position].image
|
||||
if (image != null) positionList.add(GameAndPosition(image, position))
|
||||
}
|
||||
|
||||
@ -31,6 +31,7 @@ import com.gh.gamecenter.game.data.GameItemData
|
||||
import com.gh.gamecenter.game.rank.RankCollectionAdapter
|
||||
import com.gh.gamecenter.gamecollection.square.GameCollectionListItemData
|
||||
import com.gh.gamecenter.home.BlankDividerViewHolder
|
||||
import com.gh.gamecenter.home.LegacyHomeFragmentAdapterAssistant
|
||||
import com.gh.gamecenter.home.test_v2.HomeGameTestV2DownloadStateUpdateHelper
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
@ -56,6 +57,8 @@ class GameViewModel(application: Application, var blockData: SubjectRecommendEnt
|
||||
private val mItemDataListCache: MutableList<GameItemData> = ArrayList()
|
||||
private val mSubjectChangedMap: ArrayMap<String, List<GameEntity>> = ArrayMap() // 存储换一换的数据
|
||||
private val mSubjectRefreshMap: ArrayMap<String, MutableList<GameEntity>> = ArrayMap() // 存储专题刷新数据
|
||||
private val mRefreshGameCollectionMap: ArrayMap<String, List<HomeGameCollectionEntity>> = ArrayMap() // 存储刷新轮换游戏单的数据
|
||||
private val mRefreshGameCollectionPageMap: ArrayMap<String, Int> = ArrayMap() // 存储刷新轮换游戏单的次数
|
||||
private var mSmartSubject: SubjectEntity? = null // 猜你喜欢专题
|
||||
private var mDiscoveryGameCard: DiscoveryGameCardEntity? = null
|
||||
private var mDiscoveryGameCardLabels: List<DiscoveryGameCardLabel>? = null
|
||||
@ -595,6 +598,53 @@ class GameViewModel(application: Application, var blockData: SubjectRecommendEnt
|
||||
}
|
||||
}
|
||||
|
||||
fun changeGameCollectionRefresh(collectionId: String, isRefreshClick: Boolean): Boolean {
|
||||
val page = (mRefreshGameCollectionPageMap[collectionId] ?: 1) + 1
|
||||
return if (page != 0) {
|
||||
getGameCollectionRefresh(collectionId, page, isRefreshClick)
|
||||
true // 表示需要从接口获取数据
|
||||
} else {
|
||||
false // 表示已加载完毕
|
||||
}
|
||||
}
|
||||
|
||||
private fun getGameCollectionRefresh(collectionId: String, page: Int, isRefreshClick: Boolean) {
|
||||
mSensitiveApi.getGameCollectionRefresh(collectionId, "block", page, 1)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<List<HomeGameCollectionEntity>>() {
|
||||
override fun onResponse(response: List<HomeGameCollectionEntity>?) {
|
||||
if (response != null) {
|
||||
if (response.isNotEmpty()) {
|
||||
mRefreshGameCollectionPageMap[collectionId] = page
|
||||
mRefreshGameCollectionMap[collectionId] = mRefreshGameCollectionMap[collectionId]?.let {
|
||||
ArrayList(it).apply {
|
||||
addAll(response)
|
||||
}
|
||||
}
|
||||
|
||||
// 手动点击刷新获取时,若游戏单内游戏被全部屏蔽会自动获取下一个游戏单
|
||||
if (isRefreshClick) {
|
||||
val filterGameList = RegionSettingHelper.filterGame(response[0].games)
|
||||
if (filterGameList.isEmpty()) {
|
||||
changeGameCollectionRefresh(collectionId, true)
|
||||
return
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// -1 表示加载完毕
|
||||
mRefreshGameCollectionPageMap[collectionId] = -1
|
||||
}
|
||||
transformationItemData()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailure(e: HttpException?) {
|
||||
Utils.toast(getApplication(), "网络异常")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun transformationItemData() {
|
||||
mItemDataListCache.clear()
|
||||
positionAndPackageMap.clear()
|
||||
@ -666,6 +716,7 @@ class GameViewModel(application: Application, var blockData: SubjectRecommendEnt
|
||||
if (!(!isTopItemShown && index == 0)
|
||||
&& !shouldShowDivider
|
||||
&& !hideSubjectName
|
||||
&& !(subjectEntity.type == "game_list_collection" && subjectEntity.style == LegacyHomeFragmentAdapterAssistant.GAME_COLLECTION_VERTICAL_REFRESH_STYLE)
|
||||
) {
|
||||
mItemDataListCache.add(getBlankSpacingItem())
|
||||
}
|
||||
@ -724,7 +775,8 @@ class GameViewModel(application: Application, var blockData: SubjectRecommendEnt
|
||||
&& subjectEntity.type != "news"
|
||||
&& subjectEntity.type != "game"
|
||||
&& subjectEntity.type != "video"
|
||||
&& subjectEntity.type != "game_explore")
|
||||
&& subjectEntity.type != "game_explore"
|
||||
&& subjectEntity.type != "game_list_collection")
|
||||
|| (subjectEntity.type == "column_collection" && subjectEntity.style != "top")
|
||||
) {
|
||||
val itemDataHead = GameItemData()
|
||||
@ -954,24 +1006,63 @@ class GameViewModel(application: Application, var blockData: SubjectRecommendEnt
|
||||
val gameCollectionItem = GameItemData()
|
||||
val itemDataList = arrayListOf<GameCollectionListItemData>().apply {
|
||||
if (!subjectEntity.gameListCollection.isNullOrEmpty()) {
|
||||
var position = 0
|
||||
if (subjectEntity.style?.contains("refresh") == true) {
|
||||
if (mRefreshGameCollectionMap[subjectEntity.id] == null) {
|
||||
mRefreshGameCollectionMap[subjectEntity.id] = subjectEntity.gameListCollection
|
||||
mRefreshGameCollectionPageMap[subjectEntity.id] = 1
|
||||
} else {
|
||||
subjectEntity.gameListCollection = mRefreshGameCollectionMap[subjectEntity.id]
|
||||
}
|
||||
}
|
||||
for (item in subjectEntity.gameListCollection!!) {
|
||||
item.games = RegionSettingHelper.filterSimpleGame(item.games)
|
||||
add(
|
||||
GameCollectionListItemData(
|
||||
gameCollectionItem = item,
|
||||
gameStartPosition = position,
|
||||
outerSequence = subjectEntity.outerSequence + 1
|
||||
item.games = RegionSettingHelper.filterGame(item.games)
|
||||
if (!item.games.isNullOrEmpty() || subjectEntity.style == LegacyHomeFragmentAdapterAssistant.GAME_COLLECTION_CAROUSEL_STYLE || subjectEntity.style == LegacyHomeFragmentAdapterAssistant.GAME_COLLECTION_SMALL_SLIDE_STYLE) {
|
||||
add(
|
||||
GameCollectionListItemData(
|
||||
homeGameCollectionItem = item,
|
||||
outerSequence = index
|
||||
)
|
||||
)
|
||||
)
|
||||
position += if (item.count?.game!! > 2) 3 else if (item.games?.size == 0) 0 else
|
||||
item.count?.game ?: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (itemDataList.isEmpty()) {
|
||||
if (subjectEntity.style?.contains("refresh") == true) {
|
||||
subjectEntity.id?.let { changeGameCollectionRefresh(it, false) }
|
||||
return
|
||||
}
|
||||
continue
|
||||
}
|
||||
// 轮播图样式需要至少3个游戏单
|
||||
if ((subjectEntity.style == LegacyHomeFragmentAdapterAssistant.GAME_COLLECTION_CAROUSEL_STYLE && itemDataList.size >= 3) || subjectEntity.style != LegacyHomeFragmentAdapterAssistant.GAME_COLLECTION_CAROUSEL_STYLE) {
|
||||
if (subjectEntity.style?.contains("refresh") == false) {
|
||||
val head = GameItemData()
|
||||
head.columnHead =
|
||||
SubjectEntity(
|
||||
id = subjectEntity.id,
|
||||
type = subjectEntity.type,
|
||||
name = subjectEntity.name,
|
||||
adIconActive = subjectEntity.adIconActive,
|
||||
style = subjectEntity.style
|
||||
)
|
||||
mItemDataListCache.add(head)
|
||||
}
|
||||
gameCollectionItem.gameCollection = GameListCollection(
|
||||
id = subjectEntity.id ?: "",
|
||||
name = subjectEntity.name ?: "",
|
||||
style = subjectEntity.style ?: "",
|
||||
gameCollectionItemDataList = itemDataList
|
||||
)
|
||||
mItemDataListCache.add(gameCollectionItem)
|
||||
if (subjectEntity.style == LegacyHomeFragmentAdapterAssistant.GAME_COLLECTION_BIG_SLIDE_STYLE || subjectEntity.style == LegacyHomeFragmentAdapterAssistant.GAME_COLLECTION_VERTICAL_REFRESH_STYLE) {
|
||||
gameCollectionItem.gameCollection?.gameCollectionItemDataList?.forEach {
|
||||
it.homeGameCollectionItem?.games?.forEach { game ->
|
||||
addGamePositionAndPackage(game)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
gameCollectionItem.gameCollection = itemDataList
|
||||
appendAdditionalInfoToSubjectGame(subjectEntity, index)
|
||||
mItemDataListCache.add(gameCollectionItem)
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@ -9,12 +9,16 @@ import com.gh.gamecenter.common.view.WrapContentDraweeView
|
||||
import com.gh.gamecenter.databinding.GameColumnCollectionItemBinding
|
||||
import com.gh.gamecenter.entity.SubjectEntity
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.gh.gamecenter.feature.exposure.ExposureSource
|
||||
import com.lightgame.adapter.BaseRecyclerAdapter
|
||||
|
||||
class GameColumnCollectionAdapter(
|
||||
context: Context,
|
||||
private var mSubjectEntity: SubjectEntity,
|
||||
private var mClickClosure: (position: Int, gameEntity: GameEntity) -> Unit
|
||||
private var mBasicExposureSourceList: ArrayList<ExposureSource>,
|
||||
private var mClickClosure: (position: Int, gameEntity: GameEntity) -> Unit,
|
||||
private var mExposureClosure: (exposureEvent: ExposureEvent) -> Unit
|
||||
) : BaseRecyclerAdapter<GameColumnCollectionItemViewHolder>(context) {
|
||||
|
||||
private var mCountAndKey: Pair<Int, String>? = null
|
||||
@ -55,6 +59,17 @@ class GameColumnCollectionAdapter(
|
||||
}
|
||||
})
|
||||
|
||||
val exposureEvent = ExposureEvent.createEventWithSourceConcat(
|
||||
data,
|
||||
mBasicExposureSourceList,
|
||||
arrayListOf(ExposureSource("游戏专题合集","${mSubjectEntity.name}+${mSubjectEntity.id}"))
|
||||
).apply {
|
||||
payload.sequence = position
|
||||
}
|
||||
|
||||
data.exposureEvent = exposureEvent
|
||||
mExposureClosure.invoke(exposureEvent)
|
||||
|
||||
holder.binding.columnCollectionImage.setOnClickListener {
|
||||
mClickClosure(position, data)
|
||||
}
|
||||
|
||||
@ -10,13 +10,17 @@ import com.gh.gamecenter.common.view.SpacingItemDecoration
|
||||
import com.gh.gamecenter.databinding.GameColumnCollectionListBinding
|
||||
import com.gh.gamecenter.entity.SubjectEntity
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.gh.gamecenter.feature.exposure.ExposureSource
|
||||
|
||||
class GameColumnCollectionViewHolder(val binding: GameColumnCollectionListBinding) :
|
||||
BaseRecyclerViewHolder<Any>(binding.root) {
|
||||
|
||||
fun bindColumnCollection(
|
||||
columnCollection: SubjectEntity,
|
||||
clickClosure: (position: Int, gameEntity: GameEntity) -> Unit
|
||||
basicExposureList: ArrayList<ExposureSource>,
|
||||
clickClosure: (position: Int, gameEntity: GameEntity) -> Unit,
|
||||
exposureClosure: (exposureEvent: ExposureEvent) -> Unit
|
||||
) {
|
||||
val context = binding.root.context
|
||||
val dataList = columnCollection.data!!
|
||||
@ -32,7 +36,7 @@ class GameColumnCollectionViewHolder(val binding: GameColumnCollectionListBindin
|
||||
binding.columnCollectionList.visibility = View.VISIBLE
|
||||
var slideAdapter = binding.columnCollectionList.adapter
|
||||
if (slideAdapter == null) {
|
||||
slideAdapter = GameColumnCollectionAdapter(context, columnCollection, clickClosure)
|
||||
slideAdapter = GameColumnCollectionAdapter(context, columnCollection, basicExposureList, clickClosure, exposureClosure)
|
||||
binding.columnCollectionList.layoutManager =
|
||||
LinearLayoutManager(context, RecyclerView.HORIZONTAL, false)
|
||||
binding.columnCollectionList.addItemDecoration(
|
||||
|
||||
@ -1,14 +1,15 @@
|
||||
package com.gh.gamecenter.game.columncollection.detail
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.gh.gamecenter.common.base.activity.ToolBarActivity
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.catalog.CatalogActivity
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.utils.updateStatusBarColor
|
||||
|
||||
/**
|
||||
* 游戏专题合集详情页
|
||||
*/
|
||||
class ColumnCollectionDetailActivity : ToolBarActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@ -40,29 +41,4 @@ class ColumnCollectionDetailActivity : ToolBarActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* [position] 当专题合集是排行榜(多专题)类型时的起始位置
|
||||
*/
|
||||
fun getIntent(
|
||||
context: Context,
|
||||
collectionId: String,
|
||||
position: Int = -1,
|
||||
entrance: String = "",
|
||||
columnName: String = ""
|
||||
): Intent {
|
||||
val bundle = Bundle()
|
||||
bundle.putString(EntranceConsts.KEY_ENTRANCE, entrance)
|
||||
bundle.putString(EntranceConsts.KEY_COLLECTION_ID, collectionId)
|
||||
bundle.putInt(EntranceConsts.KEY_POSITION, position)
|
||||
bundle.putString(EntranceConsts.KEY_COLUMNNAME, columnName)
|
||||
return getTargetIntent(
|
||||
context,
|
||||
CatalogActivity::class.java,
|
||||
ColumnCollectionDetailFragment::class.java,
|
||||
bundle
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,10 +1,12 @@
|
||||
package com.gh.gamecenter.game.columncollection.detail
|
||||
|
||||
import android.content.Context
|
||||
import android.util.SparseArray
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
||||
import com.gh.common.exposure.IExposable
|
||||
import com.gh.gamecenter.common.constant.ItemViewType
|
||||
import com.gh.common.util.DirectUtils
|
||||
import com.gh.common.util.NewLogUtils
|
||||
@ -17,12 +19,18 @@ import com.gh.gamecenter.adapter.viewholder.GameColumnCollectionItemViewHolder
|
||||
import com.gh.gamecenter.common.baselist.ListAdapter
|
||||
import com.gh.gamecenter.databinding.GameColumnCollectionItemBinding
|
||||
import com.gh.gamecenter.common.entity.LinkEntity
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.gh.gamecenter.feature.exposure.ExposureSource
|
||||
|
||||
class ColumnCollectionDetailAdapter(
|
||||
context: Context,
|
||||
private val mViewModel: ColumnCollectionDetailViewModel,
|
||||
private var mTabIndex: Int,
|
||||
private val mBasicExposureSourceList: ArrayList<ExposureSource>?,
|
||||
private val mEntrance: String,
|
||||
) : ListAdapter<LinkEntity>(context) {
|
||||
) : ListAdapter<LinkEntity>(context), IExposable {
|
||||
|
||||
private var mExposureSparseArray = SparseArray<ExposureEvent>()
|
||||
|
||||
override fun areItemsTheSame(oldItem: LinkEntity?, newItem: LinkEntity?): Boolean {
|
||||
return oldItem == newItem
|
||||
@ -66,12 +74,21 @@ class ColumnCollectionDetailAdapter(
|
||||
Pair(PageSwitchDataHelper.PAGE_BUSINESS_NAME, mViewModel.columnCollection.value?.name ?: "")
|
||||
)
|
||||
)
|
||||
DirectUtils.directToLinkPage(mContext, data, mEntrance, "专题合集")
|
||||
DirectUtils.directToLinkPage(mContext, data, mEntrance, "专题合集", mExposureSparseArray.get(position))
|
||||
NewLogUtils.logColumnCategoryDetailContentClick(
|
||||
data.name ?: "", data?.link ?: "",
|
||||
mViewModel.columnCollection.value?.name ?: "", mViewModel.collectionId
|
||||
)
|
||||
}
|
||||
val exposureEvent = ExposureEvent.createEventWithSourceConcat(
|
||||
null,
|
||||
mBasicExposureSourceList ?: arrayListOf(),
|
||||
arrayListOf(ExposureSource("游戏专题合集", "${mViewModel.getGameColumnCollectionName()}+${mViewModel.collectionId}"))
|
||||
).apply {
|
||||
payload.outerSequence = mTabIndex
|
||||
payload.sequence = position
|
||||
}
|
||||
mExposureSparseArray.put(position, exposureEvent)
|
||||
} else if (holder is FooterViewHolder) {
|
||||
holder.initFooterViewHolder(mViewModel, mIsLoading, mIsNetworkError, mIsOver)
|
||||
if (holder.itemView.layoutParams is StaggeredGridLayoutManager.LayoutParams) {
|
||||
@ -79,4 +96,10 @@ class ColumnCollectionDetailAdapter(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getEventByPosition(pos: Int): ExposureEvent? {
|
||||
return mExposureSparseArray.get(pos)
|
||||
}
|
||||
|
||||
override fun getEventListByPosition(pos: Int) = null
|
||||
}
|
||||
@ -1,9 +1,11 @@
|
||||
package com.gh.gamecenter.game.columncollection.detail
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.lifecycle.ViewModelProviders
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
||||
import com.ethanhua.skeleton.Skeleton
|
||||
import com.gh.common.exposure.ExposureListener
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.utils.dip2px
|
||||
@ -15,6 +17,7 @@ import com.gh.gamecenter.common.baselist.LazyListFragment
|
||||
import com.gh.gamecenter.databinding.FragmentColumnCollectionDetailBinding
|
||||
import com.gh.gamecenter.common.entity.LinkEntity
|
||||
import com.gh.gamecenter.entity.SubjectData
|
||||
import com.gh.gamecenter.feature.exposure.ExposureSource
|
||||
import com.gh.gamecenter.subject.tab.SubjectTabFragment
|
||||
|
||||
class ColumnCollectionDetailFragment : LazyListFragment<LinkEntity, ColumnCollectionDetailViewModel>() {
|
||||
@ -22,6 +25,11 @@ class ColumnCollectionDetailFragment : LazyListFragment<LinkEntity, ColumnCollec
|
||||
private var mAdapter: ColumnCollectionDetailAdapter? = null
|
||||
private var mBinding: FragmentColumnCollectionDetailBinding? = null
|
||||
|
||||
private var mExposureListener: ExposureListener? = null
|
||||
|
||||
private var mTabIndex = -1
|
||||
private var mBasicExposureSourceList : ArrayList<ExposureSource>? = null
|
||||
|
||||
override fun getItemDecoration() = null
|
||||
|
||||
override fun getRealLayoutId() = R.layout.fragment_column_collection_detail
|
||||
@ -31,6 +39,13 @@ class ColumnCollectionDetailFragment : LazyListFragment<LinkEntity, ColumnCollec
|
||||
mBinding = FragmentColumnCollectionDetailBinding.bind(inflatedView)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
mTabIndex = arguments?.getInt(EntranceConsts.KEY_TAB_INDEX) ?: -1
|
||||
mBasicExposureSourceList = arguments?.getParcelableArrayList(EntranceConsts.KEY_EXPOSURE_SOURCE_LIST)
|
||||
}
|
||||
|
||||
override fun onFragmentFirstVisible() {
|
||||
super.onFragmentFirstVisible()
|
||||
|
||||
@ -57,8 +72,12 @@ class ColumnCollectionDetailFragment : LazyListFragment<LinkEntity, ColumnCollec
|
||||
val gridLayoutManager =
|
||||
StaggeredGridLayoutManager(mListViewModel.rowCount(), StaggeredGridLayoutManager.VERTICAL)
|
||||
gridLayoutManager.gapStrategy = StaggeredGridLayoutManager.GAP_HANDLING_NONE
|
||||
|
||||
mExposureListener = ExposureListener(this, provideListAdapter())
|
||||
|
||||
mListRv.clipToPadding = false
|
||||
mListRv.layoutManager = gridLayoutManager
|
||||
mListRv.addOnScrollListener(mExposureListener!!)
|
||||
if (mListViewModel.rowCount() == 1) {
|
||||
mListRv.setPadding(16F.dip2px(), 0, 16F.dip2px(), 0)
|
||||
mListRv.addItemDecoration(GridSpacingItemDecoration(mListViewModel.rowCount(), 16F.dip2px(), false))
|
||||
@ -113,7 +132,7 @@ class ColumnCollectionDetailFragment : LazyListFragment<LinkEntity, ColumnCollec
|
||||
|
||||
override fun provideListAdapter(): ColumnCollectionDetailAdapter {
|
||||
if (mAdapter == null) {
|
||||
mAdapter = ColumnCollectionDetailAdapter(requireContext(), mListViewModel, mEntrance)
|
||||
mAdapter = ColumnCollectionDetailAdapter(requireContext(), mListViewModel, mTabIndex, mBasicExposureSourceList, mEntrance)
|
||||
}
|
||||
return mAdapter!!
|
||||
}
|
||||
|
||||
@ -25,6 +25,7 @@ class ColumnCollectionDetailViewModel(
|
||||
) : ListViewModel<LinkEntity, LinkEntity>(application) {
|
||||
|
||||
private val mSensitiveApi = RetrofitManager.getInstance().api
|
||||
private var mCollectionName = ""
|
||||
|
||||
val collectionId: String
|
||||
get() = mCollectionId
|
||||
@ -41,6 +42,10 @@ class ColumnCollectionDetailViewModel(
|
||||
mResultLiveData.addSource(mListLiveData) { mResultLiveData.postValue(it) }
|
||||
}
|
||||
|
||||
fun getGameColumnCollectionName(): String {
|
||||
return mCollectionName
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
fun getGameColumnCollection() {
|
||||
mSensitiveApi.getGameColumnCollection(mCollectionId)
|
||||
@ -50,6 +55,7 @@ class ColumnCollectionDetailViewModel(
|
||||
override fun onResponse(response: GameColumnCollection?) {
|
||||
super.onResponse(response)
|
||||
columnCollection.postValue(response)
|
||||
mCollectionName = response?.name ?: ""
|
||||
loadData()
|
||||
}
|
||||
|
||||
|
||||
@ -15,10 +15,19 @@ import com.lightgame.adapter.BaseRecyclerAdapter
|
||||
class CommonCollectionAdapter(
|
||||
context: Context,
|
||||
private var mSubjectEntity: SubjectEntity,
|
||||
private var mClickClosure: (position: Int, contentEntity: CommonCollectionContentEntity) -> Unit,
|
||||
private var mExposureClosure: (position: Int, entity: ExposureLinkEntity) -> Unit
|
||||
) : BaseRecyclerAdapter<CommonCollectionItemViewHolder>(context) {
|
||||
|
||||
private var mExposureClosure: ((position: Int, entity: ExposureLinkEntity) -> Unit)? = null
|
||||
private var mClickClosure: ((position: Int, contentEntity: CommonCollectionContentEntity) -> Unit)? = null
|
||||
|
||||
fun setCallback(
|
||||
clickClosure: ((position: Int, contentEntity: CommonCollectionContentEntity) -> Unit),
|
||||
exposureClosure: ((position: Int, entity: ExposureLinkEntity) -> Unit)
|
||||
) {
|
||||
mClickClosure = clickClosure
|
||||
mExposureClosure = exposureClosure
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CommonCollectionItemViewHolder {
|
||||
return CommonCollectionItemViewHolder(parent.toBinding())
|
||||
}
|
||||
@ -45,7 +54,7 @@ class CommonCollectionAdapter(
|
||||
}
|
||||
|
||||
if (linkEntity.type == "game") {
|
||||
mExposureClosure.invoke(position, linkEntity)
|
||||
mExposureClosure?.invoke(position, linkEntity)
|
||||
}
|
||||
|
||||
holder.binding.apply {
|
||||
@ -81,7 +90,7 @@ class CommonCollectionAdapter(
|
||||
rootParams.rightMargin = if (position == itemCount - 1) 16F.dip2px() else 0
|
||||
root.layoutParams = rootParams
|
||||
|
||||
root.setOnClickListener { mClickClosure.invoke(position, contentEntity) }
|
||||
root.setOnClickListener { mClickClosure?.invoke(position, contentEntity) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -55,15 +55,20 @@ class CommonCollectionViewHolder(val binding: CommonCollectionListBinding) : Bas
|
||||
}
|
||||
}
|
||||
})
|
||||
adapter = CommonCollectionAdapter(context, mCollection!!, clickClosure, exposureClosure)
|
||||
adapter = CommonCollectionAdapter(context, mCollection!!).also {
|
||||
it.setCallback(clickClosure, exposureClosure)
|
||||
}
|
||||
} else {
|
||||
mLayoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
|
||||
if (itemDecorationCount > 0) {
|
||||
removeItemDecorationAt(0)
|
||||
}
|
||||
addItemDecoration(SpacingItemDecoration(notDecorateTheFirstItem = true, left = 8f.dip2px()))
|
||||
addItemDecoration(SpacingItemDecoration(notDecorateTheFirstItem = true, left = 8F.dip2px()))
|
||||
layoutManager = mLayoutManager
|
||||
(adapter as CommonCollectionAdapter).checkResetData(mCollection!!)
|
||||
(adapter as CommonCollectionAdapter).apply {
|
||||
setCallback(clickClosure, exposureClosure)
|
||||
checkResetData(mCollection!!)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,6 +28,7 @@ class CommonCollectionDetailAdapter(
|
||||
val mViewModel: CommonCollectionDetailViewModel,
|
||||
val mBlockId: String,
|
||||
val mBlockName: String,
|
||||
val mTabIndex: Int,
|
||||
val mEntrance: String,
|
||||
private val mBasicExposureSource: List<ExposureSource>?
|
||||
) : ListAdapter<CommonCollectionContentEntity>(context), IExposable {
|
||||
@ -70,7 +71,13 @@ class CommonCollectionDetailAdapter(
|
||||
val linkEntity = mEntityList[position].linkEntity
|
||||
|
||||
val listener: (v: View) -> Unit = {
|
||||
DirectUtils.directToLinkPage(mContext, linkEntity, "通用链接合集详情", "")
|
||||
DirectUtils.directToLinkPage(
|
||||
mContext,
|
||||
linkEntity,
|
||||
"通用链接合集详情",
|
||||
"",
|
||||
mExposureEventSparseArray.get(position)
|
||||
)
|
||||
val commonLinkCollection = mViewModel.commonCollectionLiveData.value
|
||||
NewLogUtils.logCommonCollectionClick(
|
||||
commonLinkCollection?.id ?: "",
|
||||
@ -110,11 +117,13 @@ class CommonCollectionDetailAdapter(
|
||||
listOf(
|
||||
ExposureSource(
|
||||
"内容合集",
|
||||
mViewModel.commonCollectionLiveData.value?.name ?: ""
|
||||
"${mViewModel.commonCollectionLiveData.value?.name}+${mViewModel.commonCollectionLiveData.value?.id}"
|
||||
),
|
||||
ExposureSource("合集详情")
|
||||
),
|
||||
)
|
||||
).apply {
|
||||
this.payload.outerSequence = mTabIndex
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -32,6 +32,7 @@ class CommonCollectionDetailFragment : LazyListFragment<LinkEntity, CommonCollec
|
||||
private lateinit var mBinding: FragmentListBaseSkeletonBinding
|
||||
private var mBlockId = ""
|
||||
private var mBlockName = ""
|
||||
private var mTabIndexValue = 0 // 在首页的 tab 位置
|
||||
|
||||
override fun getRealLayoutId(): Int = R.layout.fragment_list_base_skeleton
|
||||
|
||||
@ -39,6 +40,7 @@ class CommonCollectionDetailFragment : LazyListFragment<LinkEntity, CommonCollec
|
||||
super.onCreate(savedInstanceState)
|
||||
mBlockId = requireArguments().getString(EntranceConsts.KEY_BLOCK_ID, "")
|
||||
mBlockName = requireArguments().getString(EntranceConsts.KEY_BLOCK_NAME, "")
|
||||
mTabIndexValue = requireArguments().getInt(EntranceConsts.KEY_TAB_INDEX, -1)
|
||||
}
|
||||
|
||||
override fun onRealLayoutInflated(inflatedView: View) {
|
||||
@ -56,6 +58,7 @@ class CommonCollectionDetailFragment : LazyListFragment<LinkEntity, CommonCollec
|
||||
mViewModel,
|
||||
mBlockId,
|
||||
mBlockName,
|
||||
mTabIndexValue,
|
||||
mEntrance,
|
||||
exposureEvent
|
||||
)
|
||||
|
||||
@ -28,7 +28,7 @@ class GameItemData : ExposureItemData {
|
||||
|
||||
var rankCollection: SubjectEntity? = null
|
||||
|
||||
var gameCollection: List<GameCollectionListItemData>? = null
|
||||
var gameCollection: GameListCollection? = null
|
||||
|
||||
var doubleCardColumn: SubjectEntity? = null // 双列卡片专题
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user