Compare commits

..

16 Commits

Author SHA1 Message Date
8c0773aab2 fix:模拟器下载流程修复20221027测试反馈 https://git.shanqu.cc/pm/halo/halo-app-issues/-/issues/2125 2022-10-28 14:35:36 +08:00
e596de766a Merge remote-tracking branch 'origin/dev' into feature-issues2125 2022-10-27 14:36:36 +08:00
12c3605db8 fix:规范修改 2022-10-27 11:44:37 +08:00
4201d0abd3 fix:规范修改 2022-10-27 11:30:40 +08:00
3a0daea1fb fix:修改 2022-10-27 11:18:22 +08:00
17e4923c98 fix修改私有变量命名规范 2022-10-27 10:39:37 +08:00
1a2c90cfb0 fix:合并冲突 2022-10-27 10:37:46 +08:00
06c084a1ec feat:模拟器游戏埋点 2022-10-26 16:29:53 +08:00
930fc88183 merge 2022-10-26 11:30:14 +08:00
e8dec7d101 Merge remote-tracking branch 'origin/dev' into feature-issues2125 2022-10-26 11:20:46 +08:00
28fcd20186 fix:模拟器下载流程修改 2022-10-26 11:06:20 +08:00
d8483686d2 Merge remote-tracking branch 'origin/dev' into feature-issues2125
# Conflicts:
#	app/src/main/java/com/gh/common/util/NewFlatLogUtils.kt
2022-10-25 17:40:55 +08:00
cb67b4f01e Merge branch 'dev' into 'feature-issues2125'
# Conflicts:
#   app/src/main/java/com/gh/common/util/NewFlatLogUtils.kt
2022-10-25 09:31:16 +00:00
236ecb9f4f fix:解决冲突 2022-10-25 17:26:46 +08:00
877335f47b fix:解决冲突 2022-10-25 17:21:07 +08:00
676b81b649 feat: 模拟器下载流程调整 https://git.shanqu.cc/pm/halo/halo-app-issues/-/issues/2125 2022-10-25 17:03:41 +08:00
857 changed files with 10566 additions and 19650 deletions

3
.gitmodules vendored
View File

@ -8,6 +8,3 @@
[submodule "module_common/src/debug/assets/assistant-android-mock"]
path = module_common/src/debug/assets/assistant-android-mock
url = git@git.shanqu.cc:halo/android/assistant-android-mock.git
[submodule "ndownload"]
path = ndownload
url = git@git.shanqu.cc:android/ndownload.git

View File

@ -260,7 +260,6 @@ dependencies {
compileOnly "com.github.axen1314.lancet:lancet-base:${lancet_version}"
kapt "com.alibaba:arouter-compiler:$arouterVersion"
implementation project(':ndownload')
implementation project(':vspace-bridge:vspace')
implementation (project(':module_common')) {
@ -269,9 +268,6 @@ dependencies {
implementation(project(':module_login')) {
exclude group: 'androidx.swiperefreshlayout'
}
implementation(project(':module_setting')) {
exclude group: 'androidx.swiperefreshlayout'
}
// 默认不接入光能模块,提高编译速度
// debugImplementation(project(':module_energy')) {
// exclude group: 'androidx.swiperefreshlayout'
@ -395,6 +391,7 @@ andResGuard {
"R.drawable.suggest_type_function_suggest",
"R.drawable.suggest_type_article_collect",
"R.drawable.suggest_type_copyright",
"R.drawable.help_result_empty",
"R.drawable.news_comment_detail_read",
"R.drawable.news_comment_detail_comment",
"R.drawable.news_comment_detail_share",

View File

@ -1,16 +1,14 @@
package com.gh.gamecenter.provider
import android.app.Activity
import android.app.Application
import android.text.TextUtils
import com.gh.gamecenter.common.constant.Config
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.utils.PackageFlavorHelper
import com.gh.gamecenter.core.provider.IFlavorProvider
import com.gh.gamecenter.core.utils.SPUtils
import com.leon.channel.helper.ChannelReaderUtil
class FlavorProviderImp : IFlavorProvider {
class ChannelProviderImp : ChannelProvider {
override fun getChannelStr(application: Application): String {
var channel = ChannelReaderUtil.getChannel(application)
if (channel == null || TextUtils.isEmpty(channel.trim())) {
@ -25,12 +23,4 @@ class FlavorProviderImp : IFlavorProvider {
}
return channel
}
override fun init(application: Application, activity: Activity) {
// do nothing
}
override fun logEvent(content: String) {
// do nothing
}
}

View File

@ -6,11 +6,6 @@
<queries>
<package android:name="com.gh.gamecenter" />
</queries>
<queries>
<package android:name="com.lg.vspace" />
</queries>
<!-- 允许应用程序访问网络连接 -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- 允许应用程序写入外部存储如SD卡上写文件 -->
@ -153,6 +148,10 @@
android:name="com.gh.gamecenter.NewsDetailActivity"
android:screenOrientation="portrait" />
<activity
android:name="com.gh.gamecenter.SettingActivity"
android:screenOrientation="portrait" />
<activity
android:name="com.gh.gamecenter.ConcernActivity"
android:screenOrientation="portrait" />
@ -220,6 +219,18 @@
android:name="com.gh.gamecenter.SelectUserIconActivity"
android:screenOrientation="portrait" />
<activity
android:name="com.gh.gamecenter.AboutActivity"
android:screenOrientation="portrait" />
<activity
android:name="com.gh.gamecenter.security.SecurityActivity"
android:screenOrientation="portrait" />
<activity
android:name="com.gh.gamecenter.security.BindPhoneActivity"
android:screenOrientation="portrait" />
<activity
android:name="com.gh.gamecenter.CommentDetailActivity"
android:screenOrientation="portrait"
@ -333,6 +344,10 @@
android:name="com.gh.gamecenter.amway.AmwayActivity"
android:screenOrientation="portrait" />
<activity
android:name="com.gh.gamecenter.NetworkDiagnosisActivity"
android:screenOrientation="portrait" />
<activity
android:name="com.gh.gamecenter.personalhome.fans.FansActivity"
android:screenOrientation="portrait" />
@ -571,6 +586,14 @@
android:name=".qa.video.publish.VideoPublishActivity"
android:screenOrientation="portrait" />
<activity
android:name=".setting.GameDownloadSettingActivity"
android:screenOrientation="portrait" />
<activity
android:name=".setting.VideoSettingActivity"
android:screenOrientation="portrait" />
<activity
android:name=".qa.video.detail.ForumVideoDetailActivity"
android:screenOrientation="portrait" />
@ -710,23 +733,6 @@
android:name=".BbsCertificationActivity"
android:screenOrientation="portrait" />
<activity
android:name=".discovery.DiscoveryActivity"
android:screenOrientation="portrait" />
<activity
android:name=".cloudarchive.CloudArchiveManagerActivity"
android:screenOrientation="portrait" />
<activity
android:name=".savegame.GameArchiveListActivity"
android:screenOrientation="portrait" />
<activity
android:name=".discovery.interestedgame.InterestedGameActivity"
android:screenOrientation="portrait" />
<!-- <activity-->
<!-- android:name="${applicationId}.douyinapi.DouYinEntryActivity"-->
<!-- android:launchMode="singleTask"-->
@ -749,26 +755,6 @@
android:enabled="true"
android:exported="true" />
<provider
android:name="com.gh.vspace.VFileProvider"
android:authorities="${applicationId}.virtual_file_provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>
<service
android:name=".aidl.CommunicationService"
android:enabled="true"
android:exported="true" >
<intent-filter>
<action android:name="com.gh.gamecenter.aidl.CommunicationService"/>
</intent-filter>
</service>
<!-- <provider-->
<!-- android:name="androidx.startup.InitializationProvider"-->
<!-- android:authorities="${applicationId}.androidx-startup"-->

View File

@ -1 +0,0 @@
{"v":"5.9.1","fr":60,"ip":0,"op":100,"w":64,"h":64,"nm":"多版本下载提示_dark","ddd":0,"assets":[{"id":"comp_0","nm":"arrow 合成_dark","fr":60,"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"arrow","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.333],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":0,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":24,"s":[100]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.667],"y":[0]},"t":76,"s":[100]},{"t":100,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.333,"y":1},"o":{"x":0.364,"y":0},"t":0,"s":[28,-12,0],"to":[0,6.382,0],"ti":[0,-0.284,0]},{"i":{"x":0.667,"y":0.667},"o":{"x":0.333,"y":0.333},"t":24,"s":[28,28,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.667,"y":1},"o":{"x":0.667,"y":0},"t":76,"s":[28,28,0],"to":[0,6.667,0],"ti":[0,-6.667,0]},{"t":100,"s":[28,68,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":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[0,2],[0,-2]],"c":false},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ind":1,"ty":"sh","ix":2,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[-2,0],[0,2]],"c":false},"ix":2},"nm":"路径 2","mn":"ADBE Vector Shape - Group","hd":false},{"ind":2,"ty":"sh","ix":3,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[2,0],[0,2]],"c":false},"ix":2},"nm":"路径 3","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.333,0.333],"y":[1,1]},"o":{"x":[0.333,0.333],"y":[0,0]},"t":0,"s":[80,120]},{"i":{"x":[0.667,0.667],"y":[1,1]},"o":{"x":[0.667,0.667],"y":[0,0]},"t":24,"s":[100,100]},{"i":{"x":[0.667,0.667],"y":[1,1]},"o":{"x":[0.667,0.667],"y":[0,0]},"t":76,"s":[100,100]},{"t":100,"s":[80,120]}],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.156862750649,0.533333361149,0.878431379795,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"stroke","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[400,400],"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":"Vector 97","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":100,"st":0,"bm":0}]}],"layers":[{"ddd":0,"ind":1,"ty":0,"nm":"arrow 合成_dark","refId":"comp_0","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[32,32,0],"ix":2,"l":2},"a":{"a":0,"k":[28,28,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"w":56,"h":56,"ip":0,"op":100,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"base","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[32,32,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":[{"d":1,"ty":"el","s":{"a":0,"k":[15,15],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"椭圆路径 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[0.156862750649,0.533333361149,0.878431379795,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"stroke","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0.137254908681,0.137254908681,0.137254908681,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"filling","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":[400,400],"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":"Ellipse 44","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":100,"st":0,"bm":0}],"markers":[]}

View File

@ -1 +0,0 @@
{"v":"5.9.1","fr":60,"ip":0,"op":100,"w":64,"h":64,"nm":"多版本下载提示_light","ddd":0,"assets":[{"id":"comp_0","nm":"arrow 合成_light","fr":60,"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"arrow","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.333],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":0,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":24,"s":[100]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.667],"y":[0]},"t":76,"s":[100]},{"t":100,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.333,"y":1},"o":{"x":0.364,"y":0},"t":0,"s":[28,-12,0],"to":[0,6.382,0],"ti":[0,-0.284,0]},{"i":{"x":0.667,"y":0.667},"o":{"x":0.333,"y":0.333},"t":24,"s":[28,28,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.667,"y":1},"o":{"x":0.667,"y":0},"t":76,"s":[28,28,0],"to":[0,6.667,0],"ti":[0,-6.667,0]},{"t":100,"s":[28,68,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":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[0,2],[0,-2]],"c":false},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ind":1,"ty":"sh","ix":2,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[-2,0],[0,2]],"c":false},"ix":2},"nm":"路径 2","mn":"ADBE Vector Shape - Group","hd":false},{"ind":2,"ty":"sh","ix":3,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[2,0],[0,2]],"c":false},"ix":2},"nm":"路径 3","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.333,0.333],"y":[1,1]},"o":{"x":[0.333,0.333],"y":[0,0]},"t":0,"s":[80,120]},{"i":{"x":[0.667,0.667],"y":[1,1]},"o":{"x":[0.667,0.667],"y":[0,0]},"t":24,"s":[100,100]},{"i":{"x":[0.667,0.667],"y":[1,1]},"o":{"x":[0.667,0.667],"y":[0,0]},"t":76,"s":[100,100]},{"t":100,"s":[80,120]}],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.141176477075,0.588235318661,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"stroke","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[400,400],"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":"Vector 97","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":100,"st":0,"bm":0}]}],"layers":[{"ddd":0,"ind":1,"ty":0,"nm":"arrow 合成_light","refId":"comp_0","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[32,32,0],"ix":2,"l":2},"a":{"a":0,"k":[28,28,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"w":56,"h":56,"ip":0,"op":100,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"base","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[32,32,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":[{"d":1,"ty":"el","s":{"a":0,"k":[15,15],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"椭圆路径 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[0.141176477075,0.588235318661,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"stroke","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"filling","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":[400,400],"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":"Ellipse 44","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":100,"st":0,"bm":0}],"markers":[]}

View File

@ -0,0 +1 @@
{"v":"5.6.9","fr":60,"ip":0,"op":36,"w":120,"h":66,"nm":"开关动画-关闭","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"按钮手柄","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.667,"y":1},"o":{"x":0.667,"y":0},"t":0,"s":[87,33,0],"to":[7.682,0,0],"ti":[-13.443,0,0]},{"i":{"x":0.333,"y":1},"o":{"x":0.333,"y":0},"t":18,"s":[31,33,0],"to":[2.306,0,0],"ti":[-1.318,0,0]},{"t":24,"s":[33,33,0]}],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[16,16],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"椭圆路径 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[300,300],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"椭圆形","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":37,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"指示器-on","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.667],"y":[0]},"t":0,"s":[100]},{"t":18,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[33,33,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":1,"k":[{"i":{"x":[0.667,0.667],"y":[1,1]},"o":{"x":[0.667,0.667],"y":[0,0]},"t":0,"s":[6.5,6.5]},{"t":18,"s":[4.5,4.5]}],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"椭圆路径 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[0.966666666667,0.966666666667,0.966666666667,0.420000005762],"ix":3},"o":{"a":0,"k":40,"ix":4},"w":{"a":0,"k":1.5,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[300,300],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"椭圆形","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":37,"st":0,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"指示器-off","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[87,33,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":1,"k":[{"i":{"x":[0.667,0.667],"y":[1,1]},"o":{"x":[0.667,0.667],"y":[0,0]},"t":0,"s":[1.5,4]},{"t":18,"s":[1.5,6]}],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"r":{"a":0,"k":0.75,"ix":4},"nm":"矩形路径 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"fl","c":{"a":0,"k":[0,0,0,1],"ix":4},"o":{"a":0,"k":5,"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":90,"ix":6},"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.667],"y":[0]},"t":0,"s":[0]},{"t":18,"s":[100]}],"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"矩形","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":37,"st":0,"bm":0},{"ddd":0,"ind":4,"ty":4,"nm":"按钮背景","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[60,33,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"sy":[{"c":{"a":0,"k":[0,0,0,1],"ix":2},"o":{"a":0,"k":5,"ix":3},"a":{"a":0,"k":120,"ix":5},"s":{"a":0,"k":1,"ix":8},"d":{"a":0,"k":0,"ix":6},"ch":{"a":0,"k":100,"ix":7},"bm":{"a":0,"k":5,"ix":1},"no":{"a":0,"k":0,"ix":9},"ty":2,"nm":"内阴影"}],"shapes":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[40,22],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"r":{"a":0,"k":12,"ix":4},"nm":"矩形路径 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"fl","c":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.667],"y":[0]},"t":0,"s":[0.141176477075,0.588235318661,1,1]},{"t":18,"s":[0.933333337307,0.933333337307,0.933333337307,1]}],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"filling","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0.118,0.006],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[300,300],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"矩形","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":37,"st":0,"bm":0}],"markers":[]}

View File

