Compare commits
272 Commits
feature-mo
...
v5.16.0-67
| Author | SHA1 | Date | |
|---|---|---|---|
| 5a7c316a2d | |||
| 305c6792f2 | |||
| 1294a13933 | |||
| b5eb376055 | |||
| 4a321a6884 | |||
| 8d4fbed5d9 | |||
| 93a8c24ad3 | |||
| c69ececcb7 | |||
| ec4eeb0219 | |||
| 8ff62a9f5e | |||
| 203c8db840 | |||
| f1e3a21191 | |||
| cae48cb2b7 | |||
| 988b931170 | |||
| 50acd6998e | |||
| 84faf3e0d5 | |||
| d84c1f1f25 | |||
| 52b6a429bc | |||
| 6492b41ad1 | |||
| 3e4faca388 | |||
| cd1609a3ef | |||
| 4fd9c7b36e | |||
| 2bd8e0f96b | |||
| 2d64f19f98 | |||
| 15de55ceae | |||
| 2316bd1e18 | |||
| 6a4726650c | |||
| e79e6f8ec8 | |||
| 894d962836 | |||
| f48767c4bf | |||
| b5a64d1c36 | |||
| 001d062207 | |||
| d4b1b822f4 | |||
| 732765118e | |||
| eeacae1fd2 | |||
| e982ae9125 | |||
| a7ee0c754b | |||
| b042b3433d | |||
| 8ba70f4a7d | |||
| 094a85bfa4 | |||
| 54f0fa8dd8 | |||
| 1f331a20fa | |||
| ad58699d2f | |||
| 55e80c00de | |||
| 172b8cfa4c | |||
| bf6b1f05b0 | |||
| a28ba2773e | |||
| a19b2c5dc8 | |||
| a70156e272 | |||
| 583e8c8eb8 | |||
| b08b6bda3b | |||
| ef1d32b330 | |||
| 98deb6c702 | |||
| 1aa23aeeae | |||
| dd4f9918c9 | |||
| da1d7b23c3 | |||
| 8fc324cbc3 | |||
| cd83c0a267 | |||
| d61eb01461 | |||
| 546d692151 | |||
| bc313422e2 | |||
| acc5bd6e8c | |||
| 15c3aed5ba | |||
| afc8f15048 | |||
| de02ea7312 | |||
| 420b112576 | |||
| f6a67350b4 | |||
| 5482322c28 | |||
| 08236d4ddc | |||
| 9558c0b123 | |||
| f68df0fce5 | |||
| 03401e5649 | |||
| 86f6b0c108 | |||
| fc9eea7a4e | |||
| bff56dc114 | |||
| fddf52b0c3 | |||
| 5eb804d9d4 | |||
| d04e2b59e5 | |||
| 558f4409af | |||
| c21040f8f1 | |||
| 2f577c7ef1 | |||
| 56ddf9a83b | |||
| 50e8071a31 | |||
| ca073c128d | |||
| 6e0dd3831b | |||
| a22e26aec3 | |||
| fa33fe3d71 | |||
| f9e16d1f32 | |||
| 8584e12a7e | |||
| 5ffd28de1b | |||
| fff91052ff | |||
| 0e0812c00e | |||
| efe0efa0f8 | |||
| bdb7336d16 | |||
| 2ee01a0819 | |||
| d322c0c500 | |||
| be43470066 | |||
| ade40c49ef | |||
| 31d23a3a02 | |||
| 22e56e838a | |||
| 2242de5f83 | |||
| b684fff4f1 | |||
| 001a472b8e | |||
| 0b0f575c41 | |||
| da25541147 | |||
| e57ba6ed71 | |||
| fad7083a2c | |||
| 9254c9ef7d | |||
| d3042b9199 | |||
| 0893a34dff | |||
| da22540af3 | |||
| fffc27e779 | |||
| 2f246da269 | |||
| c6137fc3c9 | |||
| 518eb222b9 | |||
| 8bf7c61690 | |||
| a28169eeae | |||
| fb1968b402 | |||
| f479c789e9 | |||
| 67fb1948b4 | |||
| cd39a497e9 | |||
| 2398795438 | |||
| 2d41122c1c | |||
| ec576900e8 | |||
| 47549d788b | |||
| 34f1dd057c | |||
| 20e8fa451c | |||
| f92fb6a1c7 | |||
| 0e71b917c5 | |||
| d48947b256 | |||
| 7f5605a1a7 | |||
| f0ed0ae612 | |||
| 2c7997aa57 | |||
| 0bc638a2f9 | |||
| 1ae64c35b9 | |||
| 252566837a | |||
| 4cfa723a0e | |||
| 6c74096302 | |||
| 53075a2eff | |||
| 94d249312b | |||
| 4855dda839 | |||
| c5519fb160 | |||
| 5cd9197d0f | |||
| 28a97b0441 | |||
| d0cd3b4ac2 | |||
| f87e0dfe3c | |||
| c838f1dc24 | |||
| 584512c2ae | |||
| 22cfe03a30 | |||
| 3b178c0bbe | |||
| 6270f9fb98 | |||
| 0306caadb5 | |||
| 9c1e2f18fd | |||
| 305ab1d0e2 | |||
| ad208538f6 | |||
| 308cf4b627 | |||
| 4fd4086023 | |||
| 858f213b19 | |||
| 5efb343599 | |||
| 842f120de4 | |||
| adf7795877 | |||
| 095e533269 | |||
| 364e7d0588 | |||
| d3ce4b00ab | |||
| bde4baa0d1 | |||
| 1fdb1bd24a | |||
| 4cba936bf2 | |||
| f33b5e1609 | |||
| 5881f70a9e | |||
| d56a63236e | |||
| 714da89e9c | |||
| 5781629898 | |||
| 00e6fc54ce | |||
| cf68f11cc7 | |||
| 50c77dfd11 | |||
| 8564bc95e9 | |||
| 6244387c79 | |||
| b3cbe02e40 | |||
| 68a8933f62 | |||
| 63a38f0dc6 | |||
| ecbdbf57db | |||
| ba1a7d874f | |||
| c70f1aa267 | |||
| 1189619bdd | |||
| a7898ff9bd | |||
| 9b90f5bcab | |||
| ec4d60b9f3 | |||
| eac296a6fd | |||
| 99c3f3e735 | |||
| 67400bb4cc | |||
| e9f1346035 | |||
| 4c40996a95 | |||
| bdf7c7fcc8 | |||
| a51019ea8b | |||
| 319bb3ac2c | |||
| c675cba035 | |||
| 7f1a0351a9 | |||
| e120f22b57 | |||
| 6d64b26e3d | |||
| 7ced550195 | |||
| ca1b812c30 | |||
| d306fb185c | |||
| 4b10019888 | |||
| 640dce271c | |||
| b7b4ce8c83 | |||
| f689ef6228 | |||
| c9911a1a22 | |||
| b8fb3327b5 | |||
| 259791faf0 | |||
| d20866a045 | |||
| 110de25099 | |||
| 8e863bb7cc | |||
| 9cf044ee2e | |||
| 04886fb265 | |||
| ca26ccbecb | |||
| 30268a5cda | |||
| 5d4f489ddd | |||
| 102d285c09 | |||
| 092092fd6f | |||
| 97a54f1000 | |||
| 6b0611e05f | |||
| d3295f81f6 | |||
| 384469bcae | |||
| 77a512852b | |||
| 0aeb37a5eb | |||
| 50b5b1d8ac | |||
| de08c5dc98 | |||
| c2abe5be34 | |||
| 1222b4cde4 | |||
| a3cf98196d | |||
| 4839ee4aca | |||
| 115dc8ffab | |||
| e174c882e6 | |||
| 546f7fc122 | |||
| 900ee8e641 | |||
| bad1e32fda | |||
| b602960882 | |||
| 6be3798b36 | |||
| 5cf7ab8159 | |||
| 1e7c56221a | |||
| 73a473b1c1 | |||
| 258ada53af | |||
| 128f0e0e82 | |||
| 424efdafcf | |||
| 08e90bf923 | |||
| 60c967808d | |||
| 44b776a156 | |||
| b17fa55f94 | |||
| 5d1bc4aedd | |||
| b5c265e0d6 | |||
| 5b266c91da | |||
| fadd165e68 | |||
| 255b6ea141 | |||
| 7712039804 | |||
| fee65172d1 | |||
| 89846e04f3 | |||
| b09f0cde18 | |||
| 0e16aa7dd4 | |||
| cb355b2490 | |||
| 806ceee7e7 | |||
| 0cc8904852 | |||
| 1ffb58feea | |||
| e80c8d76cd | |||
| f47b0326f4 | |||
| a1aada02d6 | |||
| 659469aabc | |||
| 3ae27ebdb6 | |||
| aab422662a | |||
| 8193b9ec9f | |||
| 13929f4dc5 | |||
| 0ea0834140 | |||
| 7efdb5e432 |
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -8,3 +8,6 @@
|
||||
[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
|
||||
|
||||
@ -260,6 +260,7 @@ 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')) {
|
||||
@ -268,7 +269,7 @@ dependencies {
|
||||
implementation(project(':module_login')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
implementation(project(':module_setting_compose')) {
|
||||
implementation(project(':module_setting')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
// 默认不接入光能模块,提高编译速度
|
||||
|
||||
@ -51,27 +51,7 @@
|
||||
com.google.android.exoplayer2,
|
||||
tv.danmaku.ijk.media.exo2,
|
||||
pl.droidsonroids.gif,
|
||||
com.lzf.easyfloat,
|
||||
com.airbnb.lottie.compose,
|
||||
androidx.compose.ui.platform,
|
||||
androidx.compose.material.icons,
|
||||
androidx.activity.compose,
|
||||
androidx.compose.ui.tooling,
|
||||
androidx.compose.ui.tooling.data,
|
||||
androidx.compose.material.ripple,
|
||||
androidx.compose.foundation,
|
||||
androidx.compose.animation,
|
||||
androidx.compose.foundation.layout,
|
||||
androidx.compose.ui.text,
|
||||
androidx.compose.ui.graphics,
|
||||
androidx.compose.ui.unit,
|
||||
androidx.compose.ui.util,
|
||||
androidx.compose.ui.geometry,
|
||||
androidx.compose.runtime.saveable,
|
||||
androidx.compose.animation.core,
|
||||
androidx.constraintlayout.compose,
|
||||
androidx.compose.ui.test.manifest,
|
||||
androidx.compose.ui.tooling.preview"/>
|
||||
com.lzf.easyfloat" />
|
||||
|
||||
<!-- 去掉 SDK 一些流氓权限 -->
|
||||
<uses-permission
|
||||
@ -729,6 +709,15 @@
|
||||
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="${applicationId}.douyinapi.DouYinEntryActivity"-->
|
||||
<!-- android:launchMode="singleTask"-->
|
||||
@ -751,6 +740,26 @@
|
||||
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"-->
|
||||
|
||||
1
app/src/main/assets/lottie/downloadtips_dark.json
Normal file
1
app/src/main/assets/lottie/downloadtips_dark.json
Normal file
@ -0,0 +1 @@
|
||||
{"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":[]}
|
||||
1
app/src/main/assets/lottie/downloadtips_light.json
Normal file
1
app/src/main/assets/lottie/downloadtips_light.json
Normal file
@ -0,0 +1 @@
|
||||
{"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":[]}
|
||||
@ -38,8 +38,8 @@ 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.compose.activity.ComposeAboutActivity
|
||||
import com.gh.gamecenter.setting.compose.activity.ComposeBindPhoneActivity
|
||||
import com.gh.gamecenter.setting.view.AboutActivity
|
||||
import com.gh.gamecenter.setting.view.security.BindPhoneActivity
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Utils
|
||||
import org.json.JSONObject
|
||||
@ -270,7 +270,7 @@ class DefaultJsApi(var context: Context, val entrance: String = "") {
|
||||
|
||||
@JavascriptInterface
|
||||
fun bindPhone(msg: Any) {
|
||||
val intent = ComposeBindPhoneActivity.getNormalIntent(context, false)
|
||||
val intent = BindPhoneActivity.getNormalIntent(context, false)
|
||||
context.startActivity(intent)
|
||||
}
|
||||
|
||||
@ -416,7 +416,7 @@ class DefaultJsApi(var context: Context, val entrance: String = "") {
|
||||
|
||||
@JavascriptInterface
|
||||
fun checkUpdateGhzs(msg: Any) {
|
||||
context.startActivity(ComposeAboutActivity.getIntent(context, true))
|
||||
context.startActivity(AboutActivity.getIntent(context, true))
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
|
||||
@ -2,14 +2,15 @@ package com.gh.common
|
||||
|
||||
import com.gh.common.exposure.ExposureManager
|
||||
import com.gh.common.filter.RegionSettingHelper
|
||||
import com.gh.gamecenter.common.loghub.LoghubUtils
|
||||
import com.gh.gamecenter.common.utils.doOnMainProcessOnly
|
||||
import com.gh.gamecenter.common.utils.tryCatchInRelease
|
||||
import com.gh.common.util.AdHelper
|
||||
import com.gh.common.videolog.VideoRecordUtils
|
||||
import com.gh.download.DownloadDataHelper
|
||||
import com.gh.gamecenter.entity.TimeEntity
|
||||
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.gamecenter.entity.TimeEntity
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
@ -25,6 +26,7 @@ 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
|
||||
|
||||
@ -82,6 +84,11 @@ 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++
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@ import com.gh.vspace.VHelper
|
||||
class ValidateVSpaceHandler : ChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity) {
|
||||
VHelper.validateVSpaceBeforeAction(context, gameEntity, true) {
|
||||
VHelper.validateVSpaceBeforeAction(context, gameEntity) {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
} else {
|
||||
|
||||
@ -1,18 +1,33 @@
|
||||
package com.gh.common.chain
|
||||
|
||||
import android.content.Context
|
||||
import com.gh.common.util.DialogUtils
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.utils.DialogHelper
|
||||
import com.gh.gamecenter.common.utils.toResString
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
|
||||
class VersionNumberHandler : ChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity) {
|
||||
DialogUtils.showVersionNumberDialog(context, gameEntity) {
|
||||
val confirmCallback = {
|
||||
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)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8,24 +8,26 @@ import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
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.AdHelper;
|
||||
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;
|
||||
@ -64,8 +66,9 @@ public class Config {
|
||||
|
||||
private static SettingsEntity mSettingsEntity;
|
||||
private static NewSettingsEntity mNewSettingsEntity;
|
||||
private static NewApiSettingsEntity mNewApiSettingsEntity;
|
||||
|
||||
private static NewSettingsEntity.NightMode mNightModeSetting;
|
||||
private static NewApiSettingsEntity.NightMode mNightModeSetting;
|
||||
private static SimulatorEntity mNewSimulatorEntity;
|
||||
private static VSetting mVSetting;
|
||||
private static GameGuidePopupEntity mGameGuidePopupEntity;
|
||||
@ -204,7 +207,7 @@ public class Config {
|
||||
PackageHelper.initList();
|
||||
|
||||
// 初始化畅玩相关的东西
|
||||
VHelper.init(HaloApp.getInstance());
|
||||
VHelper.init(HaloApp.getInstance(), false);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -227,19 +230,19 @@ public class Config {
|
||||
public static SimulatorEntity getNewSimulatorEntitySetting() {
|
||||
if (mNewSimulatorEntity != null) {
|
||||
return mNewSimulatorEntity;
|
||||
} else if (mNewSettingsEntity != null && mNewSettingsEntity.getSimulator() != null) {
|
||||
return mNewSettingsEntity.getSimulator();
|
||||
} else if (mNewApiSettingsEntity != null && mNewApiSettingsEntity.getSimulator() != null) {
|
||||
return mNewApiSettingsEntity.getSimulator();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static NewSettingsEntity.NightMode getNightModeSetting() {
|
||||
public static NewApiSettingsEntity.NightMode getNightModeSetting() {
|
||||
if (mNightModeSetting != null) {
|
||||
return mNightModeSetting;
|
||||
} else if (mNewSettingsEntity != null && mNewSettingsEntity.getNightMode() != null) {
|
||||
return mNewSettingsEntity.getNightMode();
|
||||
} else if (mNewApiSettingsEntity != null && mNewApiSettingsEntity.getNightMode() != null) {
|
||||
return mNewApiSettingsEntity.getNightMode();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -260,6 +263,26 @@ 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) {
|
||||
@ -344,9 +367,6 @@ 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));
|
||||
}
|
||||
});
|
||||
@ -364,27 +384,23 @@ public class Config {
|
||||
});
|
||||
}
|
||||
|
||||
if (mNightModeSetting == null && mNewSimulatorEntity == null) {
|
||||
if (mNewApiSettingsEntity == null) {
|
||||
RetrofitManager.getInstance()
|
||||
.getNewApi().getNewSettings(PackageUtils.getGhVersionName(), channel)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BiResponse<NewSettingsEntity>() {
|
||||
.subscribe(new BiResponse<NewApiSettingsEntity>() {
|
||||
@Override
|
||||
public void onSuccess(NewSettingsEntity data) {
|
||||
public void onSuccess(NewApiSettingsEntity data) {
|
||||
mNewApiSettingsEntity = 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();
|
||||
}
|
||||
|
||||
if (mNewSettingsEntity != null) {
|
||||
mNewSettingsEntity.setSimulator(mNewSimulatorEntity);
|
||||
mNewSettingsEntity.setNightMode(mNightModeSetting);
|
||||
SPUtils.setString(Constants.SP_NEW_SETTINGS, GsonUtils.toJson(data));
|
||||
}
|
||||
AdHelper.prefetchStartUpAd(mNewApiSettingsEntity);
|
||||
SPUtils.setString(Constants.SP_NEW_API_SETTINGS, GsonUtils.toJson(data));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -850,11 +850,11 @@ public class BindingAdapters {
|
||||
|
||||
public static void setVideoData(TextView view, int count) {
|
||||
if (count > 0) {
|
||||
view.setCompoundDrawablesWithIntrinsicBounds(ContextCompat.getDrawable(view.getContext(), R.drawable.ic_video_data_up), null, null, null);
|
||||
ExtensionsKt.setDrawableStart(view, ContextCompat.getDrawable(view.getContext(), R.drawable.ic_video_data_up), null, null);
|
||||
view.setTextColor(ContextCompat.getColor(view.getContext(), R.color.text_EA3333));
|
||||
view.setText(count + "");
|
||||
} else {
|
||||
view.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
|
||||
ExtensionsKt.removeDrawable(view);
|
||||
view.setTextColor(ContextCompat.getColor(view.getContext(), R.color.text_subtitleDesc));
|
||||
view.setText("-");
|
||||
}
|
||||
|
||||
@ -18,18 +18,18 @@ import androidx.core.content.ContextCompat
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
import com.facebook.drawee.view.SimpleDraweeView
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.utils.ImageUtils
|
||||
import com.gh.gamecenter.common.utils.countDownTimer
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.core.utils.GsonUtils
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.common.utils.countDownTimer
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
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.compose.activity.ComposeGameDownloadSettingActivity
|
||||
import com.gh.gamecenter.setting.view.GameDownloadSettingFragment
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.lightgame.download.DataWatcher
|
||||
import com.lightgame.download.DownloadEntity
|
||||
@ -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(ComposeGameDownloadSettingActivity.AUTO_INSTALL_SP_KEY, true)
|
||||
val autoInstall = SPUtils.getBoolean(GameDownloadSettingFragment.AUTO_INSTALL_SP_KEY, true)
|
||||
if (autoInstall) {
|
||||
dismiss()
|
||||
}
|
||||
|
||||
@ -13,13 +13,11 @@ 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() {
|
||||
|
||||
@ -161,7 +159,7 @@ class NewPrivacyPolicyDialogFragment : BaseDialogFragment() {
|
||||
}
|
||||
}
|
||||
privacyDialogFragment.arguments = Bundle().apply {
|
||||
put(KEY_DATA, privacyPolicyEntity)
|
||||
putParcelable(KEY_DATA, privacyPolicyEntity)
|
||||
}
|
||||
privacyDialogFragment.show(
|
||||
activity.supportFragmentManager,
|
||||
|
||||
@ -303,7 +303,7 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
//安装、卸载事件
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onEventMainThread(busFour: EBPackage) {
|
||||
if ("安装" == busFour.type || "卸载" == busFour.type) {
|
||||
if (busFour.isInstalledOrUninstalled()) {
|
||||
mAllInstalledPackages = PackageUtils.getInstalledPackages(HaloApp.getInstance().application, 0)
|
||||
mAdapter?.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
@ -23,7 +23,6 @@ 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() {
|
||||
|
||||
@ -184,7 +183,7 @@ class PrivacyPolicyDialogFragment : BaseDialogFragment() {
|
||||
}
|
||||
}
|
||||
privacyDialogFragment.arguments = Bundle().apply {
|
||||
put(KEY_DATA, privacyPolicyEntity)
|
||||
putParcelable(KEY_DATA, privacyPolicyEntity)
|
||||
}
|
||||
privacyDialogFragment.show(
|
||||
activity.supportFragmentManager,
|
||||
|
||||
@ -29,7 +29,7 @@ data class ExposureEvent(
|
||||
var timeInMillisecond: Long = System.currentTimeMillis(),
|
||||
@PrimaryKey
|
||||
var id: String = UUID.randomUUID().toString(),
|
||||
) : Parcelable {
|
||||
) : Parcelable, Cloneable {
|
||||
|
||||
@Transient
|
||||
@IgnoredOnParcel
|
||||
@ -45,6 +45,9 @@ 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
|
||||
@ -71,7 +74,7 @@ data class ExposureEvent(
|
||||
?: eTrace?.firstOrNull()?.payload?.welcomeDialogId,
|
||||
welcomeDialogLinkTitle = gameEntity?.welcomeDialogTitle
|
||||
?: eTrace?.firstOrNull()?.payload?.welcomeDialogLinkTitle,
|
||||
isAdData = gameEntity?.adIconActive ?: eTrace?.firstOrNull()?.payload?.isAdData ?: false
|
||||
isAdData = gameEntity?.isAdData ?: eTrace?.firstOrNull()?.payload?.isAdData ?: false
|
||||
)
|
||||
this.id = UUID.randomUUID().toString()
|
||||
this.timeInMillisecond = System.currentTimeMillis()
|
||||
@ -124,6 +127,10 @@ 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
|
||||
|
||||
@ -6,11 +6,13 @@ object ExposureTraceUtils {
|
||||
val traceList = arrayListOf<ExposureEvent>()
|
||||
|
||||
event?.let {
|
||||
if (event.eTrace == null) {
|
||||
traceList.add(event)
|
||||
//这里使用deepCopy,是为了防止循环引用调用hashCode方法触发StackOverflowError错误
|
||||
val deepCopy = it.deepCopy()
|
||||
if (deepCopy.eTrace == null) {
|
||||
traceList.add(deepCopy)
|
||||
} else {
|
||||
traceList.addAll(event.eTrace!!)
|
||||
traceList.add(flattenTrace(event))
|
||||
traceList.addAll(deepCopy.eTrace!!)
|
||||
traceList.add(flattenTrace(deepCopy))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ import com.halo.assistant.HaloApp
|
||||
|
||||
@Database(
|
||||
entities = [AnswerEntity::class, ArticleEntity::class, NewsEntity::class, HistoryGameEntity::class, MyVideoEntity::class, GamesCollectionEntity::class],
|
||||
version = 11,
|
||||
version = 12,
|
||||
exportSchema = false
|
||||
)
|
||||
@TypeConverters(
|
||||
@ -28,6 +28,7 @@ import com.halo.assistant.HaloApp
|
||||
AnswerUserConverter::class,
|
||||
ThumbnailConverter::class,
|
||||
TagStyleListConverter::class,
|
||||
TagStyleConverter::class,
|
||||
StringArrayListConverter::class,
|
||||
ListStringConverter::class,
|
||||
CommunityVideoConverter::class,
|
||||
@ -127,6 +128,13 @@ 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,
|
||||
@ -142,6 +150,7 @@ abstract class HistoryDatabase : RoomDatabase() {
|
||||
.addMigrations(MIGRATION_8_9)
|
||||
.addMigrations(MIGRATION_9_10)
|
||||
.addMigrations(MIGRATION_10_11)
|
||||
.addMigrations(MIGRATION_11_12)
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,6 +71,8 @@ object HistoryHelper {
|
||||
historyGame.name = gameEntity.name
|
||||
historyGame.tagStyle = gameEntity.tagStyle
|
||||
historyGame.tag = gameEntity.getTag()
|
||||
historyGame.subtitle = gameEntity.subtitle
|
||||
historyGame.subtitleStyle = gameEntity.subtitleStyle
|
||||
return historyGame
|
||||
}
|
||||
|
||||
|
||||
@ -146,21 +146,31 @@ class SimulatorDownloadManager private constructor() {
|
||||
|
||||
PermissionHelper.checkGetInstalledAppsListBeforeAction(context, object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
//判断是否隐藏
|
||||
if (simulator?.active == false) {
|
||||
val isInstalledNewSimulator =
|
||||
SimulatorGameManager.isNewSimulatorInstalled(HaloApp.getInstance().application)
|
||||
//当没有安装新版本模拟器时候 判断是否隐藏
|
||||
if (simulator?.active == false && !isInstalledNewSimulator) {
|
||||
showNoneEmulatorDialog(context)
|
||||
return
|
||||
}
|
||||
val isInstalled = PackageUtils.isInstalledFromAllPackage(context, simulator?.apk?.packageName)
|
||||
var isInstalled = PackageUtils.isInstalledFromAllPackage(
|
||||
context,
|
||||
simulator?.apk?.packageName
|
||||
)
|
||||
//模拟器管理界面还是用之前的逻辑
|
||||
if (isInstalledNewSimulator && location != SimulatorLocation.SIMULATOR_MANAGE) {
|
||||
isInstalled = isInstalledNewSimulator
|
||||
}
|
||||
// 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 "安装模拟器"
|
||||
|
||||
@ -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.utils.NetworkUtils
|
||||
import com.gh.gamecenter.common.retrofit.Response
|
||||
import com.gh.gamecenter.common.utils.ImageUtils
|
||||
import com.gh.gamecenter.common.utils.observableToMain
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.entity.NewApiSettingsEntity
|
||||
import com.gh.gamecenter.entity.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,24 +19,40 @@ object AdHelper {
|
||||
const val LOCATION_SUGGESTION_FUNCTION = "suggestion_function"
|
||||
const val LOCATION_SIMULATOR_GAME = "simulator_game"
|
||||
|
||||
@JvmField
|
||||
var startupAd = MutableLiveData<StartupAdEntity>()
|
||||
@JvmStatic
|
||||
fun getStartUpAd(): StartupAdEntity? {
|
||||
return Config.getNewApiSettingsEntity()?.startAd
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@SuppressLint("CheckResult")
|
||||
fun getStartUpAd() {
|
||||
if (!NetworkUtils.isNetworkConnected(HaloApp.getInstance())) {
|
||||
startupAd.postValue(null)
|
||||
return
|
||||
}
|
||||
fun getStartUp(): StartupAdEntity? {
|
||||
return Config.getNewApiSettingsEntity()?.startup
|
||||
}
|
||||
|
||||
RetrofitManager.getInstance()
|
||||
.api
|
||||
.getSplashAd(HaloApp.getInstance().channel)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : BiResponse<StartupAdEntity>() {
|
||||
override fun onSuccess(data: StartupAdEntity) {
|
||||
startupAd.postValue(data)
|
||||
@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)
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@ -0,0 +1,250 @@
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -15,12 +15,14 @@ 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.core.utils.SPUtils;
|
||||
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.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.
|
||||
@ -36,6 +38,10 @@ 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())) {
|
||||
@ -171,8 +177,34 @@ public class DetailDownloadUtils {
|
||||
}
|
||||
viewHolder.mDownloadPb.setText(downloadText);
|
||||
} else {
|
||||
viewHolder.mDownloadPb.setText("选择下载你的版本" + (TextUtils.isEmpty(downloadAddWord) ? "" : "-" + downloadAddWord) + " >");
|
||||
viewHolder.mMultiVersionDownloadTv.setText("选择下载你的版本" + (TextUtils.isEmpty(downloadAddWord) ? "" : "-" + downloadAddWord));
|
||||
viewHolder.mMultiVersionDownloadTv.setVisibility(View.VISIBLE);
|
||||
viewHolder.mDownloadPb.setText("");
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.NORMAL);
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(viewHolder.gameEntity);
|
||||
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) {
|
||||
@ -203,10 +235,14 @@ 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));
|
||||
@ -220,29 +256,28 @@ public class DetailDownloadUtils {
|
||||
}
|
||||
|
||||
switch (downloadEntity.getStatus()) {
|
||||
case timeout:
|
||||
case neterror:
|
||||
case subscribe:
|
||||
case downloading:
|
||||
case redirected:
|
||||
case pause:
|
||||
case overflow:
|
||||
if (SPUtils.getBoolean(Constants.SP_USE_BROWSER_TO_INSTALL)) {
|
||||
viewHolder.mDownloadPb.setText(R.string.browser_install_downloading);
|
||||
} else {
|
||||
viewHolder.mDownloadPb.setText(R.string.downloading);
|
||||
}
|
||||
String downloadingText = "游戏加载中 " + downloadEntity.getPercent() + "%";
|
||||
String resumeText = "继续加载 " + downloadEntity.getPercent() + "%";
|
||||
viewHolder.mDownloadPb.setText((downloadEntity.getStatus() == DownloadStatus.downloading || downloadEntity.getStatus() == DownloadStatus.redirected) ? downloadingText : resumeText);
|
||||
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.DOWNLOADING_PLUGIN);
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.WAITING);
|
||||
} else {
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_NORMAL);
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.WAITING);
|
||||
}
|
||||
break;
|
||||
case done:
|
||||
@ -304,18 +339,19 @@ 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);
|
||||
|
||||
@ -8,7 +8,6 @@ import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.CountDownTimer;
|
||||
import android.provider.Settings;
|
||||
@ -93,8 +92,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.compose.activity.ComposeBindPhoneActivity;
|
||||
import com.gh.gamecenter.setting.compose.activity.ComposeGameDownloadSettingActivity;
|
||||
import com.gh.gamecenter.setting.view.GameDownloadSettingFragment;
|
||||
import com.gh.gamecenter.setting.view.security.BindPhoneActivity;
|
||||
import com.gh.gamecenter.suggest.SuggestType;
|
||||
import com.lightgame.adapter.BaseRecyclerAdapter;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
@ -216,7 +215,7 @@ public class DialogUtils {
|
||||
} else if (NetworkUtils.isWifiConnected(context)
|
||||
|| filter4GorSize(context, size)) {
|
||||
callBack.onResponse(false);
|
||||
} else if (!SPUtils.getBoolean(ComposeGameDownloadSettingActivity.getTrafficDownloadHintKey(), true)) {
|
||||
} else if (!SPUtils.getBoolean(GameDownloadSettingFragment.getTrafficDownloadHintKey(), true)) {
|
||||
AppExecutor.getUiExecutor().executeWithDelay(() -> Utils.toast(context, "当前使用移动网络下载,请注意流量消耗"), 500);
|
||||
callBack.onResponse(false);
|
||||
} else {
|
||||
@ -288,7 +287,7 @@ public class DialogUtils {
|
||||
// MtaHelper.onEvent("移动网络下载", NetworkUtils.getMobileNetworkType(finalContext), "连上WiFi后自动下载");
|
||||
});
|
||||
allowAlways.setOnClickListener(v -> {
|
||||
SPUtils.setBoolean(ComposeGameDownloadSettingActivity.getTrafficDownloadHintKey(), false);
|
||||
SPUtils.setBoolean(GameDownloadSettingFragment.getTrafficDownloadHintKey(), false);
|
||||
AppExecutor.getUiExecutor().executeWithDelay(() -> {
|
||||
// 显示了弹窗以后,即便下面这个 toast 放在 listener.onConfirm 后调用也是显示 listener.onConfirm 里的 toast
|
||||
// 喷了,延时包治疑难杂症
|
||||
@ -1252,38 +1251,6 @@ 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);
|
||||
@ -1618,7 +1585,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));
|
||||
@ -1628,7 +1595,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 {
|
||||
@ -1637,12 +1604,10 @@ 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("其它")) {
|
||||
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);
|
||||
ExtensionsKt.setDrawableEnd(reportTv, R.drawable.ic_complaint_arrow_right, DisplayUtils.dip2px(6F), DisplayUtils.dip2px(6F));
|
||||
}
|
||||
complaintContainer.addView(reportTv);
|
||||
|
||||
@ -2051,7 +2016,7 @@ public class DialogUtils {
|
||||
binding.confirmTv.setText("我知道了");
|
||||
binding.centerDivider.setVisibility(View.GONE);
|
||||
binding.cancelTv.setVisibility(View.GONE);
|
||||
binding.titleTv.setCompoundDrawablesWithIntrinsicBounds(ExtensionsKt.toDrawable(R.drawable.ic_reserve_success), null, null, null);
|
||||
ExtensionsKt.setDrawableStart(binding.titleTv, R.drawable.ic_reserve_success, null, null);
|
||||
binding.confirmTv.setOnClickListener(v -> dialog.dismiss());
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(binding.getRoot());
|
||||
@ -2080,7 +2045,7 @@ public class DialogUtils {
|
||||
|
||||
binding.bindPhoneBtn.setOnClickListener(v -> {
|
||||
dialog.dismiss();
|
||||
Intent intent = ComposeBindPhoneActivity.getNormalIntent(finalContext, false);
|
||||
Intent intent = BindPhoneActivity.getNormalIntent(finalContext, false);
|
||||
finalContext.startActivity(intent);
|
||||
});
|
||||
|
||||
|
||||
@ -65,8 +65,8 @@ import com.gh.gamecenter.qa.video.detail.ForumVideoDetailActivity
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.gh.gamecenter.servers.GameServerTestActivity
|
||||
import com.gh.gamecenter.servers.GameServersActivity
|
||||
import com.gh.gamecenter.setting.compose.activity.ComposeBindPhoneActivity
|
||||
import com.gh.gamecenter.setting.compose.activity.ComposeSettingActivity
|
||||
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,6 +145,7 @@ object DirectUtils {
|
||||
directToLinkPage(context, linkEntity, entrance, path, null)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun directToLinkPage(
|
||||
context: Context,
|
||||
linkEntity: LinkEntity,
|
||||
@ -358,7 +359,7 @@ object DirectUtils {
|
||||
|
||||
"mobile_bind" -> {
|
||||
CheckLoginUtils.checkLogin(context, entrance) {
|
||||
context.startActivity(ComposeBindPhoneActivity.getNormalIntent(context, false))
|
||||
context.startActivity(BindPhoneActivity.getNormalIntent(context, false))
|
||||
}
|
||||
}
|
||||
|
||||
@ -388,7 +389,7 @@ object DirectUtils {
|
||||
|
||||
"etiquette_exam" -> directToRegulationTestPage(context)
|
||||
|
||||
"setting" -> context.startActivity(ComposeSettingActivity.getIntent(context, false, entrance))
|
||||
"setting" -> context.startActivity(SettingActivity.getIntent(context, false, entrance))
|
||||
|
||||
"index_page" -> directToHomeTab(context)
|
||||
|
||||
@ -772,6 +773,36 @@ 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()
|
||||
|
||||
@ -19,26 +19,25 @@ 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.entity.GameEntity
|
||||
import com.gh.gamecenter.common.entity.LinkEntity
|
||||
import com.gh.gamecenter.energy.EnergyBridge
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
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
|
||||
@ -126,7 +125,7 @@ object DownloadItemUtils {
|
||||
holder.gameDownloadBtn.text = "已预约"
|
||||
holder.gameDownloadBtn.visibility = View.VISIBLE
|
||||
holder.gameDownloadBtn.buttonStyle = DownloadButton.ButtonStyle.RESERVED
|
||||
updateItemViewStatus(holder, false, null, null)
|
||||
updateItemViewStatus(holder, null, null)
|
||||
}
|
||||
}
|
||||
|
||||
@ -166,7 +165,8 @@ object DownloadItemUtils {
|
||||
) {
|
||||
// 显示预约
|
||||
if (gameEntity.isReservable) {
|
||||
updateItemViewStatus(holder, false, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
|
||||
holder.multiVersionDownloadTv?.visibility = View.GONE
|
||||
updateItemViewStatus(holder, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
|
||||
updateDownloadButton(
|
||||
context,
|
||||
holder.gameDownloadBtn,
|
||||
@ -177,11 +177,16 @@ object DownloadItemUtils {
|
||||
return
|
||||
}
|
||||
if (gameEntity.getApk().isEmpty() || gameEntity.downloadOffStatus != null) {
|
||||
updateItemViewStatus(holder, false, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
|
||||
holder.multiVersionDownloadTv?.visibility = View.GONE
|
||||
holder.gameDownloadTips?.visibility = View.GONE
|
||||
updateItemViewStatus(holder, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
|
||||
} else if (gameEntity.getApk().size == 1) {
|
||||
updateNormalItem(context, holder, gameEntity, isShowPlatform, briefStyle, isShowRecommendStar)
|
||||
holder.multiVersionDownloadTv?.visibility = View.GONE
|
||||
holder.gameDownloadTips?.visibility = View.GONE
|
||||
updateNormalItem(context, holder, gameEntity, briefStyle, isShowRecommendStar)
|
||||
} else {
|
||||
updatePluginItem(context, holder, gameEntity, isShowPlatform, briefStyle, isShowRecommendStar)
|
||||
holder.multiVersionDownloadTv?.visibility = View.VISIBLE
|
||||
updatePluginItem(context, holder, gameEntity, briefStyle, isShowRecommendStar)
|
||||
}
|
||||
updateDownloadButton(
|
||||
context,
|
||||
@ -262,42 +267,56 @@ 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 {
|
||||
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)
|
||||
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 -> {
|
||||
buttonStyle = DownloadButton.ButtonStyle.NORMAL
|
||||
return
|
||||
setText(R.string.resume)
|
||||
}
|
||||
if (downloadEntity.isSimulatorGame() && gameEntity.simulator != null) {
|
||||
DownloadStatus.cancel -> {
|
||||
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)
|
||||
}
|
||||
buttonStyle =
|
||||
if (downloadEntity.isPluggable && PackagesManager.isInstalled(downloadEntity.packageName)) {
|
||||
DownloadButton.ButtonStyle.PLUGIN
|
||||
} else {
|
||||
DownloadButton.ButtonStyle.NORMAL
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -310,8 +329,10 @@ object DownloadItemUtils {
|
||||
|
||||
// 更新正常的条目,只有一个apk包
|
||||
private fun updateNormalItem(
|
||||
context: Context, holder: GameViewHolder, gameEntity: GameEntity,
|
||||
isShowPlatform: Boolean, briefStyle: String?,
|
||||
context: Context,
|
||||
holder: GameViewHolder,
|
||||
gameEntity: GameEntity,
|
||||
briefStyle: String?,
|
||||
isShowRecommendStar: Boolean = false
|
||||
) {
|
||||
val entryMap: ArrayMap<String, DownloadEntity> = gameEntity.getEntryMap()
|
||||
@ -322,23 +343,25 @@ object DownloadItemUtils {
|
||||
if (downloadEntity.isSimulatorGame()) {
|
||||
if (downloadEntity.status != DownloadStatus.done) {
|
||||
// 更改进度条和提示文本的状态
|
||||
changeStatus(context, holder, downloadEntity, isShowPlatform, true)
|
||||
changeStatus(context, holder, downloadEntity)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
// 更改进度条和提示文本的状态
|
||||
changeStatus(context, holder, downloadEntity, isShowPlatform, true, isShowRecommendStar)
|
||||
changeStatus(context, holder, downloadEntity)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
updateItemViewStatus(holder, false, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
|
||||
updateItemViewStatus(holder, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
|
||||
}
|
||||
|
||||
// 更新插件的条目,有多个apk包
|
||||
private fun updatePluginItem(
|
||||
context: Context, holder: GameViewHolder, gameEntity: GameEntity,
|
||||
isShowPlatform: Boolean, briefStyle: String?,
|
||||
context: Context,
|
||||
holder: GameViewHolder,
|
||||
gameEntity: GameEntity,
|
||||
briefStyle: String?,
|
||||
isShowRecommendStar: Boolean = false
|
||||
) {
|
||||
val entryMap = gameEntity.getEntryMap()
|
||||
@ -351,151 +374,131 @@ object DownloadItemUtils {
|
||||
}
|
||||
if (downloadEntity != null) {
|
||||
// 更改进度条和提示文本的状态
|
||||
changeStatus(context, holder, downloadEntity, isShowPlatform, false, isShowRecommendStar)
|
||||
changeStatus(context, holder, downloadEntity, gameEntity.getApk().size > 1)
|
||||
return
|
||||
}
|
||||
}
|
||||
updateItemViewStatus(holder, false, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
|
||||
updateItemViewStatus(holder, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
|
||||
}
|
||||
|
||||
// 更改进度条和提示文本的状态
|
||||
fun changeStatus(
|
||||
context: Context, holder: GameViewHolder, downloadEntity: DownloadEntity,
|
||||
isShowPlatform: Boolean, isNormal: Boolean, isShowRecommendStar: Boolean = false
|
||||
context: Context,
|
||||
holder: GameViewHolder,
|
||||
downloadEntity: DownloadEntity,
|
||||
isMultiVersion: Boolean = false
|
||||
) {
|
||||
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
|
||||
)
|
||||
)
|
||||
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))
|
||||
} else {
|
||||
holder.gameDownloadSpeed.text = String.format(
|
||||
"%s(剩%s)", SpeedUtils.getSpeed(downloadEntity.speed),
|
||||
SpeedUtils.getRemainTime(
|
||||
downloadEntity.size,
|
||||
downloadEntity.progress,
|
||||
downloadEntity.speed * 1024
|
||||
)
|
||||
)
|
||||
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.gameDownloadPercentage.text = downloadEntity.percent.toString() + "%"
|
||||
}
|
||||
} 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.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)
|
||||
}
|
||||
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.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.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
|
||||
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.gameProgressbar.progress = 1000
|
||||
if (isShowPlatform && platform != null) {
|
||||
holder.gameDownloadSpeed.text = String.format("%s - 下载完成", platform)
|
||||
} else {
|
||||
holder.gameDownloadSpeed.text = "下载完成"
|
||||
else -> {
|
||||
holder.gameDownloadTips?.visibility = View.GONE
|
||||
}
|
||||
holder.gameDownloadPercentage.setText(R.string.hundred_percent)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateItemViewStatus(
|
||||
holder: GameViewHolder,
|
||||
showDownload: Boolean,
|
||||
briefStyle: String?,
|
||||
recommendStyle: LinkEntity?,
|
||||
isShowRecommendStar: Boolean = false
|
||||
) {
|
||||
if (showDownload) {
|
||||
holder.gameDownloadTips?.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
|
||||
holder.gameProgressbar.visibility = View.VISIBLE
|
||||
holder.gameInfo.visibility = View.VISIBLE
|
||||
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 (holder.recommendStarInfo != null) {
|
||||
holder.recommendStarInfo!!.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
if (briefStyle != null && briefStyle.contains("star")) {
|
||||
if (holder.gameRating != null) holder.gameRating!!.visibility = View.VISIBLE
|
||||
} else {
|
||||
holder.gameProgressbar.visibility = View.GONE
|
||||
holder.gameInfo.visibility = View.GONE
|
||||
if (holder.gameRating != null) holder.gameRating!!.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
|
||||
}
|
||||
// 缺省情况下回落到游戏简介
|
||||
if (TextUtils.isEmpty(briefStyle) || briefStyle!!.contains("brief") || briefStyle.contains("recommend")) {
|
||||
holder.gameDes.visibility = View.VISIBLE
|
||||
} else {
|
||||
holder.gameDes.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
@ -787,6 +790,7 @@ 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())
|
||||
@ -844,8 +848,11 @@ object DownloadItemUtils {
|
||||
val isInstalledNewSimulator = SimulatorGameManager.isNewSimulatorInstalled(context)
|
||||
val isInstalledOldSimulator = SimulatorGameManager.isOldSimulatorInstalled(context)
|
||||
var simulator = gameEntity.simulator
|
||||
if (!isInstalledOldSimulator) {
|
||||
simulator = Config.getNewSimulatorEntitySetting()
|
||||
val newSimulator = Config.getNewSimulatorEntitySetting()
|
||||
if (!isInstalledOldSimulator && newSimulator != null) {//在没有安装旧的模拟器且有配置新版模拟器 才使用新版模拟器 否则还是用以前旧的
|
||||
if (newSimulator.active) {
|
||||
simulator = newSimulator
|
||||
}
|
||||
}
|
||||
if (downloadEntity != null && SimulatorGameManager.isSimulatorGame(gameEntity) && !isInstalled && !isInstalledNewSimulator) {
|
||||
SimulatorDownloadManager.getInstance().showDownloadDialog(
|
||||
@ -907,15 +914,31 @@ object DownloadItemUtils {
|
||||
}
|
||||
})
|
||||
} else {
|
||||
if (gameEntity.isVGame()) {
|
||||
context.startActivity(VDownloadManagerActivity.getIntent(context, true))
|
||||
} else {
|
||||
context.startActivity(
|
||||
DownloadManagerActivity.getDownloadMangerIntent(
|
||||
context,
|
||||
apk.url, entrance + "+(" + location.split(":").toTypedArray()[0] + ")"
|
||||
)
|
||||
)
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -944,7 +967,7 @@ object DownloadItemUtils {
|
||||
traceEvent
|
||||
)
|
||||
Utils.toast(context, gameEntity.name + "已加入下载队列")
|
||||
downloadBtn.setText(R.string.downloading)
|
||||
downloadBtn.text = "0%"
|
||||
downloadBtn.buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_NORMAL
|
||||
DeviceRemindDialog.showDeviceRemindDialog(context, gameEntity)
|
||||
} else {
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.preference.PreferenceManager
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.common.exposure.ExposureUtils
|
||||
import com.gh.common.simulator.SimulatorDownloadManager
|
||||
@ -22,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.compose.activity.ComposeGameDownloadSettingActivity
|
||||
import com.gh.gamecenter.setting.view.GameDownloadSettingFragment
|
||||
import com.gh.gamecenter.suggest.SuggestType
|
||||
import com.gh.vspace.VHelper
|
||||
import com.halo.assistant.HaloApp
|
||||
@ -240,16 +241,20 @@ 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
|
||||
if (!isInstalledOldSimulator || isInstalledNewSimulator) { //如果没有安装任一旧的模拟器 或者下载了新模拟器 则使用新版本模拟器
|
||||
Config.getNewSimulatorEntitySetting().let {
|
||||
simulator = it!!
|
||||
}
|
||||
val newSimulator = Config.getNewSimulatorEntitySetting()
|
||||
if ((!isInstalledOldSimulator && newSimulator != null && newSimulator.active) || isInstalledNewSimulator) { //如果没有安装任一旧的模拟器 或者下载了新模拟器 则使用新版本模拟器
|
||||
simulator = newSimulator ?: simulator
|
||||
}
|
||||
SimulatorDownloadManager.getInstance().showDownloadDialog(
|
||||
currentActivity, simulator,
|
||||
@ -261,7 +266,7 @@ object DownloadObserver {
|
||||
} else {
|
||||
val downloadType = downloadEntity.getMetaExtra(Constants.EXTRA_DOWNLOAD_TYPE)
|
||||
// 是否是自动安装
|
||||
val isAutoInstall = SPUtils.getBoolean(ComposeGameDownloadSettingActivity.AUTO_INSTALL_SP_KEY, true)
|
||||
val isAutoInstall = SPUtils.getBoolean(GameDownloadSettingFragment.AUTO_INSTALL_SP_KEY, true)
|
||||
if (downloadType == Constants.SIMULATOR_DOWNLOAD || isAutoInstall) {
|
||||
if (FileUtils.isEmptyFile(downloadEntity.path)) {
|
||||
Utils.toast(mApplication, R.string.install_failure_hint)
|
||||
|
||||
@ -37,6 +37,32 @@ 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);
|
||||
|
||||
|
||||
@ -183,6 +183,11 @@ 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)
|
||||
}
|
||||
}
|
||||
@ -403,15 +408,16 @@ object ErrorHelper {
|
||||
val errorEntity: ErrorEntity? =
|
||||
httpException?.response()?.errorBody()?.string()?.toObject()
|
||||
when {
|
||||
errorEntity?.code == 403099 -> {
|
||||
Utils.toast(context, "当前账号正在注销,禁止登录")
|
||||
}
|
||||
errorEntity?.code == 403401 -> {//禁止登录
|
||||
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?.code == 403404 -> Utils.toast(context, "您的设备存在违规,不允许登录")
|
||||
|
||||
errorEntity?.toast?.isNotEmpty() == true -> Utils.toast(context, errorEntity.toast)
|
||||
|
||||
else -> Utils.toast(context, R.string.login_failure)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
|
||||
@ -5,6 +5,7 @@ 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
|
||||
@ -12,6 +13,9 @@ 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
|
||||
@ -27,8 +31,10 @@ 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
|
||||
@ -37,7 +43,10 @@ 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
|
||||
|
||||
/**
|
||||
* 游戏活动下载辅助类
|
||||
@ -168,10 +177,13 @@ object GameActivityDownloadHelper {
|
||||
) {
|
||||
val apk = getApk(gameEntity, event, true) ?: return
|
||||
val downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity)
|
||||
if (downloadEntity != null) {
|
||||
val str = GameUtils.getDownloadBtnText(context, gameEntity, PluginLocation.only_game)
|
||||
if (downloadEntity != null &&
|
||||
str != context.getString(R.string.install) &&
|
||||
str != context.getString(R.string.launch)
|
||||
) {
|
||||
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) {
|
||||
@ -182,7 +194,7 @@ object GameActivityDownloadHelper {
|
||||
}
|
||||
DataLogUtils.uploadGameLog(context, gameEntity.id, gameEntity.name, entrance)
|
||||
} else if (str == context.getString(R.string.smooth)) {
|
||||
VHelper.validateVSpaceBeforeAction(context, gameEntity, true) {
|
||||
VHelper.validateVSpaceBeforeAction(context, gameEntity) {
|
||||
GamePermissionDialogFragment.show((context as AppCompatActivity), gameEntity, gameEntity.info) {
|
||||
CertificationDialog.showCertificationDialog(context, gameEntity) {
|
||||
DialogUtils.checkDownload(context, apk.size) { isSubscribe: Boolean ->
|
||||
@ -201,12 +213,73 @@ object GameActivityDownloadHelper {
|
||||
}
|
||||
}
|
||||
}
|
||||
} 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.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.update)) {
|
||||
DialogUtils.checkDownload(context, apk.size) { isSubscribe: Boolean ->
|
||||
update(context, gameEntity, apk, entrance, location, isSubscribe, traceEvent)
|
||||
}
|
||||
} else {
|
||||
ToastUtils.toast("${gameEntity.name}已加入下载队列")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -294,6 +367,29 @@ 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,
|
||||
|
||||
@ -1,16 +1,17 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.text.TextUtils;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.common.view.DownloadButton;
|
||||
import com.gh.gamecenter.core.AppExecutor;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.WorkerThread;
|
||||
|
||||
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;
|
||||
@ -26,9 +27,6 @@ import com.lightgame.download.DownloadStatus;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.WorkerThread;
|
||||
|
||||
public class GameUtils {
|
||||
|
||||
/**
|
||||
@ -80,7 +78,7 @@ public class GameUtils {
|
||||
@WorkerThread
|
||||
public static String getDownloadBtnText(Context context, GameEntity gameEntity, PluginLocation pluginLocation) {
|
||||
if (gameEntity.getApk().size() > 1) {
|
||||
return context.getString(R.string.expand);
|
||||
return "";
|
||||
}
|
||||
|
||||
int doneCount = 0; // 下载完成数量
|
||||
|
||||
@ -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("安装", packageName, installVersion));
|
||||
EventBus.getDefault().post(new EBPackage(EBPackage.TYPE_INSTALLED, packageName, installVersion));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,7 +18,6 @@ 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;
|
||||
@ -165,6 +164,12 @@ 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);
|
||||
@ -355,7 +360,14 @@ public class LibaoUtils {
|
||||
Utils.toast(context, "还没到开始领取时间");
|
||||
break;
|
||||
case "查看":
|
||||
if (!TextUtils.isEmpty(libaoEntity.getDes())) {
|
||||
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())) {
|
||||
DialogHelper.showCenterDialog(v.getContext(), "使用说明", Html.fromHtml(libaoEntity.getDes()), "关闭", "", () -> {
|
||||
}, () -> {
|
||||
});
|
||||
|
||||
@ -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.setWelcomeDialogId(linkTitle);
|
||||
payload.setWelcomeDialogLinkTitle(linkTitle);
|
||||
|
||||
SimpleLogContainerEntity entity = new SimpleLogContainerEntity();
|
||||
entity.setEvent("dialog");
|
||||
|
||||
@ -813,4 +813,235 @@ object NewFlatLogUtils {
|
||||
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)
|
||||
}
|
||||
}
|
||||
@ -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 isSmoothGame = downloadEntity.getMetaExtra(Constants.SMOOTH_GAME) == "true"
|
||||
val isVGame = downloadEntity.getMetaExtra(Constants.SMOOTH_GAME) == "true"
|
||||
|
||||
val currentActivity = CurrentActivityHolder.getCurrentActivity() ?: return
|
||||
|
||||
if (isSmoothGame) {
|
||||
if (isVGame) {
|
||||
VHelper.install(currentActivity, downloadEntity)
|
||||
return
|
||||
}
|
||||
|
||||
@ -12,9 +12,10 @@ 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
|
||||
@ -94,13 +95,8 @@ 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.setCompoundDrawables(null, null, drawableUp, null)
|
||||
typeTv.setDrawableEnd(R.drawable.ic_filter_arrow_up)
|
||||
|
||||
val inflater = LayoutInflater.from(typeTv.context)
|
||||
val layout = inflater.inflate(R.layout.layout_filter_size, null)
|
||||
@ -145,7 +141,7 @@ class CatalogFilterView @JvmOverloads constructor(
|
||||
|
||||
popupWindow.setOnDismissListener {
|
||||
typeTv.setTextColor(R.color.text_757575.toColor(context))
|
||||
typeTv.setCompoundDrawables(null, null, drawableDown, null)
|
||||
typeTv.setDrawableEnd(R.drawable.ic_filter_arrow_down)
|
||||
mTypePopupWindow = null
|
||||
}
|
||||
|
||||
@ -156,13 +152,8 @@ 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.setCompoundDrawables(null, null, drawableUp, null)
|
||||
catalogTv.setDrawableEnd(R.drawable.ic_filter_arrow_up)
|
||||
|
||||
val inflater = LayoutInflater.from(catalogTv.context)
|
||||
val layout = inflater.inflate(R.layout.layout_filter_size, null)
|
||||
@ -209,7 +200,7 @@ class CatalogFilterView @JvmOverloads constructor(
|
||||
|
||||
popupWindow.setOnDismissListener {
|
||||
catalogTv.setTextColor(R.color.text_757575.toColor(context))
|
||||
catalogTv.setCompoundDrawables(null, null, drawableDown, null)
|
||||
catalogTv.setDrawableEnd(R.drawable.ic_filter_arrow_down)
|
||||
mCatalogPopupWindow = null
|
||||
}
|
||||
|
||||
@ -220,13 +211,8 @@ 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.setCompoundDrawables(null, null, drawableUp, null)
|
||||
sizeTv.setDrawableEnd(R.drawable.ic_filter_arrow_up)
|
||||
|
||||
val inflater = LayoutInflater.from(sizeTv.context)
|
||||
val layout = inflater.inflate(R.layout.layout_filter_size, null)
|
||||
@ -281,7 +267,7 @@ class CatalogFilterView @JvmOverloads constructor(
|
||||
|
||||
popupWindow.setOnDismissListener {
|
||||
sizeTv.setTextColor(R.color.text_757575.toColor(context))
|
||||
sizeTv.setCompoundDrawables(null, null, drawableDown, null)
|
||||
sizeTv.setDrawableEnd(R.drawable.ic_filter_arrow_down)
|
||||
mSizePopupWindow = null
|
||||
}
|
||||
|
||||
|
||||
@ -11,9 +11,10 @@ import android.widget.PopupWindow
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.gh.gamecenter.common.utils.dip2px
|
||||
import com.gh.gamecenter.common.utils.toColor
|
||||
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.entity.SubjectSettingEntity
|
||||
import com.google.android.flexbox.FlexboxLayout
|
||||
|
||||
@ -89,13 +90,8 @@ 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.setCompoundDrawables(null, null, drawableUp, null)
|
||||
typeTv.setDrawableEnd(R.drawable.ic_filter_arrow_up)
|
||||
|
||||
val inflater = LayoutInflater.from(typeTv.context)
|
||||
val layout = inflater.inflate(R.layout.layout_filter_size, null)
|
||||
@ -141,7 +137,7 @@ class CategoryFilterView @JvmOverloads constructor(
|
||||
|
||||
popupWindow.setOnDismissListener {
|
||||
typeTv.setTextColor(R.color.text_757575.toColor(context))
|
||||
typeTv.setCompoundDrawables(null, null, drawableDown, null)
|
||||
typeTv.setDrawableEnd(R.drawable.ic_filter_arrow_down)
|
||||
mTypePopupWindow = null
|
||||
}
|
||||
|
||||
@ -152,13 +148,8 @@ 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.setCompoundDrawables(null, null, drawableUp, null)
|
||||
sizeTv.setDrawableEnd(R.drawable.ic_filter_arrow_up)
|
||||
|
||||
val inflater = LayoutInflater.from(sizeTv.context)
|
||||
val layout = inflater.inflate(R.layout.layout_filter_size, null)
|
||||
@ -214,7 +205,7 @@ class CategoryFilterView @JvmOverloads constructor(
|
||||
|
||||
popupWindow.setOnDismissListener {
|
||||
sizeTv.setTextColor(R.color.text_757575.toColor(context))
|
||||
sizeTv.setCompoundDrawables(null, null, drawableDown, null)
|
||||
sizeTv.setDrawableEnd(R.drawable.ic_filter_arrow_down)
|
||||
mSizePopupWindow = null
|
||||
}
|
||||
|
||||
|
||||
@ -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,14 +112,8 @@ 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.setCompoundDrawables(null, null, drawableUp, null)
|
||||
sizeTv.setDrawableEnd(R.drawable.ic_filter_arrow_up)
|
||||
|
||||
val inflater = LayoutInflater.from(sizeTv.context)
|
||||
val layout = inflater.inflate(R.layout.layout_filter_size, null)
|
||||
@ -178,7 +172,7 @@ class ConfigFilterView @JvmOverloads constructor(
|
||||
|
||||
popupWindow.setOnDismissListener {
|
||||
sizeTv.setTextColor(R.color.text_757575.toColor(sizeTv.context))
|
||||
sizeTv.setCompoundDrawables(null, null, drawableDown, null)
|
||||
sizeTv.setDrawableEnd(R.drawable.ic_filter_arrow_down)
|
||||
mPopupWindow = null
|
||||
}
|
||||
|
||||
|
||||
@ -45,12 +45,7 @@ class DownloadButton @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
var text: String
|
||||
get() {
|
||||
if (showProgress && mText.contains("%")) {
|
||||
return context.getString(R.string.downloading)
|
||||
}
|
||||
return mText
|
||||
}
|
||||
get() = mText
|
||||
set(value) {
|
||||
mText = value
|
||||
invalidate()
|
||||
@ -123,11 +118,7 @@ class DownloadButton @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
fun setText(@StringRes res: Int) {
|
||||
text = if (mShowPercent && res == R.string.downloading) {
|
||||
"${progress / 10}%"
|
||||
} else {
|
||||
context.getString(res)
|
||||
}
|
||||
text = context.getString(res)
|
||||
invalidate()
|
||||
}
|
||||
|
||||
@ -156,6 +147,7 @@ class DownloadButton @JvmOverloads constructor(
|
||||
when (buttonStyle) {
|
||||
ButtonStyle.NORMAL,
|
||||
ButtonStyle.INSTALL_NORMAL,
|
||||
ButtonStyle.XAPK_FAILURE,
|
||||
ButtonStyle.NONE_WITH_HINT,
|
||||
ButtonStyle.H5_GAME,
|
||||
ButtonStyle.SPECIAL_DOWNLOAD,
|
||||
@ -187,6 +179,7 @@ class DownloadButton @JvmOverloads constructor(
|
||||
progress = 0
|
||||
mDefaultColor = R.color.white.toColor(context)
|
||||
}
|
||||
ButtonStyle.FAILURE,
|
||||
ButtonStyle.NONE,
|
||||
ButtonStyle.RESERVED -> {
|
||||
progressDrawable = null
|
||||
@ -201,6 +194,8 @@ class DownloadButton @JvmOverloads constructor(
|
||||
progress = 0
|
||||
mDefaultColor = R.color.white.toColor(context)
|
||||
}
|
||||
ButtonStyle.XAPK_SUCCESS,
|
||||
ButtonStyle.XAPK_UNZIPPING,
|
||||
ButtonStyle.DOWNLOADING_NORMAL -> {
|
||||
if (showProgress) {
|
||||
progressDrawable =
|
||||
@ -239,18 +234,6 @@ 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
|
||||
}
|
||||
|
||||
@ -14,9 +14,10 @@ import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.gamecenter.common.utils.dip2px
|
||||
import com.gh.gamecenter.common.utils.toColor
|
||||
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.common.utils.toDrawable
|
||||
import com.gh.gamecenter.databinding.ItemFilterBinding
|
||||
import com.gh.gamecenter.databinding.LayoutFilterBinding
|
||||
@ -107,13 +108,8 @@ 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.setCompoundDrawables(null, null, drawableUp, null)
|
||||
subFilterTv.setDrawableEnd(R.drawable.ic_filter_arrow_up)
|
||||
|
||||
val inflater = LayoutInflater.from(subFilterTv.context)
|
||||
val layout = inflater.inflate(R.layout.layout_filter_size, null)
|
||||
@ -163,7 +159,7 @@ class FilterView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
||||
}
|
||||
|
||||
popupWindow.setOnDismissListener {
|
||||
subFilterTv.setCompoundDrawables(null, null, drawableDown, null)
|
||||
subFilterTv.setDrawableEnd(R.drawable.ic_filter_arrow_down)
|
||||
}
|
||||
|
||||
popupWindow.isTouchable = true
|
||||
|
||||
@ -36,6 +36,7 @@ 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;
|
||||
@ -389,12 +390,16 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
* 清理不存在本地 APK 文件的任务
|
||||
*/
|
||||
public void clearTasksThatFileBeenDeleted() {
|
||||
for (DownloadEntity entity : getAllDownloadEntity()) {
|
||||
if (entity.getStatus() == DownloadStatus.done) {
|
||||
if (FileUtils.isEmptyFile(entity.getPath())) {
|
||||
cancel(entity.getUrl());
|
||||
try {
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
@ -688,6 +693,14 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
return filterSilentDownloadTask(all);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下载列表中除下载状态为完成以外的任务
|
||||
*/
|
||||
public List<DownloadEntity> getAllDownloadEntityExcludeDoneTask() {
|
||||
List<DownloadEntity> all = getAllDownloadEntity();
|
||||
return filterDoneDownloadTask(all);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下载列表中的畅玩下载任务快照
|
||||
*/
|
||||
@ -728,6 +741,20 @@ 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);
|
||||
}
|
||||
@ -868,7 +895,7 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
Utils.log(DownloadManager.class.getSimpleName(), "addObserver");
|
||||
DataChanger.INSTANCE.addObserver(dataWatcher);
|
||||
|
||||
notifyDownloadedStatusASAP(dataWatcher);
|
||||
notifyDownloadStatusASAP(dataWatcher);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -880,13 +907,11 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* 立马通知 dataWatcher 更新已下载完的任务状态,这里的下载完成是持久状态,不是瞬时状态
|
||||
* 立马通知 dataWatcher 更新下载任务状态
|
||||
*/
|
||||
private void notifyDownloadedStatusASAP(DataWatcher dataWatcher) {
|
||||
private void notifyDownloadStatusASAP(DataWatcher dataWatcher) {
|
||||
for (DownloadEntity downloadEntity : getAllDownloadEntitySnapshots()) {
|
||||
if (downloadEntity.getStatus() == DownloadStatus.done) {
|
||||
dataWatcher.onDataInit(downloadEntity);
|
||||
}
|
||||
dataWatcher.onDataInit(downloadEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@ -951,7 +976,7 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
public void checkAndRetryDownload() {
|
||||
if (!NetworkUtils.isWifiConnected(mContext)) return;
|
||||
|
||||
for (DownloadEntity downloadEntity : DownloadManager.getInstance().getAllDownloadEntityExcludeSilentTask()) {
|
||||
for (DownloadEntity downloadEntity : DownloadManager.getInstance().getAllDownloadEntityExcludeDoneTask()) {
|
||||
if (DownloadStatus.neterror.equals(downloadEntity.getStatus())
|
||||
|| DownloadStatus.timeout.equals(downloadEntity.getStatus())
|
||||
|| DownloadStatus.subscribe.equals(downloadEntity.getStatus())) {
|
||||
|
||||
@ -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.compose.activity.ComposeGameDownloadSettingActivity
|
||||
import com.gh.gamecenter.setting.view.GameDownloadSettingFragment
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import com.lightgame.download.FileUtils
|
||||
@ -91,7 +91,7 @@ object PackageObserver {
|
||||
gameId = approximateGameId
|
||||
}
|
||||
|
||||
if ("安装" == busFour.type) {
|
||||
if (EBPackage.TYPE_INSTALLED == busFour.type) {
|
||||
mPackageViewModel.addInstalledGame(packageName)
|
||||
|
||||
BrowserInstallHelper.onApkInstalled(mDownloadEntity?.path)
|
||||
@ -109,11 +109,7 @@ object PackageObserver {
|
||||
|
||||
DownloadManager.getInstance().cancel(mDownloadEntity.url, false, true, false)
|
||||
|
||||
if (SPUtils.getBoolean(
|
||||
ComposeGameDownloadSettingActivity.CONCERN_GAME_SP_KEY,
|
||||
true
|
||||
)
|
||||
) { //设置页面控制是否安装后自动关注
|
||||
if (SPUtils.getBoolean(GameDownloadSettingFragment.CONCERN_GAME_SP_KEY, true)) { //设置页面控制是否安装后自动关注
|
||||
// 安装后关注游戏
|
||||
val finalDownloadEntity = mDownloadEntity
|
||||
RetrofitManager.getInstance().api
|
||||
|
||||
@ -14,17 +14,19 @@ 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
|
||||
@ -48,6 +50,9 @@ 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
|
||||
@ -91,6 +96,9 @@ 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) ?: ""
|
||||
@ -106,6 +114,7 @@ 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 ->
|
||||
@ -145,7 +154,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 + "版本")
|
||||
@ -161,6 +170,41 @@ 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))
|
||||
|
||||
@ -83,7 +83,7 @@ class DownloadDialogItemViewHolder(val binding: DownloadDialogItemBinding) : Bas
|
||||
|
||||
|
||||
binding.containerView.setBackgroundResource(R.drawable.download_dialog_item_background)
|
||||
binding.status.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null)
|
||||
binding.status.removeDrawable()
|
||||
changeRecommendUI(apkEntity, listData, position)
|
||||
|
||||
if (apkLink != null) {
|
||||
@ -95,12 +95,7 @@ class DownloadDialogItemViewHolder(val binding: DownloadDialogItemBinding) : Bas
|
||||
binding.remark.goneIf(apkLink.remark.isEmpty())
|
||||
|
||||
binding.status.text = "点击查看"
|
||||
binding.status.setCompoundDrawablesWithIntrinsicBounds(
|
||||
null,
|
||||
null,
|
||||
ContextCompat.getDrawable(binding.status.context, R.drawable.download_dialog_collection_status_link),
|
||||
null
|
||||
)
|
||||
binding.status.setDrawableEnd(R.drawable.download_dialog_collection_status_link)
|
||||
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())) {
|
||||
@ -149,15 +144,7 @@ class DownloadDialogItemViewHolder(val binding: DownloadDialogItemBinding) : Bas
|
||||
binding.status.visibility = View.VISIBLE
|
||||
|
||||
binding.status.text = "可更新"
|
||||
binding.status.setCompoundDrawablesWithIntrinsicBounds(
|
||||
null,
|
||||
null,
|
||||
ContextCompat.getDrawable(
|
||||
binding.status.context,
|
||||
R.drawable.download_dialog_collection_status_update
|
||||
),
|
||||
null
|
||||
)
|
||||
binding.status.setDrawableEnd(R.drawable.download_dialog_collection_status_update)
|
||||
binding.downloadStatusIcon.visibility = View.GONE
|
||||
itemView.setTag(DownloadDialogAdapter.ITEM_TAG_KEY, DownloadDialogItemStatus.UPDATE)
|
||||
} else if (PackageUtils.getGhId(apkEntity.packageName) == gameEntity.id ||
|
||||
@ -184,15 +171,7 @@ class DownloadDialogItemViewHolder(val binding: DownloadDialogItemBinding) : Bas
|
||||
// 点击启动
|
||||
binding.status.text = "点击启动"
|
||||
itemView.setTag(DownloadDialogAdapter.ITEM_TAG_KEY, DownloadDialogItemStatus.LAUNCH)
|
||||
binding.status.setCompoundDrawablesWithIntrinsicBounds(
|
||||
null,
|
||||
null,
|
||||
ContextCompat.getDrawable(
|
||||
binding.status.context,
|
||||
R.drawable.download_dialog_collection_status_launch
|
||||
),
|
||||
null
|
||||
)
|
||||
binding.status.setDrawableEnd(R.drawable.download_dialog_collection_status_launch)
|
||||
}
|
||||
} else {
|
||||
binding.downloadStatusIcon.visibility = View.VISIBLE
|
||||
|
||||
@ -0,0 +1,25 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
105
app/src/main/java/com/gh/download/simple/DownloadButtonHelper.kt
Normal file
105
app/src/main/java/com/gh/download/simple/DownloadButtonHelper.kt
Normal file
@ -0,0 +1,105 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
37
app/src/main/java/com/gh/download/simple/DownloadDao.kt
Normal file
37
app/src/main/java/com/gh/download/simple/DownloadDao.kt
Normal file
@ -0,0 +1,37 @@
|
||||
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)
|
||||
|
||||
}
|
||||
16
app/src/main/java/com/gh/download/simple/DownloadListener.kt
Normal file
16
app/src/main/java/com/gh/download/simple/DownloadListener.kt
Normal file
@ -0,0 +1,16 @@
|
||||
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)
|
||||
}
|
||||
@ -0,0 +1,297 @@
|
||||
package com.gh.download.simple
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
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 = ArrayList(mDownloadDao.getAllDownloadEntity())
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
19
app/src/main/java/com/gh/download/simple/FixedSizeStack.kt
Normal file
19
app/src/main/java/com/gh/download/simple/FixedSizeStack.kt
Normal file
@ -0,0 +1,19 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
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
|
||||
@ -0,0 +1,95 @@
|
||||
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
|
||||
}
|
||||
@ -0,0 +1,81 @@
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
@ -6,15 +6,14 @@ 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.base.activity.BaseActivity
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.gamedetail.GameDetailFragment
|
||||
import com.halo.assistant.HaloApp
|
||||
@ -166,6 +165,33 @@ 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
|
||||
@ -173,6 +199,8 @@ class GameDetailActivity : DownloadToolbarActivity() {
|
||||
* @param scrollToLibao 滚动到礼包区域
|
||||
* @param openVideoStreaming 是否打开视频流
|
||||
* @param openPlatformWindow 打开多版本下载弹窗
|
||||
* @param platformName 平台名称
|
||||
* @param packageName 包名
|
||||
* @param traceEvent 曝光事件
|
||||
*/
|
||||
@JvmStatic
|
||||
@ -185,6 +213,8 @@ class GameDetailActivity : DownloadToolbarActivity() {
|
||||
scrollToLibao: Boolean = false,
|
||||
openVideoStreaming: Boolean = false,
|
||||
openPlatformWindow: Boolean = false,
|
||||
platformName: String? = null,
|
||||
packageName: String? = null,
|
||||
traceEvent: ExposureEvent? = null
|
||||
) {
|
||||
val bundle = Bundle()
|
||||
@ -224,6 +254,12 @@ 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)
|
||||
|
||||
@ -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.common.constant.Constants.LOGIN_TAG;
|
||||
import static com.gh.gamecenter.login.utils.LoginHelper.WEIBO_SCOPE;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
@ -26,6 +26,7 @@ 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;
|
||||
@ -39,9 +40,15 @@ 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;
|
||||
@ -58,8 +65,7 @@ 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.gamecenter.common.eventbus.EBReuse;
|
||||
import com.gh.gamecenter.common.utils.NotificationHelper;
|
||||
import com.gh.common.util.NewFlatLogUtils;
|
||||
import com.gh.common.util.PackageInstaller;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.PlatformUtils;
|
||||
@ -72,12 +78,17 @@ 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;
|
||||
@ -86,21 +97,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;
|
||||
@ -136,6 +147,7 @@ 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;
|
||||
@ -159,6 +171,9 @@ 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";
|
||||
|
||||
@ -180,6 +195,7 @@ 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);
|
||||
@ -292,7 +308,7 @@ public class MainActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
if (showAd) {
|
||||
observeAd();
|
||||
observeStartUp();
|
||||
} else {
|
||||
checkDialog();
|
||||
}
|
||||
@ -474,38 +490,95 @@ public class MainActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
AppExecutor.getUiExecutor().executeWithDelay(() -> hideAd(false), 950);
|
||||
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 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 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;
|
||||
}
|
||||
|
||||
checkDialog();
|
||||
SPUtils.setString(Constants.SP_STARTUP_AD_TIMESTAMP, startUpAd.getId() + TimeUtils.getToday());
|
||||
} else {
|
||||
hideStartUpAd();
|
||||
}
|
||||
}
|
||||
|
||||
@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 hideStartUp() {
|
||||
View maskContainer = findViewById(R.id.maskContainer);
|
||||
if (maskContainer != null) {
|
||||
maskContainer.setVisibility(View.GONE);
|
||||
ExtensionsKt.removeFromParent(maskContainer);
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
@ -517,9 +590,53 @@ public class MainActivity extends BaseActivity {
|
||||
});
|
||||
}
|
||||
|
||||
private void showAd(StartupAdEntity ad) {
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
@ -529,12 +646,12 @@ public class MainActivity extends BaseActivity {
|
||||
adContentTv.setText(ad.getDesc());
|
||||
adContentTv.setVisibility(View.VISIBLE);
|
||||
if (ad.getButton()) {
|
||||
View btn = findViewById(R.id.adBtn);
|
||||
btn.setOnClickListener((v) -> {
|
||||
View adBtn = findViewById(R.id.adBtn);
|
||||
adBtn.setOnClickListener(v -> {
|
||||
DirectUtils.directToLinkPage(this, ad.getJump(), "(启动广告)", "");
|
||||
LogUtils.logStartAd("click_watch_start_ads", ad);
|
||||
});
|
||||
btn.setVisibility(View.VISIBLE);
|
||||
adBtn.setVisibility(View.VISIBLE);
|
||||
LogUtils.logStartAd("watch_start_ads", ad);
|
||||
} else {
|
||||
LogUtils.logStartAd("start_ads", ad);
|
||||
|
||||
@ -40,7 +40,6 @@ import com.gh.download.DownloadManager;
|
||||
import com.gh.gamecenter.adapter.viewholder.DetailViewHolder;
|
||||
import com.gh.gamecenter.common.callback.OnRequestCallBackListener;
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts;
|
||||
import com.gh.gamecenter.common.eventbus.EBReuse;
|
||||
import com.gh.gamecenter.common.retrofit.Response;
|
||||
import com.gh.gamecenter.common.utils.ExtensionsKt;
|
||||
import com.gh.gamecenter.common.utils.ShareUtils;
|
||||
@ -57,9 +56,10 @@ import com.gh.gamecenter.eventbus.EBConcernChanged;
|
||||
import com.gh.gamecenter.eventbus.EBDownloadStatus;
|
||||
import com.gh.gamecenter.eventbus.EBNetworkState;
|
||||
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.compose.activity.ComposeSettingActivity;
|
||||
import com.gh.gamecenter.setting.view.SettingsFragment;
|
||||
import com.lightgame.download.DataWatcher;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
import com.lightgame.utils.Utils;
|
||||
@ -319,7 +319,7 @@ public class NewsDetailActivity extends DownloadToolbarActivity implements OnCli
|
||||
}
|
||||
|
||||
sp = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
fontsize = sp.getInt(ComposeSettingActivity.FONT_SIZE_SP_KEY, 1);
|
||||
fontsize = sp.getInt(SettingsFragment.FONT_SIZE_SP_KEY, 1);
|
||||
if (fontsize == 0) {
|
||||
fontsize = 1;
|
||||
}
|
||||
@ -556,14 +556,14 @@ public class NewsDetailActivity extends DownloadToolbarActivity implements OnCli
|
||||
if ((R11 - R12) > scrollSize && fontsize > 1) {
|
||||
fontsize--;
|
||||
adapter.setFontSize(fontsize);
|
||||
sp.edit().putInt(ComposeSettingActivity.FONT_SIZE_SP_KEY, fontsize).apply();
|
||||
sp.edit().putInt(SettingsFragment.FONT_SIZE_SP_KEY, fontsize).apply();
|
||||
String fontSizeText = getFontSize(fontsize);
|
||||
Utils.toast(this, fontSizeText);
|
||||
}
|
||||
if ((R11 - R12) < -scrollSize && fontsize < 4) {
|
||||
fontsize++;
|
||||
adapter.setFontSize(fontsize);
|
||||
sp.edit().putInt(ComposeSettingActivity.FONT_SIZE_SP_KEY, fontsize).apply();
|
||||
sp.edit().putInt(SettingsFragment.FONT_SIZE_SP_KEY, fontsize).apply();
|
||||
String fontSizeText = getFontSize(fontsize);
|
||||
Utils.toast(this, fontSizeText);
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@ public class SkipActivity extends BaseActivity {
|
||||
if (!TextUtils.isEmpty(qaId)) {
|
||||
DirectUtils.directToQa(this, qaTitle, qaId);
|
||||
} else if ("vgame".equals(suggestionType)) {
|
||||
DirectUtils.directToFeedback(this, content, "game", isQaFeedback, qaContentId, EntranceConsts.ENTRANCE_BROWSER);
|
||||
DirectUtils.directToFeedbackCompat(this, content, "game", isQaFeedback, qaContentId, EntranceConsts.ENTRANCE_BROWSER);
|
||||
} else {
|
||||
DirectUtils.directToFeedback(this, content, null, isQaFeedback, qaContentId, EntranceConsts.ENTRANCE_BROWSER);
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.gh.gamecenter
|
||||
|
||||
import android.Manifest
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
@ -25,6 +26,7 @@ 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
|
||||
@ -60,6 +62,8 @@ 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
|
||||
)
|
||||
|
||||
@ -150,42 +154,41 @@ 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)
|
||||
// guideLayout.visibility = View.VISIBLE
|
||||
// SPUtils.setBoolean(Constants.SP_BRAND_NEW_USER, false)
|
||||
//
|
||||
// // 恢复畅玩数据
|
||||
// VHelper.recoverVDataIfPossible()
|
||||
//
|
||||
// requestPermission()
|
||||
//
|
||||
// // 检查是否有旧版本光环,有就删掉
|
||||
// AppExecutor.ioExecutor.execute { deleteOutdatedUpdatePackage() }
|
||||
// if (mStartMainActivityDirectly) {
|
||||
// launchMainActivity()
|
||||
// }
|
||||
|
||||
// 恢复畅玩数据
|
||||
VHelper.recoverVDataIfPossible()
|
||||
mShouldPrefetchData = false
|
||||
prefetchData()
|
||||
|
||||
requestPermission()
|
||||
|
||||
// 检查是否有旧版本光环,有就删掉
|
||||
AppExecutor.ioExecutor.execute { deleteOutdatedUpdatePackage() }
|
||||
if (mStartMainActivityDirectly) {
|
||||
launchMainActivity()
|
||||
} else {
|
||||
mShouldPrefetchData = false
|
||||
prefetchData()
|
||||
val callback = object : SimpleCallback<Boolean> {
|
||||
override fun onCallback(arg: Boolean) {
|
||||
// Dialog dismiss 后的回调
|
||||
guideLayout.visibility = View.VISIBLE
|
||||
SPUtils.setBoolean(Constants.SP_BRAND_NEW_USER, false)
|
||||
if (arg) {
|
||||
requestPermission()
|
||||
} else {
|
||||
mStartMainActivityDirectly = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
// })
|
||||
|
||||
mViewModel?.showPrivacyPolicy({
|
||||
DialogUtils.showPrivacyPolicyDialog(this@SplashScreenActivity, it, callback)
|
||||
}, {
|
||||
DialogUtils.showPrivacyPolicyDialog(this@SplashScreenActivity, PrivacyPolicyEntity.createDefaultData(), callback)
|
||||
})
|
||||
} else {
|
||||
DialogUtils.showPrivacyPolicyDisallowDialog(
|
||||
this,
|
||||
@ -255,7 +258,6 @@ class SplashScreenActivity : BaseActivity() {
|
||||
SPUtils.setLong(Constants.SP_GH_LAST_UPDATE_TIME, PackageUtils.getHaloLastUpdateTime())
|
||||
HaloApp.getInstance().postInit(true)
|
||||
TrackerLogger.logAppLaunchSuccessful()
|
||||
AdHelper.getStartUpAd()
|
||||
if (mShouldPrefetchData) {
|
||||
prefetchData()
|
||||
}
|
||||
@ -385,10 +387,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()
|
||||
@ -477,7 +479,7 @@ class SplashScreenActivity : BaseActivity() {
|
||||
intent.action = Intent.ACTION_MAIN
|
||||
intent.addCategory(Intent.CATEGORY_LAUNCHER)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
intent.putExtras(bundle!!)
|
||||
intent.putExtras(bundle ?: Bundle())
|
||||
return intent
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,18 +5,22 @@ import android.content.Context;
|
||||
import android.text.Html;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextPaint;
|
||||
import android.text.TextUtils;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.ClickableSpan;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.text.HtmlCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.RecyclerView.ViewHolder;
|
||||
|
||||
import com.gh.common.util.DirectUtils;
|
||||
import com.gh.common.view.DownloadButton;
|
||||
import com.gh.gamecenter.common.callback.OnRequestCallBackListener;
|
||||
import com.gh.gamecenter.common.utils.ExtensionsKt;
|
||||
@ -42,6 +46,7 @@ import com.gh.gamecenter.entity.LibaoStatusEntity;
|
||||
import com.gh.gamecenter.entity.MeEntity;
|
||||
import com.gh.gamecenter.entity.UserDataLibaoEntity;
|
||||
import com.gh.gamecenter.common.retrofit.Response;
|
||||
import com.gh.gamecenter.game.GameItemViewHolder;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
import com.gh.gamecenter.suggest.SuggestType;
|
||||
import com.lightgame.adapter.BaseRecyclerAdapter;
|
||||
@ -196,6 +201,8 @@ public class LibaoDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
ExtensionsKt.setRootBackgroundColor(holder.binding.getRoot(), R.color.background_white);
|
||||
if (mLibaoEntity.getGame() != null) {
|
||||
holder.binding.libaodetailGameIcon.displayGameIcon(mLibaoEntity.getGame().getIcon(), mLibaoEntity.getGame().getIconSubscript());
|
||||
GameEntity gameEntity = mLibaoEntity.getGame().toGameEntity();
|
||||
GameItemViewHolder.initGameSubtitle(gameEntity, holder.binding.gameSubtitleTv, null, null, false);
|
||||
} else {
|
||||
holder.binding.libaodetailGameIcon.displayGameIcon(mLibaoEntity.getIcon(), null);
|
||||
}
|
||||
@ -321,6 +328,32 @@ public class LibaoDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
}
|
||||
holder.binding.libaodetailCondition.setVisibility(View.VISIBLE);
|
||||
holder.binding.libaodetailCondition.setText(content);
|
||||
} else if (ExtensionsKt.toResString(R.string.libao_activity_grant).equals(mLibaoEntity.getReceiveLimit())) {
|
||||
holder.binding.libaodetailCondition.setVisibility(View.VISIBLE);
|
||||
String url = mLibaoEntity.getActivityLink().getUrl();
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
holder.binding.libaodetailCondition.setText("领取条件:通过活动获得");
|
||||
} else {
|
||||
SpannableStringBuilder content = new SpannableStringBuilder("领取条件:通过活动获得,查看详情");
|
||||
content.setSpan(new ClickableSpan() {
|
||||
|
||||
@Override
|
||||
public void updateDrawState(@NonNull TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
ds.setColor(ExtensionsKt.toColor(R.color.theme_font, mContext));
|
||||
ds.setUnderlineText(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
DirectUtils.directToWebView(mContext, url, "礼包详情-领取条件-查看活动详情");
|
||||
}
|
||||
}, 12, content.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
holder.binding.libaodetailCondition.setText(content);
|
||||
holder.binding.libaodetailCondition.setMovementMethod(new LinkMovementMethod());
|
||||
ExtensionsKt.setDrawableEnd(holder.binding.libaodetailCondition, com.gh.gamecenter.common.R.drawable.ic_libao_activity_arrow, null, null);
|
||||
holder.binding.libaodetailCondition.setCompoundDrawablePadding(DisplayUtils.dip2px(4F));
|
||||
}
|
||||
}
|
||||
if (mLibaoDetailEntity.getTime() != null) {
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm", Locale.CHINA);
|
||||
|
||||
@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
@ -11,6 +12,7 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.airbnb.lottie.LottieAnimationView;
|
||||
import com.gh.common.chain.BrowserInstallHandler;
|
||||
import com.gh.common.chain.CertificationHandler;
|
||||
import com.gh.common.chain.ChainBuilder;
|
||||
@ -36,6 +38,8 @@ import com.gh.common.simulator.SimulatorDownloadManager;
|
||||
import com.gh.common.simulator.SimulatorGameManager;
|
||||
import com.gh.common.util.CheckLoginUtils;
|
||||
import com.gh.common.util.DirectUtils;
|
||||
import com.gh.common.xapk.XapkInstaller;
|
||||
import com.gh.common.xapk.XapkUnzipStatus;
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts;
|
||||
import com.gh.gamecenter.common.utils.DataLogUtils;
|
||||
import com.gh.common.util.DetailDownloadUtils;
|
||||
@ -65,6 +69,7 @@ import com.gh.gamecenter.entity.SimulatorEntity;
|
||||
import com.gh.gamecenter.eventbus.EBScroll;
|
||||
import com.gh.gamecenter.gamedetail.GameDetailFragment;
|
||||
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;
|
||||
@ -96,14 +101,18 @@ public class DetailViewHolder {
|
||||
public View downloadBottom;
|
||||
|
||||
public DownloadButton mDownloadPb;
|
||||
public LottieAnimationView mDownloadTips;
|
||||
public TextView mOverlayTv; // 额外的文字 (用于一些含图片的情况)
|
||||
public TextView mMultiVersionDownloadTv; // 多版本下载文字
|
||||
|
||||
// 注意View的命名
|
||||
public DetailViewHolder(View view, GameEntity gameEntity, DownloadEntity downloadEntity,
|
||||
boolean isNewsDetail, String entrance, String name, String title, @Nullable ExposureEvent traceEvent) {
|
||||
downloadBottom = view.findViewById(R.id.detail_ll_bottom);
|
||||
mDownloadPb = view.findViewById(R.id.detail_progressbar);
|
||||
mDownloadTips = view.findViewById(R.id.downloadTipsLottie);
|
||||
mOverlayTv = view.findViewById(R.id.overlayTv);
|
||||
mMultiVersionDownloadTv = view.findViewById(R.id.multiVersionDownloadTv);
|
||||
|
||||
this.gameEntity = gameEntity;
|
||||
this.downloadEntity = downloadEntity;
|
||||
@ -193,6 +202,43 @@ public class DetailViewHolder {
|
||||
}
|
||||
|
||||
v.setTag(null);
|
||||
|
||||
if (mViewHolder.mDownloadPb.getButtonStyle() != DownloadButton.ButtonStyle.INSTALL_NORMAL
|
||||
&& mViewHolder.mDownloadPb.getButtonStyle() != DownloadButton.ButtonStyle.INSTALL_PLUGIN
|
||||
&& mViewHolder.mDownloadPb.getButtonStyle() != DownloadButton.ButtonStyle.LAUNCH_OR_OPEN) {
|
||||
|
||||
if (mGameEntity.isVGame() && !VHelper.INSTANCE.shouldLaunchGameAfterInstallation()) {
|
||||
// 畅玩游戏的非真实点击下载按钮下载不需要滚动到特定地方
|
||||
} else {
|
||||
EventBus.getDefault().post(new EBScroll(Constants.EB_GAME_DETAIL, mGameEntity.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
if (mDownloadEntity == null) {
|
||||
mDownloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(mGameEntity);
|
||||
}
|
||||
|
||||
if (mDownloadEntity != null) {
|
||||
String xapkStatus = mDownloadEntity.getMeta().get(XapkInstaller.XAPK_UNZIP_STATUS);
|
||||
if (XapkUnzipStatus.UNZIPPING.name().equals(xapkStatus)) {
|
||||
XapkInstaller.cancelUnzipTask(mDownloadEntity);
|
||||
return;
|
||||
} else if (XapkUnzipStatus.FAILURE.name().equals(xapkStatus)) {
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(mViewHolder.context, () -> {
|
||||
if (mDownloadEntity != null) {
|
||||
final String path = mDownloadEntity.getPath();
|
||||
if (FileUtils.isEmptyFile(path)) {
|
||||
Utils.toast(mViewHolder.context, R.string.install_failure_hint);
|
||||
DownloadManager.getInstance().cancel(mDownloadEntity.getUrl());
|
||||
} else {
|
||||
PackageInstaller.install(mViewHolder.context, mDownloadEntity);
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch (mViewHolder.mDownloadPb.getButtonStyle()) {
|
||||
case NONE_WITH_HINT:
|
||||
case NONE:
|
||||
@ -229,7 +275,6 @@ public class DetailViewHolder {
|
||||
builder.addHandler(new CheckStoragePermissionHandler());
|
||||
|
||||
if (mGameEntity.getApk().size() == 1) {
|
||||
ApkEntity apk = mGameEntity.getApk().get(0);
|
||||
builder.addHandler(new BrowserInstallHandler());
|
||||
builder.addHandler(new PackageCheckHandler());
|
||||
builder.addHandler(new DownloadDialogHelperHandler());
|
||||
@ -239,7 +284,7 @@ public class DetailViewHolder {
|
||||
builder.addHandler(new CheckDownloadHandler());
|
||||
|
||||
builder.setProcessEndCallback(o -> {
|
||||
DialogUtils.checkDownload(mViewHolder.context, apk.getSize(), this::download);
|
||||
download((boolean) o);
|
||||
return null;
|
||||
});
|
||||
final ChainHandler chainHandler = builder.buildHandlerChain();
|
||||
@ -269,7 +314,7 @@ public class DetailViewHolder {
|
||||
if (mGameEntity.getApk().size() == 1) {
|
||||
//启动模拟器游戏
|
||||
if (SimulatorGameManager.isSimulatorGame(mGameEntity)) {
|
||||
if (NewSimulatorGameManager.shouldShowUpdateNewSimulatorAlert(mViewHolder.context)){
|
||||
if (NewSimulatorGameManager.shouldShowUpdateNewSimulatorAlert(mViewHolder.context)) {
|
||||
NewSimulatorGameManager.showUpdateNewsSimulator(mViewHolder.context, null);
|
||||
return;
|
||||
}
|
||||
@ -315,9 +360,10 @@ public class DetailViewHolder {
|
||||
boolean isInstalledNewSimulator = SimulatorGameManager.isNewSimulatorInstalled(mViewHolder.context);
|
||||
boolean isInstalledOldSimulator = SimulatorGameManager.isOldSimulatorInstalled(mViewHolder.context);
|
||||
SimulatorEntity simulator = mGameEntity.getSimulator();
|
||||
if (!isInstalledOldSimulator){
|
||||
if (Config.getNewSimulatorEntitySetting() != null){
|
||||
simulator = Config.getNewSimulatorEntitySetting();
|
||||
SimulatorEntity newSimulator = Config.getNewSimulatorEntitySetting();
|
||||
if (!isInstalledOldSimulator && newSimulator != null) {
|
||||
if (newSimulator.getActive()) {
|
||||
simulator = newSimulator;
|
||||
}
|
||||
}
|
||||
|
||||
@ -335,7 +381,7 @@ public class DetailViewHolder {
|
||||
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(mViewHolder.context, () -> {
|
||||
if (mDownloadEntity == null) {
|
||||
mDownloadEntity = DownloadManager.getInstance().getDownloadEntityByUrl(mGameEntity.getApk().get(0).getUrl());
|
||||
mDownloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(mGameEntity);
|
||||
}
|
||||
|
||||
if (mDownloadEntity != null) {
|
||||
@ -411,6 +457,24 @@ public class DetailViewHolder {
|
||||
DirectUtils.directForumDetail(mViewHolder.context, info.getBbsId(), mEntrance);
|
||||
}
|
||||
break;
|
||||
case WAITING:
|
||||
Utils.toast(mViewHolder.context, "最多只能同时下载三个任务,请稍等");
|
||||
break;
|
||||
case DOWNLOADING_NORMAL:
|
||||
case DOWNLOADING_PLUGIN:
|
||||
if (mDownloadEntity == null) {
|
||||
mDownloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(mGameEntity);
|
||||
}
|
||||
|
||||
if (mDownloadEntity != null) {
|
||||
if (downloadText.contains("继续加载")) {
|
||||
DownloadManager.getInstance().resume(mDownloadEntity, true);
|
||||
} else {
|
||||
DownloadManager.getInstance().pause(mDownloadEntity.getUrl());
|
||||
mViewHolder.mDownloadPb.setText("继续加载 " + mDownloadEntity.getPercent() + "%");
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (mGameEntity.isVGame()) {
|
||||
mViewHolder.context.startActivity(VDownloadManagerActivity.getIntent(mViewHolder.context, true));
|
||||
@ -422,12 +486,6 @@ public class DetailViewHolder {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (mViewHolder.mDownloadPb.getButtonStyle() != DownloadButton.ButtonStyle.INSTALL_NORMAL
|
||||
&& mViewHolder.mDownloadPb.getButtonStyle() != DownloadButton.ButtonStyle.INSTALL_PLUGIN
|
||||
&& mViewHolder.mDownloadPb.getButtonStyle() != DownloadButton.ButtonStyle.LAUNCH_OR_OPEN) {
|
||||
EventBus.getDefault().post(new EBScroll(Constants.EB_GAME_DETAIL, mGameEntity.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
private void showOffServiceDialog(GameEntity.Dialog dialog) {
|
||||
@ -472,7 +530,7 @@ public class DetailViewHolder {
|
||||
DownloadButton.ButtonStyle.DOWNLOADING_PLUGIN : DownloadButton.ButtonStyle.DOWNLOADING_NORMAL);
|
||||
DeviceRemindDialog.Companion.showDeviceRemindDialog(mViewHolder.context, mGameEntity);
|
||||
|
||||
if (mGameEntity.isVGame() && mViewHolder.context.getString(R.string.download).equals(method)) {
|
||||
if (mGameEntity.isVGame() && mViewHolder.context.getString(R.string.download).equals(method) && VHelper.INSTANCE.shouldLaunchGameAfterInstallation()) {
|
||||
mViewHolder.context.startActivity(VSpaceLoadingActivity.getIntent(mViewHolder.context, mGameEntity, false));
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -15,10 +15,6 @@ public class GameTestViewHolder extends GameViewHolder {
|
||||
gameDownloadBtn = binding.home2DownloadBtn;
|
||||
gameDes = binding.home2GameDes;
|
||||
gameLabelList = binding.home2LabelList;
|
||||
gameInfo = binding.home2GameLlInfo;
|
||||
gameProgressbar = binding.home2GameProgressbar;
|
||||
gameDownloadSpeed = binding.home2DownloadSpeed;
|
||||
gameDownloadPercentage = binding.home2DownloadPercentage;
|
||||
gameServerType = binding.home2GameServerType;
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.gh.gamecenter.adapter.viewholder;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
@ -8,10 +9,13 @@ import android.widget.TextView;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.airbnb.lottie.LottieAnimationView;
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.gh.common.view.DownloadButton;
|
||||
import com.gh.gamecenter.common.view.DrawableView;
|
||||
import com.gh.common.view.GameIconView;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.common.utils.ExtensionsKt;
|
||||
import com.gh.gamecenter.common.view.DrawableView;
|
||||
import com.gh.gamecenter.databinding.GameItemBinding;
|
||||
import com.gh.gamecenter.entity.ColorEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
@ -23,15 +27,13 @@ public class GameViewHolder extends RecyclerView.ViewHolder {
|
||||
public DownloadButton gameDownloadBtn;
|
||||
public TextView gameDes;
|
||||
public LinearLayout gameLabelList;
|
||||
public View gameInfo;
|
||||
public ProgressBar gameProgressbar;
|
||||
@Nullable
|
||||
public View recommendContainer;
|
||||
public TextView recommendTv;
|
||||
public SimpleDraweeView recommendIv;
|
||||
public TextView gameDownloadSpeed;
|
||||
public TextView gameDownloadPercentage;
|
||||
public TextView gameServerType;
|
||||
public LottieAnimationView gameDownloadTips;
|
||||
public TextView multiVersionDownloadTv;
|
||||
|
||||
@Nullable
|
||||
public TextView gameRating;
|
||||
@ -46,11 +48,9 @@ public class GameViewHolder extends RecyclerView.ViewHolder {
|
||||
public GameViewHolder(GameItemBinding binding) {
|
||||
super(binding.getRoot());
|
||||
gameDownloadBtn = binding.downloadBtn;
|
||||
gameProgressbar = binding.gameProgressbar;
|
||||
gameInfo = binding.gameInfo;
|
||||
gameDownloadPercentage = binding.downloadPercentage;
|
||||
gameDes = binding.gameDes;
|
||||
gameDownloadSpeed = binding.downloadSpeed;
|
||||
gameDownloadTips = binding.downloadTipsLottie;
|
||||
multiVersionDownloadTv = binding.multiVersionDownloadTv;
|
||||
gameRating = binding.gameRating;
|
||||
recommendContainer = binding.recommendContainer;
|
||||
recommendTv = binding.recommendTv;
|
||||
@ -65,7 +65,13 @@ public class GameViewHolder extends RecyclerView.ViewHolder {
|
||||
} else if (serverLabel != null) {
|
||||
gameServerType.setVisibility(View.VISIBLE);
|
||||
gameServerType.setText(serverLabel.getValue());
|
||||
gameServerType.setBackground(DrawableView.getServerDrawable(serverLabel.getColor()));
|
||||
if (gameEntity.isUseDefaultServerStyle()) {
|
||||
gameServerType.setBackground(ExtensionsKt.toDrawable(R.drawable.server_label_default_bg));
|
||||
gameServerType.setTextColor(ExtensionsKt.toColor(R.color.text_server_label));
|
||||
} else {
|
||||
gameServerType.setBackground(DrawableView.getServerDrawable(serverLabel.getColor()));
|
||||
gameServerType.setTextColor(ExtensionsKt.toColor(R.color.white));
|
||||
}
|
||||
} else {
|
||||
gameServerType.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@ -0,0 +1,44 @@
|
||||
package com.gh.gamecenter.aidl
|
||||
|
||||
import android.app.Service
|
||||
import android.content.Intent
|
||||
import android.os.IBinder
|
||||
import com.gh.vspace.VArchiveHelper
|
||||
import com.gh.vspace.VHelper
|
||||
import com.lg.vclient.interfaces.ICommunicationManager
|
||||
import com.lg.vspace.remote.model.VGameInstallerResult
|
||||
import com.lightgame.utils.Utils
|
||||
|
||||
class CommunicationService : Service() {
|
||||
|
||||
private var mBinder: ICommunicationManager.Stub = object : ICommunicationManager.Stub() {
|
||||
override fun archiveUnzipCompleted(packageName: String, isSuccess: Boolean) {
|
||||
Utils.log(VHelper.LOG_TAG, "包名 $packageName 应用存档的结果是 $isSuccess")
|
||||
|
||||
VArchiveHelper.onApplyGameArchiveFinished(packageName, isSuccess)
|
||||
}
|
||||
|
||||
override fun archiveinPackageCompleted(packageName: String, isSuccess: Boolean) {
|
||||
Utils.log(VHelper.LOG_TAG, "包名 $packageName 保存存档的结果是 $isSuccess")
|
||||
|
||||
VArchiveHelper.onSaveGameArchiveFinished(packageName, isSuccess)
|
||||
}
|
||||
|
||||
override fun installGameCompleted(packageName: String, params: VGameInstallerResult) {
|
||||
Utils.log(VHelper.LOG_TAG, "包名 $packageName 安装的结果是 ${params.status}")
|
||||
|
||||
VHelper.onInstallFinished(packageName, params)
|
||||
}
|
||||
|
||||
override fun connectionCompleted() {
|
||||
Utils.log(VHelper.LOG_TAG, "服务回调连接成功")
|
||||
|
||||
VHelper.onConnectionCompleted(shouldReconnect = true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBind(intent: Intent?): IBinder {
|
||||
return mBinder
|
||||
}
|
||||
|
||||
}
|
||||
@ -28,6 +28,7 @@ import com.gh.gamecenter.core.utils.NumberUtils
|
||||
import com.gh.gamecenter.databinding.AmwayCommentItemBinding
|
||||
import com.gh.gamecenter.eventbus.EBDownloadStatus
|
||||
import com.gh.gamecenter.game.GameAndPosition
|
||||
import com.gh.gamecenter.game.GameItemViewHolder
|
||||
import com.gh.gamecenter.game.vertical.GameVerticalAdapter
|
||||
import com.gh.gamecenter.gamedetail.rating.RatingFragment
|
||||
import com.gh.gamecenter.gamedetail.rating.RatingReplyActivity
|
||||
@ -206,6 +207,7 @@ class AmwayAdapter(
|
||||
) {
|
||||
val context = binding.root.context
|
||||
val amway = itemData.amwayCommentItem!!
|
||||
val gameEntity = amway.game.toGameEntity()
|
||||
|
||||
binding.gameContainer.background = R.drawable.selector_f8f8f8.toDrawable(context)
|
||||
binding.commentContainer.background = R.drawable.selector_f8f8f8.toDrawable(context)
|
||||
@ -237,7 +239,8 @@ class AmwayAdapter(
|
||||
)
|
||||
}
|
||||
|
||||
itemData.exposureEvent = ExposureEvent.createEvent(amway.game.toGameEntity(), basicExposureSource)
|
||||
itemData.exposureEvent = ExposureEvent.createEvent(gameEntity, basicExposureSource)
|
||||
GameItemViewHolder.initGameSubtitle(gameEntity, binding.gameSubtitleTv)
|
||||
|
||||
binding.gameContainer.setOnClickListener {
|
||||
GameDetailActivity.startGameDetailActivity(
|
||||
|
||||
@ -142,23 +142,20 @@ class AmwayViewModel(application: Application) : ListViewModel<AmwayCommentEntit
|
||||
|
||||
override fun mergeResultLiveData() {
|
||||
mResultLiveData.addSource(mListLiveData) { list ->
|
||||
val subjectListCopy = LinkedList(mAmwaySubjectList)
|
||||
|
||||
var subjectPosition = 0
|
||||
val itemDataList = arrayListOf<AmwayListItemData>()
|
||||
|
||||
for (i in list.indices) {
|
||||
// 在位置 3, 6, 9 穿插专题数据
|
||||
if (subjectListCopy.isNotEmpty()
|
||||
&& (i != 0 && i % 2 == 0)
|
||||
) {
|
||||
LegacyHomeSubjectTransformer.transform(
|
||||
itemDataList as ArrayList<LegacyHomeItemData>,
|
||||
subjectListCopy.poll(),
|
||||
subjectPosition++,
|
||||
{ AmwayListItemData() },
|
||||
{ addGamePositionAndPackage(itemDataList.size - 1, it) }
|
||||
)
|
||||
mAmwaySubjectList.forEach { subjectEntity ->
|
||||
if (subjectEntity.position != -1 && subjectEntity.position == i) {
|
||||
LegacyHomeSubjectTransformer.transform(
|
||||
itemDataList as ArrayList<LegacyHomeItemData>,
|
||||
subjectEntity,
|
||||
subjectPosition++,
|
||||
{ AmwayListItemData() },
|
||||
{ addGamePositionAndPackage(itemDataList.size - 1, it) }
|
||||
)
|
||||
}
|
||||
}
|
||||
itemDataList.add(AmwayListItemData(amwayCommentItem = list[i]).apply { blockPosition = i + 1 })
|
||||
}
|
||||
|
||||
@ -5,10 +5,7 @@ import android.view.View
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.utils.DialogHelper
|
||||
import com.gh.gamecenter.common.utils.observeNonNull
|
||||
import com.gh.gamecenter.common.utils.toColor
|
||||
import com.gh.gamecenter.common.utils.viewModelProviderFromParent
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.databinding.FragmentAmwaySearchDefaultBinding
|
||||
import com.gh.gamecenter.eventbus.EBSearch
|
||||
import com.gh.gamecenter.search.SearchDefaultFragment
|
||||
@ -68,13 +65,11 @@ class AmwaySearchDefaultFragment : SearchDefaultFragment() {
|
||||
headTitle.textSize = 16F
|
||||
headActionTv.text = "清空"
|
||||
headActionTv.setTextColor(R.color.text_subtitleDesc.toColor(requireContext()))
|
||||
headActionTv.setCompoundDrawablesWithIntrinsicBounds(
|
||||
VectorDrawableCompat.create(
|
||||
resources,
|
||||
R.drawable.search_history_delete,
|
||||
null
|
||||
), null, null, null
|
||||
)
|
||||
headActionTv.setDrawableStart(VectorDrawableCompat.create(
|
||||
resources,
|
||||
R.drawable.search_history_delete,
|
||||
null
|
||||
))
|
||||
headActionTv.setOnClickListener {
|
||||
DialogHelper.showCenterWarningDialog(requireContext(), "清空记录", "确定清空历史搜索记录?", confirmClickCallback = {
|
||||
mSearchDao.deleteAll()
|
||||
|
||||
@ -181,7 +181,7 @@ class NewCatalogListFragment : ListFragment<GameEntity, NewCatalogListViewModel>
|
||||
// 安装/卸载 事件
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onEventMainThread(busFour: EBPackage) {
|
||||
if ("安装" == busFour.type || "卸载" == busFour.type) {
|
||||
if (busFour.isInstalledOrUninstalled()) {
|
||||
mAdapter?.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ class NewCategoryListFragment : ListFragment<GameEntity, NewCategoryListViewMode
|
||||
// 安装/卸载 事件
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onEventMainThread(busFour: EBPackage) {
|
||||
if ("安装" == busFour.type || "卸载" == busFour.type) {
|
||||
if (busFour.isInstalledOrUninstalled()) {
|
||||
mAdapter?.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,28 +5,27 @@ import android.util.SparseArray
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.gamecenter.common.base.BaseRecyclerViewHolder
|
||||
import com.gh.gamecenter.common.constant.ItemViewType
|
||||
import com.gh.common.databind.BindingAdapters
|
||||
import com.gh.common.exposure.ExposureEvent
|
||||
import com.gh.common.exposure.ExposureSource
|
||||
import com.gh.common.exposure.ExposureType
|
||||
import com.gh.common.exposure.IExposable
|
||||
import com.gh.common.util.*
|
||||
import com.gh.gamecenter.common.view.DrawableView
|
||||
import com.gh.common.util.DownloadItemUtils
|
||||
import com.gh.gamecenter.GameDetailActivity
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.viewholder.FooterViewHolder
|
||||
import com.gh.gamecenter.adapter.viewholder.GameViewHolder
|
||||
import com.gh.gamecenter.common.base.BaseRecyclerViewHolder
|
||||
import com.gh.gamecenter.common.baselist.ListAdapter
|
||||
import com.gh.gamecenter.common.utils.dip2px
|
||||
import com.gh.gamecenter.common.utils.toBinding
|
||||
import com.gh.gamecenter.common.utils.toColor
|
||||
import com.gh.gamecenter.common.utils.toDrawable
|
||||
import com.gh.gamecenter.core.utils.*
|
||||
import com.gh.gamecenter.common.constant.ItemViewType
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.common.view.DrawableView
|
||||
import com.gh.gamecenter.common.viewholder.FooterViewHolder
|
||||
import com.gh.gamecenter.core.utils.PageSwitchDataHelper
|
||||
import com.gh.gamecenter.core.utils.StringUtils
|
||||
import com.gh.gamecenter.databinding.CategoryGameItemBinding
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.eventbus.EBDownloadStatus
|
||||
import com.gh.gamecenter.game.GameItemViewHolder
|
||||
import com.lightgame.download.DownloadEntity
|
||||
|
||||
class CategoryV2ListAdapter(
|
||||
@ -229,12 +228,7 @@ class CategoryV2ListAdapter(
|
||||
BindingAdapters.setGameName(gameName, gameEntity, false, null)
|
||||
BindingAdapters.setTextSize(gameRating, if (gameEntity.commentCount > 3) 12 else 10)
|
||||
BindingAdapters.setGameTags(labelList, gameEntity)
|
||||
gameRating.setCompoundDrawablesWithIntrinsicBounds(
|
||||
if (gameEntity.commentCount > 3) R.drawable.game_horizontal_rating.toDrawable() else null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
)
|
||||
gameRating.setDrawableStart(if (gameEntity.commentCount > 3) R.drawable.game_horizontal_rating.toDrawable() else null)
|
||||
gameRating.text = if (gameEntity.commentCount > 3) {
|
||||
if (gameEntity.star == 10.0F) "10" else gameEntity.star.toString()
|
||||
} else ""
|
||||
@ -245,6 +239,8 @@ class CategoryV2ListAdapter(
|
||||
)
|
||||
)
|
||||
gameDes.text = gameEntity.decoratedDes
|
||||
|
||||
GameItemViewHolder.initGameSubtitle(gameEntity, gameSubtitleTv, gameDesSpace, root)
|
||||
}
|
||||
}
|
||||
|
||||
@ -258,7 +254,14 @@ class CategoryV2ListAdapter(
|
||||
serverLabel != null -> {
|
||||
binding.gameKaifuType.visibility = View.VISIBLE
|
||||
binding.gameKaifuType.text = serverLabel.value
|
||||
binding.gameKaifuType.background = DrawableView.getServerDrawable(serverLabel.color)
|
||||
if (gameEntity.isUseDefaultServerStyle()) {
|
||||
binding.gameKaifuType.background =
|
||||
R.drawable.server_label_default_bg.toDrawable(binding.root.context)
|
||||
binding.gameKaifuType.setTextColor(R.color.text_server_label.toColor(binding.root.context))
|
||||
} else {
|
||||
binding.gameKaifuType.background = DrawableView.getServerDrawable(serverLabel.color)
|
||||
binding.gameKaifuType.setTextColor(R.color.white.toColor(binding.root.context))
|
||||
}
|
||||
}
|
||||
else -> binding.gameKaifuType.visibility = View.GONE
|
||||
}
|
||||
@ -271,11 +274,7 @@ class CategoryV2ListAdapter(
|
||||
inner class CategoryGameViewHolder(val binding: CategoryGameItemBinding) : GameViewHolder(binding.root) {
|
||||
init {
|
||||
gameDownloadBtn = binding.downloadBtn
|
||||
gameProgressbar = binding.gameProgressbar
|
||||
gameInfo = binding.gameInfo
|
||||
gameDownloadPercentage = binding.downloadPercentage
|
||||
gameDes = binding.gameDes
|
||||
gameDownloadSpeed = binding.downloadSpeed
|
||||
gameRating = binding.gameRating
|
||||
recommendContainer = binding.recommendContainer
|
||||
recommendTv = binding.recommendTv
|
||||
|
||||
@ -310,7 +310,7 @@ class CategoryV2ListFragment : ListFragment<GameEntity, CategoryV2ListViewModel>
|
||||
// 安装/卸载 事件
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onEventMainThread(busFour: EBPackage) {
|
||||
if ("安装" == busFour.type || "卸载" == busFour.type) {
|
||||
if (busFour.isInstalledOrUninstalled()) {
|
||||
mAdapter?.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,367 @@
|
||||
package com.gh.gamecenter.cloudarchive
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.os.Bundle
|
||||
import android.view.MenuItem
|
||||
import android.view.Window
|
||||
import androidx.core.widget.doOnTextChanged
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.gh.common.util.CheckLoginUtils
|
||||
import com.gh.common.util.DirectUtils
|
||||
import com.gh.common.util.DownloadItemUtils
|
||||
import com.gh.common.util.NewFlatLogUtils
|
||||
import com.gh.common.view.DownloadButton
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.activity.BaseActivity_TabLayout
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.eventbus.EBReuse
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.utils.CurrentActivityHolder
|
||||
import com.gh.gamecenter.core.utils.MD5Utils
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.databinding.ActivityCloudArchiveManagerBinding
|
||||
import com.gh.gamecenter.databinding.DialogUploadArchiveBinding
|
||||
import com.gh.gamecenter.entity.ArchiveEntity
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.manager.PackagesManager
|
||||
import com.gh.vspace.VArchiveHelper
|
||||
import com.gh.vspace.VHelper
|
||||
import com.lightgame.download.DataWatcher
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import com.lightgame.download.DownloadStatus
|
||||
import com.lightgame.utils.Utils
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
import java.io.File
|
||||
|
||||
class CloudArchiveManagerActivity : BaseActivity_TabLayout() {
|
||||
|
||||
private lateinit var mBinding: ActivityCloudArchiveManagerBinding
|
||||
private var mGameEntity: GameEntity? = null
|
||||
private var mArchiveConfigUrl = ""
|
||||
private var mArchiveFragment: MyArchiveFragment? = null
|
||||
private var mDownloadArchiveFragment: MyDownloadArchiveFragment? = null
|
||||
private var mShareArchiveFragment: MyShareArchiveFragment? = null
|
||||
private val mViewModel: CloudArchiveManagerViewModel by lazy {
|
||||
viewModelProvider(
|
||||
CloudArchiveManagerViewModel.Factory(
|
||||
gameId = mGameEntity?.id ?: "",
|
||||
configUrl = mArchiveConfigUrl
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private val dataWatcher = object : DataWatcher() {
|
||||
override fun onDataChanged(downloadEntity: DownloadEntity) {
|
||||
if (downloadEntity.gameId == mViewModel.gameId) {
|
||||
if (mGameEntity?.getApk()?.size == 1) {
|
||||
updateDownloadBtn(downloadEntity, mBinding.downloadBtn, mGameEntity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDataInit(downloadEntity: DownloadEntity) {
|
||||
onDataChanged(downloadEntity)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
mGameEntity = intent.getParcelableExtra<GameEntity?>(EntranceConsts.KEY_GAME)?.apply {
|
||||
setEntryMap(DownloadManager.getInstance().getEntryMap(name))
|
||||
}
|
||||
mArchiveConfigUrl = intent.getStringExtra(EntranceConsts.KEY_ARCHIVE_CONFIG_URL) ?: ""
|
||||
mBinding = ActivityCloudArchiveManagerBinding.bind(mContentView)
|
||||
setNavigationTitle("云存档")
|
||||
setToolbarMenu(R.menu.menu_cloud_archive_manager)
|
||||
updateStatusBarColor(R.color.background_white, R.color.background_white)
|
||||
NewFlatLogUtils.logCloudArchiveManagePageShow(mGameEntity?.id ?: "", mGameEntity?.name ?: "", mEntrance)
|
||||
|
||||
mBinding.run {
|
||||
mGameEntity?.let {
|
||||
gameIconView.displayGameIcon(it)
|
||||
gameNameTv.text = it.name
|
||||
}
|
||||
controlUploadGameArchive()
|
||||
uploadTv.setOnClickListener {
|
||||
when {
|
||||
// 检查是否已安装游戏、本地是否存在存档数据
|
||||
!VHelper.isInstalled(mGameEntity?.getUniquePackageName()) || !VHelper.checkArchiveExist(
|
||||
mGameEntity?.getUniquePackageName() ?: "", mViewModel.archiveConfigStr
|
||||
) -> toast("暂未检测到本地的存档数据,请玩会儿游戏再试~")
|
||||
else -> {
|
||||
NewFlatLogUtils.logCloudArchiveUploadDialogShow()
|
||||
showUploadDialog()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mViewModel.uploadSuccess.observeNonNull(this) {
|
||||
if (it) {
|
||||
mArchiveFragment?.onLoadRefresh()
|
||||
toast("上传成功")
|
||||
} else {
|
||||
toast("上传失败")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onMenuItemClick(item: MenuItem?): Boolean {
|
||||
if (item?.itemId == R.id.menu_help) {
|
||||
if (EnvHelper.isDevEnv) {
|
||||
DirectUtils.directToArticle(this, DEV_HELP_ARTICLE_ID, "云存档管理")
|
||||
} else {
|
||||
DirectUtils.directToArticle(this, HELP_ARTICLE_ID, "云存档管理")
|
||||
}
|
||||
return true
|
||||
}
|
||||
return super.onMenuItemClick(item)
|
||||
}
|
||||
|
||||
override fun getLayoutId(): Int = R.layout.activity_cloud_archive_manager
|
||||
|
||||
override fun initFragmentList(fragments: MutableList<Fragment>) {
|
||||
fragments.add(MyArchiveFragment().apply { mArchiveFragment = this }.with(intent.extras))
|
||||
fragments.add(MyDownloadArchiveFragment().apply { mDownloadArchiveFragment = this }.with(intent.extras))
|
||||
fragments.add(MyShareArchiveFragment().apply { mShareArchiveFragment = this }.with(intent.extras))
|
||||
}
|
||||
|
||||
override fun initTabTitleList(tabTitleList: MutableList<String>) {
|
||||
tabTitleList.add("我的存档")
|
||||
tabTitleList.add("我的下载")
|
||||
tabTitleList.add("我的分享")
|
||||
}
|
||||
|
||||
override fun onPageSelected(position: Int) {
|
||||
super.onPageSelected(position)
|
||||
mCheckedIndex = position
|
||||
NewFlatLogUtils.logCloudArchiveTabShow(
|
||||
mGameEntity?.id ?: "",
|
||||
mGameEntity?.name ?: "",
|
||||
if (position == MY_ARCHIVE_INDEX) "我的存档" else if (position == MY_DOWNLOAD_ARCHIVE_INDEX) "我的下载" else "我的分享"
|
||||
)
|
||||
controlUploadGameArchive()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
initDownloadBtn()
|
||||
DownloadManager.getInstance().addObserver(dataWatcher)
|
||||
}
|
||||
|
||||
private fun initDownloadBtn() {
|
||||
mGameEntity?.let { gameEntity ->
|
||||
DownloadItemUtils.updateDownloadButton(this, mBinding.downloadBtn, gameEntity)
|
||||
DownloadItemUtils.setOnClickListener(this, mBinding.downloadBtn, gameEntity, 0, null, mEntrance, "")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
DownloadManager.getInstance().removeObserver(dataWatcher)
|
||||
}
|
||||
|
||||
fun controlUploadGameArchive() {
|
||||
val shouldShowUploadGameArchive =
|
||||
(mCheckedIndex == MY_ARCHIVE_INDEX) || (mCheckedIndex == MY_DOWNLOAD_ARCHIVE_INDEX && mDownloadArchiveFragment?.isEmpty == true)
|
||||
showUploadGameArchive(shouldShowUploadGameArchive)
|
||||
}
|
||||
|
||||
private fun showUploadGameArchive(show: Boolean) {
|
||||
mBinding.uploadContainer.goneIf(!show || !CheckLoginUtils.isLogin())
|
||||
mBinding.divider.goneIf(!show || !CheckLoginUtils.isLogin())
|
||||
}
|
||||
|
||||
private fun showUploadDialog() {
|
||||
val dialog = Dialog(this)
|
||||
val binding = DialogUploadArchiveBinding.inflate(layoutInflater)
|
||||
binding.run {
|
||||
clearIv.setOnClickListener {
|
||||
contentEt.text.clear()
|
||||
}
|
||||
contentEt.doOnTextChanged { text, _, _, _ ->
|
||||
clearIv.goneIf(text?.length == 0)
|
||||
confirmTv.isEnabled = text?.length != 0
|
||||
confirmTv.alpha = if (text?.length != 0) 1F else 0.4F
|
||||
}
|
||||
confirmTv.setOnClickListener {
|
||||
NewFlatLogUtils.logCloudArchiveUploadDialogClick("确定")
|
||||
if (contentEt.text.trim().length in 3..30) {
|
||||
saveAndUploadArchive(contentEt.text.toString().trim())
|
||||
dialog.dismiss()
|
||||
} else {
|
||||
toast("存档名称限制3~30个字符")
|
||||
}
|
||||
}
|
||||
cancelTv.setOnClickListener {
|
||||
NewFlatLogUtils.logCloudArchiveUploadDialogClick("取消")
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||
dialog.setContentView(binding.root)
|
||||
dialog.setCanceledOnTouchOutside(true)
|
||||
dialog.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
private fun saveAndUploadArchive(archiveName: String) {
|
||||
val pathName = "${VArchiveHelper.archivePath}${
|
||||
MD5Utils.getContentMD5(
|
||||
System.currentTimeMillis().toString()
|
||||
)
|
||||
}.zip"
|
||||
VArchiveHelper.saveGameArchive(
|
||||
this@CloudArchiveManagerActivity,
|
||||
mGameEntity?.getUniquePackageName() ?: "",
|
||||
mViewModel.archiveConfigStr,
|
||||
File(pathName)
|
||||
) { entity ->
|
||||
OssUploadUtils.uploadFile(
|
||||
pathName,
|
||||
OssUploadUtils.UploadType.GAME_ARCHIVE,
|
||||
object : OssUploadUtils.OnUploadFileListener {
|
||||
override fun onSuccess(url: String) {
|
||||
mViewModel.postArchive(ArchiveEntity().apply {
|
||||
name = archiveName
|
||||
this.url = url
|
||||
configUrl = mArchiveConfigUrl
|
||||
md5 = entity.md5
|
||||
gameVersion = entity.gameVersion
|
||||
})
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable?) {
|
||||
toast("上传失败")
|
||||
}
|
||||
},
|
||||
null,
|
||||
mGameEntity?.id ?: "",
|
||||
entity.md5
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateDownloadBtn(
|
||||
downloadEntity: DownloadEntity?, downloadBtn: DownloadButton, gameEntity: GameEntity?
|
||||
) {
|
||||
// 青少年模式显示查看
|
||||
if (SPUtils.getBoolean(Constants.SP_TEENAGER_MODE)) {
|
||||
downloadBtn.text = "查看"
|
||||
downloadBtn.buttonStyle = DownloadButton.ButtonStyle.TEENAGER_MODE
|
||||
return
|
||||
}
|
||||
|
||||
if (downloadEntity != null) {
|
||||
val status = downloadEntity.status
|
||||
var btnText = getString(R.string.downloading)
|
||||
var backgroundType = DownloadButton.ButtonStyle.NORMAL
|
||||
|
||||
downloadBtn.apply {
|
||||
when (status) {
|
||||
DownloadStatus.downloading -> {
|
||||
btnText = "${downloadEntity.percent}%"
|
||||
backgroundType = DownloadButton.ButtonStyle.DOWNLOADING_NORMAL
|
||||
progress = (downloadEntity.percent * 10).toInt()
|
||||
setOnClickListener {
|
||||
DownloadManager.getInstance().pause(downloadEntity.url)
|
||||
}
|
||||
}
|
||||
DownloadStatus.waiting -> {
|
||||
btnText = getString(R.string.waiting)
|
||||
setOnClickListener { Utils.toast(this@CloudArchiveManagerActivity, "最多只能同时下载三个任务,请稍等"); }
|
||||
}
|
||||
DownloadStatus.pause, DownloadStatus.timeout, DownloadStatus.neterror, DownloadStatus.subscribe, DownloadStatus.overflow -> {
|
||||
btnText = getString(R.string.resume)
|
||||
setOnClickListener {
|
||||
DownloadManager.getInstance().resume(downloadEntity, true)
|
||||
}
|
||||
}
|
||||
DownloadStatus.done -> {
|
||||
if (PackagesManager.isCanUpdate(
|
||||
gameEntity?.id, gameEntity?.getApk()?.firstOrNull()?.packageName
|
||||
)
|
||||
) {
|
||||
btnText = getString(R.string.update)
|
||||
setOnClickListener {
|
||||
PackagesManager.getUpdateList().firstOrNull { it.id == downloadEntity.gameId }?.let {
|
||||
VHelper.updateOrReDownload(downloadEntity, it)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
btnText = getString(R.string.launch)
|
||||
setOnClickListener {
|
||||
CurrentActivityHolder.getCurrentActivity()?.let {
|
||||
VHelper.installOrLaunch(it, downloadEntity.packageName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
text = btnText
|
||||
buttonStyle = backgroundType
|
||||
}
|
||||
} else {
|
||||
downloadBtn.buttonStyle = DownloadButton.ButtonStyle.NORMAL
|
||||
downloadBtn.text = "畅玩"
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDarkModeChanged() {
|
||||
super.onDarkModeChanged()
|
||||
updateStatusBarColor(R.color.background_white, R.color.background_white)
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onEventMainThread(reuse: EBReuse) {
|
||||
when (reuse.type) {
|
||||
Constants.LOGIN_TAG -> {
|
||||
controlUploadGameArchive()
|
||||
}
|
||||
"download" -> {
|
||||
mBinding.downloadBtn.performClick()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun updateMyArchive() {
|
||||
mArchiveFragment?.onLoadRefresh()
|
||||
}
|
||||
|
||||
fun updateMyDownloadArchive() {
|
||||
mDownloadArchiveFragment?.onLoadRefresh()
|
||||
}
|
||||
|
||||
fun updateMyShareArchive() {
|
||||
mShareArchiveFragment?.onLoadRefresh()
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val MY_ARCHIVE_INDEX = 0
|
||||
const val MY_DOWNLOAD_ARCHIVE_INDEX = 1
|
||||
const val MY_SHARE_ARCHIVE_INDEX = 2
|
||||
|
||||
private const val DEV_HELP_ARTICLE_ID = "173387"
|
||||
private const val HELP_ARTICLE_ID = "202342"
|
||||
|
||||
@JvmStatic
|
||||
fun getIntent(context: Context, gameEntity: GameEntity, configUrl: String, entrance: String): Intent {
|
||||
return Intent(context, CloudArchiveManagerActivity::class.java).apply {
|
||||
putExtra(EntranceConsts.KEY_GAME, gameEntity)
|
||||
putExtra(EntranceConsts.KEY_ARCHIVE_CONFIG_URL, configUrl)
|
||||
putExtra(EntranceConsts.KEY_ENTRANCE, entrance)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,221 @@
|
||||
package com.gh.gamecenter.cloudarchive
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Application
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.gh.common.util.NewFlatLogUtils
|
||||
import com.gh.gamecenter.common.baselist.ListViewModel
|
||||
import com.gh.gamecenter.common.baselist.LoadType
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse
|
||||
import com.gh.gamecenter.common.utils.toRequestBody
|
||||
import com.gh.gamecenter.entity.ArchiveEntity
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.gh.vspace.VArchiveHelper
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Utils
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.Single
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.*
|
||||
import java.io.IOException
|
||||
|
||||
class CloudArchiveManagerViewModel(
|
||||
application: Application,
|
||||
private val mType: MyArchiveFragment.Type = MyArchiveFragment.Type.MY_ARCHIVE,
|
||||
val gameId: String,
|
||||
val configUrl: String
|
||||
) :
|
||||
ListViewModel<ArchiveEntity, ArchiveEntity>(application) {
|
||||
|
||||
var archiveConfigStr = ""
|
||||
private val mApi = RetrofitManager.getInstance().newApi
|
||||
|
||||
val uploadSuccess = MutableLiveData<Boolean>()
|
||||
val shareSuccess = MutableLiveData<Boolean>()
|
||||
|
||||
init {
|
||||
if (configUrl.isNotEmpty()) getArchiveConfigString(configUrl)
|
||||
}
|
||||
|
||||
override fun mergeResultLiveData() {
|
||||
mResultLiveData.addSource(mListLiveData) { list ->
|
||||
list.forEach { it.gameId = gameId }
|
||||
mResultLiveData.postValue(list)
|
||||
}
|
||||
}
|
||||
|
||||
override fun provideDataObservable(page: Int): Observable<List<ArchiveEntity>>? = when (mType) {
|
||||
MyArchiveFragment.Type.MY_ARCHIVE -> {
|
||||
mApi.getMyArchives(gameId, page)
|
||||
}
|
||||
MyArchiveFragment.Type.MY_DOWNLOAD_ARCHIVE -> null
|
||||
MyArchiveFragment.Type.MY_SHARE_ARCHIVE -> mApi.getMyShareArchives(gameId, page)
|
||||
}
|
||||
|
||||
override fun provideDataSingle(page: Int): Single<MutableList<ArchiveEntity>>? {
|
||||
return if (mType == MyArchiveFragment.Type.MY_DOWNLOAD_ARCHIVE) {
|
||||
Single.create { emitter ->
|
||||
val downloadList = VArchiveHelper.vArchiveEntityListLiveData.value
|
||||
val archiveEntityList = arrayListOf<ArchiveEntity>()
|
||||
if (downloadList != null) {
|
||||
for (vArchiveEntity in downloadList) {
|
||||
if (vArchiveEntity.gameId == gameId && vArchiveEntity.type == 1) {
|
||||
archiveEntityList.add(
|
||||
ArchiveEntity(
|
||||
id = vArchiveEntity.id,
|
||||
name = vArchiveEntity.name,
|
||||
gameId = vArchiveEntity.gameId,
|
||||
desc = vArchiveEntity.descContent,
|
||||
url = vArchiveEntity.url,
|
||||
configUrl = vArchiveEntity.configUrl,
|
||||
md5 = vArchiveEntity.md5,
|
||||
time = ArchiveEntity.Time(update = vArchiveEntity.time),
|
||||
gameVersion = vArchiveEntity.gameVersion
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
emitter.onSuccess(archiveEntityList)
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
fun postArchive(archiveEntity: ArchiveEntity) {
|
||||
val paramsMap = mapOf(
|
||||
"name" to archiveEntity.name,
|
||||
"url" to archiveEntity.url,
|
||||
"config_url" to archiveEntity.configUrl,
|
||||
"game_version" to archiveEntity.gameVersion,
|
||||
"md5" to archiveEntity.md5
|
||||
)
|
||||
mApi.postMyArchive(gameId, paramsMap.toRequestBody())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
uploadSuccess.postValue(true)
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
super.onFailure(exception)
|
||||
uploadSuccess.postValue(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
fun shareArchive(archiveEntity: ArchiveEntity, shareName: String, shareDesc: String) {
|
||||
val paramsMap = mapOf(
|
||||
"share_name" to shareName,
|
||||
"share_desc" to shareDesc,
|
||||
"is_shared" to true
|
||||
)
|
||||
mApi.patchMyArchive(gameId, archiveEntity.id, paramsMap.toRequestBody())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
shareSuccess.postValue(true)
|
||||
Utils.toast(getApplication(), "分享成功")
|
||||
NewFlatLogUtils.logCloudArchiveShareDialogResult("分享成功")
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
super.onFailure(exception)
|
||||
shareSuccess.postValue(false)
|
||||
Utils.toast(getApplication(), "分享失败")
|
||||
NewFlatLogUtils.logCloudArchiveShareDialogResult("分享失败")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
fun cancelShareArchive(archiveEntity: ArchiveEntity) {
|
||||
val paramsMap = mapOf(
|
||||
"is_shared" to false
|
||||
)
|
||||
mApi.patchMyArchive(gameId, archiveEntity.id, paramsMap.toRequestBody())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
load(LoadType.REFRESH)
|
||||
Utils.toast(getApplication(), "取消分享成功")
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
super.onFailure(exception)
|
||||
Utils.toast(getApplication(), "取消分享失败")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
fun editMyArchive(archiveEntity: ArchiveEntity) {
|
||||
val paramsMap = mapOf(
|
||||
"name" to archiveEntity.name
|
||||
)
|
||||
mApi.patchMyArchive(gameId, archiveEntity.id, paramsMap.toRequestBody())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
load(LoadType.REFRESH)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
fun deleteArchive(archiveEntity: ArchiveEntity) {
|
||||
mApi.deleteMyArchive(gameId, archiveEntity.id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
load(LoadType.REFRESH)
|
||||
Utils.toast(getApplication(), "删除成功")
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
super.onFailure(exception)
|
||||
Utils.toast(getApplication(), "删除失败")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 通过url获取config字符串内容
|
||||
private fun getArchiveConfigString(url: String) {
|
||||
OkHttpClient().newCall(
|
||||
Request.Builder()
|
||||
.url(url)
|
||||
.build()
|
||||
)
|
||||
.enqueue(object : Callback {
|
||||
override fun onFailure(call: Call, e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
override fun onResponse(call: Call, response: Response) {
|
||||
archiveConfigStr = response.body()?.string() ?: ""
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
class Factory(
|
||||
val type: MyArchiveFragment.Type = MyArchiveFragment.Type.MY_ARCHIVE,
|
||||
val gameId: String,
|
||||
val configUrl: String
|
||||
) : ViewModelProvider.NewInstanceFactory() {
|
||||
override fun <T : ViewModel> create(modelClass: Class<T>): T {
|
||||
return CloudArchiveManagerViewModel(HaloApp.getInstance().application, type, gameId, configUrl) as T
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,109 @@
|
||||
package com.gh.gamecenter.cloudarchive
|
||||
|
||||
import android.content.Context
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.common.util.ArchiveDownloadButtonHelper
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.BaseRecyclerViewHolder
|
||||
import com.gh.gamecenter.common.baselist.ListAdapter
|
||||
import com.gh.gamecenter.common.constant.ItemViewType
|
||||
import com.gh.gamecenter.common.utils.formatTime
|
||||
import com.gh.gamecenter.common.utils.toBinding
|
||||
import com.gh.gamecenter.common.viewholder.FooterViewHolder
|
||||
import com.gh.gamecenter.databinding.ItemMyArchiveBinding
|
||||
import com.gh.gamecenter.databinding.ItemMyShareArchiveBinding
|
||||
import com.gh.gamecenter.entity.ArchiveEntity
|
||||
|
||||
class MyArchiveAdapter(
|
||||
context: Context,
|
||||
private val mFragment: Fragment,
|
||||
private val mViewModel: CloudArchiveManagerViewModel,
|
||||
private val mType: MyArchiveFragment.Type,
|
||||
private val mPackageName: String
|
||||
) : ListAdapter<ArchiveEntity>(context) {
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
return if (position == itemCount - 1) ItemViewType.ITEM_FOOTER else ItemViewType.ITEM_BODY
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder =
|
||||
if (viewType == ItemViewType.ITEM_FOOTER) FooterViewHolder(
|
||||
mLayoutInflater.inflate(
|
||||
R.layout.refresh_footerview,
|
||||
parent,
|
||||
false
|
||||
)
|
||||
) else if (mType == MyArchiveFragment.Type.MY_SHARE_ARCHIVE) {
|
||||
MyShareArchiveItemViewHolder(parent.toBinding())
|
||||
} else {
|
||||
MyArchiveItemViewHolder(parent.toBinding())
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||
if (holder is MyArchiveItemViewHolder) {
|
||||
val entity = mEntityList[position]
|
||||
holder.binding.run {
|
||||
titleTv.text = entity.name
|
||||
timeTv.text = entity.time.update.formatTime("yyyy-MM-dd HH:mm")
|
||||
versionTv.text = "版本:${entity.gameVersion}"
|
||||
optionsIv.setOnClickListener {
|
||||
MyArchiveOptionDialogFragment.show(mContext as AppCompatActivity, mViewModel, mType, entity)
|
||||
}
|
||||
val entrance = if (mType == MyArchiveFragment.Type.MY_ARCHIVE) "云存档-我的存档" else "云存档-我的下载"
|
||||
ArchiveDownloadButtonHelper.bindItem(
|
||||
mContext,
|
||||
entrance,
|
||||
mFragment,
|
||||
mPackageName,
|
||||
entity,
|
||||
actionTv
|
||||
) {
|
||||
if (mContext is CloudArchiveManagerActivity) {
|
||||
(mContext as CloudArchiveManagerActivity).updateMyShareArchive()
|
||||
(mContext as CloudArchiveManagerActivity).updateMyDownloadArchive()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (holder is MyShareArchiveItemViewHolder) {
|
||||
val entity = mEntityList[position]
|
||||
holder.binding.run {
|
||||
titleTv.text = entity.name
|
||||
timeTv.text = entity.time.update.formatTime("yyyy-MM-dd HH:mm")
|
||||
versionTv.text = "版本:${entity.gameVersion}"
|
||||
descTv.text = entity.desc
|
||||
optionsIv.setOnClickListener {
|
||||
MyArchiveOptionDialogFragment.show(mContext as AppCompatActivity, mViewModel, mType, entity)
|
||||
}
|
||||
ArchiveDownloadButtonHelper.bindItem(
|
||||
mContext,
|
||||
"云存档-我的分享",
|
||||
mFragment,
|
||||
mPackageName,
|
||||
entity,
|
||||
actionTv
|
||||
) {
|
||||
if (mContext is CloudArchiveManagerActivity) {
|
||||
(mContext as CloudArchiveManagerActivity).updateMyArchive()
|
||||
(mContext as CloudArchiveManagerActivity).updateMyDownloadArchive()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (holder is FooterViewHolder) {
|
||||
holder.initItemPadding()
|
||||
holder.initFooterViewHolder(mViewModel, mIsLoading, mIsNetworkError, mIsOver)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = if (mEntityList.isNullOrEmpty()) 0 else mEntityList.size + FOOTER_ITEM_COUNT
|
||||
|
||||
class MyArchiveItemViewHolder(val binding: ItemMyArchiveBinding) : BaseRecyclerViewHolder<Any>(binding.root)
|
||||
class MyShareArchiveItemViewHolder(val binding: ItemMyShareArchiveBinding) :
|
||||
BaseRecyclerViewHolder<Any>(binding.root)
|
||||
}
|
||||
@ -0,0 +1,145 @@
|
||||
package com.gh.gamecenter.cloudarchive
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.common.util.CheckLoginUtils
|
||||
import com.gh.common.util.NewFlatLogUtils
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.baselist.ListAdapter
|
||||
import com.gh.gamecenter.common.baselist.ListFragment
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.eventbus.EBReuse
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.common.view.CustomDividerItemDecoration
|
||||
import com.gh.gamecenter.databinding.FragmentMyArchiveBinding
|
||||
import com.gh.gamecenter.entity.ArchiveEntity
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
open class MyArchiveFragment : ListFragment<ArchiveEntity, CloudArchiveManagerViewModel>() {
|
||||
protected var mGameEntity: GameEntity? = null
|
||||
protected var mType: Type = Type.MY_ARCHIVE
|
||||
|
||||
protected val mBinding: FragmentMyArchiveBinding by lazy { FragmentMyArchiveBinding.inflate(layoutInflater) }
|
||||
protected val mViewModel: CloudArchiveManagerViewModel by lazy {
|
||||
viewModelProvider(
|
||||
CloudArchiveManagerViewModel.Factory(
|
||||
mType, mGameEntity?.id ?: "", ""
|
||||
)
|
||||
)
|
||||
}
|
||||
protected val mAdapter by lazy {
|
||||
MyArchiveAdapter(
|
||||
requireContext(),
|
||||
this,
|
||||
provideListViewModel(),
|
||||
mType,
|
||||
mGameEntity?.getUniquePackageName() ?: ""
|
||||
)
|
||||
}
|
||||
|
||||
override fun getLayoutId(): Int = 0
|
||||
|
||||
override fun getInflatedLayout() = mBinding.root
|
||||
|
||||
override fun provideListAdapter(): ListAdapter<*> = mAdapter
|
||||
|
||||
override fun provideListViewModel(): CloudArchiveManagerViewModel = mViewModel
|
||||
|
||||
override fun getItemDecoration(): RecyclerView.ItemDecoration =
|
||||
CustomDividerItemDecoration(requireContext(), notDecorateTheLastTwoItems = true).apply {
|
||||
setDrawable(R.drawable.divider_item_line_space_16.toDrawable(requireContext())!!)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
mGameEntity = requireArguments().getParcelable(EntranceConsts.KEY_GAME)
|
||||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
mBinding.reuseNoneData.root.setBackgroundColor(R.color.background_white.toColor(requireContext()))
|
||||
mBinding.reuseDataException.root.setBackgroundColor(R.color.background_white.toColor(requireContext()))
|
||||
mBinding.reuseNoConnection.root.setBackgroundColor(R.color.background_white.toColor(requireContext()))
|
||||
mBinding.reuseNoLogin.root.setBackgroundColor(R.color.background_white.toColor(requireContext()))
|
||||
|
||||
mBinding.reuseNoneData.reuseNoneDataTv.text = "还没有存档噢~"
|
||||
mBinding.reuseNoneData.reuseNoneDataDescTv.text = "点击下方按钮上传您的游戏存档吧!"
|
||||
mBinding.reuseNoneData.reuseNoneDataDescTv.visibility = View.VISIBLE
|
||||
|
||||
mBinding.reuseNoLogin.reuseNoneDataTv.text = "登录光环助手查看您的游戏存档~"
|
||||
mBinding.reuseNoLogin.reuseResetLoadTv.text = "立即登录"
|
||||
mBinding.reuseNoLogin.reuseNoneDataDescTv.visibility = View.GONE
|
||||
mBinding.reuseNoLogin.reuseResetLoadTv.visibility = View.VISIBLE
|
||||
mBinding.reuseNoLogin.reuseResetLoadTv.layoutParams =
|
||||
mBinding.reuseNoLogin.reuseResetLoadTv.layoutParams.apply { width = 136F.dip2px() }
|
||||
mBinding.reuseNoLogin.reuseResetLoadTv.setOnClickListener {
|
||||
ifLogin("云存档-我的存档")
|
||||
}
|
||||
mBinding.reuseNoLogin.root.goneIf(CheckLoginUtils.isLogin())
|
||||
|
||||
mViewModel.shareSuccess.observeNonNull(viewLifecycleOwner) {
|
||||
if (it && requireActivity() is CloudArchiveManagerActivity) {
|
||||
(requireActivity() as CloudArchiveManagerActivity).updateMyShareArchive()
|
||||
}
|
||||
}
|
||||
if (mType == Type.MY_ARCHIVE) {
|
||||
NewFlatLogUtils.logCloudArchiveTabShow(mGameEntity?.id ?: "", mGameEntity?.name ?: "", "我的存档")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onLoadEmpty() {
|
||||
super.onLoadEmpty()
|
||||
mBinding.tipsTv.visibility = View.GONE
|
||||
}
|
||||
|
||||
override fun onLoadNotFound() {
|
||||
super.onLoadNotFound()
|
||||
mBinding.tipsTv.visibility = View.GONE
|
||||
}
|
||||
|
||||
override fun onLoadError() {
|
||||
super.onLoadError()
|
||||
mBinding.tipsTv.visibility = View.GONE
|
||||
}
|
||||
|
||||
override fun onLoadDone() {
|
||||
super.onLoadDone()
|
||||
mBinding.tipsTv.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
override fun onLoadRefresh() {
|
||||
super.onLoadRefresh()
|
||||
mBinding.reuseNoLogin.root.goneIf(CheckLoginUtils.isLogin())
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
open fun onEventMainThread(reuse: EBReuse) {
|
||||
if (reuse.type == Constants.LOGIN_TAG) {
|
||||
onLoadRefresh()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDarkModeChanged() {
|
||||
super.onDarkModeChanged()
|
||||
mBinding.reuseNoneData.root.setBackgroundColor(R.color.background_white.toColor(requireContext()))
|
||||
mBinding.reuseDataException.root.setBackgroundColor(R.color.background_white.toColor(requireContext()))
|
||||
mBinding.reuseNoConnection.root.setBackgroundColor(R.color.background_white.toColor(requireContext()))
|
||||
mBinding.reuseNoLogin.root.setBackgroundColor(R.color.background_white.toColor(requireContext()))
|
||||
}
|
||||
|
||||
enum class Type(val value: String) {
|
||||
MY_ARCHIVE("my_archive"),
|
||||
MY_DOWNLOAD_ARCHIVE("my_download_archive"),
|
||||
MY_SHARE_ARCHIVE("my_share_archive");
|
||||
|
||||
companion object {
|
||||
fun fromString(typeString: String): Type {
|
||||
return values().find { typeString == it.value } ?: MY_ARCHIVE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,241 @@
|
||||
package com.gh.gamecenter.cloudarchive
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Dialog
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.os.Bundle
|
||||
import android.view.*
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.core.widget.doOnTextChanged
|
||||
import com.gh.common.util.NewFlatLogUtils
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.fragment.BaseDialogFragment
|
||||
import com.gh.gamecenter.common.eventbus.EBReuse
|
||||
import com.gh.gamecenter.common.utils.DialogHelper
|
||||
import com.gh.gamecenter.common.utils.goneIf
|
||||
import com.gh.gamecenter.common.utils.setRootBackgroundDrawable
|
||||
import com.gh.gamecenter.common.utils.toColor
|
||||
import com.gh.gamecenter.core.runOnIoThread
|
||||
import com.gh.gamecenter.databinding.DialogEditArchiveBinding
|
||||
import com.gh.gamecenter.databinding.DialogMyArchiveOptionBinding
|
||||
import com.gh.gamecenter.databinding.DialogShareArchiveBinding
|
||||
import com.gh.gamecenter.entity.ArchiveEntity
|
||||
import com.gh.vspace.VArchiveHelper
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.download.FileUtils
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
|
||||
class MyArchiveOptionDialogFragment(private val mViewModel: CloudArchiveManagerViewModel) : BaseDialogFragment() {
|
||||
|
||||
private lateinit var mBinding: DialogMyArchiveOptionBinding
|
||||
private var mType = MyArchiveFragment.Type.MY_ARCHIVE
|
||||
private var mGameId = ""
|
||||
private var mArchiveEntity: ArchiveEntity? = null
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
return DialogMyArchiveOptionBinding.inflate(layoutInflater, null, false).apply {
|
||||
mBinding = this
|
||||
}.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
mGameId = mViewModel.gameId
|
||||
mType = MyArchiveFragment.Type.fromString(requireArguments().getString(KEY_ARCHIVE_TYPE, ""))
|
||||
mArchiveEntity = requireArguments().getParcelable(KEY_ARCHIVE)
|
||||
|
||||
mBinding.editTv.goneIf(mType != MyArchiveFragment.Type.MY_ARCHIVE)
|
||||
mBinding.shareTv.goneIf(mType != MyArchiveFragment.Type.MY_ARCHIVE)
|
||||
mBinding.deleteTv.setOnClickListener {
|
||||
NewFlatLogUtils.logCloudArchiveDeleteDialogShow()
|
||||
DialogHelper.showDialog(
|
||||
requireContext(),
|
||||
"提示",
|
||||
"删除存档数据后将无法恢复,\n" +
|
||||
"是否删除?",
|
||||
"确定删除",
|
||||
"取消",
|
||||
confirmClickCallback = {
|
||||
NewFlatLogUtils.logCloudArchiveDeleteDialogClick("确定")
|
||||
mArchiveEntity?.let { entity ->
|
||||
when (mType) {
|
||||
MyArchiveFragment.Type.MY_ARCHIVE -> {
|
||||
if (VArchiveHelper.isArchiveDownloaded(entity.md5)) {
|
||||
deleteLocalArchive(entity.md5)
|
||||
}
|
||||
mViewModel.deleteArchive(entity)
|
||||
EventBus.getDefault().post(EBReuse("RefreshShareArchive"))
|
||||
}
|
||||
MyArchiveFragment.Type.MY_DOWNLOAD_ARCHIVE -> {
|
||||
if (VArchiveHelper.isArchiveDownloaded(entity.md5)) {
|
||||
deleteLocalArchive(entity.md5)
|
||||
EventBus.getDefault().post(EBReuse("RefreshArchive"))
|
||||
}
|
||||
}
|
||||
MyArchiveFragment.Type.MY_SHARE_ARCHIVE -> {
|
||||
mViewModel.cancelShareArchive(entity)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
cancelClickCallback = {
|
||||
NewFlatLogUtils.logCloudArchiveDeleteDialogClick("取消")
|
||||
},
|
||||
uiModificationCallback = {
|
||||
it.confirmTv.setTextColor(R.color.theme_red.toColor(requireContext()))
|
||||
},
|
||||
extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true)
|
||||
)
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
mBinding.editTv.setOnClickListener {
|
||||
showEditDialog()
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
mBinding.shareTv.setOnClickListener {
|
||||
NewFlatLogUtils.logCloudArchiveShareDialogShow()
|
||||
showShareDialog()
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
mBinding.cancelBtn.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
|
||||
private fun deleteLocalArchive(md5: String) {
|
||||
VArchiveHelper.deleteArchive(md5)
|
||||
val pathName = VArchiveHelper.getArchiveFilePath(md5)
|
||||
if (pathName.isNotEmpty()) {
|
||||
runOnIoThread { FileUtils.deleteFile(pathName) }
|
||||
}
|
||||
}
|
||||
|
||||
private fun showEditDialog() {
|
||||
val dialog = Dialog(requireActivity())
|
||||
val binding = DialogEditArchiveBinding.inflate(layoutInflater)
|
||||
binding.run {
|
||||
descTv.text = "当前存档名《${mArchiveEntity?.name}》,修改为"
|
||||
clearIv.setOnClickListener {
|
||||
contentEt.text.clear()
|
||||
}
|
||||
contentEt.doOnTextChanged { text, _, _, _ ->
|
||||
clearIv.goneIf(text?.length == 0)
|
||||
confirmTv.isEnabled = text?.length != 0
|
||||
confirmTv.alpha = if (text?.length != 0) 1F else 0.4F
|
||||
}
|
||||
confirmTv.setOnClickListener {
|
||||
mArchiveEntity?.let { entity ->
|
||||
mViewModel.editMyArchive(entity.copy(name = contentEt.text.toString().trim()))
|
||||
}
|
||||
dialog.dismiss()
|
||||
}
|
||||
cancelTv.setOnClickListener {
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||
dialog.setContentView(binding.root)
|
||||
dialog.setCanceledOnTouchOutside(true)
|
||||
dialog.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
private fun showShareDialog() {
|
||||
val dialog = Dialog(requireActivity())
|
||||
val binding = DialogShareArchiveBinding.inflate(layoutInflater)
|
||||
binding.run {
|
||||
mArchiveEntity?.let {
|
||||
titleEt.setText(it.name)
|
||||
clearTitleIv.goneIf(it.name.isEmpty())
|
||||
}
|
||||
clearTitleIv.setOnClickListener {
|
||||
titleEt.text.clear()
|
||||
}
|
||||
clearDescIv.setOnClickListener {
|
||||
descEt.text.clear()
|
||||
}
|
||||
titleEt.doOnTextChanged { text, _, _, _ ->
|
||||
clearTitleIv.goneIf(text?.length == 0)
|
||||
confirmTv.isEnabled = (text?.length != 0 && descEt.text.isNotEmpty())
|
||||
confirmTv.alpha = if (text?.length != 0 && descEt.text.isNotEmpty()) 1F else 0.4F
|
||||
}
|
||||
descEt.doOnTextChanged { text, _, _, _ ->
|
||||
clearDescIv.goneIf(text?.length == 0)
|
||||
confirmTv.isEnabled = (text?.length != 0 && titleEt.text.isNotEmpty())
|
||||
confirmTv.alpha = if (text?.length != 0 && titleEt.text.isNotEmpty()) 1F else 0.4F
|
||||
}
|
||||
confirmTv.setOnClickListener {
|
||||
mArchiveEntity?.let { entity ->
|
||||
mViewModel.shareArchive(entity, titleEt.text.toString().trim(), descEt.text.toString().trim())
|
||||
}
|
||||
NewFlatLogUtils.logCloudArchiveShareDialogClick("分享")
|
||||
dialog.dismiss()
|
||||
}
|
||||
cancelTv.setOnClickListener {
|
||||
NewFlatLogUtils.logCloudArchiveShareDialogClick("取消")
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||
dialog.setContentView(binding.root)
|
||||
dialog.setCanceledOnTouchOutside(true)
|
||||
dialog.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
|
||||
dialog.show()
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val createDialog = super.onCreateDialog(savedInstanceState)
|
||||
createDialog.setCanceledOnTouchOutside(true)
|
||||
val window = createDialog.window
|
||||
window?.setGravity(Gravity.BOTTOM)
|
||||
window?.setWindowAnimations(R.style.community_publication_animation)
|
||||
return createDialog
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
val width = HaloApp.getInstance().application.resources.displayMetrics.widthPixels
|
||||
val height = dialog?.window?.attributes?.height ?: ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
dialog?.window?.setLayout(width, height)
|
||||
}
|
||||
|
||||
override fun onDarkModeChanged() {
|
||||
super.onDarkModeChanged()
|
||||
if (::mBinding.isInitialized) {
|
||||
mBinding.run {
|
||||
root.setRootBackgroundDrawable(R.drawable.background_shape_white_radius_12_top_only)
|
||||
line1.setBackgroundColor(R.color.divider.toColor(requireContext()))
|
||||
cancelBtn.setTextColor(R.color.text_subtitle.toColor(requireContext()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val KEY_ARCHIVE_TYPE = "archive_type"
|
||||
const val KEY_ARCHIVE = "archive"
|
||||
|
||||
fun show(
|
||||
activity: AppCompatActivity,
|
||||
mViewModel: CloudArchiveManagerViewModel,
|
||||
archiveType: MyArchiveFragment.Type,
|
||||
archiveEntity: ArchiveEntity
|
||||
) {
|
||||
MyArchiveOptionDialogFragment(mViewModel).apply {
|
||||
arguments = bundleOf(
|
||||
KEY_ARCHIVE_TYPE to archiveType.value,
|
||||
KEY_ARCHIVE to archiveEntity
|
||||
)
|
||||
}.show(activity.supportFragmentManager, MyArchiveOptionDialogFragment::class.java.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package com.gh.gamecenter.cloudarchive
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import com.gh.gamecenter.common.baselist.LoadType
|
||||
import com.gh.gamecenter.common.eventbus.EBReuse
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
class MyDownloadArchiveFragment : MyArchiveFragment() {
|
||||
var isEmpty = false
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
mType = Type.MY_DOWNLOAD_ARCHIVE
|
||||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
mBinding.reuseNoneData.reuseNoneDataTv.text = "还没有存档噢~"
|
||||
mBinding.reuseNoneData.reuseNoneDataDescTv.text = "去看看大家上传的热门存档吧!"
|
||||
}
|
||||
|
||||
override fun onLoadDone() {
|
||||
super.onLoadDone()
|
||||
isEmpty = false
|
||||
mBinding.tipsTv.visibility = View.GONE
|
||||
if (requireActivity() is CloudArchiveManagerActivity) {
|
||||
(requireActivity() as CloudArchiveManagerActivity).controlUploadGameArchive()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onLoadEmpty() {
|
||||
super.onLoadEmpty()
|
||||
isEmpty = true
|
||||
if (requireActivity() is CloudArchiveManagerActivity) {
|
||||
(requireActivity() as CloudArchiveManagerActivity).controlUploadGameArchive()
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
override fun onEventMainThread(reuse: EBReuse) {
|
||||
super.onEventMainThread(reuse)
|
||||
if ("RefreshArchive" == reuse.type) {
|
||||
AppExecutor.uiExecutor.executeWithDelay({
|
||||
mListViewModel.load(LoadType.REFRESH)
|
||||
if (requireActivity() is CloudArchiveManagerActivity) {
|
||||
(requireActivity() as CloudArchiveManagerActivity).updateMyArchive()
|
||||
(requireActivity() as CloudArchiveManagerActivity).updateMyShareArchive()
|
||||
}
|
||||
}, 200)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
package com.gh.gamecenter.cloudarchive
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import com.gh.gamecenter.common.baselist.LoadType
|
||||
import com.gh.gamecenter.common.eventbus.EBReuse
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
class MyShareArchiveFragment : MyArchiveFragment() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
mType = Type.MY_SHARE_ARCHIVE
|
||||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
mBinding.tipsTv.visibility = View.GONE
|
||||
mBinding.reuseNoneData.reuseNoneDataTv.text = "还没有您分享存档噢~"
|
||||
mBinding.reuseNoneData.reuseNoneDataDescTv.text = "快快把您的有趣存档分享给大家吧!"
|
||||
}
|
||||
|
||||
override fun onLoadDone() {
|
||||
super.onLoadDone()
|
||||
mBinding.tipsTv.visibility = View.GONE
|
||||
if (requireActivity() is CloudArchiveManagerActivity) {
|
||||
(requireActivity() as CloudArchiveManagerActivity).controlUploadGameArchive()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onLoadEmpty() {
|
||||
super.onLoadEmpty()
|
||||
if (requireActivity() is CloudArchiveManagerActivity) {
|
||||
(requireActivity() as CloudArchiveManagerActivity).controlUploadGameArchive()
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
override fun onEventMainThread(reuse: EBReuse) {
|
||||
super.onEventMainThread(reuse)
|
||||
if ("RefreshShareArchive" == reuse.type) {
|
||||
AppExecutor.uiExecutor.executeWithDelay({
|
||||
mListViewModel.load(LoadType.REFRESH)
|
||||
}, 200)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -14,6 +14,7 @@ import com.gh.gamecenter.common.syncpage.ISyncAdapterHandler;
|
||||
import com.gh.common.util.CollectionUtils;
|
||||
import com.gh.gamecenter.common.utils.DialogHelper;
|
||||
import com.gh.gamecenter.common.utils.ExtensionsKt;
|
||||
import com.gh.gamecenter.common.view.DrawableView;
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.common.viewholder.FooterViewHolder;
|
||||
@ -232,6 +233,11 @@ public class AnswerAdapter extends ListAdapter<AnswerEntity> implements ISyncAda
|
||||
|
||||
}
|
||||
});
|
||||
mPopupBinding.checkAllCb.setCompoundDrawablesWithIntrinsicBounds(
|
||||
DrawableView.getCheckSelectorDrawable(
|
||||
mContext
|
||||
), null, null, null
|
||||
);
|
||||
mPopupBinding.checkAllCb.setOnClickListener(v -> {
|
||||
if (mPopupBinding.checkAllCb.isChecked()) {
|
||||
selectItems.clear();
|
||||
|
||||
@ -16,6 +16,7 @@ import com.gh.gamecenter.common.callback.OnListClickListener;
|
||||
import com.gh.gamecenter.common.constant.ItemViewType;
|
||||
import com.gh.gamecenter.common.utils.DialogHelper;
|
||||
import com.gh.gamecenter.common.utils.ExtensionsKt;
|
||||
import com.gh.gamecenter.common.view.DrawableView;
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils;
|
||||
import com.gh.gamecenter.common.utils.ImageUtils;
|
||||
import com.gh.common.util.NewsUtils;
|
||||
@ -361,6 +362,11 @@ public class ArticleAdapter extends ListAdapter<NewsEntity> {
|
||||
|
||||
}
|
||||
});
|
||||
mPopupBinding.checkAllCb.setCompoundDrawablesWithIntrinsicBounds(
|
||||
DrawableView.getCheckSelectorDrawable(
|
||||
mContext
|
||||
), null, null, null
|
||||
);
|
||||
mPopupBinding.checkAllCb.setOnClickListener(v -> {
|
||||
if (mPopupBinding.checkAllCb.isChecked()) {
|
||||
selectItems.clear();
|
||||
|
||||
@ -18,6 +18,7 @@ import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.databinding.CommunityAnswerItemBinding
|
||||
import com.gh.gamecenter.databinding.PopupHistoryOptionBinding
|
||||
import com.gh.gamecenter.common.entity.CommunityEntity
|
||||
import com.gh.gamecenter.common.view.DrawableView
|
||||
import com.gh.gamecenter.history.ManageOption
|
||||
import com.gh.gamecenter.qa.answer.CommunityAnswerItemViewHolder
|
||||
import com.gh.gamecenter.qa.article.detail.ArticleDetailActivity
|
||||
@ -172,6 +173,11 @@ class CommunityArticleAdapter(
|
||||
}, extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true))
|
||||
|
||||
}
|
||||
mPopupBinding?.checkAllCb?.setCompoundDrawablesWithIntrinsicBounds(
|
||||
DrawableView.getCheckSelectorDrawable(
|
||||
mContext
|
||||
), null, null, null
|
||||
)
|
||||
mPopupBinding?.checkAllCb?.setOnClickListener {
|
||||
if (mPopupBinding?.checkAllCb?.isChecked == true) {
|
||||
selectItems.clear()
|
||||
|
||||
@ -24,6 +24,7 @@ import com.gh.gamecenter.adapter.viewholder.GameCollectionItemViewHolder
|
||||
import com.gh.gamecenter.common.baselist.ListAdapter
|
||||
import com.gh.gamecenter.collection.GamesCollectionFragment.Companion.TYPE_USER
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.common.view.DrawableView
|
||||
import com.gh.gamecenter.core.utils.*
|
||||
import com.gh.gamecenter.databinding.ItemGameCollectionFlexTagBinding
|
||||
import com.gh.gamecenter.databinding.PopupHistoryOptionBinding
|
||||
@ -424,6 +425,11 @@ class GamesCollectionAdapter(
|
||||
}, extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true))
|
||||
|
||||
}
|
||||
mPopupBinding?.checkAllCb?.setCompoundDrawablesWithIntrinsicBounds(
|
||||
DrawableView.getCheckSelectorDrawable(
|
||||
mContext
|
||||
), null, null, null
|
||||
)
|
||||
mPopupBinding?.checkAllCb?.setOnClickListener {
|
||||
if (mPopupBinding?.checkAllCb?.isChecked == true) {
|
||||
selectItems.clear()
|
||||
|
||||
@ -3,6 +3,7 @@ package com.gh.gamecenter.collection
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.drawable.StateListDrawable
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
@ -17,6 +18,7 @@ import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.viewholder.FooterViewHolder
|
||||
import com.gh.gamecenter.common.baselist.ListAdapter
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.common.view.DrawableView
|
||||
import com.gh.gamecenter.databinding.PopupHistoryOptionBinding
|
||||
import com.gh.gamecenter.databinding.VideoNewItemBinding
|
||||
import com.gh.gamecenter.entity.MyVideoEntity
|
||||
@ -166,6 +168,11 @@ class VideoAdapter(
|
||||
}, extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true))
|
||||
|
||||
}
|
||||
mPopupBinding?.checkAllCb?.setCompoundDrawablesWithIntrinsicBounds(
|
||||
DrawableView.getCheckSelectorDrawable(
|
||||
mContext
|
||||
), null, null, null
|
||||
)
|
||||
mPopupBinding?.checkAllCb?.setOnClickListener {
|
||||
if (mPopupBinding?.checkAllCb?.isChecked == true) {
|
||||
selectItems.clear()
|
||||
|
||||
@ -14,8 +14,9 @@ import com.gh.common.exposure.ExposureEvent
|
||||
import com.gh.common.exposure.ExposureSource
|
||||
import com.gh.common.exposure.ExposureType
|
||||
import com.gh.common.exposure.IExposable
|
||||
import com.gh.common.util.*
|
||||
import com.gh.common.util.DialogUtils
|
||||
import com.gh.common.util.DirectUtils
|
||||
import com.gh.common.util.DownloadItemUtils
|
||||
import com.gh.common.util.HomeBottomBarHelper
|
||||
import com.gh.common.util.NewFlatLogUtils
|
||||
import com.gh.gamecenter.BlockActivity
|
||||
import com.gh.gamecenter.GameDetailActivity
|
||||
@ -25,7 +26,6 @@ import com.gh.gamecenter.adapter.viewholder.GameViewHolder
|
||||
import com.gh.gamecenter.common.base.BaseRecyclerViewHolder
|
||||
import com.gh.gamecenter.common.baselist.ListAdapter
|
||||
import com.gh.gamecenter.common.baselist.LoadStatus
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.constant.ItemViewType
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.common.viewholder.FooterViewHolder
|
||||
@ -48,7 +48,8 @@ class DiscoveryAdapter(
|
||||
private val mViewModel: DiscoveryViewModel,
|
||||
private val mBaseExposureSource: ArrayList<ExposureSource>,
|
||||
private val mOuterSequence: Int,
|
||||
private val mEntrance: String
|
||||
private val mEntrance: String,
|
||||
private val mDislikeCallback: (anchorView: View, position: Int, gameEntity: GameEntity) -> Unit
|
||||
) : ListAdapter<DiscoveryItemData>(context), IExposable {
|
||||
|
||||
private val mExposureEventSparseArray: SparseArray<ExposureEvent> = SparseArray()
|
||||
@ -150,7 +151,7 @@ class DiscoveryAdapter(
|
||||
)
|
||||
}
|
||||
holder.itemView.setOnLongClickListener {
|
||||
discoveryFeedback(position, gameEntity)
|
||||
mDislikeCallback.invoke(holder.itemView, position, gameEntity)
|
||||
true
|
||||
}
|
||||
DownloadItemUtils.setOnClickListener(
|
||||
@ -174,12 +175,7 @@ class DiscoveryAdapter(
|
||||
labelTv.goneIf(labels.size < index + 1) {
|
||||
labelTv.setTextColor(R.color.text_subtitle.toColor(mContext))
|
||||
labelTv.background = R.drawable.bg_shape_white_radius_4.toDrawable(mContext)
|
||||
labelTv.setCompoundDrawablesWithIntrinsicBounds(
|
||||
null,
|
||||
null,
|
||||
R.drawable.ic_interest_arrow.toDrawable(mContext),
|
||||
null
|
||||
)
|
||||
labelTv.setDrawableEnd(R.drawable.ic_interest_arrow)
|
||||
labels[index].text = labels[index].linkText
|
||||
labelTv.text = labels[index].title
|
||||
labelTv.setOnClickListener {
|
||||
@ -238,21 +234,6 @@ class DiscoveryAdapter(
|
||||
return if (mEntityList == null || mEntityList.isEmpty()) return 0 else mEntityList.size + 1
|
||||
}
|
||||
|
||||
private fun discoveryFeedback(position: Int, gameEntity: GameEntity) {
|
||||
DialogUtils.showReportReasonDialog(
|
||||
mContext,
|
||||
Constants.FEEDBACK_REASON_LIST.toList() as ArrayList<String>,
|
||||
"不喜欢的原因"
|
||||
) { reason, _ ->
|
||||
mViewModel.discoveryFeedback(gameEntity.id, reason, gameEntity.type ?: "") {
|
||||
NewFlatLogUtils.logDiscoverPageNotInterest(gameEntity.id, gameEntity.name ?: "")
|
||||
mViewModel.forceRefresh = true
|
||||
mEntityList.removeAt(position)
|
||||
notifyItemRemoved(position)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun notifyItemByDownload(download: DownloadEntity) {
|
||||
val positionAndPackageMap = mViewModel.positionAndPackageMap
|
||||
for (key in positionAndPackageMap.keys) {
|
||||
@ -298,11 +279,7 @@ class DiscoveryAdapter(
|
||||
class DiscoveryGameViewHolder(val binding: DiscoveryGameItemBinding) : GameViewHolder(binding.root) {
|
||||
init {
|
||||
gameDownloadBtn = binding.downloadBtn
|
||||
gameProgressbar = binding.gameProgressbar
|
||||
gameInfo = binding.gameInfo
|
||||
gameDownloadPercentage = binding.downloadPercentage
|
||||
gameDes = binding.gameDes
|
||||
gameDownloadSpeed = binding.downloadSpeed
|
||||
gameRating = binding.gameRating
|
||||
recommendContainer = binding.recommendContainer
|
||||
recommendIv = binding.recommendIv
|
||||
@ -320,12 +297,7 @@ class DiscoveryAdapter(
|
||||
gameIconView.displayGameIcon(gameEntity)
|
||||
BindingAdapters.setGameName(gameName, gameEntity, false, null)
|
||||
BindingAdapters.setTextSize(gameRating, if (gameEntity.commentCount > 3) 12 else 10)
|
||||
gameRating.setCompoundDrawablesWithIntrinsicBounds(
|
||||
if (gameEntity.commentCount > 3) R.drawable.game_horizontal_rating.toDrawable() else null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
)
|
||||
gameRating.setDrawableStart(if (gameEntity.commentCount > 3) R.drawable.game_horizontal_rating.toDrawable() else null)
|
||||
gameRating.text = if (gameEntity.commentCount > 3) {
|
||||
if (gameEntity.star == 10.0F) "10" else gameEntity.star.toString()
|
||||
} else {
|
||||
@ -352,19 +324,14 @@ class DiscoveryAdapter(
|
||||
recommendReasonTv.text =
|
||||
"${gameEntity.columnRank!!.name}·第${gameEntity.columnRank!!.position}名"
|
||||
recommendReasonTv.setTextColor(R.color.theme_yellow.toColor(binding.root.context))
|
||||
recommendReasonTv.setCompoundDrawablesWithIntrinsicBounds(
|
||||
R.drawable.ic_discovery_rank.toDrawable(binding.root.context),
|
||||
null,
|
||||
null,
|
||||
null
|
||||
)
|
||||
recommendReasonTv.setDrawableStart(R.drawable.ic_discovery_rank)
|
||||
recommendReasonTv.background =
|
||||
R.drawable.bg_discovery_recommend.toDrawable(binding.root.context)
|
||||
recommendReasonTv.visibility = View.VISIBLE
|
||||
} else if (gameEntity.type == "recommend") {
|
||||
recommendReasonTv.text = "其他玩家推荐"
|
||||
recommendReasonTv.setTextColor(R.color.theme_font.toColor(binding.root.context))
|
||||
recommendReasonTv.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null)
|
||||
recommendReasonTv.removeDrawable()
|
||||
recommendReasonTv.background = R.drawable.bg_discovery_rank.toDrawable(binding.root.context)
|
||||
recommendReasonTv.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
@ -1,8 +1,12 @@
|
||||
package com.gh.gamecenter.discovery
|
||||
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
@ -20,14 +24,16 @@ import com.gh.gamecenter.common.baselist.LazyListFragment
|
||||
import com.gh.gamecenter.common.baselist.ListAdapter
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.utils.dip2px
|
||||
import com.gh.gamecenter.common.utils.getBitmapFromView
|
||||
import com.gh.gamecenter.common.utils.toColor
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.databinding.LayoutDiscoveryGuideBinding
|
||||
import com.gh.gamecenter.databinding.LayoutPopupDiscoveryDislikeBinding
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.eventbus.EBDownloadStatus
|
||||
import com.gh.gamecenter.eventbus.EBPackage
|
||||
import com.google.android.flexbox.FlexboxLayout
|
||||
import com.lightgame.download.DataWatcher
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
@ -136,12 +142,18 @@ class DiscoveryFragment : LazyListFragment<DiscoveryItemData, DiscoveryViewModel
|
||||
arguments?.getParcelable<ExposureSource>(EntranceConsts.KEY_EXPOSURE_SOURCE)?.let { add(it) }
|
||||
}
|
||||
val outerSequence = requireArguments().getInt(EntranceConsts.KEY_POSITION, -1)
|
||||
|
||||
val dislikeCallback: (anchorView: View, position: Int, gameEntity: GameEntity) -> Unit =
|
||||
{ view, position, entity ->
|
||||
showDislikeWindow(view, position, entity)
|
||||
}
|
||||
return mAdapter ?: DiscoveryAdapter(
|
||||
requireContext(),
|
||||
mListViewModel,
|
||||
basicExposureSource,
|
||||
outerSequence,
|
||||
"发现页"
|
||||
"发现页",
|
||||
dislikeCallback,
|
||||
).also { mAdapter = it }
|
||||
}
|
||||
|
||||
@ -230,6 +242,78 @@ class DiscoveryFragment : LazyListFragment<DiscoveryItemData, DiscoveryViewModel
|
||||
}
|
||||
}
|
||||
|
||||
private fun showDislikeWindow(view: View, position: Int, gameEntity: GameEntity) {
|
||||
val decorView = requireActivity().window.decorView as? FrameLayout
|
||||
val binding = LayoutPopupDiscoveryDislikeBinding.inflate(LayoutInflater.from(requireContext()), decorView, true)
|
||||
binding.reasonFlex.removeAllViews()
|
||||
Constants.FEEDBACK_REASON_LIST.toList().forEach {
|
||||
val popupItem = getPopupItem(it)
|
||||
val params =
|
||||
FlexboxLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
binding.reasonFlex.addView(popupItem, params)
|
||||
popupItem.setOnClickListener {
|
||||
mListViewModel.discoveryFeedback(gameEntity.id, popupItem.text.toString(), gameEntity.type ?: "") {
|
||||
NewFlatLogUtils.logDiscoverPageNotInterest(gameEntity.id, gameEntity.name ?: "")
|
||||
mListViewModel.forceRefresh = true
|
||||
mAdapter?.entityList?.removeAt(position)
|
||||
mAdapter?.notifyItemRemoved(position)
|
||||
decorView?.removeView(binding.root)
|
||||
ToastUtils.showToast("已根据你的偏好优化推荐机制~", Gravity.CENTER)
|
||||
}
|
||||
}
|
||||
}
|
||||
binding.root.setOnClickListener {
|
||||
decorView?.removeView(it)
|
||||
}
|
||||
binding.contentView.visibility = View.INVISIBLE
|
||||
binding.contentView.post {
|
||||
val (windowPosition, isNeedShowUp) = getWindowPosition(view, binding.contentView, 36F.dip2px())
|
||||
(binding.contentView.layoutParams as RelativeLayout.LayoutParams).run {
|
||||
topMargin = windowPosition[1]
|
||||
binding.contentView.layoutParams = this
|
||||
}
|
||||
binding.anchorUpIv.goneIf(isNeedShowUp)
|
||||
binding.anchorDownIv.goneIf(!isNeedShowUp)
|
||||
binding.contentView.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
private fun getPopupItem(reason: String): TextView {
|
||||
return TextView(requireContext()).apply {
|
||||
height = 32F.dip2px()
|
||||
text = reason
|
||||
textSize = 12F
|
||||
includeFontPadding = false
|
||||
setTextColor(R.color.text_subtitle.toColor(requireContext()))
|
||||
gravity = Gravity.CENTER
|
||||
setPadding(12F.dip2px(), 0F.dip2px(), 12F.dip2px(), 0F.dip2px())
|
||||
background = R.drawable.bg_shape_space_radius_8.toDrawable(requireContext())
|
||||
}
|
||||
}
|
||||
|
||||
private fun getWindowPosition(
|
||||
anchorView: View,
|
||||
contentView: View,
|
||||
distanceY: Int = 0
|
||||
): Pair<IntArray, Boolean> {
|
||||
val windowPos = IntArray(2)
|
||||
val anchorLoc = IntArray(2)
|
||||
anchorView.getLocationInWindow(anchorLoc)
|
||||
val anchorHeight = anchorView.height
|
||||
val screenHeight = anchorView.context.resources.displayMetrics.heightPixels
|
||||
contentView.measure(0, 0)
|
||||
val contentViewWidth = contentView.width
|
||||
val contentViewHeight = contentView.height
|
||||
val isNeedShowUp = screenHeight - anchorLoc[1] - anchorHeight < contentViewHeight
|
||||
windowPos[1] = if (isNeedShowUp) {
|
||||
anchorLoc[1] - contentViewHeight + distanceY
|
||||
} else {
|
||||
anchorLoc[1] + anchorHeight - distanceY
|
||||
}
|
||||
windowPos[0] = (anchorLoc[0] - contentViewWidth + anchorView.width) / 2
|
||||
return Pair(windowPos, isNeedShowUp)
|
||||
}
|
||||
|
||||
override fun onDarkModeChanged() {
|
||||
super.onDarkModeChanged()
|
||||
mListRv?.recycledViewPool?.clear()
|
||||
@ -250,7 +334,7 @@ class DiscoveryFragment : LazyListFragment<DiscoveryItemData, DiscoveryViewModel
|
||||
// 安装/卸载 事件
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onEventMainThread(busFour: EBPackage) {
|
||||
if ("安装" == busFour.type || "卸载" == busFour.type) {
|
||||
if (busFour.isInstalledOrUninstalled()) {
|
||||
mAdapter?.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator;
|
||||
@ -89,81 +90,79 @@ public class GameDownloadFragment extends BaseFragment implements View.OnClickLi
|
||||
}
|
||||
|
||||
if (location != null) {
|
||||
if (!"pause".equals(adapter.getStatusMap().get(downloadEntity.getUrl()))) {
|
||||
if (downloadEntity.getStatus().equals(DownloadStatus.done)) {
|
||||
// 检查对应下载列表中是否存在该数据
|
||||
boolean isContains = false;
|
||||
for (DownloadEntity entity : adapter.getDownloadingList()) {
|
||||
if (entity.getUrl().equals(downloadEntity.getUrl())) {
|
||||
isContains = true;
|
||||
break;
|
||||
}
|
||||
if (downloadEntity.getStatus().equals(DownloadStatus.done)) {
|
||||
// 检查对应下载列表中是否存在该数据
|
||||
boolean isContains = false;
|
||||
for (DownloadEntity entity : adapter.getDownloadingList()) {
|
||||
if (entity.getUrl().equals(downloadEntity.getUrl())) {
|
||||
isContains = true;
|
||||
break;
|
||||
}
|
||||
if (isContains) {
|
||||
// 删除下载中列表对应数据
|
||||
if (adapter.getDownloadingList().size() == 1) {
|
||||
location = adapter.getLocation(downloadEntity.getUrl());
|
||||
if (location != null) {
|
||||
adapter.getDownloadingList().remove(location.intValue());
|
||||
adapter.initLocationMap();
|
||||
adapter.notifyItemRangeRemoved(adapter.getBase(), 2);
|
||||
}
|
||||
} else {
|
||||
location = adapter.getLocation(downloadEntity.getUrl());
|
||||
if (location != null) {
|
||||
adapter.getDownloadingList().remove(location.intValue());
|
||||
adapter.initLocationMap();
|
||||
adapter.notifyItemRemoved(adapter.getBase() + location + 1);
|
||||
adapter.notifyItemChanged(adapter.getBase() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
// 添加进已完成列表
|
||||
if (adapter.getDoneList().isEmpty()) {
|
||||
adapter.getDoneList().add(0, downloadEntity);
|
||||
}
|
||||
if (isContains) {
|
||||
// 删除下载中列表对应数据
|
||||
if (adapter.getDownloadingList().size() == 1) {
|
||||
location = adapter.getLocation(downloadEntity.getUrl());
|
||||
if (location != null) {
|
||||
adapter.getDownloadingList().remove(location.intValue());
|
||||
adapter.initLocationMap();
|
||||
adapter.notifyItemRangeInserted(0, 2);
|
||||
} else {
|
||||
adapter.getDoneList().add(0, downloadEntity);
|
||||
adapter.initLocationMap();
|
||||
adapter.notifyItemInserted(1);
|
||||
adapter.notifyItemRangeRemoved(adapter.getBase(), 2);
|
||||
}
|
||||
|
||||
} else {
|
||||
location = adapter.getLocation(downloadEntity.getUrl());
|
||||
if (location != null) {
|
||||
adapter.notifyItemChanged(location + 1);
|
||||
adapter.getDownloadingList().remove(location.intValue());
|
||||
adapter.initLocationMap();
|
||||
adapter.notifyItemRemoved(adapter.getBase() + location + 1);
|
||||
adapter.notifyItemChanged(adapter.getBase() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
adapter.getUrlMap().put(PackageUtils.getPackageNameByPath(HaloApp.getInstance().getApplication(),
|
||||
downloadEntity.getPath()), downloadEntity.getUrl());
|
||||
|
||||
// 用户焦点在下载管理页面时有任务完成,直接把所有下载完成的任务标记为已读
|
||||
DownloadManager.getInstance().markDownloadedTaskAsRead();
|
||||
} else if (DownloadStatus.cancel.equals(downloadEntity.getStatus())) { // 有可能由于网络劫持造成的
|
||||
adapter.initMap();
|
||||
adapter.notifyDataSetChanged();
|
||||
int listSize = adapter.getDownloadingList().size() + adapter.getDoneList().size();
|
||||
if (listSize == 0) {
|
||||
EventBus.getDefault().post(new EBDownloadChanged("download", View.GONE, listSize));
|
||||
if (mBinding.reuseNoneData.getRoot().getVisibility() == View.GONE) {
|
||||
mBinding.reuseNoneData.getRoot().setVisibility(View.VISIBLE);
|
||||
}
|
||||
// 添加进已完成列表
|
||||
if (adapter.getDoneList().isEmpty()) {
|
||||
adapter.getDoneList().add(0, downloadEntity);
|
||||
adapter.initLocationMap();
|
||||
adapter.notifyItemRangeInserted(0, 2);
|
||||
} else {
|
||||
EventBus.getDefault().post(new EBDownloadChanged("download", View.VISIBLE,
|
||||
adapter.getDownloadingList().size()));
|
||||
adapter.getDoneList().add(0, downloadEntity);
|
||||
adapter.initLocationMap();
|
||||
adapter.notifyItemInserted(1);
|
||||
}
|
||||
|
||||
} else {
|
||||
location = adapter.getLocation(downloadEntity.getUrl());
|
||||
if (location != null && adapter.getDownloadingList().size() > location) {
|
||||
adapter.getDownloadingList().set(location, downloadEntity);
|
||||
adapter.notifyItemChanged(adapter.getBase() + location + 1);
|
||||
if (location != null) {
|
||||
adapter.notifyItemChanged(location + 1);
|
||||
}
|
||||
}
|
||||
if (downloadEntity.getStatus() == DownloadStatus.neterror) {
|
||||
adapter.notifyItemChanged(adapter.getBase());
|
||||
|
||||
adapter.getUrlMap().put(PackageUtils.getPackageNameByPath(HaloApp.getInstance().getApplication(),
|
||||
downloadEntity.getPath()), downloadEntity.getUrl());
|
||||
|
||||
// 用户焦点在下载管理页面时有任务完成,直接把所有下载完成的任务标记为已读
|
||||
DownloadManager.getInstance().markDownloadedTaskAsRead();
|
||||
} else if (DownloadStatus.cancel.equals(downloadEntity.getStatus())) { // 有可能由于网络劫持造成的
|
||||
adapter.initMap();
|
||||
adapter.notifyDataSetChanged();
|
||||
int listSize = adapter.getDownloadingList().size() + adapter.getDoneList().size();
|
||||
if (listSize == 0) {
|
||||
EventBus.getDefault().post(new EBDownloadChanged("download", View.GONE, listSize));
|
||||
if (mBinding.reuseNoneData.getRoot().getVisibility() == View.GONE) {
|
||||
mBinding.reuseNoneData.getRoot().setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else {
|
||||
EventBus.getDefault().post(new EBDownloadChanged("download", View.VISIBLE,
|
||||
adapter.getDownloadingList().size()));
|
||||
}
|
||||
} else {
|
||||
location = adapter.getLocation(downloadEntity.getUrl());
|
||||
if (location != null && adapter.getDownloadingList().size() > location) {
|
||||
adapter.getDownloadingList().set(location, downloadEntity);
|
||||
adapter.notifyItemChanged(adapter.getBase() + location + 1);
|
||||
}
|
||||
}
|
||||
if (downloadEntity.getStatus() == DownloadStatus.neterror) {
|
||||
adapter.notifyItemChanged(adapter.getBase());
|
||||
}
|
||||
} else {
|
||||
if (!adapter.getDeleteList().contains(downloadEntity.getUrl())) {
|
||||
@ -348,7 +347,7 @@ public class GameDownloadFragment extends BaseFragment implements View.OnClickLi
|
||||
if (url != null) {
|
||||
Integer location = adapter.getLocation(url);
|
||||
if (location != null) {
|
||||
if ("安装".equals(busFour.getType())) {
|
||||
if (EBPackage.TYPE_INSTALLED.equals(busFour.getType())) {
|
||||
// DownloadEntity downloadEntity = DownloadManager.getInstance(getActivity()).get(url);
|
||||
// if (downloadEntity == null
|
||||
// || !downloadEntity.isPlugin() // 不是插件游戏,自己删除数据库数据和安装包
|
||||
|
||||
@ -60,6 +60,8 @@ class GameDownloadFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
private final List<DownloadEntity> mDownloadingList;
|
||||
private final List<DownloadEntity> mDownloadedList;
|
||||
|
||||
private final ArrayMap<String, String> xapkStatusMap;
|
||||
|
||||
// 1、此处的所有MAP只是对DownloadManager内部Map的引用,
|
||||
// 2、任何对下载器任务的操作,通过DownloadManager处理,由DownloadManager处理之后抛出对应的状态变化事件
|
||||
// 3、监听下载任务状态变化,刷新界面
|
||||
@ -86,6 +88,7 @@ class GameDownloadFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
deleteList = new ArrayList<>();
|
||||
|
||||
mDownloadedList = new ArrayList<>();
|
||||
xapkStatusMap = new ArrayMap<>();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@ -106,8 +109,7 @@ class GameDownloadFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
viewHolder.binding.getRoot().setBackground(ContextCompat.getDrawable(mContext, R.drawable.reuse_listview_item_style));
|
||||
|
||||
viewHolder.binding.dmItemTvTitle.setTextColor(ContextCompat.getColor(mContext, R.color.text_title));
|
||||
viewHolder.binding.dmItemTvDownloads.setTextColor(ContextCompat.getColor(mContext, R.color.text_subtitleDesc));
|
||||
viewHolder.binding.dmItemTvSpeed.setTextColor(ContextCompat.getColor(mContext, R.color.text_9a9a9a));
|
||||
ExtensionsKt.removeDrawable(viewHolder.binding.dmItemTvSpeed);
|
||||
|
||||
final DownloadEntity downloadEntity;
|
||||
if (mDownloadedList.size() != 0 && position > 0 && position <= mDownloadedList.size()) {
|
||||
@ -156,114 +158,112 @@ class GameDownloadFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
}
|
||||
|
||||
DownloadStatus status = downloadEntity.getStatus();
|
||||
String xapkStatus = downloadEntity.getMeta().get(XapkInstaller.XAPK_UNZIP_STATUS);
|
||||
if (status.equals(DownloadStatus.done)) {
|
||||
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
viewHolder.binding.dmItemTvDownloads.setLayoutParams(lparams);
|
||||
viewHolder.binding.dmItemTvDownloads.setTextColor(0xFF9A9A9A);
|
||||
viewHolder.binding.dmItemTvDownloads.setText("下载完成");
|
||||
viewHolder.binding.dmItemIvDelete.setVisibility(View.VISIBLE);
|
||||
if (XapkUnzipStatus.UNZIPPING.name().equals(xapkStatus)) {
|
||||
// XAPK状态有几率在SUCCESS后返回UNZIPPING, 此处对UNZIPPING之前的状态做一个判断
|
||||
if (XapkUnzipStatus.SUCCESS.name().equals(xapkStatusMap.get(downloadEntity.getUrl()))) {
|
||||
XapkInstaller.cancelUnzipTask(downloadEntity);
|
||||
return;
|
||||
}
|
||||
String percent = downloadEntity.getMeta().get(XapkInstaller.XAPK_UNZIP_PERCENT);
|
||||
viewHolder.binding.dmItemTvStartorpause.setButtonStyle(DownloadButton.ButtonStyle.XAPK_UNZIPPING);
|
||||
viewHolder.binding.dmItemTvStartorpause.setProgress((int) (Float.parseFloat(percent == null ? "0" : percent) * 10));
|
||||
viewHolder.binding.dmItemTvStartorpause.setText(percent + "%");
|
||||
viewHolder.binding.dmItemTvSpeed.setTextColor(mContext.getResources().getColor(R.color.text_subtitleDesc));
|
||||
viewHolder.binding.dmItemTvSpeed.setText(R.string.unzipping);
|
||||
return;
|
||||
} else if (XapkUnzipStatus.FAILURE.name().equals(xapkStatus)) {
|
||||
viewHolder.binding.dmItemTvStartorpause.setText(R.string.install);
|
||||
viewHolder.binding.dmItemTvStartorpause.setButtonStyle(DownloadButton.ButtonStyle.INSTALL_NORMAL);
|
||||
viewHolder.binding.dmItemTvStartorpause.setProgress((int) (downloadEntity.getPercent() * 10));
|
||||
viewHolder.binding.dmItemTvSpeed.setTextColor(ContextCompat.getColor(mContext, R.color.theme_red));
|
||||
viewHolder.binding.dmItemTvSpeed.setText("解压失败");
|
||||
ExtensionsKt.setDrawableStart(viewHolder.binding.dmItemTvSpeed, R.drawable.unzip_failure_hint, null, null);
|
||||
return;
|
||||
} else if (XapkUnzipStatus.SUCCESS.name().equals(xapkStatus)) {
|
||||
viewHolder.binding.dmItemTvStartorpause.setButtonStyle(DownloadButton.ButtonStyle.XAPK_SUCCESS);
|
||||
viewHolder.binding.dmItemTvStartorpause.setProgress(1000);
|
||||
viewHolder.binding.dmItemTvStartorpause.setText(R.string.hundred_percent);
|
||||
}
|
||||
if (xapkStatus != null && !xapkStatus.isEmpty()) {
|
||||
xapkStatusMap.put(downloadEntity.getUrl(), xapkStatus);
|
||||
}
|
||||
viewHolder.binding.dmItemTvSpeed.setTextColor(ContextCompat.getColor(mContext, R.color.text_subtitleDesc));
|
||||
viewHolder.binding.dmItemTvSpeed.setText("加载完成");
|
||||
viewHolder.binding.dmItemTvStartorpause.setText(R.string.install);
|
||||
|
||||
if (downloadEntity.isPluggable()
|
||||
&& PackagesManager.isInstalled(downloadEntity.getPackageName())) {
|
||||
viewHolder.binding.dmItemTvStartorpause.setText("安装");
|
||||
viewHolder.binding.dmItemTvStartorpause.setButtonStyle(DownloadButton.ButtonStyle.INSTALL_PLUGIN);
|
||||
} else {
|
||||
viewHolder.binding.dmItemTvStartorpause.setText("安装");
|
||||
viewHolder.binding.dmItemTvStartorpause.setButtonStyle(DownloadButton.ButtonStyle.INSTALL_NORMAL);
|
||||
}
|
||||
viewHolder.binding.dmItemTvSpeed.setText(R.string.hundred_percent);
|
||||
} else if (status.equals(DownloadStatus.downloading)) {
|
||||
if (!"pause".equals(statusMap.get(downloadEntity.getUrl()))) {
|
||||
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
|
||||
0, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
lparams.weight = 4;
|
||||
viewHolder.binding.dmItemTvDownloads.setLayoutParams(lparams);
|
||||
viewHolder.binding.dmItemTvDownloads.setTextColor(ContextCompat.getColor(mContext, R.color.theme_font));
|
||||
viewHolder.binding.dmItemTvDownloads.setText(String.format("%s(剩%s)",
|
||||
SpeedUtils.getSpeed(downloadEntity.getSpeed()),
|
||||
SpeedUtils.getRemainTime(downloadEntity.getSize(), downloadEntity.getProgress(), downloadEntity.getSpeed() * 1024)));
|
||||
viewHolder.binding.dmItemIvDelete.setVisibility(View.GONE);
|
||||
viewHolder.binding.dmItemTvStartorpause.setText("暂停");
|
||||
viewHolder.binding.dmItemTvStartorpause.setButtonStyle(DownloadButton.ButtonStyle.PAUSE);
|
||||
viewHolder.binding.dmItemTvSpeed.setText(downloadEntity.getPercent() + "%");
|
||||
}
|
||||
} else if (status.equals(DownloadStatus.downloading) || status.equals(DownloadStatus.redirected)) {
|
||||
viewHolder.binding.dmItemTvSpeed.setTextColor(ContextCompat.getColor(mContext, R.color.theme_font));
|
||||
viewHolder.binding.dmItemTvSpeed.setText(String.format("%s(剩%s)",
|
||||
SpeedUtils.getSpeed(downloadEntity.getSpeed()),
|
||||
SpeedUtils.getRemainTime(downloadEntity.getSize(), downloadEntity.getProgress(), downloadEntity.getSpeed() * 1024)));
|
||||
viewHolder.binding.dmItemTvStartorpause.setText(downloadEntity.getPercent() + "%");
|
||||
viewHolder.binding.dmItemTvStartorpause.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_NORMAL);
|
||||
viewHolder.binding.dmItemTvStartorpause.setProgress((int) (downloadEntity.getPercent() * 10));
|
||||
} else if (status.equals(DownloadStatus.waiting)) {
|
||||
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
viewHolder.binding.dmItemTvDownloads.setLayoutParams(lparams);
|
||||
viewHolder.binding.dmItemTvDownloads.setTextColor(0xFF9A9A9A);
|
||||
viewHolder.binding.dmItemTvDownloads.setText("等待中");
|
||||
viewHolder.binding.dmItemIvDelete.setVisibility(View.VISIBLE);
|
||||
viewHolder.binding.dmItemTvStartorpause.setText("等待");
|
||||
viewHolder.binding.dmItemTvSpeed.setTextColor(ContextCompat.getColor(mContext, R.color.text_subtitleDesc));
|
||||
viewHolder.binding.dmItemTvSpeed.setText(R.string.waiting);
|
||||
viewHolder.binding.dmItemTvStartorpause.setText(R.string.waiting);
|
||||
viewHolder.binding.dmItemTvStartorpause.setButtonStyle(DownloadButton.ButtonStyle.WAITING);
|
||||
viewHolder.binding.dmItemTvSpeed.setText(downloadEntity.getPercent() + "%");
|
||||
} else if (status.equals(DownloadStatus.pause)
|
||||
|| status.equals(DownloadStatus.timeout)
|
||||
|| status.equals(DownloadStatus.neterror)
|
||||
|| status.equals(DownloadStatus.subscribe)) {
|
||||
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
viewHolder.binding.dmItemIvDelete.setVisibility(View.VISIBLE);
|
||||
viewHolder.binding.dmItemTvStartorpause.setText("继续");
|
||||
viewHolder.binding.dmItemTvStartorpause.setText(R.string.resume);
|
||||
viewHolder.binding.dmItemTvStartorpause.setButtonStyle(DownloadButton.ButtonStyle.NORMAL);
|
||||
viewHolder.binding.dmItemTvSpeed.setText(downloadEntity.getPercent() + "%");
|
||||
|
||||
viewHolder.binding.dmItemTvDownloads.setLayoutParams(lparams);
|
||||
viewHolder.binding.dmItemTvDownloads.setTextColor(0xFF9A9A9A);
|
||||
viewHolder.binding.dmItemTvSpeed.setTextColor(ContextCompat.getColor(mContext, R.color.text_subtitleDesc));
|
||||
|
||||
if (status.equals(DownloadStatus.timeout)
|
||||
|| status.equals(DownloadStatus.neterror)
|
||||
|| status.equals(DownloadStatus.subscribe)) {
|
||||
viewHolder.binding.dmItemTvDownloads.setText("已暂停,连接WiFi自动下载");
|
||||
viewHolder.binding.dmItemTvSpeed.setText("等待WIFI");
|
||||
} else {
|
||||
viewHolder.binding.dmItemTvDownloads.setText("已暂停");
|
||||
viewHolder.binding.dmItemTvSpeed.setText("已暂停");
|
||||
}
|
||||
} else if (status.equals(DownloadStatus.overflow)) {
|
||||
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
viewHolder.binding.dmItemTvDownloads.setLayoutParams(lparams);
|
||||
viewHolder.binding.dmItemTvDownloads.setTextColor(mContext.getResources().getColor(R.color.theme_red));
|
||||
viewHolder.binding.dmItemTvDownloads.setText("数据异常,请重新下载");
|
||||
viewHolder.binding.dmItemIvDelete.setVisibility(View.VISIBLE);
|
||||
viewHolder.binding.dmItemTvSpeed.setTextColor(ContextCompat.getColor(mContext, R.color.text_subtitleDesc));
|
||||
viewHolder.binding.dmItemTvSpeed.setText("数据异常,请重新下载");
|
||||
viewHolder.binding.dmItemTvStartorpause.setText("失败");
|
||||
viewHolder.binding.dmItemTvStartorpause.setButtonStyle(DownloadButton.ButtonStyle.FAILURE);
|
||||
viewHolder.binding.dmItemTvSpeed.setText(downloadEntity.getPercent() + "%");
|
||||
}
|
||||
|
||||
String xapkStatus = downloadEntity.getMeta().get(XapkInstaller.XAPK_UNZIP_STATUS);
|
||||
if (XapkUnzipStatus.UNZIPPING.name().equals(xapkStatus)) {
|
||||
viewHolder.binding.dmItemTvStartorpause.setText("取消");
|
||||
|
||||
String percent = downloadEntity.getMeta().get(XapkInstaller.XAPK_UNZIP_PERCENT);
|
||||
viewHolder.binding.dmItemProgressbar.setProgress((int) (Float.parseFloat(percent == null ? "0" : percent) * 10));
|
||||
viewHolder.binding.dmItemProgressbar.setProgressDrawable(mContext.getResources().getDrawable(R.drawable.progressbar_xapk_style));
|
||||
|
||||
viewHolder.binding.dmItemTvSpeed.setText((percent + "%"));
|
||||
viewHolder.binding.dmItemTvSpeed.setTextColor(mContext.getResources().getColor(R.color.theme_font));
|
||||
|
||||
viewHolder.binding.dmItemTvDownloads.setText("解压中");
|
||||
viewHolder.binding.unzipFailureHint.setVisibility(View.GONE);
|
||||
} else if (XapkUnzipStatus.FAILURE.name().equals(xapkStatus)) {
|
||||
viewHolder.binding.dmItemProgressbar.setProgress((int) (downloadEntity.getPercent() * 10));
|
||||
viewHolder.binding.dmItemProgressbar.setProgressDrawable(mContext.getResources().getDrawable(R.drawable.progressbar_bg_style));
|
||||
viewHolder.binding.dmItemTvDownloads.setTextColor(ContextCompat.getColor(mContext, R.color.text_F10000));
|
||||
viewHolder.binding.unzipFailureHint.setVisibility(View.VISIBLE);
|
||||
viewHolder.binding.dmItemTvDownloads.setText("解压失败");
|
||||
} else {
|
||||
viewHolder.binding.dmItemProgressbar.setProgress((int) (downloadEntity.getPercent() * 10));
|
||||
viewHolder.binding.dmItemProgressbar.setProgressDrawable(mContext.getResources().getDrawable(R.drawable.progressbar_bg_style));
|
||||
viewHolder.binding.unzipFailureHint.setVisibility(View.GONE);
|
||||
viewHolder.binding.dmItemTvSpeed.setTextColor(mContext.getResources().getColor(R.color.text_9a9a9a));
|
||||
}
|
||||
|
||||
viewHolder.binding.dmItemTvStartorpause.setOnClickListener(v -> {
|
||||
String str = ((DownloadButton) v).getText();
|
||||
final String url = downloadEntity.getUrl();
|
||||
DownloadManager.getInstance().put(url, System.currentTimeMillis());
|
||||
switch (str) {
|
||||
case "继续":
|
||||
case "下载":
|
||||
if (XapkUnzipStatus.UNZIPPING.name().equals(xapkStatus)) {
|
||||
XapkInstaller.cancelUnzipTask(downloadEntity);
|
||||
return;
|
||||
} else if (XapkUnzipStatus.FAILURE.name().equals(xapkStatus)) {
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(mContext, () -> {
|
||||
final String path = downloadEntity.getPath();
|
||||
if (downloadEntity.isPluggable()
|
||||
&& PackagesManager.isInstalled(downloadEntity.getPackageName())) {
|
||||
showPluginDialog(downloadEntity.getPath());
|
||||
} else {
|
||||
if (FileUtils.isEmptyFile(path)) {
|
||||
Utils.toast(mContext, R.string.install_failure_hint);
|
||||
removeDownload(downloadEntity);
|
||||
} else {
|
||||
PackageInstaller.install(mContext, downloadEntity);
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
switch (status) {
|
||||
case pause:
|
||||
case timeout:
|
||||
case neterror:
|
||||
case subscribe:
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(mContext, () -> {
|
||||
// 下载管理不用判断是否大于50M
|
||||
DialogUtils.checkDownload(mContext, Float.toString(100F), isSubscribe -> {
|
||||
@ -273,72 +273,65 @@ class GameDownloadFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
notifyItemChanged(mDownloadedList.isEmpty() ? 0 : 1 + mDownloadedList
|
||||
.size());
|
||||
} else {
|
||||
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
|
||||
0, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
lparams.weight = 4;
|
||||
viewHolder.binding.dmItemTvDownloads.setLayoutParams(lparams);
|
||||
viewHolder.binding.dmItemTvDownloads.setTextColor(ContextCompat.getColor(mContext, R.color.theme_font));
|
||||
viewHolder.binding.dmItemTvDownloads.setText(String.format("%s(剩%s)",
|
||||
viewHolder.binding.dmItemTvSpeed.setTextColor(ContextCompat.getColor(mContext, R.color.theme_font));
|
||||
viewHolder.binding.dmItemTvSpeed.setText(String.format("%s(剩%s)",
|
||||
SpeedUtils.getSpeed(downloadEntity.getSpeed()),
|
||||
SpeedUtils.getRemainTime(downloadEntity.getSize(),
|
||||
downloadEntity.getProgress(), downloadEntity.getSpeed() * 1024)));
|
||||
viewHolder.binding.dmItemIvDelete.setVisibility(View.GONE);
|
||||
|
||||
viewHolder.binding.dmItemTvStartorpause.setText("暂停");
|
||||
viewHolder.binding.dmItemTvStartorpause.setButtonStyle(DownloadButton.ButtonStyle.PAUSE);
|
||||
viewHolder.binding.dmItemTvStartorpause.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_NORMAL);
|
||||
viewHolder.binding.dmItemTvStartorpause.setText(downloadEntity.getPercent() + "%");
|
||||
viewHolder.binding.dmItemTvStartorpause.setProgress((int) (downloadEntity.getPercent() * 10));
|
||||
statusMap.put(url, DownloadStatus.downloading.getStatus());
|
||||
notifyItemChanged(mDownloadedList.isEmpty() ? 0 : 1 + mDownloadedList
|
||||
.size());
|
||||
|
||||
Message msg = Message.obtain();
|
||||
msg.what = DownloadConfig.CONTINUE_DOWNLOAD_TASK;
|
||||
msg.obj = url;
|
||||
DownloadManager.getInstance().sendMessageDelayed(msg, 1000);
|
||||
DownloadManager.getInstance().resume(downloadEntity, true);
|
||||
// Message msg = Message.obtain();
|
||||
// msg.what = DownloadConfig.CONTINUE_DOWNLOAD_TASK;
|
||||
// msg.obj = url;
|
||||
// DownloadManager.getInstance().sendMessageDelayed(msg, 1000);
|
||||
}
|
||||
});
|
||||
});
|
||||
break;
|
||||
case "安装":
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(mContext, () -> {
|
||||
final String path = downloadEntity.getPath();
|
||||
if (downloadEntity.isPluggable()
|
||||
&& PackagesManager.isInstalled(downloadEntity.getPackageName())) {
|
||||
showPluginDialog(downloadEntity.getPath());
|
||||
} else {
|
||||
if (FileUtils.isEmptyFile(path)) {
|
||||
Utils.toast(mContext, R.string.install_failure_hint);
|
||||
removeDownload(downloadEntity);
|
||||
case done:
|
||||
if (str.equals(mContext.getString(R.string.install))) {
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(mContext, () -> {
|
||||
final String path = downloadEntity.getPath();
|
||||
if (downloadEntity.isPluggable()
|
||||
&& PackagesManager.isInstalled(downloadEntity.getPackageName())) {
|
||||
showPluginDialog(downloadEntity.getPath());
|
||||
} else {
|
||||
PackageInstaller.install(mContext, downloadEntity);
|
||||
if (FileUtils.isEmptyFile(path)) {
|
||||
Utils.toast(mContext, R.string.install_failure_hint);
|
||||
removeDownload(downloadEntity);
|
||||
} else {
|
||||
PackageInstaller.install(mContext, downloadEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
} else if (str.equals(mContext.getString(R.string.launch))) {
|
||||
PackageUtils.launchApplicationByPackageName(mContext, downloadEntity.getPackageName());
|
||||
}
|
||||
break;
|
||||
case "暂停":
|
||||
viewHolder.binding.dmItemTvStartorpause.setText("继续");
|
||||
case redirected:
|
||||
case downloading:
|
||||
viewHolder.binding.dmItemTvStartorpause.setText(R.string.resume);
|
||||
viewHolder.binding.dmItemTvStartorpause.setButtonStyle(DownloadButton.ButtonStyle.NORMAL);
|
||||
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
viewHolder.binding.dmItemTvDownloads.setLayoutParams(lparams);
|
||||
viewHolder.binding.dmItemTvDownloads.setTextColor(0xFF9A9A9A);
|
||||
viewHolder.binding.dmItemTvDownloads.setText("已暂停");
|
||||
viewHolder.binding.dmItemIvDelete.setVisibility(View.VISIBLE);
|
||||
viewHolder.binding.dmItemTvSpeed.setText("已暂停");
|
||||
viewHolder.binding.dmItemTvSpeed.setTextColor(ContextCompat.getColor(mContext, R.color.text_subtitleDesc));
|
||||
statusMap.put(url, DownloadStatus.pause.getStatus());
|
||||
notifyItemChanged(mDownloadedList.isEmpty() ? 0 : 1 + mDownloadedList.size());
|
||||
Message msg = Message.obtain();
|
||||
msg.what = DownloadConfig.PAUSE_DOWNLOAD_TASK;
|
||||
msg.obj = url;
|
||||
DownloadManager.getInstance().sendMessageDelayed(msg, 1000);
|
||||
// Message msg = Message.obtain();
|
||||
// msg.what = DownloadConfig.PAUSE_DOWNLOAD_TASK;
|
||||
// msg.obj = url;
|
||||
// DownloadManager.getInstance().sendMessageDelayed(msg, 1000);
|
||||
|
||||
// DownloadManager.getInstance().pause(downloadEntity);
|
||||
DownloadManager.getInstance().pause(downloadEntity.getUrl());
|
||||
break;
|
||||
case "等待":
|
||||
case waiting:
|
||||
Utils.toast(mContext, "最多只能同时下载三个任务,请稍等");
|
||||
break;
|
||||
case "启动":
|
||||
PackageUtils.launchApplicationByPackageName(mContext, downloadEntity.getPackageName());
|
||||
break;
|
||||
case "失败":
|
||||
case overflow:
|
||||
DialogHelper.showCenterDialog(mContext
|
||||
, "下载失败"
|
||||
, "安装包数据校验失败,无法完成下载,建议删除任务重新下载"
|
||||
@ -346,39 +339,18 @@ class GameDownloadFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
}, () -> {
|
||||
});
|
||||
break;
|
||||
case "取消":
|
||||
XapkInstaller.cancelUnzipTask(downloadEntity);
|
||||
break;
|
||||
}
|
||||
|
||||
// DataUtils.onMtaEvent(HaloApp.getInstance().getApplication(), "下载管理", "游戏下载", str);
|
||||
});
|
||||
|
||||
viewHolder.binding.dmItemTvDownloads.setOnClickListener(v -> {
|
||||
if (viewHolder.binding.unzipFailureHint.getVisibility() == View.VISIBLE) {
|
||||
DialogUtils.showUnzipFailureDialog(mContext, downloadEntity);
|
||||
} else if (viewHolder.binding.dmItemIvDelete.getVisibility() == View.VISIBLE) {
|
||||
showDeleteDialog(downloadEntity, viewHolder.getPosition());
|
||||
}
|
||||
});
|
||||
|
||||
viewHolder.binding.dmItemIvDelete.setOnClickListener(v -> {
|
||||
if (viewHolder.binding.dmItemIvDelete.getVisibility() == View.VISIBLE) {
|
||||
showDeleteDialog(downloadEntity, viewHolder.getPosition());
|
||||
}
|
||||
});
|
||||
|
||||
if (downloadEntity.getUrl().equals(url)) {
|
||||
viewHolder.binding.getRoot().setBackgroundColor(ContextCompat.getColor(mContext, R.color.select));
|
||||
} else {
|
||||
viewHolder.binding.getRoot().setBackgroundResource(R.drawable.reuse_listview_item_style);
|
||||
}
|
||||
viewHolder.binding.getRoot().setOnLongClickListener(v -> {
|
||||
if (viewHolder.binding.dmItemIvDelete.getVisibility() == View.VISIBLE) {
|
||||
showDeleteDialog(downloadEntity, viewHolder.getPosition());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
showDeleteDialog(viewHolder.binding.dmItemTvStartorpause, downloadEntity, viewHolder.getPosition());
|
||||
return true;
|
||||
});
|
||||
|
||||
} else if (holder instanceof DownloadHeadViewHolder) {
|
||||
@ -566,23 +538,31 @@ class GameDownloadFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
}
|
||||
|
||||
// 显示删除提示框
|
||||
private void showDeleteDialog(final DownloadEntity entry, final int position) {
|
||||
private void showDeleteDialog(DownloadButton downloadButton, final DownloadEntity entry, final int position) {
|
||||
boolean autoPause = DownloadStatus.downloading.equals(entry.getStatus());
|
||||
if (autoPause) {
|
||||
downloadButton.performClick();
|
||||
}
|
||||
String xapkStatus = entry.getMeta().get(XapkInstaller.XAPK_UNZIP_STATUS);
|
||||
String msg;
|
||||
String contentText;
|
||||
if (XapkUnzipStatus.UNZIPPING.name().equals(xapkStatus)) {
|
||||
msg = "游戏正在解压安装哦,确定删除?";
|
||||
contentText = "游戏正在解压安装哦,确定删除?";
|
||||
} else if (mDownloadedList.size() != 0 && position <= mDownloadedList.size()) {
|
||||
msg = "游戏还没安装哦,确定删除?";
|
||||
contentText = "游戏还没安装哦,确定删除?";
|
||||
} else {
|
||||
msg = "游戏还没下载完,确定删除?";
|
||||
contentText = "游戏还没下载完,确定删除?";
|
||||
}
|
||||
|
||||
DialogHelper.showCenterWarningDialog(mContext, "删除下载", msg, () -> {
|
||||
DialogHelper.showDeleteDialog(mContext, "删除游戏", contentText, "删除", "再等等", () -> {
|
||||
removeDownload(entry);
|
||||
if (XapkUnzipStatus.UNZIPPING.name().equals(xapkStatus)) {
|
||||
XapkInstaller.cancelUnzipTask(entry);
|
||||
}
|
||||
});
|
||||
}, () -> {
|
||||
if (autoPause) {
|
||||
downloadButton.performClick();
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
public void initLocationMap() {
|
||||
|
||||
@ -1,180 +0,0 @@
|
||||
//package com.gh.gamecenter.download
|
||||
//
|
||||
//import android.graphics.Color
|
||||
//import android.os.Bundle
|
||||
//import android.view.View
|
||||
//import android.widget.LinearLayout
|
||||
//import android.widget.TextView
|
||||
//import androidx.lifecycle.Observer
|
||||
//import androidx.lifecycle.ViewModelProviders
|
||||
//import androidx.recyclerview.widget.DefaultItemAnimator
|
||||
//import androidx.recyclerview.widget.RecyclerView
|
||||
//import butterknife.BindView
|
||||
//import com.ethanhua.skeleton.Skeleton
|
||||
//import com.ethanhua.skeleton.ViewSkeletonScreen
|
||||
//import com.gh.gamecenter.common.callback.OnRequestCallBackListener
|
||||
//import com.gh.common.exposure.ExposureListener
|
||||
//import com.gh.common.util.DownloadItemUtils
|
||||
//import com.gh.gamecenter.common.utils.isSimulatorGame
|
||||
//import com.gh.gamecenter.common.view.FixLinearLayoutManager
|
||||
//import com.gh.gamecenter.common.view.VerticalItemDecoration
|
||||
//import com.gh.download.DownloadManager
|
||||
//import com.gh.gamecenter.MainActivity
|
||||
//import com.gh.gamecenter.R
|
||||
//import com.gh.gamecenter.entity.GameEntity
|
||||
//import com.gh.gamecenter.entity.GameInstall
|
||||
//import com.gh.gamecenter.eventbus.EBDownloadStatus
|
||||
//import com.gh.gamecenter.common.eventbus.EBReuse
|
||||
//import com.gh.gamecenter.fragment.MainWrapperFragment
|
||||
//import com.gh.gamecenter.manager.PackagesManager
|
||||
//import com.gh.gamecenter.common.base.fragment.NormalFragment
|
||||
//import com.gh.gamecenter.packagehelper.PackageViewModel
|
||||
//import com.lightgame.download.DataWatcher
|
||||
//import com.lightgame.download.DownloadEntity
|
||||
//import com.lightgame.download.DownloadStatus
|
||||
//import org.greenrobot.eventbus.Subscribe
|
||||
//import org.greenrobot.eventbus.ThreadMode
|
||||
//
|
||||
//// 时间不够,不重构了,直接把原 Activity 改成 Fragment 就算了
|
||||
//class InstalledGameFragment : NormalFragment(), OnRequestCallBackListener<Any> {
|
||||
//
|
||||
// @BindView(R.id.fm_install_rv_show)
|
||||
// lateinit var mInstallRv: RecyclerView
|
||||
//
|
||||
// @BindView(R.id.reuse_nodata_skip)
|
||||
// lateinit var mNoDataSkip: LinearLayout
|
||||
//
|
||||
// @BindView(R.id.reuse_nodata_skip_tv_hint)
|
||||
// lateinit var mNoDataSkipHint: TextView
|
||||
//
|
||||
// @BindView(R.id.reuse_nodata_skip_tv_btn)
|
||||
// lateinit var mNoDataSkipBtn: TextView
|
||||
//
|
||||
// @BindView(R.id.list_skeleton)
|
||||
// lateinit var mListSkeleton: View
|
||||
//
|
||||
// private var mPackageViewModel: PackageViewModel? = null
|
||||
// private var mAdapter: InstalledGameFragmentAdapter? = null
|
||||
// private var mExposureListener: ExposureListener? = null
|
||||
//
|
||||
// private var mSkeleton: ViewSkeletonScreen? = null
|
||||
//
|
||||
// private var isEverpause = false
|
||||
//
|
||||
// private val dataWatcher = object : DataWatcher() {
|
||||
// override fun onDataChanged(downloadEntity: DownloadEntity) {
|
||||
// if (downloadEntity.status == DownloadStatus.done && downloadEntity.isSimulatorGame()) {
|
||||
// DownloadManager.getInstance().getEntryMap(downloadEntity.name)[downloadEntity.platform] = downloadEntity
|
||||
// mPackageViewModel?.getGameInstalledLiveData()?.value?.let {
|
||||
// mAdapter?.initData(PackagesManager.filterSameApk(PackagesManager.filterDownloadBlackPackage(it as MutableList<GameInstall>?)))
|
||||
// }
|
||||
// return
|
||||
// }
|
||||
// val locationList = mAdapter!!.locationMap[downloadEntity.packageName]
|
||||
// if (locationList != null && locationList.size != 0) {
|
||||
// var gameEntity: GameEntity?
|
||||
// for (location in locationList) {
|
||||
// if (location < mAdapter!!.gameList.size) {
|
||||
// gameEntity = mAdapter!!.gameList[location]
|
||||
// if (gameEntity != null) {
|
||||
// DownloadItemUtils.processDate(gameEntity, downloadEntity, mAdapter, location)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun onCreate(savedInstanceState: Bundle?) {
|
||||
// super.onCreate(savedInstanceState)
|
||||
// mNoDataSkip.visibility = View.GONE
|
||||
// mSkeleton = Skeleton.bind(mListSkeleton).shimmer(false).load(R.layout.activity_install_skeleton).show()
|
||||
// mNoDataSkipHint.text = "暂无游戏"
|
||||
// mNoDataSkipBtn.text = "去首页看看"
|
||||
// mNoDataSkipBtn.setOnClickListener {
|
||||
// MainActivity.skipToMainActivity(requireContext(), MainWrapperFragment.INDEX_HOME)
|
||||
// }
|
||||
//
|
||||
// mInstallRv.layoutManager = FixLinearLayoutManager(requireContext())
|
||||
// (mInstallRv.itemAnimator as DefaultItemAnimator).supportsChangeAnimations = false
|
||||
// mAdapter = InstalledGameFragmentAdapter(this)
|
||||
// mExposureListener = ExposureListener(this, mAdapter!!)
|
||||
// mInstallRv.addItemDecoration(VerticalItemDecoration(requireContext(), 8f, true))
|
||||
// mInstallRv.addOnScrollListener(mExposureListener!!)
|
||||
// mInstallRv.adapter = mAdapter
|
||||
//
|
||||
// mPackageViewModel = ViewModelProviders.of(this, PackageViewModel.Factory()).get(PackageViewModel::class.java)
|
||||
// mPackageViewModel?.getGameInstalledLiveData()?.observe(this,
|
||||
// Observer { gameInstalls -> mAdapter?.initData(PackagesManager.filterSameApk(PackagesManager.filterDownloadBlackPackage(gameInstalls as MutableList<GameInstall>?))) })
|
||||
// }
|
||||
//
|
||||
// override fun getLayoutId(): Int {
|
||||
// return R.layout.fragment_my_game
|
||||
// }
|
||||
//
|
||||
// override fun onResume() {
|
||||
// super.onResume()
|
||||
// if (isEverpause) {
|
||||
// for (entity in mAdapter!!.gameList) {
|
||||
// entity.setEntryMap(DownloadManager.getInstance().getEntryMap(entity.name))
|
||||
// }
|
||||
// mAdapter!!.notifyDataSetChanged()
|
||||
// }
|
||||
// isEverpause = false
|
||||
// DownloadManager.getInstance().addObserver(dataWatcher)
|
||||
// }
|
||||
//
|
||||
// override fun onPause() {
|
||||
// super.onPause()
|
||||
// isEverpause = true
|
||||
// DownloadManager.getInstance().removeObserver(dataWatcher)
|
||||
// }
|
||||
//
|
||||
// override fun loadDone() {
|
||||
// mSkeleton!!.hide()
|
||||
// }
|
||||
//
|
||||
// override fun loadDone(obj: Any) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// override fun loadError() {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// override fun loadEmpty() {
|
||||
// mSkeleton?.hide()
|
||||
// mInstallRv.visibility = View.GONE
|
||||
// mNoDataSkip.visibility = View.VISIBLE
|
||||
// mNoDataSkip.setBackgroundColor(Color.WHITE)
|
||||
// }
|
||||
//
|
||||
// // 打开下载按钮事件
|
||||
// @Subscribe(threadMode = ThreadMode.MAIN)
|
||||
// fun onEventMainThread(reuse: EBReuse) {
|
||||
// if (("Refresh" == reuse.type || "PlatformChanged" == reuse.type) && mAdapter != null) {
|
||||
// mAdapter?.notifyDataSetChanged()
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //下载被删除事件
|
||||
// @Subscribe(threadMode = ThreadMode.MAIN)
|
||||
// fun onEventMainThread(status: EBDownloadStatus) {
|
||||
// if ("delete" == status.status) {
|
||||
// DownloadManager.getInstance().removePlatform(status.name, status.platform)
|
||||
//
|
||||
// val locationList = mAdapter!!.locationMap[status.packageName]
|
||||
// var gameEntity: GameEntity?
|
||||
// if (locationList != null && locationList.size != 0) {
|
||||
// for (location in locationList) {
|
||||
// gameEntity = mAdapter!!.gameList[location]
|
||||
// if (gameEntity != null && gameEntity.getEntryMap() != null) {
|
||||
// gameEntity.getEntryMap().remove(status.platform)
|
||||
// }
|
||||
// }
|
||||
// mAdapter?.notifyDataSetChanged()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@ -1,382 +0,0 @@
|
||||
//package com.gh.gamecenter.download;
|
||||
//
|
||||
//import android.text.TextUtils;
|
||||
//import android.view.View;
|
||||
//import android.view.ViewGroup;
|
||||
//
|
||||
//import com.gh.gamecenter.common.constant.ItemViewType;
|
||||
//import com.gh.common.exposure.ExposureEvent;
|
||||
//import com.gh.common.exposure.ExposureSource;
|
||||
//import com.gh.common.exposure.ExposureType;
|
||||
//import com.gh.common.exposure.IExposable;
|
||||
//import com.gh.common.filter.RegionSettingHelper;
|
||||
//import com.gh.common.simulator.SimulatorGameManager;
|
||||
//import com.gh.common.util.ApkActiveUtils;
|
||||
//import com.gh.common.util.DataCollectionUtils;
|
||||
//import com.gh.common.util.DownloadItemUtils;
|
||||
//import com.gh.common.util.ExtensionsKt;
|
||||
//import com.gh.common.util.GameUtils;
|
||||
//import com.gh.common.util.PackageUtils;
|
||||
//import com.gh.common.util.PlatformUtils;
|
||||
//import com.gh.gamecenter.core.utils.ThirdPartyPackageHelper;
|
||||
//import com.gh.download.DownloadManager;
|
||||
//import com.gh.gamecenter.GameDetailActivity;
|
||||
//import com.gh.gamecenter.R;
|
||||
//import com.gh.gamecenter.common.viewholder.FooterViewHolder;
|
||||
//import com.gh.gamecenter.adapter.viewholder.GameViewHolder;
|
||||
//import com.gh.gamecenter.databinding.GameItemBinding;
|
||||
//import com.gh.gamecenter.entity.ApkEntity;
|
||||
//import com.gh.gamecenter.entity.GameCollectionEntity;
|
||||
//import com.gh.gamecenter.entity.GameEntity;
|
||||
//import com.gh.gamecenter.entity.GameInstall;
|
||||
//import com.gh.gamecenter.game.GameItemViewHolder;
|
||||
//import com.gh.gamecenter.manager.PackagesManager;
|
||||
//import com.gh.gamecenter.retrofit.Response;
|
||||
//import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
//import com.lightgame.adapter.BaseRecyclerAdapter;
|
||||
//import com.lightgame.download.DownloadEntity;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.Collections;
|
||||
//import java.util.List;
|
||||
//
|
||||
//import androidx.annotation.Nullable;
|
||||
//import androidx.collection.ArrayMap;
|
||||
//import androidx.recyclerview.widget.RecyclerView.ViewHolder;
|
||||
//
|
||||
//import io.reactivex.Observable;
|
||||
//import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
//import io.reactivex.schedulers.Schedulers;
|
||||
//import retrofit2.HttpException;
|
||||
//
|
||||
///**
|
||||
// * Created by LGT on 2016/8/12.
|
||||
// * 已安装界面-数据适配器
|
||||
// */
|
||||
//public class InstalledGameFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> implements IExposable {
|
||||
//
|
||||
// private InstalledGameFragment mFragment;
|
||||
//
|
||||
// private ArrayList<GameEntity> gameList;
|
||||
// private List<GameInstall> sortedList;
|
||||
//
|
||||
// //下载用到的map
|
||||
// private ArrayMap<String, ArrayList<Integer>> locationMap;
|
||||
//
|
||||
// private boolean isRemove;
|
||||
//
|
||||
// private ArrayList<ExposureSource> mExposureSource;
|
||||
//
|
||||
// public InstalledGameFragmentAdapter(InstalledGameFragment fragment) {
|
||||
// super(fragment.requireContext());
|
||||
// mFragment = fragment;
|
||||
//
|
||||
// gameList = new ArrayList<>();
|
||||
// sortedList = new ArrayList<>();
|
||||
//
|
||||
// locationMap = new ArrayMap<>();
|
||||
//
|
||||
// isRemove = false;
|
||||
//
|
||||
// mExposureSource = new ArrayList<>();
|
||||
// mExposureSource.add(new ExposureSource("下载管理", ""));
|
||||
// mExposureSource.add(new ExposureSource("已安装", ""));
|
||||
// }
|
||||
//
|
||||
// public void initData(List<GameInstall> list) {
|
||||
// List<DownloadEntity> downloadEntityList = DownloadManager.getInstance().getAllSimulatorDownloadEntity();
|
||||
// for (DownloadEntity entity : downloadEntityList) {
|
||||
// GameInstall gameInstall = new GameInstall();
|
||||
// gameInstall.setId(entity.getGameId());
|
||||
// list.add(gameInstall);
|
||||
// }
|
||||
//
|
||||
// for (GameInstall gameInstall : list) {
|
||||
// Object gh_id = PackageUtils.getMetaData(mContext, gameInstall.getPackageName(), "gh_id");
|
||||
// if (gh_id != null && !gh_id.equals(gameInstall.getId())) {
|
||||
// gameInstall.setId(gh_id.toString());
|
||||
// } else {
|
||||
// String gameId = ThirdPartyPackageHelper.getGameId(gameInstall.getPackageName());
|
||||
// if (!TextUtils.isEmpty(gameId)) {
|
||||
// gameInstall.setId(gameId);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// sortedList.clear();
|
||||
// //gameList.clear();
|
||||
// sortedList.addAll(list);
|
||||
//
|
||||
// if (sortedList.isEmpty()) {
|
||||
// mFragment.loadEmpty();
|
||||
// } else {
|
||||
// List<String> ids = new ArrayList<>();
|
||||
// Collections.sort(sortedList, (lhs, rhs) -> {
|
||||
// if (rhs == null || lhs == null) {
|
||||
// return 0;
|
||||
// }
|
||||
// // 按安装时间排序
|
||||
// if (rhs.getInstallTime() > lhs.getInstallTime()) {
|
||||
// return 1;
|
||||
// } else if (rhs.getInstallTime() < lhs.getInstallTime()) {
|
||||
// return -1;
|
||||
// } else {
|
||||
// return 0;
|
||||
// }
|
||||
// });
|
||||
// for (GameInstall info : sortedList) {
|
||||
// if (!ids.contains(info.getId()) && !RegionSettingHelper.shouldThisGameBeFiltered(info.getId())) {
|
||||
// ids.add(info.getId());
|
||||
// }
|
||||
// }
|
||||
// initGameList(ids);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //获取游戏简介
|
||||
// private void initGameList(List<String> ids) {
|
||||
// final List<GameEntity> result = new ArrayList<>();
|
||||
//
|
||||
// List<Observable<GameEntity>> sequences = new ArrayList<>();
|
||||
// for (String id : ids) {
|
||||
// sequences.add(RetrofitManager.getInstance().getApi().getGameDigest(id));
|
||||
// }
|
||||
// Observable.mergeDelayError(sequences)
|
||||
// .map(ApkActiveUtils.filterMapper)
|
||||
// .subscribeOn(Schedulers.io())
|
||||
// .observeOn(AndroidSchedulers.mainThread())
|
||||
// .subscribe(new Response<GameEntity>() {
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
// processingData(result);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onFailure(@Nullable HttpException e) {
|
||||
// processingData(result);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(GameEntity response) {
|
||||
// ApkActiveUtils.filterHideApk(response);
|
||||
// result.add(response);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// private void processingData(List<GameEntity> gameList) {
|
||||
// ArrayList<GameEntity> newGameList = new ArrayList<>();
|
||||
// if (gameList.size() != 0) {
|
||||
// for (int i = 0, size = sortedList.size(); i < size; i++) {
|
||||
// String id = sortedList.get(i).getId();
|
||||
// for (GameEntity entity : gameList) {
|
||||
// if (entity.getId().equals(id)) {
|
||||
// GameEntity newEntity = entity.clone();
|
||||
// newEntity.setLibaoExists(entity.isLibaoExists());
|
||||
//
|
||||
// // 下载管理不显示镜像游戏,不然会有奇怪的问题
|
||||
// if (entity.shouldUseMirrorInfo()) {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// if (newEntity.getApk().size() > 1) {
|
||||
// for (ApkEntity apkEntity : newEntity.getApk()) {
|
||||
// String packageName = sortedList.get(i).getPackageName();
|
||||
// if (packageName.equals(apkEntity.getPackageName())) {
|
||||
// ArrayList<ApkEntity> list = new ArrayList<>();
|
||||
// list.add(apkEntity);
|
||||
// newEntity.setApk(list);
|
||||
//
|
||||
// if (PackageUtils.isCanPluggable(apkEntity)) {
|
||||
// GameCollectionEntity pluggableCollection =
|
||||
// GameUtils.getPluggableCollectionFromGameEntity(entity, packageName);
|
||||
// if (pluggableCollection != null) {
|
||||
// newEntity.setPluggableCollection(pluggableCollection);
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// newGameList.add(newEntity);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// for (GameEntity entity : newGameList) {
|
||||
// entity.setEntryMap(DownloadManager.getInstance().getEntryMap(entity.getName()));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// this.gameList.clear();
|
||||
// this.gameList.addAll(newGameList);
|
||||
//
|
||||
// if (this.gameList.size() != 0) {
|
||||
// isRemove = true;
|
||||
// notifyDataSetChanged();
|
||||
// initLocationMap();
|
||||
//
|
||||
// mFragment.loadDone();
|
||||
// } else {
|
||||
// mFragment.loadEmpty();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void initLocationMap() {
|
||||
// locationMap.clear();
|
||||
// GameEntity gameEntity;
|
||||
// ArrayList<Integer> list;
|
||||
// for (int i = 0; i < gameList.size(); i++) {
|
||||
// gameEntity = gameList.get(i);
|
||||
// if (gameEntity.getApk() != null && gameEntity.getApk().size() != 0) {
|
||||
// for (ApkEntity apkEntity : gameEntity.getApk()) {
|
||||
// list = locationMap.get(apkEntity.getPackageName());
|
||||
// if (list == null) {
|
||||
// list = new ArrayList<>();
|
||||
// locationMap.put(apkEntity.getPackageName(), list);
|
||||
// }
|
||||
// list.add(i);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public ArrayList<GameEntity> getGameList() {
|
||||
// return gameList;
|
||||
// }
|
||||
//
|
||||
// public ArrayMap<String, ArrayList<Integer>> getLocationMap() {
|
||||
// return locationMap;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
// switch (viewType) {
|
||||
// case ItemViewType.GAME_NORMAL:
|
||||
// return new GameItemViewHolder(GameItemBinding.bind(
|
||||
// mLayoutInflater.inflate(R.layout.game_item, parent, false)));
|
||||
// case ItemViewType.LOADING:
|
||||
// return new FooterViewHolder(
|
||||
// mLayoutInflater.inflate(R.layout.refresh_footerview, parent, false));
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onBindViewHolder(final ViewHolder holder, int position) {
|
||||
// if (holder instanceof GameItemViewHolder) {
|
||||
// GameEntity gameEntity = ExtensionsKt.safelyGetInRelease(gameList, position);
|
||||
// if (gameEntity != null) {
|
||||
// initGameNormal((GameItemViewHolder) holder, gameEntity);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getItemViewType(int position) {
|
||||
// if (gameList.size() != 0 && position >= 0 && position < gameList.size()) {
|
||||
// return ItemViewType.GAME_NORMAL;
|
||||
// }
|
||||
//
|
||||
// return ItemViewType.LOADING;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getItemCount() {
|
||||
// if (gameList.isEmpty() && !isRemove) {
|
||||
// return 1;
|
||||
// }
|
||||
// if (isRemove) {
|
||||
// return gameList.size();
|
||||
// }
|
||||
// return gameList.size() + 1;
|
||||
// }
|
||||
//
|
||||
// private void initGameNormal(final GameItemViewHolder holder, final GameEntity gameEntity) {
|
||||
// gameEntity.setCollection(new ArrayList<>()); // 清空集合,防止下载按钮会因为存在集合而清空合集包的状态判断
|
||||
// holder.initServerType(gameEntity);
|
||||
// GameItemBinding binding = holder.getBinding();
|
||||
//
|
||||
// binding.setGame(gameEntity);
|
||||
// binding.setIsShowPlatform(true);
|
||||
// binding.executePendingBindings();
|
||||
//
|
||||
// String name;
|
||||
// if (gameEntity.getApk().size() > 0) {
|
||||
// name = String.format("%s - %s", gameEntity.getName(),
|
||||
// PlatformUtils.getInstance(mContext).getPlatformName(gameEntity.getApk().get(0).getPlatform()));
|
||||
// // TODO Fresco 未来可能不用 ImageView 作为基类,使用 setImageDrawable 有风险
|
||||
// binding.gameIconView.getIconIv().setImageDrawable(PackageUtils.getIconByPackageName(mContext, gameEntity.getApk().get(0).getPackageName()));
|
||||
// binding.gameIconView.getIconDecoratorIv().setVisibility(View.GONE);
|
||||
// if (SimulatorGameManager.isSimulatorGame(gameEntity)) {
|
||||
// binding.gameDes.setText(String.format("V%s", gameEntity.getApk().get(0).getVersion()));
|
||||
// } else {
|
||||
// binding.gameDes.setText(String.format("V%s", PackageUtils.getVersionNameByPackageName(gameEntity.getApk().get(0).getPackageName())));
|
||||
// }
|
||||
// } else {
|
||||
// name = gameEntity.getName();
|
||||
// binding.gameIconView.displayGameIcon(gameEntity.getRawIconInAdvanced(), gameEntity.getIconSubscript());
|
||||
// binding.gameDes.setText(gameEntity.getBrief());
|
||||
// }
|
||||
// if (SimulatorGameManager.isSimulatorGame(gameEntity)) {
|
||||
// binding.gameIconView.displayGameIcon(gameEntity.getIcon(), gameEntity.getIconSubscript());
|
||||
// }
|
||||
//
|
||||
// binding.gameName.setText(name);
|
||||
//
|
||||
// generateExposureEvent(gameEntity);
|
||||
//
|
||||
// DownloadItemUtils.setOnClickListener(
|
||||
// mContext,
|
||||
// binding.downloadBtn,
|
||||
// gameEntity,
|
||||
// 1,
|
||||
// InstalledGameFragmentAdapter.this,
|
||||
// "(我的光环-已安装)", "我的光环-已安装" + ":" + gameEntity.getName(),
|
||||
// gameEntity.getExposureEvent()
|
||||
//// , () -> MtaHelper.onEvent("下载管理", "已安装", binding.downloadBtn.getText().toString())
|
||||
// );
|
||||
//
|
||||
// DownloadItemUtils.updateItem(mContext, gameEntity, new GameViewHolder(binding), !gameEntity.isPluggable());
|
||||
//
|
||||
// holder.itemView.setOnClickListener(v -> {
|
||||
// DataCollectionUtils.uploadClick(mContext, "列表", "我的光环-我的游戏", gameEntity.getName());
|
||||
// GameDetailActivity.startGameDetailActivity(mContext, gameEntity.getId(), "(我的光环:我的游戏)", gameEntity.getExposureEvent());
|
||||
// });
|
||||
//
|
||||
// // 强制修改该列表安装状态(如果该包是合集且安装了合集内任意一个光环的游戏包都不显示插件化)
|
||||
// ArrayList<ApkEntity> apkList = gameEntity.getApk();
|
||||
// if (holder.getBinding().downloadBtn.getText().toString().contains("化") && apkList.size() == 1) {
|
||||
// ApkEntity apkEntity = apkList.get(0);
|
||||
// GameCollectionEntity pluggableCollection = gameEntity.getPluggableCollection();
|
||||
// if (pluggableCollection != null && pluggableCollection.getPackages().contains(apkEntity.getPackageName())) {
|
||||
// for (String pkg : pluggableCollection.getPackages()) {
|
||||
// Object ghId = PackageUtils.getGhId(pkg);
|
||||
// if (PackagesManager.isInstalled(pkg) && ghId != null && gameEntity.getId().equals(ghId.toString())) {
|
||||
// holder.getBinding().downloadBtn.setText(R.string.launch);
|
||||
// holder.getBinding().downloadBtn.setBackgroundResource(R.drawable.download_button_normal_style);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void generateExposureEvent(GameEntity gameEntity) {
|
||||
// ExposureEvent event = ExposureEvent.createEvent(gameEntity, mExposureSource, null, ExposureType.EXPOSURE);
|
||||
// gameEntity.setExposureEvent(event);
|
||||
// }
|
||||
//
|
||||
// @Nullable
|
||||
// @Override
|
||||
// public ExposureEvent getEventByPosition(int pos) {
|
||||
// return gameList.get(pos).getExposureEvent();
|
||||
// }
|
||||
//
|
||||
// @Nullable
|
||||
// @Override
|
||||
// public List<ExposureEvent> getEventListByPosition(int pos) {
|
||||
// return null;
|
||||
// }
|
||||
//}
|
||||
@ -25,6 +25,7 @@ import com.gh.gamecenter.databinding.FragmentMyGameBinding
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.GameInstall
|
||||
import com.gh.gamecenter.eventbus.EBDownloadStatus
|
||||
import com.gh.gamecenter.eventbus.EBPackage
|
||||
import com.gh.gamecenter.fragment.MainWrapperFragment
|
||||
import com.gh.gamecenter.manager.PackagesManager
|
||||
import com.gh.gamecenter.packagehelper.PackageRepository
|
||||
@ -46,8 +47,6 @@ class NewInstalledGameFragment : ToolbarFragment() {
|
||||
private var mSkeleton: ViewSkeletonScreen? = null
|
||||
private var mItemDecoration: VerticalItemDecoration? = null
|
||||
|
||||
private var isEverpause = false
|
||||
|
||||
private val dataWatcher = object : DataWatcher() {
|
||||
override fun onDataChanged(downloadEntity: DownloadEntity) {
|
||||
if (downloadEntity.status == DownloadStatus.done && downloadEntity.isSimulatorGame()) {
|
||||
@ -135,7 +134,6 @@ class NewInstalledGameFragment : ToolbarFragment() {
|
||||
}
|
||||
|
||||
private fun updateNoDataView() {
|
||||
|
||||
val layoutParam = mBinding.reuseNoneData.reuseResetLoadTv.layoutParams
|
||||
layoutParam.width = DisplayUtils.dip2px(150F)
|
||||
mBinding.reuseNoneData.reuseResetLoadTv.layoutParams = layoutParam
|
||||
@ -179,30 +177,12 @@ class NewInstalledGameFragment : ToolbarFragment() {
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
val gameList = mInstallGameViewModel.gameListLiveData.value
|
||||
if (isEverpause && !gameList.isNullOrEmpty()) {
|
||||
for (entity in gameList) {
|
||||
entity.setEntryMap(
|
||||
DownloadManager.getInstance().getEntryMap(entity.name)
|
||||
)
|
||||
}
|
||||
mInstallGameViewModel.gameListLiveData.postValue(gameList)
|
||||
}
|
||||
if (isEverpause) {
|
||||
mInstallGameViewModel.initData(
|
||||
PackagesManager.filterSameApk(
|
||||
PackagesManager.filterDownloadBlackPackage(mPackageViewModel?.getGameInstalledLiveData()?.value as MutableList<GameInstall>?)
|
||||
)
|
||||
)
|
||||
}
|
||||
isEverpause = false
|
||||
DownloadManager.getInstance().addObserver(dataWatcher)
|
||||
updateNoDataView()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
isEverpause = true
|
||||
DownloadManager.getInstance().removeObserver(dataWatcher)
|
||||
}
|
||||
|
||||
@ -234,6 +214,17 @@ class NewInstalledGameFragment : ToolbarFragment() {
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onEventMainThread(packageEb: EBPackage) {
|
||||
if (packageEb.isInstalledOrUninstalled()) {
|
||||
mInstallGameViewModel.initData(
|
||||
PackagesManager.filterSameApk(
|
||||
PackagesManager.filterDownloadBlackPackage(mPackageViewModel?.getGameInstalledLiveData()?.value as MutableList<GameInstall>?)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDarkModeChanged() {
|
||||
super.onDarkModeChanged()
|
||||
mBinding.root.setBackgroundColor(R.color.background.toColor(requireContext()))
|
||||
|
||||
@ -1,29 +1,27 @@
|
||||
package com.gh.gamecenter.download
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.graphics.Color
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.setPadding
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.gamecenter.core.utils.CurrentActivityHolder
|
||||
import com.gh.common.exposure.ExposureEvent
|
||||
import com.gh.common.exposure.ExposureEvent.Companion.createEvent
|
||||
import com.gh.common.exposure.ExposureSource
|
||||
import com.gh.common.exposure.IExposable
|
||||
import com.gh.common.util.*
|
||||
import com.gh.common.util.DialogUtils
|
||||
import com.gh.gamecenter.common.view.BugFixedPopupWindow
|
||||
import com.gh.common.view.DownloadButton
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.download.dialog.DownloadDialog
|
||||
import com.gh.gamecenter.DownloadManagerActivity
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.common.view.BugFixedPopupWindow
|
||||
import com.gh.gamecenter.core.utils.CurrentActivityHolder
|
||||
import com.gh.gamecenter.databinding.*
|
||||
import com.gh.gamecenter.entity.GameUpdateEntity
|
||||
import com.gh.gamecenter.eventbus.EBSkip
|
||||
@ -44,7 +42,23 @@ class UpdatableGameAdapter(private var mViewModel: UpdatableGameViewModel) :
|
||||
}
|
||||
}
|
||||
|
||||
val positionAndPackageMap = HashMap<String, Int>()
|
||||
|
||||
fun submitList(dataList: ArrayList<UpdatableGameViewModel.UpdatableDataItem>) {
|
||||
positionAndPackageMap.clear()
|
||||
// 记录游戏位置
|
||||
if (dataList.isNotEmpty()) {
|
||||
for (i in 0 until dataList.size) {
|
||||
val entity = dataList[i].normalUpdate
|
||||
?: dataList[i].normalUpdateWithArrow
|
||||
?: dataList[i].otherVersionUpdate
|
||||
?: dataList[i].ignoredUpdate
|
||||
if (entity != null) {
|
||||
val packages = entity.id + entity.packageName
|
||||
positionAndPackageMap[packages + i] = i
|
||||
}
|
||||
}
|
||||
}
|
||||
mItemList = dataList
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
@ -98,26 +112,18 @@ class UpdatableGameAdapter(private var mViewModel: UpdatableGameViewModel) :
|
||||
if (itemData.header != null) {
|
||||
holder.binding.infoTv.setTextColor(R.color.text_title.toColor(mContext))
|
||||
holder.binding.root.setOnClickListener(null)
|
||||
holder.binding.infoTv.setCompoundDrawablesWithIntrinsicBounds(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
)
|
||||
holder.binding.infoTv.removeDrawable()
|
||||
} else {
|
||||
holder.binding.infoTv.setTextColor(R.color.text_subtitleDesc.toColor(mContext))
|
||||
holder.binding.root.setOnClickListener {
|
||||
mViewModel.toggleIgnoredUpdateVisibility()
|
||||
}
|
||||
holder.binding.infoTv.setCompoundDrawablesWithIntrinsicBounds(
|
||||
null,
|
||||
null,
|
||||
holder.binding.infoTv.setDrawableEnd(
|
||||
if (mViewModel.isIgnoredUpdateExpanded()) {
|
||||
R.drawable.ic_arrow_up_grey.toDrawable()
|
||||
} else {
|
||||
R.drawable.ic_arrow_down_grey.toDrawable()
|
||||
},
|
||||
null
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -187,19 +193,9 @@ class UpdatableGameAdapter(private var mViewModel: UpdatableGameViewModel) :
|
||||
mViewModel.toggleOtherVersionVisibility(itemData.miscPackageName)
|
||||
}
|
||||
if (itemData.otherVersionUpdateHint == true) {
|
||||
holder.binding.selectorTv.setCompoundDrawablesWithIntrinsicBounds(
|
||||
null,
|
||||
null,
|
||||
R.drawable.ic_arrow_up_blue.toDrawable(),
|
||||
null
|
||||
)
|
||||
holder.binding.selectorTv.setDrawableEnd(R.drawable.ic_arrow_up_blue)
|
||||
} else {
|
||||
holder.binding.selectorTv.setCompoundDrawablesWithIntrinsicBounds(
|
||||
null,
|
||||
null,
|
||||
R.drawable.ic_arrow_down_blue.toDrawable(),
|
||||
null
|
||||
)
|
||||
holder.binding.selectorTv.setDrawableEnd(R.drawable.ic_arrow_down_blue)
|
||||
}
|
||||
holder.binding.closeHintTv.enlargeTouchArea()
|
||||
holder.binding.closeHintTv.setOnClickListener {
|
||||
@ -280,7 +276,7 @@ class UpdatableGameAdapter(private var mViewModel: UpdatableGameViewModel) :
|
||||
}
|
||||
|
||||
private fun updateUpdateBtn(
|
||||
updateBtn: TextView,
|
||||
updateBtn: DownloadButton,
|
||||
downloadEntity: DownloadEntity?,
|
||||
update: GameUpdateEntity,
|
||||
pluginDesc: String,
|
||||
@ -289,55 +285,50 @@ class UpdatableGameAdapter(private var mViewModel: UpdatableGameViewModel) :
|
||||
if (downloadEntity == null) {
|
||||
if (PackagesManager.isCanUpdate(update.id, update.packageName)) {
|
||||
updateBtn.setText(R.string.update)
|
||||
updateBtn.setTextColor(Color.WHITE)
|
||||
updateBtn.setBackgroundResource(R.drawable.download_button_normal_style)
|
||||
updateBtn.buttonStyle = DownloadButton.ButtonStyle.NORMAL
|
||||
} else if (update.isPluggable) {
|
||||
updateBtn.text = "${pluginDesc}化"
|
||||
updateBtn.setTextColor(Color.WHITE)
|
||||
val samePackageNameDownloadEntity =
|
||||
downloadManager.getDownloadEntityByPackageName(update.packageName)
|
||||
if (samePackageNameDownloadEntity == null || samePackageNameDownloadEntity.url == update.url) {
|
||||
updateBtn.isClickable = true
|
||||
updateBtn.setBackgroundResource(R.drawable.download_button_pluggable_style)
|
||||
updateBtn.buttonStyle = DownloadButton.ButtonStyle.PLUGIN
|
||||
} else {
|
||||
updateBtn.isClickable = false
|
||||
updateBtn.buttonStyle = DownloadButton.ButtonStyle.PLUGIN
|
||||
updateBtn.setBackgroundResource(R.drawable.game_item_btn_pause_up)
|
||||
}
|
||||
} else {
|
||||
updateBtn.setText(R.string.launch)
|
||||
updateBtn.setTextColor(Color.WHITE)
|
||||
updateBtn.setBackgroundResource(R.drawable.download_button_normal_style)
|
||||
updateBtn.buttonStyle = DownloadButton.ButtonStyle.LAUNCH_OR_OPEN
|
||||
}
|
||||
} else {
|
||||
if (update.isPluggable) {
|
||||
if (downloadEntity.status == DownloadStatus.done) {
|
||||
updateBtn.setText(R.string.install)
|
||||
updateBtn.setTextColor(Color.WHITE)
|
||||
updateBtn.setBackgroundResource(R.drawable.download_button_pluggable_style)
|
||||
} else {
|
||||
updateBtn.setText(R.string.downloading)
|
||||
updateBtn.setTextColor(
|
||||
ContextCompat.getColorStateList(
|
||||
updateBtn.context,
|
||||
R.color.text_downloading_style
|
||||
)
|
||||
)
|
||||
updateBtn.setBackgroundResource(R.drawable.game_item_btn_downloading_style)
|
||||
when (downloadEntity.status) {
|
||||
DownloadStatus.downloading -> {
|
||||
updateBtn.text = "${downloadEntity.percent}%"
|
||||
updateBtn.buttonStyle =
|
||||
if (update.isPluggable) DownloadButton.ButtonStyle.DOWNLOADING_PLUGIN else DownloadButton.ButtonStyle.DOWNLOADING_NORMAL
|
||||
updateBtn.progress = (downloadEntity.percent * 10).toInt()
|
||||
}
|
||||
} else {
|
||||
if (downloadEntity.status == DownloadStatus.done) {
|
||||
DownloadStatus.waiting -> {
|
||||
updateBtn.setText(R.string.waiting)
|
||||
updateBtn.buttonStyle = DownloadButton.ButtonStyle.WAITING
|
||||
}
|
||||
DownloadStatus.timeout,
|
||||
DownloadStatus.neterror,
|
||||
DownloadStatus.subscribe,
|
||||
DownloadStatus.overflow,
|
||||
DownloadStatus.pause -> {
|
||||
updateBtn.setText(R.string.resume)
|
||||
updateBtn.buttonStyle = DownloadButton.ButtonStyle.NORMAL
|
||||
}
|
||||
DownloadStatus.done -> {
|
||||
updateBtn.setText(R.string.install)
|
||||
updateBtn.setTextColor(Color.WHITE)
|
||||
updateBtn.setBackgroundResource(R.drawable.download_button_normal_style)
|
||||
} else {
|
||||
updateBtn.setText(R.string.downloading)
|
||||
updateBtn.setTextColor(
|
||||
ContextCompat.getColorStateList(
|
||||
updateBtn.context,
|
||||
R.color.text_downloading_style
|
||||
)
|
||||
)
|
||||
updateBtn.setBackgroundResource(R.drawable.game_item_btn_downloading_style)
|
||||
updateBtn.buttonStyle =
|
||||
if (update.isPluggable) DownloadButton.ButtonStyle.INSTALL_PLUGIN else DownloadButton.ButtonStyle.INSTALL_NORMAL
|
||||
}
|
||||
else -> {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -363,24 +354,14 @@ class UpdatableGameAdapter(private var mViewModel: UpdatableGameViewModel) :
|
||||
)
|
||||
return@checkDownload
|
||||
} else {
|
||||
updateBtn.setText(R.string.downloading)
|
||||
updateBtn.setTextColor(
|
||||
ContextCompat.getColorStateList(
|
||||
updateBtn.context,
|
||||
R.color.text_plugining_style
|
||||
)
|
||||
)
|
||||
updateBtn.setBackgroundResource(R.drawable.game_item_btn_plugining_style)
|
||||
updateBtn.text = "0%"
|
||||
updateBtn.buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_PLUGIN
|
||||
updateBtn.progress = 0
|
||||
}
|
||||
} else {
|
||||
updateBtn.setText(R.string.downloading)
|
||||
updateBtn.setTextColor(
|
||||
ContextCompat.getColorStateList(
|
||||
updateBtn.context,
|
||||
R.color.text_downloading_style
|
||||
)
|
||||
)
|
||||
updateBtn.setBackgroundResource(R.drawable.game_item_btn_downloading_style)
|
||||
updateBtn.text = "0%"
|
||||
updateBtn.buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_NORMAL
|
||||
updateBtn.progress = 0
|
||||
}
|
||||
|
||||
mViewModel.update(update, isSubscribe)
|
||||
@ -396,20 +377,25 @@ class UpdatableGameAdapter(private var mViewModel: UpdatableGameViewModel) :
|
||||
}
|
||||
} else if (updateBtn.context.getString(R.string.launch) == str) {
|
||||
PackageUtils.launchApplicationByPackageName(updateBtn.context, update.packageName)
|
||||
} else if (updateBtn.context.getString(R.string.downloading) == str) {
|
||||
mViewModel.refreshList()
|
||||
EventBus.getDefault().post(
|
||||
EBSkip(
|
||||
DownloadManagerActivity.TAG,
|
||||
DownloadManagerActivity.INDEX_DOWNLOAD
|
||||
)
|
||||
)
|
||||
} else if (updateBtn.context.getString(R.string.resume) == str) {
|
||||
if (downloadEntity != null) {
|
||||
DownloadManager.getInstance().resume(downloadEntity, true)
|
||||
updateBtn.text = "${downloadEntity.percent}%"
|
||||
updateBtn.buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_NORMAL
|
||||
updateBtn.progress = (downloadEntity.percent * 10).toInt()
|
||||
}
|
||||
} else if (updateBtn.context.getString(R.string.install) == str) {
|
||||
PackageInstaller.install(
|
||||
updateBtn.context,
|
||||
DownloadManager.getInstance()
|
||||
.getDownloadEntityByUrl(update.url)
|
||||
)
|
||||
} else {
|
||||
if (downloadEntity != null) {
|
||||
DownloadManager.getInstance().pause(downloadEntity.url)
|
||||
updateBtn.setText(R.string.resume)
|
||||
updateBtn.buttonStyle = DownloadButton.ButtonStyle.NORMAL
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -419,6 +405,17 @@ class UpdatableGameAdapter(private var mViewModel: UpdatableGameViewModel) :
|
||||
createEvent(updateEntity.transformGameEntity(), mExposureSource)
|
||||
}
|
||||
|
||||
fun notifyItemByDownload(download: DownloadEntity) {
|
||||
for (key in positionAndPackageMap.keys) {
|
||||
if (key.contains(download.packageName) && key.contains(download.gameId)) {
|
||||
val position = positionAndPackageMap[key]
|
||||
if (position != null && mItemList != null && position < (mItemList?.size ?: 0)) {
|
||||
notifyItemChanged(position)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TYPE_DIVIDER = 233
|
||||
const val TYPE_HEADER = 234
|
||||
|
||||
@ -2,6 +2,7 @@ package com.gh.gamecenter.download
|
||||
|
||||
import android.view.View
|
||||
import com.gh.common.exposure.ExposureListener
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.MainActivity
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.fragment.LazyFragment
|
||||
@ -16,6 +17,8 @@ import com.gh.gamecenter.eventbus.EBDownloadStatus
|
||||
import com.gh.gamecenter.fragment.MainWrapperFragment
|
||||
import com.gh.gamecenter.packagehelper.PackageRepository
|
||||
import com.gh.gamecenter.packagehelper.PackageViewModel
|
||||
import com.lightgame.download.DataWatcher
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
@ -26,6 +29,17 @@ class UpdatableGameFragment : LazyFragment() {
|
||||
private var mBinding: FragmentGameUpdatableBinding? = null
|
||||
private var mAdapter: UpdatableGameAdapter? = null
|
||||
|
||||
private val dataWatcher = object : DataWatcher() {
|
||||
override fun onDataChanged(downloadEntity: DownloadEntity) {
|
||||
mAdapter?.notifyItemByDownload(downloadEntity)
|
||||
}
|
||||
|
||||
override fun onDataInit(downloadEntity: DownloadEntity) {
|
||||
mAdapter?.notifyItemByDownload(downloadEntity)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun getRealLayoutId() = R.layout.fragment_game_updatable
|
||||
override fun onRealLayoutInflated(inflatedView: View) {
|
||||
mBinding = FragmentGameUpdatableBinding.bind(inflatedView)
|
||||
@ -52,15 +66,21 @@ class UpdatableGameFragment : LazyFragment() {
|
||||
|
||||
override fun onFragmentResume() {
|
||||
super.onFragmentResume()
|
||||
|
||||
DownloadManager.getInstance().addObserver(dataWatcher)
|
||||
updateNoDataView()
|
||||
}
|
||||
|
||||
override fun onFragmentPause() {
|
||||
super.onFragmentPause()
|
||||
DownloadManager.getInstance().removeObserver(dataWatcher)
|
||||
}
|
||||
|
||||
override fun initRealView() {
|
||||
super.initRealView()
|
||||
|
||||
mBinding?.run {
|
||||
mAdapter = UpdatableGameAdapter(mViewModel!!)
|
||||
recyclerView.itemAnimator = null
|
||||
recyclerView.layoutManager = FixLinearLayoutManager(requireContext())
|
||||
recyclerView.adapter = mAdapter?.also {
|
||||
recyclerView.addOnScrollListener(ExposureListener(this@UpdatableGameFragment, it))
|
||||
|
||||
@ -32,6 +32,10 @@ data class AmwayCommentEntity(
|
||||
@SerializedName("new_star")
|
||||
var star: Float,
|
||||
|
||||
var subtitle: String? = "",
|
||||
@SerializedName("subtitle_style")
|
||||
var subtitleStyle: TagStyleEntity? = null,
|
||||
|
||||
// 曝光用的位置
|
||||
var sequence: Int = 0,
|
||||
var outerSequence: Int = 0
|
||||
@ -50,6 +54,9 @@ data class AmwayCommentEntity(
|
||||
gameEntity.iconSubscript = iconSubscript
|
||||
gameEntity.platform = ""
|
||||
|
||||
gameEntity.subtitle = subtitle ?: ""
|
||||
gameEntity.subtitleStyle = subtitleStyle
|
||||
|
||||
gameEntity.sequence = sequence
|
||||
gameEntity.outerSequence = outerSequence
|
||||
return gameEntity
|
||||
|
||||
40
app/src/main/java/com/gh/gamecenter/entity/ArchiveEntity.kt
Normal file
40
app/src/main/java/com/gh/gamecenter/entity/ArchiveEntity.kt
Normal file
@ -0,0 +1,40 @@
|
||||
package com.gh.gamecenter.entity
|
||||
|
||||
import android.os.Parcelable
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class ArchiveEntity(
|
||||
@SerializedName("_id")
|
||||
var id: String = "",
|
||||
var name: String = "",
|
||||
var desc: String = "",
|
||||
var url: String = "",
|
||||
@SerializedName("config_url")
|
||||
var configUrl: String = "",
|
||||
var md5: String = "",
|
||||
@SerializedName("game_version")
|
||||
var gameVersion: String = "",
|
||||
var count: Count = Count(),
|
||||
var time: Time = Time(),
|
||||
@SerializedName("is_shared")
|
||||
var isShared: Boolean = false,
|
||||
var user: UserEntity = UserEntity(),
|
||||
|
||||
// 本地字段
|
||||
@SerializedName("game_id")
|
||||
var gameId: String = ""
|
||||
) : Parcelable {
|
||||
|
||||
@Parcelize
|
||||
data class Count(
|
||||
var usage: Int = 0,
|
||||
) : Parcelable
|
||||
|
||||
@Parcelize
|
||||
data class Time(
|
||||
var create: Long = 0L,
|
||||
var update: Long = 0L,
|
||||
) : Parcelable
|
||||
}
|
||||
@ -308,6 +308,10 @@ data class GameEntity(
|
||||
|
||||
// 游戏分类,用于埋点使用
|
||||
var gameType: String = "",
|
||||
//游戏存档 需要使用
|
||||
var configUrl: String = "",
|
||||
//是否广告,用于曝光使用
|
||||
var isAdData: Boolean = false
|
||||
) : Parcelable {
|
||||
|
||||
constructor(id: String?) : this() {
|
||||
@ -612,6 +616,18 @@ data class GameEntity(
|
||||
}
|
||||
}
|
||||
|
||||
fun isUseDefaultServerStyle(): Boolean {
|
||||
return if (serverLabel == null) {
|
||||
false
|
||||
} else {
|
||||
serverLabel?.value == "公测"
|
||||
|| serverLabel?.value == "不删档内测"
|
||||
|| serverLabel?.value == "删档内测"
|
||||
|| serverLabel?.value == "即将开测"
|
||||
|| serverLabel?.value == "明日开测"
|
||||
}
|
||||
}
|
||||
|
||||
fun isSpecialDownload() = RegionSettingHelper.shouldThisGameShowSpecialDownload(id)
|
||||
|
||||
fun toSimpleGame(): SimpleGame {
|
||||
@ -680,6 +696,8 @@ data class GameEntity(
|
||||
gameEntity.simulatorType = simulatorType
|
||||
gameEntity.displayContent = displayContent
|
||||
gameEntity.isPlatformRecommend = isPlatformRecommend
|
||||
gameEntity.adIconActive = adIconActive
|
||||
gameEntity.isAdData = isAdData
|
||||
return gameEntity
|
||||
}
|
||||
|
||||
@ -876,7 +894,11 @@ data class SimpleGame(
|
||||
@SerializedName("recommend_text")
|
||||
var recommendText: String = "",
|
||||
@SerializedName("download_status")
|
||||
var downloadStatus: String = ""
|
||||
var downloadStatus: String = "",
|
||||
|
||||
var subtitle: String? = "",
|
||||
@SerializedName("subtitle_style")
|
||||
var subtitleStyle: TagStyleEntity? = null,
|
||||
) : Parcelable {
|
||||
|
||||
@IgnoredOnParcel
|
||||
@ -902,6 +924,8 @@ data class SimpleGame(
|
||||
gameEntity.recommendStar = recommendStar
|
||||
gameEntity.recommendText = recommendText
|
||||
gameEntity.downloadStatus = downloadStatus
|
||||
gameEntity.subtitle = subtitle ?: ""
|
||||
gameEntity.subtitleStyle = subtitleStyle
|
||||
return gameEntity
|
||||
}
|
||||
|
||||
|
||||
@ -16,6 +16,9 @@ data class HistoryGameEntity(
|
||||
var tag: ArrayList<String>? = null,
|
||||
var isLibaoExist: Boolean = false,
|
||||
|
||||
var subtitle: String = "",
|
||||
var subtitleStyle: TagStyleEntity? = null,
|
||||
|
||||
@SerializedName("tag_style")
|
||||
var tagStyle: ArrayList<TagStyleEntity> = ArrayList(),
|
||||
|
||||
@ -31,6 +34,8 @@ data class HistoryGameEntity(
|
||||
gameEntity.des = des
|
||||
gameEntity.rawIcon = icon
|
||||
gameEntity.iconSubscript = iconSubscript
|
||||
gameEntity.subtitle = subtitle
|
||||
gameEntity.subtitleStyle = subtitleStyle
|
||||
gameEntity.name = name
|
||||
gameEntity.tagStyle = tagStyle
|
||||
gameEntity.isLibaoExists = isLibaoExist
|
||||
|
||||
@ -30,4 +30,6 @@ data class HomeContent(
|
||||
val secondLineRecommend: String = "",
|
||||
@SerializedName("recommend_tag")
|
||||
val recommendTag: String = "",
|
||||
@SerializedName("ad_icon_active")
|
||||
val adIconActive: Boolean = false,
|
||||
)
|
||||
@ -35,11 +35,24 @@ data class LibaoEntity(
|
||||
var expires: Int = 0,//过期时间
|
||||
@SerializedName("libao_active")
|
||||
var libaoActive: Boolean = false,//后台礼包是否被隐藏
|
||||
@SerializedName("receive_limit")
|
||||
var receiveLimit: String = "", //领取限制,暂时只有"通过活动自动发放"->“activity_grant”
|
||||
@SerializedName("activity_link")
|
||||
var activityLink: ActivityLink = ActivityLink(), //关联活动链接数据
|
||||
@SerializedName("app_and_plugin_hide")
|
||||
var appAndPluginHide: Boolean = false, //app和插件内不显示
|
||||
|
||||
//本地字段
|
||||
var clickReceiveBtnIn: Boolean = false//是否是点击列表领取按钮进入
|
||||
) : Parcelable {
|
||||
|
||||
@Parcelize
|
||||
data class ActivityLink(
|
||||
var link: String = "",
|
||||
var text: String = "",
|
||||
var url: String = ""
|
||||
) : Parcelable
|
||||
|
||||
fun getIcon(): String {
|
||||
return if (game != null) {
|
||||
game!!.getIcon()
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user