Compare commits
545 Commits
feature-is
...
v5.17.4-69
| Author | SHA1 | Date | |
|---|---|---|---|
| e20df1e0fb | |||
| f60c907978 | |||
| 3f21d7d37c | |||
| e622d6a8ee | |||
| e911588569 | |||
| 8b1c046475 | |||
| 984a1ba517 | |||
| a337494d22 | |||
| 6c5f9f2689 | |||
| 7ad73b84f9 | |||
| ad683b66d7 | |||
| fb719577cf | |||
| 7770f16565 | |||
| 43fdd0d8d3 | |||
| 0067ef2c40 | |||
| 03a7f2bd89 | |||
| 07d4865593 | |||
| ba49c9aa25 | |||
| f19a687eee | |||
| 3fbec365a0 | |||
| d1dba07b6b | |||
| a53239afd8 | |||
| 26f2b161bd | |||
| 8b28b8de44 | |||
| 81ab27d02a | |||
| 544c67c316 | |||
| fbd61f3783 | |||
| 5f4c0ab2df | |||
| ff245ad516 | |||
| 315523a27f | |||
| a3ae5ecb7b | |||
| dfc7c918d7 | |||
| d396deb94b | |||
| 52bf1a85c5 | |||
| 762bed1ed5 | |||
| 7d77ca9b35 | |||
| cd7e3c7777 | |||
| 44c6c5ad08 | |||
| fca02bcb0b | |||
| a4d3368567 | |||
| 210f2240a3 | |||
| a6a2012e66 | |||
| d5ef24b1cc | |||
| 92b658c304 | |||
| 8271126bf9 | |||
| 13bc07b0be | |||
| e19fcf5077 | |||
| dba49b090a | |||
| b964472619 | |||
| 733be9e441 | |||
| c9d4bfadcf | |||
| cd54c0967c | |||
| d2bf534ca4 | |||
| ff350e268a | |||
| 79cd610e41 | |||
| 4af47a71b7 | |||
| 9fed52ca0a | |||
| f3c0e16cff | |||
| 0ee5c106c6 | |||
| abc52f622c | |||
| 8ba82698d7 | |||
| e74e700bcf | |||
| abb4c40499 | |||
| df79970eae | |||
| d8775429d1 | |||
| 7fd7ac3523 | |||
| 1729f3d688 | |||
| 5c1498a8fd | |||
| 9268181751 | |||
| 2d97319931 | |||
| 9930673792 | |||
| d7219431e6 | |||
| d9311fcce0 | |||
| 88035b65ce | |||
| e63e50f828 | |||
| e080d8ab6d | |||
| 1dacab2000 | |||
| 754750a330 | |||
| 401f1c176a | |||
| b10fac1371 | |||
| f750682bff | |||
| c7094a0476 | |||
| f8cedcf737 | |||
| d1e04a5743 | |||
| 4659ebe064 | |||
| 9eded4d0ce | |||
| e93d95dc0d | |||
| 5a7c316a2d | |||
| f55448a264 | |||
| 1c20bf9e02 | |||
| 69cb4865b2 | |||
| d5e9e9f092 | |||
| 20a60fb2b5 | |||
| deac181261 | |||
| 5a4eb2ed65 | |||
| 634e897511 | |||
| 305c6792f2 | |||
| 0ae726d6b1 | |||
| 6be4412ac6 | |||
| 586e3deb9e | |||
| f02219b83b | |||
| 1391ab730d | |||
| 9eca2ab660 | |||
| b58daea96f | |||
| f958787f9e | |||
| 5fbeff3158 | |||
| c03fcc7fde | |||
| ce4c6c1ca3 | |||
| 1294a13933 | |||
| 1b07c28956 | |||
| c0b2eb622c | |||
| c4bed719f9 | |||
| d022f03ef8 | |||
| 7ab8f2c4c5 | |||
| 4f0480c7b4 | |||
| 12818c322c | |||
| 92f08d1bb8 | |||
| db5fbded43 | |||
| e554b1681e | |||
| 8ae846df88 | |||
| 10e7047eec | |||
| 32eefa9003 | |||
| f95b091c58 | |||
| e810369ee2 | |||
| b090e7863f | |||
| 1fb27ab467 | |||
| 772abccae5 | |||
| b64bb8bcd8 | |||
| 699f55313c | |||
| 32b51e899e | |||
| 719caf99cd | |||
| ac49180f98 | |||
| 356acc053e | |||
| 78366cd647 | |||
| 926e917a1a | |||
| b5eb376055 | |||
| 4a321a6884 | |||
| 208ee23676 | |||
| a3f6464b1a | |||
| 8d4fbed5d9 | |||
| 93a8c24ad3 | |||
| 4014572130 | |||
| 3bf6a6eaf3 | |||
| 6397b4cfdd | |||
| 544e9458ee | |||
| 1b5b19fa76 | |||
| 00436dd3b9 | |||
| 64b4a6bef0 | |||
| b330ccc54d | |||
| 7f460ac3df | |||
| 19fa7436c3 | |||
| 9a5e529eeb | |||
| faac45e719 | |||
| 17e4624909 | |||
| 6cf3786799 | |||
| d6e713fd60 | |||
| 830715f44b | |||
| 73470771fe | |||
| b62ce00f7a | |||
| 963f7f9ee0 | |||
| 5c606f8eb3 | |||
| 6fed28da75 | |||
| 823060320f | |||
| d0bf32db06 | |||
| d7fb0c86bb | |||
| c69ececcb7 | |||
| ec4eeb0219 | |||
| 35aabd0fd3 | |||
| e626eb193f | |||
| 51d42c96d3 | |||
| ea32d5a798 | |||
| 59a5ea9600 | |||
| 8ff62a9f5e | |||
| 203c8db840 | |||
| 90ab76aa48 | |||
| f1e3a21191 | |||
| cae48cb2b7 | |||
| b91fa853ca | |||
| 0f0900033c | |||
| 4fbc80ca38 | |||
| 7fbe32d2af | |||
| 988b931170 | |||
| 50acd6998e | |||
| 84faf3e0d5 | |||
| d84c1f1f25 | |||
| 52b6a429bc | |||
| 6492b41ad1 | |||
| 3e4faca388 | |||
| 15b3f7df2a | |||
| 937109224c | |||
| cd1609a3ef | |||
| 4fd9c7b36e | |||
| 2bd8e0f96b | |||
| 2d64f19f98 | |||
| 15de55ceae | |||
| 2316bd1e18 | |||
| 6a4726650c | |||
| e79e6f8ec8 | |||
| 894d962836 | |||
| f48767c4bf | |||
| b5a64d1c36 | |||
| fb4936a553 | |||
| 001d062207 | |||
| d4b1b822f4 | |||
| 732765118e | |||
| eeacae1fd2 | |||
| e982ae9125 | |||
| a7ee0c754b | |||
| b042b3433d | |||
| 8ba70f4a7d | |||
| 094a85bfa4 | |||
| 54f0fa8dd8 | |||
| 30f4bcc422 | |||
| 39820b2c8a | |||
| 1f331a20fa | |||
| ad58699d2f | |||
| ecb73f9636 | |||
| 55e80c00de | |||
| 172b8cfa4c | |||
| bf6b1f05b0 | |||
| 5e69aa2362 | |||
| 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 | |||
| b0ad6ff8c5 | |||
| ccbe6650d1 | |||
| f99b3af9c6 | |||
| e80c8d76cd | |||
| f47b0326f4 | |||
| a5ce8f389c | |||
| 8f5daed7a7 | |||
| a1aada02d6 | |||
| 659469aabc | |||
| 9ee743c14f | |||
| 8be8430543 | |||
| de2c0dc0c3 | |||
| e961642cf7 | |||
| fb8bd8b440 | |||
| ed19677568 | |||
| c4cf232d35 | |||
| 5fe552ad91 | |||
| 1db87a4152 | |||
| 1bd741be9c | |||
| 7570e3e14e | |||
| ca009fb1b2 | |||
| 872ac7bb85 | |||
| 8ce13fd0db | |||
| 3ae27ebdb6 | |||
| aab422662a | |||
| bb80862d19 | |||
| 02eea04cdc | |||
| 133b3aec96 | |||
| 4b974e3278 | |||
| 8193b9ec9f | |||
| 13929f4dc5 | |||
| 0ea0834140 | |||
| 927e0e2468 | |||
| be3d509c9c | |||
| 40bd4a1adf | |||
| b6bb3bf794 | |||
| ef6ef5c584 | |||
| a600a9f0b0 | |||
| 31d0ce1302 | |||
| bffa36bc5d | |||
| 716a32a2b5 | |||
| 70c09648a8 | |||
| a7cdade878 | |||
| b479048a87 | |||
| 714d975602 | |||
| a363090e4e | |||
| f07b37ff01 | |||
| d0efdccb1d | |||
| 7efdb5e432 | |||
| e5d73e5c73 | |||
| e2f5de67a7 | |||
| c34cacb5d0 | |||
| 681ba37c4e | |||
| d4d71d27ce | |||
| 609b2805cc | |||
| 987ab1ccc9 | |||
| 93a77df0dc | |||
| e1c365ffe5 | |||
| 8863b02c7a | |||
| 89b97d274b | |||
| bbe3f9c741 | |||
| e7d0c15a0a | |||
| ddfb474624 | |||
| b15b8c1237 | |||
| 0af8660b14 | |||
| 4ea2f8d5af | |||
| 66c727c874 | |||
| 619abb9805 | |||
| a94bb4dcb5 | |||
| 195d9343eb | |||
| 5a847970b2 | |||
| ccd70b6087 | |||
| bd9fea1551 | |||
| f8c7bf5f64 | |||
| 7b71adc3fa | |||
| 1882707e56 | |||
| 49cafeb8bd | |||
| 072cf65af4 | |||
| 2f7277e410 | |||
| f10a88a5a4 | |||
| 45b5030ab5 | |||
| fa35d98d5b | |||
| d4e79a7b47 | |||
| d9fb9bcc2f | |||
| 13f7ca9f7d | |||
| cabe3055cb | |||
| 64e45521a6 | |||
| b6d035f3a9 | |||
| 313ed74939 | |||
| c79e5edc7a | |||
| b4ccdcb8fa | |||
| 1ed50c2626 | |||
| 7ad6395bab | |||
| 28d2a9442c | |||
| 997bfdf93d | |||
| 8eceb571ca | |||
| 68f8619d09 | |||
| de712065f5 | |||
| 511449c709 | |||
| e79d5d1dfb | |||
| da8717693d | |||
| 03095b682b | |||
| 8437bfe1e3 | |||
| a169ce1989 | |||
| c327fcaf99 | |||
| b032f054f9 | |||
| 9690429e95 | |||
| b1dff15234 |
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,6 +269,9 @@ dependencies {
|
||||
implementation(project(':module_login')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
implementation(project(':module_setting')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
// 默认不接入光能模块,提高编译速度
|
||||
// debugImplementation(project(':module_energy')) {
|
||||
// exclude group: 'androidx.swiperefreshlayout'
|
||||
@ -391,7 +395,6 @@ andResGuard {
|
||||
"R.drawable.suggest_type_function_suggest",
|
||||
"R.drawable.suggest_type_article_collect",
|
||||
"R.drawable.suggest_type_copyright",
|
||||
"R.drawable.help_result_empty",
|
||||
"R.drawable.news_comment_detail_read",
|
||||
"R.drawable.news_comment_detail_comment",
|
||||
"R.drawable.news_comment_detail_share",
|
||||
|
||||
@ -1,14 +1,16 @@
|
||||
package com.gh.gamecenter.provider
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Application
|
||||
import android.text.TextUtils
|
||||
import com.gh.gamecenter.common.constant.Config
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.utils.PackageFlavorHelper
|
||||
import com.gh.gamecenter.core.provider.IFlavorProvider
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.leon.channel.helper.ChannelReaderUtil
|
||||
|
||||
class ChannelProviderImp : ChannelProvider {
|
||||
class FlavorProviderImp : IFlavorProvider {
|
||||
override fun getChannelStr(application: Application): String {
|
||||
var channel = ChannelReaderUtil.getChannel(application)
|
||||
if (channel == null || TextUtils.isEmpty(channel.trim())) {
|
||||
@ -23,4 +25,12 @@ class ChannelProviderImp : ChannelProvider {
|
||||
}
|
||||
return channel
|
||||
}
|
||||
|
||||
override fun init(application: Application, activity: Activity) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
override fun logEvent(content: String) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
@ -6,6 +6,11 @@
|
||||
<queries>
|
||||
<package android:name="com.gh.gamecenter" />
|
||||
</queries>
|
||||
|
||||
<queries>
|
||||
<package android:name="com.lg.vspace" />
|
||||
</queries>
|
||||
|
||||
<!-- 允许应用程序访问网络连接 -->
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<!-- 允许应用程序写入外部存储,如SD卡上写文件 -->
|
||||
@ -148,10 +153,6 @@
|
||||
android:name="com.gh.gamecenter.NewsDetailActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.SettingActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.ConcernActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
@ -219,18 +220,6 @@
|
||||
android:name="com.gh.gamecenter.SelectUserIconActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.AboutActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.security.SecurityActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.security.BindPhoneActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.CommentDetailActivity"
|
||||
android:screenOrientation="portrait"
|
||||
@ -344,10 +333,6 @@
|
||||
android:name="com.gh.gamecenter.amway.AmwayActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.NetworkDiagnosisActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.personalhome.fans.FansActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
@ -586,14 +571,6 @@
|
||||
android:name=".qa.video.publish.VideoPublishActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".setting.GameDownloadSettingActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".setting.VideoSettingActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".qa.video.detail.ForumVideoDetailActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
@ -733,6 +710,23 @@
|
||||
android:name=".BbsCertificationActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".discovery.DiscoveryActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".cloudarchive.CloudArchiveManagerActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".savegame.GameArchiveListActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".discovery.interestedgame.InterestedGameActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
|
||||
<!-- <activity-->
|
||||
<!-- android:name="${applicationId}.douyinapi.DouYinEntryActivity"-->
|
||||
<!-- android:launchMode="singleTask"-->
|
||||
@ -755,6 +749,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":[]}
|
||||
@ -1 +0,0 @@
|
||||
{"v":"5.6.9","fr":60,"ip":0,"op":36,"w":120,"h":66,"nm":"开关动画-关闭","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"按钮手柄","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.667,"y":1},"o":{"x":0.667,"y":0},"t":0,"s":[87,33,0],"to":[7.682,0,0],"ti":[-13.443,0,0]},{"i":{"x":0.333,"y":1},"o":{"x":0.333,"y":0},"t":18,"s":[31,33,0],"to":[2.306,0,0],"ti":[-1.318,0,0]},{"t":24,"s":[33,33,0]}],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[16,16],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"椭圆路径 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[300,300],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"椭圆形","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":37,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"指示器-on","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.667],"y":[0]},"t":0,"s":[100]},{"t":18,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[33,33,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":1,"k":[{"i":{"x":[0.667,0.667],"y":[1,1]},"o":{"x":[0.667,0.667],"y":[0,0]},"t":0,"s":[6.5,6.5]},{"t":18,"s":[4.5,4.5]}],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"椭圆路径 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[0.966666666667,0.966666666667,0.966666666667,0.420000005762],"ix":3},"o":{"a":0,"k":40,"ix":4},"w":{"a":0,"k":1.5,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"描边 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[300,300],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"椭圆形","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":37,"st":0,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"指示器-off","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[87,33,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":1,"k":[{"i":{"x":[0.667,0.667],"y":[1,1]},"o":{"x":[0.667,0.667],"y":[0,0]},"t":0,"s":[1.5,4]},{"t":18,"s":[1.5,6]}],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"r":{"a":0,"k":0.75,"ix":4},"nm":"矩形路径 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"fl","c":{"a":0,"k":[0,0,0,1],"ix":4},"o":{"a":0,"k":5,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[300,300],"ix":3},"r":{"a":0,"k":90,"ix":6},"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.667],"y":[0]},"t":0,"s":[0]},{"t":18,"s":[100]}],"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"矩形","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":37,"st":0,"bm":0},{"ddd":0,"ind":4,"ty":4,"nm":"按钮背景","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[60,33,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"sy":[{"c":{"a":0,"k":[0,0,0,1],"ix":2},"o":{"a":0,"k":5,"ix":3},"a":{"a":0,"k":120,"ix":5},"s":{"a":0,"k":1,"ix":8},"d":{"a":0,"k":0,"ix":6},"ch":{"a":0,"k":100,"ix":7},"bm":{"a":0,"k":5,"ix":1},"no":{"a":0,"k":0,"ix":9},"ty":2,"nm":"内阴影"}],"shapes":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[40,22],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"r":{"a":0,"k":12,"ix":4},"nm":"矩形路径 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"fl","c":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.667],"y":[0]},"t":0,"s":[0.141176477075,0.588235318661,1,1]},{"t":18,"s":[0.933333337307,0.933333337307,0.933333337307,1]}],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"filling","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0.118,0.006],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[300,300],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"矩形","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":37,"st":0,"bm":0}],"markers":[]}
|
||||
@ -473,14 +473,14 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
private fun chooseImage() {
|
||||
MtaHelper.onEvent(mtaEventName(), "插入图片", "插入图片")
|
||||
val imageCount = mViewModel.quoteCountEntity.imageCount
|
||||
if (imageCount >= MAX_MEDIA_COUNT) {
|
||||
if (imageCount >= MAX_IMAGE_COUNT) {
|
||||
toast(R.string.answer_edit_max_img_hint)
|
||||
return
|
||||
}
|
||||
try {
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(this, object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
val maxChooseCount = if (imageCount + 10 <= MAX_MEDIA_COUNT) 10 else MAX_MEDIA_COUNT - imageCount
|
||||
val maxChooseCount = if (imageCount + 10 <= MAX_IMAGE_COUNT) 10 else MAX_IMAGE_COUNT - imageCount
|
||||
val intent = LocalMediaActivity.getIntent(
|
||||
this@BaseRichEditorActivity,
|
||||
LocalMediaActivity.ChooseType.IMAGE,
|
||||
@ -770,6 +770,7 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
const val INSERT_VIDEO_CODE = 415
|
||||
const val MAX_INPUT_TEXT_NUM = 10000
|
||||
const val MAX_MEDIA_COUNT = 20
|
||||
const val MAX_IMAGE_COUNT = 35
|
||||
|
||||
const val REQUEST_CODE_IMAGE = 120
|
||||
const val INSERT_MEDIA_VIDEO_CODE = 121
|
||||
|
||||
@ -9,16 +9,17 @@ import android.text.TextUtils
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.MediatorLiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.gh.gamecenter.common.base.fragment.WaitingDialogFragment
|
||||
import com.gh.gamecenter.core.runOnUiThread
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.fragment.WaitingDialogFragment
|
||||
import com.gh.gamecenter.common.retrofit.Response
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.utils.*
|
||||
import com.gh.gamecenter.core.runOnUiThread
|
||||
import com.gh.gamecenter.core.utils.MD5Utils
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.entity.ErrorEntity
|
||||
import com.gh.gamecenter.entity.LocalVideoEntity
|
||||
import com.gh.gamecenter.entity.QuoteCountEntity
|
||||
import com.gh.gamecenter.qa.BbsType
|
||||
import com.gh.gamecenter.common.retrofit.Response
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.gh.gamecenter.retrofit.service.ApiService
|
||||
import com.gh.gamecenter.video.upload.OnUploadListener
|
||||
@ -32,20 +33,12 @@ import okhttp3.ResponseBody
|
||||
import retrofit2.HttpException
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.util.*
|
||||
import kotlin.collections.HashMap
|
||||
import kotlin.collections.LinkedHashMap
|
||||
import kotlin.collections.List
|
||||
import kotlin.collections.Map
|
||||
import kotlin.collections.find
|
||||
import kotlin.collections.forEach
|
||||
import kotlin.collections.set
|
||||
|
||||
// TODO: 移动到module_bbs模块
|
||||
abstract class BaseRichEditorViewModel(application: Application) : AndroidViewModel(application) {
|
||||
val mApi: ApiService = RetrofitManager.getInstance().api
|
||||
val processDialog = MediatorLiveData<WaitingDialogFragment.WaitingDialogData>()
|
||||
val uploadingImage = ArrayList<LinkedHashMap<String, String>>()
|
||||
val chooseImagesUpload = MutableLiveData<LinkedHashMap<String, String>>()
|
||||
val chooseImagesUploadSuccess = MutableLiveData<LinkedHashMap<String, String>>()
|
||||
var uploadImageSubscription: Disposable? = null
|
||||
@ -70,7 +63,10 @@ abstract class BaseRichEditorViewModel(application: Application) : AndroidViewMo
|
||||
//检查图片是否符合规则并上传图片
|
||||
fun uploadPic(data: Intent) {
|
||||
val uris = Matisse.obtainResult(data)
|
||||
val pictureList = ArrayList<String>()
|
||||
val rawImgUrlList = ArrayList<String>() // 需要上传图片的原始地址列表
|
||||
val uploadingImgList = ArrayList<String>() // 正在上传图片的地址列表(已压缩处理)
|
||||
val compressedImgUrlList = ArrayList<String>() // 压缩处理后图片的地址列表
|
||||
|
||||
for (uri in uris) {
|
||||
val picturePath = PathUtils.getPath(getApplication(), uri)
|
||||
if (picturePath != null) {
|
||||
@ -84,12 +80,12 @@ abstract class BaseRichEditorViewModel(application: Application) : AndroidViewMo
|
||||
continue
|
||||
}
|
||||
Utils.log("picturePath = $picturePath")
|
||||
pictureList.add(picturePath)
|
||||
rawImgUrlList.add(picturePath)
|
||||
} else {
|
||||
Utils.log("picturePath is null")
|
||||
}
|
||||
}
|
||||
if (pictureList.size == 0) return
|
||||
if (rawImgUrlList.size == 0) return
|
||||
val imageType = when (getRichType()) {
|
||||
RichType.ARTICLE -> UploadImageUtils.UploadType.community_article
|
||||
RichType.QUESTION -> UploadImageUtils.UploadType.question
|
||||
@ -97,7 +93,7 @@ abstract class BaseRichEditorViewModel(application: Application) : AndroidViewMo
|
||||
}
|
||||
uploadImageSubscription = UploadImageUtils.compressAndUploadImageList(
|
||||
imageType,
|
||||
pictureList,
|
||||
rawImgUrlList,
|
||||
false,
|
||||
object : UploadImageUtils.OnUploadImageListListener {
|
||||
override fun onProgress(total: Long, progress: Long) {}
|
||||
@ -107,87 +103,108 @@ abstract class BaseRichEditorViewModel(application: Application) : AndroidViewMo
|
||||
imageUrls.forEach {
|
||||
chooseImageMd5Map[MD5Utils.getUrlMD5(it)] = ""
|
||||
}
|
||||
uploadingImage.add(chooseImageMd5Map)
|
||||
uploadingImgList.addAll(imageUrls)
|
||||
compressedImgUrlList.addAll(imageUrls)
|
||||
chooseImagesUpload.postValue(chooseImageMd5Map)
|
||||
}
|
||||
|
||||
override fun onSingleSuccess(imageUrl: Map<String, String>) {
|
||||
val map = LinkedHashMap<String, String>()
|
||||
for (key in imageUrl.keys) {
|
||||
map[MD5Utils.getUrlMD5(key)] = FILE_HOST + key.decodeURI()
|
||||
mapImages[TextUtils.htmlEncode(key).decodeURI()] = imageUrl[key] ?: ""
|
||||
override fun onSingleSuccess(imageUrlMap: Map<String, String>) {
|
||||
imageUrlMap.forEach {
|
||||
if (uploadingImgList.contains(it.key)) {
|
||||
uploadingImgList.remove(it.key)
|
||||
}
|
||||
}
|
||||
chooseImagesUploadSuccess.postValue(map)
|
||||
val map = LinkedHashMap<String, String>()
|
||||
for (key in imageUrlMap.keys) {
|
||||
map[MD5Utils.getUrlMD5(key)] = FILE_HOST + key.decodeURI()
|
||||
mapImages[TextUtils.htmlEncode(key).decodeURI()] = imageUrlMap[key] ?: ""
|
||||
}
|
||||
chooseImagesUploadSuccess.value = map
|
||||
}
|
||||
|
||||
override fun onSuccess(
|
||||
imageUrl: LinkedHashMap<String, String>,
|
||||
errorMap: Map<String, Exception>
|
||||
) {
|
||||
val uploadMap = uploadingImage.find {
|
||||
it.containsKey(
|
||||
MD5Utils.getUrlMD5(
|
||||
imageUrl.entries.iterator().next().key
|
||||
)
|
||||
)
|
||||
}
|
||||
uploadMap?.let {
|
||||
uploadingImage.remove(uploadMap)
|
||||
}
|
||||
|
||||
val errorSize = pictureList.size - imageUrl.size
|
||||
if (errorSize > 0) {
|
||||
val map = LinkedHashMap<String, String>()
|
||||
for (key in errorMap.keys) {
|
||||
map[MD5Utils.getUrlMD5(key)] = ""
|
||||
override fun onSuccess(imageUrlMap: LinkedHashMap<String, String>, errorMap: Map<String, Exception>) {
|
||||
imageUrlMap.forEach {
|
||||
if (uploadingImgList.contains(it.key)) {
|
||||
uploadingImgList.remove(it.key)
|
||||
}
|
||||
//value为空会删除PlaceholderImage
|
||||
chooseImagesUploadSuccess.postValue(map)
|
||||
}
|
||||
|
||||
for (error in errorMap.values) {
|
||||
if (error is HttpException && error.code() == 403) {
|
||||
Utils.toast(getApplication(), errorSize.toString() + "张违规图片上传失败")
|
||||
return
|
||||
var errorSize = compressedImgUrlList.size - imageUrlMap.size
|
||||
if (errorSize > 0 || uploadingImgList.isNotEmpty()) {
|
||||
val errorImageMap = LinkedHashMap<String, String>()
|
||||
for (key in errorMap.keys) {
|
||||
errorImageMap[MD5Utils.getUrlMD5(key)] = ""
|
||||
}
|
||||
|
||||
for (rawImgUrl in compressedImgUrlList) {
|
||||
if (!imageUrlMap.containsKey(rawImgUrl)) {
|
||||
errorImageMap[MD5Utils.getUrlMD5(rawImgUrl)] = ""
|
||||
}
|
||||
}
|
||||
Utils.toast(getApplication(), errorSize.toString() + "张图片上传失败")
|
||||
errorSize = if (errorMap.isEmpty()) {
|
||||
errorImageMap.size
|
||||
} else {
|
||||
errorMap.size + errorImageMap.size
|
||||
}
|
||||
|
||||
// value为空会删除PlaceholderImage
|
||||
chooseImagesUploadSuccess.value = errorImageMap
|
||||
|
||||
if (handleUploadError(errorSize, errorMap)) return
|
||||
|
||||
if (errorSize > 0) {
|
||||
ToastUtils.showToast(errorSize.toString() + "张图片上传失败")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onError(errorMap: Map<String, Exception>) {
|
||||
val errorSize = errorMap.size
|
||||
if (errorSize > 0) {
|
||||
val errorSize = uploadingImgList.size
|
||||
if (uploadingImgList.size > 0) {
|
||||
val map = LinkedHashMap<String, String>()
|
||||
for (key in errorMap.keys) {
|
||||
for (key in uploadingImgList) {
|
||||
map[MD5Utils.getUrlMD5(key)] = ""
|
||||
}
|
||||
//value为空会删除PlaceholderImage
|
||||
chooseImagesUploadSuccess.postValue(map)
|
||||
// value为空会删除PlaceholderImage
|
||||
chooseImagesUploadSuccess.value = map
|
||||
}
|
||||
|
||||
for (error in errorMap.values) {
|
||||
if (error is HttpException && error.code() == 403) {
|
||||
val e = error.response()?.errorBody()?.string()?.toObject<ErrorEntity>()
|
||||
if (e != null && e.code == 403017) {
|
||||
Utils.toast(
|
||||
getApplication(),
|
||||
errorSize.toString() + "张图片的宽或高超过限制,请裁剪后上传"
|
||||
)
|
||||
} else {
|
||||
Utils.toast(getApplication(), errorSize.toString() + "张违规图片上传失败")
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
if (handleUploadError(errorSize, errorMap)) return
|
||||
|
||||
if (errorSize == 0) return
|
||||
|
||||
if (errorSize == 1) {
|
||||
Utils.toast(getApplication(), "图片上传失败")
|
||||
ToastUtils.showToast("图片上传失败")
|
||||
} else {
|
||||
Utils.toast(getApplication(), errorSize.toString() + "张图片上传失败")
|
||||
ToastUtils.showToast(errorSize.toString() + "张图片上传失败")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理上传错误 (包括超时 cancel 的异常)
|
||||
* @return 如果 toast 过了就返回 true
|
||||
*/
|
||||
private fun handleUploadError(
|
||||
errorSize: Int,
|
||||
errorMap: Map<String, Exception>
|
||||
): Boolean {
|
||||
for (error in errorMap.values) {
|
||||
if (error is HttpException && error.code() == 403) {
|
||||
val e = error.response()?.errorBody()?.string()?.toObject<ErrorEntity>()
|
||||
if (e != null && e.code == 403017) {
|
||||
ToastUtils.showToast(errorSize.toString() + "张图片的宽或高超过限制,请裁剪后上传")
|
||||
} else {
|
||||
ToastUtils.showToast(errorSize.toString() + "张违规图片上传失败")
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
fun uploadPoster(picturePath: String) {
|
||||
processDialog.postValue(WaitingDialogFragment.WaitingDialogData("封面上传中...", true))
|
||||
uploadImageSubscription =
|
||||
|
||||
@ -6,14 +6,9 @@ import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.gh.common.util.FloatingBackViewManager
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.MainActivity
|
||||
import com.gh.gamecenter.SplashScreenActivity
|
||||
import com.gh.gamecenter.WebActivity
|
||||
import com.gh.gamecenter.common.utils.PackageFlavorHelper
|
||||
import com.gh.gamecenter.forum.detail.ForumDetailActivity
|
||||
import com.gh.gamecenter.forum.list.ForumListActivity
|
||||
import com.gh.gamecenter.qa.article.detail.ArticleDetailActivity
|
||||
import com.gh.gamecenter.qa.questions.newdetail.NewQuestionDetailActivity
|
||||
import com.gh.gamecenter.qa.video.detail.ForumVideoDetailActivity
|
||||
import com.gh.vspace.VHelper
|
||||
import com.halo.assistant.HaloApp
|
||||
|
||||
@ -35,7 +30,7 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
||||
&& FloatingBackViewManager.getType() == FloatingBackViewManager.TYPE_TASK
|
||||
) {
|
||||
FloatingBackViewManager.disableBackView()
|
||||
} else if (!shouldShowActivityBackView(activity)
|
||||
} else if (activity is WebActivity
|
||||
&& FloatingBackViewManager.getType() == FloatingBackViewManager.TYPE_ACTIVITY
|
||||
) {
|
||||
FloatingBackViewManager.disableBackView()
|
||||
@ -65,15 +60,6 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
||||
}
|
||||
}
|
||||
|
||||
private fun shouldShowActivityBackView(activity: Activity): Boolean {
|
||||
return (activity is MainActivity
|
||||
|| activity is ArticleDetailActivity
|
||||
|| activity is ForumVideoDetailActivity
|
||||
|| activity is ForumDetailActivity
|
||||
|| activity is ForumListActivity
|
||||
|| activity is NewQuestionDetailActivity)
|
||||
}
|
||||
|
||||
override fun onActivityPaused(activity: Activity) {
|
||||
FloatingBackViewManager.dismissBackView()
|
||||
if (PackageFlavorHelper.IS_TEST_FLAVOR && activity is AppCompatActivity) {
|
||||
|
||||
@ -4,13 +4,20 @@ import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.util.Base64
|
||||
import android.view.View
|
||||
import android.webkit.JavascriptInterface
|
||||
import androidx.annotation.Keep
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import com.gh.common.util.*
|
||||
import com.gh.common.util.LogUtils
|
||||
import com.gh.gamecenter.*
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.download.PackageObserver
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.gh.gamecenter.ImageViewerActivity
|
||||
import com.gh.gamecenter.WebActivity
|
||||
import com.gh.gamecenter.common.callback.BiCallback
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.entity.NotificationUgc
|
||||
@ -21,23 +28,27 @@ import com.gh.gamecenter.common.view.dsbridge.CompletionHandler
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.core.runOnIoThread
|
||||
import com.gh.gamecenter.core.runOnUiThread
|
||||
import com.gh.gamecenter.core.utils.CurrentActivityHolder
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.core.utils.MtaHelper
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.core.utils.*
|
||||
import com.gh.gamecenter.energy.EnergyBridge
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.MtaEvent
|
||||
import com.gh.gamecenter.eventbus.EBPackage
|
||||
import com.gh.gamecenter.help.QaFeedbackDialogFragment
|
||||
import com.gh.gamecenter.login.entity.Badge
|
||||
import com.gh.gamecenter.login.user.LoginTag
|
||||
import com.gh.gamecenter.login.view.LoginActivity
|
||||
import com.gh.gamecenter.login.user.UserManager
|
||||
import com.gh.gamecenter.personalhome.border.AvatarBorderActivity
|
||||
import com.gh.gamecenter.security.BindPhoneActivity
|
||||
import com.gh.gamecenter.login.user.UserRepository
|
||||
import com.gh.gamecenter.login.utils.LoginHelper
|
||||
import com.gh.gamecenter.login.utils.QuickLoginHelper
|
||||
import com.gh.gamecenter.login.view.LoginActivity
|
||||
import com.gh.gamecenter.personalhome.border.AvatarBorderActivity
|
||||
import com.gh.gamecenter.setting.view.AboutActivity
|
||||
import com.gh.gamecenter.setting.view.security.BindPhoneActivity
|
||||
import com.gh.vspace.VHelper
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.download.DataWatcher
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import com.lightgame.download.DownloadStatus.*
|
||||
import com.lightgame.utils.Utils
|
||||
import org.json.JSONObject
|
||||
import java.io.BufferedOutputStream
|
||||
@ -45,9 +56,18 @@ import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.util.*
|
||||
|
||||
class DefaultJsApi(var context: Context, val entrance: String = "") {
|
||||
class DefaultJsApi(var context: Context, val entrance: String = "", private var mFragment: Fragment? = null) {
|
||||
|
||||
private var mLoginHandler: CompletionHandler<Any>? = null
|
||||
private var mDownloadWatcher: DataWatcher? = null
|
||||
private var mDownloadUrlSet: HashSet<String>? = null
|
||||
private var mDownloadHandler: CompletionHandler<Any>? = null
|
||||
|
||||
init {
|
||||
if (mFragment != null) {
|
||||
autoUnregisterDownloadObserverIfNeeded(mFragment)
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun isGhzs(msg: Any): String {
|
||||
@ -164,7 +184,16 @@ class DefaultJsApi(var context: Context, val entrance: String = "") {
|
||||
@JavascriptInterface
|
||||
fun startApp(msg: Any) {
|
||||
val packageName = msg.toString()
|
||||
PackageUtils.launchApplicationByPackageName(HaloApp.getInstance().application, packageName)
|
||||
val context = HaloApp.getInstance().application
|
||||
|
||||
// 若畅玩列表中安装了,优先启动畅玩游戏
|
||||
if (VHelper.isInstalled(packageName)) {
|
||||
if (!VHelper.showDialogIfVSpaceIsNeeded(context)) {
|
||||
VHelper.launch(context, packageName)
|
||||
}
|
||||
} else {
|
||||
PackageUtils.launchApplicationByPackageName(context, packageName)
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
@ -436,7 +465,175 @@ class DefaultJsApi(var context: Context, val entrance: String = "") {
|
||||
|
||||
@JavascriptInterface
|
||||
fun getEntrance(msg: Any): String {
|
||||
return entrance
|
||||
return when {
|
||||
entrance.contains("论坛-活动") -> "社区-活动tab-活动banner"
|
||||
entrance.contains("启动弹窗") -> "首页_弹窗"
|
||||
entrance.contains("新首页-轮播图") -> "首页banner"
|
||||
entrance.contains("论坛banner") -> "社区banner"
|
||||
entrance.contains("启动广告") -> "app_开屏文案"
|
||||
// entrance.contains("资讯广场-轮播图") -> "资讯_活动banner"
|
||||
entrance.contains("通用链接合集") -> "资讯_活动banner"
|
||||
entrance.contains("视频流广告位") -> "视频流_广告位"
|
||||
entrance.contains("我的光环banner") -> "我的光环_banner"
|
||||
entrance.contains("论坛详情页置顶栏") -> "社区_论坛置顶"
|
||||
|
||||
else -> entrance
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun getInstallStatus(event: Any): String {
|
||||
val localInstalledPackageList = PackageUtils.getAllPackageName(HaloApp.getInstance().application)
|
||||
val packageNameList: ArrayList<String> = event.toString().toObject() ?: ArrayList()
|
||||
val installStatusMap: HashMap<String, Boolean> = hashMapOf()
|
||||
|
||||
for (packageName in packageNameList) {
|
||||
installStatusMap[packageName] =
|
||||
localInstalledPackageList.contains(packageName) || VHelper.isInstalled(packageName)
|
||||
}
|
||||
|
||||
return installStatusMap.toJson()
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun installDownloadedGame(event: Any) {
|
||||
val url = event.toString()
|
||||
val vUrl = VHelper.getVUrl(url)
|
||||
|
||||
val downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(url, null, false)
|
||||
?: DownloadManager.getInstance().getDownloadEntitySnapshot(vUrl, null, false)
|
||||
|
||||
downloadEntity?.let {
|
||||
PackageInstaller.install(context, it, showUnzipToast = false)
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun registerDownloadCallback(msg: Any, handler: CompletionHandler<Any>) {
|
||||
val downloadUrlSet: HashSet<String> = msg.toString().toObject() ?: return
|
||||
|
||||
mDownloadHandler = handler
|
||||
mDownloadUrlSet = downloadUrlSet
|
||||
|
||||
if (mDownloadWatcher == null) {
|
||||
mDownloadWatcher = object : DataWatcher() {
|
||||
override fun onDataInit(downloadEntity: DownloadEntity) {
|
||||
onDataChanged(downloadEntity)
|
||||
}
|
||||
|
||||
override fun onDataChanged(downloadEntity: DownloadEntity?) {
|
||||
val url = VHelper.getOriginalUrl(downloadEntity?.url)
|
||||
|
||||
if (downloadEntity != null) {
|
||||
if (mDownloadUrlSet?.contains(url) == true) {
|
||||
mDownloadHandler?.setProgressData(
|
||||
SimpleDownloadEntity.fromDownloadEntity(downloadEntity).toJson()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
DownloadManager.getInstance().addObserver(mDownloadWatcher)
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun registerPackageChangesCallback(msg: Any, handler: CompletionHandler<Any>) {
|
||||
PackageObserver.registerPackageChangeChangeListener(object : PackageObserver.PackageChangeListener {
|
||||
override fun onChanged(data: EBPackage) {
|
||||
handler.setProgressData(data.toJson())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun startDownload(msg: Any) {
|
||||
val gameEntity: GameEntity? = msg.toString().toObject()
|
||||
|
||||
if (gameEntity == null) {
|
||||
ToastUtils.toast("下载异常,请稍后重试")
|
||||
return
|
||||
}
|
||||
|
||||
runOnUiThread {
|
||||
// 用一个假的 view 来当 downloadView
|
||||
val stubView = View(context)
|
||||
DownloadItemUtils.setOnClickListener(
|
||||
position = 0,
|
||||
context = context,
|
||||
downloadBtn = stubView,
|
||||
gameEntity = gameEntity,
|
||||
adapter = null,
|
||||
entrance = "(网页活动)",
|
||||
location = "",
|
||||
traceEvent = null,
|
||||
clickCallback = null,
|
||||
refreshCallback = null,
|
||||
allStateClickCallback = null
|
||||
)
|
||||
|
||||
stubView.performClick()
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun resumeDownload(msg: Any) {
|
||||
val url = msg.toString()
|
||||
|
||||
DownloadManager.getInstance().resumeDownload(url)
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun pauseDownload(msg: Any) {
|
||||
val url = msg.toString()
|
||||
|
||||
DownloadManager.getInstance().pause(url)
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun shareText(event: Any) {
|
||||
val textShareEvent = event.toString().toObject() ?: TextShareEvent()
|
||||
if (textShareEvent.text.isNotEmpty() && textShareEvent.type.isNotEmpty()) {
|
||||
val activity = CurrentActivityHolder.getCurrentActivity()
|
||||
MessageShareUtils.getInstance(activity).shareTextFromWeb(activity, textShareEvent.text, textShareEvent.type)
|
||||
}
|
||||
}
|
||||
|
||||
private fun autoUnregisterDownloadObserverIfNeeded(fragment: Fragment?) {
|
||||
fragment?.parentFragmentManager?.registerFragmentLifecycleCallbacks(
|
||||
object : FragmentManager.FragmentLifecycleCallbacks() {
|
||||
override fun onFragmentViewDestroyed(fm: FragmentManager, f: Fragment) {
|
||||
super.onFragmentViewDestroyed(fm, f)
|
||||
if (f === fragment) {
|
||||
fragment.parentFragmentManager.unregisterFragmentLifecycleCallbacks(this)
|
||||
|
||||
if (mDownloadWatcher != null) {
|
||||
DownloadManager.getInstance().removeObserver(mDownloadWatcher)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFragmentResumed(fm: FragmentManager, f: Fragment) {
|
||||
super.onFragmentResumed(fm, f)
|
||||
|
||||
if (f === fragment) {
|
||||
if (mDownloadWatcher != null) {
|
||||
DownloadManager.getInstance().addObserver(mDownloadWatcher)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFragmentPaused(fm: FragmentManager, f: Fragment) {
|
||||
super.onFragmentPaused(fm, f)
|
||||
|
||||
if (f === fragment) {
|
||||
if (mDownloadWatcher != null) {
|
||||
DownloadManager.getInstance().removeObserver(mDownloadWatcher)
|
||||
}
|
||||
}
|
||||
}
|
||||
}, false
|
||||
)
|
||||
}
|
||||
|
||||
@Keep
|
||||
@ -445,6 +642,9 @@ class DefaultJsApi(var context: Context, val entrance: String = "") {
|
||||
@Keep
|
||||
internal data class ImageShareEvent(var image: String = "", var type: String = "")
|
||||
|
||||
@Keep
|
||||
internal data class TextShareEvent(var text: String = "", var type: String = "")
|
||||
|
||||
@Keep
|
||||
internal data class InviteFriendsEvent(
|
||||
var type: String = "",
|
||||
@ -466,4 +666,39 @@ class DefaultJsApi(var context: Context, val entrance: String = "") {
|
||||
var activityId: String = "",
|
||||
var platform: String = ""
|
||||
)
|
||||
|
||||
@Keep
|
||||
data class SimpleDownloadEntity(
|
||||
var url: String = "",
|
||||
var progress: Float = 0F,
|
||||
var status: String = "" // DOWNLOADING, PAUSED, DOWNLOADED, ERROR, UNKNOWN
|
||||
) {
|
||||
companion object {
|
||||
fun fromDownloadEntity(downloadEntity: DownloadEntity): SimpleDownloadEntity {
|
||||
val status: String = when (downloadEntity.status) {
|
||||
add,
|
||||
download,
|
||||
downloading -> "DOWNLOADING"
|
||||
|
||||
done -> "DOWNLOADED"
|
||||
|
||||
pause,
|
||||
resume,
|
||||
subscribe,
|
||||
waiting -> "PAUSED"
|
||||
|
||||
cancel,
|
||||
delete -> "UNKNOWN"
|
||||
|
||||
else -> "ERROR"
|
||||
}
|
||||
|
||||
return SimpleDownloadEntity(
|
||||
url = VHelper.getOriginalUrl(downloadEntity.url),
|
||||
progress = downloadEntity.percent.toFloat(),
|
||||
status = status
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,25 +15,26 @@ import com.gh.common.util.DirectUtils.directToGameVideo
|
||||
import com.gh.common.util.DirectUtils.directToLegacyVideoDetail
|
||||
import com.gh.common.util.DirectUtils.directToLinkPage
|
||||
import com.gh.common.util.DirectUtils.directToQa
|
||||
import com.gh.gamecenter.*
|
||||
import com.gh.gamecenter.core.utils.GsonUtils.gson
|
||||
import com.gh.gamecenter.LibaoDetailActivity
|
||||
import com.gh.gamecenter.MainActivity
|
||||
import com.gh.gamecenter.NewsDetailActivity
|
||||
import com.gh.gamecenter.WebActivity
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.entity.CommunityEntity
|
||||
import com.gh.gamecenter.common.entity.LinkEntity
|
||||
import com.gh.gamecenter.common.eventbus.EBReuse
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.common.utils.DialogHelper
|
||||
import com.gh.gamecenter.common.utils.EnvHelper
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.entity.*
|
||||
import com.gh.gamecenter.eventbus.EBSkip
|
||||
import com.gh.gamecenter.fragment.MainWrapperFragment
|
||||
import com.gh.gamecenter.gamecollection.publish.GameCollectionEditActivity
|
||||
import com.gh.gamecenter.qa.BbsType
|
||||
import com.gh.gamecenter.qa.video.publish.VideoPublishActivity
|
||||
import com.gh.gamecenter.subject.SubjectActivity
|
||||
import com.gh.gamecenter.video.detail.VideoDetailContainerViewModel
|
||||
import com.lightgame.utils.Utils
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import java.nio.charset.Charset
|
||||
|
||||
object DefaultUrlHandler {
|
||||
@ -185,10 +186,12 @@ object DefaultUrlHandler {
|
||||
EntranceConsts.HOST_USERHOME -> {
|
||||
val position = uri.getQueryParameter("position")
|
||||
val subtype = uri.getQueryParameter("sub_type") ?: ""
|
||||
val subGameType = uri.getQueryParameter("sub_game_type") ?: "game_collection"
|
||||
DirectUtils.directToHomeActivity(
|
||||
context,
|
||||
id,
|
||||
subtype,
|
||||
subGameType,
|
||||
if (position.isNullOrEmpty()) -1 else position.toInt(),
|
||||
entrance,
|
||||
""
|
||||
@ -490,6 +493,18 @@ object DefaultUrlHandler {
|
||||
)
|
||||
}
|
||||
|
||||
EntranceConsts.HOST_GAME_LIBRARY -> {
|
||||
DirectUtils.directToMainActivity(context)
|
||||
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_GAME))
|
||||
}
|
||||
|
||||
EntranceConsts.HOST_HOME_GAME_COLLECTION_SQUARE -> {
|
||||
DirectUtils.directToMainActivity(context)
|
||||
EventBus.getDefault()
|
||||
.post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_HOME))
|
||||
EventBus.getDefault().post(EBReuse(host))
|
||||
}
|
||||
|
||||
else -> {
|
||||
if (bringAppToFront) {
|
||||
DirectUtils.directToMainActivity(context)
|
||||
|
||||
@ -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++
|
||||
}
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
package com.gh.common.chain
|
||||
|
||||
import android.content.Context
|
||||
import com.gh.common.simulator.NewSimulatorGameManager
|
||||
import com.gh.common.simulator.SimulatorGameManager
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
|
||||
class UpdateNewSimulatorHandler: ChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity) {
|
||||
if (SimulatorGameManager.isSimulatorGame(gameEntity)) {
|
||||
if (NewSimulatorGameManager.shouldShowUpdateNewSimulatorAlert(context)) {
|
||||
NewSimulatorGameManager.showUpdateNewsSimulator(context) {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
} else {
|
||||
processEndCallback?.invoke(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -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,23 +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;
|
||||
@ -63,8 +66,10 @@ 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;
|
||||
private static SharedPreferences mDefaultSharedPreferences;
|
||||
@ -202,7 +207,7 @@ public class Config {
|
||||
PackageHelper.initList();
|
||||
|
||||
// 初始化畅玩相关的东西
|
||||
VHelper.init(HaloApp.getInstance());
|
||||
VHelper.init(HaloApp.getInstance(), false);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -220,17 +225,37 @@ public class Config {
|
||||
return mSettingsEntity;
|
||||
}
|
||||
|
||||
//新模拟器
|
||||
@Nullable
|
||||
public static NewSettingsEntity.NightMode getNightModeSetting() {
|
||||
if (mNightModeSetting != null) {
|
||||
return mNightModeSetting;
|
||||
} else if (mNewSettingsEntity != null && mNewSettingsEntity.getNightMode() != null) {
|
||||
return mNewSettingsEntity.getNightMode();
|
||||
public static SimulatorEntity getNewSimulatorEntitySetting() {
|
||||
if (mNewSimulatorEntity != null) {
|
||||
return mNewSimulatorEntity;
|
||||
} else if (mNewApiSettingsEntity != null && mNewApiSettingsEntity.getSimulator() != null) {
|
||||
return mNewApiSettingsEntity.getSimulator();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static NewApiSettingsEntity.NightMode getNightModeSetting() {
|
||||
if (mNightModeSetting != null) {
|
||||
return mNightModeSetting;
|
||||
} else if (mNewApiSettingsEntity != null && mNewApiSettingsEntity.getNightMode() != null) {
|
||||
return mNewApiSettingsEntity.getNightMode();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean getUserInterestedGame() {
|
||||
if (mNewApiSettingsEntity != null) {
|
||||
return mNewApiSettingsEntity.getUserInterestedGame();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static NewSettingsEntity getNewSettingsEntity() {
|
||||
if (mNewSettingsEntity == null) {
|
||||
@ -246,6 +271,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) {
|
||||
@ -295,26 +340,6 @@ public class Config {
|
||||
return mDefaultSharedPreferences;
|
||||
}
|
||||
|
||||
public static boolean isExistHideFunction() {
|
||||
SharedPreferences preferences = getPreferences();
|
||||
if (!preferences.getBoolean(FIX_DOWNLOAD_KEY, false)) return true;
|
||||
if (!preferences.getBoolean(FIX_PLUGIN_KEY, false)) return true;
|
||||
if (!preferences.getBoolean(FIX_COMMUNITY_KEY, false)) return true;
|
||||
if (!preferences.getBoolean(FIX_ARTICLE_KEY, false)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void fixHideFunction() {
|
||||
SharedPreferences preferences = PreferenceManager.
|
||||
getDefaultSharedPreferences(HaloApp.getInstance().getApplication());
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean(Config.FIX_DOWNLOAD_KEY, true);
|
||||
editor.putBoolean(Config.FIX_ARTICLE_KEY, true);
|
||||
editor.putBoolean(Config.FIX_COMMUNITY_KEY, true);
|
||||
editor.putBoolean(Config.FIX_PLUGIN_KEY, true);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
public static void getGhzsSettings() {
|
||||
String channel = HaloApp.getInstance().getChannel();
|
||||
@ -350,9 +375,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));
|
||||
}
|
||||
});
|
||||
@ -370,25 +392,23 @@ public class Config {
|
||||
});
|
||||
}
|
||||
|
||||
if (mNightModeSetting == 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.setNightMode(mNightModeSetting);
|
||||
SPUtils.setString(Constants.SP_NEW_SETTINGS, GsonUtils.toJson(data));
|
||||
}
|
||||
AdHelper.prefetchStartUpAd(mNewApiSettingsEntity);
|
||||
SPUtils.setString(Constants.SP_NEW_API_SETTINGS, GsonUtils.toJson(data));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -50,6 +50,7 @@ import com.gh.common.util.PlatformUtils;
|
||||
import com.gh.common.util.ReservationHelper;
|
||||
import com.gh.common.view.DownloadButton;
|
||||
import com.gh.common.view.GameIconView;
|
||||
import com.gh.common.view.NoEllipsizeSpaceTextView;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.download.dialog.DownloadDialog;
|
||||
import com.gh.gamecenter.DownloadManagerActivity;
|
||||
@ -784,7 +785,7 @@ public class BindingAdapters {
|
||||
}
|
||||
}
|
||||
|
||||
public static void setGameName(TextView view, GameEntity game, boolean isShowPlatform, @Nullable Boolean isShowSuffix) {
|
||||
public static void setGameName(NoEllipsizeSpaceTextView view, GameEntity game, boolean isShowPlatform, @Nullable Boolean isShowSuffix) {
|
||||
if (isShowSuffix == null) isShowSuffix = true; // 默认显示
|
||||
if (isShowPlatform && game.getApk().size() > 0) {
|
||||
view.setText(String.format("%s - %s", !isShowSuffix ? game.getNameWithoutSuffix() : game.getName(),
|
||||
@ -842,7 +843,7 @@ public class BindingAdapters {
|
||||
int start = index;
|
||||
int end = start + tag.getName().length() + ((i != showCount - 1) ? 1 : 0);
|
||||
index = end;
|
||||
span.setSpan(new ForegroundColorSpan(Color.parseColor("#" + tag.getColor())),
|
||||
span.setSpan(new ForegroundColorSpan(ExtensionsKt.hexStringToIntColor("#" + tag.getColor(), Color.WHITE)),
|
||||
start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
view.setText(span);
|
||||
@ -850,11 +851,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("-");
|
||||
}
|
||||
|
||||
@ -29,8 +29,8 @@ import com.gh.gamecenter.common.utils.ImageUtils
|
||||
import com.gh.gamecenter.databinding.DialogDeviceRemindBinding
|
||||
import com.gh.gamecenter.entity.DeviceDialogEntity
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.setting.view.GameDownloadSettingFragment
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.gh.gamecenter.setting.GameDownloadSettingFragment.Companion.AUTO_INSTALL_SP_KEY
|
||||
import com.lightgame.download.DataWatcher
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import com.lightgame.download.DownloadStatus
|
||||
@ -53,7 +53,7 @@ class DeviceRemindDialog(context: Context, val entity: DeviceDialogEntity, val g
|
||||
private val dataWatcher = object : DataWatcher() {
|
||||
override fun onDataChanged(downloadEntity: DownloadEntity) {
|
||||
if (downloadEntity.status == DownloadStatus.done && downloadEntity.name == gameEntity.name) {
|
||||
val autoInstall = SPUtils.getBoolean(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
|
||||
@ -70,7 +73,8 @@ data class ExposureEvent(
|
||||
welcomeDialogId = gameEntity?.welcomeDialogId
|
||||
?: eTrace?.firstOrNull()?.payload?.welcomeDialogId,
|
||||
welcomeDialogLinkTitle = gameEntity?.welcomeDialogTitle
|
||||
?: eTrace?.firstOrNull()?.payload?.welcomeDialogLinkTitle
|
||||
?: eTrace?.firstOrNull()?.payload?.welcomeDialogLinkTitle,
|
||||
isAdData = gameEntity?.isAdData ?: eTrace?.firstOrNull()?.payload?.isAdData ?: false
|
||||
)
|
||||
this.id = UUID.randomUUID().toString()
|
||||
this.timeInMillisecond = System.currentTimeMillis()
|
||||
@ -123,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
|
||||
}
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.core.provider.IAppProvider
|
||||
import com.gh.gamecenter.core.provider.IFlavorProvider
|
||||
import com.halo.assistant.HaloApp
|
||||
|
||||
@Route(path = RouteConsts.provider.app, name = "Application暴露服务")
|
||||
@ -33,6 +34,10 @@ class AppProviderImpl : IAppProvider {
|
||||
return HaloApp.getInstance().channel ?: ""
|
||||
}
|
||||
|
||||
override fun setChannel(channel: String) {
|
||||
HaloApp.getInstance().channel = channel
|
||||
}
|
||||
|
||||
override fun getUserAgent(): String {
|
||||
return HaloApp.getInstance().userAgent ?: ""
|
||||
}
|
||||
@ -52,4 +57,8 @@ class AppProviderImpl : IAppProvider {
|
||||
override fun isUserAcceptPrivacyPolicy(context: Context): Boolean {
|
||||
return HaloApp.isUserAcceptPrivacyPolicy(context)
|
||||
}
|
||||
|
||||
override fun getFlavorProvider(): IFlavorProvider {
|
||||
return HaloApp.getInstance().flavorProvider
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package com.gh.common.provider
|
||||
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gh.download.server.BrowserInstallHelper
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.core.provider.IBrowserInstallHelperProvider
|
||||
|
||||
@Route(path = RouteConsts.provider.browserInstallHelper, name = "BrowserInstallHelper暴露服务")
|
||||
class BrowserInstallHelperProviderImpl : IBrowserInstallHelperProvider {
|
||||
override fun isUseBrowserToInstallEnabled(): Boolean = BrowserInstallHelper.isUseBrowserToInstallEnabled()
|
||||
|
||||
override fun shouldUseBrowserToInstall(): Boolean = BrowserInstallHelper.shouldUseBrowserToInstall()
|
||||
|
||||
override fun logSwitchInstallSettingEvent() {
|
||||
BrowserInstallHelper.logOrdinaryBrowserEvent(BrowserInstallHelper.Type.SWITCH_INSTALL_SETTING)
|
||||
}
|
||||
|
||||
|
||||
override fun init(context: Context?) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
@ -72,6 +72,10 @@ class ConfigProviderImpl : IConfigProvider {
|
||||
return Config.WEIBO_APPKEY
|
||||
}
|
||||
|
||||
override fun getNightModeSetting(): Boolean {
|
||||
return Config.getNightModeSetting()?.setting ?: false
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.gh.common.provider
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gh.common.util.DialogUtils
|
||||
@ -22,6 +23,46 @@ class DialogUtilsProviderImpl : IDialogUtilsProvider {
|
||||
})
|
||||
}
|
||||
|
||||
override fun showWaitDialog(context: Context, string: String): Dialog = DialogUtils.showWaitDialog(context, string)
|
||||
|
||||
override fun showForceDialog(
|
||||
context: Context,
|
||||
title: String,
|
||||
message: CharSequence,
|
||||
positive: String,
|
||||
negative: String,
|
||||
confirm: () -> Unit,
|
||||
cancel: () -> Unit
|
||||
) {
|
||||
DialogUtils.showForceDialog(context, title, message, positive, negative,
|
||||
{ confirm.invoke() }, object :CancelListener{
|
||||
override fun onCancel() {
|
||||
cancel.invoke()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun showUsageStatsDialog(context: Context, confirm: () -> Unit, cancel: () -> Unit) {
|
||||
DialogUtils.showUsageStatsDialog(context,
|
||||
{ confirm.invoke() }, object :CancelListener{
|
||||
override fun onCancel() {
|
||||
cancel.invoke()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun showNoticeDialog(
|
||||
context: Context,
|
||||
title: String,
|
||||
content: String,
|
||||
confirm: () -> Unit
|
||||
) {
|
||||
DialogUtils.showNoticeDialog(context, title, content
|
||||
) { confirm.invoke() }
|
||||
}
|
||||
|
||||
override fun showBindPhoneDialog(context: Context, confirm: () -> Unit): Dialog = DialogUtils.showBindPhoneDialog(context) { confirm.invoke() }
|
||||
|
||||
override fun init(context: Context?) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@ -49,6 +49,14 @@ class DirectProviderImpl : IDirectProvider {
|
||||
DirectUtils.directToLotteryParadisePage(context)
|
||||
}
|
||||
|
||||
override fun directDouyin(context: Context, userId: String) {
|
||||
DirectUtils.directDouyin(context, userId)
|
||||
}
|
||||
|
||||
override fun directToSuggestionFromDiagnosis(context: Context, diagnosis: String) {
|
||||
DirectUtils.directToSuggestion(context, diagnosis = diagnosis)
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
package com.gh.common.provider
|
||||
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gh.common.history.HistoryHelper
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.core.provider.IHistoryHelperProvider
|
||||
|
||||
@Route(path = RouteConsts.provider.historyHelper, name = "HistoryHelper暴露服务")
|
||||
class HistoryHelperProviderImpl : IHistoryHelperProvider {
|
||||
override fun emptyDatabase() {
|
||||
HistoryHelper.emptyDatabase()
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
20
app/src/main/java/com/gh/common/provider/MainProviderImpl.kt
Normal file
20
app/src/main/java/com/gh/common/provider/MainProviderImpl.kt
Normal file
@ -0,0 +1,20 @@
|
||||
package com.gh.common.provider
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gh.gamecenter.MainActivity
|
||||
import com.gh.gamecenter.WebActivity
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.core.provider.IMainProvider
|
||||
|
||||
@Route(path = RouteConsts.provider.mainActivity, name = "MainActivity暴露服务")
|
||||
class MainProviderImpl : IMainProvider {
|
||||
override fun skipToMainActivity(context: Context, position: Int) {
|
||||
MainActivity.skipToMainActivity(context, position)
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.gh.common.provider
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Parcelable
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gh.gamecenter.ShellActivity
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.core.provider.IShellProvider
|
||||
|
||||
@Route(path = RouteConsts.provider.shellActivity, name = "ShellActivity暴露服务")
|
||||
class ShellProviderImpl : IShellProvider {
|
||||
override fun getSwitchInstallMethodIntent(context: Context, extraParcelable: Parcelable?): Intent =
|
||||
ShellActivity.getIntent(context, ShellActivity.Type.SWITCH_INSTALL_METHOD, extraParcelable)
|
||||
|
||||
override fun init(context: Context?) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.gh.common.provider
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Handler
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.core.provider.IUpdateManagerProvider
|
||||
import com.gh.gamecenter.manager.UpdateManager
|
||||
|
||||
@Route(path = RouteConsts.provider.updateManager, name = "UpdateManager暴露服务")
|
||||
class UpdateManagerProviderImpl: IUpdateManagerProvider {
|
||||
override fun checkUpdate(context: Context, isAutoCheck: Boolean, handler: Handler) {
|
||||
UpdateManager.getInstance(context).checkUpdate(isAutoCheck, handler)
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package com.gh.common.provider
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import androidx.annotation.RequiresApi
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gh.common.util.UsageStatsHelper
|
||||
import com.gh.common.util.WechatBindHelper
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.core.provider.IUsageStatsHelperProvider
|
||||
|
||||
@Route(path = RouteConsts.provider.usageStatsHelper, name = "UsageStatsHelper暴露服务")
|
||||
class UsageStatsHelperProviderImpl : IUsageStatsHelperProvider {
|
||||
@RequiresApi(Build.VERSION_CODES.LOLLIPOP_MR1)
|
||||
override fun checkForPermission(): Boolean = UsageStatsHelper.checkForPermission()
|
||||
override fun skipToUsageStats(context: Context, requestCode: Int) {
|
||||
UsageStatsHelper.skipToUsageStats(context, requestCode)
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
@ -17,6 +17,14 @@ class WebProviderImpl : IWebProvider {
|
||||
return WebActivity.getWebIntent(context, title, url)
|
||||
}
|
||||
|
||||
override fun getBindWechatIntent(context: Context): Intent {
|
||||
return WebActivity.getBindWechatIntent(context)
|
||||
}
|
||||
|
||||
override fun getSecurityCertificationIntent(context: Context): Intent {
|
||||
return WebActivity.getSecurityCertificationIntent(context)
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@ -8,8 +8,10 @@ import com.gh.gamecenter.core.provider.IWechatBindHelperProvider
|
||||
|
||||
@Route(path = RouteConsts.provider.wechatHelper, name = "WechatHelper暴露服务")
|
||||
class WechatHelperProviderImpl : IWechatBindHelperProvider {
|
||||
override fun getWechatConfig() {
|
||||
WechatBindHelper.getWechatConfig()
|
||||
override fun getWechatConfig(callback: (() -> Unit)?) {
|
||||
WechatBindHelper.getWechatConfig {
|
||||
callback?.invoke()
|
||||
}
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
|
||||
@ -0,0 +1,165 @@
|
||||
package com.gh.common.simulator
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Bitmap
|
||||
import android.view.Gravity
|
||||
import androidx.core.content.FileProvider
|
||||
import com.g00fy2.versioncompare.Version
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.common.util.DownloadItemUtils
|
||||
import com.gh.common.util.LogUtils
|
||||
import com.gh.common.util.NewFlatLogUtils
|
||||
import com.gh.common.util.PackageUtils
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.utils.EmptyCallback
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.core.utils.TimeUtils
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import com.lightgame.utils.AppManager
|
||||
import io.reactivex.Single
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.File
|
||||
|
||||
object NewSimulatorGameManager {
|
||||
|
||||
private const val KEY_GAME_ICON = "GAME_ICON"
|
||||
private const val KEY_GAME_ID = "GAME_ID"
|
||||
private const val KEY_GAME_NAME = "GAME_NAME"
|
||||
private const val KEY_GAME_PACKAGE_NAME = "GAME_PACKAGE_NAME"
|
||||
private const val KEY_GAME_PACKAGE_PATH = "GAME_PACKAGE_PATH"
|
||||
private const val KEY_GAME_PACKAGE_LAST_MODIFICATION = "GAME_PACKAGE_LAST_MODIFICATION"
|
||||
private const val KEY_GAME_PACKAGE_EXTENSION = "GAME_PACKAGE_EXTENSION"
|
||||
private const val KEY_GAME_PACKAGE_SDCARD_PATH = "GAME_PACKAGE_SDCARD_PATH" // boolean 是否sdcard文件路径
|
||||
private const val KEY_GAME_EMU_SYSTEM = "GAME_EMU_SYSTEM"
|
||||
private const val KEY_EMU_ID = "EMU_ID"
|
||||
private const val KEY_EMU_NAME = "EMU_NAME"
|
||||
private const val KEY_USE_DEBUG_API = "USE_DEBUG_API"
|
||||
private const val KEY_META = "META"
|
||||
|
||||
// private const val GH_RETRO_EMU_APP_PACKAGE_NAME = "com.gh.retroemu"
|
||||
private const val GH_RETRO_EMU_APP_LAUNCHER_ACTIVITY_NAME = "com.gh.retroemu.ui.SplashActivity"
|
||||
|
||||
|
||||
private const val NEW_SIMULATOR_SHOW_ALERT_TAG = "-news-simulator-show-alert"
|
||||
|
||||
/**
|
||||
* 后台模拟器管理上传新版本模拟器(显示状态),且检测用户有安装旧版本模拟器 每日弹出一次更新弹框
|
||||
*/
|
||||
@JvmStatic
|
||||
fun shouldShowUpdateNewSimulatorAlert(context: Context): Boolean {
|
||||
val isUploadNewsSimulator = Config.getNewSimulatorEntitySetting()?.active ?: false
|
||||
val isInstallOld = SimulatorGameManager.isOldSimulatorInstalled(context)
|
||||
val showAlertTag = SPUtils.getString(NEW_SIMULATOR_SHOW_ALERT_TAG, "")
|
||||
val todayIsShow = showAlertTag == TimeUtils.getToday()//当天是否弹出过一次
|
||||
val isInstalledNewSimulator = SimulatorGameManager.isNewSimulatorInstalled(context)
|
||||
return (isUploadNewsSimulator && !todayIsShow && isInstallOld && !isInstalledNewSimulator)
|
||||
}
|
||||
|
||||
/**
|
||||
* 弹出更新弹框
|
||||
*/
|
||||
@JvmStatic
|
||||
fun showUpdateNewsSimulator(context: Context, callback: EmptyCallback? = null){
|
||||
NewFlatLogUtils.logSimulatorUpdateAlertShow()
|
||||
DialogHelper.showDialog(
|
||||
context,
|
||||
"更新提示",
|
||||
"光环助手近期对模拟器进行升级,优化游戏体验!\n但更新后可能会导致原先的游戏存档数据无法使用(可在模拟器管理中安装新版本模拟器)",
|
||||
"更新",
|
||||
"取消",
|
||||
confirmClickCallback = {
|
||||
NewFlatLogUtils.logSimulatorUpdateAlertClick("更新")
|
||||
val simulator = Config.getNewSimulatorEntitySetting()
|
||||
if (simulator != null) {
|
||||
SimulatorDownloadManager.getInstance().showDownloadingDialog(context, simulator)
|
||||
}
|
||||
},
|
||||
cancelClickCallback = {
|
||||
callback?.onCallback()
|
||||
NewFlatLogUtils.logSimulatorUpdateAlertClick("取消")
|
||||
},
|
||||
uiModificationCallback = { binding ->
|
||||
binding.contentTv.gravity = Gravity.START
|
||||
binding.contentTv.setTextColor(R.color.text_subtitle.toColor(context))
|
||||
},
|
||||
extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true)
|
||||
)
|
||||
SPUtils.setString(NEW_SIMULATOR_SHOW_ALERT_TAG, TimeUtils.getToday())
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过模拟器启动游戏
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
@JvmStatic
|
||||
fun launchGameViaSimulator(downloadEntity: DownloadEntity, gameEntity: GameEntity) {
|
||||
val newSimulator = Config.getNewSimulatorEntitySetting() ?: return
|
||||
val gameIcon = gameEntity.icon ?: gameEntity.rawIcon ?: ""
|
||||
Single.just(ImageUtils.getCachedUrl(gameIcon))
|
||||
.flatMap {
|
||||
SimulatorGameManager.getBitmapFormCache(it)
|
||||
}.map {
|
||||
BitmapUtils.compressBitmap(it, 100)
|
||||
}.map {
|
||||
val baos = ByteArrayOutputStream()
|
||||
it.compress(Bitmap.CompressFormat.WEBP, 90, baos)
|
||||
baos.toByteArray()
|
||||
}
|
||||
.compose(singleToMain())
|
||||
.subscribe({
|
||||
val gamePackageFileUri = FileProvider.getUriForFile(
|
||||
HaloApp.getInstance(),
|
||||
BuildConfig.APPLICATION_ID,
|
||||
File(downloadEntity.path)
|
||||
)
|
||||
HaloApp.getInstance().grantUriPermission(
|
||||
SimulatorGameManager.NEW_SIMULATOR_PACKAGE_NAME,
|
||||
gamePackageFileUri,
|
||||
Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION or
|
||||
Intent.FLAG_GRANT_READ_URI_PERMISSION or
|
||||
Intent.FLAG_GRANT_WRITE_URI_PERMISSION // 冗余,以备不时之需
|
||||
)
|
||||
|
||||
val intent = Intent()
|
||||
intent.setClassName(SimulatorGameManager.NEW_SIMULATOR_PACKAGE_NAME, GH_RETRO_EMU_APP_LAUNCHER_ACTIVITY_NAME)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
intent.data = gamePackageFileUri
|
||||
gameEntity.getApk().safelyGetInRelease(0)?.let { apk ->
|
||||
intent.putExtra(KEY_GAME_PACKAGE_NAME, apk.packageName)
|
||||
intent.putExtra(KEY_GAME_PACKAGE_EXTENSION, apk.format)
|
||||
}
|
||||
intent.putExtra(KEY_GAME_NAME, downloadEntity.name)
|
||||
intent.putExtra(KEY_GAME_ICON, it)
|
||||
intent.putExtra(KEY_GAME_PACKAGE_PATH, downloadEntity.path) // 游戏包文件路径,冗余参数)
|
||||
intent.putExtra(KEY_GAME_PACKAGE_SDCARD_PATH, true)
|
||||
intent.putExtra(KEY_GAME_PACKAGE_LAST_MODIFICATION, File(downloadEntity.path).lastModified()) // 游戏包文件修改时间
|
||||
intent.putExtra(KEY_GAME_EMU_SYSTEM, gameEntity.simulatorType) // 模拟器类型
|
||||
intent.putExtra(KEY_GAME_ID, gameEntity.id)
|
||||
// TODO 补充光环模拟器的游戏 id
|
||||
intent.putExtra(KEY_EMU_ID, newSimulator.apk?.id) // 光环模拟器.apk gameId
|
||||
intent.putExtra(KEY_EMU_NAME, "光环模拟器") // 光环模拟器.apk name
|
||||
intent.putExtra(KEY_USE_DEBUG_API, EnvHelper.isDevEnv) // // 游戏来源是否为dev后台 (是否来源于测试环境)
|
||||
intent.putExtra(KEY_META, LogUtils.getMetaObject().toString())
|
||||
|
||||
try {
|
||||
AppManager.getInstance().recentActiveActivity?.startActivity(intent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
ToastUtils.showToast("模拟器安装错误")
|
||||
}
|
||||
|
||||
SimulatorGameManager.recordPlaySimulatorGames(gameEntity.id)
|
||||
}, {
|
||||
ToastUtils.showToast("跳转失败")
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@ -10,6 +10,7 @@ import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.g00fy2.versioncompare.Version
|
||||
import com.gh.common.util.LogUtils
|
||||
import com.gh.common.util.NewFlatLogUtils
|
||||
import com.gh.common.util.PackageInstaller
|
||||
import com.gh.common.util.PackageUtils
|
||||
import com.gh.download.DownloadManager
|
||||
@ -138,7 +139,6 @@ class SimulatorDownloadManager private constructor() {
|
||||
) {
|
||||
if (context == null) return
|
||||
|
||||
mContextRef = WeakReference(context)
|
||||
this.simulatorLocation = location
|
||||
this.simulator = simulator
|
||||
this.gameId = gameId
|
||||
@ -146,26 +146,46 @@ 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)
|
||||
val versionFromInstalledApp = PackageUtils.getVersionNameByPackageName(simulator?.apk?.packageName)
|
||||
val shouldShowUpdate = Version(simulator?.apk?.version).isHigherThan(versionFromInstalledApp)
|
||||
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 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) {
|
||||
return
|
||||
}
|
||||
if (downloadType == "download" && isInstalled) {
|
||||
return
|
||||
}
|
||||
val title = if (shouldShowUpdate && isInstalled) "更新模拟器" else "安装模拟器"
|
||||
val message = if (shouldShowUpdate && isInstalled) "检测到模拟器存在更高版本,是否前往更新" else "模拟器游戏需要先下载安装对应的模拟器,才可以运行"
|
||||
val positiveText =
|
||||
if (shouldShowUpdate && isInstalled) "更新(${simulator?.apk?.size})" else "下载(${simulator?.apk?.size})"
|
||||
val negativeText = if (shouldShowUpdate && isInstalled) "下次再说" else "取消"
|
||||
downloadType = if (shouldShowUpdate && isInstalled) "update" else "download"
|
||||
|
||||
val trackableEntity = TrackableEntity(
|
||||
"模拟器下载",
|
||||
key = if (shouldShowUpdate && isInstalled) "更新弹窗" else "下载弹窗",
|
||||
logShowEvent = true
|
||||
)
|
||||
if (shouldShowUpdate && isInstalled) {
|
||||
NewFlatLogUtils.logSimulatorUpdateAlertShow()
|
||||
}
|
||||
DialogHelper.showDialog(
|
||||
context,
|
||||
title,
|
||||
@ -176,11 +196,13 @@ class SimulatorDownloadManager private constructor() {
|
||||
cancelClickCallback = {
|
||||
if (shouldShowUpdate && isInstalled) {
|
||||
cancelCallback?.invoke()
|
||||
NewFlatLogUtils.logSimulatorUpdateAlertClick("取消")
|
||||
MtaHelper.onEvent(trackableEntity.event, trackableEntity.key, "点击下次再说")
|
||||
}
|
||||
},
|
||||
confirmClickCallback = {
|
||||
showDownloadingDialog(context, simulator)
|
||||
NewFlatLogUtils.logSimulatorUpdateAlertClick("更新")
|
||||
MtaHelper.onEvent(
|
||||
trackableEntity.event,
|
||||
trackableEntity.key,
|
||||
@ -190,11 +212,15 @@ class SimulatorDownloadManager private constructor() {
|
||||
mtaEvent = trackableEntity.event, mtaKey = trackableEntity.key,
|
||||
extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true)
|
||||
)
|
||||
if (downloadType == "update" && location != SimulatorLocation.SIMULATOR_MANAGE) {
|
||||
SPUtils.setString(SimulatorGameManager.SIMULATOR_UPDATE_SHOW_ALERT_TAG, TimeUtils.getToday())
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun showDownloadingDialog(context: Context, simulator: SimulatorEntity?) {
|
||||
fun showDownloadingDialog(context: Context, simulator: SimulatorEntity?) {
|
||||
mContextRef = WeakReference(context)
|
||||
val msg = FileUtils.isCanDownload(context, simulator?.apk?.size)
|
||||
if (!msg.isNullOrEmpty()) {
|
||||
Utils.toast(context, msg)
|
||||
|
||||
@ -2,11 +2,12 @@ package com.gh.common.simulator
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Bitmap
|
||||
import android.net.Uri
|
||||
import android.text.TextUtils
|
||||
import com.g00fy2.versioncompare.Version
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.common.util.ApkActiveUtils
|
||||
import com.gh.common.util.LogUtils
|
||||
import com.gh.common.util.PackageUtils
|
||||
@ -17,6 +18,8 @@ import com.gh.gamecenter.common.retrofit.BiResponse
|
||||
import com.gh.gamecenter.common.retrofit.EmptyResponse
|
||||
import com.gh.gamecenter.common.retrofit.Response
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
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.entity.GameEntity
|
||||
@ -36,13 +39,48 @@ import okhttp3.ResponseBody
|
||||
import org.json.JSONArray
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
object SimulatorGameManager {
|
||||
|
||||
private val gamePath by lazy { FileUtils.getDownloadPath(HaloApp.getInstance().application, "emulator_game") }
|
||||
private val mGamePath by lazy { FileUtils.getDownloadPath(HaloApp.getInstance().application, "emulator_game") }
|
||||
|
||||
const val SIMULATOR_UPDATE_SHOW_ALERT_TAG = "simulator-update-show-alert"
|
||||
|
||||
private val mSimulatorPackageNames by lazy {
|
||||
listOf(
|
||||
"com.gh.fbnemu",
|
||||
"com.gh.mame4droid",
|
||||
"com.gh.nesemu",
|
||||
"com.gh.ppsspp",
|
||||
"com.gh.gbaemu",
|
||||
"com.gh.gbcemu",
|
||||
"com.gh.snes9xplus"
|
||||
)
|
||||
}
|
||||
|
||||
const val NEW_SIMULATOR_PACKAGE_NAME = "com.gh.retroemu" //新版本模拟器包名
|
||||
|
||||
|
||||
@JvmStatic
|
||||
fun getPathByType(type: String) = "${gamePath}/${type}"
|
||||
//是否安装了新模拟器
|
||||
fun isNewSimulatorInstalled(context: Context?): Boolean {
|
||||
return PackageUtils.isInstalledFromAllPackage(context, NEW_SIMULATOR_PACKAGE_NAME)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
//是否安装了旧模拟器
|
||||
fun isOldSimulatorInstalled(context: Context?): Boolean {
|
||||
for (packageName in mSimulatorPackageNames) {
|
||||
if (PackageUtils.isInstalledFromAllPackage(context, packageName)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getPathByType(type: String) = "${mGamePath}/${type}"
|
||||
|
||||
@JvmStatic
|
||||
fun deleteLocalGames(names: List<String>) {
|
||||
@ -90,16 +128,33 @@ object SimulatorGameManager {
|
||||
|
||||
@JvmStatic
|
||||
fun launchSimulatorGame(downloadEntity: DownloadEntity, gameEntity: GameEntity) {
|
||||
val versionFromInstalledApp = PackageUtils.getVersionNameByPackageName(gameEntity.simulator?.apk?.packageName)
|
||||
val shouldShowUpdate = Version(gameEntity.simulator?.apk?.version).isHigherThan(versionFromInstalledApp)
|
||||
val isInstalledNewSimulator = isNewSimulatorInstalled(HaloApp.getInstance().application)
|
||||
var packageName = gameEntity.simulator?.apk?.packageName
|
||||
var simulator = gameEntity.simulator
|
||||
|
||||
if (isInstalledNewSimulator) {
|
||||
packageName = NEW_SIMULATOR_PACKAGE_NAME
|
||||
if (Config.getNewSimulatorEntitySetting() == null) {
|
||||
return
|
||||
}
|
||||
simulator = Config.getNewSimulatorEntitySetting()
|
||||
}
|
||||
// val version = simulator?.apk?.version
|
||||
// val versionFromInstalledApp = PackageUtils.getVersionNameByPackageName(packageName)
|
||||
val shouldShowUpdate = PackageUtils.isInstalledApkMatchedMd5(packageName, simulator?.apk?.md5)
|
||||
updateSimulatorConfigFile(gameId = gameEntity.id)
|
||||
if (shouldShowUpdate) {
|
||||
SimulatorDownloadManager.getInstance().showDownloadDialog(
|
||||
AppManager.getInstance().recentActiveActivity, gameEntity.simulator,
|
||||
SimulatorDownloadManager.SimulatorLocation.LAUNCH, gameEntity.id, gameEntity.name
|
||||
?: ""
|
||||
) {
|
||||
val showAlertTag = SPUtils.getString(SIMULATOR_UPDATE_SHOW_ALERT_TAG, "")
|
||||
val todayIsShow = showAlertTag == TimeUtils.getToday() //当天是否弹过
|
||||
if (!todayIsShow) {
|
||||
SimulatorDownloadManager.getInstance().showDownloadDialog(
|
||||
AppManager.getInstance().recentActiveActivity, simulator,
|
||||
SimulatorDownloadManager.SimulatorLocation.LAUNCH, gameEntity.id, gameEntity.name
|
||||
?: ""
|
||||
) {
|
||||
jumpToSimulator(downloadEntity, gameEntity)
|
||||
}
|
||||
} else {
|
||||
jumpToSimulator(downloadEntity, gameEntity)
|
||||
}
|
||||
} else {
|
||||
@ -109,6 +164,11 @@ object SimulatorGameManager {
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private fun jumpToSimulator(downloadEntity: DownloadEntity, gameEntity: GameEntity) {
|
||||
val isInstalledNewSimulator = isNewSimulatorInstalled(HaloApp.getInstance().application)
|
||||
if (isInstalledNewSimulator){
|
||||
NewSimulatorGameManager.launchGameViaSimulator(downloadEntity,gameEntity)
|
||||
return
|
||||
}
|
||||
val gameIcon = gameEntity.icon ?: gameEntity.rawIcon ?: ""
|
||||
Single.just(ImageUtils.getCachedUrl(gameIcon))
|
||||
.flatMap {
|
||||
@ -152,7 +212,7 @@ object SimulatorGameManager {
|
||||
})
|
||||
}
|
||||
|
||||
private fun getBitmapFormCache(url: String): Single<Bitmap> {
|
||||
fun getBitmapFormCache(url: String): Single<Bitmap> {
|
||||
return Single.create {
|
||||
ImageUtils.getBitmap(url, object : BiCallback<Bitmap, Boolean> {
|
||||
override fun onFirst(first: Bitmap) {
|
||||
|
||||
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2,17 +2,14 @@ package com.gh.common.util;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Application;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.gh.base.GlobalActivityManager;
|
||||
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.common.base.activity.BaseActivity;
|
||||
import com.gh.gamecenter.common.constant.Constants;
|
||||
@ -126,6 +123,16 @@ public class DataUtils {
|
||||
|
||||
// 避免初始化顺序问题导致 MetaUtil 一直持有空的 gid
|
||||
MetaUtil.INSTANCE.refreshMeta();
|
||||
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(GhContentProvider.KEY_GID, gid);
|
||||
values.put(GhContentProvider.KEY_ANDROID_ID, MetaUtil.getBase64EncodedAndroidId());
|
||||
try {
|
||||
HaloApp.getInstance().getContentResolver().insert(Uri.parse("content://com.gh.gamecenter.provider/device"), values);
|
||||
} catch (Exception exception) {
|
||||
SentryHelper.INSTANCE.onEvent("DEVICE_INSERT_ERROR", "exception_digest", exception.getLocalizedMessage());
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -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,35 +256,35 @@ 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:
|
||||
if (SimulatorGameManager.isSimulatorGame(viewHolder.gameEntity)) {
|
||||
boolean isInstalled = PackageUtils.isInstalledFromAllPackage(viewHolder.context, viewHolder.gameEntity.getSimulator().getApk().getPackageName());
|
||||
if (isInstalled) {
|
||||
boolean isInstalledNewSimulator = SimulatorGameManager.isNewSimulatorInstalled(viewHolder.context);
|
||||
if (isInstalled || isInstalledNewSimulator) {
|
||||
viewHolder.mDownloadPb.setText(R.string.launch);
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.LAUNCH_OR_OPEN);
|
||||
} else {
|
||||
@ -303,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);
|
||||
|
||||
@ -6,13 +6,10 @@ import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.CountDownTimer;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.Settings;
|
||||
import android.text.Html;
|
||||
import android.text.Spannable;
|
||||
@ -95,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.security.BindPhoneActivity;
|
||||
import com.gh.gamecenter.setting.GameDownloadSettingFragment;
|
||||
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;
|
||||
@ -1254,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);
|
||||
@ -1620,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));
|
||||
@ -1630,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 {
|
||||
@ -1639,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);
|
||||
|
||||
@ -1907,13 +1870,21 @@ public class DialogUtils {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
public static void showReportReasonDialog(Context context, ArrayList<String> items, ReportReasonCallBack callBack) {
|
||||
showReportReasonDialog(context, items, "", callBack);
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
public static void showReportReasonDialog(Context context, ArrayList<String> items, String title, ReportReasonCallBack callBack) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.DialogWindowTransparent);
|
||||
DialogReportReasonBinding binding = DialogReportReasonBinding.inflate(LayoutInflater.from(context));
|
||||
|
||||
if (!title.isEmpty()) {
|
||||
binding.reasonTitle.setText(title);
|
||||
}
|
||||
|
||||
ReportReasonAdapter reportReasonAdapter = new ReportReasonAdapter(context, items, reason -> {
|
||||
if (reason.equals("其他原因")) {
|
||||
binding.reasonTitle.setText(R.string.report_reason_other_title);
|
||||
@ -2045,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());
|
||||
|
||||
@ -9,32 +9,33 @@ import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.gh.gamecenter.common.base.activity.BaseActivity
|
||||
import com.gh.gamecenter.common.base.activity.BaseActivity_TabLayout
|
||||
import com.gh.gamecenter.common.base.activity.ToolBarActivity
|
||||
import com.gh.gamecenter.common.base.fragment.BaseFragment_TabLayout
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.common.exposure.ExposureEvent
|
||||
import com.gh.common.exposure.ExposureEvent.Companion.createEvent
|
||||
import com.gh.common.exposure.ExposureManager.log
|
||||
import com.gh.common.exposure.ExposureTraceUtils.appendTrace
|
||||
import com.gh.common.exposure.ExposureType
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts.*
|
||||
import com.gh.common.util.EntranceUtils.*
|
||||
import com.gh.common.util.EntranceUtils.jumpActivity
|
||||
import com.gh.gamecenter.*
|
||||
import com.gh.gamecenter.amway.AmwayActivity
|
||||
import com.gh.gamecenter.catalog.CatalogActivity
|
||||
import com.gh.gamecenter.category.CategoryDirectoryActivity
|
||||
import com.gh.gamecenter.category2.CategoryV2Activity
|
||||
import com.gh.gamecenter.common.base.activity.BaseActivity
|
||||
import com.gh.gamecenter.common.base.activity.BaseActivity_TabLayout
|
||||
import com.gh.gamecenter.common.base.activity.ToolBarActivity
|
||||
import com.gh.gamecenter.common.base.fragment.BaseFragment_TabLayout
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts.*
|
||||
import com.gh.gamecenter.common.entity.CommunityEntity
|
||||
import com.gh.gamecenter.common.entity.Display
|
||||
import com.gh.gamecenter.common.entity.LinkEntity
|
||||
import com.gh.gamecenter.common.retrofit.Response
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.discovery.DiscoveryActivity
|
||||
import com.gh.gamecenter.download.DownloadFragment.Companion.INDEX_UPDATE
|
||||
import com.gh.gamecenter.entity.*
|
||||
import com.gh.gamecenter.eventbus.EBSkip
|
||||
@ -62,9 +63,10 @@ import com.gh.gamecenter.qa.questions.newdetail.NewQuestionDetailActivity
|
||||
import com.gh.gamecenter.qa.subject.CommunitySubjectActivity
|
||||
import com.gh.gamecenter.qa.video.detail.ForumVideoDetailActivity
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.gh.gamecenter.security.BindPhoneActivity
|
||||
import com.gh.gamecenter.servers.GameServerTestActivity
|
||||
import com.gh.gamecenter.servers.GameServersActivity
|
||||
import com.gh.gamecenter.setting.view.security.BindPhoneActivity
|
||||
import com.gh.gamecenter.setting.view.SettingActivity
|
||||
import com.gh.gamecenter.subject.SubjectActivity
|
||||
import com.gh.gamecenter.suggest.SuggestType
|
||||
import com.gh.gamecenter.tag.TagsActivity
|
||||
@ -143,6 +145,7 @@ object DirectUtils {
|
||||
directToLinkPage(context, linkEntity, entrance, path, null)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun directToLinkPage(
|
||||
context: Context,
|
||||
linkEntity: LinkEntity,
|
||||
@ -181,7 +184,8 @@ object DirectUtils {
|
||||
"common_collection",
|
||||
"game_list",
|
||||
"game_list_detail",
|
||||
"bbs_video"
|
||||
"bbs_video",
|
||||
"explore_column"
|
||||
)
|
||||
|
||||
fun directToLinkPage(
|
||||
@ -434,6 +438,8 @@ object DirectUtils {
|
||||
|
||||
"game_list_detail" -> directToGameCollectionDetail(context, linkEntity.link ?: "", entrance)
|
||||
|
||||
"explore_column" -> context.startActivity(DiscoveryActivity.getIntent(context, entrance))
|
||||
|
||||
"" -> {
|
||||
// do nothing
|
||||
}
|
||||
@ -585,19 +591,21 @@ object DirectUtils {
|
||||
entrance: String? = null,
|
||||
path: String? = null
|
||||
) {
|
||||
directToHomeActivity(context, userId, "", position, entrance, path)
|
||||
directToHomeActivity(context, userId, "", "", position, entrance, path)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至个人主页
|
||||
* @param position 定位到某个tab 0游戏 1发布
|
||||
* @param type 类型
|
||||
* @param type 类型 (发布)
|
||||
* @param game_type 类型 (游戏)
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToHomeActivity(
|
||||
context: Context,
|
||||
userId: String? = "",
|
||||
type: String? = "",
|
||||
game_type: String? = "",
|
||||
position: Int? = 0,
|
||||
entrance: String? = null,
|
||||
path: String? = null
|
||||
@ -610,6 +618,7 @@ object DirectUtils {
|
||||
bundle.putString(KEY_ENTRANCE, BaseActivity.mergeEntranceAndPath(entrance, path))
|
||||
bundle.putString(KEY_PATH, path)
|
||||
bundle.putString(KEY_TYPE, UserHistoryViewModel.TYPE.fromValue(type).value)
|
||||
bundle.putString(KEY_GAME, game_type)
|
||||
bundle.putInt(KEY_POSITION, position ?: 0)
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
@ -767,6 +776,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()
|
||||
|
||||
@ -14,30 +14,30 @@ import com.gh.common.exposure.ExposureEvent
|
||||
import com.gh.common.filter.RegionSettingHelper
|
||||
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.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
|
||||
@ -119,13 +119,13 @@ object DownloadItemUtils {
|
||||
fun updateItemWithReserveStatus(holder: GameViewHolder, gameEntity: GameEntity) {
|
||||
if ("download" == gameEntity.reserveStatus) {
|
||||
// 已上线
|
||||
updateItem(holder.gameDes.context, gameEntity, holder, false)
|
||||
updateItem(holder.gameDownloadBtn.context, gameEntity, holder, false)
|
||||
} else if ("appointment" == gameEntity.reserveStatus) {
|
||||
// 已预约
|
||||
holder.gameDownloadBtn.text = "已预约"
|
||||
holder.gameDownloadBtn.visibility = View.VISIBLE
|
||||
holder.gameDownloadBtn.buttonStyle = DownloadButton.ButtonStyle.RESERVED
|
||||
updateItemViewStatus(holder, false, null, null)
|
||||
updateItemViewStatus(holder, null, null)
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,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,
|
||||
@ -176,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,
|
||||
@ -261,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 {
|
||||
@ -309,192 +329,184 @@ 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()
|
||||
val apkEntity = gameEntity.getApk()[0]
|
||||
var downloadEntity: DownloadEntity? = null
|
||||
if (entryMap.isNotEmpty()) {
|
||||
val downloadEntity = entryMap[apkEntity.getPlatform()]
|
||||
if (downloadEntity != null) {
|
||||
if (downloadEntity.isSimulatorGame()) {
|
||||
if (downloadEntity.status != DownloadStatus.done) {
|
||||
// 更改进度条和提示文本的状态
|
||||
changeStatus(context, holder, downloadEntity, isShowPlatform, true)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
downloadEntity = entryMap[apkEntity.getPlatform()]
|
||||
}
|
||||
if (downloadEntity == null) {
|
||||
downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity)
|
||||
}
|
||||
if (downloadEntity != null) {
|
||||
if (downloadEntity.isSimulatorGame()) {
|
||||
if (downloadEntity.status != DownloadStatus.done) {
|
||||
// 更改进度条和提示文本的状态
|
||||
changeStatus(context, holder, downloadEntity, isShowPlatform, true, isShowRecommendStar)
|
||||
changeStatus(context, holder, downloadEntity)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
// 更改进度条和提示文本的状态
|
||||
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()
|
||||
var downloadEntity: DownloadEntity? = null
|
||||
if (entryMap.isNotEmpty()) {
|
||||
val queue = DownloadManager.getInstance().getQueue(gameEntity.name)
|
||||
val downloadEntity = if (queue != null && !queue.isEmpty()) {
|
||||
downloadEntity = if (queue != null && !queue.isEmpty()) {
|
||||
entryMap[queue.peek()]
|
||||
} else {
|
||||
entryMap[entryMap.keyAt(0)]
|
||||
}
|
||||
if (downloadEntity != null) {
|
||||
// 更改进度条和提示文本的状态
|
||||
changeStatus(context, holder, downloadEntity, isShowPlatform, false, isShowRecommendStar)
|
||||
return
|
||||
}
|
||||
}
|
||||
updateItemViewStatus(holder, false, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
|
||||
if (downloadEntity == null) {
|
||||
downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity)
|
||||
}
|
||||
if (downloadEntity != null) {
|
||||
// 更改进度条和提示文本的状态
|
||||
changeStatus(context, holder, downloadEntity, gameEntity.getApk().size > 1)
|
||||
return
|
||||
}
|
||||
updateItemViewStatus(holder, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
|
||||
}
|
||||
|
||||
// 更改进度条和提示文本的状态
|
||||
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
|
||||
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 (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
|
||||
}
|
||||
}
|
||||
|
||||
@ -561,7 +573,7 @@ object DownloadItemUtils {
|
||||
@JvmStatic
|
||||
fun setOnClickListener(
|
||||
context: Context,
|
||||
downloadBtn: DownloadButton,
|
||||
downloadBtn: View,
|
||||
gameEntity: GameEntity,
|
||||
position: Int,
|
||||
adapter: RecyclerView.Adapter<out RecyclerView.ViewHolder?>?,
|
||||
@ -641,30 +653,22 @@ object DownloadItemUtils {
|
||||
allStateClickCallback?.onCallback()
|
||||
clickCallback?.onCallback()
|
||||
if ("download" == gameEntity.reserveStatus) {
|
||||
ReservationHelper.showDeleteReservationDialog(context, object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
ReservationHelper.deleteReservation(gameEntity, object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
adapter?.notifyItemChanged(position)
|
||||
refreshCallback?.onCallback()
|
||||
}
|
||||
})
|
||||
ReservationHelper.showDeleteReservationDialog(context) {
|
||||
ReservationHelper.deleteReservation(gameEntity) {
|
||||
adapter?.notifyItemChanged(position)
|
||||
refreshCallback?.onCallback()
|
||||
}
|
||||
})
|
||||
}
|
||||
} else {
|
||||
ReservationHelper.showCancelReservationDialog(context, object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
NewFlatLogUtils.logMyGameCancelReserveDialogClick(
|
||||
"确定取消",
|
||||
gameEntity.id,
|
||||
gameEntity.name ?: ""
|
||||
)
|
||||
ReservationHelper.cancelReservation(gameEntity, object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
adapter?.notifyItemChanged(position)
|
||||
refreshCallback?.onCallback()
|
||||
}
|
||||
})
|
||||
ReservationHelper.showCancelReservationDialog(context, {
|
||||
NewFlatLogUtils.logMyGameCancelReserveDialogClick(
|
||||
"确定取消",
|
||||
gameEntity.id,
|
||||
gameEntity.name ?: ""
|
||||
)
|
||||
ReservationHelper.cancelReservation(gameEntity) {
|
||||
adapter?.notifyItemChanged(position)
|
||||
refreshCallback?.onCallback()
|
||||
}
|
||||
}, object : CancelListener {
|
||||
override fun onCancel() {
|
||||
@ -707,26 +711,24 @@ object DownloadItemUtils {
|
||||
}
|
||||
} else if (gameEntity.getApk().size == 1) {
|
||||
downloadBtn.setOnClickListener {
|
||||
val clickRunnable = object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
allStateClickCallback?.onCallback()
|
||||
clickCallback?.onCallback()
|
||||
onNormalClick(
|
||||
context,
|
||||
downloadBtn,
|
||||
gameEntity,
|
||||
position,
|
||||
adapter,
|
||||
entrance,
|
||||
location,
|
||||
traceEvent,
|
||||
refreshCallback
|
||||
)
|
||||
}
|
||||
val clickRunnable = EmptyCallback {
|
||||
allStateClickCallback?.onCallback()
|
||||
clickCallback?.onCallback()
|
||||
onNormalClick(
|
||||
context,
|
||||
downloadBtn,
|
||||
gameEntity,
|
||||
position,
|
||||
adapter,
|
||||
entrance,
|
||||
location,
|
||||
traceEvent,
|
||||
refreshCallback
|
||||
)
|
||||
}
|
||||
|
||||
// 启动不需要请求存储权限
|
||||
if (downloadBtn.text.toString() == context.getString(R.string.launch)) {
|
||||
if (downloadBtn is DownloadButton && downloadBtn.text == context.getString(R.string.launch)) {
|
||||
clickRunnable.onCallback()
|
||||
} else {
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(context, clickRunnable)
|
||||
@ -755,7 +757,7 @@ object DownloadItemUtils {
|
||||
@JvmOverloads
|
||||
fun onNormalClick(
|
||||
context: Context,
|
||||
downloadBtn: DownloadButton,
|
||||
downloadBtn: View?,
|
||||
gameEntity: GameEntity,
|
||||
position: Int,
|
||||
adapter: RecyclerView.Adapter<out RecyclerView.ViewHolder?>?,
|
||||
@ -764,11 +766,12 @@ object DownloadItemUtils {
|
||||
traceEvent: ExposureEvent? = null,
|
||||
refreshCallback: EmptyCallback? = null
|
||||
) {
|
||||
val str = downloadBtn.text.toString()
|
||||
val str = if (downloadBtn is DownloadButton) downloadBtn.text else context.getString(R.string.download)
|
||||
if (gameEntity.getApk().isEmpty()) return
|
||||
val apk = gameEntity.getApk().safelyGetInRelease(0) ?: return
|
||||
if (str == context.getString(R.string.download)) {
|
||||
ChainBuilder().apply {
|
||||
addHandler(UpdateNewSimulatorHandler())
|
||||
addHandler(GamePermissionHandler())
|
||||
addHandler(BrowserInstallHandler())
|
||||
addHandler(PackageCheckHandler())
|
||||
@ -785,6 +788,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())
|
||||
@ -839,9 +843,18 @@ object DownloadItemUtils {
|
||||
if (gameEntity.simulator != null) {
|
||||
val isInstalled =
|
||||
PackageUtils.isInstalledFromAllPackage(context, gameEntity.simulator!!.apk!!.packageName)
|
||||
if (downloadEntity != null && SimulatorGameManager.isSimulatorGame(gameEntity) && !isInstalled) {
|
||||
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 (downloadEntity != null && SimulatorGameManager.isSimulatorGame(gameEntity) && !isInstalled && !isInstalledNewSimulator) {
|
||||
SimulatorDownloadManager.getInstance().showDownloadDialog(
|
||||
context, gameEntity.simulator,
|
||||
context, simulator,
|
||||
SimulatorDownloadManager.SimulatorLocation.LAUNCH, gameEntity.id, gameEntity.name!!, null
|
||||
)
|
||||
return
|
||||
@ -855,9 +868,12 @@ object DownloadItemUtils {
|
||||
}
|
||||
} 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 downloadEntity = SimulatorGameManager.findDownloadEntityByUrl(gameEntity.getApk()[0].url)
|
||||
if (downloadEntity != null) {
|
||||
val file = File(downloadEntity.path)
|
||||
@ -865,6 +881,7 @@ object DownloadItemUtils {
|
||||
download(context, gameEntity, downloadBtn, entrance, location, false, traceEvent)
|
||||
return
|
||||
}
|
||||
NewFlatLogUtils.logSimulatorGameCardClick("启动")
|
||||
SimulatorGameManager.launchSimulatorGame(downloadEntity, gameEntity)
|
||||
}
|
||||
return
|
||||
@ -895,15 +912,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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -912,7 +945,7 @@ object DownloadItemUtils {
|
||||
private fun download(
|
||||
context: Context,
|
||||
gameEntity: GameEntity,
|
||||
downloadBtn: DownloadButton,
|
||||
downloadBtn: View?,
|
||||
entrance: String,
|
||||
location: String,
|
||||
isSubscribe: Boolean,
|
||||
@ -932,8 +965,10 @@ object DownloadItemUtils {
|
||||
traceEvent
|
||||
)
|
||||
Utils.toast(context, gameEntity.name + "已加入下载队列")
|
||||
downloadBtn.setText(R.string.downloading)
|
||||
downloadBtn.buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_NORMAL
|
||||
if (downloadBtn is DownloadButton) {
|
||||
downloadBtn.text = "0%"
|
||||
downloadBtn.buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_NORMAL
|
||||
}
|
||||
DeviceRemindDialog.showDeviceRemindDialog(context, gameEntity)
|
||||
} else {
|
||||
Utils.toast(context, msg)
|
||||
@ -942,15 +977,22 @@ object DownloadItemUtils {
|
||||
|
||||
//插件化
|
||||
private fun plugin(
|
||||
context: Context, gameEntity: GameEntity, downloadBtn: DownloadButton, entrance: String,
|
||||
location: String, isSubscribe: Boolean, traceEvent: ExposureEvent?
|
||||
context: Context,
|
||||
gameEntity: GameEntity,
|
||||
downloadBtn: View?,
|
||||
entrance: String,
|
||||
location: String,
|
||||
isSubscribe: Boolean,
|
||||
traceEvent: ExposureEvent?
|
||||
) {
|
||||
val msg = FileUtils.isCanDownload(context, gameEntity.getApk()[0].size)
|
||||
if (TextUtils.isEmpty(msg)) {
|
||||
DownloadManager.createDownload(context, gameEntity, "插件化", entrance, location, isSubscribe, traceEvent)
|
||||
Utils.toast(context, gameEntity.name + "已加入下载队列")
|
||||
downloadBtn.setText(R.string.downloading)
|
||||
downloadBtn.buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_PLUGIN
|
||||
if (downloadBtn is DownloadButton) {
|
||||
downloadBtn.setText(R.string.downloading)
|
||||
downloadBtn.buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_PLUGIN
|
||||
}
|
||||
} else {
|
||||
Utils.toast(context, msg)
|
||||
}
|
||||
@ -958,8 +1000,11 @@ object DownloadItemUtils {
|
||||
|
||||
//安装
|
||||
private fun install(
|
||||
context: Context, gameEntity: GameEntity, position: Int,
|
||||
adapter: RecyclerView.Adapter<out RecyclerView.ViewHolder?>?, refreshCallback: EmptyCallback?
|
||||
context: Context,
|
||||
gameEntity: GameEntity,
|
||||
position: Int,
|
||||
adapter: RecyclerView.Adapter<out RecyclerView.ViewHolder?>?,
|
||||
refreshCallback: EmptyCallback?
|
||||
) {
|
||||
val apkEntity = gameEntity.getApk()[0]
|
||||
val downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity)
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
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
|
||||
import com.gh.common.simulator.SimulatorGameManager
|
||||
@ -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.GameDownloadSettingFragment
|
||||
import com.gh.gamecenter.setting.view.GameDownloadSettingFragment
|
||||
import com.gh.gamecenter.suggest.SuggestType
|
||||
import com.gh.vspace.VHelper
|
||||
import com.halo.assistant.HaloApp
|
||||
@ -47,6 +48,8 @@ object DownloadObserver {
|
||||
// TODO 修复因为更改内存对象造成的双重下载完成事件问题,具体触发代码见 DownloadDao.updateSnapshotList
|
||||
private var mDoneDebouncePair: Pair<String, Long>? = null
|
||||
|
||||
private const val TEA_EVENT_DOWNLOAD_COMPLETE = "game_addiction"
|
||||
|
||||
// 如果在WIFI状态下,下载自动暂停,则再重试一遍
|
||||
@JvmStatic
|
||||
fun initObserver() {
|
||||
@ -200,6 +203,11 @@ object DownloadObserver {
|
||||
} else {
|
||||
statDoneEvent(downloadEntity)
|
||||
|
||||
if (!SPUtils.getBoolean(TEA_EVENT_DOWNLOAD_COMPLETE)) {
|
||||
HaloApp.getInstance().flavorProvider.logEvent(TEA_EVENT_DOWNLOAD_COMPLETE)
|
||||
SPUtils.setBoolean(TEA_EVENT_DOWNLOAD_COMPLETE, true)
|
||||
}
|
||||
|
||||
GameActivityDownloadHelper.clear()
|
||||
|
||||
EnergyBridge.postEnergyTask("download_game", downloadEntity.gameId, downloadEntity.packageName)
|
||||
@ -239,20 +247,27 @@ object DownloadObserver {
|
||||
val simulatorJson = downloadEntity.getMetaExtra(Constants.SIMULATOR)
|
||||
val gameName = downloadEntity.getMetaExtra(Constants.GAME_NAME)
|
||||
if (simulatorJson.isEmpty()) return
|
||||
val simulator = GsonUtils.fromJson(simulatorJson, SimulatorEntity::class.java)
|
||||
var simulator = GsonUtils.fromJson(simulatorJson, SimulatorEntity::class.java)
|
||||
val isInstalled = PackageUtils.isInstalledFromAllPackage(
|
||||
HaloApp.getInstance().application,
|
||||
simulator.apk?.packageName
|
||||
)
|
||||
if (!isInstalled) {
|
||||
val currentActivity = AppManager.getInstance().currentActivity()
|
||||
?: return
|
||||
|
||||
SimulatorDownloadManager.getInstance().showDownloadDialog(
|
||||
currentActivity, simulator,
|
||||
SimulatorDownloadManager.SimulatorLocation.LAUNCH, downloadEntity.gameId, gameName, null
|
||||
)
|
||||
val isInstalledNewSimulator =
|
||||
SimulatorGameManager.isNewSimulatorInstalled(HaloApp.getInstance().application)
|
||||
val isInstalledOldSimulator =
|
||||
SimulatorGameManager.isOldSimulatorInstalled(HaloApp.getInstance().application)
|
||||
// if (!isInstalled && !isInstalledNewSimulator) {
|
||||
val currentActivity = AppManager.getInstance().currentActivity()
|
||||
?: return
|
||||
val newSimulator = Config.getNewSimulatorEntitySetting()
|
||||
if ((!isInstalledOldSimulator && newSimulator != null && newSimulator.active) || isInstalledNewSimulator) { //如果没有安装任一旧的模拟器 或者下载了新模拟器 则使用新版本模拟器
|
||||
simulator = newSimulator ?: simulator
|
||||
}
|
||||
SimulatorDownloadManager.getInstance().showDownloadDialog(
|
||||
currentActivity, simulator,
|
||||
SimulatorDownloadManager.SimulatorLocation.LAUNCH, downloadEntity.gameId, gameName, null
|
||||
)
|
||||
// }
|
||||
SimulatorGameManager.recordDownloadSimulatorGame(downloadEntity.gameId, simulator.type)
|
||||
SimulatorGameManager.postPlayedGame(downloadEntity.gameId, downloadEntity.packageName)
|
||||
} else {
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -3,10 +3,10 @@ package com.gh.common.util
|
||||
import android.app.Activity
|
||||
import android.os.Build
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.utils.dip2px
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.energy.EnergyBridge
|
||||
import com.lightgame.utils.Util_System_Keyboard
|
||||
import com.lzf.easyfloat.EasyFloat
|
||||
@ -67,23 +67,14 @@ object FloatingBackViewManager {
|
||||
}
|
||||
|
||||
dragEnd { view ->
|
||||
val statusBarHeight = DisplayUtils.getStatusBarHeight(activity.resources)
|
||||
|
||||
// 记录停止拖动的最后位置
|
||||
val outLocation = IntArray(2)
|
||||
view.getLocationInWindow(outLocation)
|
||||
val yOffset = outLocation[1]
|
||||
view.findViewById<View>(R.id.titleTv)?.apply {
|
||||
val outLocation = IntArray(2)
|
||||
getLocationOnScreen(outLocation)
|
||||
val yOffset = outLocation[1]
|
||||
|
||||
if (yOffset <= statusBarHeight) {
|
||||
// 判断状态栏是否被消费
|
||||
if (yOffset == view.y.toInt()) {
|
||||
view.y = statusBarHeight.toFloat()
|
||||
} else {
|
||||
view.y = 0F
|
||||
}
|
||||
mLastPositionY = yOffset
|
||||
}
|
||||
|
||||
mLastPositionY = yOffset
|
||||
}
|
||||
}
|
||||
.show()
|
||||
@ -113,8 +104,6 @@ object FloatingBackViewManager {
|
||||
|
||||
/**
|
||||
* 停用返回小浮窗
|
||||
* @param type 类型
|
||||
* @param activityUrl 类型为活动的时候用的地址
|
||||
*/
|
||||
@JvmStatic
|
||||
fun disableBackView() {
|
||||
|
||||
@ -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; // 下载完成数量
|
||||
@ -89,7 +87,7 @@ public class GameUtils {
|
||||
int installCount = 0; // 已安装数量
|
||||
|
||||
boolean isRelatedEmulatorInstalled = false; // 若该游戏是模拟器游戏时其对应的模拟器是否已经安装
|
||||
|
||||
boolean isInstalledNewSimulator = false;// 是否安装新模拟器
|
||||
DownloadEntity downloadEntity = null;
|
||||
Object gh_id;
|
||||
apkFor:
|
||||
@ -138,6 +136,7 @@ public class GameUtils {
|
||||
}
|
||||
}
|
||||
if (SimulatorGameManager.isSimulatorGame(gameEntity)) {
|
||||
isInstalledNewSimulator = SimulatorGameManager.isNewSimulatorInstalled(context);
|
||||
DownloadEntity simulatorDownloadEntity = SimulatorGameManager.findDownloadEntityByUrl(apkEntity.getUrl());
|
||||
if (simulatorDownloadEntity != null && gameEntity.getSimulator() != null) {
|
||||
boolean isInstalled = PackageUtils.isInstalledFromAllPackage(context, gameEntity.getSimulator().getApk().getPackageName());
|
||||
@ -150,8 +149,7 @@ public class GameUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isRelatedEmulatorInstalled && doneCount != 0) {
|
||||
if ((isRelatedEmulatorInstalled || isInstalledNewSimulator) && doneCount != 0) {
|
||||
return context.getString(R.string.launch);
|
||||
}
|
||||
|
||||
@ -182,7 +180,17 @@ public class GameUtils {
|
||||
if (gameEntity.isVGame()) {
|
||||
return context.getString(R.string.smooth);
|
||||
} else {
|
||||
return context.getString(R.string.download);
|
||||
if ("smooth".equals(gameEntity.getDownloadStatus())) {
|
||||
GameEntity.GameCategory gameCategory = gameEntity.getGameCategory();
|
||||
if (gameCategory.equals(GameEntity.GameCategory.ONLINE_GAME)
|
||||
|| gameCategory.equals(GameEntity.GameCategory.INTERNATIONAL_ONLINE_GAME)) {
|
||||
return context.getString(R.string.download);
|
||||
} else {
|
||||
return context.getString(R.string.attempt);
|
||||
}
|
||||
} else {
|
||||
return context.getString(R.string.download);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@ import android.widget.TextView;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.gh.gamecenter.common.utils.ExtensionsKt;
|
||||
import com.gh.gamecenter.core.AppExecutor;
|
||||
import com.gh.gamecenter.common.view.DrawableView;
|
||||
import com.gh.gamecenter.R;
|
||||
@ -125,8 +126,8 @@ public class GameViewUtils {
|
||||
DisplayUtils.dip2px(context, 4),
|
||||
DisplayUtils.dip2px(context, 1));
|
||||
|
||||
textView.setTextColor(Color.parseColor("#" + tagEntity.getColor()));
|
||||
textView.setBackground(DrawableView.getServerDrawable(Color.parseColor("#" + tagEntity.getBackground())));
|
||||
textView.setTextColor(ExtensionsKt.hexStringToIntColor("#" + tagEntity.getColor(), Color.WHITE));
|
||||
textView.setBackground(DrawableView.getServerDrawable(ExtensionsKt.hexStringToIntColor("#" + tagEntity.getBackground(), Color.WHITE)));
|
||||
}
|
||||
|
||||
private static TextView getGameTagView(Context context, String tagStr, int rightMargin, String tagType, TagStyleEntity tagEntity) {
|
||||
@ -149,10 +150,10 @@ public class GameViewUtils {
|
||||
|
||||
if ("border".equals(tagEntity.getStyle())) {
|
||||
gradientDrawable.setColor(Color.TRANSPARENT);
|
||||
gradientDrawable.setStroke(DisplayUtils.dip2px(context, 1f), Color.parseColor(colorStr));
|
||||
tag.setTextColor(Color.parseColor(colorStr));
|
||||
gradientDrawable.setStroke(DisplayUtils.dip2px(context, 1f), ExtensionsKt.hexStringToIntColor(colorStr, Color.WHITE));
|
||||
tag.setTextColor(ExtensionsKt.hexStringToIntColor(colorStr, Color.WHITE));
|
||||
} else {
|
||||
gradientDrawable.setColor(Color.parseColor(colorStr));
|
||||
gradientDrawable.setColor(ExtensionsKt.hexStringToIntColor(colorStr, Color.WHITE));
|
||||
gradientDrawable.setShape(GradientDrawable.RECTANGLE);
|
||||
tag.setTextColor(Color.WHITE);
|
||||
}
|
||||
@ -163,7 +164,7 @@ public class GameViewUtils {
|
||||
if (colorStr == null) {
|
||||
return null;
|
||||
}
|
||||
int color = Color.parseColor(colorStr);
|
||||
int color = ExtensionsKt.hexStringToIntColor(colorStr, Color.WHITE);
|
||||
GradientDrawable gradientDrawable = new GradientDrawable();
|
||||
gradientDrawable.setColor(Color.TRANSPARENT);
|
||||
gradientDrawable.setStroke(DisplayUtils.dip2px(context, 1f), color);
|
||||
|
||||
@ -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");
|
||||
@ -553,7 +553,7 @@ public class LogUtils {
|
||||
}
|
||||
|
||||
public static void uploadSearchGame(String event, String location, String key, String searchType) {
|
||||
uploadSearchClick(event, location, key, searchType, "", "", false);
|
||||
uploadSearchClick(event, location, key, searchType, "", "", false, false);
|
||||
}
|
||||
|
||||
public static void uploadSearchClick(String event,
|
||||
@ -562,7 +562,8 @@ public class LogUtils {
|
||||
String searchType,
|
||||
String gameId,
|
||||
String gameName,
|
||||
Boolean isMirrorData) {
|
||||
Boolean isMirrorData,
|
||||
Boolean isAdData) {
|
||||
JSONObject object = new JSONObject();
|
||||
JSONObject payload = new JSONObject();
|
||||
try {
|
||||
@ -576,6 +577,7 @@ public class LogUtils {
|
||||
payload.put("game_id", gameId); //event为search_click才取值
|
||||
payload.put("game_name", gameName); //event为search_click才取值
|
||||
payload.put("is_mirror_data", isMirrorData);
|
||||
payload.put("is_ad_data", isAdData);
|
||||
object.put("payload", payload);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@ -43,6 +43,7 @@ import com.tencent.connect.share.QQShare;
|
||||
import com.tencent.mm.opensdk.modelmsg.SendMessageToWX;
|
||||
import com.tencent.mm.opensdk.modelmsg.WXImageObject;
|
||||
import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
|
||||
import com.tencent.mm.opensdk.modelmsg.WXTextObject;
|
||||
import com.tencent.mm.opensdk.openapi.IWXAPI;
|
||||
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
|
||||
import com.tencent.open.TDialog;
|
||||
@ -311,6 +312,51 @@ public class MessageShareUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public void shareTextFromWeb(Activity activity, String text, String type) {
|
||||
switch (type) {
|
||||
case "qq":
|
||||
Utils.toast(mContext, "分享跳转中...");
|
||||
if (ShareUtils.isQQClientAvailable(activity)) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_SEND);
|
||||
intent.putExtra(Intent.EXTRA_TEXT, text);
|
||||
intent.setType("text/plain");
|
||||
intent.setPackage("com.tencent.mobileqq");
|
||||
intent.setClassName("com.tencent.mobileqq", "com.tencent.mobileqq.activity.JumpActivity");
|
||||
try {
|
||||
activity.startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
Utils.toast(mContext, "分享失败");
|
||||
}
|
||||
} else {
|
||||
Utils.toast(mContext, "请安装QQ客户端");
|
||||
}
|
||||
break;
|
||||
case "wechat":
|
||||
Utils.toast(mContext, "分享跳转中...");
|
||||
|
||||
if (!mIWXAPI.isWXAppInstalled() && !PermissionHelper.isGetInstalledListPermissionDisabled(mContext)) {
|
||||
Utils.toast(mContext, mContext.getString(R.string.share_no_wechat_hint));
|
||||
return;
|
||||
}
|
||||
|
||||
WXTextObject textObj = new WXTextObject();
|
||||
textObj.text = text;
|
||||
|
||||
WXMediaMessage msg = new WXMediaMessage();
|
||||
msg.mediaObject = textObj;
|
||||
msg.description = text;
|
||||
|
||||
SendMessageToWX.Req req = new SendMessageToWX.Req();
|
||||
req.transaction = buildTransaction("text");
|
||||
req.message = msg;
|
||||
req.scene = SendMessageToWX.Req.WXSceneSession;
|
||||
|
||||
mIWXAPI.sendReq(req);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//QQ分享
|
||||
private void qqShare() {
|
||||
Utils.toast(mContext, "分享跳转中...");
|
||||
|
||||
@ -461,17 +461,6 @@ object NewFlatLogUtils {
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
//设置点击深色模式跟随系统切换开关
|
||||
@JvmStatic
|
||||
fun logHaloSelfNightModeOsSwitch(isOn: Boolean) {
|
||||
val json = json {
|
||||
"event" to "halo_self_night_mode_os_switch"
|
||||
"is_on" to isOn
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
//触发关闭深色模式跟随系统切换弹窗
|
||||
@JvmStatic
|
||||
fun logHaloSelfNightModeOsDialog(buttonText: String) {
|
||||
@ -558,7 +547,7 @@ object NewFlatLogUtils {
|
||||
//手机号验证弹窗点击事件
|
||||
fun logPhoneNumberVerifyDialogClick(entrance: String, text: String) {
|
||||
val json = json {
|
||||
"event" to "phone_number_verify_dialog_click"
|
||||
"event" to "publish_phone_number_verify_dialog_click"
|
||||
"entrance" to entrance
|
||||
"text" to text
|
||||
parseAndPutMeta().invoke(this)
|
||||
@ -569,7 +558,7 @@ object NewFlatLogUtils {
|
||||
//手机号验证界面展示事件
|
||||
fun logPhoneNumberVerifyDialogShow(entrance: String) {
|
||||
val json = json {
|
||||
"event" to "phone_number_verify_dialog_show"
|
||||
"event" to "publish_phone_number_verify_dialog_show"
|
||||
"entrance" to entrance
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
@ -580,7 +569,7 @@ object NewFlatLogUtils {
|
||||
//完成手机号验证
|
||||
fun logPhoneNumberVerifyDialogSuccess() {
|
||||
val json = json {
|
||||
"event" to "phone_number_verify_dialog_success"
|
||||
"event" to "publish_phone_number_verify_dialog_success"
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
@ -607,4 +596,625 @@ object NewFlatLogUtils {
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
//模拟器更新弹窗展示事件
|
||||
@JvmStatic
|
||||
fun logSimulatorUpdateAlertShow() {
|
||||
val json = json {
|
||||
"event" to "simulator_update_pop_show"
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
//模拟器更新弹窗按钮点击事件
|
||||
@JvmStatic
|
||||
fun logSimulatorUpdateAlertClick(buttonText: String) {
|
||||
val json = json {
|
||||
"event" to "simulator_update_pop_click"
|
||||
"button_type" to buttonText
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
//模拟器游戏页面展示事件
|
||||
@JvmStatic
|
||||
fun logSimulatorGamePageShow() {
|
||||
val json = json {
|
||||
"event" to "simulator_game_page_show"
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
//模拟器游戏类型Tab展示事件
|
||||
@JvmStatic
|
||||
fun logSimulatorGamePageTabClick(tabName: String) {
|
||||
val json = json {
|
||||
"event" to "simulator_game_tag_show"
|
||||
"tab_name" to tabName
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
//模拟器游戏卡片点击事件
|
||||
@JvmStatic
|
||||
fun logSimulatorGameCardClick(buttonText: String) {
|
||||
val json = json {
|
||||
"event" to "simulator_game_card_click"
|
||||
"button_type" to buttonText
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
//模拟器游戏合集点击事件
|
||||
@JvmStatic
|
||||
fun logSimulatorGameCollectionClick() {
|
||||
val json = json {
|
||||
"event" to "simulator_game_collection_click"
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
//游戏删除提示弹窗展示事件
|
||||
@JvmStatic
|
||||
fun logSimulatorGameDeleteAlertShow() {
|
||||
val json = json {
|
||||
"event" to "simulator_delete_game_pop_show"
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
//游戏删除提示弹窗点击事件
|
||||
@JvmStatic
|
||||
fun logSimulatorGameDeleteAlertClick(buttonText: String) {
|
||||
val json = json {
|
||||
"event" to "simulator_delete_game_pop_click"
|
||||
"button_type" to buttonText
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
//模拟器管理页面展示事件
|
||||
@JvmStatic
|
||||
fun logSimulatorManagerClick() {
|
||||
val json = json {
|
||||
"event" to "simulator_manger_page_show"
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
//模拟器列表相关点击事件
|
||||
fun logSimulatorListClick(buttonText: String, simulatorType: String) {
|
||||
val json = json {
|
||||
"event" to "simulator_list_click"
|
||||
"button_type" to buttonText
|
||||
"simulator_name" to simulatorType
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
//模拟器卸载提示弹窗展示事件
|
||||
fun logSimulatorUninstallAlertShow(simulatorType: String) {
|
||||
val json = json {
|
||||
"event" to "simulator_uninstall_pop_show"
|
||||
"simulator_name" to simulatorType
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
//模拟器卸载提示弹窗展示事件
|
||||
fun logSimulatorUninstallAlertClick(buttonText: String) {
|
||||
val json = json {
|
||||
"event" to "simulator_uninstall_pop_click"
|
||||
"button_type" to buttonText
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
//进入发现页面
|
||||
fun logDiscoverPageEnter() {
|
||||
val json = json {
|
||||
"event" to "discover_page_enter"
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
//离开发现页面
|
||||
fun logDiscoverPageQuit(sequence: Int) {
|
||||
val json = json {
|
||||
"event" to "discover_page_quit"
|
||||
"sequence" to sequence
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
//发现页面可见事件
|
||||
fun logDiscoverPageVisible() {
|
||||
val json = json {
|
||||
"event" to "discover_page_visible"
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
//发现页面不可见事件
|
||||
fun logDiscoverPageInvisible(sequence: Int) {
|
||||
val json = json {
|
||||
"event" to "discover_page_invisible"
|
||||
"sequence" to sequence
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
//页面顶部露出
|
||||
fun logDiscoverPageTopVisible(countNum: Int) {
|
||||
val json = json {
|
||||
"event" to "discover_page_top_visible"
|
||||
"count_num" to countNum
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
//页面底部停留
|
||||
fun logDiscoverPageBottomStay(countNum: Int) {
|
||||
val json = json {
|
||||
"event" to "discover_page_bottom_stay"
|
||||
"count_num" to countNum
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
//点击兴趣推荐卡片
|
||||
fun logDiscoverPageRecommendedInterestCardClick(sequence: Int, linkText: String, linkType: String, linkId: String) {
|
||||
val json = json {
|
||||
"event" to "discover_page_recommended_interest_card_click"
|
||||
"sequence" to sequence
|
||||
"link_text" to linkText
|
||||
"link_type" to linkType
|
||||
"link_id" to linkId
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
//点击跳转游戏库
|
||||
fun logDiscoverPageJumpGamesLibraries() {
|
||||
val json = json {
|
||||
"event" to "discover_page_jump_games_libraries"
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
//触发不感兴趣
|
||||
fun logDiscoverPageNotInterest(gameId: String, gameName: String) {
|
||||
val json = json {
|
||||
"event" to "discover_page_not_interest"
|
||||
"game_id" to gameId
|
||||
"game_name" to gameName
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
//跳过广告
|
||||
@JvmStatic
|
||||
fun logOpenScreenAdSkip(adId: String, linkText: String, linkType: String, linkId: String) {
|
||||
val json = json {
|
||||
"event" to "open_screen_ad_skip"
|
||||
"ad_id" to adId
|
||||
"link_text" to linkText
|
||||
"link_type" to linkType
|
||||
"link_id" to linkId
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
//游戏单广场浏览时长
|
||||
fun logGameCollectSquareStayTime(interval: Long) {
|
||||
val json = json {
|
||||
"event" to "game_collect_square_stay_time"
|
||||
"interval" to interval
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
//游戏单浏览时长
|
||||
fun logGameCollectStayTime(interval: Long, id: String, title: String) {
|
||||
val json = json {
|
||||
"event" to "game_collect_stay_time"
|
||||
"interval" to interval
|
||||
"game_collect_id" to id
|
||||
"game_collect_title" to title
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
// 游戏存档页面展示事件
|
||||
fun logGameArchivePageShow(tabName: String) {
|
||||
val json = json {
|
||||
"event" to "cloud_save_game_save_page_show"
|
||||
"tab_name" to tabName
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
// 云存档管理页面展示事件
|
||||
fun logCloudArchiveManagePageShow(gameId: String, gameName: String, entrance: String) {
|
||||
val json = json {
|
||||
"event" to "cloud_save_manage_page_show"
|
||||
"game_id" to gameId
|
||||
"game_name" to gameName
|
||||
"entrance" to entrance
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
// 云存档Tab页面展示事件
|
||||
fun logCloudArchiveTabShow(gameId: String, gameName: String, tabName: String) {
|
||||
val json = json {
|
||||
"event" to "cloud_save_tab_page_show"
|
||||
"game_id" to gameId
|
||||
"game_name" to gameName
|
||||
"tab_name" to tabName
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
// 存档分享弹窗展示事件
|
||||
fun logCloudArchiveShareDialogShow() {
|
||||
val json = json {
|
||||
"event" to "cloud_save_share_dialog_show"
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
// 存档分享弹窗点击事件
|
||||
fun logCloudArchiveShareDialogClick(buttonType: String) {
|
||||
val json = json {
|
||||
"event" to "cloud_save_share_dialog_click"
|
||||
"button_type" to buttonType
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
// 存档分享弹窗分享结果事件
|
||||
fun logCloudArchiveShareDialogResult(shareResult: String) {
|
||||
val json = json {
|
||||
"event" to "cloud_save_share_dialog_result"
|
||||
"share_result" to shareResult
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
// 存档删除弹窗展示事件
|
||||
fun logCloudArchiveDeleteDialogShow() {
|
||||
val json = json {
|
||||
"event" to "cloud_save_delete_dialog_show"
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
// 存档删除弹窗点击事件
|
||||
fun logCloudArchiveDeleteDialogClick(buttonType: String) {
|
||||
val json = json {
|
||||
"event" to "cloud_save_delete_dialog_click"
|
||||
"button_type" to buttonType
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
// 上传存档弹窗展示事件
|
||||
fun logCloudArchiveUploadDialogShow() {
|
||||
val json = json {
|
||||
"event" to "cloud_save_upload_dialog_show"
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
// 上传存档弹窗点击事件
|
||||
fun logCloudArchiveUploadDialogClick(buttonType: String) {
|
||||
val json = json {
|
||||
"event" to "cloud_save_upload_dialog_click"
|
||||
"button_type" to buttonType
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
// 畅玩助手下载提示弹窗展示事件
|
||||
fun logCloudArchiveVSpaceDownloadDialogShow() {
|
||||
val json = json {
|
||||
"event" to "cloud_save_halo_fun_download_dialog_show"
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
// 畅玩助手下载提示弹窗点击事件
|
||||
fun logCloudArchiveVSpaceDownloadDialogClick(buttonType: String) {
|
||||
val json = json {
|
||||
"event" to "cloud_save_halo_fun_download_dialog_click"
|
||||
"button_type" to buttonType
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
// 游戏下载提示弹窗展示事件
|
||||
fun logCloudArchiveGameDownloadDialogShow() {
|
||||
val json = json {
|
||||
"event" to "cloud_save_game_download_dialog_show"
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
// 游戏下载提示弹窗点击事件
|
||||
fun logCloudArchiveGameDownloadDialogClick(buttonType: String) {
|
||||
val json = json {
|
||||
"event" to "cloud_save_game_download_dialog_click"
|
||||
"button_type" to buttonType
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
// 推荐游戏页面下载游戏事件
|
||||
fun logCloudArchiveRecommendGameDownload(gameId: String, gameName: String) {
|
||||
val json = json {
|
||||
"event" to "cloud_save_recommend_game_page_download"
|
||||
"game_id" to gameId
|
||||
"game_name" to gameName
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
// 搜索功能关键词上传事件
|
||||
fun logCloudArchiveSearchKeyUpload(gameId: String, gameName: String, key: String) {
|
||||
val json = json {
|
||||
"event" to "cloud_save_search_key_upload"
|
||||
"game_id" to gameId
|
||||
"game_name" to gameName
|
||||
"key" to key
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
// 云存档Tab展示事件/云存档Tab展示事件
|
||||
fun logCloudArchiveGameDetailTabRelated(event: String, gameId: String, gameName: String) {
|
||||
val json = json {
|
||||
"event" to event
|
||||
"game_id" to gameId
|
||||
"game_name" to gameName
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
// 云存档下载/使用事件
|
||||
fun logCloudArchiveDownloadOrApply(archiveName: String, entrance: String) {
|
||||
val json = json {
|
||||
"event" to "cloud_save_download"
|
||||
"cloud_save_name" to archiveName
|
||||
"entrance" to entrance
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
// 存档覆盖风险提示弹窗展示事件/存档覆盖风险提示弹窗点击事件
|
||||
fun logCloudArchiveApplyDialogRelated(event: String, buttonType: String = "") {
|
||||
val json = json {
|
||||
"event" to event
|
||||
if (buttonType.isNotBlank()) {
|
||||
"button_type" to buttonType
|
||||
}
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
// 进入发现页详情
|
||||
fun logDiscoverDetailPageEnter(entrance: String, blockName: String = "") {
|
||||
val json = json {
|
||||
"event" to "discover_detail_page_enter"
|
||||
"entrance" to entrance
|
||||
if (blockName.isNotBlank()) {
|
||||
"block_name" to blockName
|
||||
}
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
// 点击设置偏好
|
||||
fun logInterestedGameClick(entrance: String, blockName: String = "") {
|
||||
val json = json {
|
||||
"event" to "discover_preference_settings_click"
|
||||
"entrance" to entrance
|
||||
if (blockName.isNotBlank()) {
|
||||
"block_name" to blockName
|
||||
}
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
// 进入游戏偏好页面
|
||||
fun logInterestedGamePageEnter(frequency: String, prefer: String, tendency: String, typeTags: JSONArray) {
|
||||
val json = json {
|
||||
"event" to "discover_preference_game_page_enter"
|
||||
"frequency" to frequency
|
||||
"prefer" to prefer
|
||||
"tendency" to tendency
|
||||
"type_tags" to typeTags
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
// 离开游戏偏好页面
|
||||
fun logInterestedGamePageExit(
|
||||
frequency: String,
|
||||
prefer: String,
|
||||
tendency: String,
|
||||
typeTags: JSONArray,
|
||||
) {
|
||||
val json = json {
|
||||
"event" to "discover_preference_game_page_quit"
|
||||
"frequency" to frequency
|
||||
"prefer" to prefer
|
||||
"tendency" to tendency
|
||||
"type_tags" to typeTags
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
// 浏览游戏偏好页面
|
||||
fun logInterestedGamePageBrowse(
|
||||
frequency: String,
|
||||
prefer: String,
|
||||
tendency: String,
|
||||
typeTags: JSONArray,
|
||||
interval: Long
|
||||
) {
|
||||
val json = json {
|
||||
"event" to "discover_preference_game_view"
|
||||
"frequency" to frequency
|
||||
"prefer" to prefer
|
||||
"tendency" to tendency
|
||||
"type_tags" to typeTags
|
||||
"interval" to interval
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
// 展开感兴趣的分类弹窗
|
||||
fun logInterestedGameTypeDialogShow(typeTags: JSONArray) {
|
||||
val json = json {
|
||||
"event" to "discover_preference_type_tags_dialog_show"
|
||||
"type_tags" to typeTags
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
// 关闭感兴趣的分类弹窗
|
||||
fun logInterestedGameTypeDialogClose(typeTags: JSONArray) {
|
||||
val json = json {
|
||||
"event" to "discover_preference_type_tags_dialog_close"
|
||||
"type_tags" to typeTags
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
// 浏览感兴趣的分类弹窗
|
||||
fun logInterestedGameTypeDialogBrowse(typeTags: JSONArray, interval: Long) {
|
||||
val json = json {
|
||||
"event" to "discover_preference_type_tags_dialog_view"
|
||||
"type_tags" to typeTags
|
||||
"interval" to interval
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
//游戏详情-游戏单推荐,点击右上角进入游戏单广场时触发
|
||||
fun logGameDetailGameListRecommendSquareJump(gameName: String, gameId: String) {
|
||||
val json = json {
|
||||
"event" to "game_detail_game_list_recommend_square_jump"
|
||||
"game_name" to gameName
|
||||
"game_id" to gameId
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
//游戏详情-专题推荐,点击右上角时触发
|
||||
fun logGameDetailColumnRecommendUpperRightClick(
|
||||
gameName: String,
|
||||
gameId: String,
|
||||
buttonType: String,
|
||||
columnName: String,
|
||||
columnId: String,
|
||||
linkText: String,
|
||||
linkType: String,
|
||||
linkId: String
|
||||
) {
|
||||
val json = json {
|
||||
"event" to "game_detail_column_recommend_upper_right_click"
|
||||
"game_name" to gameName
|
||||
"game_id" to gameId
|
||||
"button_type" to buttonType
|
||||
"column_name" to columnName
|
||||
"column_id" to columnId
|
||||
"link_text" to linkText
|
||||
"link_type" to linkType
|
||||
"link_id" to linkId
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
|
||||
//用户通过活动页的“立即投稿/添加”成功创建游戏单时上报
|
||||
fun logActivityGameListCreateSuccessV2(
|
||||
entrance: String,
|
||||
gameId: String,
|
||||
gameName: String,
|
||||
gameCollectId: String,
|
||||
gameCollectTitle: String,
|
||||
activityId: String,
|
||||
activityName: String,
|
||||
) {
|
||||
val json = json {
|
||||
"event" to "activity_game_list_create_success_v2"
|
||||
"entrance" to entrance
|
||||
if (gameId.isNotEmpty()) {
|
||||
"game_id" to gameId
|
||||
}
|
||||
if (gameName.isNotEmpty()) {
|
||||
"game_name" to gameName
|
||||
}
|
||||
"game_collect_id" to gameCollectId
|
||||
"game_collect_title" to gameCollectTitle
|
||||
"activity_id" to activityId
|
||||
"activity_name" to activityName
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "event", false)
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import com.gh.gamecenter.common.entity.WechatConfigEntity
|
||||
import com.gh.gamecenter.common.json.JsonObjectBuilder
|
||||
import com.gh.gamecenter.common.json.json
|
||||
import com.gh.gamecenter.common.loghub.LoghubUtils
|
||||
@ -8,12 +9,10 @@ import com.gh.gamecenter.common.retrofit.EmptyResponse
|
||||
import com.gh.gamecenter.common.tracker.Tracker
|
||||
import com.gh.gamecenter.common.utils.toRequestBody
|
||||
import com.gh.gamecenter.entity.QuoteCountEntity
|
||||
import com.gh.gamecenter.entity.WechatConfigEntity
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.lightgame.utils.Utils
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.ResponseBody
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
|
||||
object NewLogUtils {
|
||||
@ -1896,20 +1895,6 @@ object NewLogUtils {
|
||||
log(json, "appointment", false)
|
||||
}
|
||||
|
||||
//点击微信提醒
|
||||
@JvmStatic
|
||||
fun logWechatRemindConfigClick(wechatConfigEntity: WechatConfigEntity) {
|
||||
val json = json {
|
||||
"event" to "appointment_wechat_remind_config_click"
|
||||
"wechat_is_bind" to wechatConfigEntity.bind
|
||||
"wechat_is_follow" to wechatConfigEntity.follow
|
||||
"wechat_is_remind" to wechatConfigEntity.notice
|
||||
"timestamp" to System.currentTimeMillis() / 1000
|
||||
parseAndPutMeta().invoke(this)
|
||||
}
|
||||
log(json, "appointment", false)
|
||||
}
|
||||
|
||||
//选择图片上传方式
|
||||
@JvmStatic
|
||||
fun logShowGameCollectionCoverTypeDialog() {
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -28,6 +28,8 @@ import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.common.constant.Constants;
|
||||
import com.gh.gamecenter.common.utils.ExtensionsKt;
|
||||
import com.gh.gamecenter.common.utils.PackageFlavorHelper;
|
||||
import com.gh.gamecenter.core.AppExecutor;
|
||||
import com.gh.gamecenter.core.utils.MD5Utils;
|
||||
import com.gh.gamecenter.core.utils.SentryHelper;
|
||||
import com.gh.gamecenter.entity.ApkEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
@ -55,6 +57,7 @@ import java.security.cert.CertificateException;
|
||||
import java.security.cert.CertificateFactory;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -72,6 +75,36 @@ public class PackageUtils {
|
||||
|
||||
private static final String TAG = "PackageUtils";
|
||||
|
||||
public static String getInstallPackageInfoSourceDir(String packageName) {
|
||||
try {
|
||||
return HaloApp.getInstance().getApplication().getPackageManager().getPackageInfo(packageName,
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT).applicationInfo.sourceDir;
|
||||
} catch (NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据packageName和模拟器apk文件的MD5去判断目标文件是否需要更新
|
||||
*
|
||||
* @param packageName 包名
|
||||
* @param MD5Str 文件MD5
|
||||
*/
|
||||
public static boolean isInstalledApkMatchedMd5(String packageName, String MD5Str) {
|
||||
if (MD5Str == null){
|
||||
Utils.log("MD5Str is null");
|
||||
return false;
|
||||
}
|
||||
String path = getInstallPackageInfoSourceDir(packageName);
|
||||
if (path == null){
|
||||
Utils.log("File path null");
|
||||
return false;
|
||||
}
|
||||
File file = new File(path);
|
||||
return !(MD5Str.equals(MD5Utils.calculateMD5(file)));
|
||||
}
|
||||
|
||||
/*
|
||||
* 判断是否可以更新,只判断gh_version的大小
|
||||
*/
|
||||
@ -984,7 +1017,7 @@ public class PackageUtils {
|
||||
public static boolean checkWebViewIsAvailable(Context context) {
|
||||
List<String> webViewAbiList = HaloApp.getInstance().getWebViewAbiList();
|
||||
|
||||
if (webViewAbiList != null) {
|
||||
if (webViewAbiList != null && !webViewAbiList.isEmpty()) {
|
||||
if (webViewAbiList.size() == 2 && webViewAbiList.contains("x86") && webViewAbiList.contains("x86_64")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -8,9 +8,9 @@ import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.WebActivity
|
||||
import com.gh.gamecenter.common.callback.CancelListener
|
||||
import com.gh.gamecenter.common.callback.ConfirmListener
|
||||
import com.gh.gamecenter.common.entity.WechatConfigEntity
|
||||
import com.gh.gamecenter.core.utils.*
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.WechatConfigEntity
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
|
||||
@ -3,11 +3,11 @@ package com.gh.common.util
|
||||
import android.annotation.SuppressLint
|
||||
import com.gh.gamecenter.common.callback.BiCallback
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.entity.WechatConfigEntity
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.common.utils.createRequestBody
|
||||
import com.gh.gamecenter.common.utils.singleToMain
|
||||
import com.gh.gamecenter.common.utils.toJson
|
||||
import com.gh.gamecenter.entity.WechatConfigEntity
|
||||
import com.gh.gamecenter.login.user.UserManager
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
|
||||
@ -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
|
||||
|
||||
@ -6,18 +6,19 @@ import android.graphics.drawable.GradientDrawable
|
||||
import android.text.TextUtils
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import androidx.cardview.widget.CardView
|
||||
import androidx.annotation.ColorRes
|
||||
import com.facebook.drawee.generic.RoundingParams
|
||||
import com.facebook.drawee.view.SimpleDraweeView
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.common.view.RadiusCardView
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import splitties.views.dsl.core.add
|
||||
import splitties.views.dsl.core.lParams
|
||||
import splitties.views.dsl.core.matchParent
|
||||
|
||||
class GameIconView : CardView {
|
||||
class GameIconView : RadiusCardView {
|
||||
|
||||
private var mCornerRadius = 0
|
||||
private var mBorderColor = 0
|
||||
@ -28,6 +29,7 @@ class GameIconView : CardView {
|
||||
private var mGameIconIv: SimpleDraweeView? = null
|
||||
private var mGameIconDecorationIv: SimpleDraweeView? = null
|
||||
private var mBorderView: View? = null
|
||||
private var mIsRemoveCrevice = false
|
||||
|
||||
constructor(context: Context) : super(context, null) {
|
||||
initView(null)
|
||||
@ -58,6 +60,7 @@ class GameIconView : CardView {
|
||||
mGameIconOverlayColor = ta.getColor(R.styleable.GameIconView_gameIconOverlayColor, 0)
|
||||
mBorderWidth = ta.getDimensionPixelSize(R.styleable.GameIconView_gameIconBorderWidth, 1)
|
||||
mFadeDuration = ta.getInt(R.styleable.GameIconView_gameIconFadeDuration, -1)
|
||||
mIsRemoveCrevice = ta.getBoolean(R.styleable.GameIconView_gameIconRemoveCrevice, false)
|
||||
ta.recycle()
|
||||
}
|
||||
|
||||
@ -112,14 +115,17 @@ class GameIconView : CardView {
|
||||
|
||||
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
||||
super.onSizeChanged(w, h, oldw, oldh)
|
||||
setBorder(w)
|
||||
}
|
||||
|
||||
private fun setBorder(width: Int) {
|
||||
val cornerRadius = if (!isInEditMode) {
|
||||
getCornerRadius(w)
|
||||
getCornerRadius(width)
|
||||
} else {
|
||||
0F
|
||||
}
|
||||
|
||||
radius = cornerRadius
|
||||
setRadiusPx(cornerRadius, cornerRadius, cornerRadius, cornerRadius)
|
||||
cardElevation = 0F
|
||||
|
||||
// 一些设备(没错,又是 vivo),代码设置 CardView 的 radius 无效(xml 设置有效)
|
||||
@ -131,16 +137,24 @@ class GameIconView : CardView {
|
||||
|
||||
if (mBorderColor != 0) {
|
||||
// 当图片为动图时,设置边框无效,所以改为增加一个View,专门用来设置边框
|
||||
// roundingParams.setBorder(mBorderColor, mBorderWidth.toFloat())
|
||||
//roundingParams.setBorder(mBorderColor, mBorderWidth.toFloat())
|
||||
val drawable = GradientDrawable().apply {
|
||||
shape = GradientDrawable.RECTANGLE
|
||||
setCornerRadius(cornerRadius)
|
||||
//骚操作~ 这里加这个操作是为了防止图片和边框有间隙
|
||||
setCornerRadius(cornerRadius - if (mIsRemoveCrevice) mBorderWidth else 0)
|
||||
setColor(R.color.transparent.toColor())
|
||||
setStroke(mBorderWidth, mBorderColor)
|
||||
}
|
||||
mBorderView?.background = drawable
|
||||
}
|
||||
|
||||
//骚操作~ 这里加这个操作是为了防止图片和边框有间隙、防止右上角的静态小标签都被挡住
|
||||
if (mBorderWidth != 0) {
|
||||
val halfBorderWidth = (mBorderWidth / 2F).toInt()
|
||||
mGameIconIv?.setPadding(halfBorderWidth, halfBorderWidth, halfBorderWidth, halfBorderWidth)
|
||||
mGameIconDecorationIv?.setPadding(halfBorderWidth, halfBorderWidth, halfBorderWidth, halfBorderWidth)
|
||||
}
|
||||
|
||||
mGameIconIv?.hierarchy?.roundingParams = roundingParams
|
||||
mGameIconDecorationIv?.hierarchy?.roundingParams = roundingParams
|
||||
}
|
||||
@ -149,6 +163,11 @@ class GameIconView : CardView {
|
||||
mCornerRadius = cornerRadius
|
||||
}
|
||||
|
||||
fun setBorderColor(@ColorRes color: Int) {
|
||||
mBorderColor = color.toColor(context)
|
||||
setBorder(measuredWidth)
|
||||
}
|
||||
|
||||
private fun getCornerRadius(width: Int): Float {
|
||||
// 预设的圆角设置优先级更高
|
||||
if (mCornerRadius != 0) {
|
||||
|
||||
@ -0,0 +1,38 @@
|
||||
package com.gh.common.view
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import androidx.appcompat.widget.AppCompatTextView
|
||||
|
||||
/**
|
||||
* 去除省略号后面空白的TextView
|
||||
*/
|
||||
class NoEllipsizeSpaceTextView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) :
|
||||
AppCompatTextView(context, attrs, defStyleAttr) {
|
||||
override fun setText(text: CharSequence?, type: BufferType?) {
|
||||
super.setText(text, type)
|
||||
post {
|
||||
if (layout != null) {
|
||||
val rawText = layout.text.toString()
|
||||
if (rawText.contains(ELLIPSIS_NORMAL)) {
|
||||
val index = rawText.indexOf(ELLIPSIS_BLANK)
|
||||
var trimText = rawText
|
||||
if (index > 0) {
|
||||
trimText = rawText.substring(0, index)
|
||||
}
|
||||
trimText = rawText.substring(0, trimText.length - 1) + ELLIPSIS_NORMAL
|
||||
setText(trimText)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val ELLIPSIS_NORMAL = "\u2026" // 省略号字符(...)
|
||||
private const val ELLIPSIS_BLANK = "\uFEFF" // 空白字符
|
||||
}
|
||||
}
|
||||
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@ -574,7 +579,7 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
* @return null表示下载列表中不存在该任务,否则返回下载任务
|
||||
*/
|
||||
@Nullable
|
||||
private DownloadEntity getDownloadEntitySnapshot(String url, String gameId, boolean isVGame) {
|
||||
public DownloadEntity getDownloadEntitySnapshot(String url, String gameId, boolean isVGame) {
|
||||
DownloadEntity snapshot = null;
|
||||
|
||||
if (isVGame && !TextUtils.isEmpty(gameId)) {
|
||||
@ -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.GameDownloadSettingFragment.Companion.CONCERN_GAME_SP_KEY
|
||||
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,7 +109,7 @@ object PackageObserver {
|
||||
|
||||
DownloadManager.getInstance().cancel(mDownloadEntity.url, false, true, false)
|
||||
|
||||
if (SPUtils.getBoolean(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,302 @@
|
||||
package com.gh.download.simple
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.database.sqlite.SQLiteException
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.lg.download.*
|
||||
import com.lg.download.listener.InnerDownloadListener
|
||||
import com.lg.ndownload.DownloadConfig
|
||||
import java.net.URLConnection
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
/**
|
||||
* 下载信息管理类
|
||||
*/
|
||||
object DownloadMessageHandler : InnerDownloadListener {
|
||||
|
||||
// 单页可订阅的监听数最少从 3 开始, 如果值为 5 的话有可能出现状态无法更新的情况 (fragment onDestroy 回调慢)
|
||||
private const val MAX_LISTENER_SIZE = 5
|
||||
|
||||
private lateinit var mDownloadDao: DownloadDao
|
||||
|
||||
private val mGlobalStatusChangedListenerList by lazy {
|
||||
arrayListOf<((SimpleDownloadEntity, DownloadStatus) -> Unit)>()
|
||||
}
|
||||
|
||||
/**
|
||||
* map key: 下载 id
|
||||
*
|
||||
* map value:
|
||||
* pair first-> 下载实体
|
||||
* pair second-> 对应页面的下载回调
|
||||
*/
|
||||
private var mListenerMap: ConcurrentHashMap<String, FixedSizeStack<DownloadListener>> = ConcurrentHashMap()
|
||||
|
||||
var downloadList = arrayListOf<SimpleDownloadEntity>()
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
fun init(downloadDao: DownloadDao) {
|
||||
mDownloadDao = downloadDao
|
||||
|
||||
updateDownloadList()
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册全局回调(为避免影响下载性能,目前仅对接了状态变更回调)
|
||||
*/
|
||||
fun registerGlobalStatusChangedListener(listener: ((SimpleDownloadEntity, DownloadStatus) -> Unit)) {
|
||||
mGlobalStatusChangedListenerList.add(listener)
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态回调
|
||||
* @param id 下载 id
|
||||
* @param status 下载状态
|
||||
*/
|
||||
override fun onStatusChanged(id: String, status: DownloadStatus) {
|
||||
val entity = findEntity(id)
|
||||
|
||||
if (entity != null) {
|
||||
entity.status = status
|
||||
|
||||
if (status == DownloadStatus.COMPLETED) {
|
||||
SimpleDownloadManager.resumeQueuedTask()
|
||||
}
|
||||
|
||||
ExecutorProvider.getInstance().backgroundExecutor.execute {
|
||||
updateDownloadToDatabase(entity)
|
||||
updateDownloadList()
|
||||
}
|
||||
}
|
||||
|
||||
for (listener in mGlobalStatusChangedListenerList) {
|
||||
listener.invoke(entity!!, status)
|
||||
}
|
||||
|
||||
val listenerList = mListenerMap[id] ?: return
|
||||
|
||||
ExecutorProvider.getInstance().mainThreadExecutor.execute {
|
||||
safeIteratorList(listenerList) {
|
||||
it.onStatusChanged(status)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重定向中的回调
|
||||
* @param id 下载 id
|
||||
* @param connection 未重定向前的原始连接
|
||||
* @param config 下载配置
|
||||
*/
|
||||
override fun onRedirectingUrl(id: String?, connection: URLConnection?, config: DownloadConfig?) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 重定向完成后的回调
|
||||
* @param id 下载 id
|
||||
* @param connection 重定向完成后的连接
|
||||
* @param redirectedUrl 重定向完成的最终地址
|
||||
*/
|
||||
override fun onRedirectedUrl(id: String, connection: URLConnection, redirectedUrl: String) {
|
||||
val entity = findEntity(id) ?: return
|
||||
|
||||
entity.url = redirectedUrl
|
||||
|
||||
// 更新数据库数据
|
||||
updateDownloadToDatabase(entity, updateDownloadList = true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 进度回调,带频率控制,适合用来更新 UI
|
||||
* @param id 下载 id
|
||||
* @param progress 进度 0~1
|
||||
*/
|
||||
override fun onProgress(id: String, progress: Float) {
|
||||
val entity = findEntity(id) ?: return
|
||||
|
||||
entity.progress = progress * 100
|
||||
|
||||
updateDownloadToDatabase(entity)
|
||||
|
||||
val listenerList = mListenerMap[id] ?: return
|
||||
|
||||
ExecutorProvider.getInstance().mainThreadExecutor.execute {
|
||||
safeIteratorList(listenerList) {
|
||||
it.onProgress(progress * 100)
|
||||
}
|
||||
}
|
||||
|
||||
updateDownloadList()
|
||||
}
|
||||
|
||||
/**
|
||||
* 没有频率控制的进度回调,适合做一些轻度的操作
|
||||
* @param id 下载 id
|
||||
* @param progress 进度 0~1
|
||||
*/
|
||||
override fun onProgressWithoutThrottle(id: String?, progress: Float) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 速度回调,带频率控制,适合用来更新 UI
|
||||
* @param id 下载 id
|
||||
* @param speed 下载速度,单位为字节
|
||||
*/
|
||||
override fun onSpeedChanged(id: String, speed: Float) {
|
||||
val listenerList = mListenerMap[id] ?: return
|
||||
|
||||
ExecutorProvider.getInstance().mainThreadExecutor.execute {
|
||||
safeIteratorList(listenerList) {
|
||||
it.onSpeedChanged(speed)
|
||||
}
|
||||
}
|
||||
|
||||
findEntity(id)?.run {
|
||||
this.speed = speed
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 错误回调
|
||||
* @param id 下载 id
|
||||
* @param error 错误类型
|
||||
* @param exception 包裹错误的 Exception
|
||||
*/
|
||||
override fun onError(id: String, error: DownloadError?, exception: Exception) {
|
||||
error ?: return
|
||||
|
||||
when (error) {
|
||||
DownloadError.EMPTY_URL,
|
||||
DownloadError.HTTP_NOT_FOUND,
|
||||
DownloadError.CONTENT_LENGTH_IS_ZERO -> {
|
||||
ToastUtils.toast("下载链接异常,请检查")
|
||||
}
|
||||
else -> {
|
||||
// 想怎么处理就怎么处理
|
||||
}
|
||||
}
|
||||
|
||||
val listenerList = mListenerMap[id] ?: return
|
||||
|
||||
ExecutorProvider.getInstance().mainThreadExecutor.execute {
|
||||
safeIteratorList(listenerList) {
|
||||
it.onError(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件大小获取成功回调
|
||||
* @param id 下载 id
|
||||
* @param fileSize 文件大小,单位为字节
|
||||
*/
|
||||
override fun onSizeReceived(id: String, fileSize: Long) {
|
||||
val entity = findEntity(id) ?: return
|
||||
|
||||
entity.totalBytes = fileSize
|
||||
updateDownloadToDatabase(entity, updateDownloadList = true)
|
||||
|
||||
val listenerList = mListenerMap[id] ?: return
|
||||
|
||||
ExecutorProvider.getInstance().mainThreadExecutor.execute {
|
||||
safeIteratorList(listenerList) {
|
||||
it.onSizeReceived(fileSize)
|
||||
}
|
||||
}
|
||||
|
||||
updateDownloadList()
|
||||
}
|
||||
|
||||
fun registerListener(id: String, listener: DownloadListener) {
|
||||
var listenerList = mListenerMap[id]
|
||||
if (listenerList == null) {
|
||||
listenerList = FixedSizeStack(MAX_LISTENER_SIZE)
|
||||
listenerList.push(listener)
|
||||
mListenerMap[id] = listenerList
|
||||
} else {
|
||||
listenerList.push(listener)
|
||||
}
|
||||
|
||||
// Post download status if it could be obtain from database.
|
||||
val entityFromDatabase = findEntity(id)
|
||||
if (entityFromDatabase != null) {
|
||||
listener.onProgress(entityFromDatabase.progress)
|
||||
listener.onStatusChanged(entityFromDatabase.status)
|
||||
}
|
||||
}
|
||||
|
||||
fun unregisterListener(id: String, listener: DownloadListener) {
|
||||
ExecutorProvider.getInstance().mainThreadExecutor.execute {
|
||||
mListenerMap[id]?.remove(listener)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从下载列表中取 downloadEntity
|
||||
* TODO 不应该直接修改 downloadEntity 内存的值,不然会有莫名其妙的问题
|
||||
*/
|
||||
fun findEntity(id: String): SimpleDownloadEntity? {
|
||||
try {
|
||||
return downloadList.firstOrNull { it.id == id }
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
private fun updateDownloadList() {
|
||||
downloadList = try {
|
||||
ArrayList(mDownloadDao.getAllDownloadEntity())
|
||||
} catch (e: SQLiteException) {
|
||||
arrayListOf()
|
||||
}
|
||||
}
|
||||
|
||||
fun insertDownloadToDatabase(downloadEntity: SimpleDownloadEntity) {
|
||||
mDownloadDao.insertDownloadEntity(downloadEntity)
|
||||
updateDownloadList()
|
||||
}
|
||||
|
||||
fun updateDownloadToDatabase(
|
||||
downloadEntity: SimpleDownloadEntity,
|
||||
updateDownloadList: Boolean = false
|
||||
) {
|
||||
mDownloadDao.updateDownloadEntity(downloadEntity)
|
||||
|
||||
if (updateDownloadList) {
|
||||
updateDownloadList()
|
||||
}
|
||||
}
|
||||
|
||||
fun deleteDownloadOfDatabase(downloadEntity: SimpleDownloadEntity) {
|
||||
mDownloadDao.deleteDownloadEntity(downloadEntity)
|
||||
updateDownloadList()
|
||||
}
|
||||
|
||||
/*****
|
||||
* 迭代的时候针对temp Stack进行迭代
|
||||
*/
|
||||
private fun safeIteratorList(
|
||||
sourceList: FixedSizeStack<DownloadListener>?,
|
||||
function: (arg: DownloadListener) -> (Unit)
|
||||
) {
|
||||
sourceList?.apply {
|
||||
if (this.size > 0) {
|
||||
// FIXME 高频遍历时会产生巨量临时的 FixedSizeStack
|
||||
val tempStack = FixedSizeStack<DownloadListener>(MAX_LISTENER_SIZE)
|
||||
|
||||
tempStack.addAll(sourceList)
|
||||
|
||||
tempStack.forEach { listener ->
|
||||
|
||||
listener?.apply {
|
||||
function(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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,13 +6,16 @@ import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.gh.gamecenter.common.base.activity.ToolBarActivity;
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts;
|
||||
import com.gh.gamecenter.common.constant.RouteConsts;
|
||||
import com.halo.assistant.fragment.ApkCleanerFragment;
|
||||
|
||||
/**
|
||||
* Created by khy on 2017/1/24.
|
||||
*/
|
||||
@Route(path = RouteConsts.activity.cleanApkActivity)
|
||||
public class CleanApkActivity extends ToolBarActivity {
|
||||
|
||||
@NonNull
|
||||
@ -34,4 +37,9 @@ public class CleanApkActivity extends ToolBarActivity {
|
||||
bundle.putString(EntranceConsts.KEY_PLATFORM_REQUESTS_ID, platformRequestsId);
|
||||
return getTargetIntent(context, CleanApkActivity.class, ApkCleanerFragment.class, bundle);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Intent provideNormalIntent() {
|
||||
return getIntent(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -59,7 +59,7 @@ import com.gh.gamecenter.eventbus.EBPackage;
|
||||
import com.gh.gamecenter.common.eventbus.EBReuse;
|
||||
import com.gh.gamecenter.newsdetail.NewsDetailAdapter;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
import com.halo.assistant.fragment.SettingsFragment;
|
||||
import com.gh.gamecenter.setting.view.SettingsFragment;
|
||||
import com.lightgame.download.DataWatcher;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
@ -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);
|
||||
}
|
||||
@ -291,8 +291,9 @@ public class SkipActivity extends BaseActivity {
|
||||
case HOST_USERHOME:
|
||||
String position = uri.getQueryParameter("position");
|
||||
String subTypeString = uri.getQueryParameter("sub_type");
|
||||
String subGameType = uri.getQueryParameter("sub_game_type");
|
||||
|
||||
DirectUtils.directToHomeActivity(this, path, subTypeString, TextUtils.isEmpty(position) ? -1 : Integer.parseInt(position), ENTRANCE_BROWSER, "浏览器");
|
||||
DirectUtils.directToHomeActivity(this, path, subTypeString, subGameType, TextUtils.isEmpty(position) ? -1 : Integer.parseInt(position), ENTRANCE_BROWSER, "浏览器");
|
||||
break;
|
||||
case HOST_COMMUNITY_COLUMN:
|
||||
CommunityEntity community = new CommunityEntity();
|
||||
|
||||
@ -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()
|
||||
}
|
||||
@ -267,10 +269,14 @@ class SplashScreenActivity : BaseActivity() {
|
||||
intent.putExtra(MainActivity.SHOW_AD, !mIsNewForThisVersion)
|
||||
overridePendingTransition(0, 0)
|
||||
startActivity(intent)
|
||||
uploadTeaData()
|
||||
doFlavorInit()
|
||||
finish()
|
||||
}
|
||||
|
||||
private fun doFlavorInit() {
|
||||
HaloApp.getInstance().flavorProvider.init(HaloApp.getInstance(), this)
|
||||
}
|
||||
|
||||
private fun getGitLogString(): String {
|
||||
if (com.gh.gamecenter.common.BuildConfig.BUILD_TIME != 0L) {
|
||||
val stringBuilder = StringBuilder()
|
||||
@ -341,20 +347,6 @@ class SplashScreenActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun uploadTeaData() {
|
||||
if ("tea" == BuildConfig.FLAVOR) {
|
||||
// 在可能获取了相关权限后才初始化SDK/发送激活数据
|
||||
// TeaHelper.init(getApplication(), HaloApp.getInstance().getChannel());
|
||||
try {
|
||||
val clazz = Class.forName("com.gh.gamecenter.TeaHelper")
|
||||
val method = clazz.getMethod("init", Context::class.java, String::class.java)
|
||||
method.invoke(null, application, HaloApp.getInstance().channel)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun prefetchData() {
|
||||
AppExecutor.ioExecutor.execute {
|
||||
Config.getGhzsSettings()
|
||||
@ -385,10 +377,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 +469,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
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,7 +7,6 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
@ -1108,16 +1107,16 @@ public class SuggestionActivity extends ToolBarActivity implements OnRequestCall
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSingleSuccess(@NotNull Map<String, String> imageUrl) {
|
||||
public void onSingleSuccess(@NotNull Map<String, String> imageUrlMap) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(@NotNull LinkedHashMap<String, String> imageUrl, @NotNull Map<String, ? extends Exception> errorMap) {
|
||||
public void onSuccess(@NotNull LinkedHashMap<String, String> imageUrlMap, @NotNull Map<String, ? extends Exception> errorMap) {
|
||||
Utils.log("意见反馈:图片上传完成");
|
||||
final JSONArray picArray = new JSONArray();
|
||||
for (String s : imageUrl.keySet()) {
|
||||
picArray.put(imageUrl.get(s));
|
||||
for (String s : imageUrlMap.keySet()) {
|
||||
picArray.put(imageUrlMap.get(s));
|
||||
}
|
||||
initPostData(email, picArray);
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Environment;
|
||||
import android.view.View;
|
||||
@ -117,7 +118,8 @@ public class CleanApkAdapter extends BaseRecyclerAdapter<KcSelectGameViewHolder>
|
||||
appInfo.sourceDir = apk_path;
|
||||
appInfo.publicSourceDir = apk_path;
|
||||
Drawable apk_icon = appInfo.loadIcon(pm);
|
||||
apkEntity.setGameBm(BitmapUtils.drawableToBitmap(apk_icon, true));
|
||||
Bitmap originalBitmap = BitmapUtils.drawableToBitmap(apk_icon, true);
|
||||
apkEntity.setGameBm(BitmapUtils.compressBitmap(originalBitmap, 100));
|
||||
/** apk的绝对路劲 */
|
||||
apkEntity.setGamePath(apk_path);
|
||||
/** apk的版本名称 String */
|
||||
|
||||
@ -12,20 +12,20 @@ import android.view.ViewGroup;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.gh.gamecenter.common.entity.ExposureEntity;
|
||||
import com.gh.common.exposure.ExposureEvent;
|
||||
import com.gh.common.exposure.ExposureSource;
|
||||
import com.gh.common.exposure.ExposureType;
|
||||
import com.gh.gamecenter.common.utils.DataLogUtils;
|
||||
import com.gh.common.util.DirectUtils;
|
||||
import com.gh.gamecenter.MainActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.common.entity.ExposureEntity;
|
||||
import com.gh.gamecenter.common.entity.LinkEntity;
|
||||
import com.gh.gamecenter.common.utils.DataLogUtils;
|
||||
import com.gh.gamecenter.common.utils.ImageUtils;
|
||||
import com.gh.gamecenter.core.utils.MtaHelper;
|
||||
import com.gh.gamecenter.core.utils.PageSwitchDataHelper;
|
||||
import com.gh.gamecenter.core.utils.StringUtils;
|
||||
import com.gh.gamecenter.MainActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.common.entity.LinkEntity;
|
||||
import com.gh.gamecenter.entity.SubjectRecommendEntity;
|
||||
import com.gh.gamecenter.game.data.GameItemData;
|
||||
|
||||
@ -79,7 +79,7 @@ public class ImagePagerAdapter extends RecyclingPagerAdapter {
|
||||
@Override
|
||||
public View getView(final int position, View view, ViewGroup container) {
|
||||
if (view == null) {
|
||||
view = new SimpleDraweeView(mContext);
|
||||
view = View.inflate(mContext, R.layout.game_slide_list_item, null);
|
||||
}
|
||||
|
||||
int index = getPosition(position);
|
||||
@ -87,7 +87,15 @@ public class ImagePagerAdapter extends RecyclingPagerAdapter {
|
||||
|
||||
final LinkEntity slideEntity = mSlideEntityList.get(index);
|
||||
|
||||
ImageUtils.display(mContext.getResources(), (SimpleDraweeView) view, slideEntity.getImage(), R.drawable.preload);
|
||||
SimpleDraweeView slideImage = (SimpleDraweeView) view.findViewById(R.id.slideImage);
|
||||
ImageUtils.display(slideImage, slideEntity.getImage());
|
||||
|
||||
View playIv = view.findViewById(R.id.playIv);
|
||||
if ("video".equals(slideEntity.getType())) {
|
||||
playIv.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
playIv.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
ExposureEvent exposureEvent = null;
|
||||
if ("game".equals(slideEntity.getType())) {
|
||||
|
||||
@ -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, null);
|
||||
} 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;
|
||||
@ -21,18 +23,23 @@ import com.gh.common.chain.DownloadDialogHelperHandler;
|
||||
import com.gh.common.chain.GamePermissionHandler;
|
||||
import com.gh.common.chain.OverseaDownloadHandler;
|
||||
import com.gh.common.chain.PackageCheckHandler;
|
||||
import com.gh.common.chain.UpdateNewSimulatorHandler;
|
||||
import com.gh.common.chain.ValidateVSpaceHandler;
|
||||
import com.gh.common.chain.VersionNumberHandler;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.dialog.DeviceRemindDialog;
|
||||
import com.gh.common.dialog.GameOffServiceDialogFragment;
|
||||
import com.gh.common.exposure.ExposureEvent;
|
||||
import com.gh.common.filter.RegionSetting;
|
||||
import com.gh.common.filter.RegionSettingHelper;
|
||||
import com.gh.common.history.HistoryHelper;
|
||||
import com.gh.common.simulator.NewSimulatorGameManager;
|
||||
import com.gh.common.simulator.SimulatorDownloadManager;
|
||||
import com.gh.common.simulator.SimulatorGameManager;
|
||||
import com.gh.common.util.CheckLoginUtils;
|
||||
import com.gh.common.util.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;
|
||||
@ -58,9 +65,11 @@ import com.gh.gamecenter.entity.ApkEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.common.entity.LinkEntity;
|
||||
import com.gh.gamecenter.common.eventbus.EBReuse;
|
||||
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;
|
||||
@ -92,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;
|
||||
@ -189,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:
|
||||
@ -216,13 +266,15 @@ public class DetailViewHolder {
|
||||
DataLogUtils.uploadGameLog(mViewHolder.context, mGameEntity.getId(), mGameEntity.getName(), mEntrance);
|
||||
}
|
||||
case PLUGIN:
|
||||
|
||||
|
||||
ChainBuilder builder = new ChainBuilder();
|
||||
builder.addHandler(new UpdateNewSimulatorHandler());
|
||||
builder.addHandler(new ValidateVSpaceHandler());
|
||||
builder.addHandler(new GamePermissionHandler());
|
||||
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());
|
||||
@ -232,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();
|
||||
@ -262,6 +314,10 @@ public class DetailViewHolder {
|
||||
if (mGameEntity.getApk().size() == 1) {
|
||||
//启动模拟器游戏
|
||||
if (SimulatorGameManager.isSimulatorGame(mGameEntity)) {
|
||||
if (NewSimulatorGameManager.shouldShowUpdateNewSimulatorAlert(mViewHolder.context)) {
|
||||
NewSimulatorGameManager.showUpdateNewsSimulator(mViewHolder.context, null);
|
||||
return;
|
||||
}
|
||||
DownloadEntity downloadEntity = SimulatorGameManager.findDownloadEntityByUrl(mGameEntity.getApk().get(0).getUrl());
|
||||
if (downloadEntity != null) {
|
||||
File file = new File(downloadEntity.getPath());
|
||||
@ -301,8 +357,18 @@ public class DetailViewHolder {
|
||||
DownloadEntity downloadEntity = SimulatorGameManager.findDownloadEntityByUrl(apk.getUrl());
|
||||
if (mGameEntity.getSimulator() != null) {
|
||||
boolean isInstalled = PackageUtils.isInstalledFromAllPackage(mViewHolder.context, mGameEntity.getSimulator().getApk().getPackageName());
|
||||
if (downloadEntity != null && SimulatorGameManager.isSimulatorGame(mGameEntity) && !isInstalled) {
|
||||
SimulatorDownloadManager.getInstance().showDownloadDialog(mViewHolder.context, mGameEntity.getSimulator(),
|
||||
boolean isInstalledNewSimulator = SimulatorGameManager.isNewSimulatorInstalled(mViewHolder.context);
|
||||
boolean isInstalledOldSimulator = SimulatorGameManager.isOldSimulatorInstalled(mViewHolder.context);
|
||||
SimulatorEntity simulator = mGameEntity.getSimulator();
|
||||
SimulatorEntity newSimulator = Config.getNewSimulatorEntitySetting();
|
||||
if (!isInstalledOldSimulator && newSimulator != null) {
|
||||
if (newSimulator.getActive()) {
|
||||
simulator = newSimulator;
|
||||
}
|
||||
}
|
||||
|
||||
if (downloadEntity != null && SimulatorGameManager.isSimulatorGame(mGameEntity) && !isInstalled && !isInstalledNewSimulator) {
|
||||
SimulatorDownloadManager.getInstance().showDownloadDialog(mViewHolder.context, simulator,
|
||||
SimulatorDownloadManager.SimulatorLocation.LAUNCH, mGameEntity.getId(), mGameEntity.getName(), null);
|
||||
return;
|
||||
}
|
||||
@ -315,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) {
|
||||
@ -391,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));
|
||||
@ -402,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) {
|
||||
@ -452,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 {
|
||||
|
||||
@ -6,6 +6,7 @@ import com.gh.gamecenter.common.base.BaseRecyclerViewHolder
|
||||
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.goneIf
|
||||
import com.gh.gamecenter.databinding.GameHeadItemBinding
|
||||
import com.gh.gamecenter.entity.SubjectEntity
|
||||
|
||||
@ -64,5 +65,6 @@ class GameHeadViewHolder(var binding: GameHeadItemBinding) :
|
||||
binding.arrowIv.visibility = View.VISIBLE
|
||||
}
|
||||
binding.headTitle.setTextColor(R.color.text_title.toColor(binding.root.context))
|
||||
binding.adLabelTv.goneIf(!subject.adIconActive)
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,11 +15,9 @@ 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;
|
||||
multiVersionDownloadTv = binding.multiVersionDownloadTv;
|
||||
gameDownloadTips = binding.downloadTipsLottie;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user