@ -473,14 +473,14 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
private fun chooseImage() {
MtaHelper.onEvent(mtaEventName(), "插入图片", "插入图片")
val imageCount = mViewModel.quoteCountEntity.imageCount
if (imageCount >= MAX_IMAGE_COUNT) {
if (imageCount >= MAX_MEDIA_COUNT) {
toast(R.string.answer_edit_max_img_hint)
return
}
try {
PermissionHelper.checkStoragePermissionBeforeAction(this, object : EmptyCallback {
override fun onCallback() {
val maxChooseCount = if (imageCount + 10 <= MAX_IMAGE_COUNT) 10 else MAX_IMAGE_COUNT - imageCount
val maxChooseCount = if (imageCount + 10 <= MAX_MEDIA_COUNT) 10 else MAX_MEDIA_COUNT - imageCount
val intent = LocalMediaActivity.getIntent(
this@BaseRichEditorActivity,
LocalMediaActivity.ChooseType.IMAGE,
@ -770,7 +770,6 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
const val INSERT_VIDEO_CODE = 415
const val MAX_INPUT_TEXT_NUM = 10000
const val MAX_MEDIA_COUNT = 20
const val MAX_IMAGE_COUNT = 35
const val REQUEST_CODE_IMAGE = 120
const val INSERT_MEDIA_VIDEO_CODE = 121

View File

@ -9,17 +9,16 @@ import android.text.TextUtils
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.MediatorLiveData
import androidx.lifecycle.MutableLiveData
import com.gh.gamecenter.R
import com.gh.gamecenter.common.base.fragment.WaitingDialogFragment
import com.gh.gamecenter.common.retrofit.Response
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.core.runOnUiThread
import com.gh.gamecenter.core.utils.MD5Utils
import com.gh.gamecenter.core.utils.ToastUtils
import com.gh.gamecenter.R
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.core.utils.*
import com.gh.gamecenter.entity.ErrorEntity
import com.gh.gamecenter.entity.LocalVideoEntity
import com.gh.gamecenter.entity.QuoteCountEntity
import com.gh.gamecenter.qa.BbsType
import com.gh.gamecenter.common.retrofit.Response
import com.gh.gamecenter.retrofit.RetrofitManager
import com.gh.gamecenter.retrofit.service.ApiService
import com.gh.gamecenter.video.upload.OnUploadListener
@ -33,12 +32,20 @@ import okhttp3.ResponseBody
import retrofit2.HttpException
import java.io.File
import java.io.FileOutputStream
import java.util.*
import kotlin.collections.HashMap
import kotlin.collections.LinkedHashMap
import kotlin.collections.List
import kotlin.collections.Map
import kotlin.collections.find
import kotlin.collections.forEach
import kotlin.collections.set
// TODO: 移动到module_bbs模块
abstract class BaseRichEditorViewModel(application: Application) : AndroidViewModel(application) {
val mApi: ApiService = RetrofitManager.getInstance().api
val processDialog = MediatorLiveData<WaitingDialogFragment.WaitingDialogData>()
val uploadingImage = ArrayList<LinkedHashMap<String, String>>()
val chooseImagesUpload = MutableLiveData<LinkedHashMap<String, String>>()
val chooseImagesUploadSuccess = MutableLiveData<LinkedHashMap<String, String>>()
var uploadImageSubscription: Disposable? = null
@ -63,10 +70,7 @@ abstract class BaseRichEditorViewModel(application: Application) : AndroidViewMo
//检查图片是否符合规则并上传图片
fun uploadPic(data: Intent) {
val uris = Matisse.obtainResult(data)
val rawImgUrlList = ArrayList<String>() // 需要上传图片的原始地址列表
val uploadingImgList = ArrayList<String>() // 正在上传图片的地址列表(已压缩处理)
val compressedImgUrlList = ArrayList<String>() // 压缩处理后图片的地址列表
val pictureList = ArrayList<String>()
for (uri in uris) {
val picturePath = PathUtils.getPath(getApplication(), uri)
if (picturePath != null) {
@ -80,12 +84,12 @@ abstract class BaseRichEditorViewModel(application: Application) : AndroidViewMo
continue
}
Utils.log("picturePath = $picturePath")
rawImgUrlList.add(picturePath)
pictureList.add(picturePath)
} else {
Utils.log("picturePath is null")
}
}
if (rawImgUrlList.size == 0) return
if (pictureList.size == 0) return
val imageType = when (getRichType()) {
RichType.ARTICLE -> UploadImageUtils.UploadType.community_article
RichType.QUESTION -> UploadImageUtils.UploadType.question
@ -93,7 +97,7 @@ abstract class BaseRichEditorViewModel(application: Application) : AndroidViewMo
}
uploadImageSubscription = UploadImageUtils.compressAndUploadImageList(
imageType,
rawImgUrlList,
pictureList,
false,
object : UploadImageUtils.OnUploadImageListListener {
override fun onProgress(total: Long, progress: Long) {}
@ -103,108 +107,87 @@ abstract class BaseRichEditorViewModel(application: Application) : AndroidViewMo
imageUrls.forEach {
chooseImageMd5Map[MD5Utils.getUrlMD5(it)] = ""
}
uploadingImgList.addAll(imageUrls)
compressedImgUrlList.addAll(imageUrls)
uploadingImage.add(chooseImageMd5Map)
chooseImagesUpload.postValue(chooseImageMd5Map)
}
override fun onSingleSuccess(imageUrlMap: Map<String, String>) {
imageUrlMap.forEach {
if (uploadingImgList.contains(it.key)) {
uploadingImgList.remove(it.key)
}
}
override fun onSingleSuccess(imageUrl: Map<String, String>) {
val map = LinkedHashMap<String, String>()
for (key in imageUrlMap.keys) {
for (key in imageUrl.keys) {
map[MD5Utils.getUrlMD5(key)] = FILE_HOST + key.decodeURI()
mapImages[TextUtils.htmlEncode(key).decodeURI()] = imageUrlMap[key] ?: ""
mapImages[TextUtils.htmlEncode(key).decodeURI()] = imageUrl[key] ?: ""
}
chooseImagesUploadSuccess.value = map
chooseImagesUploadSuccess.postValue(map)
}
override fun onSuccess(imageUrlMap: LinkedHashMap<String, String>, errorMap: Map<String, Exception>) {
imageUrlMap.forEach {
if (uploadingImgList.contains(it.key)) {
uploadingImgList.remove(it.key)
}
override fun onSuccess(
imageUrl: LinkedHashMap<String, String>,
errorMap: Map<String, Exception>
) {
val uploadMap = uploadingImage.find {
it.containsKey(
MD5Utils.getUrlMD5(
imageUrl.entries.iterator().next().key
)
)
}
uploadMap?.let {
uploadingImage.remove(uploadMap)
}
var errorSize = compressedImgUrlList.size - imageUrlMap.size
if (errorSize > 0 || uploadingImgList.isNotEmpty()) {
val errorImageMap = LinkedHashMap<String, String>()
val errorSize = pictureList.size - imageUrl.size
if (errorSize > 0) {
val map = LinkedHashMap<String, String>()
for (key in errorMap.keys) {
errorImageMap[MD5Utils.getUrlMD5(key)] = ""
map[MD5Utils.getUrlMD5(key)] = ""
}
//value为空会删除PlaceholderImage
chooseImagesUploadSuccess.postValue(map)
for (rawImgUrl in compressedImgUrlList) {
if (!imageUrlMap.containsKey(rawImgUrl)) {
errorImageMap[MD5Utils.getUrlMD5(rawImgUrl)] = ""
for (error in errorMap.values) {
if (error is HttpException && error.code() == 403) {
Utils.toast(getApplication(), errorSize.toString() + "张违规图片上传失败")
return
}
}
errorSize = if (errorMap.isEmpty()) {
errorImageMap.size
} else {
errorMap.size + errorImageMap.size
}
// value为空会删除PlaceholderImage
chooseImagesUploadSuccess.value = errorImageMap
if (handleUploadError(errorSize, errorMap)) return
if (errorSize > 0) {
ToastUtils.showToast(errorSize.toString() + "张图片上传失败")
}
Utils.toast(getApplication(), errorSize.toString() + "张图片上传失败")
}
}
override fun onError(errorMap: Map<String, Exception>) {
val errorSize = uploadingImgList.size
if (uploadingImgList.size > 0) {
val errorSize = errorMap.size
if (errorSize > 0) {
val map = LinkedHashMap<String, String>()
for (key in uploadingImgList) {
for (key in errorMap.keys) {
map[MD5Utils.getUrlMD5(key)] = ""
}
// value为空会删除PlaceholderImage
chooseImagesUploadSuccess.value = map
//value为空会删除PlaceholderImage
chooseImagesUploadSuccess.postValue(map)
}
if (handleUploadError(errorSize, errorMap)) return
if (errorSize == 0) return
for (error in errorMap.values) {
if (error is HttpException && error.code() == 403) {
val e = error.response()?.errorBody()?.string()?.toObject<ErrorEntity>()
if (e != null && e.code == 403017) {
Utils.toast(
getApplication(),
errorSize.toString() + "张图片的宽或高超过限制,请裁剪后上传"
)
} else {
Utils.toast(getApplication(), errorSize.toString() + "张违规图片上传失败")
}
return
}
}
if (errorSize == 1) {
ToastUtils.showToast("图片上传失败")
Utils.toast(getApplication(), "图片上传失败")
} else {
ToastUtils.showToast(errorSize.toString() + "张图片上传失败")
Utils.toast(getApplication(), errorSize.toString() + "张图片上传失败")
}
}
})
}
/**
* 处理上传错误 (包括超时 cancel 的异常)
* @return 如果 toast 过了就返回 true
*/
private fun handleUploadError(
errorSize: Int,
errorMap: Map<String, Exception>
): Boolean {
for (error in errorMap.values) {
if (error is HttpException && error.code() == 403) {
val e = error.response()?.errorBody()?.string()?.toObject<ErrorEntity>()
if (e != null && e.code == 403017) {
ToastUtils.showToast(errorSize.toString() + "张图片的宽或高超过限制,请裁剪后上传")
} else {
ToastUtils.showToast(errorSize.toString() + "张违规图片上传失败")
}
return true
}
}
return false
}
fun uploadPoster(picturePath: String) {
processDialog.postValue(WaitingDialogFragment.WaitingDialogData("封面上传中...", true))
uploadImageSubscription =

View File

@ -6,9 +6,14 @@ import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.gh.common.util.FloatingBackViewManager
import com.gh.download.DownloadManager
import com.gh.gamecenter.MainActivity
import com.gh.gamecenter.SplashScreenActivity
import com.gh.gamecenter.WebActivity
import com.gh.gamecenter.common.utils.PackageFlavorHelper
import com.gh.gamecenter.forum.detail.ForumDetailActivity
import com.gh.gamecenter.forum.list.ForumListActivity
import com.gh.gamecenter.qa.article.detail.ArticleDetailActivity
import com.gh.gamecenter.qa.questions.newdetail.NewQuestionDetailActivity
import com.gh.gamecenter.qa.video.detail.ForumVideoDetailActivity
import com.gh.vspace.VHelper
import com.halo.assistant.HaloApp
@ -30,7 +35,7 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
&& FloatingBackViewManager.getType() == FloatingBackViewManager.TYPE_TASK
) {
FloatingBackViewManager.disableBackView()
} else if (activity is WebActivity
} else if (!shouldShowActivityBackView(activity)
&& FloatingBackViewManager.getType() == FloatingBackViewManager.TYPE_ACTIVITY
) {
FloatingBackViewManager.disableBackView()
@ -60,6 +65,15 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
}
}
private fun shouldShowActivityBackView(activity: Activity): Boolean {
return (activity is MainActivity
|| activity is ArticleDetailActivity
|| activity is ForumVideoDetailActivity
|| activity is ForumDetailActivity
|| activity is ForumListActivity
|| activity is NewQuestionDetailActivity)
}
override fun onActivityPaused(activity: Activity) {
FloatingBackViewManager.dismissBackView()
if (PackageFlavorHelper.IS_TEST_FLAVOR && activity is AppCompatActivity) {

View File

@ -4,20 +4,13 @@ import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.util.Base64
import android.view.View
import android.webkit.JavascriptInterface
import androidx.annotation.Keep
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.fragment.app.FragmentManager
import com.gh.common.util.*
import com.gh.common.util.LogUtils
import com.gh.download.DownloadManager
import com.gh.download.PackageObserver
import com.gh.gamecenter.BuildConfig
import com.gh.gamecenter.ImageViewerActivity
import com.gh.gamecenter.WebActivity
import com.gh.gamecenter.*
import com.gh.gamecenter.common.callback.BiCallback
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.entity.NotificationUgc
@ -28,27 +21,23 @@ import com.gh.gamecenter.common.view.dsbridge.CompletionHandler
import com.gh.gamecenter.core.AppExecutor
import com.gh.gamecenter.core.runOnIoThread
import com.gh.gamecenter.core.runOnUiThread
import com.gh.gamecenter.core.utils.*
import com.gh.gamecenter.core.utils.CurrentActivityHolder
import com.gh.gamecenter.core.utils.DisplayUtils
import com.gh.gamecenter.core.utils.MtaHelper
import com.gh.gamecenter.core.utils.SPUtils
import com.gh.gamecenter.energy.EnergyBridge
import com.gh.gamecenter.entity.GameEntity
import com.gh.gamecenter.entity.MtaEvent
import com.gh.gamecenter.eventbus.EBPackage
import com.gh.gamecenter.help.QaFeedbackDialogFragment
import com.gh.gamecenter.login.entity.Badge
import com.gh.gamecenter.login.user.LoginTag
import com.gh.gamecenter.login.view.LoginActivity
import com.gh.gamecenter.login.user.UserManager
import com.gh.gamecenter.personalhome.border.AvatarBorderActivity
import com.gh.gamecenter.security.BindPhoneActivity
import com.gh.gamecenter.login.user.UserRepository
import com.gh.gamecenter.login.utils.LoginHelper
import com.gh.gamecenter.login.utils.QuickLoginHelper
import com.gh.gamecenter.login.view.LoginActivity
import com.gh.gamecenter.personalhome.border.AvatarBorderActivity
import com.gh.gamecenter.setting.view.AboutActivity
import com.gh.gamecenter.setting.view.security.BindPhoneActivity
import com.gh.vspace.VHelper
import com.halo.assistant.HaloApp
import com.lightgame.download.DataWatcher
import com.lightgame.download.DownloadEntity
import com.lightgame.download.DownloadStatus.*
import com.lightgame.utils.Utils
import org.json.JSONObject
import java.io.BufferedOutputStream
@ -56,18 +45,9 @@ import java.io.File
import java.io.FileOutputStream
import java.util.*
class DefaultJsApi(var context: Context, val entrance: String = "", private var mFragment: Fragment? = null) {
class DefaultJsApi(var context: Context, val entrance: String = "") {
private var mLoginHandler: CompletionHandler<Any>? = null
private var mDownloadWatcher: DataWatcher? = null
private var mDownloadUrlSet: HashSet<String>? = null
private var mDownloadHandler: CompletionHandler<Any>? = null
init {
if (mFragment != null) {
autoUnregisterDownloadObserverIfNeeded(mFragment)
}
}
@JavascriptInterface
fun isGhzs(msg: Any): String {
@ -184,16 +164,7 @@ class DefaultJsApi(var context: Context, val entrance: String = "", private var
@JavascriptInterface
fun startApp(msg: Any) {
val packageName = msg.toString()
val context = HaloApp.getInstance().application
// 若畅玩列表中安装了,优先启动畅玩游戏
if (VHelper.isInstalled(packageName)) {
if (!VHelper.showDialogIfVSpaceIsNeeded(context)) {
VHelper.launch(context, packageName)
}
} else {
PackageUtils.launchApplicationByPackageName(context, packageName)
}
PackageUtils.launchApplicationByPackageName(HaloApp.getInstance().application, packageName)
}
@JavascriptInterface
@ -465,175 +436,7 @@ class DefaultJsApi(var context: Context, val entrance: String = "", private var
@JavascriptInterface
fun getEntrance(msg: Any): String {
return when {
entrance.contains("论坛-活动") -> "社区-活动tab-活动banner"
entrance.contains("启动弹窗") -> "首页_弹窗"
entrance.contains("新首页-轮播图") -> "首页banner"
entrance.contains("论坛banner") -> "社区banner"
entrance.contains("启动广告") -> "app_开屏文案"
// entrance.contains("资讯广场-轮播图") -> "资讯_活动banner"
entrance.contains("通用链接合集") -> "资讯_活动banner"
entrance.contains("视频流广告位") -> "视频流_广告位"
entrance.contains("我的光环banner") -> "我的光环_banner"
entrance.contains("论坛详情页置顶栏") -> "社区_论坛置顶"
else -> entrance
}
}
@JavascriptInterface
fun getInstallStatus(event: Any): String {
val localInstalledPackageList = PackageUtils.getAllPackageName(HaloApp.getInstance().application)
val packageNameList: ArrayList<String> = event.toString().toObject() ?: ArrayList()
val installStatusMap: HashMap<String, Boolean> = hashMapOf()
for (packageName in packageNameList) {
installStatusMap[packageName] =
localInstalledPackageList.contains(packageName) || VHelper.isInstalled(packageName)
}
return installStatusMap.toJson()
}
@JavascriptInterface
fun installDownloadedGame(event: Any) {
val url = event.toString()
val vUrl = VHelper.getVUrl(url)
val downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(url, null, false)
?: DownloadManager.getInstance().getDownloadEntitySnapshot(vUrl, null, false)
downloadEntity?.let {
PackageInstaller.install(context, it, showUnzipToast = false)
}
}
@JavascriptInterface
fun registerDownloadCallback(msg: Any, handler: CompletionHandler<Any>) {
val downloadUrlSet: HashSet<String> = msg.toString().toObject() ?: return
mDownloadHandler = handler
mDownloadUrlSet = downloadUrlSet
if (mDownloadWatcher == null) {
mDownloadWatcher = object : DataWatcher() {
override fun onDataInit(downloadEntity: DownloadEntity) {
onDataChanged(downloadEntity)
}
override fun onDataChanged(downloadEntity: DownloadEntity?) {
val url = VHelper.getOriginalUrl(downloadEntity?.url)
if (downloadEntity != null) {
if (mDownloadUrlSet?.contains(url) == true) {
mDownloadHandler?.setProgressData(
SimpleDownloadEntity.fromDownloadEntity(downloadEntity).toJson()
)
}
}
}
}
DownloadManager.getInstance().addObserver(mDownloadWatcher)
}
}
@JavascriptInterface
fun registerPackageChangesCallback(msg: Any, handler: CompletionHandler<Any>) {
PackageObserver.registerPackageChangeChangeListener(object : PackageObserver.PackageChangeListener {
override fun onChanged(data: EBPackage) {
handler.setProgressData(data.toJson())
}
})
}
@JavascriptInterface
fun startDownload(msg: Any) {
val gameEntity: GameEntity? = msg.toString().toObject()
if (gameEntity == null) {
ToastUtils.toast("下载异常,请稍后重试")
return
}
runOnUiThread {
// 用一个假的 view 来当 downloadView
val stubView = View(context)
DownloadItemUtils.setOnClickListener(
position = 0,
context = context,
downloadBtn = stubView,
gameEntity = gameEntity,
adapter = null,
entrance = "(网页活动)",
location = "",
traceEvent = null,
clickCallback = null,
refreshCallback = null,
allStateClickCallback = null
)
stubView.performClick()
}
}
@JavascriptInterface
fun resumeDownload(msg: Any) {
val url = msg.toString()
DownloadManager.getInstance().resumeDownload(url)
}
@JavascriptInterface
fun pauseDownload(msg: Any) {
val url = msg.toString()
DownloadManager.getInstance().pause(url)
}
@JavascriptInterface
fun shareText(event: Any) {
val textShareEvent = event.toString().toObject() ?: TextShareEvent()
if (textShareEvent.text.isNotEmpty() && textShareEvent.type.isNotEmpty()) {
val activity = CurrentActivityHolder.getCurrentActivity()
MessageShareUtils.getInstance(activity).shareTextFromWeb(activity, textShareEvent.text, textShareEvent.type)
}
}
private fun autoUnregisterDownloadObserverIfNeeded(fragment: Fragment?) {
fragment?.parentFragmentManager?.registerFragmentLifecycleCallbacks(
object : FragmentManager.FragmentLifecycleCallbacks() {
override fun onFragmentViewDestroyed(fm: FragmentManager, f: Fragment) {
super.onFragmentViewDestroyed(fm, f)
if (f === fragment) {
fragment.parentFragmentManager.unregisterFragmentLifecycleCallbacks(this)
if (mDownloadWatcher != null) {
DownloadManager.getInstance().removeObserver(mDownloadWatcher)
}
}
}
override fun onFragmentResumed(fm: FragmentManager, f: Fragment) {
super.onFragmentResumed(fm, f)
if (f === fragment) {
if (mDownloadWatcher != null) {
DownloadManager.getInstance().addObserver(mDownloadWatcher)
}
}
}
override fun onFragmentPaused(fm: FragmentManager, f: Fragment) {
super.onFragmentPaused(fm, f)
if (f === fragment) {
if (mDownloadWatcher != null) {
DownloadManager.getInstance().removeObserver(mDownloadWatcher)
}
}
}
}, false
)
return entrance
}
@Keep
@ -642,9 +445,6 @@ class DefaultJsApi(var context: Context, val entrance: String = "", private var
@Keep
internal data class ImageShareEvent(var image: String = "", var type: String = "")
@Keep
internal data class TextShareEvent(var text: String = "", var type: String = "")
@Keep
internal data class InviteFriendsEvent(
var type: String = "",
@ -666,39 +466,4 @@ class DefaultJsApi(var context: Context, val entrance: String = "", private var
var activityId: String = "",
var platform: String = ""
)
@Keep
data class SimpleDownloadEntity(
var url: String = "",
var progress: Float = 0F,
var status: String = "" // DOWNLOADING, PAUSED, DOWNLOADED, ERROR, UNKNOWN
) {
companion object {
fun fromDownloadEntity(downloadEntity: DownloadEntity): SimpleDownloadEntity {
val status: String = when (downloadEntity.status) {
add,
download,
downloading -> "DOWNLOADING"
done -> "DOWNLOADED"
pause,
resume,
subscribe,
waiting -> "PAUSED"
cancel,
delete -> "UNKNOWN"
else -> "ERROR"
}
return SimpleDownloadEntity(
url = VHelper.getOriginalUrl(downloadEntity.url),
progress = downloadEntity.percent.toFloat(),
status = status
)
}
}
}
}

View File

@ -15,26 +15,25 @@ import com.gh.common.util.DirectUtils.directToGameVideo
import com.gh.common.util.DirectUtils.directToLegacyVideoDetail
import com.gh.common.util.DirectUtils.directToLinkPage
import com.gh.common.util.DirectUtils.directToQa
import com.gh.gamecenter.*
import com.gh.gamecenter.core.utils.GsonUtils.gson
import com.gh.gamecenter.LibaoDetailActivity
import com.gh.gamecenter.MainActivity
import com.gh.gamecenter.NewsDetailActivity
import com.gh.gamecenter.WebActivity
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.entity.CommunityEntity
import com.gh.gamecenter.common.entity.LinkEntity
import com.gh.gamecenter.common.eventbus.EBReuse
import com.gh.gamecenter.core.AppExecutor
import com.gh.gamecenter.common.utils.DialogHelper
import com.gh.gamecenter.common.utils.EnvHelper
import com.gh.gamecenter.core.utils.ToastUtils
import com.gh.gamecenter.entity.*
import com.gh.gamecenter.eventbus.EBSkip
import com.gh.gamecenter.fragment.MainWrapperFragment
import com.gh.gamecenter.gamecollection.publish.GameCollectionEditActivity
import com.gh.gamecenter.qa.BbsType
import com.gh.gamecenter.qa.video.publish.VideoPublishActivity
import com.gh.gamecenter.subject.SubjectActivity
import com.gh.gamecenter.video.detail.VideoDetailContainerViewModel
import com.lightgame.utils.Utils
import org.greenrobot.eventbus.EventBus
import java.nio.charset.Charset
object DefaultUrlHandler {
@ -186,12 +185,10 @@ object DefaultUrlHandler {
EntranceConsts.HOST_USERHOME -> {
val position = uri.getQueryParameter("position")
val subtype = uri.getQueryParameter("sub_type") ?: ""
val subGameType = uri.getQueryParameter("sub_game_type") ?: "game_collection"
DirectUtils.directToHomeActivity(
context,
id,
subtype,
subGameType,
if (position.isNullOrEmpty()) -1 else position.toInt(),
entrance,
""
@ -493,18 +490,6 @@ object DefaultUrlHandler {
)
}
EntranceConsts.HOST_GAME_LIBRARY -> {
DirectUtils.directToMainActivity(context)
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_GAME))
}
EntranceConsts.HOST_HOME_GAME_COLLECTION_SQUARE -> {
DirectUtils.directToMainActivity(context)
EventBus.getDefault()
.post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_HOME))
EventBus.getDefault().post(EBReuse(host))
}
else -> {
if (bringAppToFront) {
DirectUtils.directToMainActivity(context)

View File

@ -2,15 +2,14 @@ package com.gh.common
import com.gh.common.exposure.ExposureManager
import com.gh.common.filter.RegionSettingHelper
import com.gh.common.util.AdHelper
import com.gh.common.videolog.VideoRecordUtils
import com.gh.download.DownloadDataHelper
import com.gh.gamecenter.common.loghub.LoghubUtils
import com.gh.gamecenter.common.retrofit.Response
import com.gh.gamecenter.common.utils.doOnMainProcessOnly
import com.gh.gamecenter.common.utils.tryCatchInRelease
import com.gh.gamecenter.core.runOnUiThread
import com.gh.common.videolog.VideoRecordUtils
import com.gh.download.DownloadDataHelper
import com.gh.gamecenter.entity.TimeEntity
import com.gh.gamecenter.common.retrofit.Response
import com.gh.gamecenter.core.runOnUiThread
import com.gh.gamecenter.retrofit.RetrofitManager
import com.halo.assistant.HaloApp
import io.reactivex.schedulers.Schedulers
@ -26,7 +25,6 @@ object FixedRateJobHelper {
private const val DOWNLOAD_HEARTBEAT_PERIOD: Long = 60 * 1000L
private const val DOWNLOAD_HEARTBEAT_SHEET_PERIOD: Long = 15 * 1000L
private const val STARTUP_AD: Long = 30 * 60 * 1000L
private var mExecuteCount: Int = 0
@ -84,11 +82,6 @@ object FixedRateJobHelper {
VideoRecordUtils.commitVideoRecord()
}
// 获取启动广告
if ((mExecuteCount * CHECKER_PERIOD) % STARTUP_AD == 0L) {
AdHelper.getSettingAdCache()
}
// ExposureUtils.logADownloadCompleteExposureEvent(GameEntity(id = mExecuteCount.toString(), name = "测试曝光上传"), platform = "", trace = null, downloadType = ExposureUtils.DownloadType.DOWNLOAD)
mExecuteCount++
}

View File

@ -7,7 +7,7 @@ import com.gh.vspace.VHelper
class ValidateVSpaceHandler : ChainHandler() {
override fun handleRequest(context: Context, gameEntity: GameEntity) {
VHelper.validateVSpaceBeforeAction(context, gameEntity) {
VHelper.validateVSpaceBeforeAction(context, gameEntity, true) {
if (hasNext()) {
getNext()?.handleRequest(context, gameEntity)
} else {

View File

@ -1,33 +1,18 @@
package com.gh.common.chain
import android.content.Context
import com.gh.gamecenter.R
import com.gh.gamecenter.common.utils.DialogHelper
import com.gh.gamecenter.common.utils.toResString
import com.gh.common.util.DialogUtils
import com.gh.gamecenter.entity.GameEntity
class VersionNumberHandler : ChainHandler() {
override fun handleRequest(context: Context, gameEntity: GameEntity) {
val confirmCallback = {
DialogUtils.showVersionNumberDialog(context, gameEntity) {
if (hasNext()) {
getNext()?.handleRequest(context, gameEntity)
} else {
processEndCallback?.invoke(null)
}
}
if (!gameEntity.isShowVersionNumber()) {
confirmCallback.invoke()
} else {
DialogHelper.showGuideDialog(
context,
"温馨提示",
gameEntity.getVersionNumberString(),
"继续下载",
R.string.cancel.toResString(),
{ confirmCallback.invoke() },
extraConfig = DialogHelper.Config(titleIcon = R.drawable.ic_dialog_tips)
)
}
}
}

View File

@ -8,26 +8,24 @@ import android.text.TextUtils;
import androidx.annotation.Nullable;
import com.gh.common.util.AdHelper;
import com.gh.gamecenter.common.utils.DarkModeUtils;
import com.gh.gamecenter.common.utils.EnvHelper;
import com.gh.gamecenter.common.constant.Constants;
import com.gh.gamecenter.core.utils.GsonUtils;
import com.gh.common.util.PackageHelper;
import com.gh.common.util.PackageUtils;
import com.gh.gamecenter.BuildConfig;
import com.gh.gamecenter.SuggestionActivity;
import com.gh.gamecenter.common.constant.Constants;
import com.gh.gamecenter.common.eventbus.EBReuse;
import com.gh.gamecenter.common.retrofit.BiResponse;
import com.gh.gamecenter.common.retrofit.Response;
import com.gh.gamecenter.common.utils.DarkModeUtils;
import com.gh.gamecenter.common.utils.EnvHelper;
import com.gh.gamecenter.core.utils.GsonUtils;
import com.gh.gamecenter.core.utils.SPUtils;
import com.gh.gamecenter.entity.GameGuidePopupEntity;
import com.gh.gamecenter.entity.NewApiSettingsEntity;
import com.gh.gamecenter.entity.NewSettingsEntity;
import com.gh.gamecenter.entity.NewsEntity;
import com.gh.gamecenter.entity.SettingsEntity;
import com.gh.gamecenter.common.eventbus.EBReuse;
import com.gh.gamecenter.entity.SimulatorEntity;
import com.gh.gamecenter.entity.VSetting;
import com.gh.gamecenter.common.retrofit.BiResponse;
import com.gh.gamecenter.common.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
import com.gh.vspace.VHelper;
import com.halo.assistant.HaloApp;
@ -66,9 +64,8 @@ public class Config {
private static SettingsEntity mSettingsEntity;
private static NewSettingsEntity mNewSettingsEntity;
private static NewApiSettingsEntity mNewApiSettingsEntity;
private static NewApiSettingsEntity.NightMode mNightModeSetting;
private static NewSettingsEntity.NightMode mNightModeSetting;
private static SimulatorEntity mNewSimulatorEntity;
private static VSetting mVSetting;
private static GameGuidePopupEntity mGameGuidePopupEntity;
@ -207,7 +204,7 @@ public class Config {
PackageHelper.initList();
// 初始化畅玩相关的东西
VHelper.init(HaloApp.getInstance(), false);
VHelper.init(HaloApp.getInstance());
}
@Nullable
@ -230,32 +227,24 @@ public class Config {
public static SimulatorEntity getNewSimulatorEntitySetting() {
if (mNewSimulatorEntity != null) {
return mNewSimulatorEntity;
} else if (mNewApiSettingsEntity != null && mNewApiSettingsEntity.getSimulator() != null) {
return mNewApiSettingsEntity.getSimulator();
} else if (mNewSettingsEntity != null && mNewSettingsEntity.getSimulator() != null) {
return mNewSettingsEntity.getSimulator();
} else {
return null;
}
}
@Nullable
public static NewApiSettingsEntity.NightMode getNightModeSetting() {
public static NewSettingsEntity.NightMode getNightModeSetting() {
if (mNightModeSetting != null) {
return mNightModeSetting;
} else if (mNewApiSettingsEntity != null && mNewApiSettingsEntity.getNightMode() != null) {
return mNewApiSettingsEntity.getNightMode();
} else if (mNewSettingsEntity != null && mNewSettingsEntity.getNightMode() != null) {
return mNewSettingsEntity.getNightMode();
} else {
return null;
}
}
public static boolean getUserInterestedGame() {
if (mNewApiSettingsEntity != null) {
return mNewApiSettingsEntity.getUserInterestedGame();
} else {
return false;
}
}
@Nullable
public static NewSettingsEntity getNewSettingsEntity() {
if (mNewSettingsEntity == null) {
@ -271,26 +260,6 @@ public class Config {
return mNewSettingsEntity;
}
@Nullable
public static NewApiSettingsEntity getNewApiSettingsEntity() {
if (mNewApiSettingsEntity == null) {
try {
String json = SPUtils.getString(Constants.SP_NEW_API_SETTINGS);
if (!TextUtils.isEmpty(json)) {
mNewApiSettingsEntity = GsonUtils.fromJson(json, NewApiSettingsEntity.class);
}
} catch (Exception e) {
e.printStackTrace();
}
}
return mNewApiSettingsEntity;
}
public static void updateNewApiSettings(NewApiSettingsEntity settingsEntity) {
mNewApiSettingsEntity = settingsEntity;
SPUtils.setString(Constants.SP_NEW_API_SETTINGS, GsonUtils.toJson(settingsEntity));
}
@Nullable
public static VSetting getVSettingEntity() {
if (mVSetting == null) {
@ -340,6 +309,26 @@ public class Config {
return mDefaultSharedPreferences;
}
public static boolean isExistHideFunction() {
SharedPreferences preferences = getPreferences();
if (!preferences.getBoolean(FIX_DOWNLOAD_KEY, false)) return true;
if (!preferences.getBoolean(FIX_PLUGIN_KEY, false)) return true;
if (!preferences.getBoolean(FIX_COMMUNITY_KEY, false)) return true;
if (!preferences.getBoolean(FIX_ARTICLE_KEY, false)) return true;
return false;
}
public static void fixHideFunction() {
SharedPreferences preferences = PreferenceManager.
getDefaultSharedPreferences(HaloApp.getInstance().getApplication());
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean(Config.FIX_DOWNLOAD_KEY, true);
editor.putBoolean(Config.FIX_ARTICLE_KEY, true);
editor.putBoolean(Config.FIX_COMMUNITY_KEY, true);
editor.putBoolean(Config.FIX_PLUGIN_KEY, true);
editor.apply();
}
@SuppressLint("CheckResult")
public static void getGhzsSettings() {
String channel = HaloApp.getInstance().getChannel();
@ -375,6 +364,9 @@ public class Config {
@Override
public void onSuccess(NewSettingsEntity data) {
mNewSettingsEntity = data;
if (mNightModeSetting != null) {
mNewSettingsEntity.setNightMode(mNightModeSetting);
}
SPUtils.setString(Constants.SP_NEW_SETTINGS, GsonUtils.toJson(data));
}
});
@ -392,23 +384,27 @@ public class Config {
});
}
if (mNewApiSettingsEntity == null) {
if (mNightModeSetting == null && mNewSimulatorEntity == null) {
RetrofitManager.getInstance()
.getNewApi().getNewSettings(PackageUtils.getGhVersionName(), channel)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new BiResponse<NewApiSettingsEntity>() {
.subscribe(new BiResponse<NewSettingsEntity>() {
@Override
public void onSuccess(NewApiSettingsEntity data) {
mNewApiSettingsEntity = data;
public void onSuccess(NewSettingsEntity data) {
mNightModeSetting = data.getNightMode();
mNewSimulatorEntity = data.getSimulator();
if (HaloApp.getInstance().isNewForThisVersion && mNightModeSetting != null && mNightModeSetting.getInstall()) {
DarkModeUtils.INSTANCE.updateFollowSystemDarkModeToSp(true);
DarkModeUtils.INSTANCE.updateAppDarkModeStatusToSp(true);
DarkModeUtils.INSTANCE.initDarkMode();
}
AdHelper.prefetchStartUpAd(mNewApiSettingsEntity);
SPUtils.setString(Constants.SP_NEW_API_SETTINGS, GsonUtils.toJson(data));
if (mNewSettingsEntity != null) {
mNewSettingsEntity.setSimulator(mNewSimulatorEntity);
mNewSettingsEntity.setNightMode(mNightModeSetting);
SPUtils.setString(Constants.SP_NEW_SETTINGS, GsonUtils.toJson(data));
}
}
});
}

View File

@ -50,7 +50,6 @@ import com.gh.common.util.PlatformUtils;
import com.gh.common.util.ReservationHelper;
import com.gh.common.view.DownloadButton;
import com.gh.common.view.GameIconView;
import com.gh.common.view.NoEllipsizeSpaceTextView;
import com.gh.download.DownloadManager;
import com.gh.download.dialog.DownloadDialog;
import com.gh.gamecenter.DownloadManagerActivity;
@ -785,7 +784,7 @@ public class BindingAdapters {
}
}
public static void setGameName(NoEllipsizeSpaceTextView view, GameEntity game, boolean isShowPlatform, @Nullable Boolean isShowSuffix) {
public static void setGameName(TextView view, GameEntity game, boolean isShowPlatform, @Nullable Boolean isShowSuffix) {
if (isShowSuffix == null) isShowSuffix = true; // 默认显示
if (isShowPlatform && game.getApk().size() > 0) {
view.setText(String.format("%s - %s", !isShowSuffix ? game.getNameWithoutSuffix() : game.getName(),
@ -843,7 +842,7 @@ public class BindingAdapters {
int start = index;
int end = start + tag.getName().length() + ((i != showCount - 1) ? 1 : 0);
index = end;
span.setSpan(new ForegroundColorSpan(ExtensionsKt.hexStringToIntColor("#" + tag.getColor(), Color.WHITE)),
span.setSpan(new ForegroundColorSpan(Color.parseColor("#" + tag.getColor())),
start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
view.setText(span);
@ -851,11 +850,11 @@ public class BindingAdapters {
public static void setVideoData(TextView view, int count) {
if (count > 0) {
ExtensionsKt.setDrawableStart(view, ContextCompat.getDrawable(view.getContext(), R.drawable.ic_video_data_up), null, null);
view.setCompoundDrawablesWithIntrinsicBounds(ContextCompat.getDrawable(view.getContext(), R.drawable.ic_video_data_up), null, null, null);
view.setTextColor(ContextCompat.getColor(view.getContext(), R.color.text_EA3333));
view.setText(count + "");
} else {
ExtensionsKt.removeDrawable(view);
view.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
view.setTextColor(ContextCompat.getColor(view.getContext(), R.color.text_subtitleDesc));
view.setText("-");
}

View File

@ -29,8 +29,8 @@ import com.gh.gamecenter.common.utils.ImageUtils
import com.gh.gamecenter.databinding.DialogDeviceRemindBinding
import com.gh.gamecenter.entity.DeviceDialogEntity
import com.gh.gamecenter.entity.GameEntity
import com.gh.gamecenter.setting.view.GameDownloadSettingFragment
import com.google.gson.reflect.TypeToken
import com.gh.gamecenter.setting.GameDownloadSettingFragment.Companion.AUTO_INSTALL_SP_KEY
import com.lightgame.download.DataWatcher
import com.lightgame.download.DownloadEntity
import com.lightgame.download.DownloadStatus
@ -53,7 +53,7 @@ class DeviceRemindDialog(context: Context, val entity: DeviceDialogEntity, val g
private val dataWatcher = object : DataWatcher() {
override fun onDataChanged(downloadEntity: DownloadEntity) {
if (downloadEntity.status == DownloadStatus.done && downloadEntity.name == gameEntity.name) {
val autoInstall = SPUtils.getBoolean(GameDownloadSettingFragment.AUTO_INSTALL_SP_KEY, true)
val autoInstall = SPUtils.getBoolean(AUTO_INSTALL_SP_KEY, true)
if (autoInstall) {
dismiss()
}

View File

@ -13,11 +13,13 @@ import androidx.fragment.app.FragmentActivity
import androidx.fragment.app.FragmentTransaction
import com.gh.common.util.DirectUtils
import com.gh.gamecenter.R
import com.gh.gamecenter.WebActivity
import com.gh.gamecenter.common.base.fragment.BaseDialogFragment
import com.gh.gamecenter.common.utils.dip2px
import com.gh.gamecenter.common.view.CustomLinkMovementMethod
import com.gh.gamecenter.databinding.DialogPrivacyProtocolNewBinding
import com.gh.gamecenter.entity.DialogEntity
import splitties.bundle.put
class NewPrivacyPolicyDialogFragment : BaseDialogFragment() {
@ -159,7 +161,7 @@ class NewPrivacyPolicyDialogFragment : BaseDialogFragment() {
}
}
privacyDialogFragment.arguments = Bundle().apply {
putParcelable(KEY_DATA, privacyPolicyEntity)
put(KEY_DATA, privacyPolicyEntity)
}
privacyDialogFragment.show(
activity.supportFragmentManager,

View File

@ -303,7 +303,7 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
//安装、卸载事件
@Subscribe(threadMode = ThreadMode.MAIN)
fun onEventMainThread(busFour: EBPackage) {
if (busFour.isInstalledOrUninstalled()) {
if ("安装" == busFour.type || "卸载" == busFour.type) {
mAllInstalledPackages = PackageUtils.getInstalledPackages(HaloApp.getInstance().application, 0)
mAdapter?.notifyDataSetChanged()
}

View File

@ -23,6 +23,7 @@ import com.gh.gamecenter.core.utils.SPUtils
import com.gh.gamecenter.databinding.DialogPrivacyProtocolBinding
import com.gh.gamecenter.entity.DialogEntity
import com.lightgame.utils.AppManager
import splitties.bundle.put
class PrivacyPolicyDialogFragment : BaseDialogFragment() {
@ -183,7 +184,7 @@ class PrivacyPolicyDialogFragment : BaseDialogFragment() {
}
}
privacyDialogFragment.arguments = Bundle().apply {
putParcelable(KEY_DATA, privacyPolicyEntity)
put(KEY_DATA, privacyPolicyEntity)
}
privacyDialogFragment.show(
activity.supportFragmentManager,

View File

@ -29,7 +29,7 @@ data class ExposureEvent(
var timeInMillisecond: Long = System.currentTimeMillis(),
@PrimaryKey
var id: String = UUID.randomUUID().toString(),
) : Parcelable, Cloneable {
) : Parcelable {
@Transient
@IgnoredOnParcel
@ -45,9 +45,6 @@ data class ExposureEvent(
eTrace: List<ExposureEvent>? = null,
event: ExposureType = ExposureType.EXPOSURE
) {
if (gameEntity?.adIconActive == true) {
gameEntity.isAdData = true
}
this.payload = ExposureEntity(
gameId = gameEntity?.id?.getFirstElementDividedByDivider(DownloadEntity.GAME_ID_DIVIDER),
gameName = eTrace?.firstOrNull()?.payload?.gameName
@ -73,8 +70,7 @@ data class ExposureEvent(
welcomeDialogId = gameEntity?.welcomeDialogId
?: eTrace?.firstOrNull()?.payload?.welcomeDialogId,
welcomeDialogLinkTitle = gameEntity?.welcomeDialogTitle
?: eTrace?.firstOrNull()?.payload?.welcomeDialogLinkTitle,
isAdData = gameEntity?.isAdData ?: eTrace?.firstOrNull()?.payload?.isAdData ?: false
?: eTrace?.firstOrNull()?.payload?.welcomeDialogLinkTitle
)
this.id = UUID.randomUUID().toString()
this.timeInMillisecond = System.currentTimeMillis()
@ -127,10 +123,6 @@ data class ExposureEvent(
return flags == FLAG_IN_USE
}
fun deepCopy(): ExposureEvent {
return super.clone() as ExposureEvent
}
companion object {
private val sPoolSync = Any()
private var sPool: ExposureEvent? = null

View File

@ -6,13 +6,11 @@ object ExposureTraceUtils {
val traceList = arrayListOf<ExposureEvent>()
event?.let {
//这里使用deepCopy是为了防止循环引用调用hashCode方法触发StackOverflowError错误
val deepCopy = it.deepCopy()
if (deepCopy.eTrace == null) {
traceList.add(deepCopy)
if (event.eTrace == null) {
traceList.add(event)
} else {
traceList.addAll(deepCopy.eTrace!!)
traceList.add(flattenTrace(deepCopy))
traceList.addAll(event.eTrace!!)
traceList.add(flattenTrace(event))
}
}

View File

@ -18,7 +18,7 @@ import com.halo.assistant.HaloApp
@Database(
entities = [AnswerEntity::class, ArticleEntity::class, NewsEntity::class, HistoryGameEntity::class, MyVideoEntity::class, GamesCollectionEntity::class],
version = 12,
version = 11,
exportSchema = false
)
@TypeConverters(
@ -28,7 +28,6 @@ import com.halo.assistant.HaloApp
AnswerUserConverter::class,
ThumbnailConverter::class,
TagStyleListConverter::class,
TagStyleConverter::class,
StringArrayListConverter::class,
ListStringConverter::class,
CommunityVideoConverter::class,
@ -128,13 +127,6 @@ abstract class HistoryDatabase : RoomDatabase() {
}
}
val MIGRATION_11_12: Migration = object : Migration(11, 12) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("Alter TABLE HistoryGameEntity add subtitle TEXT NOT NULL DEFAULT ''")
database.execSQL("Alter TABLE HistoryGameEntity add subtitleStyle TEXT")
}
}
val instance by lazy {
Room.databaseBuilder(
HaloApp.getInstance().application,
@ -150,7 +142,6 @@ abstract class HistoryDatabase : RoomDatabase() {
.addMigrations(MIGRATION_8_9)
.addMigrations(MIGRATION_9_10)
.addMigrations(MIGRATION_10_11)
.addMigrations(MIGRATION_11_12)
.build()
}
}

View File

@ -71,8 +71,6 @@ object HistoryHelper {
historyGame.name = gameEntity.name
historyGame.tagStyle = gameEntity.tagStyle
historyGame.tag = gameEntity.getTag()
historyGame.subtitle = gameEntity.subtitle
historyGame.subtitleStyle = gameEntity.subtitleStyle
return historyGame
}

View File

@ -5,7 +5,6 @@ import com.alibaba.android.arouter.facade.annotation.Route
import com.gh.gamecenter.R
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.core.provider.IAppProvider
import com.gh.gamecenter.core.provider.IFlavorProvider
import com.halo.assistant.HaloApp
@Route(path = RouteConsts.provider.app, name = "Application暴露服务")
@ -34,10 +33,6 @@ class AppProviderImpl : IAppProvider {
return HaloApp.getInstance().channel ?: ""
}
override fun setChannel(channel: String) {
HaloApp.getInstance().channel = channel
}
override fun getUserAgent(): String {
return HaloApp.getInstance().userAgent ?: ""
}
@ -57,8 +52,4 @@ class AppProviderImpl : IAppProvider {
override fun isUserAcceptPrivacyPolicy(context: Context): Boolean {
return HaloApp.isUserAcceptPrivacyPolicy(context)
}
override fun getFlavorProvider(): IFlavorProvider {
return HaloApp.getInstance().flavorProvider
}
}

View File

@ -1,23 +0,0 @@
package com.gh.common.provider
import android.content.Context
import com.alibaba.android.arouter.facade.annotation.Route
import com.gh.download.server.BrowserInstallHelper
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.core.provider.IBrowserInstallHelperProvider
@Route(path = RouteConsts.provider.browserInstallHelper, name = "BrowserInstallHelper暴露服务")
class BrowserInstallHelperProviderImpl : IBrowserInstallHelperProvider {
override fun isUseBrowserToInstallEnabled(): Boolean = BrowserInstallHelper.isUseBrowserToInstallEnabled()
override fun shouldUseBrowserToInstall(): Boolean = BrowserInstallHelper.shouldUseBrowserToInstall()
override fun logSwitchInstallSettingEvent() {
BrowserInstallHelper.logOrdinaryBrowserEvent(BrowserInstallHelper.Type.SWITCH_INSTALL_SETTING)
}
override fun init(context: Context?) {
// Do nothing
}
}

View File

@ -72,10 +72,6 @@ class ConfigProviderImpl : IConfigProvider {
return Config.WEIBO_APPKEY
}
override fun getNightModeSetting(): Boolean {
return Config.getNightModeSetting()?.setting ?: false
}
override fun init(context: Context?) {
// Do nothing
}

View File

@ -1,6 +1,5 @@
package com.gh.common.provider
import android.app.Dialog
import android.content.Context
import com.alibaba.android.arouter.facade.annotation.Route
import com.gh.common.util.DialogUtils
@ -23,46 +22,6 @@ class DialogUtilsProviderImpl : IDialogUtilsProvider {
})
}
override fun showWaitDialog(context: Context, string: String): Dialog = DialogUtils.showWaitDialog(context, string)
override fun showForceDialog(
context: Context,
title: String,
message: CharSequence,
positive: String,
negative: String,
confirm: () -> Unit,
cancel: () -> Unit
) {
DialogUtils.showForceDialog(context, title, message, positive, negative,
{ confirm.invoke() }, object :CancelListener{
override fun onCancel() {
cancel.invoke()
}
})
}
override fun showUsageStatsDialog(context: Context, confirm: () -> Unit, cancel: () -> Unit) {
DialogUtils.showUsageStatsDialog(context,
{ confirm.invoke() }, object :CancelListener{
override fun onCancel() {
cancel.invoke()
}
})
}
override fun showNoticeDialog(
context: Context,
title: String,
content: String,
confirm: () -> Unit
) {
DialogUtils.showNoticeDialog(context, title, content
) { confirm.invoke() }
}
override fun showBindPhoneDialog(context: Context, confirm: () -> Unit): Dialog = DialogUtils.showBindPhoneDialog(context) { confirm.invoke() }
override fun init(context: Context?) {
// Do nothing
}

View File

@ -49,14 +49,6 @@ class DirectProviderImpl : IDirectProvider {
DirectUtils.directToLotteryParadisePage(context)
}
override fun directDouyin(context: Context, userId: String) {
DirectUtils.directDouyin(context, userId)
}
override fun directToSuggestionFromDiagnosis(context: Context, diagnosis: String) {
DirectUtils.directToSuggestion(context, diagnosis = diagnosis)
}
override fun init(context: Context?) {
// Do nothing
}

View File

@ -1,18 +0,0 @@
package com.gh.common.provider
import android.content.Context
import com.alibaba.android.arouter.facade.annotation.Route
import com.gh.common.history.HistoryHelper
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.core.provider.IHistoryHelperProvider
@Route(path = RouteConsts.provider.historyHelper, name = "HistoryHelper暴露服务")
class HistoryHelperProviderImpl : IHistoryHelperProvider {
override fun emptyDatabase() {
HistoryHelper.emptyDatabase()
}
override fun init(context: Context?) {
// Do nothing
}
}

View File

@ -1,20 +0,0 @@
package com.gh.common.provider
import android.content.Context
import android.content.Intent
import com.alibaba.android.arouter.facade.annotation.Route
import com.gh.gamecenter.MainActivity
import com.gh.gamecenter.WebActivity
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.core.provider.IMainProvider
@Route(path = RouteConsts.provider.mainActivity, name = "MainActivity暴露服务")
class MainProviderImpl : IMainProvider {
override fun skipToMainActivity(context: Context, position: Int) {
MainActivity.skipToMainActivity(context, position)
}
override fun init(context: Context?) {
// Do nothing
}
}

View File

@ -1,19 +0,0 @@
package com.gh.common.provider
import android.content.Context
import android.content.Intent
import android.os.Parcelable
import com.alibaba.android.arouter.facade.annotation.Route
import com.gh.gamecenter.ShellActivity
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.core.provider.IShellProvider
@Route(path = RouteConsts.provider.shellActivity, name = "ShellActivity暴露服务")
class ShellProviderImpl : IShellProvider {
override fun getSwitchInstallMethodIntent(context: Context, extraParcelable: Parcelable?): Intent =
ShellActivity.getIntent(context, ShellActivity.Type.SWITCH_INSTALL_METHOD, extraParcelable)
override fun init(context: Context?) {
// Do nothing
}
}

View File

@ -1,19 +0,0 @@
package com.gh.common.provider
import android.content.Context
import android.os.Handler
import com.alibaba.android.arouter.facade.annotation.Route
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.core.provider.IUpdateManagerProvider
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) {
UpdateManager.getInstance(context).checkUpdate(isAutoCheck, handler)
}
override fun init(context: Context?) {
// Do nothing
}
}

View File

@ -1,23 +0,0 @@
package com.gh.common.provider
import android.content.Context
import android.os.Build
import androidx.annotation.RequiresApi
import com.alibaba.android.arouter.facade.annotation.Route
import com.gh.common.util.UsageStatsHelper
import com.gh.common.util.WechatBindHelper
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.core.provider.IUsageStatsHelperProvider
@Route(path = RouteConsts.provider.usageStatsHelper, name = "UsageStatsHelper暴露服务")
class UsageStatsHelperProviderImpl : IUsageStatsHelperProvider {
@RequiresApi(Build.VERSION_CODES.LOLLIPOP_MR1)
override fun checkForPermission(): Boolean = UsageStatsHelper.checkForPermission()
override fun skipToUsageStats(context: Context, requestCode: Int) {
UsageStatsHelper.skipToUsageStats(context, requestCode)
}
override fun init(context: Context?) {
// Do nothing
}
}

View File

@ -17,14 +17,6 @@ class WebProviderImpl : IWebProvider {
return WebActivity.getWebIntent(context, title, url)
}
override fun getBindWechatIntent(context: Context): Intent {
return WebActivity.getBindWechatIntent(context)
}
override fun getSecurityCertificationIntent(context: Context): Intent {
return WebActivity.getSecurityCertificationIntent(context)
}
override fun init(context: Context?) {
// Do nothing
}

View File

@ -8,10 +8,8 @@ import com.gh.gamecenter.core.provider.IWechatBindHelperProvider
@Route(path = RouteConsts.provider.wechatHelper, name = "WechatHelper暴露服务")
class WechatHelperProviderImpl : IWechatBindHelperProvider {
override fun getWechatConfig(callback: (() -> Unit)?) {
WechatBindHelper.getWechatConfig {
callback?.invoke()
}
override fun getWechatConfig() {
WechatBindHelper.getWechatConfig()
}
override fun init(context: Context?) {

View File

@ -138,7 +138,6 @@ class SimulatorDownloadManager private constructor() {
cancelCallback: (() -> Unit)? = null
) {
if (context == null) return
this.simulatorLocation = location
this.simulator = simulator
this.gameId = gameId
@ -146,31 +145,21 @@ class SimulatorDownloadManager private constructor() {
PermissionHelper.checkGetInstalledAppsListBeforeAction(context, object : EmptyCallback {
override fun onCallback() {
val isInstalledNewSimulator =
SimulatorGameManager.isNewSimulatorInstalled(HaloApp.getInstance().application)
//当没有安装新版本模拟器时候 判断是否隐藏
if (simulator?.active == false && !isInstalledNewSimulator) {
//判断是否隐藏
if (simulator?.active == false) {
showNoneEmulatorDialog(context)
return
}
var isInstalled = PackageUtils.isInstalledFromAllPackage(
context,
simulator?.apk?.packageName
)
//模拟器管理界面还是用之前的逻辑
if (isInstalledNewSimulator && location != SimulatorLocation.SIMULATOR_MANAGE) {
isInstalled = isInstalledNewSimulator
}
val isInstalled = PackageUtils.isInstalledFromAllPackage(context, simulator?.apk?.packageName)
// val versionFromInstalledApp = PackageUtils.getVersionNameByPackageName(simulator?.apk?.packageName)
val shouldShowUpdate =
PackageUtils.isInstalledApkMatchedMd5(simulator?.apk?.packageName, simulator?.apk?.md5)
val shouldShowUpdate = PackageUtils.isInstalledApkMatchedMd5(simulator?.apk?.packageName, simulator?.apk?.md5)
val showAlertTag = SPUtils.getString(SimulatorGameManager.SIMULATOR_UPDATE_SHOW_ALERT_TAG, "") //当天是否弹过
val todayIsShow = showAlertTag == TimeUtils.getToday()
downloadType = if (shouldShowUpdate && isInstalled) "update" else "download"
if (downloadType == "update" && todayIsShow && location != SimulatorLocation.SIMULATOR_MANAGE) {
if (downloadType == "update" && todayIsShow && location != SimulatorLocation.SIMULATOR_MANAGE){
return
}
if (downloadType == "download" && isInstalled) {
if (downloadType == "download" && isInstalled){
return
}
val title = if (shouldShowUpdate && isInstalled) "更新模拟器" else "安装模拟器"

View File

@ -1,15 +1,15 @@
package com.gh.common.util
import android.annotation.SuppressLint
import androidx.lifecycle.MutableLiveData
import com.gh.common.constant.Config
import com.gh.gamecenter.common.retrofit.Response
import com.gh.gamecenter.common.utils.ImageUtils
import com.gh.gamecenter.common.utils.observableToMain
import com.gh.gamecenter.core.utils.DisplayUtils
import com.gh.gamecenter.entity.NewApiSettingsEntity
import com.gh.gamecenter.common.utils.NetworkUtils
import com.gh.gamecenter.entity.SettingsEntity
import com.gh.gamecenter.entity.StartupAdEntity
import com.gh.gamecenter.common.retrofit.BiResponse
import com.gh.gamecenter.retrofit.RetrofitManager
import com.halo.assistant.HaloApp
import io.reactivex.schedulers.Schedulers
object AdHelper {
@ -19,40 +19,24 @@ object AdHelper {
const val LOCATION_SUGGESTION_FUNCTION = "suggestion_function"
const val LOCATION_SIMULATOR_GAME = "simulator_game"
@JvmStatic
fun getStartUpAd(): StartupAdEntity? {
return Config.getNewApiSettingsEntity()?.startAd
}
@JvmField
var startupAd = MutableLiveData<StartupAdEntity>()
@JvmStatic
fun getStartUp(): StartupAdEntity? {
return Config.getNewApiSettingsEntity()?.startup
}
@JvmStatic
fun prefetchStartUpAd(settingsEntity: NewApiSettingsEntity) {
if (settingsEntity.startAd != null && !settingsEntity.startAd?.img.isNullOrEmpty()) {
val screenWidth = DisplayUtils.getScreenWidth()
val transformedUrl = ImageUtils.getTransformedUrl(settingsEntity.startAd?.img, screenWidth) ?: return
ImageUtils.prefetchToDiskCache(transformedUrl)
@SuppressLint("CheckResult")
fun getStartUpAd() {
if (!NetworkUtils.isNetworkConnected(HaloApp.getInstance())) {
startupAd.postValue(null)
return
}
}
fun getSettingAdCache() {
RetrofitManager.getInstance().newApi
.getSettingAdCache(HaloApp.getInstance().channel)
.compose(observableToMain())
.subscribe(object : Response<NewApiSettingsEntity>() {
override fun onResponse(response: NewApiSettingsEntity?) {
super.onResponse(response)
val settings = Config.getNewApiSettingsEntity()
if (settings != null) {
settings.startAd = response?.startAd
Config.updateNewApiSettings(settings)
if (response != null) {
prefetchStartUpAd(response)
}
}
RetrofitManager.getInstance()
.api
.getSplashAd(HaloApp.getInstance().channel)
.subscribeOn(Schedulers.io())
.subscribe(object : BiResponse<StartupAdEntity>() {
override fun onSuccess(data: StartupAdEntity) {
startupAd.postValue(data)
}
})
}

View File

@ -1,250 +0,0 @@
package com.gh.common.util
import android.app.Dialog
import android.content.Context
import android.view.View
import android.view.Window
import android.widget.TextView
import androidx.fragment.app.Fragment
import com.gh.download.simple.AutoUnregisteredSimpleDownloadListener
import com.gh.download.simple.DownloadListener
import com.gh.gamecenter.R
import com.gh.gamecenter.common.eventbus.EBReuse
import com.gh.gamecenter.common.utils.DialogHelper
import com.gh.gamecenter.common.utils.dip2px
import com.gh.gamecenter.common.utils.roundTo
import com.gh.gamecenter.common.utils.toResString
import com.gh.gamecenter.core.utils.DisplayUtils
import com.gh.gamecenter.core.utils.ToastUtils
import com.gh.gamecenter.databinding.DialogArchiveLoadingBinding
import com.gh.gamecenter.entity.ArchiveEntity
import com.gh.gamecenter.retrofit.RetrofitManager
import com.gh.vspace.VArchiveHelper
import com.gh.vspace.VHelper
import com.lg.download.DownloadError
import com.lg.download.DownloadStatus
import io.reactivex.schedulers.Schedulers
import org.greenrobot.eventbus.EventBus
import splitties.systemservices.layoutInflater
/**
* 云存档下载按钮辅助类
*/
object ArchiveDownloadButtonHelper {
fun bindItem(
context: Context,
entrance: String,
fragment: Fragment,
packageName: String,
archiveEntity: ArchiveEntity,
downloadBtn: TextView,
downloadCompletedListener: (() -> Unit)? = null
) {
downloadBtn.text = if (VArchiveHelper.isArchiveDownloaded(archiveEntity.md5)) {
R.string.archive_apply.toResString()
} else {
R.string.archive_download.toResString()
}
downloadBtn.setOnClickListener {
when {
// 检查是否已安装畅玩助手
!VHelper.isVSpaceInstalled(context) -> showVspaceTipDialog(context)
// 检查是否已安装游戏
!VHelper.isInstalled(packageName) -> {
// 检查游戏是否在安装中
if (!VHelper.isInstalling(packageName)) {
showDownloadTipDialog(context)
} else {
ToastUtils.toast("游戏正在安装中,请稍候")
}
}
// 检查本地是否已下载存档
VArchiveHelper.isArchiveDownloaded(archiveEntity.md5) -> showApplyArchiveTipDialog(
context,
entrance,
packageName,
archiveEntity
)
// 检查完毕下载存档
else -> downloadArchive(
context,
entrance,
fragment,
packageName,
archiveEntity,
downloadBtn,
downloadCompletedListener
)
}
}
}
private fun showVspaceTipDialog(context: Context) {
NewFlatLogUtils.logCloudArchiveVSpaceDownloadDialogShow()
DialogHelper.showDialog(
context,
R.string.archive_dialog_title.toResString(),
R.string.archive_vspace_dialog_content.toResString(),
R.string.archive_vspace_dialog_confirm.toResString(),
R.string.cancel.toResString(),
{
NewFlatLogUtils.logCloudArchiveVSpaceDownloadDialogClick(R.string.archive_vspace_dialog_confirm.toResString())
VHelper.showVspaceDialog(context)
},
{
NewFlatLogUtils.logCloudArchiveVSpaceDownloadDialogClick(R.string.cancel.toResString())
},
extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true)
)
}
private fun showDownloadTipDialog(context: Context) {
NewFlatLogUtils.logCloudArchiveGameDownloadDialogShow()
DialogHelper.showDialog(
context,
R.string.archive_dialog_title.toResString(),
R.string.archive_download_dialog_content.toResString(),
R.string.archive_download_dialog_confirm.toResString(),
R.string.cancel.toResString(),
{
NewFlatLogUtils.logCloudArchiveGameDownloadDialogClick(R.string.archive_download_dialog_confirm.toResString())
VHelper.disableLaunchGameAfterInstallation()
EventBus.getDefault().post(EBReuse("download"))
},
{
NewFlatLogUtils.logCloudArchiveGameDownloadDialogClick(R.string.cancel.toResString())
},
extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true)
)
}
private fun applyArchive(
context: Context,
entrance: String,
packageName: String,
archiveEntity: ArchiveEntity
) {
VArchiveHelper.getArchiveFile(archiveEntity.md5)?.run {
RetrofitManager.getInstance().newApi
.postArchiveUsage(archiveEntity.gameId, archiveEntity.id)
.subscribeOn(Schedulers.io())
.subscribe()
VArchiveHelper.applyGameArchive(context, packageName, this) { packageName, isSuccess ->
if (isSuccess) {
VHelper.launch(context, packageName)
} else {
ToastUtils.toast(R.string.archive_apply_fail.toResString())
}
}
}
NewFlatLogUtils.logCloudArchiveDownloadOrApply(archiveEntity.name, entrance)
}
private fun downloadArchive(
context: Context,
entrance: String,
fragment: Fragment,
packageName: String,
archiveEntity: ArchiveEntity,
downloadBtn: TextView,
downloadCompletedListener: (() -> Unit)? = null
) {
// 执行下载
VArchiveHelper.downloadArchive(archiveEntity)
// 下载进度弹窗
val archiveLoadingDialog = Dialog(context, R.style.DialogWindowTransparent)
val archiveLoadingBinding = DialogArchiveLoadingBinding.inflate(context.layoutInflater)
showArchiveLoadingDialog(archiveLoadingDialog, archiveLoadingBinding.root)
// 下载进度监听
AutoUnregisteredSimpleDownloadListener(archiveEntity.id, fragment, object : DownloadListener {
override fun onError(error: DownloadError) {
dismissArchiveLoadingDialog(archiveLoadingDialog)
ToastUtils.toast(R.string.archive_download_fail.toResString())
}
override fun onProgress(progress: Float) {
archiveLoadingBinding.run {
progressTv.text = "${progress.roundTo(1)}%"
progressBar.progress = progress.toInt()
}
}
override fun onSizeReceived(fileSize: Long) {
// Do nothing
}
override fun onStatusChanged(status: DownloadStatus) {
when (status) {
DownloadStatus.COMPLETED -> {
dismissArchiveLoadingDialog(archiveLoadingDialog)
downloadBtn.text = R.string.archive_apply.toResString()
showApplyArchiveTipDialog(context, entrance, packageName, archiveEntity)
downloadCompletedListener?.invoke()
}
else -> {
// Do nothing
}
}
}
override fun onSpeedChanged(speed: Float) {
// Do nothing
}
})
NewFlatLogUtils.logCloudArchiveDownloadOrApply(archiveEntity.name, entrance)
}
private fun showArchiveLoadingDialog(
archiveLoadingDialog: Dialog,
contentView: View
) {
archiveLoadingDialog.run {
setCancelable(false)
setCanceledOnTouchOutside(false)
requestWindowFeature(Window.FEATURE_NO_TITLE)
setContentView(contentView)
show()
}
archiveLoadingDialog.window?.attributes?.apply {
width = DisplayUtils.getScreenWidth() - 120F.dip2px()
archiveLoadingDialog.window?.attributes = this
}
}
private fun showApplyArchiveTipDialog(
context: Context,
entrance: String,
packageName: String,
archiveEntity: ArchiveEntity
) {
DialogHelper.showDialog(
context,
R.string.archive_dialog_title.toResString(),
R.string.archive_apply_dialog_content.toResString(),
R.string.archive_apply.toResString(),
R.string.cancel.toResString(),
{
applyArchive(context, entrance, packageName, archiveEntity)
NewFlatLogUtils.logCloudArchiveApplyDialogRelated("cloud_save_overwrite_dialog_click", "使用")
},
{ NewFlatLogUtils.logCloudArchiveApplyDialogRelated("cloud_save_overwrite_dialog_click", "取消") },
extraConfig = DialogHelper.Config(centerTitle = true)
)
NewFlatLogUtils.logCloudArchiveApplyDialogRelated("cloud_save_overwrite_dialog_show")
}
private fun dismissArchiveLoadingDialog(archiveLoadingDialog: Dialog) {
if (archiveLoadingDialog.isShowing) {
archiveLoadingDialog.dismiss()
}
}
}

View File

@ -2,14 +2,17 @@ package com.gh.common.util;
import android.annotation.SuppressLint;
import android.app.Application;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.net.Uri;
import android.os.Build;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.util.Log;
import com.gh.base.GlobalActivityManager;
import com.gh.gamecenter.BuildConfig;
import com.gh.gamecenter.common.base.activity.BaseActivity;
import com.gh.gamecenter.common.constant.Constants;
@ -123,16 +126,6 @@ public class DataUtils {
// 避免初始化顺序问题导致 MetaUtil 一直持有空的 gid
MetaUtil.INSTANCE.refreshMeta();
ContentValues values = new ContentValues();
values.put(GhContentProvider.KEY_GID, gid);
values.put(GhContentProvider.KEY_ANDROID_ID, MetaUtil.getBase64EncodedAndroidId());
try {
HaloApp.getInstance().getContentResolver().insert(Uri.parse("content://com.gh.gamecenter.provider/device"), values);
} catch (Exception exception) {
SentryHelper.INSTANCE.onEvent("DEVICE_INSERT_ERROR", "exception_digest", exception.getLocalizedMessage());
exception.printStackTrace();
}
}
@Override

View File

@ -15,14 +15,12 @@ import com.gh.download.DownloadManager;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.viewholder.DetailViewHolder;
import com.gh.gamecenter.common.constant.Constants;
import com.gh.gamecenter.common.entity.LinkEntity;
import com.gh.gamecenter.common.utils.ExtensionsKt;
import com.gh.gamecenter.core.utils.SPUtils;
import com.gh.gamecenter.common.entity.LinkEntity;
import com.gh.gamecenter.entity.PluginLocation;
import com.gh.gamecenter.manager.PackagesManager;
import com.gh.vspace.VHelper;
import com.lightgame.download.DownloadEntity;
import com.lightgame.download.DownloadStatus;
/**
* Created by khy on 27/06/17.
@ -38,10 +36,6 @@ public class DetailDownloadUtils {
viewHolder.getOverlayTv().setVisibility(View.GONE);
}
if (viewHolder.mMultiVersionDownloadTv != null) {
viewHolder.mMultiVersionDownloadTv.setVisibility(View.GONE);
}
if (viewHolder.gameEntity != null
&& Config.isShowDownload(viewHolder.gameEntity.getId())
&& !"光环助手".equals(viewHolder.gameEntity.getName())) {
@ -177,34 +171,8 @@ public class DetailDownloadUtils {
}
viewHolder.mDownloadPb.setText(downloadText);
} else {
viewHolder.mMultiVersionDownloadTv.setText("选择下载你的版本" + (TextUtils.isEmpty(downloadAddWord) ? "" : "-" + downloadAddWord));
viewHolder.mMultiVersionDownloadTv.setVisibility(View.VISIBLE);
viewHolder.mDownloadPb.setText("");
viewHolder.mDownloadPb.setText("选择下载你的版本" + (TextUtils.isEmpty(downloadAddWord) ? "" : "-" + downloadAddWord) + " >");
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.NORMAL);
DownloadEntity downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(viewHolder.gameEntity);
if (downloadEntity != null) {
switch (downloadEntity.getStatus()) {
case downloading:
viewHolder.mDownloadTips.setVisibility(View.VISIBLE);
ExtensionsKt.setDownloadTipsAnimation(viewHolder.mDownloadTips, true);
break;
case done:
case pause:
case waiting:
case timeout:
case subscribe:
case neterror:
case overflow:
viewHolder.mDownloadTips.setVisibility(View.VISIBLE);
ExtensionsKt.setDownloadTipsAnimation(viewHolder.mDownloadTips, false);
break;
default:
viewHolder.mDownloadTips.setVisibility(View.GONE);
break;
}
} else {
viewHolder.mDownloadTips.setVisibility(View.GONE);
}
}
if (isCheck && viewHolder.gameEntity.getApk().size() == 1) {
@ -235,14 +203,10 @@ public class DetailDownloadUtils {
if (XapkUnzipStatus.UNZIPPING.name().equals(xapkStatus)) {
String percent = downloadEntity.getMeta().get(XapkInstaller.XAPK_UNZIP_PERCENT);
viewHolder.mDownloadPb.setText("游戏解压中 " + percent + "%");
viewHolder.mDownloadPb.setText("解压中" + percent + "%");
viewHolder.mDownloadPb.setProgress((int) (Float.valueOf(percent) * 10));
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.XAPK_UNZIPPING);
return;
} else if (XapkUnzipStatus.FAILURE.name().equals(xapkStatus)) {
viewHolder.mDownloadPb.setText(R.string.install);
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.XAPK_FAILURE);
return;
}
viewHolder.mDownloadPb.setProgress((int) (viewHolder.downloadEntity.getPercent() * 10));
@ -256,28 +220,29 @@ public class DetailDownloadUtils {
}
switch (downloadEntity.getStatus()) {
case timeout:
case neterror:
case subscribe:
case downloading:
case redirected:
case pause:
case overflow:
String downloadingText = "游戏加载中 " + downloadEntity.getPercent() + "%";
String resumeText = "继续加载 " + downloadEntity.getPercent() + "%";
viewHolder.mDownloadPb.setText((downloadEntity.getStatus() == DownloadStatus.downloading || downloadEntity.getStatus() == DownloadStatus.redirected) ? downloadingText : resumeText);
if (SPUtils.getBoolean(Constants.SP_USE_BROWSER_TO_INSTALL)) {
viewHolder.mDownloadPb.setText(R.string.browser_install_downloading);
} else {
viewHolder.mDownloadPb.setText(R.string.downloading);
}
if (downloadEntity.isPluggable() && PackagesManager.INSTANCE.isInstalled(downloadEntity.getPackageName())) {
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_PLUGIN);
} else {
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_NORMAL);
}
break;
case timeout:
case neterror:
case waiting:
case subscribe:
viewHolder.mDownloadPb.setText(R.string.waiting);
if (downloadEntity.isPluggable() && PackagesManager.INSTANCE.isInstalled(downloadEntity.getPackageName())) {
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.WAITING);
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_PLUGIN);
} else {
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.WAITING);
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_NORMAL);
}
break;
case done:
@ -339,19 +304,18 @@ public class DetailDownloadUtils {
private static void updateVStyleButton(DetailViewHolder viewHolder) {
switch (viewHolder.downloadEntity.getStatus()) {
case redirected:
case downloading:
case overflow:
viewHolder.mDownloadPb.setText("游戏加载中 " + viewHolder.downloadEntity.getPercent() + "%");
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_NORMAL);
break;
case timeout:
case neterror:
case waiting:
case subscribe:
viewHolder.mDownloadPb.setText(R.string.waiting);
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_NORMAL);
break;
case overflow:
case timeout:
case neterror:
case subscribe:
case pause:
viewHolder.mDownloadPb.setText("继续加载 " + viewHolder.downloadEntity.getPercent() + "%");
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_NORMAL);

View File

@ -6,10 +6,13 @@ import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.CountDownTimer;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.text.Html;
import android.text.Spannable;
@ -92,8 +95,8 @@ import com.gh.gamecenter.entity.SettingsEntity;
import com.gh.gamecenter.entity.SimpleGameEntity;
import com.gh.gamecenter.entity.TrackableEntity;
import com.gh.gamecenter.login.entity.Badge;
import com.gh.gamecenter.setting.view.GameDownloadSettingFragment;
import com.gh.gamecenter.setting.view.security.BindPhoneActivity;
import com.gh.gamecenter.security.BindPhoneActivity;
import com.gh.gamecenter.setting.GameDownloadSettingFragment;
import com.gh.gamecenter.suggest.SuggestType;
import com.lightgame.adapter.BaseRecyclerAdapter;
import com.lightgame.download.DownloadEntity;
@ -1251,6 +1254,38 @@ public class DialogUtils {
dialog.show();
}
public static void showVersionNumberDialog(Context context, GameEntity gameEntity, @NonNull ConfirmListener listener) {
context = checkDialogContext(context);
if (!gameEntity.isShowVersionNumber()) {
listener.onConfirm();
} else {
final Dialog dialog = new Dialog(context, R.style.GhAlertDialog);
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_version_number, null);
TextView contentTv = contentView.findViewById(R.id.contentTv);
TextView cancelTv = contentView.findViewById(R.id.cancelTv);
TextView continueTv = contentView.findViewById(R.id.continueTv);
contentTv.setText(gameEntity.getVersionNumberString());
cancelTv.setOnClickListener(v -> dialog.dismiss());
continueTv.setOnClickListener(v -> {
listener.onConfirm();
dialog.dismiss();
});
Window window = dialog.getWindow();
if (window != null) {
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(contentView);
dialog.show();
}
}
// 海外下载地址弹窗
public static void showOverseaDownloadDialog(Context context, GameEntity gameEntity, @NonNull ConfirmListener listener) {
context = checkDialogContext(context);
@ -1585,7 +1620,7 @@ public class DialogUtils {
TextView commitTv = view.findViewById(R.id.commitTv);
Context finalContext = context;
//添加透明阴影,实现类似 clipPadding=false 效果
complaintCommentEt.setShadowLayer(complaintCommentEt.getExtendedPaddingBottom(), 0F, 0F, Color.TRANSPARENT);
complaintCommentEt.setShadowLayer(complaintCommentEt.getExtendedPaddingBottom(), 0f, 0f, Color.TRANSPARENT);
ExtensionsKt.setTextChangedListener(complaintCommentEt, (s, start, before, count) -> {
commitTv.setTextColor(ContextCompat.getColor(finalContext, s.toString().trim().isEmpty() ? R.color.text_subtitleDesc : R.color.theme_font));
@ -1595,7 +1630,7 @@ public class DialogUtils {
for (String option : options) {
TextView reportTv = new TextView(context);
reportTv.setText(option);
reportTv.setTextSize(16F);
reportTv.setTextSize(16f);
if (disabledOptions != null && disabledOptions.contains(option)) {
reportTv.setTextColor(ContextCompat.getColor(context, R.color.btn_gray));
} else {
@ -1604,10 +1639,12 @@ public class DialogUtils {
}
reportTv.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
reportTv.setPadding(DisplayUtils.dip2px(context, 20F), DisplayUtils.dip2px(context, 17F),
DisplayUtils.dip2px(context, 20F), DisplayUtils.dip2px(context, 17F));
reportTv.setPadding(DisplayUtils.dip2px(context, 20f), DisplayUtils.dip2px(context, 17f),
DisplayUtils.dip2px(context, 20f), DisplayUtils.dip2px(context, 17f));
if (option.equals("其它")) {
ExtensionsKt.setDrawableEnd(reportTv, R.drawable.ic_complaint_arrow_right, DisplayUtils.dip2px(6F), DisplayUtils.dip2px(6F));
Drawable drawable = ContextCompat.getDrawable(context, R.drawable.ic_complaint_arrow_right);
drawable.setBounds(0, 0, DisplayUtils.dip2px(6f), DisplayUtils.dip2px(10f));
reportTv.setCompoundDrawables(null, null, drawable, null);
}
complaintContainer.addView(reportTv);
@ -1870,21 +1907,13 @@ public class DialogUtils {
}
}
public static void showReportReasonDialog(Context context, ArrayList<String> items, ReportReasonCallBack callBack) {
showReportReasonDialog(context, items, "", callBack);
}
@SuppressLint("SetTextI18n")
public static void showReportReasonDialog(Context context, ArrayList<String> items, String title, ReportReasonCallBack callBack) {
public static void showReportReasonDialog(Context context, ArrayList<String> items, ReportReasonCallBack callBack) {
context = checkDialogContext(context);
final Dialog dialog = new Dialog(context, R.style.DialogWindowTransparent);
DialogReportReasonBinding binding = DialogReportReasonBinding.inflate(LayoutInflater.from(context));
if (!title.isEmpty()) {
binding.reasonTitle.setText(title);
}
ReportReasonAdapter reportReasonAdapter = new ReportReasonAdapter(context, items, reason -> {
if (reason.equals("其他原因")) {
binding.reasonTitle.setText(R.string.report_reason_other_title);
@ -2016,7 +2045,7 @@ public class DialogUtils {
binding.confirmTv.setText("我知道了");
binding.centerDivider.setVisibility(View.GONE);
binding.cancelTv.setVisibility(View.GONE);
ExtensionsKt.setDrawableStart(binding.titleTv, R.drawable.ic_reserve_success, null, null);
binding.titleTv.setCompoundDrawablesWithIntrinsicBounds(ExtensionsKt.toDrawable(R.drawable.ic_reserve_success), null, null, null);
binding.confirmTv.setOnClickListener(v -> dialog.dismiss());
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(binding.getRoot());

View File

@ -9,33 +9,32 @@ import android.os.Build
import android.os.Bundle
import android.text.TextUtils
import androidx.appcompat.app.AppCompatActivity
import com.gh.gamecenter.common.base.activity.BaseActivity
import com.gh.gamecenter.common.base.activity.BaseActivity_TabLayout
import com.gh.gamecenter.common.base.activity.ToolBarActivity
import com.gh.gamecenter.common.base.fragment.BaseFragment_TabLayout
import com.gh.gamecenter.core.AppExecutor
import com.gh.common.constant.Config
import com.gh.gamecenter.common.constant.Constants
import com.gh.common.exposure.ExposureEvent
import com.gh.common.exposure.ExposureEvent.Companion.createEvent
import com.gh.common.exposure.ExposureManager.log
import com.gh.common.exposure.ExposureTraceUtils.appendTrace
import com.gh.common.exposure.ExposureType
import com.gh.common.util.EntranceUtils.jumpActivity
import com.gh.gamecenter.common.constant.EntranceConsts.*
import com.gh.common.util.EntranceUtils.*
import com.gh.gamecenter.*
import com.gh.gamecenter.amway.AmwayActivity
import com.gh.gamecenter.catalog.CatalogActivity
import com.gh.gamecenter.category.CategoryDirectoryActivity
import com.gh.gamecenter.category2.CategoryV2Activity
import com.gh.gamecenter.common.base.activity.BaseActivity
import com.gh.gamecenter.common.base.activity.BaseActivity_TabLayout
import com.gh.gamecenter.common.base.activity.ToolBarActivity
import com.gh.gamecenter.common.base.fragment.BaseFragment_TabLayout
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.constant.EntranceConsts.*
import com.gh.gamecenter.common.entity.CommunityEntity
import com.gh.gamecenter.common.entity.Display
import com.gh.gamecenter.common.entity.LinkEntity
import com.gh.gamecenter.common.retrofit.Response
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.core.AppExecutor
import com.gh.gamecenter.core.utils.ToastUtils
import com.gh.gamecenter.discovery.DiscoveryActivity
import com.gh.gamecenter.download.DownloadFragment.Companion.INDEX_UPDATE
import com.gh.gamecenter.entity.*
import com.gh.gamecenter.eventbus.EBSkip
@ -63,10 +62,9 @@ import com.gh.gamecenter.qa.questions.newdetail.NewQuestionDetailActivity
import com.gh.gamecenter.qa.subject.CommunitySubjectActivity
import com.gh.gamecenter.qa.video.detail.ForumVideoDetailActivity
import com.gh.gamecenter.retrofit.RetrofitManager
import com.gh.gamecenter.security.BindPhoneActivity
import com.gh.gamecenter.servers.GameServerTestActivity
import com.gh.gamecenter.servers.GameServersActivity
import com.gh.gamecenter.setting.view.security.BindPhoneActivity
import com.gh.gamecenter.setting.view.SettingActivity
import com.gh.gamecenter.subject.SubjectActivity
import com.gh.gamecenter.suggest.SuggestType
import com.gh.gamecenter.tag.TagsActivity
@ -145,7 +143,6 @@ object DirectUtils {
directToLinkPage(context, linkEntity, entrance, path, null)
}
@JvmStatic
fun directToLinkPage(
context: Context,
linkEntity: LinkEntity,
@ -184,8 +181,7 @@ object DirectUtils {
"common_collection",
"game_list",
"game_list_detail",
"bbs_video",
"explore_column"
"bbs_video"
)
fun directToLinkPage(
@ -438,8 +434,6 @@ object DirectUtils {
"game_list_detail" -> directToGameCollectionDetail(context, linkEntity.link ?: "", entrance)
"explore_column" -> context.startActivity(DiscoveryActivity.getIntent(context, entrance))
"" -> {
// do nothing
}
@ -591,21 +585,19 @@ object DirectUtils {
entrance: String? = null,
path: String? = null
) {
directToHomeActivity(context, userId, "", "", position, entrance, path)
directToHomeActivity(context, userId, "", position, entrance, path)
}
/**
* 跳转至个人主页
* @param position 定位到某个tab 0游戏 1发布
* @param type 类型 (发布)
* @param game_type 类型 (游戏)
* @param type 类型
*/
@JvmStatic
fun directToHomeActivity(
context: Context,
userId: String? = "",
type: String? = "",
game_type: String? = "",
position: Int? = 0,
entrance: String? = null,
path: String? = null
@ -618,7 +610,6 @@ object DirectUtils {
bundle.putString(KEY_ENTRANCE, BaseActivity.mergeEntranceAndPath(entrance, path))
bundle.putString(KEY_PATH, path)
bundle.putString(KEY_TYPE, UserHistoryViewModel.TYPE.fromValue(type).value)
bundle.putString(KEY_GAME, game_type)
bundle.putInt(KEY_POSITION, position ?: 0)
jumpActivity(context, bundle)
}
@ -776,36 +767,6 @@ object DirectUtils {
jumpActivity(context, bundle)
}
@JvmStatic
fun directToFeedbackCompat(
context: Context,
content: String? = null,
hintType: String? = null,
isQaFeedback: Boolean = false,
qaContentId: String? = "",
entrance: String? = null
) {
val bundle = Bundle()
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
bundle.putString(KEY_TO, SuggestionActivity::class.java.simpleName)
if (isQaFeedback) {
bundle.putBoolean(KEY_IS_QA_FEEDBACK, true)
bundle.putString(KEY_QA_CONTENT_ID, qaContentId)
bundle.putSerializable(KEY_SUGGESTTYPE, SuggestType.normal)
} else {
bundle.putString(KEY_CONTENT, content)
if (TextUtils.isEmpty(hintType)) {
bundle.putSerializable(KEY_SUGGESTTYPE, SuggestType.gameQuestion)
bundle.putString(KEY_SUGGEST_HINT_TYPE, KEY_PLUGIN)
} else {
bundle.putSerializable(KEY_SUGGESTTYPE, SuggestType.normal)
bundle.putString(KEY_SUGGEST_HINT_TYPE, hintType)
}
}
EntranceUtils.jumpActivityCompat(context, bundle)
}
@JvmStatic
fun directToDownloadManager(context: Context, entrance: String? = null) {
val bundle = Bundle()

View File

@ -19,25 +19,26 @@ import com.gh.common.simulator.SimulatorDownloadManager
import com.gh.common.simulator.SimulatorGameManager
import com.gh.common.view.DownloadButton
import com.gh.common.xapk.XapkInstaller
import com.gh.common.xapk.XapkInstaller.cancelUnzipTask
import com.gh.common.xapk.XapkUnzipStatus
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.adapter.viewholder.GameViewHolder
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.utils.*
import com.gh.gamecenter.energy.EnergyBridge
import com.gh.gamecenter.entity.GameEntity
import com.gh.gamecenter.common.entity.LinkEntity
import com.gh.gamecenter.energy.EnergyBridge
import com.gh.gamecenter.entity.PluginLocation
import com.gh.gamecenter.gamedetail.dialog.GamePermissionDialogFragment
import com.gh.gamecenter.manager.PackagesManager
import com.gh.gamecenter.teenagermode.TeenagerModeActivity
import com.gh.vspace.VDownloadManagerActivity
import com.gh.vspace.VHelper
import com.lightgame.download.DownloadConfig
import com.lightgame.download.DownloadEntity
@ -119,13 +120,13 @@ object DownloadItemUtils {
fun updateItemWithReserveStatus(holder: GameViewHolder, gameEntity: GameEntity) {
if ("download" == gameEntity.reserveStatus) {
// 已上线
updateItem(holder.gameDownloadBtn.context, gameEntity, holder, false)
updateItem(holder.gameDes.context, gameEntity, holder, false)
} else if ("appointment" == gameEntity.reserveStatus) {
// 已预约
holder.gameDownloadBtn.text = "已预约"
holder.gameDownloadBtn.visibility = View.VISIBLE
holder.gameDownloadBtn.buttonStyle = DownloadButton.ButtonStyle.RESERVED
updateItemViewStatus(holder, null, null)
updateItemViewStatus(holder, false, null, null)
}
}
@ -165,8 +166,7 @@ object DownloadItemUtils {
) {
// 显示预约
if (gameEntity.isReservable) {
holder.multiVersionDownloadTv?.visibility = View.GONE
updateItemViewStatus(holder, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
updateItemViewStatus(holder, false, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
updateDownloadButton(
context,
holder.gameDownloadBtn,
@ -177,16 +177,11 @@ object DownloadItemUtils {
return
}
if (gameEntity.getApk().isEmpty() || gameEntity.downloadOffStatus != null) {
holder.multiVersionDownloadTv?.visibility = View.GONE
holder.gameDownloadTips?.visibility = View.GONE
updateItemViewStatus(holder, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
updateItemViewStatus(holder, false, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
} else if (gameEntity.getApk().size == 1) {
holder.multiVersionDownloadTv?.visibility = View.GONE
holder.gameDownloadTips?.visibility = View.GONE
updateNormalItem(context, holder, gameEntity, briefStyle, isShowRecommendStar)
updateNormalItem(context, holder, gameEntity, isShowPlatform, briefStyle, isShowRecommendStar)
} else {
holder.multiVersionDownloadTv?.visibility = View.VISIBLE
updatePluginItem(context, holder, gameEntity, briefStyle, isShowRecommendStar)
updatePluginItem(context, holder, gameEntity, isShowPlatform, briefStyle, isShowRecommendStar)
}
updateDownloadButton(
context,
@ -267,56 +262,42 @@ object DownloadItemUtils {
downloadEntity = VHelper.getDownloadEntitySnapshot(gameEntity.id, gameEntity.getUniquePackageName())
}
if (downloadEntity == null) {
val entryMap: ArrayMap<String, DownloadEntity> = gameEntity.getEntryMap()
val apkEntity = gameEntity.getApk()[0]
if (entryMap.isNotEmpty()) {
downloadEntity = entryMap[apkEntity.getPlatform()]
}
}
if (downloadEntity != null) {
downloadBtn.apply {
when (downloadEntity.status) {
DownloadStatus.done -> {
if (downloadEntity.isSimulatorGame() && gameEntity.simulator != null) {
GameUtils.setDownloadBtnStatus(context, gameEntity, downloadBtn, pluginLocation)
} else if (downloadEntity.isVGame()) {
buttonStyle =
if (PackagesManager.isCanUpdate(
downloadEntity.gameId,
downloadEntity.packageName
)
) {
setText(R.string.update)
DownloadButton.ButtonStyle.NORMAL
} else {
setText(R.string.launch)
DownloadButton.ButtonStyle.LAUNCH_OR_OPEN
}
} else {
buttonStyle = DownloadButton.ButtonStyle.INSTALL_NORMAL
setText(R.string.install)
}
buttonStyle =
if (downloadEntity.isPluggable && PackagesManager.isInstalled(downloadEntity.packageName)) {
DownloadButton.ButtonStyle.PLUGIN
} else {
DownloadButton.ButtonStyle.NORMAL
}
}
DownloadStatus.pause,
DownloadStatus.timeout,
DownloadStatus.neterror,
DownloadStatus.subscribe,
DownloadStatus.overflow -> {
val status = downloadEntity.status
if (status == DownloadStatus.downloading) {
setText(R.string.downloading)
buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_NORMAL
} else if (status == DownloadStatus.waiting) {
setText(R.string.waiting)
buttonStyle = DownloadButton.ButtonStyle.WAITING
} else if (status == DownloadStatus.pause || status == DownloadStatus.timeout || status == DownloadStatus.neterror || status == DownloadStatus.subscribe || status == DownloadStatus.overflow) {
setText(R.string.downloading)
buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_NORMAL
} else if (status == DownloadStatus.done) {
val xapkStatus = downloadEntity.meta[XapkInstaller.XAPK_UNZIP_STATUS]
if (XapkUnzipStatus.UNZIPPING.name == xapkStatus) {
setText(R.string.unzipping)
buttonStyle = DownloadButton.ButtonStyle.NORMAL
setText(R.string.resume)
return
}
DownloadStatus.cancel -> {
if (downloadEntity.isSimulatorGame() && gameEntity.simulator != null) {
GameUtils.setDownloadBtnStatus(context, gameEntity, downloadBtn, pluginLocation)
} else if (downloadEntity.isVGame()) {
if (PackagesManager.isCanUpdate(downloadEntity.gameId, downloadEntity.packageName)) {
setText(R.string.update)
} else {
setText(R.string.launch)
}
} else {
setText(R.string.install)
}
else -> {}
buttonStyle =
if (downloadEntity.isPluggable && PackagesManager.isInstalled(downloadEntity.packageName)) {
DownloadButton.ButtonStyle.PLUGIN
} else {
DownloadButton.ButtonStyle.NORMAL
}
}
}
} else {
@ -329,184 +310,192 @@ object DownloadItemUtils {
// 更新正常的条目只有一个apk包
private fun updateNormalItem(
context: Context,
holder: GameViewHolder,
gameEntity: GameEntity,
briefStyle: String?,
context: Context, holder: GameViewHolder, gameEntity: GameEntity,
isShowPlatform: Boolean, briefStyle: String?,
isShowRecommendStar: Boolean = false
) {
val entryMap: ArrayMap<String, DownloadEntity> = gameEntity.getEntryMap()
val apkEntity = gameEntity.getApk()[0]
var downloadEntity: DownloadEntity? = null
if (entryMap.isNotEmpty()) {
downloadEntity = entryMap[apkEntity.getPlatform()]
}
if (downloadEntity == null) {
downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity)
}
if (downloadEntity != null) {
if (downloadEntity.isSimulatorGame()) {
if (downloadEntity.status != DownloadStatus.done) {
val downloadEntity = entryMap[apkEntity.getPlatform()]
if (downloadEntity != null) {
if (downloadEntity.isSimulatorGame()) {
if (downloadEntity.status != DownloadStatus.done) {
// 更改进度条和提示文本的状态
changeStatus(context, holder, downloadEntity, isShowPlatform, true)
return
}
} else {
// 更改进度条和提示文本的状态
changeStatus(context, holder, downloadEntity)
changeStatus(context, holder, downloadEntity, isShowPlatform, true, isShowRecommendStar)
return
}
} else {
// 更改进度条和提示文本的状态
changeStatus(context, holder, downloadEntity)
return
}
}
updateItemViewStatus(holder, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
updateItemViewStatus(holder, false, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
}
// 更新插件的条目有多个apk包
private fun updatePluginItem(
context: Context,
holder: GameViewHolder,
gameEntity: GameEntity,
briefStyle: String?,
context: Context, holder: GameViewHolder, gameEntity: GameEntity,
isShowPlatform: Boolean, briefStyle: String?,
isShowRecommendStar: Boolean = false
) {
val entryMap = gameEntity.getEntryMap()
var downloadEntity: DownloadEntity? = null
if (entryMap.isNotEmpty()) {
val queue = DownloadManager.getInstance().getQueue(gameEntity.name)
downloadEntity = if (queue != null && !queue.isEmpty()) {
val downloadEntity = if (queue != null && !queue.isEmpty()) {
entryMap[queue.peek()]
} else {
entryMap[entryMap.keyAt(0)]
}
if (downloadEntity != null) {
// 更改进度条和提示文本的状态
changeStatus(context, holder, downloadEntity, isShowPlatform, false, isShowRecommendStar)
return
}
}
if (downloadEntity == null) {
downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity)
}
if (downloadEntity != null) {
// 更改进度条和提示文本的状态
changeStatus(context, holder, downloadEntity, gameEntity.getApk().size > 1)
return
}
updateItemViewStatus(holder, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
updateItemViewStatus(holder, false, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
}
// 更改进度条和提示文本的状态
fun changeStatus(
context: Context,
holder: GameViewHolder,
downloadEntity: DownloadEntity,
isMultiVersion: Boolean = false
context: Context, holder: GameViewHolder, downloadEntity: DownloadEntity,
isShowPlatform: Boolean, isNormal: Boolean, isShowRecommendStar: Boolean = false
) {
when (downloadEntity.status) {
DownloadStatus.redirected,
DownloadStatus.downloading -> {
if (isMultiVersion) {
holder.gameDownloadBtn.buttonStyle = DownloadButton.ButtonStyle.NORMAL
val darkMode = (holder.gameDownloadTips?.getTag(R.string.is_dark_mode_on_id) as? Boolean) ?: false
val isDarkModeChanged = DarkModeUtils.isDarkModeOn(context) != darkMode
if (holder.gameDownloadTips?.visibility == View.GONE || holder.gameDownloadTips?.isAnimating == false || isDarkModeChanged) {
holder.gameDownloadTips?.visibility = View.VISIBLE
holder.gameDownloadTips?.setDownloadTipsAnimation(true)
}
holder.gameDownloadTips?.setTag(R.string.is_dark_mode_on_id, DarkModeUtils.isDarkModeOn(context))
val status = downloadEntity.status
// 畅玩游戏下载完成时不再需要显示进度条
val shouldShowDownload = !(downloadEntity.isVGame() && status == DownloadStatus.done)
val platform = PlatformUtils.getInstance(context).getPlatformName(downloadEntity.platform)
updateItemViewStatus(holder, shouldShowDownload, null, null, isShowRecommendStar)
holder.gameProgressbar.progressDrawable = R.drawable.progressbar_bg_style.toDrawable()
if (status == DownloadStatus.downloading) {
if (DownloadStatus.pause != DownloadManager.getInstance().getStatus(downloadEntity.url)) {
holder.gameProgressbar.progress = (downloadEntity.percent * 10).toInt()
if (isShowPlatform && platform != null) {
holder.gameDownloadSpeed.text = String.format(
"%s - %s(剩%s)", platform,
SpeedUtils.getSpeed(downloadEntity.speed),
SpeedUtils.getRemainTime(
downloadEntity.size,
downloadEntity.progress,
downloadEntity.speed * 1024
)
)
} else {
holder.gameDownloadTips?.visibility = View.GONE
holder.gameDownloadBtn.buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_NORMAL
holder.gameDownloadBtn.progress = (downloadEntity.percent * 10).toInt()
holder.gameDownloadBtn.text = downloadEntity.percent.toString() + "%"
holder.gameDownloadSpeed.text = String.format(
"%s(剩%s)", SpeedUtils.getSpeed(downloadEntity.speed),
SpeedUtils.getRemainTime(
downloadEntity.size,
downloadEntity.progress,
downloadEntity.speed * 1024
)
)
}
holder.gameDownloadPercentage.text = downloadEntity.percent.toString() + "%"
}
DownloadStatus.waiting -> {
if (isMultiVersion) {
holder.gameDownloadTips?.visibility = View.VISIBLE
holder.gameDownloadTips?.setDownloadTipsAnimation(false)
}
holder.gameDownloadBtn.buttonStyle = DownloadButton.ButtonStyle.WAITING
holder.gameDownloadBtn.text = context.getString(R.string.waiting)
} else if (status == DownloadStatus.waiting) {
holder.gameProgressbar.progress = (downloadEntity.percent * 10).toInt()
if (isShowPlatform && platform != null) {
holder.gameDownloadSpeed.text = String.format("%s - 等待", platform)
} else {
holder.gameDownloadSpeed.text = "等待"
}
DownloadStatus.pause,
DownloadStatus.timeout,
DownloadStatus.neterror,
DownloadStatus.subscribe,
DownloadStatus.overflow -> {
if (isMultiVersion) {
holder.gameDownloadTips?.visibility = View.VISIBLE
holder.gameDownloadTips?.setDownloadTipsAnimation(false)
}
holder.gameDownloadBtn.buttonStyle = DownloadButton.ButtonStyle.NORMAL
holder.gameDownloadBtn.text = context.getString(R.string.resume)
holder.gameDownloadPercentage.text = downloadEntity.percent.toString() + "%"
} else if (status == DownloadStatus.pause || status == DownloadStatus.timeout || status == DownloadStatus.neterror || status == DownloadStatus.subscribe || status == DownloadStatus.overflow) {
holder.gameProgressbar.progress = (downloadEntity.percent * 10).toInt()
if (isShowPlatform && platform != null) {
holder.gameDownloadSpeed.text = String.format("%s - 暂停", platform)
} else {
holder.gameDownloadSpeed.text = "暂停"
}
DownloadStatus.done -> {
if (isMultiVersion) {
holder.gameDownloadTips?.visibility = View.VISIBLE
holder.gameDownloadTips?.setDownloadTipsAnimation(false)
}
val xapkStatus = downloadEntity.meta[XapkInstaller.XAPK_UNZIP_STATUS]
if (XapkUnzipStatus.UNZIPPING.name == xapkStatus) {
val percent = downloadEntity.meta[XapkInstaller.XAPK_UNZIP_PERCENT]
holder.gameDownloadBtn.progress = (java.lang.Float.valueOf(percent) * 10).toInt()
holder.gameDownloadBtn.text = "$percent%"
return
} else if (XapkUnzipStatus.FAILURE.name == xapkStatus) {
holder.gameDownloadBtn.setText(R.string.install)
holder.gameDownloadBtn.buttonStyle = DownloadButton.ButtonStyle.INSTALL_NORMAL
return
}
holder.gameDownloadBtn.progress = 1000
holder.gameDownloadBtn.setText(R.string.hundred_percent)
holder.gameDownloadPercentage.text = downloadEntity.percent.toString() + "%"
} else if (status == DownloadStatus.done) {
val xapkStatus = downloadEntity.meta[XapkInstaller.XAPK_UNZIP_STATUS]
if (XapkUnzipStatus.UNZIPPING.name == xapkStatus) {
val percent = downloadEntity.meta[XapkInstaller.XAPK_UNZIP_PERCENT]
holder.gameProgressbar.progressDrawable =
context.resources.getDrawable(R.drawable.progressbar_xapk_style)
holder.gameDownloadSpeed.setText(R.string.unzipping)
holder.gameProgressbar.progress = (java.lang.Float.valueOf(percent) * 10).toInt()
holder.gameDownloadPercentage.text = "$percent%"
return
}
else -> {
holder.gameDownloadTips?.visibility = View.GONE
holder.gameProgressbar.progress = 1000
if (isShowPlatform && platform != null) {
holder.gameDownloadSpeed.text = String.format("%s - 下载完成", platform)
} else {
holder.gameDownloadSpeed.text = "下载完成"
}
holder.gameDownloadPercentage.setText(R.string.hundred_percent)
}
}
private fun updateItemViewStatus(
holder: GameViewHolder,
showDownload: Boolean,
briefStyle: String?,
recommendStyle: LinkEntity?,
isShowRecommendStar: Boolean = false
) {
holder.gameDownloadTips?.visibility = View.GONE
// 推荐指数优先,现暂时为游戏单详情列表游戏使用
if (isShowRecommendStar && holder.recommendStarInfo != null) {
holder.recommendStarInfo!!.visibility = View.VISIBLE
if (showDownload) {
if (holder.gameRating != null) holder.gameRating!!.visibility = View.GONE
holder.gameDes?.visibility = View.GONE
return
}
// 推荐优先,有推荐内容时不执行下面的 star 和 brief 代码块
if (briefStyle != null && recommendStyle != null && briefStyle.contains("recommend")) {
if (holder.recommendContainer != null) {
holder.recommendContainer!!.visibility = View.VISIBLE
}
if (holder.gameRating != null) holder.gameRating!!.visibility = View.GONE
holder.gameDes?.visibility = View.GONE
holder.recommendTv?.text = recommendStyle.text
if (TextUtils.isEmpty(recommendStyle.icon)) {
holder.recommendIv?.visibility = View.GONE
holder.recommendContainer?.setPadding(6F.dip2px(), 0, 8F.dip2px(), 0)
} else {
holder.recommendIv?.visibility = View.VISIBLE
ImageUtils.display(holder.recommendIv, recommendStyle.icon)
}
return
} else {
holder.gameDes.visibility = View.GONE
holder.gameProgressbar.visibility = View.VISIBLE
holder.gameInfo.visibility = View.VISIBLE
if (holder.recommendContainer != null) {
holder.recommendContainer!!.visibility = View.GONE
}
}
if (briefStyle != null && briefStyle.contains("star")) {
if (holder.gameRating != null) holder.gameRating!!.visibility = View.VISIBLE
if (holder.recommendStarInfo != null) {
holder.recommendStarInfo!!.visibility = View.GONE
}
} else {
if (holder.gameRating != null) holder.gameRating!!.visibility = View.GONE
}
holder.gameProgressbar.visibility = View.GONE
holder.gameInfo.visibility = View.GONE
// 缺省情况下回落到游戏简介
if (TextUtils.isEmpty(briefStyle) || briefStyle!!.contains("brief") || briefStyle.contains("recommend")) {
holder.gameDes?.visibility = View.VISIBLE
} else {
holder.gameDes?.visibility = View.GONE
// 推荐指数优先,现暂时为游戏单详情列表游戏使用
if (isShowRecommendStar && holder.recommendStarInfo != null) {
holder.recommendStarInfo!!.visibility = View.VISIBLE
if (holder.gameRating != null) holder.gameRating!!.visibility = View.GONE
holder.gameDes.visibility = View.GONE
return
}
// 推荐优先,有推荐内容时不执行下面的 star 和 brief 代码块
if (briefStyle != null && recommendStyle != null && briefStyle.contains("recommend")) {
if (holder.recommendContainer != null) {
holder.recommendContainer!!.visibility = View.VISIBLE
}
if (holder.gameRating != null) holder.gameRating!!.visibility = View.GONE
holder.gameDes.visibility = View.GONE
holder.recommendTv.text = recommendStyle.text
if (TextUtils.isEmpty(recommendStyle.icon)) {
holder.recommendIv.visibility = View.GONE
holder.recommendContainer?.setPadding(6F.dip2px(), 0, 8F.dip2px(), 0)
} else {
holder.recommendIv.visibility = View.VISIBLE
ImageUtils.display(holder.recommendIv, recommendStyle.icon)
}
return
} else {
if (holder.recommendContainer != null) {
holder.recommendContainer!!.visibility = View.GONE
}
}
if (briefStyle != null && briefStyle.contains("star")) {
if (holder.gameRating != null) holder.gameRating!!.visibility = View.VISIBLE
} else {
if (holder.gameRating != null) holder.gameRating!!.visibility = View.GONE
}
// 缺省情况下回落到游戏简介
if (TextUtils.isEmpty(briefStyle) || briefStyle!!.contains("brief") || briefStyle.contains("recommend")) {
holder.gameDes.visibility = View.VISIBLE
} else {
holder.gameDes.visibility = View.GONE
}
}
}
@ -573,7 +562,7 @@ object DownloadItemUtils {
@JvmStatic
fun setOnClickListener(
context: Context,
downloadBtn: View,
downloadBtn: DownloadButton,
gameEntity: GameEntity,
position: Int,
adapter: RecyclerView.Adapter<out RecyclerView.ViewHolder?>?,
@ -653,22 +642,30 @@ object DownloadItemUtils {
allStateClickCallback?.onCallback()
clickCallback?.onCallback()
if ("download" == gameEntity.reserveStatus) {
ReservationHelper.showDeleteReservationDialog(context) {
ReservationHelper.deleteReservation(gameEntity) {
adapter?.notifyItemChanged(position)
refreshCallback?.onCallback()
ReservationHelper.showDeleteReservationDialog(context, object : EmptyCallback {
override fun onCallback() {
ReservationHelper.deleteReservation(gameEntity, object : EmptyCallback {
override fun onCallback() {
adapter?.notifyItemChanged(position)
refreshCallback?.onCallback()
}
})
}
}
})
} else {
ReservationHelper.showCancelReservationDialog(context, {
NewFlatLogUtils.logMyGameCancelReserveDialogClick(
"确定取消",
gameEntity.id,
gameEntity.name ?: ""
)
ReservationHelper.cancelReservation(gameEntity) {
adapter?.notifyItemChanged(position)
refreshCallback?.onCallback()
ReservationHelper.showCancelReservationDialog(context, object : EmptyCallback {
override fun onCallback() {
NewFlatLogUtils.logMyGameCancelReserveDialogClick(
"确定取消",
gameEntity.id,
gameEntity.name ?: ""
)
ReservationHelper.cancelReservation(gameEntity, object : EmptyCallback {
override fun onCallback() {
adapter?.notifyItemChanged(position)
refreshCallback?.onCallback()
}
})
}
}, object : CancelListener {
override fun onCancel() {
@ -711,24 +708,26 @@ object DownloadItemUtils {
}
} else if (gameEntity.getApk().size == 1) {
downloadBtn.setOnClickListener {
val clickRunnable = EmptyCallback {
allStateClickCallback?.onCallback()
clickCallback?.onCallback()
onNormalClick(
context,
downloadBtn,
gameEntity,
position,
adapter,
entrance,
location,
traceEvent,
refreshCallback
)
val clickRunnable = object : EmptyCallback {
override fun onCallback() {
allStateClickCallback?.onCallback()
clickCallback?.onCallback()
onNormalClick(
context,
downloadBtn,
gameEntity,
position,
adapter,
entrance,
location,
traceEvent,
refreshCallback
)
}
}
// 启动不需要请求存储权限
if (downloadBtn is DownloadButton && downloadBtn.text == context.getString(R.string.launch)) {
if (downloadBtn.text.toString() == context.getString(R.string.launch)) {
clickRunnable.onCallback()
} else {
PermissionHelper.checkStoragePermissionBeforeAction(context, clickRunnable)
@ -757,7 +756,7 @@ object DownloadItemUtils {
@JvmOverloads
fun onNormalClick(
context: Context,
downloadBtn: View?,
downloadBtn: DownloadButton,
gameEntity: GameEntity,
position: Int,
adapter: RecyclerView.Adapter<out RecyclerView.ViewHolder?>?,
@ -766,7 +765,7 @@ object DownloadItemUtils {
traceEvent: ExposureEvent? = null,
refreshCallback: EmptyCallback? = null
) {
val str = if (downloadBtn is DownloadButton) downloadBtn.text else context.getString(R.string.download)
val str = downloadBtn.text.toString()
if (gameEntity.getApk().isEmpty()) return
val apk = gameEntity.getApk().safelyGetInRelease(0) ?: return
if (str == context.getString(R.string.download)) {
@ -788,7 +787,6 @@ object DownloadItemUtils {
DataLogUtils.uploadGameLog(context, gameEntity.id, gameEntity.name, entrance)
} else if (str == context.getString(R.string.attempt)) {
ChainBuilder().apply {
addHandler(UpdateNewSimulatorHandler())
addHandler(GamePermissionHandler())
addHandler(BrowserInstallHandler())
addHandler(PackageCheckHandler())
@ -846,11 +844,8 @@ object DownloadItemUtils {
val isInstalledNewSimulator = SimulatorGameManager.isNewSimulatorInstalled(context)
val isInstalledOldSimulator = SimulatorGameManager.isOldSimulatorInstalled(context)
var simulator = gameEntity.simulator
val newSimulator = Config.getNewSimulatorEntitySetting()
if (!isInstalledOldSimulator && newSimulator != null) {//在没有安装旧的模拟器且有配置新版模拟器 才使用新版模拟器 否则还是用以前旧的
if (newSimulator.active) {
simulator = newSimulator
}
if (!isInstalledOldSimulator) {
simulator = Config.getNewSimulatorEntitySetting()
}
if (downloadEntity != null && SimulatorGameManager.isSimulatorGame(gameEntity) && !isInstalled && !isInstalledNewSimulator) {
SimulatorDownloadManager.getInstance().showDownloadDialog(
@ -912,31 +907,15 @@ object DownloadItemUtils {
}
})
} 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()]
}
}
if (downloadEntity != null) {
val xapkStatus = downloadEntity.meta[XapkInstaller.XAPK_UNZIP_STATUS]
if (XapkUnzipStatus.UNZIPPING.name == xapkStatus) {
cancelUnzipTask(downloadEntity)
return
}
when (str) {
context.getString(R.string.resume) -> {
DownloadManager.getInstance().resume(downloadEntity, true)
}
context.getString(R.string.waiting) -> {
Utils.toast(context, "最多只能同时下载三个任务,请稍等")
}
else -> {
DownloadManager.getInstance().pause(downloadEntity.url)
}
}
if (gameEntity.isVGame()) {
context.startActivity(VDownloadManagerActivity.getIntent(context, true))
} else {
context.startActivity(
DownloadManagerActivity.getDownloadMangerIntent(
context,
apk.url, entrance + "+(" + location.split(":").toTypedArray()[0] + ")"
)
)
}
}
}
@ -945,7 +924,7 @@ object DownloadItemUtils {
private fun download(
context: Context,
gameEntity: GameEntity,
downloadBtn: View?,
downloadBtn: DownloadButton,
entrance: String,
location: String,
isSubscribe: Boolean,
@ -965,10 +944,8 @@ object DownloadItemUtils {
traceEvent
)
Utils.toast(context, gameEntity.name + "已加入下载队列")
if (downloadBtn is DownloadButton) {
downloadBtn.text = "0%"
downloadBtn.buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_NORMAL
}
downloadBtn.setText(R.string.downloading)
downloadBtn.buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_NORMAL
DeviceRemindDialog.showDeviceRemindDialog(context, gameEntity)
} else {
Utils.toast(context, msg)
@ -977,22 +954,15 @@ object DownloadItemUtils {
//插件化
private fun plugin(
context: Context,
gameEntity: GameEntity,
downloadBtn: View?,
entrance: String,
location: String,
isSubscribe: Boolean,
traceEvent: ExposureEvent?
context: Context, gameEntity: GameEntity, downloadBtn: DownloadButton, entrance: String,
location: String, isSubscribe: Boolean, traceEvent: ExposureEvent?
) {
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 + "已加入下载队列")
if (downloadBtn is DownloadButton) {
downloadBtn.setText(R.string.downloading)
downloadBtn.buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_PLUGIN
}
downloadBtn.setText(R.string.downloading)
downloadBtn.buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_PLUGIN
} else {
Utils.toast(context, msg)
}
@ -1000,11 +970,8 @@ object DownloadItemUtils {
//安装
private fun install(
context: Context,
gameEntity: GameEntity,
position: Int,
adapter: RecyclerView.Adapter<out RecyclerView.ViewHolder?>?,
refreshCallback: EmptyCallback?
context: Context, gameEntity: GameEntity, position: Int,
adapter: RecyclerView.Adapter<out RecyclerView.ViewHolder?>?, refreshCallback: EmptyCallback?
) {
val apkEntity = gameEntity.getApk()[0]
val downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity)

View File

@ -23,7 +23,7 @@ import com.gh.gamecenter.entity.SimpleGameEntity
import com.gh.gamecenter.entity.SimulatorEntity
import com.gh.gamecenter.eventbus.EBDownloadStatus
import com.gh.gamecenter.retrofit.RetrofitManager
import com.gh.gamecenter.setting.view.GameDownloadSettingFragment
import com.gh.gamecenter.setting.GameDownloadSettingFragment
import com.gh.gamecenter.suggest.SuggestType
import com.gh.vspace.VHelper
import com.halo.assistant.HaloApp
@ -48,8 +48,6 @@ object DownloadObserver {
// TODO 修复因为更改内存对象造成的双重下载完成事件问题,具体触发代码见 DownloadDao.updateSnapshotList
private var mDoneDebouncePair: Pair<String, Long>? = null
private const val TEA_EVENT_DOWNLOAD_COMPLETE = "game_addiction"
// 如果在WIFI状态下,下载自动暂停,则再重试一遍
@JvmStatic
fun initObserver() {
@ -203,11 +201,6 @@ 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)
}
GameActivityDownloadHelper.clear()
EnergyBridge.postEnergyTask("download_game", downloadEntity.gameId, downloadEntity.packageName)
@ -248,20 +241,16 @@ 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)
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()
if ((!isInstalledOldSimulator && newSimulator != null && newSimulator.active) || isInstalledNewSimulator) { //如果没有安装任一旧的模拟器 或者下载了新模拟器 则使用新版本模拟器
simulator = newSimulator ?: simulator
if (!isInstalledOldSimulator || isInstalledNewSimulator) { //如果没有安装任一旧的模拟器 或者下载了新模拟器 则使用新版本模拟器
Config.getNewSimulatorEntitySetting().let {
simulator = it!!
}
}
SimulatorDownloadManager.getInstance().showDownloadDialog(
currentActivity, simulator,

View File

@ -37,32 +37,6 @@ import java.util.Set;
public class EntranceUtils {
public static void jumpActivityCompat(Context context, Bundle bundle) {
bundle.putBoolean(KEY_REQUIRE_REDIRECT, true);
if (HaloApp.getInstance().isRunningForeground || HaloApp.getInstance().isAlreadyUpAndRunning) {
// 应用正在运行,前台或后台
String to = bundle.getString(KEY_TO);
Class<?> clazz = ClassUtils.forName(to);
if (clazz == null) clazz = MainActivity.class;
if (ToolbarFragment.class.isAssignableFrom(clazz)) { // 兼容ToolbarFragment
ToolBarActivity.startFragmentNewTask(context, (Class<? extends ToolbarFragment>) clazz, bundle);
} else {
Intent intent1 = new Intent(context, clazz);
intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// 如果 activity 名称有 singleton 的就添加 reorder_to_front 标签 (有点粗暴有点蠢,但暂时就先这样吧 :C )
if (clazz.getSimpleName().toLowerCase().contains("singleton")) {
intent1.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
}
intent1.putExtras(bundle);
context.startActivity(intent1);
}
} else {
// 应用未在运行
context.startActivity(SplashScreenActivity.getSplashScreenIntent(context, bundle));
}
}
public static void jumpActivity(Context context, Bundle bundle) {
bundle.putBoolean(KEY_REQUIRE_REDIRECT, true);

View File

@ -183,11 +183,6 @@ object ErrorHelper {
403210 -> handleVerifyPhoneError(context, errorEntity, realNameConfirmListener, entrance)
// 禁言(发布内容)
403402 -> Utils.toast(context, "您的账号存在违规,不允许发布内容")
// 禁言(点赞)
403403 -> Utils.toast(context, "您的账号存在违规,不允许点赞")
else -> Utils.toast(context, R.string.post_failure_hint)
}
}
@ -408,16 +403,15 @@ object ErrorHelper {
val errorEntity: ErrorEntity? =
httpException?.response()?.errorBody()?.string()?.toObject()
when {
errorEntity?.code == 403099 -> Utils.toast(context, "当前账号正在注销,禁止登录")
// 用户禁止登录
errorEntity?.code == 403401 -> Utils.toast(context, "您的账号存在违规,不允许登录")
// 设备禁止登录
errorEntity?.code == 403404 -> Utils.toast(context, "您的设备存在违规,不允许登录")
errorEntity?.toast?.isNotEmpty() == true -> Utils.toast(context, errorEntity.toast)
errorEntity?.code == 403099 -> {
Utils.toast(context, "当前账号正在注销,禁止登录")
}
errorEntity?.code == 403401 -> {//禁止登录
Utils.toast(context, "网络异常")
}
errorEntity?.toast?.isNotEmpty() == true -> {
Utils.toast(context, errorEntity.toast)
}
else -> Utils.toast(context, R.string.login_failure)
}
} catch (e: Exception) {

View File

@ -3,10 +3,10 @@ package com.gh.common.util
import android.app.Activity
import android.os.Build
import android.view.Gravity
import android.view.View
import android.widget.TextView
import com.gh.gamecenter.R
import com.gh.gamecenter.common.utils.dip2px
import com.gh.gamecenter.core.utils.DisplayUtils
import com.gh.gamecenter.energy.EnergyBridge
import com.lightgame.utils.Util_System_Keyboard
import com.lzf.easyfloat.EasyFloat
@ -67,14 +67,23 @@ object FloatingBackViewManager {
}
dragEnd { view ->
// 记录停止拖动的最后位置
view.findViewById<View>(R.id.titleTv)?.apply {
val outLocation = IntArray(2)
getLocationOnScreen(outLocation)
val yOffset = outLocation[1]
val statusBarHeight = DisplayUtils.getStatusBarHeight(activity.resources)
mLastPositionY = yOffset
// 记录停止拖动的最后位置
val outLocation = IntArray(2)
view.getLocationInWindow(outLocation)
val yOffset = outLocation[1]
if (yOffset <= statusBarHeight) {
// 判断状态栏是否被消费
if (yOffset == view.y.toInt()) {
view.y = statusBarHeight.toFloat()
} else {
view.y = 0F
}
}
mLastPositionY = yOffset
}
}
.show()
@ -104,6 +113,8 @@ object FloatingBackViewManager {
/**
* 停用返回小浮窗
* @param type 类型
* @param activityUrl 类型为活动的时候用的地址
*/
@JvmStatic
fun disableBackView() {

View File

@ -5,7 +5,6 @@ import android.content.Context
import android.text.TextUtils
import androidx.appcompat.app.AppCompatActivity
import com.gh.common.DefaultJsApi
import com.gh.common.constant.Config
import com.gh.common.dialog.CertificationDialog
import com.gh.common.exposure.ExposureEvent
import com.gh.common.exposure.ExposureManager
@ -13,9 +12,6 @@ import com.gh.common.exposure.ExposureSource
import com.gh.common.exposure.ExposureType
import com.gh.common.history.HistoryHelper
import com.gh.common.repository.ReservationRepository
import com.gh.common.simulator.NewSimulatorGameManager
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.gamecenter.R
@ -31,10 +27,8 @@ import com.gh.gamecenter.common.utils.singleToMain
import com.gh.gamecenter.common.view.dsbridge.CompletionHandler
import com.gh.gamecenter.core.runOnUiThread
import com.gh.gamecenter.core.utils.EmptyCallback
import com.gh.gamecenter.core.utils.MtaHelper
import com.gh.gamecenter.core.utils.SPUtils
import com.gh.gamecenter.core.utils.ToastUtils
import com.gh.gamecenter.energy.EnergyBridge
import com.gh.gamecenter.entity.ApkEntity
import com.gh.gamecenter.entity.GameEntity
import com.gh.gamecenter.entity.PluginLocation
@ -43,10 +37,7 @@ import com.gh.gamecenter.login.user.UserManager
import com.gh.gamecenter.retrofit.RetrofitManager
import com.gh.gamecenter.teenagermode.TeenagerModeActivity
import com.gh.vspace.VHelper
import com.lightgame.download.DownloadEntity
import com.lightgame.download.FileUtils
import com.lightgame.utils.Utils
import java.io.File
/**
* 游戏活动下载辅助类
@ -177,13 +168,10 @@ object GameActivityDownloadHelper {
) {
val apk = getApk(gameEntity, event, true) ?: return
val downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity)
val str = GameUtils.getDownloadBtnText(context, gameEntity, PluginLocation.only_game)
if (downloadEntity != null &&
str != context.getString(R.string.install) &&
str != context.getString(R.string.launch)
) {
if (downloadEntity != null) {
ToastUtils.toast("${gameEntity.name}已加入下载队列")
} else {
val str = GameUtils.getDownloadBtnText(context, gameEntity, PluginLocation.only_game)
if (str == context.getString(R.string.download) || str == context.getString(R.string.attempt)) {
GamePermissionDialogFragment.show((context as AppCompatActivity), gameEntity, gameEntity.info) {
CertificationDialog.showCertificationDialog(context, gameEntity) {
@ -194,7 +182,7 @@ object GameActivityDownloadHelper {
}
DataLogUtils.uploadGameLog(context, gameEntity.id, gameEntity.name, entrance)
} else if (str == context.getString(R.string.smooth)) {
VHelper.validateVSpaceBeforeAction(context, gameEntity) {
VHelper.validateVSpaceBeforeAction(context, gameEntity, true) {
GamePermissionDialogFragment.show((context as AppCompatActivity), gameEntity, gameEntity.info) {
CertificationDialog.showCertificationDialog(context, gameEntity) {
DialogUtils.checkDownload(context, apk.size) { isSubscribe: Boolean ->
@ -213,73 +201,12 @@ object GameActivityDownloadHelper {
}
}
}
} else if (str == context.getString(R.string.install)) {
val simulatorDownloadEntity = SimulatorGameManager.findDownloadEntityByUrl(apk.url)
if (gameEntity.simulator != null) {
val isInstalled =
PackageUtils.isInstalledFromAllPackage(context, gameEntity.simulator!!.apk!!.packageName)
val isInstalledNewSimulator = SimulatorGameManager.isNewSimulatorInstalled(context)
val isInstalledOldSimulator = SimulatorGameManager.isOldSimulatorInstalled(context)
var simulator = gameEntity.simulator
val newSimulator = Config.getNewSimulatorEntitySetting()
if (!isInstalledOldSimulator && newSimulator != null) {//在没有安装旧的模拟器且有配置新版模拟器 才使用新版模拟器 否则还是用以前旧的
if (newSimulator.active) {
simulator = newSimulator
}
}
if (simulatorDownloadEntity != null && SimulatorGameManager.isSimulatorGame(gameEntity) && !isInstalled && !isInstalledNewSimulator) {
SimulatorDownloadManager.getInstance().showDownloadDialog(
context, simulator,
SimulatorDownloadManager.SimulatorLocation.LAUNCH, gameEntity.id, gameEntity.name!!, null
)
return
}
}
if (gameEntity.isVGame()) {
VHelper.installOrLaunch((context as AppCompatActivity), gameEntity.getUniquePackageName() ?: "")
} else {
downloadEntity?.run {
install(context, gameEntity, apk, this)
}
}
} else if (str == context.getString(R.string.launch)) {
EnergyBridge.postEnergyTask("play_game", gameEntity.id, gameEntity.getApk()[0].packageName)
//启动模拟器游戏
if (SimulatorGameManager.isSimulatorGame(gameEntity)) {
if (NewSimulatorGameManager.shouldShowUpdateNewSimulatorAlert(context)) {
NewSimulatorGameManager.showUpdateNewsSimulator(context, null)
return
}
val simulatorDownloadEntity =
SimulatorGameManager.findDownloadEntityByUrl(gameEntity.getApk()[0].url)
if (simulatorDownloadEntity != null) {
val file = File(simulatorDownloadEntity.path)
if (!file.exists()) {
download(context, gameEntity, apk, false, entrance, location, traceEvent)
return
}
NewFlatLogUtils.logSimulatorGameCardClick("启动")
SimulatorGameManager.launchSimulatorGame(simulatorDownloadEntity, gameEntity)
}
return
}
if (gameEntity.isVGame()) {
VHelper.installOrLaunch((context as AppCompatActivity), gameEntity.getUniquePackageName() ?: "")
return
}
if (entrance.contains("我的游戏")) {
MtaHelper.onEvent("我的游戏_启动", "启动", gameEntity.name)
}
PackageUtils.launchApplicationByPackageName(context, gameEntity.getApk()[0].packageName)
} else if (str == context.getString(R.string.install) || str == context.getString(R.string.launch)) {
ToastUtils.toast("${gameEntity.name}已加入下载队列")
} else if (str == context.getString(R.string.update)) {
DialogUtils.checkDownload(context, apk.size) { isSubscribe: Boolean ->
update(context, gameEntity, apk, entrance, location, isSubscribe, traceEvent)
}
} else {
ToastUtils.toast("${gameEntity.name}已加入下载队列")
}
}
}
@ -367,29 +294,6 @@ object GameActivityDownloadHelper {
}
}
// 安装
private fun install(
context: Context,
gameEntity: GameEntity,
apkEntity: ApkEntity,
downloadEntity: DownloadEntity
) {
val path = downloadEntity.path
when {
FileUtils.isEmptyFile(path) -> {
Utils.toast(context, R.string.install_failure_hint)
DownloadManager.getInstance().cancel(downloadEntity.url)
gameEntity.getEntryMap().remove(apkEntity.getPlatform())
}
PackageUtils.isCanPluggable(apkEntity) -> {
DialogHelper.showPluginDialog(context) { PackageInstaller.uninstall(context, path) }
}
else -> {
PackageInstaller.install(context, downloadEntity)
}
}
}
// 更新
private fun update(
context: Context,

View File

@ -1,17 +1,16 @@
package com.gh.common.util;
import android.content.Context;
import android.graphics.Color;
import android.text.TextUtils;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
import com.gh.common.view.DownloadButton;
import com.gh.gamecenter.core.AppExecutor;
import com.gh.common.constant.Config;
import com.gh.common.simulator.SimulatorGameManager;
import com.gh.common.view.DownloadButton;
import com.gh.download.DownloadManager;
import com.gh.gamecenter.R;
import com.gh.gamecenter.core.AppExecutor;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.ApkLink;
import com.gh.gamecenter.entity.GameCollectionEntity;
@ -27,6 +26,9 @@ import com.lightgame.download.DownloadStatus;
import java.util.ArrayList;
import java.util.List;
import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
public class GameUtils {
/**
@ -78,7 +80,7 @@ public class GameUtils {
@WorkerThread
public static String getDownloadBtnText(Context context, GameEntity gameEntity, PluginLocation pluginLocation) {
if (gameEntity.getApk().size() > 1) {
return "";
return context.getString(R.string.expand);
}
int doneCount = 0; // 下载完成数量
@ -180,17 +182,7 @@ public class GameUtils {
if (gameEntity.isVGame()) {
return context.getString(R.string.smooth);
} else {
if ("smooth".equals(gameEntity.getDownloadStatus())) {
GameEntity.GameCategory gameCategory = gameEntity.getGameCategory();
if (gameCategory.equals(GameEntity.GameCategory.ONLINE_GAME)
|| gameCategory.equals(GameEntity.GameCategory.INTERNATIONAL_ONLINE_GAME)) {
return context.getString(R.string.download);
} else {
return context.getString(R.string.attempt);
}
} else {
return context.getString(R.string.download);
}
return context.getString(R.string.download);
}
}
}

View File

@ -12,7 +12,6 @@ import android.widget.TextView;
import androidx.core.content.ContextCompat;
import com.gh.gamecenter.common.utils.ExtensionsKt;
import com.gh.gamecenter.core.AppExecutor;
import com.gh.gamecenter.common.view.DrawableView;
import com.gh.gamecenter.R;
@ -126,8 +125,8 @@ public class GameViewUtils {
DisplayUtils.dip2px(context, 4),
DisplayUtils.dip2px(context, 1));
textView.setTextColor(ExtensionsKt.hexStringToIntColor("#" + tagEntity.getColor(), Color.WHITE));
textView.setBackground(DrawableView.getServerDrawable(ExtensionsKt.hexStringToIntColor("#" + tagEntity.getBackground(), Color.WHITE)));
textView.setTextColor(Color.parseColor("#" + tagEntity.getColor()));
textView.setBackground(DrawableView.getServerDrawable(Color.parseColor("#" + tagEntity.getBackground())));
}
private static TextView getGameTagView(Context context, String tagStr, int rightMargin, String tagType, TagStyleEntity tagEntity) {
@ -150,10 +149,10 @@ public class GameViewUtils {
if ("border".equals(tagEntity.getStyle())) {
gradientDrawable.setColor(Color.TRANSPARENT);
gradientDrawable.setStroke(DisplayUtils.dip2px(context, 1f), ExtensionsKt.hexStringToIntColor(colorStr, Color.WHITE));
tag.setTextColor(ExtensionsKt.hexStringToIntColor(colorStr, Color.WHITE));
gradientDrawable.setStroke(DisplayUtils.dip2px(context, 1f), Color.parseColor(colorStr));
tag.setTextColor(Color.parseColor(colorStr));
} else {
gradientDrawable.setColor(ExtensionsKt.hexStringToIntColor(colorStr, Color.WHITE));
gradientDrawable.setColor(Color.parseColor(colorStr));
gradientDrawable.setShape(GradientDrawable.RECTANGLE);
tag.setTextColor(Color.WHITE);
}
@ -164,7 +163,7 @@ public class GameViewUtils {
if (colorStr == null) {
return null;
}
int color = ExtensionsKt.hexStringToIntColor(colorStr, Color.WHITE);
int color = Color.parseColor(colorStr);
GradientDrawable gradientDrawable = new GradientDrawable();
gradientDrawable.setColor(Color.TRANSPARENT);
gradientDrawable.setStroke(DisplayUtils.dip2px(context, 1f), color);

View File

@ -70,7 +70,7 @@ public class InstallUtils {
if (!TextUtils.isEmpty(installVersion) && downloadEntity != null &&
installVersion.equals(downloadEntity.getVersionName())) {
if (!downloadEntity.isPluggable() || PackageUtils.isSignedByGh(context, packageName)) {
EventBus.getDefault().post(new EBPackage(EBPackage.TYPE_INSTALLED, packageName, installVersion));
EventBus.getDefault().post(new EBPackage("安装", packageName, installVersion));
}
}
}

View File

@ -18,6 +18,7 @@ import com.gh.gamecenter.adapter.LibaoDetailAdapter;
import com.gh.gamecenter.common.utils.DialogHelper;
import com.gh.gamecenter.common.utils.ExtensionsKt;
import com.gh.gamecenter.common.utils.NotificationHelper;
import com.gh.gamecenter.core.utils.GsonUtils;
import com.gh.gamecenter.core.utils.ToastUtils;
import com.gh.gamecenter.core.utils.UrlFilterUtils;
import com.gh.gamecenter.entity.ApkEntity;
@ -164,12 +165,6 @@ public class LibaoUtils {
String status = shouldUpdateStatus ? updateStatus(libaoEntity) : libaoEntity.getStatus();
libaoBtn.setTextColor(Color.WHITE);
if (status == null || TextUtils.isEmpty(status)) return;
// 领取限制为活动发放且未领取显示查看
if (ExtensionsKt.toResString(R.string.libao_activity_grant).equals(libaoEntity.getReceiveLimit()) && !status.equals("linged")) {
libaoBtn.setText(R.string.libao_check);
libaoBtn.setBackgroundResource(R.drawable.button_normal_round_style);
return;
}
switch (status) {
case "ling":
libaoBtn.setText(R.string.libao_ling);
@ -360,14 +355,7 @@ public class LibaoUtils {
Utils.toast(context, "还没到开始领取时间");
break;
case "查看":
if (ExtensionsKt.toResString(R.string.libao_activity_grant).equals(libaoEntity.getReceiveLimit())) {
String url = libaoEntity.getActivityLink().getUrl();
DialogHelper.showLibaoActivityDialog(
v.getContext(),
TextUtils.isEmpty(url),
() -> DirectUtils.directToWebView(v.getContext(), url, "查看礼包码弹窗-查看活动详情")
);
} else if (!TextUtils.isEmpty(libaoEntity.getDes())) {
if (!TextUtils.isEmpty(libaoEntity.getDes())) {
DialogHelper.showCenterDialog(v.getContext(), "使用说明", Html.fromHtml(libaoEntity.getDes()), "关闭", "", () -> {
}, () -> {
});

View File

@ -409,7 +409,7 @@ public class LogUtils {
public static void uploadWelcomeDialog(String action, String dialogId, String linkTitle) {
ExposureEntity payload = new ExposureEntity();
payload.setWelcomeDialogId(dialogId);
payload.setWelcomeDialogLinkTitle(linkTitle);
payload.setWelcomeDialogId(linkTitle);
SimpleLogContainerEntity entity = new SimpleLogContainerEntity();
entity.setEvent("dialog");
@ -553,7 +553,7 @@ public class LogUtils {
}
public static void uploadSearchGame(String event, String location, String key, String searchType) {
uploadSearchClick(event, location, key, searchType, "", "", false, false);
uploadSearchClick(event, location, key, searchType, "", "", false);
}
public static void uploadSearchClick(String event,
@ -562,8 +562,7 @@ public class LogUtils {
String searchType,
String gameId,
String gameName,
Boolean isMirrorData,
Boolean isAdData) {
Boolean isMirrorData) {
JSONObject object = new JSONObject();
JSONObject payload = new JSONObject();
try {
@ -577,7 +576,6 @@ public class LogUtils {
payload.put("game_id", gameId); //event为search_click才取值
payload.put("game_name", gameName); //event为search_click才取值
payload.put("is_mirror_data", isMirrorData);
payload.put("is_ad_data", isAdData);
object.put("payload", payload);
} catch (JSONException e) {
e.printStackTrace();

View File

@ -43,7 +43,6 @@ import com.tencent.connect.share.QQShare;
import com.tencent.mm.opensdk.modelmsg.SendMessageToWX;
import com.tencent.mm.opensdk.modelmsg.WXImageObject;
import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
import com.tencent.mm.opensdk.modelmsg.WXTextObject;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
import com.tencent.open.TDialog;
@ -312,51 +311,6 @@ public class MessageShareUtils {
}
}
public void shareTextFromWeb(Activity activity, String text, String type) {
switch (type) {
case "qq":
Utils.toast(mContext, "分享跳转中...");
if (ShareUtils.isQQClientAvailable(activity)) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, text);
intent.setType("text/plain");
intent.setPackage("com.tencent.mobileqq");
intent.setClassName("com.tencent.mobileqq", "com.tencent.mobileqq.activity.JumpActivity");
try {
activity.startActivity(intent);
} catch (Exception e) {
Utils.toast(mContext, "分享失败");
}
} else {
Utils.toast(mContext, "请安装QQ客户端");
}
break;
case "wechat":
Utils.toast(mContext, "分享跳转中...");
if (!mIWXAPI.isWXAppInstalled() && !PermissionHelper.isGetInstalledListPermissionDisabled(mContext)) {
Utils.toast(mContext, mContext.getString(R.string.share_no_wechat_hint));
return;
}
WXTextObject textObj = new WXTextObject();
textObj.text = text;
WXMediaMessage msg = new WXMediaMessage();
msg.mediaObject = textObj;
msg.description = text;
SendMessageToWX.Req req = new SendMessageToWX.Req();
req.transaction = buildTransaction("text");
req.message = msg;
req.scene = SendMessageToWX.Req.WXSceneSession;
mIWXAPI.sendReq(req);
break;
}
}
//QQ分享
private void qqShare() {
Utils.toast(mContext, "分享跳转中...");

View File

@ -461,6 +461,17 @@ object NewFlatLogUtils {
log(json, "event", false)
}
//设置点击深色模式跟随系统切换开关
@JvmStatic
fun logHaloSelfNightModeOsSwitch(isOn: Boolean) {
val json = json {
"event" to "halo_self_night_mode_os_switch"
"is_on" to isOn
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
//触发关闭深色模式跟随系统切换弹窗
@JvmStatic
fun logHaloSelfNightModeOsDialog(buttonText: String) {
@ -547,7 +558,7 @@ object NewFlatLogUtils {
//手机号验证弹窗点击事件
fun logPhoneNumberVerifyDialogClick(entrance: String, text: String) {
val json = json {
"event" to "publish_phone_number_verify_dialog_click"
"event" to "phone_number_verify_dialog_click"
"entrance" to entrance
"text" to text
parseAndPutMeta().invoke(this)
@ -558,7 +569,7 @@ object NewFlatLogUtils {
//手机号验证界面展示事件
fun logPhoneNumberVerifyDialogShow(entrance: String) {
val json = json {
"event" to "publish_phone_number_verify_dialog_show"
"event" to "phone_number_verify_dialog_show"
"entrance" to entrance
parseAndPutMeta().invoke(this)
}
@ -569,7 +580,7 @@ object NewFlatLogUtils {
//完成手机号验证
fun logPhoneNumberVerifyDialogSuccess() {
val json = json {
"event" to "publish_phone_number_verify_dialog_success"
"event" to "phone_number_verify_dialog_success"
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
@ -721,500 +732,4 @@ object NewFlatLogUtils {
}
log(json, "event", false)
}
//进入发现页面
fun logDiscoverPageEnter() {
val json = json {
"event" to "discover_page_enter"
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
//离开发现页面
fun logDiscoverPageQuit(sequence: Int) {
val json = json {
"event" to "discover_page_quit"
"sequence" to sequence
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
//发现页面可见事件
fun logDiscoverPageVisible() {
val json = json {
"event" to "discover_page_visible"
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
//发现页面不可见事件
fun logDiscoverPageInvisible(sequence: Int) {
val json = json {
"event" to "discover_page_invisible"
"sequence" to sequence
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
//页面顶部露出
fun logDiscoverPageTopVisible(countNum: Int) {
val json = json {
"event" to "discover_page_top_visible"
"count_num" to countNum
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
//页面底部停留
fun logDiscoverPageBottomStay(countNum: Int) {
val json = json {
"event" to "discover_page_bottom_stay"
"count_num" to countNum
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
//点击兴趣推荐卡片
fun logDiscoverPageRecommendedInterestCardClick(sequence: Int, linkText: String, linkType: String, linkId: String) {
val json = json {
"event" to "discover_page_recommended_interest_card_click"
"sequence" to sequence
"link_text" to linkText
"link_type" to linkType
"link_id" to linkId
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
//点击跳转游戏库
fun logDiscoverPageJumpGamesLibraries() {
val json = json {
"event" to "discover_page_jump_games_libraries"
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
//触发不感兴趣
fun logDiscoverPageNotInterest(gameId: String, gameName: String) {
val json = json {
"event" to "discover_page_not_interest"
"game_id" to gameId
"game_name" to gameName
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
//跳过广告
@JvmStatic
fun logOpenScreenAdSkip(adId: String, linkText: String, linkType: String, linkId: String) {
val json = json {
"event" to "open_screen_ad_skip"
"ad_id" to adId
"link_text" to linkText
"link_type" to linkType
"link_id" to linkId
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
//游戏单广场浏览时长
fun logGameCollectSquareStayTime(interval: Long) {
val json = json {
"event" to "game_collect_square_stay_time"
"interval" to interval
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
//游戏单浏览时长
fun logGameCollectStayTime(interval: Long, id: String, title: String) {
val json = json {
"event" to "game_collect_stay_time"
"interval" to interval
"game_collect_id" to id
"game_collect_title" to title
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
// 游戏存档页面展示事件
fun logGameArchivePageShow(tabName: String) {
val json = json {
"event" to "cloud_save_game_save_page_show"
"tab_name" to tabName
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
// 云存档管理页面展示事件
fun logCloudArchiveManagePageShow(gameId: String, gameName: String, entrance: String) {
val json = json {
"event" to "cloud_save_manage_page_show"
"game_id" to gameId
"game_name" to gameName
"entrance" to entrance
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
// 云存档Tab页面展示事件
fun logCloudArchiveTabShow(gameId: String, gameName: String, tabName: String) {
val json = json {
"event" to "cloud_save_tab_page_show"
"game_id" to gameId
"game_name" to gameName
"tab_name" to tabName
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
// 存档分享弹窗展示事件
fun logCloudArchiveShareDialogShow() {
val json = json {
"event" to "cloud_save_share_dialog_show"
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
// 存档分享弹窗点击事件
fun logCloudArchiveShareDialogClick(buttonType: String) {
val json = json {
"event" to "cloud_save_share_dialog_click"
"button_type" to buttonType
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
// 存档分享弹窗分享结果事件
fun logCloudArchiveShareDialogResult(shareResult: String) {
val json = json {
"event" to "cloud_save_share_dialog_result"
"share_result" to shareResult
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
// 存档删除弹窗展示事件
fun logCloudArchiveDeleteDialogShow() {
val json = json {
"event" to "cloud_save_delete_dialog_show"
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
// 存档删除弹窗点击事件
fun logCloudArchiveDeleteDialogClick(buttonType: String) {
val json = json {
"event" to "cloud_save_delete_dialog_click"
"button_type" to buttonType
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
// 上传存档弹窗展示事件
fun logCloudArchiveUploadDialogShow() {
val json = json {
"event" to "cloud_save_upload_dialog_show"
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
// 上传存档弹窗点击事件
fun logCloudArchiveUploadDialogClick(buttonType: String) {
val json = json {
"event" to "cloud_save_upload_dialog_click"
"button_type" to buttonType
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
// 畅玩助手下载提示弹窗展示事件
fun logCloudArchiveVSpaceDownloadDialogShow() {
val json = json {
"event" to "cloud_save_halo_fun_download_dialog_show"
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
// 畅玩助手下载提示弹窗点击事件
fun logCloudArchiveVSpaceDownloadDialogClick(buttonType: String) {
val json = json {
"event" to "cloud_save_halo_fun_download_dialog_click"
"button_type" to buttonType
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
// 游戏下载提示弹窗展示事件
fun logCloudArchiveGameDownloadDialogShow() {
val json = json {
"event" to "cloud_save_game_download_dialog_show"
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
// 游戏下载提示弹窗点击事件
fun logCloudArchiveGameDownloadDialogClick(buttonType: String) {
val json = json {
"event" to "cloud_save_game_download_dialog_click"
"button_type" to buttonType
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
// 推荐游戏页面下载游戏事件
fun logCloudArchiveRecommendGameDownload(gameId: String, gameName: String) {
val json = json {
"event" to "cloud_save_recommend_game_page_download"
"game_id" to gameId
"game_name" to gameName
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
// 搜索功能关键词上传事件
fun logCloudArchiveSearchKeyUpload(gameId: String, gameName: String, key: String) {
val json = json {
"event" to "cloud_save_search_key_upload"
"game_id" to gameId
"game_name" to gameName
"key" to key
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
// 云存档Tab展示事件/云存档Tab展示事件
fun logCloudArchiveGameDetailTabRelated(event: String, gameId: String, gameName: String) {
val json = json {
"event" to event
"game_id" to gameId
"game_name" to gameName
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
// 云存档下载/使用事件
fun logCloudArchiveDownloadOrApply(archiveName: String, entrance: String) {
val json = json {
"event" to "cloud_save_download"
"cloud_save_name" to archiveName
"entrance" to entrance
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
// 存档覆盖风险提示弹窗展示事件/存档覆盖风险提示弹窗点击事件
fun logCloudArchiveApplyDialogRelated(event: String, buttonType: String = "") {
val json = json {
"event" to event
if (buttonType.isNotBlank()) {
"button_type" to buttonType
}
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
// 进入发现页详情
fun logDiscoverDetailPageEnter(entrance: String, blockName: String = "") {
val json = json {
"event" to "discover_detail_page_enter"
"entrance" to entrance
if (blockName.isNotBlank()) {
"block_name" to blockName
}
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
// 点击设置偏好
fun logInterestedGameClick(entrance: String, blockName: String = "") {
val json = json {
"event" to "discover_preference_settings_click"
"entrance" to entrance
if (blockName.isNotBlank()) {
"block_name" to blockName
}
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
// 进入游戏偏好页面
fun logInterestedGamePageEnter(frequency: String, prefer: String, tendency: String, typeTags: JSONArray) {
val json = json {
"event" to "discover_preference_game_page_enter"
"frequency" to frequency
"prefer" to prefer
"tendency" to tendency
"type_tags" to typeTags
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
// 离开游戏偏好页面
fun logInterestedGamePageExit(
frequency: String,
prefer: String,
tendency: String,
typeTags: JSONArray,
) {
val json = json {
"event" to "discover_preference_game_page_quit"
"frequency" to frequency
"prefer" to prefer
"tendency" to tendency
"type_tags" to typeTags
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
// 浏览游戏偏好页面
fun logInterestedGamePageBrowse(
frequency: String,
prefer: String,
tendency: String,
typeTags: JSONArray,
interval: Long
) {
val json = json {
"event" to "discover_preference_game_view"
"frequency" to frequency
"prefer" to prefer
"tendency" to tendency
"type_tags" to typeTags
"interval" to interval
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
// 展开感兴趣的分类弹窗
fun logInterestedGameTypeDialogShow(typeTags: JSONArray) {
val json = json {
"event" to "discover_preference_type_tags_dialog_show"
"type_tags" to typeTags
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
// 关闭感兴趣的分类弹窗
fun logInterestedGameTypeDialogClose(typeTags: JSONArray) {
val json = json {
"event" to "discover_preference_type_tags_dialog_close"
"type_tags" to typeTags
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
// 浏览感兴趣的分类弹窗
fun logInterestedGameTypeDialogBrowse(typeTags: JSONArray, interval: Long) {
val json = json {
"event" to "discover_preference_type_tags_dialog_view"
"type_tags" to typeTags
"interval" to interval
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
//游戏详情-游戏单推荐,点击右上角进入游戏单广场时触发
fun logGameDetailGameListRecommendSquareJump(gameName: String, gameId: String) {
val json = json {
"event" to "game_detail_game_list_recommend_square_jump"
"game_name" to gameName
"game_id" to gameId
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
//游戏详情-专题推荐,点击右上角时触发
fun logGameDetailColumnRecommendUpperRightClick(
gameName: String,
gameId: String,
buttonType: String,
columnName: String,
columnId: String,
linkText: String,
linkType: String,
linkId: String
) {
val json = json {
"event" to "game_detail_column_recommend_upper_right_click"
"game_name" to gameName
"game_id" to gameId
"button_type" to buttonType
"column_name" to columnName
"column_id" to columnId
"link_text" to linkText
"link_type" to linkType
"link_id" to linkId
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
//用户通过活动页的“立即投稿/添加”成功创建游戏单时上报
fun logActivityGameListCreateSuccessV2(
entrance: String,
gameId: String,
gameName: String,
gameCollectId: String,
gameCollectTitle: String,
activityId: String,
activityName: String,
) {
val json = json {
"event" to "activity_game_list_create_success_v2"
"entrance" to entrance
if (gameId.isNotEmpty()) {
"game_id" to gameId
}
if (gameName.isNotEmpty()) {
"game_name" to gameName
}
"game_collect_id" to gameCollectId
"game_collect_title" to gameCollectTitle
"activity_id" to activityId
"activity_name" to activityName
parseAndPutMeta().invoke(this)
}
log(json, "event", false)
}
}

View File

@ -1,7 +1,6 @@
package com.gh.common.util
import android.annotation.SuppressLint
import com.gh.gamecenter.common.entity.WechatConfigEntity
import com.gh.gamecenter.common.json.JsonObjectBuilder
import com.gh.gamecenter.common.json.json
import com.gh.gamecenter.common.loghub.LoghubUtils
@ -9,10 +8,12 @@ import com.gh.gamecenter.common.retrofit.EmptyResponse
import com.gh.gamecenter.common.tracker.Tracker
import com.gh.gamecenter.common.utils.toRequestBody
import com.gh.gamecenter.entity.QuoteCountEntity
import com.gh.gamecenter.entity.WechatConfigEntity
import com.gh.gamecenter.retrofit.RetrofitManager
import com.lightgame.utils.Utils
import io.reactivex.schedulers.Schedulers
import okhttp3.ResponseBody
import org.json.JSONArray
import org.json.JSONObject
object NewLogUtils {
@ -1895,6 +1896,20 @@ object NewLogUtils {
log(json, "appointment", false)
}
//点击微信提醒
@JvmStatic
fun logWechatRemindConfigClick(wechatConfigEntity: WechatConfigEntity) {
val json = json {
"event" to "appointment_wechat_remind_config_click"
"wechat_is_bind" to wechatConfigEntity.bind
"wechat_is_follow" to wechatConfigEntity.follow
"wechat_is_remind" to wechatConfigEntity.notice
"timestamp" to System.currentTimeMillis() / 1000
parseAndPutMeta().invoke(this)
}
log(json, "appointment", false)
}
//选择图片上传方式
@JvmStatic
fun logShowGameCollectionCoverTypeDialog() {

View File

@ -55,11 +55,11 @@ object PackageInstaller {
fun install(context: Context, downloadEntity: DownloadEntity, showUnzipToast: Boolean) {
val pkgPath = downloadEntity.path
val isXapk = XapkInstaller.XAPK_EXTENSION_NAME == pkgPath.getExtension()
val isVGame = downloadEntity.getMetaExtra(Constants.SMOOTH_GAME) == "true"
val isSmoothGame = downloadEntity.getMetaExtra(Constants.SMOOTH_GAME) == "true"
val currentActivity = CurrentActivityHolder.getCurrentActivity() ?: return
if (isVGame) {
if (isSmoothGame) {
VHelper.install(currentActivity, downloadEntity)
return
}

View File

@ -1017,7 +1017,7 @@ public class PackageUtils {
public static boolean checkWebViewIsAvailable(Context context) {
List<String> webViewAbiList = HaloApp.getInstance().getWebViewAbiList();
if (webViewAbiList != null && !webViewAbiList.isEmpty()) {
if (webViewAbiList != null) {
if (webViewAbiList.size() == 2 && webViewAbiList.contains("x86") && webViewAbiList.contains("x86_64")) {
return true;
}

View File

@ -8,9 +8,9 @@ import com.gh.gamecenter.R
import com.gh.gamecenter.WebActivity
import com.gh.gamecenter.common.callback.CancelListener
import com.gh.gamecenter.common.callback.ConfirmListener
import com.gh.gamecenter.common.entity.WechatConfigEntity
import com.gh.gamecenter.core.utils.*
import com.gh.gamecenter.entity.GameEntity
import com.gh.gamecenter.entity.WechatConfigEntity
import com.gh.gamecenter.common.retrofit.BiResponse
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.retrofit.RetrofitManager

View File

@ -3,11 +3,11 @@ package com.gh.common.util
import android.annotation.SuppressLint
import com.gh.gamecenter.common.callback.BiCallback
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.entity.WechatConfigEntity
import com.gh.gamecenter.core.utils.SPUtils
import com.gh.gamecenter.common.utils.createRequestBody
import com.gh.gamecenter.common.utils.singleToMain
import com.gh.gamecenter.common.utils.toJson
import com.gh.gamecenter.entity.WechatConfigEntity
import com.gh.gamecenter.login.user.UserManager
import com.gh.gamecenter.common.retrofit.BiResponse
import com.gh.gamecenter.retrofit.RetrofitManager

View File

@ -12,10 +12,9 @@ import android.widget.PopupWindow
import android.widget.TextView
import androidx.annotation.ColorInt
import androidx.core.content.ContextCompat
import com.gh.gamecenter.R
import com.gh.gamecenter.common.utils.setDrawableEnd
import com.gh.gamecenter.common.utils.toColor
import com.gh.gamecenter.common.utils.visibleIf
import com.gh.gamecenter.R
import com.gh.gamecenter.entity.CatalogEntity
import com.gh.gamecenter.entity.SubjectSettingEntity
import com.google.android.flexbox.FlexboxLayout
@ -95,8 +94,13 @@ class CatalogFilterView @JvmOverloads constructor(
}
private fun showSelectTypePopupWindow(containerView: View, typeTv: TextView, typeText: String) {
val drawableUp = ContextCompat.getDrawable(typeTv.context, R.drawable.ic_filter_arrow_up)
val drawableDown = ContextCompat.getDrawable(typeTv.context, R.drawable.ic_filter_arrow_down)
drawableUp?.setBounds(0, 0, drawableUp.minimumWidth, drawableUp.minimumHeight)
drawableDown?.setBounds(0, 0, drawableDown.minimumWidth, drawableDown.minimumHeight)
typeTv.setTextColor(R.color.theme_font.toColor(context))
typeTv.setDrawableEnd(R.drawable.ic_filter_arrow_up)
typeTv.setCompoundDrawables(null, null, drawableUp, null)
val inflater = LayoutInflater.from(typeTv.context)
val layout = inflater.inflate(R.layout.layout_filter_size, null)
@ -141,7 +145,7 @@ class CatalogFilterView @JvmOverloads constructor(
popupWindow.setOnDismissListener {
typeTv.setTextColor(R.color.text_757575.toColor(context))
typeTv.setDrawableEnd(R.drawable.ic_filter_arrow_down)
typeTv.setCompoundDrawables(null, null, drawableDown, null)
mTypePopupWindow = null
}
@ -152,8 +156,13 @@ class CatalogFilterView @JvmOverloads constructor(
}
private fun showSelectCatalogPopupWindow(containerView: View, catalogTv: TextView, catalogText: String) {
val drawableUp = ContextCompat.getDrawable(catalogTv.context, R.drawable.ic_filter_arrow_up)
val drawableDown = ContextCompat.getDrawable(catalogTv.context, R.drawable.ic_filter_arrow_down)
drawableUp?.setBounds(0, 0, drawableUp.minimumWidth, drawableUp.minimumHeight)
drawableDown?.setBounds(0, 0, drawableDown.minimumWidth, drawableDown.minimumHeight)
catalogTv.setTextColor(R.color.theme_font.toColor(context))
catalogTv.setDrawableEnd(R.drawable.ic_filter_arrow_up)
catalogTv.setCompoundDrawables(null, null, drawableUp, null)
val inflater = LayoutInflater.from(catalogTv.context)
val layout = inflater.inflate(R.layout.layout_filter_size, null)
@ -200,7 +209,7 @@ class CatalogFilterView @JvmOverloads constructor(
popupWindow.setOnDismissListener {
catalogTv.setTextColor(R.color.text_757575.toColor(context))
catalogTv.setDrawableEnd(R.drawable.ic_filter_arrow_down)
catalogTv.setCompoundDrawables(null, null, drawableDown, null)
mCatalogPopupWindow = null
}
@ -211,8 +220,13 @@ class CatalogFilterView @JvmOverloads constructor(
}
private fun showSelectSizePopupWindow(containerView: View, sizeTv: TextView, sizeText: String) {
val drawableUp = ContextCompat.getDrawable(sizeTv.context, R.drawable.ic_filter_arrow_up)
val drawableDown = ContextCompat.getDrawable(sizeTv.context, R.drawable.ic_filter_arrow_down)
drawableUp?.setBounds(0, 0, drawableUp.minimumWidth, drawableUp.minimumHeight)
drawableDown?.setBounds(0, 0, drawableDown.minimumWidth, drawableDown.minimumHeight)
sizeTv.setTextColor(R.color.theme_font.toColor(context))
sizeTv.setDrawableEnd(R.drawable.ic_filter_arrow_up)
sizeTv.setCompoundDrawables(null, null, drawableUp, null)
val inflater = LayoutInflater.from(sizeTv.context)
val layout = inflater.inflate(R.layout.layout_filter_size, null)
@ -267,7 +281,7 @@ class CatalogFilterView @JvmOverloads constructor(
popupWindow.setOnDismissListener {
sizeTv.setTextColor(R.color.text_757575.toColor(context))
sizeTv.setDrawableEnd(R.drawable.ic_filter_arrow_down)
sizeTv.setCompoundDrawables(null, null, drawableDown, null)
mSizePopupWindow = null
}

View File

@ -11,10 +11,9 @@ import android.widget.PopupWindow
import android.widget.TextView
import androidx.annotation.ColorInt
import androidx.core.content.ContextCompat
import com.gh.gamecenter.R
import com.gh.gamecenter.common.utils.dip2px
import com.gh.gamecenter.common.utils.setDrawableEnd
import com.gh.gamecenter.common.utils.toColor
import com.gh.gamecenter.R
import com.gh.gamecenter.entity.SubjectSettingEntity
import com.google.android.flexbox.FlexboxLayout
@ -90,8 +89,13 @@ class CategoryFilterView @JvmOverloads constructor(
}
private fun showSelectTypePopupWindow(containerView: View, typeTv: TextView, typeText: String) {
val drawableUp = ContextCompat.getDrawable(typeTv.context, R.drawable.ic_filter_arrow_up)
val drawableDown = ContextCompat.getDrawable(typeTv.context, R.drawable.ic_filter_arrow_down)
drawableUp?.setBounds(0, 0, drawableUp.minimumWidth, drawableUp.minimumHeight)
drawableDown?.setBounds(0, 0, drawableDown.minimumWidth, drawableDown.minimumHeight)
typeTv.setTextColor(R.color.theme_font.toColor(context))
typeTv.setDrawableEnd(R.drawable.ic_filter_arrow_up)
typeTv.setCompoundDrawables(null, null, drawableUp, null)
val inflater = LayoutInflater.from(typeTv.context)
val layout = inflater.inflate(R.layout.layout_filter_size, null)
@ -137,7 +141,7 @@ class CategoryFilterView @JvmOverloads constructor(
popupWindow.setOnDismissListener {
typeTv.setTextColor(R.color.text_757575.toColor(context))
typeTv.setDrawableEnd(R.drawable.ic_filter_arrow_down)
typeTv.setCompoundDrawables(null, null, drawableDown, null)
mTypePopupWindow = null
}
@ -148,8 +152,13 @@ class CategoryFilterView @JvmOverloads constructor(
}
private fun showSelectSizePopupWindow(containerView: View, sizeTv: TextView, sizeText: String) {
val drawableUp = ContextCompat.getDrawable(sizeTv.context, R.drawable.ic_filter_arrow_up)
val drawableDown = ContextCompat.getDrawable(sizeTv.context, R.drawable.ic_filter_arrow_down)
drawableUp?.setBounds(0, 0, drawableUp.minimumWidth, drawableUp.minimumHeight)
drawableDown?.setBounds(0, 0, drawableDown.minimumWidth, drawableDown.minimumHeight)
sizeTv.setTextColor(R.color.theme_font.toColor(context))
sizeTv.setDrawableEnd(R.drawable.ic_filter_arrow_up)
sizeTv.setCompoundDrawables(null, null, drawableUp, null)
val inflater = LayoutInflater.from(sizeTv.context)
val layout = inflater.inflate(R.layout.layout_filter_size, null)
@ -205,7 +214,7 @@ class CategoryFilterView @JvmOverloads constructor(
popupWindow.setOnDismissListener {
sizeTv.setTextColor(R.color.text_757575.toColor(context))
sizeTv.setDrawableEnd(R.drawable.ic_filter_arrow_down)
sizeTv.setCompoundDrawables(null, null, drawableDown, null)
mSizePopupWindow = null
}

View File

@ -9,8 +9,8 @@ import android.widget.LinearLayout
import android.widget.PopupWindow
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.ContextCompat
import com.gh.gamecenter.R
import com.gh.gamecenter.common.utils.setDrawableEnd
import com.gh.gamecenter.common.utils.toColor
import com.gh.gamecenter.common.utils.toDrawable
import com.gh.gamecenter.entity.SubjectSettingEntity
@ -112,8 +112,14 @@ class ConfigFilterView @JvmOverloads constructor(
}
private fun showSelectionPopupWindow(containerView: View, sizeTv: TextView, sizeText: String) {
val drawableUp = ContextCompat.getDrawable(sizeTv.context, R.drawable.ic_filter_arrow_up)
val drawableDown =
ContextCompat.getDrawable(sizeTv.context, R.drawable.ic_filter_arrow_down)
drawableUp?.setBounds(0, 0, drawableUp.minimumWidth, drawableUp.minimumHeight)
drawableDown?.setBounds(0, 0, drawableDown.minimumWidth, drawableDown.minimumHeight)
sizeTv.setTextColor(R.color.theme_font.toColor(sizeTv.context))
sizeTv.setDrawableEnd(R.drawable.ic_filter_arrow_up)
sizeTv.setCompoundDrawables(null, null, drawableUp, null)
val inflater = LayoutInflater.from(sizeTv.context)
val layout = inflater.inflate(R.layout.layout_filter_size, null)
@ -172,7 +178,7 @@ class ConfigFilterView @JvmOverloads constructor(
popupWindow.setOnDismissListener {
sizeTv.setTextColor(R.color.text_757575.toColor(sizeTv.context))
sizeTv.setDrawableEnd(R.drawable.ic_filter_arrow_down)
sizeTv.setCompoundDrawables(null, null, drawableDown, null)
mPopupWindow = null
}

View File

@ -45,7 +45,12 @@ class DownloadButton @JvmOverloads constructor(
}
var text: String
get() = mText
get() {
if (showProgress && mText.contains("%")) {
return context.getString(R.string.downloading)
}
return mText
}
set(value) {
mText = value
invalidate()
@ -118,7 +123,11 @@ class DownloadButton @JvmOverloads constructor(
}
fun setText(@StringRes res: Int) {
text = context.getString(res)
text = if (mShowPercent && res == R.string.downloading) {
"${progress / 10}%"
} else {
context.getString(res)
}
invalidate()
}
@ -147,7 +156,6 @@ class DownloadButton @JvmOverloads constructor(
when (buttonStyle) {
ButtonStyle.NORMAL,
ButtonStyle.INSTALL_NORMAL,
ButtonStyle.XAPK_FAILURE,
ButtonStyle.NONE_WITH_HINT,
ButtonStyle.H5_GAME,
ButtonStyle.SPECIAL_DOWNLOAD,
@ -179,7 +187,6 @@ class DownloadButton @JvmOverloads constructor(
progress = 0
mDefaultColor = R.color.white.toColor(context)
}
ButtonStyle.FAILURE,
ButtonStyle.NONE,
ButtonStyle.RESERVED -> {
progressDrawable = null
@ -194,8 +201,6 @@ class DownloadButton @JvmOverloads constructor(
progress = 0
mDefaultColor = R.color.white.toColor(context)
}
ButtonStyle.XAPK_SUCCESS,
ButtonStyle.XAPK_UNZIPPING,
ButtonStyle.DOWNLOADING_NORMAL -> {
if (showProgress) {
progressDrawable =
@ -234,6 +239,18 @@ class DownloadButton @JvmOverloads constructor(
progress = 0
mDefaultColor = R.color.theme_font.toColor(context)
}
ButtonStyle.FAILURE -> {
progressDrawable = null
background = R.drawable.game_item_btn_pause_style.toDrawable(context)
progress = 0
mDefaultColor = R.color.white.toColor(context)
}
ButtonStyle.XAPK_FAILURE,
ButtonStyle.XAPK_SUCCESS,
ButtonStyle.XAPK_UNZIPPING -> {
mDefaultColor = R.color.white.toColor(context)
progressDrawable = R.drawable.progressbar_xapk_detail_style.toDrawable(context)
}
}
mPaintColor = mDefaultColor
}

View File

@ -14,10 +14,9 @@ import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.gh.gamecenter.R
import com.gh.gamecenter.common.utils.dip2px
import com.gh.gamecenter.common.utils.setDrawableEnd
import com.gh.gamecenter.common.utils.toColor
import com.gh.gamecenter.R
import com.gh.gamecenter.common.utils.toDrawable
import com.gh.gamecenter.databinding.ItemFilterBinding
import com.gh.gamecenter.databinding.LayoutFilterBinding
@ -108,8 +107,13 @@ class FilterView @JvmOverloads constructor(context: Context, attrs: AttributeSet
subFilterText: String,
selectedCallback: ((String) -> Unit)
) {
val drawableUp = ContextCompat.getDrawable(subFilterTv.context, R.drawable.ic_filter_arrow_up)
val drawableDown = ContextCompat.getDrawable(subFilterTv.context, R.drawable.ic_filter_arrow_down)
drawableUp?.setBounds(0, 0, drawableUp.minimumWidth, drawableUp.minimumHeight)
drawableDown?.setBounds(0, 0, drawableDown.minimumWidth, drawableDown.minimumHeight)
subFilterTv.setTextColor(R.color.theme_font.toColor(context))
subFilterTv.setDrawableEnd(R.drawable.ic_filter_arrow_up)
subFilterTv.setCompoundDrawables(null, null, drawableUp, null)
val inflater = LayoutInflater.from(subFilterTv.context)
val layout = inflater.inflate(R.layout.layout_filter_size, null)
@ -159,7 +163,7 @@ class FilterView @JvmOverloads constructor(context: Context, attrs: AttributeSet
}
popupWindow.setOnDismissListener {
subFilterTv.setDrawableEnd(R.drawable.ic_filter_arrow_down)
subFilterTv.setCompoundDrawables(null, null, drawableDown, null)
}
popupWindow.isTouchable = true

View File

@ -6,19 +6,18 @@ import android.graphics.drawable.GradientDrawable
import android.text.TextUtils
import android.util.AttributeSet
import android.view.View
import androidx.annotation.ColorRes
import androidx.cardview.widget.CardView
import com.facebook.drawee.generic.RoundingParams
import com.facebook.drawee.view.SimpleDraweeView
import com.gh.gamecenter.R
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.common.view.RadiusCardView
import com.gh.gamecenter.core.utils.DisplayUtils
import com.gh.gamecenter.entity.GameEntity
import splitties.views.dsl.core.add
import splitties.views.dsl.core.lParams
import splitties.views.dsl.core.matchParent
class GameIconView : RadiusCardView {
class GameIconView : CardView {
private var mCornerRadius = 0
private var mBorderColor = 0
@ -29,7 +28,6 @@ class GameIconView : RadiusCardView {
private var mGameIconIv: SimpleDraweeView? = null
private var mGameIconDecorationIv: SimpleDraweeView? = null
private var mBorderView: View? = null
private var mIsRemoveCrevice = false
constructor(context: Context) : super(context, null) {
initView(null)
@ -60,7 +58,6 @@ class GameIconView : RadiusCardView {
mGameIconOverlayColor = ta.getColor(R.styleable.GameIconView_gameIconOverlayColor, 0)
mBorderWidth = ta.getDimensionPixelSize(R.styleable.GameIconView_gameIconBorderWidth, 1)
mFadeDuration = ta.getInt(R.styleable.GameIconView_gameIconFadeDuration, -1)
mIsRemoveCrevice = ta.getBoolean(R.styleable.GameIconView_gameIconRemoveCrevice, false)
ta.recycle()
}
@ -115,17 +112,14 @@ class GameIconView : RadiusCardView {
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
super.onSizeChanged(w, h, oldw, oldh)
setBorder(w)
}
private fun setBorder(width: Int) {
val cornerRadius = if (!isInEditMode) {
getCornerRadius(width)
getCornerRadius(w)
} else {
0F
}
setRadiusPx(cornerRadius, cornerRadius, cornerRadius, cornerRadius)
radius = cornerRadius
cardElevation = 0F
// 一些设备(没错,又是 vivo),代码设置 CardView 的 radius 无效(xml 设置有效)
@ -137,24 +131,16 @@ class GameIconView : RadiusCardView {
if (mBorderColor != 0) {
// 当图片为动图时设置边框无效所以改为增加一个View专门用来设置边框
//roundingParams.setBorder(mBorderColor, mBorderWidth.toFloat())
// roundingParams.setBorder(mBorderColor, mBorderWidth.toFloat())
val drawable = GradientDrawable().apply {
shape = GradientDrawable.RECTANGLE
//骚操作~ 这里加这个操作是为了防止图片和边框有间隙
setCornerRadius(cornerRadius - if (mIsRemoveCrevice) mBorderWidth else 0)
setCornerRadius(cornerRadius)
setColor(R.color.transparent.toColor())
setStroke(mBorderWidth, mBorderColor)
}
mBorderView?.background = drawable
}
//骚操作~ 这里加这个操作是为了防止图片和边框有间隙、防止右上角的静态小标签都被挡住
if (mBorderWidth != 0) {
val halfBorderWidth = (mBorderWidth / 2F).toInt()
mGameIconIv?.setPadding(halfBorderWidth, halfBorderWidth, halfBorderWidth, halfBorderWidth)
mGameIconDecorationIv?.setPadding(halfBorderWidth, halfBorderWidth, halfBorderWidth, halfBorderWidth)
}
mGameIconIv?.hierarchy?.roundingParams = roundingParams
mGameIconDecorationIv?.hierarchy?.roundingParams = roundingParams
}
@ -163,11 +149,6 @@ class GameIconView : RadiusCardView {
mCornerRadius = cornerRadius
}
fun setBorderColor(@ColorRes color: Int) {
mBorderColor = color.toColor(context)
setBorder(measuredWidth)
}
private fun getCornerRadius(width: Int): Float {
// 预设的圆角设置优先级更高
if (mCornerRadius != 0) {

View File

@ -1,38 +0,0 @@
package com.gh.common.view
import android.content.Context
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatTextView
/**
* 去除省略号后面空白的TextView
*/
class NoEllipsizeSpaceTextView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) :
AppCompatTextView(context, attrs, defStyleAttr) {
override fun setText(text: CharSequence?, type: BufferType?) {
super.setText(text, type)
post {
if (layout != null) {
val rawText = layout.text.toString()
if (rawText.contains(ELLIPSIS_NORMAL)) {
val index = rawText.indexOf(ELLIPSIS_BLANK)
var trimText = rawText
if (index > 0) {
trimText = rawText.substring(0, index)
}
trimText = rawText.substring(0, trimText.length - 1) + ELLIPSIS_NORMAL
setText(trimText)
}
}
}
}
companion object {
private const val ELLIPSIS_NORMAL = "\u2026" // 省略号字符(...)
private const val ELLIPSIS_BLANK = "\uFEFF" // 空白字符
}
}

View File

@ -36,7 +36,6 @@ import com.gh.common.util.PackageUtils;
import com.gh.gamecenter.core.utils.PageSwitchDataHelper;
import com.gh.gamecenter.core.utils.SPUtils;
import com.gh.gamecenter.BuildConfig;
import com.gh.gamecenter.core.utils.SentryHelper;
import com.gh.gamecenter.download.DownloadedGameIdAndPackageNameDao;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.GameEntity;
@ -390,16 +389,12 @@ public class DownloadManager implements DownloadStatusListener {
* 清理不存在本地 APK 文件的任务
*/
public void clearTasksThatFileBeenDeleted() {
try {
for (DownloadEntity entity : getAllDownloadEntity()) {
if (entity.getStatus() == DownloadStatus.done) {
if (FileUtils.isEmptyFile(entity.getPath())) {
cancel(entity.getUrl());
}
for (DownloadEntity entity : getAllDownloadEntity()) {
if (entity.getStatus() == DownloadStatus.done) {
if (FileUtils.isEmptyFile(entity.getPath())) {
cancel(entity.getUrl());
}
}
} catch (Exception e) {
SentryHelper.INSTANCE.onEvent("CLEAR_DELETED_TASK_ERROR", "exception_digest", e.getLocalizedMessage());
}
}
@ -579,7 +574,7 @@ public class DownloadManager implements DownloadStatusListener {
* @return null表示下载列表中不存在该任务否则返回下载任务
*/
@Nullable
public DownloadEntity getDownloadEntitySnapshot(String url, String gameId, boolean isVGame) {
private DownloadEntity getDownloadEntitySnapshot(String url, String gameId, boolean isVGame) {
DownloadEntity snapshot = null;
if (isVGame && !TextUtils.isEmpty(gameId)) {
@ -693,14 +688,6 @@ public class DownloadManager implements DownloadStatusListener {
return filterSilentDownloadTask(all);
}
/**
* 获取下载列表中除下载状态为完成以外的任务
*/
public List<DownloadEntity> getAllDownloadEntityExcludeDoneTask() {
List<DownloadEntity> all = getAllDownloadEntity();
return filterDoneDownloadTask(all);
}
/**
* 获取下载列表中的畅玩下载任务快照
*/
@ -741,20 +728,6 @@ public class DownloadManager implements DownloadStatusListener {
return filteredDownloadEntityList;
}
private ArrayList<DownloadEntity> filterDoneDownloadTask(List<DownloadEntity> downloadEntityList) {
ArrayList<DownloadEntity> filteredDownloadEntityList = new ArrayList<>();
if (downloadEntityList == null) return filteredDownloadEntityList;
for (DownloadEntity downloadEntity : downloadEntityList) {
if (downloadEntity.getStatus() != DownloadStatus.done) {
filteredDownloadEntityList.add(downloadEntity);
}
}
return filteredDownloadEntityList;
}
public ArrayMap<String, DownloadEntity> getEntryMap(String name) {
return gameMap.get(name);
}
@ -895,7 +868,7 @@ public class DownloadManager implements DownloadStatusListener {
Utils.log(DownloadManager.class.getSimpleName(), "addObserver");
DataChanger.INSTANCE.addObserver(dataWatcher);
notifyDownloadStatusASAP(dataWatcher);
notifyDownloadedStatusASAP(dataWatcher);
}
/**
@ -907,11 +880,13 @@ public class DownloadManager implements DownloadStatusListener {
}
/**
* 立马通知 dataWatcher 更新下载任务状态
* 立马通知 dataWatcher 更新下载完的任务状态,这里的下载完成是持久状态,不是瞬时状态
*/
private void notifyDownloadStatusASAP(DataWatcher dataWatcher) {
private void notifyDownloadedStatusASAP(DataWatcher dataWatcher) {
for (DownloadEntity downloadEntity : getAllDownloadEntitySnapshots()) {
dataWatcher.onDataInit(downloadEntity);
if (downloadEntity.getStatus() == DownloadStatus.done) {
dataWatcher.onDataInit(downloadEntity);
}
}
}
@ -976,7 +951,7 @@ public class DownloadManager implements DownloadStatusListener {
public void checkAndRetryDownload() {
if (!NetworkUtils.isWifiConnected(mContext)) return;
for (DownloadEntity downloadEntity : DownloadManager.getInstance().getAllDownloadEntityExcludeDoneTask()) {
for (DownloadEntity downloadEntity : DownloadManager.getInstance().getAllDownloadEntityExcludeSilentTask()) {
if (DownloadStatus.neterror.equals(downloadEntity.getStatus())
|| DownloadStatus.timeout.equals(downloadEntity.getStatus())
|| DownloadStatus.subscribe.equals(downloadEntity.getStatus())) {

View File

@ -22,7 +22,7 @@ import com.gh.gamecenter.login.user.UserManager
import com.gh.gamecenter.packagehelper.PackageRepository
import com.gh.gamecenter.packagehelper.PackageViewModel
import com.gh.gamecenter.retrofit.RetrofitManager
import com.gh.gamecenter.setting.view.GameDownloadSettingFragment
import com.gh.gamecenter.setting.GameDownloadSettingFragment.Companion.CONCERN_GAME_SP_KEY
import com.halo.assistant.HaloApp
import com.lightgame.download.DownloadEntity
import com.lightgame.download.FileUtils
@ -91,7 +91,7 @@ object PackageObserver {
gameId = approximateGameId
}
if (EBPackage.TYPE_INSTALLED == busFour.type) {
if ("安装" == busFour.type) {
mPackageViewModel.addInstalledGame(packageName)
BrowserInstallHelper.onApkInstalled(mDownloadEntity?.path)
@ -109,7 +109,7 @@ object PackageObserver {
DownloadManager.getInstance().cancel(mDownloadEntity.url, false, true, false)
if (SPUtils.getBoolean(GameDownloadSettingFragment.CONCERN_GAME_SP_KEY, true)) { //设置页面控制是否安装后自动关注
if (SPUtils.getBoolean(CONCERN_GAME_SP_KEY, true)) { //设置页面控制是否安装后自动关注
// 安装后关注游戏
val finalDownloadEntity = mDownloadEntity
RetrofitManager.getInstance().api

View File

@ -14,19 +14,17 @@ import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import androidx.recyclerview.widget.*
import androidx.recyclerview.widget.RecyclerView.SmoothScroller
import com.gh.gamecenter.core.utils.TimeElapsedHelper
import com.gh.gamecenter.common.base.fragment.BaseDraggableDialogFragment
import com.gh.common.exposure.ExposureEvent
import com.gh.common.util.*
import com.gh.download.DownloadManager
import com.gh.gamecenter.BuildConfig
import com.gh.gamecenter.R
import com.gh.gamecenter.common.base.activity.ToolBarActivity
import com.gh.gamecenter.common.base.fragment.BaseDraggableDialogFragment
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.utils.goneIf
import com.gh.gamecenter.common.utils.observeNonNull
import com.gh.gamecenter.common.utils.throwExceptionInDebug
import com.gh.gamecenter.core.AppExecutor
import com.gh.gamecenter.core.utils.TimeElapsedHelper
import com.gh.gamecenter.databinding.DialogDownloadBinding
import com.gh.gamecenter.entity.ApkEntity
import com.gh.gamecenter.entity.GameEntity
@ -50,9 +48,6 @@ class DownloadDialog : BaseDraggableDialogFragment() {
private var mAdapter: DownloadDialogAdapter? = null
private var mTraceEvent: ExposureEvent? = null
private var mPlatformName: String = ""
private var mPackageName: String = ""
private var mParentBundle: Bundle? = null
// 合集页面保持和后台一样的顺序
private var mCollectionAdapter: DownloadDialogAdapter? = null
@ -96,9 +91,6 @@ class DownloadDialog : BaseDraggableDialogFragment() {
EventBus.getDefault().register(this)
super.onCreate(savedInstanceState)
mParentBundle = requireActivity().intent.extras?.getBundle(ToolBarActivity.NORMAL_FRAGMENT_BUNDLE)
mPlatformName = mParentBundle?.getString(EntranceConsts.KEY_PLATFORM, "") ?: ""
mPackageName = mParentBundle?.getString(EntranceConsts.KEY_PACKAGENAME, "") ?: ""
mGameEntity = requireArguments().getParcelable(GameEntity::class.java.simpleName)!!
mEntrance = requireArguments().getString(EntranceConsts.KEY_ENTRANCE) ?: ""
mLocation = requireArguments().getString(EntranceConsts.KEY_LOCATION) ?: ""
@ -114,7 +106,6 @@ class DownloadDialog : BaseDraggableDialogFragment() {
DownloadDialogAdapter(requireContext(), mViewModel, itemList, false, mTraceEvent, mEntrance, mLocation)
mBinding.contentList.layoutManager = createLayoutManager(itemList)
mBinding.contentList.adapter = mAdapter
performAutoDownload(itemList, mBinding.contentList)
})
mViewModel.collectionLiveData.observe(this, Observer { collection ->
@ -154,7 +145,7 @@ class DownloadDialog : BaseDraggableDialogFragment() {
)
mBinding.collectionList.layoutManager = createLayoutManager(itemList)
mBinding.collectionList.adapter = mCollectionAdapter
performAutoDownload(itemList, mBinding.collectionList)
if (mAdapter != null) collectionEnterAnimation()
} else {
mBinding.title.text = ("选择下载" + mGameEntity?.pluginDesc + "版本")
@ -170,41 +161,6 @@ class DownloadDialog : BaseDraggableDialogFragment() {
mElapsedHelper = TimeElapsedHelper()
}
//自动下载
private fun performAutoDownload(itemList: List<DownloadDialogItemData>, recyclerView: RecyclerView) {
if (mPlatformName.isEmpty() && mPackageName.isEmpty()) return
AppExecutor.uiExecutor.executeWithDelay({
recyclerView.adapter?.let {
for (i in 0 until it.itemCount) {
val apkEntity = itemList[i].normal ?: continue
val apkCollection = apkEntity.apkCollection
if (apkCollection != null) {
if (apkCollection.name == mPlatformName) {
scrollAndDownload(recyclerView, false, i)
break
}
}
if (apkEntity.getPlatformName() == mPlatformName || apkEntity.packageName == mPackageName) {
scrollAndDownload(recyclerView, true, i)
break
}
}
}
}, 200)
}
private fun scrollAndDownload(recyclerView: RecyclerView, isResetBundle: Boolean, position: Int) {
recyclerView.scrollToPosition(position)
AppExecutor.uiExecutor.executeWithDelay({
val viewHolder = recyclerView.findViewHolderForAdapterPosition(position)
viewHolder?.itemView?.performClick()
if (isResetBundle) {
mParentBundle?.putString(EntranceConsts.KEY_PLATFORM, "")
mParentBundle?.putString(EntranceConsts.KEY_PACKAGENAME, "")
}
}, 200)
}
@SuppressLint("ClickableViewAccessibility")
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
mBinding = DialogDownloadBinding.bind(layoutInflater.inflate(R.layout.dialog_download, container, false))

View File

@ -83,7 +83,7 @@ class DownloadDialogItemViewHolder(val binding: DownloadDialogItemBinding) : Bas
binding.containerView.setBackgroundResource(R.drawable.download_dialog_item_background)
binding.status.removeDrawable()
binding.status.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null)
changeRecommendUI(apkEntity, listData, position)
if (apkLink != null) {
@ -95,7 +95,12 @@ class DownloadDialogItemViewHolder(val binding: DownloadDialogItemBinding) : Bas
binding.remark.goneIf(apkLink.remark.isEmpty())
binding.status.text = "点击查看"
binding.status.setDrawableEnd(R.drawable.download_dialog_collection_status_link)
binding.status.setCompoundDrawablesWithIntrinsicBounds(
null,
null,
ContextCompat.getDrawable(binding.status.context, R.drawable.download_dialog_collection_status_link),
null
)
binding.containerView.setBackgroundResource(R.drawable.download_dialog_installed_background)
itemView.setTag(DownloadDialogAdapter.ITEM_TAG_KEY, DownloadDialogItemStatus.LINK)
} else if (apkCollection != null || (!isCollectionPage && apkEntity.downloadInstruction.isNotEmpty())) {
@ -144,7 +149,15 @@ class DownloadDialogItemViewHolder(val binding: DownloadDialogItemBinding) : Bas
binding.status.visibility = View.VISIBLE
binding.status.text = "可更新"
binding.status.setDrawableEnd(R.drawable.download_dialog_collection_status_update)
binding.status.setCompoundDrawablesWithIntrinsicBounds(
null,
null,
ContextCompat.getDrawable(
binding.status.context,
R.drawable.download_dialog_collection_status_update
),
null
)
binding.downloadStatusIcon.visibility = View.GONE
itemView.setTag(DownloadDialogAdapter.ITEM_TAG_KEY, DownloadDialogItemStatus.UPDATE)
} else if (PackageUtils.getGhId(apkEntity.packageName) == gameEntity.id ||
@ -171,7 +184,15 @@ class DownloadDialogItemViewHolder(val binding: DownloadDialogItemBinding) : Bas
// 点击启动
binding.status.text = "点击启动"
itemView.setTag(DownloadDialogAdapter.ITEM_TAG_KEY, DownloadDialogItemStatus.LAUNCH)
binding.status.setDrawableEnd(R.drawable.download_dialog_collection_status_launch)
binding.status.setCompoundDrawablesWithIntrinsicBounds(
null,
null,
ContextCompat.getDrawable(
binding.status.context,
R.drawable.download_dialog_collection_status_launch
),
null
)
}
} else {
binding.downloadStatusIcon.visibility = View.VISIBLE

View File

@ -1,25 +0,0 @@
package com.gh.download.simple
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
class AutoUnregisteredSimpleDownloadListener(var id: String, fragment: Fragment, var listener: DownloadListener) {
init {
fragment.parentFragmentManager.registerFragmentLifecycleCallbacks(
object : FragmentManager.FragmentLifecycleCallbacks() {
override fun onFragmentViewDestroyed(fm: FragmentManager, f: Fragment) {
super.onFragmentViewDestroyed(fm, f)
if (f === fragment) {
DownloadMessageHandler.unregisterListener(id, listener)
fragment.parentFragmentManager.unregisterFragmentLifecycleCallbacks(this)
}
}
}, false
)
DownloadMessageHandler.registerListener(id, listener)
}
fun unregisteredListener() {
DownloadMessageHandler.unregisterListener(id, listener)
}
}

View File

@ -1,105 +0,0 @@
package com.gh.download.simple
import com.lg.download.DownloadError
import com.lg.download.DownloadStatus
import com.gh.gamecenter.R
import com.gh.gamecenter.common.utils.dip2px
import com.gh.gamecenter.common.utils.roundTo
import com.gh.gamecenter.common.utils.setDebouncedClickListener
import com.gh.gamecenter.core.utils.ToastUtils
import com.lightgame.utils.Utils
open class DownloadButtonHelper(
private val mDownloadId: String,
private val mProgressView: SimpleProgressView,
) : DownloadListener {
private var mProgressText = ""
init {
mProgressView.setTag(R.string.app_name, mDownloadId)
mProgressView.setTextSize(12F.dip2px().toFloat())
}
override fun onError(error: DownloadError) {
Utils.log(error)
}
override fun onProgress(progress: Float) {
if (mProgressView.getTag(R.string.app_name) == mDownloadId) {
val realTimeDownloadEntity = DownloadMessageHandler.findEntity(mDownloadId)
mProgressText = "${progress.roundTo(1)}%"
mProgressView.progress = (progress).toInt()
if (realTimeDownloadEntity?.status == DownloadStatus.DOWNLOADING) {
mProgressView.text = mProgressText
}
}
}
override fun onSizeReceived(fileSize: Long) {
//nothing for sonar
}
override fun onStatusChanged(status: DownloadStatus) {
if (mProgressView.getTag(R.string.app_name) == mDownloadId) {
when (status) {
DownloadStatus.PAUSED -> {
mProgressView.text = "继续"
mProgressView.setDebouncedClickListener {
SimpleDownloadManager.resume(mDownloadId)
}
updateProgressViewStyle(mProgressView)
}
DownloadStatus.QUEUED,
DownloadStatus.WAITINGWIFI -> {
mProgressView.text = "等待"
mProgressView.setOnClickListener {
}
updateProgressViewStyle(mProgressView, isWaiting = true)
}
DownloadStatus.DOWNLOADING -> {
mProgressView.setOnClickListener {
SimpleDownloadManager.pause(mDownloadId)
onStatusChanged(status = DownloadStatus.PAUSED)
}
updateProgressViewStyle(mProgressView)
}
DownloadStatus.COMPLETED -> {
mProgressView.text = "安装"
mProgressView.progress = 100
mProgressView.setOnClickListener {
ToastUtils.toast("安装")
}
updateProgressViewStyle(mProgressView)
}
else -> {
mProgressView.text = "下载"
// do nothing
}
}
}
}
override fun onSpeedChanged(speed: Float) {}
private fun updateProgressViewStyle(
progressView: SimpleProgressView,
isEmpty: Boolean = false,
isWaiting: Boolean = false
) {
when {
isEmpty -> {
// do nothing
}
isWaiting -> {
// do nothing
}
else -> {
// do nothing
}
}
}
}

View File

@ -1,37 +0,0 @@
package com.gh.download.simple
import androidx.lifecycle.LiveData
import androidx.room.*
import io.reactivex.Single
@Dao
interface DownloadDao {
@Query("select * from SimpleDownloadEntity where id = :id")
fun getDownloadEntityById(id: String): SimpleDownloadEntity?
@Query("select * from SimpleDownloadEntity")
fun getAllDownloadEntity(): List<SimpleDownloadEntity>
@Query("select * from SimpleDownloadEntity where status == 1")
fun getAllDownloadingEntity(): List<SimpleDownloadEntity>
@Query("select * from SimpleDownloadEntity where status == 3")
fun getAllDownloadedEntity(): List<SimpleDownloadEntity>
@Query("select * from SimpleDownloadEntity")
fun getAllDownloadEntityLiveData(): LiveData<List<SimpleDownloadEntity>>
@Query("select * from SimpleDownloadEntity")
fun getAllDownloadEntitySingle(): Single<List<SimpleDownloadEntity>>
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertDownloadEntity(entity: SimpleDownloadEntity)
@Update(onConflict = OnConflictStrategy.REPLACE)
fun updateDownloadEntity(entity: SimpleDownloadEntity)
@Delete
fun deleteDownloadEntity(entity: SimpleDownloadEntity)
}

View File

@ -1,16 +0,0 @@
package com.gh.download.simple
import com.lg.download.DownloadError
import com.lg.download.DownloadStatus
interface DownloadListener {
fun onError(error: DownloadError)
fun onProgress(progress: Float)
fun onSizeReceived(fileSize: Long)
fun onStatusChanged(status: DownloadStatus)
fun onSpeedChanged(speed: Float)
}

View File

@ -1,302 +0,0 @@
package com.gh.download.simple
import android.annotation.SuppressLint
import android.database.sqlite.SQLiteException
import com.gh.gamecenter.core.utils.ToastUtils
import com.lg.download.*
import com.lg.download.listener.InnerDownloadListener
import com.lg.ndownload.DownloadConfig
import java.net.URLConnection
import java.util.concurrent.ConcurrentHashMap
import kotlin.collections.ArrayList
/**
* 下载信息管理类
*/
object DownloadMessageHandler : InnerDownloadListener {
// 单页可订阅的监听数最少从 3 开始, 如果值为 5 的话有可能出现状态无法更新的情况 (fragment onDestroy 回调慢)
private const val MAX_LISTENER_SIZE = 5
private lateinit var mDownloadDao: DownloadDao
private val mGlobalStatusChangedListenerList by lazy {
arrayListOf<((SimpleDownloadEntity, DownloadStatus) -> Unit)>()
}
/**
* map key: 下载 id
*
* map value:
* pair first-> 下载实体
* pair second-> 对应页面的下载回调
*/
private var mListenerMap: ConcurrentHashMap<String, FixedSizeStack<DownloadListener>> = ConcurrentHashMap()
var downloadList = arrayListOf<SimpleDownloadEntity>()
@SuppressLint("CheckResult")
fun init(downloadDao: DownloadDao) {
mDownloadDao = downloadDao
updateDownloadList()
}
/**
* 注册全局回调(为避免影响下载性能,目前仅对接了状态变更回调)
*/
fun registerGlobalStatusChangedListener(listener: ((SimpleDownloadEntity, DownloadStatus) -> Unit)) {
mGlobalStatusChangedListenerList.add(listener)
}
/**
* 状态回调
* @param id 下载 id
* @param status 下载状态
*/
override fun onStatusChanged(id: String, status: DownloadStatus) {
val entity = findEntity(id)
if (entity != null) {
entity.status = status
if (status == DownloadStatus.COMPLETED) {
SimpleDownloadManager.resumeQueuedTask()
}
ExecutorProvider.getInstance().backgroundExecutor.execute {
updateDownloadToDatabase(entity)
updateDownloadList()
}
}
for (listener in mGlobalStatusChangedListenerList) {
listener.invoke(entity!!, status)
}
val listenerList = mListenerMap[id] ?: return
ExecutorProvider.getInstance().mainThreadExecutor.execute {
safeIteratorList(listenerList) {
it.onStatusChanged(status)
}
}
}
/**
* 重定向中的回调
* @param id 下载 id
* @param connection 未重定向前的原始连接
* @param config 下载配置
*/
override fun onRedirectingUrl(id: String?, connection: URLConnection?, config: DownloadConfig?) {
}
/**
* 重定向完成后的回调
* @param id 下载 id
* @param connection 重定向完成后的连接
* @param redirectedUrl 重定向完成的最终地址
*/
override fun onRedirectedUrl(id: String, connection: URLConnection, redirectedUrl: String) {
val entity = findEntity(id) ?: return
entity.url = redirectedUrl
// 更新数据库数据
updateDownloadToDatabase(entity, updateDownloadList = true)
}
/**
* 进度回调,带频率控制,适合用来更新 UI
* @param id 下载 id
* @param progress 进度 0~1
*/
override fun onProgress(id: String, progress: Float) {
val entity = findEntity(id) ?: return
entity.progress = progress * 100
updateDownloadToDatabase(entity)
val listenerList = mListenerMap[id] ?: return
ExecutorProvider.getInstance().mainThreadExecutor.execute {
safeIteratorList(listenerList) {
it.onProgress(progress * 100)
}
}
updateDownloadList()
}
/**
* 没有频率控制的进度回调,适合做一些轻度的操作
* @param id 下载 id
* @param progress 进度 0~1
*/
override fun onProgressWithoutThrottle(id: String?, progress: Float) {
}
/**
* 速度回调,带频率控制,适合用来更新 UI
* @param id 下载 id
* @param speed 下载速度,单位为字节
*/
override fun onSpeedChanged(id: String, speed: Float) {
val listenerList = mListenerMap[id] ?: return
ExecutorProvider.getInstance().mainThreadExecutor.execute {
safeIteratorList(listenerList) {
it.onSpeedChanged(speed)
}
}
findEntity(id)?.run {
this.speed = speed
}
}
/**
* 错误回调
* @param id 下载 id
* @param error 错误类型
* @param exception 包裹错误的 Exception
*/
override fun onError(id: String, error: DownloadError?, exception: Exception) {
error ?: return
when (error) {
DownloadError.EMPTY_URL,
DownloadError.HTTP_NOT_FOUND,
DownloadError.CONTENT_LENGTH_IS_ZERO -> {
ToastUtils.toast("下载链接异常,请检查")
}
else -> {
// 想怎么处理就怎么处理
}
}
val listenerList = mListenerMap[id] ?: return
ExecutorProvider.getInstance().mainThreadExecutor.execute {
safeIteratorList(listenerList) {
it.onError(error)
}
}
}
/**
* 文件大小获取成功回调
* @param id 下载 id
* @param fileSize 文件大小,单位为字节
*/
override fun onSizeReceived(id: String, fileSize: Long) {
val entity = findEntity(id) ?: return
entity.totalBytes = fileSize
updateDownloadToDatabase(entity, updateDownloadList = true)
val listenerList = mListenerMap[id] ?: return
ExecutorProvider.getInstance().mainThreadExecutor.execute {
safeIteratorList(listenerList) {
it.onSizeReceived(fileSize)
}
}
updateDownloadList()
}
fun registerListener(id: String, listener: DownloadListener) {
var listenerList = mListenerMap[id]
if (listenerList == null) {
listenerList = FixedSizeStack(MAX_LISTENER_SIZE)
listenerList.push(listener)
mListenerMap[id] = listenerList
} else {
listenerList.push(listener)
}
// Post download status if it could be obtain from database.
val entityFromDatabase = findEntity(id)
if (entityFromDatabase != null) {
listener.onProgress(entityFromDatabase.progress)
listener.onStatusChanged(entityFromDatabase.status)
}
}
fun unregisterListener(id: String, listener: DownloadListener) {
ExecutorProvider.getInstance().mainThreadExecutor.execute {
mListenerMap[id]?.remove(listener)
}
}
/**
* 从下载列表中取 downloadEntity
* TODO 不应该直接修改 downloadEntity 内存的值,不然会有莫名其妙的问题
*/
fun findEntity(id: String): SimpleDownloadEntity? {
try {
return downloadList.firstOrNull { it.id == id }
} catch (e: Exception) {
e.printStackTrace()
}
return null
}
private fun updateDownloadList() {
downloadList = try {
ArrayList(mDownloadDao.getAllDownloadEntity())
} catch (e: SQLiteException) {
arrayListOf()
}
}
fun insertDownloadToDatabase(downloadEntity: SimpleDownloadEntity) {
mDownloadDao.insertDownloadEntity(downloadEntity)
updateDownloadList()
}
fun updateDownloadToDatabase(
downloadEntity: SimpleDownloadEntity,
updateDownloadList: Boolean = false
) {
mDownloadDao.updateDownloadEntity(downloadEntity)
if (updateDownloadList) {
updateDownloadList()
}
}
fun deleteDownloadOfDatabase(downloadEntity: SimpleDownloadEntity) {
mDownloadDao.deleteDownloadEntity(downloadEntity)
updateDownloadList()
}
/*****
* 迭代的时候针对temp Stack进行迭代
*/
private fun safeIteratorList(
sourceList: FixedSizeStack<DownloadListener>?,
function: (arg: DownloadListener) -> (Unit)
) {
sourceList?.apply {
if (this.size > 0) {
// FIXME 高频遍历时会产生巨量临时的 FixedSizeStack
val tempStack = FixedSizeStack<DownloadListener>(MAX_LISTENER_SIZE)
tempStack.addAll(sourceList)
tempStack.forEach { listener ->
listener?.apply {
function(this)
}
}
}
}
}
}

View File

@ -1,35 +0,0 @@
package com.gh.download.simple
import androidx.room.TypeConverter
import com.lg.download.DownloadStatus
class DownloadStatusConverter {
@TypeConverter
fun fromGameStatus(status: DownloadStatus): Int {
return when (status) {
DownloadStatus.UNKNOWN -> 0
DownloadStatus.DOWNLOADING -> 1
DownloadStatus.PAUSED -> 2
DownloadStatus.COMPLETED -> 3
DownloadStatus.CANCELLED -> 4
DownloadStatus.AUTOPAUSED -> 5
DownloadStatus.WAITINGWIFI -> 6
DownloadStatus.QUEUED -> 7
}
}
@TypeConverter
fun toGameStatus(status: Int): DownloadStatus {
return when (status) {
0 -> DownloadStatus.UNKNOWN
1 -> DownloadStatus.DOWNLOADING
2 -> DownloadStatus.PAUSED
3 -> DownloadStatus.COMPLETED
4 -> DownloadStatus.CANCELLED
5 -> DownloadStatus.AUTOPAUSED
6 -> DownloadStatus.WAITINGWIFI
7 -> DownloadStatus.QUEUED
else -> DownloadStatus.UNKNOWN
}
}
}

View File

@ -1,19 +0,0 @@
package com.gh.download.simple
import java.util.*
/**
* A stack that holds fixed size listeners.
*
* You may wonder why using a stack.
* I just can't find a proper way to handle these listeners.
* If you do have a simple and easy way to achieve the same goal, let me know, please. :)
*/
class FixedSizeStack<T>(private var maxSize: Int) : Stack<T>() {
override fun push(item: T): T {
while (this.size >= maxSize) {
this.removeAt(0)
}
return super.push(item)
}
}

View File

@ -1,30 +0,0 @@
package com.gh.download.simple
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import androidx.room.TypeConverters
import com.halo.assistant.HaloApp
@Database(
entities = [SimpleDownloadEntity::class],
version = 1,
exportSchema = false
)
@TypeConverters(DownloadStatusConverter::class)
abstract class SimpleDownloadDatabase : RoomDatabase() {
abstract fun downloadDao(): DownloadDao
companion object {
@JvmStatic
val instance by lazy {
Room.databaseBuilder(
HaloApp.getInstance().application,
SimpleDownloadDatabase::class.java,
"SIMPLE_DOWNLOAD_DATABASE"
).build()
}
}
}

View File

@ -1,29 +0,0 @@
package com.gh.download.simple
import android.os.Parcelable
import androidx.annotation.Keep
import androidx.room.Entity
import androidx.room.PrimaryKey
import com.lg.download.DownloadStatus
import kotlinx.parcelize.Parcelize
@Keep
@Entity(tableName = "SimpleDownloadEntity")
@Parcelize
data class SimpleDownloadEntity(
@PrimaryKey(autoGenerate = false)
var id: String,
var desc: String = "",
var url: String = "",
var dirPath: String = "",
var fileName: String = "",
var displayName: String = "",
var packageName: String = "",
var downloadedBytes: Long = 0,
var totalBytes: Long = 0,
var progress: Float = 0F,
var status: DownloadStatus = DownloadStatus.UNKNOWN,
var speed: Float = 0F,
var version: String = "",
var icon: String = "",
) : Parcelable

View File

@ -1,95 +0,0 @@
package com.gh.download.simple
import com.halo.assistant.HaloApp
import com.lg.download.*
import com.lg.ndownload.DownloadConfig
import com.lg.ndownload.DownloadDbManager
import com.lg.ndownload.DownloadQueue
import com.lightgame.download.FileUtils
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
object SimpleDownloadManager {
private const val MAX_DOWNLOADING_TASK = 2
private val mDownloadQueue by lazy { DownloadQueue.getInstance() }
private val mExecutor by lazy { Executors.newCachedThreadPool() }
fun init() {
ExecutorProvider.getInstance().backgroundExecutor.execute {
DownloadDbManager.init(HaloApp.getInstance())
}
// 设置最大同时下载任务数 (可选)
DownloadQueue.getInstance().setMaxDownloadingTask(MAX_DOWNLOADING_TASK)
}
/**
* 继续任务
*/
fun resume(id: String) {
mDownloadQueue.resume(id)
}
/**
* 下载任务
*/
fun download(config: DownloadConfig) {
val downloadStatus = mDownloadQueue.getStatus(config.uniqueId)
if (downloadStatus != DownloadStatus.PAUSED) {
ExecutorProvider.getInstance().backgroundExecutor.execute {
DownloadMessageHandler.insertDownloadToDatabase(getDownloadEntity(config))
mDownloadQueue.submitNewTask(config)
}
} else {
resume(config.uniqueId)
}
}
private fun getDownloadEntity(config: DownloadConfig): SimpleDownloadEntity {
return SimpleDownloadEntity(
id = config.uniqueId,
url = config.url,
fileName = config.fileName,
dirPath = config.pathToStore,
displayName = config.fileName,
icon = "",
)
}
/**
* 暂停任务
*/
fun pause(id: String) {
mDownloadQueue.pause(id)
}
/**
* 继续排队中的任务
*/
fun resumeQueuedTask() {
mDownloadQueue.resumeQueuedTask()
}
/**
* 取消任务
*/
fun cancel(id: String) {
ExecutorProvider.getInstance().backgroundExecutor.execute {
mDownloadQueue.pause(id)
mDownloadQueue.cancel(id)
DownloadMessageHandler.findEntity(id)?.let {
FileUtils.deleteFile(it.dirPath + it.fileName)
DownloadMessageHandler.deleteDownloadOfDatabase(it)
}
// 清除下载数据库那边的 id
DownloadDbManager.getInstance().delete(id)
}
}
fun getExecutor(): ExecutorService = mExecutor
}

View File

@ -1,81 +0,0 @@
package com.gh.download.simple
import android.content.Context
import android.graphics.*
import android.util.AttributeSet
import android.widget.ProgressBar
import androidx.annotation.Keep
import com.gh.gamecenter.core.utils.DisplayUtils
@Keep
class SimpleProgressView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0) :
ProgressBar(context, attrs, defStyle) {
private var mWidth = 0
private var mHalfWidth = 0
private val mMatrix: Matrix
private var mHalfTextWidth = 0F
private val mTextPaint: Paint
private var mTextSize = 0F
private var mTextColor = Color.WHITE
private var mText: String? = "打开"
init {
max = MAX_LENGTH
mTextSize = DisplayUtils.sp2px(context, 12F).toFloat()
mMatrix = Matrix()
mTextPaint = Paint()
mTextPaint.isAntiAlias = true
mTextPaint.color = mTextColor
mTextPaint.style = Paint.Style.FILL_AND_STROKE
mTextPaint.typeface = Typeface.DEFAULT_BOLD
mTextPaint.textSize = mTextSize
mTextPaint.textAlign = Paint.Align.CENTER
}
override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
super.onLayout(changed, left, top, right, bottom)
mWidth = width
mHalfWidth = mWidth / 2
}
override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)
if (mText != null) {
setProgressByPixels(mWidth * progress / MAX_LENGTH)
val fontMetrics = mTextPaint.fontMetricsInt
val baseline = (height - fontMetrics.bottom - fontMetrics.top) / 2
canvas.drawText(mText!!, mHalfWidth.toFloat(), baseline.toFloat(), mTextPaint)
}
}
var text: String?
get() = mText
set(text) {
mText = text
postInvalidate()
}
fun setTextColor(color: Int) {
mTextColor = color
mTextPaint.color = color
}
fun setTextSize(size: Float) {
mTextSize = size
mTextPaint.textSize = size
}
private fun setProgressByPixels(pixels: Int) {
if (pixels >= mHalfWidth - mHalfTextWidth) {
mMatrix.setTranslate(pixels - (mHalfWidth - mHalfTextWidth), 0F)
} else {
mMatrix.setTranslate(0F, 0F)
}
}
companion object {
const val MAX_LENGTH = 100
}
}

View File

@ -1,4 +1,4 @@
package com.gh.gamecenter.setting.view;
package com.gh.gamecenter;
import android.content.Context;
import android.content.Intent;
@ -11,7 +11,7 @@ import com.gh.gamecenter.common.base.activity.ToolBarActivity;
import com.gh.gamecenter.common.constant.EntranceConsts;
import com.gh.gamecenter.common.constant.RouteConsts;
import com.gh.gamecenter.common.utils.ExtensionsKt;
import com.gh.gamecenter.setting.R;
import com.halo.assistant.fragment.AboutFragment;
/**
* Created by khy on 2017/2/28.
@ -42,4 +42,4 @@ public class AboutActivity extends ToolBarActivity {
super.onDarkModeChanged();
ExtensionsKt.updateStatusBarColor(this, R.color.background_white, R.color.background_white);
}
}
}

View File

@ -6,16 +6,13 @@ import android.os.Bundle;
import androidx.annotation.NonNull;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.gh.gamecenter.common.base.activity.ToolBarActivity;
import com.gh.gamecenter.common.constant.EntranceConsts;
import com.gh.gamecenter.common.constant.RouteConsts;
import com.halo.assistant.fragment.ApkCleanerFragment;
/**
* Created by khy on 2017/1/24.
*/
@Route(path = RouteConsts.activity.cleanApkActivity)
public class CleanApkActivity extends ToolBarActivity {
@NonNull
@ -37,9 +34,4 @@ public class CleanApkActivity extends ToolBarActivity {
bundle.putString(EntranceConsts.KEY_PLATFORM_REQUESTS_ID, platformRequestsId);
return getTargetIntent(context, CleanApkActivity.class, ApkCleanerFragment.class, bundle);
}
@Override
protected Intent provideNormalIntent() {
return getIntent(this);
}
}

View File

@ -6,14 +6,15 @@ import android.content.Intent
import android.os.Bundle
import android.view.View
import com.gh.base.DownloadToolbarActivity
import com.gh.gamecenter.common.constant.Constants
import com.gh.common.exposure.ExposureEvent
import com.gh.common.exposure.ExposureEvent.Companion.createEvent
import com.gh.common.exposure.ExposureManager.log
import com.gh.common.exposure.ExposureTraceUtils.appendTrace
import com.gh.common.exposure.ExposureType
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.base.activity.BaseActivity
import com.gh.gamecenter.core.utils.DisplayUtils
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.entity.GameEntity
import com.gh.gamecenter.gamedetail.GameDetailFragment
import com.halo.assistant.HaloApp
@ -165,33 +166,6 @@ class GameDetailActivity : DownloadToolbarActivity() {
startGameDetailActivity(context, gameId, entrance, -1, traceEvent = traceEvent)
}
@JvmStatic
fun startGameDetailActivity(
context: Context,
gameId: String,
entrance: String?,
defaultTab: Int = -1,
isSkipGameComment: Boolean = false,
scrollToLibao: Boolean = false,
openVideoStreaming: Boolean = false,
openPlatformWindow: Boolean = false,
traceEvent: ExposureEvent? = null
) {
startGameDetailActivity(
context,
gameId,
entrance,
defaultTab,
isSkipGameComment,
scrollToLibao,
openVideoStreaming,
openPlatformWindow,
null,
null,
traceEvent
)
}
/**
* @param gameId 游戏Id
* @param defaultTab 默认定位到哪个tab
@ -199,8 +173,6 @@ class GameDetailActivity : DownloadToolbarActivity() {
* @param scrollToLibao 滚动到礼包区域
* @param openVideoStreaming 是否打开视频流
* @param openPlatformWindow 打开多版本下载弹窗
* @param platformName 平台名称
* @param packageName 包名
* @param traceEvent 曝光事件
*/
@JvmStatic
@ -213,8 +185,6 @@ class GameDetailActivity : DownloadToolbarActivity() {
scrollToLibao: Boolean = false,
openVideoStreaming: Boolean = false,
openPlatformWindow: Boolean = false,
platformName: String? = null,
packageName: String? = null,
traceEvent: ExposureEvent? = null
) {
val bundle = Bundle()
@ -254,12 +224,6 @@ class GameDetailActivity : DownloadToolbarActivity() {
}
if (openPlatformWindow) {
bundle.putBoolean(EntranceConsts.KEY_OPEN_PLATFORM_WINDOW, true)
if (!platformName.isNullOrEmpty()) {
bundle.putString(EntranceConsts.KEY_PLATFORM, platformName)
}
if (!packageName.isNullOrEmpty()) {
bundle.putString(EntranceConsts.KEY_PACKAGENAME, packageName)
}
}
if (scrollToLibao) {
bundle.putInt(EntranceConsts.KEY_TARGET, GameDetailFragment.INDEX_TRENDES)

View File

@ -1,7 +1,7 @@
package com.gh.gamecenter;
import static com.gh.gamecenter.common.constant.Constants.LOGIN_TAG;
import static com.gh.gamecenter.common.constant.Constants.LOGOUT_TAG;
import static com.gh.gamecenter.login.utils.LoginHelper.WEIBO_SCOPE;
import static com.gh.gamecenter.common.constant.EntranceConsts.ENTRANCE_BROWSER;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_LAUNCH_SIMULATOR_GAME;
import static com.gh.gamecenter.common.constant.EntranceConsts.HOST_QQ;
@ -14,7 +14,7 @@ import static com.gh.gamecenter.common.constant.EntranceConsts.KEY_TO;
import static com.gh.gamecenter.common.constant.EntranceConsts.KEY_TYPE;
import static com.gh.gamecenter.common.utils.ExtensionsKt.observableToMain;
import static com.gh.gamecenter.fragment.MainWrapperFragment.INDEX_PERSONAL;
import static com.gh.gamecenter.login.utils.LoginHelper.WEIBO_SCOPE;
import static com.gh.gamecenter.common.constant.Constants.LOGIN_TAG;
import android.annotation.SuppressLint;
import android.app.Activity;
@ -26,7 +26,6 @@ import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.SystemClock;
import android.preference.PreferenceManager;
import android.text.Html;
@ -40,15 +39,9 @@ import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProviders;
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat;
import com.facebook.drawee.view.SimpleDraweeView;
import com.gh.common.DefaultUrlHandler;
import com.gh.common.constant.Config;
import com.gh.common.exposure.ExposureEvent;
import com.gh.common.exposure.ExposureManager;
import com.gh.common.exposure.ExposureSource;
import com.gh.common.exposure.ExposureType;
import com.gh.common.history.HistoryDatabase;
import com.gh.common.history.HistoryHelper;
import com.gh.common.repository.ReservationRepository;
@ -65,7 +58,8 @@ import com.gh.common.util.ErrorHelper;
import com.gh.common.util.HomePluggableHelper;
import com.gh.common.util.LogUtils;
import com.gh.common.util.LunchType;
import com.gh.common.util.NewFlatLogUtils;
import com.gh.gamecenter.common.eventbus.EBReuse;
import com.gh.gamecenter.common.utils.NotificationHelper;
import com.gh.common.util.PackageInstaller;
import com.gh.common.util.PackageUtils;
import com.gh.common.util.PlatformUtils;
@ -78,17 +72,12 @@ import com.gh.gamecenter.common.base.fragment.BaseFragment_ViewPager;
import com.gh.gamecenter.common.base.fragment.ToolbarFragment;
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.entity.NotificationUgc;
import com.gh.gamecenter.common.eventbus.EBReuse;
import com.gh.gamecenter.common.exposure.meta.MetaUtil;
import com.gh.gamecenter.common.retrofit.BiResponse;
import com.gh.gamecenter.common.retrofit.Response;
import com.gh.gamecenter.common.utils.DeviceUtils;
import com.gh.gamecenter.common.utils.DialogHelper;
import com.gh.gamecenter.common.utils.ExtensionsKt;
import com.gh.gamecenter.common.utils.ImageUtils;
import com.gh.gamecenter.common.utils.NotificationHelper;
import com.gh.gamecenter.common.utils.ShareUtils;
import com.gh.gamecenter.core.AppExecutor;
import com.gh.gamecenter.core.utils.ClassUtils;
@ -97,21 +86,21 @@ import com.gh.gamecenter.core.utils.GsonUtils;
import com.gh.gamecenter.core.utils.MtaHelper;
import com.gh.gamecenter.core.utils.SPUtils;
import com.gh.gamecenter.core.utils.SentryHelper;
import com.gh.gamecenter.core.utils.TimeUtils;
import com.gh.gamecenter.core.utils.ToastUtils;
import com.gh.gamecenter.core.utils.UrlFilterUtils;
import com.gh.gamecenter.download.DownloadFragment;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.entity.InnerMetaInfoEntity;
import com.gh.gamecenter.common.entity.NotificationUgc;
import com.gh.gamecenter.entity.StartupAdEntity;
import com.gh.gamecenter.eventbus.EBNetworkState;
import com.gh.gamecenter.eventbus.EBSkip;
import com.gh.gamecenter.fragment.MainWrapperFragment;
import com.gh.gamecenter.home.skip.PackageSkipActivity;
import com.gh.gamecenter.login.user.UserManager;
import com.gh.gamecenter.login.utils.QuickLoginHelper;
import com.gh.gamecenter.manager.DataCollectionManager;
import com.gh.gamecenter.manager.UpdateManager;
import com.gh.gamecenter.login.user.UserManager;
import com.gh.gamecenter.packagehelper.PackageViewModel;
import com.gh.gamecenter.retrofit.RetrofitManager;
import com.gh.gamecenter.room.AppDatabase;
@ -147,7 +136,6 @@ import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
@ -171,9 +159,6 @@ public class MainActivity extends BaseActivity {
public final static String SWITCH_TO_COMMUNITY = "switch_to_community";
public final static String SWITCH_TO_VIDEO = "switch_to_video";
public final static String SHOW_AD = "show_ad";
private final static int COUNTDOWN_AD = 100;
private final static int countdownMaxCount = 3;
private int countdownCount = 0;
private final static String CURRENT_PAGE = "current_page";
@ -195,7 +180,6 @@ public class MainActivity extends BaseActivity {
showAd = getIntent().getBooleanExtra(SHOW_AD, false) && savedInstanceState == null;
HaloApp.getInstance().initFresco();
HaloApp.getInstance().isAlreadyUpAndRunning = true;
super.onCreate(savedInstanceState);
setStatusBarColor(Color.TRANSPARENT);
@ -308,7 +292,7 @@ public class MainActivity extends BaseActivity {
}
if (showAd) {
observeStartUp();
observeAd();
} else {
checkDialog();
}
@ -490,95 +474,38 @@ public class MainActivity extends BaseActivity {
}
}
private void observeStartUp() {
if (!showAd) {
hideStartUp();
hideStartUpAd();
return;
}
final StartupAdEntity startUp = AdHelper.getStartUp();
if (startUp != null) {
showStartUp(startUp);
AppExecutor.getUiExecutor().executeWithDelay(() -> {
hideStartUp();
observeStartUpAd();
}, 2000);
} else {
observeStartUpAd();
}
}
private void observeStartUpAd() {
final StartupAdEntity startUpAd = AdHelper.getStartUpAd();
if (startUpAd != null && !TextUtils.isEmpty(startUpAd.getImg())) {
final String showedTodayTimestamp = SPUtils.getString(Constants.SP_STARTUP_AD_TIMESTAMP, "");
final String rule = startUpAd.getRule();
switch (rule) {
case "each":
showStartUpAd(startUpAd);
break;
case "once":
if (TextUtils.isEmpty(showedTodayTimestamp)
|| !showedTodayTimestamp.contains(startUpAd.getId())) {
showStartUpAd(startUpAd);
} else {
hideStartUpAd();
}
break;
case "everyday":
final String today = TimeUtils.getToday();
if (TextUtils.isEmpty(showedTodayTimestamp)
|| !showedTodayTimestamp.contains(today)
|| !showedTodayTimestamp.contains(startUpAd.getId())) {
showStartUpAd(startUpAd);
} else {
hideStartUpAd();
}
break;
default:
hideStartUpAd();
break;
private void observeAd() {
AdHelper.startupAd.observe(this, startupAdEntity -> {
if (showAd) {
if (startupAdEntity == null) {
hideAd(true);
} else {
showAd(startupAdEntity);
AppExecutor.getUiExecutor().execute(() -> {
AppExecutor.getUiExecutor().executeWithDelay(() -> hideAd(true), 2000);
});
}
}
SPUtils.setString(Constants.SP_STARTUP_AD_TIMESTAMP, startUpAd.getId() + TimeUtils.getToday());
} else {
hideStartUpAd();
}
});
AppExecutor.getUiExecutor().executeWithDelay(() -> hideAd(false), 950);
}
@Override
protected void handleMessage(Message msg) {
super.handleMessage(msg);
if (msg.what == COUNTDOWN_AD) {
countdownCount++;
TextView jumpBtn = findViewById(R.id.jumpBtn);
jumpBtn.setText(String.format(Locale.CHINA, "跳过 %d", countdownMaxCount - countdownCount));
if (countdownMaxCount < countdownCount) {
hideStartUpAd();
} else {
mBaseHandler.sendEmptyMessageDelayed(COUNTDOWN_AD, 1000);
private void hideAd(boolean forceToHide) {
if (forceToHide || AdHelper.startupAd.getValue() == null) {
showAd = false;
getIntent().putExtra(SHOW_AD, false);
View view = findViewById(R.id.maskContainer);
if (view != null) {
view.setVisibility(View.GONE);
ExtensionsKt.removeFromParent(view);
}
}
}
private void hideStartUp() {
View maskContainer = findViewById(R.id.maskContainer);
if (maskContainer != null) {
maskContainer.setVisibility(View.GONE);
ExtensionsKt.removeFromParent(maskContainer);
checkDialog();
}
}
private void hideStartUpAd() {
showAd = false;
getIntent().putExtra(SHOW_AD, false);
View startAdContainer = findViewById(R.id.startAdContainer);
if (startAdContainer != null) {
startAdContainer.setVisibility(View.GONE);
ExtensionsKt.removeFromParent(startAdContainer);
}
checkDialog();
}
private void checkDialog() {
// 检查通知权限
checkNotificationPermission();
@ -590,53 +517,9 @@ public class MainActivity extends BaseActivity {
});
}
private void showStartUpAd(StartupAdEntity ad) {
View startAdContainer = findViewById(R.id.startAdContainer);
View jumpBtn = findViewById(R.id.jumpBtn);
TextView jumpDetailBtn = findViewById(R.id.jumpDetailBtn);
SimpleDraweeView adImage = findViewById(R.id.adImage);
startAdContainer.setVisibility(View.VISIBLE);
jumpDetailBtn.setText(ad.getDesc());
ExtensionsKt.setDrawableEnd(jumpDetailBtn, VectorDrawableCompat.create(getResources(), R.drawable.ic_startup_ad_arrow, null), null, null);
ImageUtils.display(adImage, ad.getImg());
startAdContainer.setOnClickListener(v -> {
// do nothing 只是为了点击拦截事件,避免传递到下面的页面
});
jumpBtn.setOnClickListener(v -> {
mBaseHandler.removeMessages(COUNTDOWN_AD);
hideStartUpAd();
LinkEntity linkEntity = ad.getJump();
NewFlatLogUtils.logOpenScreenAdSkip(
ad.getId(),
linkEntity.getText() != null ? linkEntity.getText() : "",
linkEntity.getType() != null ? linkEntity.getType() : "",
linkEntity.getLink() != null ? linkEntity.getLink() : ""
);
});
List<ExposureSource> sources = new ArrayList<>();
sources.add(new ExposureSource("开屏广告", ad.getId()));
final ExposureEvent event = ExposureEvent.createEvent(null, sources, null, ExposureType.EXPOSURE);
ExposureManager.INSTANCE.log(event);
if (ad.getButton()) {
jumpDetailBtn.setOnClickListener(v -> {
DirectUtils.directToLinkPage(this, ad.getJump(), "(启动广告)", "", event);
v.postDelayed(() -> {
mBaseHandler.removeMessages(COUNTDOWN_AD);
hideStartUpAd();
}, 1000);
});
jumpDetailBtn.setVisibility(View.VISIBLE);
LogUtils.logStartAd("watch_start_ads", ad);
} else {
LogUtils.logStartAd("start_ads", ad);
}
mBaseHandler.sendEmptyMessageDelayed(COUNTDOWN_AD, 1000);
}
private void showStartUp(StartupAdEntity ad) {
private void showAd(StartupAdEntity ad) {
TextView adContentTv = findViewById(R.id.adContentTv);
View containerView = findViewById(R.id.maskContainer);
containerView.setVisibility(View.VISIBLE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
containerView.setElevation(500F);
}
@ -646,12 +529,12 @@ public class MainActivity extends BaseActivity {
adContentTv.setText(ad.getDesc());
adContentTv.setVisibility(View.VISIBLE);
if (ad.getButton()) {
View adBtn = findViewById(R.id.adBtn);
adBtn.setOnClickListener(v -> {
View btn = findViewById(R.id.adBtn);
btn.setOnClickListener((v) -> {
DirectUtils.directToLinkPage(this, ad.getJump(), "(启动广告)", "");
LogUtils.logStartAd("click_watch_start_ads", ad);
});
adBtn.setVisibility(View.VISIBLE);
btn.setVisibility(View.VISIBLE);
LogUtils.logStartAd("watch_start_ads", ad);
} else {
LogUtils.logStartAd("start_ads", ad);

View File

@ -1,4 +1,4 @@
package com.gh.gamecenter.setting.view
package com.gh.gamecenter
import android.annotation.SuppressLint
import android.graphics.Bitmap
@ -17,16 +17,12 @@ import android.webkit.WebView
import android.webkit.WebViewClient
import android.widget.ScrollView
import android.widget.TextView
import com.alibaba.android.arouter.launcher.ARouter
import com.gh.gamecenter.common.base.activity.ToolBarActivity
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.common.retrofit.Response
import com.gh.gamecenter.common.utils.DeviceUtils
import com.gh.common.util.*
import com.gh.gamecenter.common.utils.DialogHelper
import com.gh.gamecenter.common.utils.copyTextAndToast
import com.gh.gamecenter.common.utils.tryCatchInRelease
import com.gh.gamecenter.core.provider.IDirectProvider
import com.gh.gamecenter.setting.R
import com.gh.gamecenter.common.utils.DeviceUtils
import com.gh.gamecenter.common.retrofit.Response
import io.reactivex.Observable
import io.reactivex.ObservableOnSubscribe
import io.reactivex.android.schedulers.AndroidSchedulers
@ -239,11 +235,9 @@ class NetworkDiagnosisActivity : ToolBarActivity() {
mSuggestBtn.run {
visibility = View.VISIBLE
setOnClickListener {
val directUtils = ARouter.getInstance().build(RouteConsts.provider.directUtils)
.navigation() as? IDirectProvider
directUtils?.directToSuggestionFromDiagnosis(
this@NetworkDiagnosisActivity,
builder.toString().replace(mSuccessHint, "")
DirectUtils.directToSuggestion(
context = this@NetworkDiagnosisActivity,
diagnosis = builder.toString().replace(mSuccessHint, "")
)
}
}
@ -256,7 +250,7 @@ class NetworkDiagnosisActivity : ToolBarActivity() {
}
override fun onClick(widget: View) {
builder.toString().replace(mSuccessHint, "").copyTextAndToast("复制成功")
CommentUtils.copyText(builder.toString().replace(mSuccessHint, ""), applicationContext)
}
}, builder.length - mSuccessHint.length, builder.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)

View File

@ -59,7 +59,7 @@ import com.gh.gamecenter.eventbus.EBPackage;
import com.gh.gamecenter.common.eventbus.EBReuse;
import com.gh.gamecenter.newsdetail.NewsDetailAdapter;
import com.gh.gamecenter.retrofit.RetrofitManager;
import com.gh.gamecenter.setting.view.SettingsFragment;
import com.halo.assistant.fragment.SettingsFragment;
import com.lightgame.download.DataWatcher;
import com.lightgame.download.DownloadEntity;
import com.lightgame.utils.Utils;

View File

@ -1,4 +1,4 @@
package com.gh.gamecenter.setting.view
package com.gh.gamecenter
import android.content.Context
import android.content.Intent
@ -6,7 +6,7 @@ import android.os.Bundle
import com.gh.gamecenter.common.base.activity.ToolBarActivity
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.utils.updateStatusBarColor
import com.gh.gamecenter.setting.R
import com.halo.assistant.fragment.SettingsFragment
class SettingActivity : ToolBarActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
@ -21,10 +21,6 @@ class SettingActivity : ToolBarActivity() {
updateStatusBarColor(R.color.background_white, R.color.background_white)
}
override fun provideNormalIntent(): Intent {
return getTargetIntent(this, SettingActivity::class.java, SettingsFragment::class.java)
}
companion object {
fun getIntent(context: Context, isUpdate: Boolean, entrance: String): Intent {
return getTargetIntent(

View File

@ -137,7 +137,7 @@ public class SkipActivity extends BaseActivity {
if (!TextUtils.isEmpty(qaId)) {
DirectUtils.directToQa(this, qaTitle, qaId);
} else if ("vgame".equals(suggestionType)) {
DirectUtils.directToFeedbackCompat(this, content, "game", isQaFeedback, qaContentId, EntranceConsts.ENTRANCE_BROWSER);
DirectUtils.directToFeedback(this, content, "game", isQaFeedback, qaContentId, EntranceConsts.ENTRANCE_BROWSER);
} else {
DirectUtils.directToFeedback(this, content, null, isQaFeedback, qaContentId, EntranceConsts.ENTRANCE_BROWSER);
}
@ -291,9 +291,8 @@ public class SkipActivity extends BaseActivity {
case HOST_USERHOME:
String position = uri.getQueryParameter("position");
String subTypeString = uri.getQueryParameter("sub_type");
String subGameType = uri.getQueryParameter("sub_game_type");
DirectUtils.directToHomeActivity(this, path, subTypeString, subGameType, TextUtils.isEmpty(position) ? -1 : Integer.parseInt(position), ENTRANCE_BROWSER, "浏览器");
DirectUtils.directToHomeActivity(this, path, subTypeString, TextUtils.isEmpty(position) ? -1 : Integer.parseInt(position), ENTRANCE_BROWSER, "浏览器");
break;
case HOST_COMMUNITY_COLUMN:
CommunityEntity community = new CommunityEntity();

View File

@ -1,6 +1,5 @@
package com.gh.gamecenter
import android.Manifest
import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
@ -26,7 +25,6 @@ import com.gh.common.util.GameSubstituteRepositoryHelper.updateGameSubstituteRep
import com.gh.common.util.UsageStatsHelper.checkAndPostUsageStats
import com.gh.download.DownloadManager
import com.gh.gamecenter.common.base.activity.BaseActivity
import com.gh.gamecenter.common.callback.SimpleCallback
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.common.tracker.TrackerLogger
@ -62,8 +60,6 @@ class SplashScreenActivity : BaseActivity() {
private var mShouldPrefetchData = true
private val mPermissions = arrayOf(
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE,
PermissionHelper.PERMISSION_GET_INSTALLED_LIST
)
@ -154,41 +150,42 @@ 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()
// }
guideLayout.visibility = View.VISIBLE
SPUtils.setBoolean(Constants.SP_BRAND_NEW_USER, false)
mShouldPrefetchData = false
prefetchData()
// 恢复畅玩数据
VHelper.recoverVDataIfPossible()
val callback = object : SimpleCallback<Boolean> {
override fun onCallback(arg: Boolean) {
// Dialog dismiss 后的回调
guideLayout.visibility = View.VISIBLE
SPUtils.setBoolean(Constants.SP_BRAND_NEW_USER, false)
if (arg) {
requestPermission()
} else {
mStartMainActivityDirectly = false
}
}
requestPermission()
// 检查是否有旧版本光环,有就删掉
AppExecutor.ioExecutor.execute { deleteOutdatedUpdatePackage() }
if (mStartMainActivityDirectly) {
launchMainActivity()
} else {
mShouldPrefetchData = false
prefetchData()
}
mViewModel?.showPrivacyPolicy({
DialogUtils.showPrivacyPolicyDialog(this@SplashScreenActivity, it, callback)
}, {
DialogUtils.showPrivacyPolicyDialog(this@SplashScreenActivity, PrivacyPolicyEntity.createDefaultData(), callback)
})
// val callback = object : SimpleCallback<Boolean> {
// override fun onCallback(arg: Boolean) {
// // Dialog dismiss 后的回调
// guideLayout.visibility = View.VISIBLE
// SPUtils.setBoolean(Constants.SP_BRAND_NEW_USER, false)
// if (arg) {
// requestPermission()
// } else {
// mStartMainActivityDirectly = false
// }
// }
// }
//
// mViewModel?.showPrivacyPolicy({
// DialogUtils.showPrivacyPolicyDialog(this@SplashScreenActivity, it, callback)
// }, {
// DialogUtils.showPrivacyPolicyDialog(this@SplashScreenActivity, PrivacyPolicyEntity.createDefaultData(), callback)
// })
} else {
DialogUtils.showPrivacyPolicyDisallowDialog(
this,
@ -258,6 +255,7 @@ class SplashScreenActivity : BaseActivity() {
SPUtils.setLong(Constants.SP_GH_LAST_UPDATE_TIME, PackageUtils.getHaloLastUpdateTime())
HaloApp.getInstance().postInit(true)
TrackerLogger.logAppLaunchSuccessful()
AdHelper.getStartUpAd()
if (mShouldPrefetchData) {
prefetchData()
}
@ -269,14 +267,10 @@ class SplashScreenActivity : BaseActivity() {
intent.putExtra(MainActivity.SHOW_AD, !mIsNewForThisVersion)
overridePendingTransition(0, 0)
startActivity(intent)
doFlavorInit()
uploadTeaData()
finish()
}
private fun doFlavorInit() {
HaloApp.getInstance().flavorProvider.init(HaloApp.getInstance(), this)
}
private fun getGitLogString(): String {
if (com.gh.gamecenter.common.BuildConfig.BUILD_TIME != 0L) {
val stringBuilder = StringBuilder()
@ -347,6 +341,20 @@ class SplashScreenActivity : BaseActivity() {
}
}
private fun uploadTeaData() {
if ("tea" == BuildConfig.FLAVOR) {
// 在可能获取了相关权限后才初始化SDK/发送激活数据
// TeaHelper.init(getApplication(), HaloApp.getInstance().getChannel());
try {
val clazz = Class.forName("com.gh.gamecenter.TeaHelper")
val method = clazz.getMethod("init", Context::class.java, String::class.java)
method.invoke(null, application, HaloApp.getInstance().channel)
} catch (e: Exception) {
e.printStackTrace()
}
}
}
private fun prefetchData() {
AppExecutor.ioExecutor.execute {
Config.getGhzsSettings()
@ -377,10 +385,10 @@ class SplashScreenActivity : BaseActivity() {
private fun checkAndRequestPermission() {
if (EasyPermissions.hasPermissions(this, *mPermissions)) {
// 恢复畅玩数据
VHelper.recoverVDataIfPossible()
// VHelper.recoverVDataIfPossible()
// 检查是否有旧版本光环,有就删掉
AppExecutor.ioExecutor.execute { deleteOutdatedUpdatePackage() }
// AppExecutor.ioExecutor.execute { deleteOutdatedUpdatePackage() }
if (mStartMainActivityDirectly) {
if (com.gh.gamecenter.common.BuildConfig.BUILD_TIME != 0L) {
showGitLogDialogIfNeeded()
@ -469,7 +477,7 @@ class SplashScreenActivity : BaseActivity() {
intent.action = Intent.ACTION_MAIN
intent.addCategory(Intent.CATEGORY_LAUNCHER)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
intent.putExtras(bundle ?: Bundle())
intent.putExtras(bundle!!)
return intent
}
}

View File

@ -7,6 +7,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.graphics.Color;
import android.graphics.Paint;
import android.net.Uri;
import android.os.Build;
@ -1107,16 +1108,16 @@ public class SuggestionActivity extends ToolBarActivity implements OnRequestCall
}
@Override
public void onSingleSuccess(@NotNull Map<String, String> imageUrlMap) {
public void onSingleSuccess(@NotNull Map<String, String> imageUrl) {
}
@Override
public void onSuccess(@NotNull LinkedHashMap<String, String> imageUrlMap, @NotNull Map<String, ? extends Exception> errorMap) {
public void onSuccess(@NotNull LinkedHashMap<String, String> imageUrl, @NotNull Map<String, ? extends Exception> errorMap) {
Utils.log("意见反馈:图片上传完成");
final JSONArray picArray = new JSONArray();
for (String s : imageUrlMap.keySet()) {
picArray.put(imageUrlMap.get(s));
for (String s : imageUrl.keySet()) {
picArray.put(imageUrl.get(s));
}
initPostData(email, picArray);
}

View File

@ -4,7 +4,6 @@ import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.os.Environment;
import android.view.View;
@ -118,8 +117,7 @@ public class CleanApkAdapter extends BaseRecyclerAdapter<KcSelectGameViewHolder>
appInfo.sourceDir = apk_path;
appInfo.publicSourceDir = apk_path;
Drawable apk_icon = appInfo.loadIcon(pm);
Bitmap originalBitmap = BitmapUtils.drawableToBitmap(apk_icon, true);
apkEntity.setGameBm(BitmapUtils.compressBitmap(originalBitmap, 100));
apkEntity.setGameBm(BitmapUtils.drawableToBitmap(apk_icon, true));
/** apk的绝对路劲 */
apkEntity.setGamePath(apk_path);
/** apk的版本名称 String */

View File

@ -12,20 +12,20 @@ import android.view.ViewGroup;
import androidx.annotation.NonNull;
import com.facebook.drawee.view.SimpleDraweeView;
import com.gh.gamecenter.common.entity.ExposureEntity;
import com.gh.common.exposure.ExposureEvent;
import com.gh.common.exposure.ExposureSource;
import com.gh.common.exposure.ExposureType;
import com.gh.common.util.DirectUtils;
import com.gh.gamecenter.MainActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.common.entity.ExposureEntity;
import com.gh.gamecenter.common.entity.LinkEntity;
import com.gh.gamecenter.common.utils.DataLogUtils;
import com.gh.common.util.DirectUtils;
import com.gh.gamecenter.common.utils.ImageUtils;
import com.gh.gamecenter.core.utils.MtaHelper;
import com.gh.gamecenter.core.utils.PageSwitchDataHelper;
import com.gh.gamecenter.core.utils.StringUtils;
import com.gh.gamecenter.MainActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.common.entity.LinkEntity;
import com.gh.gamecenter.entity.SubjectRecommendEntity;
import com.gh.gamecenter.game.data.GameItemData;
@ -79,7 +79,7 @@ public class ImagePagerAdapter extends RecyclingPagerAdapter {
@Override
public View getView(final int position, View view, ViewGroup container) {
if (view == null) {
view = View.inflate(mContext, R.layout.game_slide_list_item, null);
view = new SimpleDraweeView(mContext);
}
int index = getPosition(position);
@ -87,15 +87,7 @@ public class ImagePagerAdapter extends RecyclingPagerAdapter {
final LinkEntity slideEntity = mSlideEntityList.get(index);
SimpleDraweeView slideImage = (SimpleDraweeView) view.findViewById(R.id.slideImage);
ImageUtils.display(slideImage, slideEntity.getImage());
View playIv = view.findViewById(R.id.playIv);
if ("video".equals(slideEntity.getType())) {
playIv.setVisibility(View.VISIBLE);
} else {
playIv.setVisibility(View.GONE);
}
ImageUtils.display(mContext.getResources(), (SimpleDraweeView) view, slideEntity.getImage(), R.drawable.preload);
ExposureEvent exposureEvent = null;
if ("game".equals(slideEntity.getType())) {

Some files were not shown because too many files have changed in this diff Show More