Compare commits
369 Commits
v5.13.1-61
...
feature-mo
| Author | SHA1 | Date | |
|---|---|---|---|
| 04468c0627 | |||
| e585d905ac | |||
| 1f066e676f | |||
| a08f3aa9ac | |||
| b0ad6ff8c5 | |||
| ccbe6650d1 | |||
| f99b3af9c6 | |||
| a5ce8f389c | |||
| 8f5daed7a7 | |||
| f799096655 | |||
| 431aa52e49 | |||
| 9ee743c14f | |||
| 8be8430543 | |||
| de2c0dc0c3 | |||
| e961642cf7 | |||
| fb8bd8b440 | |||
| 26d6e4086a | |||
| ed19677568 | |||
| 7e999784b7 | |||
| c4cf232d35 | |||
| 5fe552ad91 | |||
| 1db87a4152 | |||
| 1bd741be9c | |||
| 7570e3e14e | |||
| ca009fb1b2 | |||
| 872ac7bb85 | |||
| 8ce13fd0db | |||
| bb80862d19 | |||
| 02eea04cdc | |||
| 133b3aec96 | |||
| 4b974e3278 | |||
| 927e0e2468 | |||
| be3d509c9c | |||
| 40bd4a1adf | |||
| b6bb3bf794 | |||
| ef6ef5c584 | |||
| a600a9f0b0 | |||
| 31d0ce1302 | |||
| bffa36bc5d | |||
| 716a32a2b5 | |||
| 70c09648a8 | |||
| a7cdade878 | |||
| b479048a87 | |||
| 714d975602 | |||
| a363090e4e | |||
| f07b37ff01 | |||
| d0efdccb1d | |||
| e5d73e5c73 | |||
| e2f5de67a7 | |||
| c34cacb5d0 | |||
| 681ba37c4e | |||
| d4d71d27ce | |||
| 609b2805cc | |||
| 987ab1ccc9 | |||
| 93a77df0dc | |||
| e1c365ffe5 | |||
| 8863b02c7a | |||
| 89b97d274b | |||
| bbe3f9c741 | |||
| e7d0c15a0a | |||
| ddfb474624 | |||
| b15b8c1237 | |||
| 0af8660b14 | |||
| 4ea2f8d5af | |||
| f07bcc89e8 | |||
| 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 | |||
| ea51827ed6 | |||
| ff4a78ae93 | |||
| 8437bfe1e3 | |||
| 19ff2a1fb7 | |||
| 2efd0e8bc9 | |||
| a169ce1989 | |||
| 6dca8cf33c | |||
| c327fcaf99 | |||
| 322774fc78 | |||
| 8128aa603c | |||
| b05fb22e42 | |||
| 2ab9b175e9 | |||
| b032f054f9 | |||
| f37b3a9729 | |||
| 1e9f17bba5 | |||
| 9690429e95 | |||
| f95365c6ba | |||
| 97022f19f6 | |||
| 9f60dd7c55 | |||
| 0124fa4d8e | |||
| b1dff15234 | |||
| e3eef66884 | |||
| 56395bc6fa | |||
| 7f2fd57d43 | |||
| fb6d96e79d | |||
| 369edbe04e | |||
| 2a56165424 | |||
| 48b8c46cdf | |||
| 6b33a0a2ff | |||
| b38d90b107 | |||
| 896f43246b | |||
| b5e3d3a03e | |||
| 65fc3e6304 | |||
| 3f895d2cc3 | |||
| 58cebe900e | |||
| ecf003bd84 | |||
| 7c2dae7125 | |||
| 8451a776dd | |||
| 2cb91a7917 | |||
| 4d9b53420f | |||
| 82300e4b4e | |||
| 5e9dc881d5 | |||
| 1a1ed4a159 | |||
| b9d6dfc83a | |||
| fbc1ccf886 | |||
| f33b699723 | |||
| a970db9ca1 | |||
| 28d983dc00 | |||
| 24193a6456 | |||
| bb264496cc | |||
| 11b75a9c52 | |||
| eebc531707 | |||
| 5f5dc8e50f | |||
| 017188a409 | |||
| f23ac762e2 | |||
| 829991571e | |||
| af01bd6990 | |||
| 1150be4f52 | |||
| c685df4fd7 | |||
| f8d372207e | |||
| 83358fab7d | |||
| 6ac1465329 | |||
| 596b5603cf | |||
| e0cd733d63 | |||
| 1d53a12082 | |||
| 22cff4ed72 | |||
| 7f12dc09a0 | |||
| 7254db3c0e | |||
| 5de5d07bca | |||
| 3442602ff8 | |||
| a57e4caa22 | |||
| 05006d91b5 | |||
| cfd67f3160 | |||
| a66c6daa82 | |||
| 73818acb9f | |||
| ebbbc618b9 | |||
| 5a560869d3 | |||
| 81c3381d94 | |||
| f0b7cdda32 | |||
| 72c5c844fc | |||
| e405be9deb | |||
| 752f79ad65 | |||
| e377a52e74 | |||
| 91c343a02b | |||
| 1fbc834597 | |||
| 9251ade73c | |||
| d759ec2d66 | |||
| 22053f5c7f | |||
| ab968673e1 | |||
| bec06b63c7 | |||
| 8efe5ec460 | |||
| 025e72101f | |||
| bd1887baad | |||
| 082e9b376a | |||
| 5014eda3f2 | |||
| 1b4852ae0c | |||
| 52a23f5bde | |||
| baae314d85 | |||
| 85372416c0 | |||
| 6d8908fe57 | |||
| 4d0d9c0b48 | |||
| a68782203b | |||
| 2fcfaf2ccd | |||
| d58a6df56a | |||
| 2f8a783565 | |||
| 9234a2f4ee | |||
| 662dd88be7 | |||
| ba64292b76 | |||
| 6fd43dd61b | |||
| 4ce7eee8eb | |||
| e3c2711b64 | |||
| e00df4a066 | |||
| 9764c2ce1a | |||
| f588c2d981 | |||
| e5dad8a8ce | |||
| 3818160a5e | |||
| 2367a0bf8a | |||
| b2e728331a | |||
| 7af3233152 | |||
| 243ad6afb1 | |||
| 0c3a063d86 | |||
| 558aa9a09e | |||
| 33c9a2e90b | |||
| e618a0d5fd | |||
| ccc97a93da | |||
| 3e16f59dc5 | |||
| c9993de3ca | |||
| e3c140e5fd | |||
| b2f6d111a7 | |||
| ea03e7a73f | |||
| c08f268b04 | |||
| f6423cb7ff | |||
| 89f00d7412 | |||
| 68061d96ed | |||
| 388c11b173 | |||
| ced7202d04 | |||
| 07c7d37d3d | |||
| 030c10c6cc | |||
| 16162a6944 | |||
| 5b9879e8a0 | |||
| 99446c7b74 | |||
| 077b865b81 | |||
| e1a95a241a | |||
| 50e15fa79a | |||
| 933c3c4fce | |||
| 2a79c9cddd | |||
| 7d6fb3e815 | |||
| 1c95a6b968 | |||
| 23c7a741cc | |||
| 46bdc4e4f7 | |||
| f41836615d | |||
| d883b29cde | |||
| d36055276d | |||
| e0c1d8169d | |||
| c18945113c | |||
| 6ec3d21994 | |||
| add6b2bc5e | |||
| 936c793ddf | |||
| bb08a845fc | |||
| a36c2085ef | |||
| d7e0de88d7 | |||
| 931213dc82 | |||
| 11c7959b38 | |||
| 4989debca5 | |||
| 082a5fbff8 | |||
| 396bfbf52d | |||
| c4ad84d0c6 | |||
| da997ad544 | |||
| f374f105ce | |||
| fef66248ea | |||
| d3e499696f | |||
| 4631d4daeb | |||
| 9bdf69e9a6 | |||
| 861b8312e1 | |||
| c4763ea342 | |||
| ff0dcfd7e1 | |||
| 6c558a1a17 | |||
| e0870b875f | |||
| 7e26003698 | |||
| 7a5e27cffa | |||
| 0711d72f6d | |||
| 07331efffb | |||
| 585acb9bae | |||
| 9434d7f9ba | |||
| 11643b9be0 | |||
| 2bec88c130 | |||
| ef9fd9d256 | |||
| 580e86c148 | |||
| 9ff97dde77 | |||
| 207b650c34 | |||
| 1ce7cd8ee3 | |||
| b015d76004 | |||
| 5f622d894d | |||
| c37b299ab7 | |||
| 41331d23a0 | |||
| 5e3a38f52d | |||
| 21c8f4cf62 | |||
| fb08bc59be | |||
| 680590e6c2 | |||
| ee169b55c5 | |||
| d3caa5d66c | |||
| c195be5137 | |||
| 40ce144fee | |||
| ba2fd87b21 | |||
| 0e385e193f | |||
| 341eabee27 | |||
| b2a1ce54a3 | |||
| 42fd666ba0 | |||
| 2aeaecfaf3 | |||
| 44d039658e | |||
| fd933f9d59 | |||
| 1b5a62e018 | |||
| 6bf74b4e03 | |||
| 537e59759b | |||
| 13f937dc0e | |||
| e3f0c2bb11 | |||
| 2eabc52aa7 | |||
| cf8615c6c3 | |||
| ab7bcc2b14 | |||
| 99b0010784 | |||
| 4af170d4fa | |||
| c45d4b5e19 | |||
| 9fca1f1551 | |||
| b8662e24a0 | |||
| ad1bee4b56 | |||
| 18ee571604 | |||
| d50615633f | |||
| 7e8702363c | |||
| f02032dd47 | |||
| f486b3aba9 | |||
| 9afa8ad61b | |||
| 9debcdf55b | |||
| 414aaeb5ea | |||
| b0d1204341 | |||
| 9d76bcc06e | |||
| 4be0ea9a96 | |||
| 61d16a9b50 | |||
| 848b41ea76 | |||
| 2bd3990404 | |||
| 552da837c1 | |||
| 192b1db9c9 | |||
| d9d7e713ba | |||
| 249b5ac876 | |||
| 14d961ed07 | |||
| 3315686440 | |||
| bea3cdeacb | |||
| 1d10028353 | |||
| ee6f53ac92 | |||
| cdfda0d175 | |||
| c6dbd167c9 | |||
| b404bb91f9 | |||
| a2488fe0c7 | |||
| 7602e27ac5 | |||
| 6d21a5e8ae | |||
| 77a1ae68ce | |||
| ccbacf6d37 | |||
| 33c408d7e5 | |||
| 774f97261f | |||
| 55e7193149 | |||
| d17bb2ac83 | |||
| 70cc9bbcb6 | |||
| 7ed1a37801 | |||
| c30a2cca6d | |||
| 9a55cc297a | |||
| 07a72bce77 | |||
| 8384464066 | |||
| 21f99df976 | |||
| 457f050948 |
@ -38,7 +38,6 @@ send_sonar_report:
|
||||
dependencies: [] #禁止传递来的artifact
|
||||
script:
|
||||
- group=`echo $CI_PROJECT_PATH | sed 's#/#-#g'`
|
||||
- docker login -u "${HARBOR_REGISTRY_USERNAME}" -p "${HARBOR_REGISTRY_PASSWORD}" "${HARBOR_REGISTRY}"
|
||||
- docker run -e PROJECTKEY=$group -e EMAIL=$GITLAB_USER_EMAIL --name send-email --rm hub.shanqu.cc/platform/send-sonar-report:latest
|
||||
only:
|
||||
- dev
|
||||
|
||||
6
.gitmodules
vendored
6
.gitmodules
vendored
@ -2,9 +2,9 @@
|
||||
path = libraries/LGLibrary
|
||||
url = git@git.shanqu.cc:android/common-library.git
|
||||
branch = master
|
||||
[submodule "assistant_flutter"]
|
||||
path = assistant_flutter
|
||||
url = git@git.shanqu.cc:halo/android/flutter-module.git
|
||||
[submodule "vspace-bridge"]
|
||||
path = vspace-bridge
|
||||
url = git@git.shanqu.cc:cwzs/android/vspace-bridge.git
|
||||
[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
|
||||
|
||||
@ -77,8 +77,6 @@ android {
|
||||
buildConfigField "String", "WECHAT_SECRET", "\"${WECHAT_SECRET}\""
|
||||
buildConfigField "String", "TENCENT_APPID", "\"${TENCENT_APPID}\""
|
||||
buildConfigField "String", "WEIBO_APPKEY", "\"${WEIBO_APPKEY}\""
|
||||
buildConfigField "String", "QUICK_LOGIN_APPID", "\"${QUICK_LOGIN_APPID}\""
|
||||
buildConfigField "String", "QUICK_LOGIN_APPKEY", "\"${QUICK_LOGIN_APPKEY}\""
|
||||
}
|
||||
|
||||
// gradle 2.2以上默认同时启用v1和v2(优先用于Android N)
|
||||
@ -157,6 +155,8 @@ android {
|
||||
buildConfigField "String", "DEV_API_HOST", "\"${DEV_API_HOST}\""
|
||||
buildConfigField "String", "NEW_DEV_API_HOST", "\"${NEW_DEV_API_HOST}\""
|
||||
buildConfigField "String", "DEV_VAPI_HOST", "\"${DEV_VAPI_HOST}\""
|
||||
buildConfigField "String", "QUICK_LOGIN_APPID", "\"${DEV_QUICK_LOGIN_APPID}\""
|
||||
buildConfigField "String", "QUICK_LOGIN_APPKEY", "\"${DEV_QUICK_LOGIN_APPKEY}\""
|
||||
}
|
||||
|
||||
// publish release host
|
||||
@ -166,6 +166,8 @@ android {
|
||||
buildConfigField "String", "DEV_API_HOST", "\"${API_HOST}\""
|
||||
buildConfigField "String", "NEW_DEV_API_HOST", "\"${NEW_API_HOST}\""
|
||||
buildConfigField "String", "DEV_VAPI_HOST", "\"${VAPI_HOST}\""
|
||||
buildConfigField "String", "QUICK_LOGIN_APPID", "\"${QUICK_LOGIN_APPID}\""
|
||||
buildConfigField "String", "QUICK_LOGIN_APPKEY", "\"${QUICK_LOGIN_APPKEY}\""
|
||||
}
|
||||
|
||||
tea {
|
||||
@ -174,15 +176,12 @@ android {
|
||||
buildConfigField "String", "DEV_API_HOST", "\"${API_HOST}\""
|
||||
buildConfigField "String", "NEW_DEV_API_HOST", "\"${NEW_API_HOST}\""
|
||||
buildConfigField "String", "DEV_VAPI_HOST", "\"${VAPI_HOST}\""
|
||||
buildConfigField "String", "QUICK_LOGIN_APPID", "\"${QUICK_LOGIN_APPID}\""
|
||||
buildConfigField "String", "QUICK_LOGIN_APPKEY", "\"${QUICK_LOGIN_APPKEY}\""
|
||||
|
||||
manifestPlaceholders.put("APPLOG_SCHEME", "rangersapplog.byAx6uYt".toLowerCase())
|
||||
}
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
// For flutter release build, see https://github.com/flutter/flutter/issues/58247
|
||||
checkReleaseBuilds false
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
@ -199,6 +198,7 @@ dependencies {
|
||||
testImplementation 'junit:junit:4.12'
|
||||
|
||||
debugImplementation "com.squareup.leakcanary:leakcanary-android:${leakcanary}"
|
||||
debugImplementation "com.squareup.leakcanary:leakcanary-android-process:${leakcanary}"
|
||||
|
||||
// debugImplementation "com.gu.android:toolargetool:${toolargetool}" // 需要使用调试时才启用
|
||||
debugImplementation "com.github.nichbar:WhatTheStack:${whatTheStack}"
|
||||
@ -238,7 +238,7 @@ dependencies {
|
||||
})
|
||||
implementation "com.github.CarGuo.GSYVideoPlayer:gsyVideoPlayer-exo_player2:$gsyVideo"
|
||||
|
||||
implementation "androidx.work:work-runtime:${workManager}"
|
||||
// implementation "androidx.work:work-runtime:${workManager}"
|
||||
|
||||
implementation "com.llew.huawei:verifier:${verifier}"
|
||||
|
||||
@ -268,9 +268,13 @@ dependencies {
|
||||
implementation(project(':module_login')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
implementation(project(':module_energy')) {
|
||||
implementation(project(':module_setting_compose')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
// 默认不接入光能模块,提高编译速度
|
||||
// debugImplementation(project(':module_energy')) {
|
||||
// exclude group: 'androidx.swiperefreshlayout'
|
||||
// }
|
||||
}
|
||||
File propFile = file('sign.properties')
|
||||
if (propFile.exists()) {
|
||||
@ -361,36 +365,14 @@ andResGuard {
|
||||
"R.drawable.bg_notification_reserve_game_style_2",
|
||||
"R.drawable.bg_notification_video_style_1",
|
||||
"R.drawable.bg_notification_video_style_2",
|
||||
"R.drawable.ic_search_no_1",
|
||||
"R.drawable.ic_search_no_2",
|
||||
"R.drawable.ic_search_no_3",
|
||||
"R.drawable.ic_search_no_4",
|
||||
"R.drawable.ic_search_no_5",
|
||||
"R.drawable.ic_search_no_6",
|
||||
"R.drawable.ic_search_no_7",
|
||||
"R.drawable.ic_search_no_8",
|
||||
"R.drawable.ic_search_no_9",
|
||||
"R.drawable.ic_search_no_10",
|
||||
"R.drawable.ic_search_no_11",
|
||||
"R.drawable.ic_search_no_12",
|
||||
"R.drawable.ic_search_no_13",
|
||||
"R.drawable.ic_search_no_14",
|
||||
"R.drawable.ic_search_no_15",
|
||||
"R.drawable.ic_search_no_16",
|
||||
"R.drawable.ic_search_no_17",
|
||||
"R.drawable.ic_search_no_18",
|
||||
"R.drawable.ic_search_no_19",
|
||||
"R.drawable.ic_search_no_20",
|
||||
"R.drawable.ic_recommend_activity",
|
||||
"R.drawable.ic_recommend_discount",
|
||||
"R.drawable.ic_recommend_function",
|
||||
"R.drawable.ic_recommend_gift",
|
||||
"R.drawable.ic_recommend_role",
|
||||
"R.drawable.download_button_normal_style",
|
||||
"R.drawable.ic_quick_login_check",
|
||||
"R.drawable.ic_quick_login_uncheck",
|
||||
"R.anim.anim_auth_in",
|
||||
"R.anim.anim_auth_out",
|
||||
"R.drawable.ic_selector_selected",
|
||||
"R.drawable.ic_selector_default",
|
||||
"R.id.download_speed",
|
||||
"R.id.download_percentage",
|
||||
"R.id.comment",
|
||||
@ -412,7 +394,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",
|
||||
|
||||
BIN
app/libs/quick_login_android_5.9.4.aar
Executable file
BIN
app/libs/quick_login_android_5.9.4.aar
Executable file
Binary file not shown.
@ -1,266 +0,0 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in C:\Android\sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
#--------- remove logs start ----------------
|
||||
-assumenosideeffects class com.lightgame.config.CommonDebug {
|
||||
private static String getLogTag(...);
|
||||
private static String getMethodName();
|
||||
public static void logMethodName(...);
|
||||
public static void logParams(...);
|
||||
public static void logFields(...);
|
||||
public static void logMethodWithParams(...);
|
||||
}
|
||||
#-assumenosideeffects class com.lightgame.config.CommonDebug {*;}
|
||||
|
||||
#-dontoptimize
|
||||
#--------- remove logs end ----------------
|
||||
|
||||
-keepattributes *Annotation*,Signature,InnerClasses,EnclosingMethod
|
||||
-dontwarn InnerClasses
|
||||
|
||||
# OrmLite uses reflection
|
||||
-keep class com.j256.**
|
||||
-keepclassmembers class com.j256.** { *; }
|
||||
-keep enum com.j256.**
|
||||
-keepclassmembers enum com.j256.** { *; }
|
||||
-keep interface com.j256.**
|
||||
-keepclassmembers interface com.j256.** { *; }
|
||||
-dontwarn com.j256.**
|
||||
|
||||
#okhttp3
|
||||
-dontwarn com.squareup.okhttp3.**
|
||||
-dontwarn okio.**
|
||||
-keep class com.squareup.okhttp3.** { *;}
|
||||
|
||||
# stetho
|
||||
-keep class com.facebook.stetho.** { *; }
|
||||
-dontwarn com.facebook.stetho.**
|
||||
|
||||
# Retrofit 2.2
|
||||
# Platform calls Class.forName on types which do not exist on Android to determine platform.
|
||||
-dontnote retrofit2.Platform
|
||||
# Platform used when running on Java 8 VMs. Will not be used at runtime.
|
||||
-dontwarn retrofit2.Platform$Java8
|
||||
# Retain generic type information for use by reflection by converters and adapters.
|
||||
-keepattributes Signature
|
||||
# Retain declared checked exceptions for use by a Proxy instance.
|
||||
-keepattributes Exceptions
|
||||
|
||||
# Retrofit 2.X
|
||||
## https://square.github.io/retrofit/ ##
|
||||
|
||||
-dontwarn retrofit2.**
|
||||
-keep class retrofit2.** { *; }
|
||||
-keepattributes Signature
|
||||
-keepattributes Exceptions
|
||||
|
||||
-keepclasseswithmembers class * {
|
||||
@retrofit2.http.* <methods>;
|
||||
}
|
||||
|
||||
|
||||
# rxjava
|
||||
-keep class rx.schedulers.Schedulers {
|
||||
public static <methods>;
|
||||
}
|
||||
-keep class rx.schedulers.ImmediateScheduler {
|
||||
public <methods>;
|
||||
}
|
||||
-keep class rx.schedulers.TestScheduler {
|
||||
public <methods>;
|
||||
}
|
||||
-keep class rx.schedulers.Schedulers {
|
||||
public static ** test();
|
||||
}
|
||||
-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
|
||||
long producerIndex;
|
||||
long consumerIndex;
|
||||
}
|
||||
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
|
||||
long producerNode;
|
||||
long consumerNode;
|
||||
}
|
||||
-dontwarn rx.internal.util.**
|
||||
|
||||
## AutoScrollViewPager
|
||||
-keep class cn.trinea.android.** { *; }
|
||||
-keepclassmembers class cn.trinea.android.** { *; }
|
||||
-dontwarn cn.trinea.android.**
|
||||
|
||||
## butterknife
|
||||
# Retain generated class which implement Unbinder.
|
||||
#-keep public class * implements butterknife.Unbinder { public <init>(**, android.view.View); }
|
||||
#
|
||||
## Prevent obfuscation of types which use ButterKnife annotations since the simple name
|
||||
## is used to reflectively look up the generated ViewBinding.
|
||||
#-keep class butterknife.*
|
||||
#-keepclasseswithmembernames class * { @butterknife.* <methods>; }
|
||||
#-keepclasseswithmembernames class * { @butterknife.* <fields>; }
|
||||
|
||||
-dontwarn butterknife.internal.**
|
||||
-keep class **$$ViewInjector { *; }
|
||||
-keepnames class * { @butterknife.InjectView *;}
|
||||
-dontwarn butterknife.Views$InjectViewProcessor
|
||||
-dontwarn com.gc.materialdesign.views.**
|
||||
|
||||
# eventbus
|
||||
-keepattributes *Annotation*
|
||||
-keepclassmembers class ** {
|
||||
@org.greenrobot.eventbus.Subscribe <methods>;
|
||||
}
|
||||
-keep enum org.greenrobot.eventbus.ThreadMode { *; }
|
||||
|
||||
# Only required if you use AsyncExecutor
|
||||
-keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {
|
||||
<init>(java.lang.Throwable);
|
||||
}
|
||||
|
||||
# weiboSdk
|
||||
-keep class com.sina.weibo.sdk.** { *; }
|
||||
-dontwarn android.webkit.WebView
|
||||
-dontwarn android.webkit.WebViewClient
|
||||
|
||||
# app models
|
||||
-keep class com.gh.common.view.** {*;}
|
||||
-keep class com.gh.gamecenter.db.info.** {*;}
|
||||
-keep class com.gh.gamecenter.entity.** {*;}
|
||||
-keep class com.gh.gamecenter.qa.entity.** {*;}
|
||||
-keep class com.gh.gamecenter.retrofit.** {*;}
|
||||
-keep class com.gh.gamecenter.eventbus.** {*;}
|
||||
-keep class com.gh.gamecenter.video.detail.** {*;}
|
||||
-keep class * extends rx.Subscriber
|
||||
|
||||
#---------------------------------webview------------------------------------
|
||||
-keepclassmembers class * extends android.webkit.WebViewClient {
|
||||
public void *(android.webkit.WebView, java.lang.String, android.graphics.Bitmap);
|
||||
public boolean *(android.webkit.WebView, java.lang.String);
|
||||
}
|
||||
-keepclassmembers class * extends android.webkit.WebViewClient {
|
||||
public void *(android.webkit.WebView, java.lang.String);
|
||||
}
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
||||
##---------------Begin: proguard configuration for Gson ----------
|
||||
# Gson uses generic type information stored in a class file when working with fields. Proguard
|
||||
# removes such information by default, so configure it to keep all of it.
|
||||
-keepattributes Signature
|
||||
|
||||
# For using GSON @Expose annotation
|
||||
-keepattributes *Annotation*
|
||||
|
||||
# Gson specific classes
|
||||
-keep class sun.misc.Unsafe { *; }
|
||||
#-keep class com.google.gson.stream.** { *; }
|
||||
|
||||
# Prevent proguard from stripping interface information from TypeAdapterFactory,
|
||||
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
|
||||
-keep class * implements com.google.gson.TypeAdapterFactory
|
||||
-keep class * implements com.google.gson.JsonSerializer
|
||||
-keep class * implements com.google.gson.JsonDeserializer
|
||||
|
||||
-keepclassmembers enum * { *; }
|
||||
|
||||
##---------------End: proguard configuration for Gson ----------
|
||||
|
||||
# ------ bugly ---------
|
||||
-dontwarn com.tencent.bugly.**
|
||||
-keep public class com.tencent.bugly.**{*;}
|
||||
|
||||
# easypermission
|
||||
-keepclassmembers class * {
|
||||
@pub.devrel.easypermissions.AfterPermissionGranted <methods>;
|
||||
}
|
||||
|
||||
# 重命名文件为SourceFile,再配合mapping符号表,可以拿到真实的类名
|
||||
-renamesourcefileattribute SourceFile
|
||||
# 保留源文件行号
|
||||
-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
-ignorewarnings
|
||||
|
||||
-keep @androidx.annotation.Keep class *
|
||||
-keepclassmembers class ** {
|
||||
@androidx.annotation.Keep *;
|
||||
}
|
||||
|
||||
-keep class com.gh.loghub.** { *; }
|
||||
|
||||
### greenDAO 3
|
||||
-keepclassmembers class * extends org.greenrobot.greendao.AbstractDao {
|
||||
public static java.lang.String TABLENAME;
|
||||
}
|
||||
-keep class **$Properties
|
||||
-keep class org.greenrobot.greendao.** { *; }
|
||||
# If you do not use SQLCipher:
|
||||
-dontwarn org.greenrobot.greendao.database.**
|
||||
# If you do not use RxJava:
|
||||
-dontwarn rx.**
|
||||
-dontwarn org.greenrobot.greendao.rx.**
|
||||
-dontwarn org.greenrobot.greendao.**
|
||||
|
||||
### fastJson
|
||||
-dontwarn com.alibaba.fastjson.**
|
||||
-keep class com.alibaba.fastjson.** { *; }
|
||||
-keepattributes Signature
|
||||
-keepattributes Annotation
|
||||
|
||||
### AndroidX
|
||||
-keep class androidx.core.app.CoreComponentFactory { *; }
|
||||
|
||||
#阿里云上传
|
||||
-keep class com.alibaba.sdk.android.oss.** { *; }
|
||||
-dontwarn okio.**
|
||||
-dontwarn org.apache.commons.codec.binary.**
|
||||
|
||||
#视频相关
|
||||
-keep class com.shuyu.gsyvideoplayer.video.** { *; }
|
||||
-dontwarn com.shuyu.gsyvideoplayer.video.**
|
||||
-keep class com.shuyu.gsyvideoplayer.video.base.** { *; }
|
||||
-dontwarn com.shuyu.gsyvideoplayer.video.base.**
|
||||
-keep class com.shuyu.gsyvideoplayer.utils.** { *; }
|
||||
-dontwarn com.shuyu.gsyvideoplayer.utils.**
|
||||
-keep class tv.danmaku.ijk.** { *; }
|
||||
-dontwarn tv.danmaku.ijk.**
|
||||
-keep public class * extends android.view.View{
|
||||
*** get*();
|
||||
void set*(***);
|
||||
public <init>(android.content.Context);
|
||||
public <init>(android.content.Context, android.util.AttributeSet);
|
||||
public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||
}
|
||||
|
||||
#穿山甲
|
||||
-keep class com.bytedance.sdk.openadsdk.** { *; }
|
||||
-keep public interface com.bytedance.sdk.openadsdk.downloadnew.** {*;}
|
||||
-keep class com.pgl.sys.ces.* {*;}
|
||||
|
||||
-keep class com.gyf.immersionbar.* {*;}
|
||||
-dontwarn com.gyf.immersionbar.**
|
||||
|
||||
-keep class com.taobao.securityjni.**{*;}
|
||||
-keep class com.taobao.wireless.security.**{*;}
|
||||
-keep class com.ut.secbody.**{*;}
|
||||
-keep class com.taobao.dp.**{*;}
|
||||
-keep class com.alibaba.wireless.security.**{*;}
|
||||
|
||||
-keep class com.alibaba.sdk.android.**{*;}
|
||||
-keep class com.ut.**{*;}
|
||||
-keep class com.ta.**{*;}
|
||||
|
||||
-keep class com.gh.gamecenter.TeaHelper { *; }
|
||||
@ -1,30 +1,7 @@
|
||||
|
||||
#--------- remove logs start ----------------
|
||||
-assumenosideeffects class com.lightgame.config.CommonDebug {
|
||||
private static String getLogTag(...);
|
||||
private static String getMethodName();
|
||||
public static void logMethodName(...);
|
||||
public static void logParams(...);
|
||||
public static void logFields(...);
|
||||
public static void logMethodWithParams(...);
|
||||
}
|
||||
|
||||
-assumenosideeffects class com.lightgame.utils.Utils {
|
||||
public static void log(...);
|
||||
}
|
||||
#--------- remove logs end ----------------
|
||||
|
||||
# inline getter method
|
||||
-allowaccessmodification
|
||||
|
||||
#--------- remove useless mtahelper class --------
|
||||
-assumenosideeffects class com.gh.gamecenter.core.utils.MtaHelper {
|
||||
public static void onEvent(...);
|
||||
public static void onEventWithTime(...);
|
||||
public static void onEventWithBasicDeviceInfo(...);
|
||||
}
|
||||
#--------- remove useless mta class end ----
|
||||
|
||||
# TODO Dicard sourceFile in final release build but remain in internal build.
|
||||
-renamesourcefileattribute SourceFile
|
||||
# Keep Attribute
|
||||
@ -39,74 +16,20 @@
|
||||
-keepclassmembers interface com.j256.* { *; }
|
||||
-dontwarn com.j256.**
|
||||
|
||||
### AutoScrollViewPager
|
||||
-keep class cn.trinea.android.* { *; }
|
||||
-keepclassmembers class cn.trinea.android.* { *; }
|
||||
-dontwarn cn.trinea.android.**
|
||||
|
||||
### eventbus
|
||||
-keepclassmembers class * {
|
||||
@org.greenrobot.eventbus.Subscribe <methods>;
|
||||
}
|
||||
-keep enum org.greenrobot.eventbus.ThreadMode { *; }
|
||||
|
||||
### Only required if you use AsyncExecutor
|
||||
-keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {
|
||||
<init>(java.lang.Throwable);
|
||||
}
|
||||
|
||||
### weiboSdk
|
||||
-keep class com.sina.weibo.sdk.** { *; }
|
||||
-dontwarn android.webkit.WebView
|
||||
-dontwarn android.webkit.WebViewClient
|
||||
|
||||
### wechatSdk
|
||||
### TODO 这里用 com.tencent.*{*;} 不起效?但其它地方可以?
|
||||
-keep class com.tencent.**{*;}
|
||||
|
||||
### app models
|
||||
-keep class com.gh.common.view.* {*;}
|
||||
-keep class com.gh.gamecenter.db.info.* {*;}
|
||||
-keep class com.gh.gamecenter.entity.* {*;}
|
||||
-keep class com.gh.gamecenter.common.entity.* {*;}
|
||||
-keep class com.gh.gamecenter.qa.entity.* {*;}
|
||||
-keep class com.gh.gamecenter.login.entity.* {*;}
|
||||
-keep class com.gh.gamecenter.energy.entity.* {*;}
|
||||
-keep class com.gh.gamecenter.retrofit.* {*;}
|
||||
-keep class com.gh.gamecenter.eventbus.* {*;}
|
||||
-keep class com.gh.gamecenter.common.eventbus.* {*;}
|
||||
-keep class com.gh.gamecenter.energy.eventbus.* {*;}
|
||||
-keep class com.gh.gamecenter.video.detail.* {*;}
|
||||
-keep class com.gh.gamecenter.home.gamecollection.* {*;}
|
||||
|
||||
###
|
||||
-keepclassmembers class * extends android.webkit.WebViewClient {
|
||||
public void *(android.webkit.WebView, java.lang.String, android.graphics.Bitmap);
|
||||
public boolean *(android.webkit.WebView, java.lang.String);
|
||||
}
|
||||
-keepclassmembers class * extends android.webkit.WebViewClient {
|
||||
public void *(android.webkit.WebView, java.lang.String);
|
||||
}
|
||||
|
||||
### easypermission
|
||||
-keepclassmembers class * {
|
||||
@pub.devrel.easypermissions.AfterPermissionGranted <methods>;
|
||||
}
|
||||
|
||||
# TODO What's this ?
|
||||
-ignorewarnings
|
||||
|
||||
### Keep Annotation
|
||||
-keep @androidx.annotation.Keep class *
|
||||
-keepclassmembers class * {
|
||||
@androidx.annotation.Keep *;
|
||||
}
|
||||
|
||||
### 阿里云上传
|
||||
-keep class com.alibaba.sdk.android.oss.* { *; }
|
||||
-dontwarn okio.**
|
||||
-dontwarn org.apache.commons.codec.binary.**
|
||||
|
||||
### 视频相关
|
||||
-keep class com.shuyu.gsyvideoplayer.video.* { *; }
|
||||
-dontwarn com.shuyu.gsyvideoplayer.video.**
|
||||
@ -124,32 +47,12 @@
|
||||
public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||
}
|
||||
|
||||
-keep class com.alibaba.sdk.android.*{*;}
|
||||
-keep class com.ut.*{*;}
|
||||
-keep class com.ta.*{*;}
|
||||
|
||||
### TEA
|
||||
-keep class com.gh.gamecenter.TeaHelper { *; }
|
||||
|
||||
### 阿里云日志
|
||||
-keep class com.aliyun.sls.android.producer.* { *; }
|
||||
-keep interface com.aliyun.sls.android.producer.* { *; }
|
||||
|
||||
### 中国移动一键登录
|
||||
-dontwarn com.cmic.sso.sdk.**
|
||||
-keep class com.cmic.sso.sdk.* { *; }
|
||||
|
||||
### EasyFloat
|
||||
-keep class com.lzf.easyfloat.* {*;}
|
||||
|
||||
### 避免 WebChromeClient 被混淆
|
||||
-keepclassmembers class * extends android.webkit.WebChromeClient{
|
||||
public void openFileChooser(...);
|
||||
}
|
||||
|
||||
### emoji4j
|
||||
-keep class emoji4j.* {*;}
|
||||
|
||||
### dokit
|
||||
-keep class com.didichuxing.** {*;}
|
||||
|
||||
@ -163,12 +66,3 @@
|
||||
public static void directToSuggestion(...);
|
||||
}
|
||||
|
||||
# ARouter
|
||||
-keep public class com.alibaba.android.arouter.routes.**{*;}
|
||||
-keep public class com.alibaba.android.arouter.facade.**{*;}
|
||||
-keep class * implements com.alibaba.android.arouter.facade.template.ISyringe{*;}
|
||||
# 如果使用了 byType 的方式获取 Service,需添加下面规则,保护接口
|
||||
-keep interface * implements com.alibaba.android.arouter.facade.template.IProvider
|
||||
# 如果使用了 单类注入,即不定义接口实现 IProvider,需添加下面规则,保护实现
|
||||
-keep class * implements com.alibaba.android.arouter.facade.template.IProvider
|
||||
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
<uses-permission android:name="com.android.permission.GET_INSTALLED_APPS" />
|
||||
|
||||
<!-- 前台服务权限-->
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
|
||||
<uses-permission
|
||||
android:name="android.permission.PACKAGE_USAGE_STATS"
|
||||
@ -51,7 +51,27 @@
|
||||
com.google.android.exoplayer2,
|
||||
tv.danmaku.ijk.media.exo2,
|
||||
pl.droidsonroids.gif,
|
||||
com.lzf.easyfloat" />
|
||||
com.lzf.easyfloat,
|
||||
com.airbnb.lottie.compose,
|
||||
androidx.compose.ui.platform,
|
||||
androidx.compose.material.icons,
|
||||
androidx.activity.compose,
|
||||
androidx.compose.ui.tooling,
|
||||
androidx.compose.ui.tooling.data,
|
||||
androidx.compose.material.ripple,
|
||||
androidx.compose.foundation,
|
||||
androidx.compose.animation,
|
||||
androidx.compose.foundation.layout,
|
||||
androidx.compose.ui.text,
|
||||
androidx.compose.ui.graphics,
|
||||
androidx.compose.ui.unit,
|
||||
androidx.compose.ui.util,
|
||||
androidx.compose.ui.geometry,
|
||||
androidx.compose.runtime.saveable,
|
||||
androidx.compose.animation.core,
|
||||
androidx.constraintlayout.compose,
|
||||
androidx.compose.ui.test.manifest,
|
||||
androidx.compose.ui.tooling.preview"/>
|
||||
|
||||
<!-- 去掉 SDK 一些流氓权限 -->
|
||||
<uses-permission
|
||||
@ -148,10 +168,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" />
|
||||
@ -175,7 +191,7 @@
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.WebActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.SingletonWebActivity"
|
||||
@ -219,18 +235,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"
|
||||
@ -291,10 +295,6 @@
|
||||
android:name="com.gh.gamecenter.qa.answer.detail.AnswerDetailActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".qa.answer.fold.AnswerFoldActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.qa.answer.edit.AnswerEditActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
@ -348,10 +348,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" />
|
||||
@ -380,10 +376,6 @@
|
||||
android:name="com.gh.gamecenter.qa.article.detail.ArticleDetailActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.qa.article.detail.comment.ArticleDetailCommentActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.qa.draft.CommunityDraftWrapperActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
@ -517,10 +509,6 @@
|
||||
android:name=".video.poster.PosterClipActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".forum.select.ForumSelectActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".forum.detail.ForumDetailActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
@ -574,10 +562,6 @@
|
||||
android:name=".forum.search.ForumOrUserSearchActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".personal.NewPersonalActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".qa.questions.draft.QuestionDraftActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
@ -602,14 +586,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" />
|
||||
@ -719,11 +695,13 @@
|
||||
android:name="com.gh.gamecenter.toolbox.ToolBoxBlockActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity android:name="com.gh.vspace.VDownloadManagerActivity"
|
||||
<activity
|
||||
android:name="com.gh.vspace.VDownloadManagerActivity"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity android:name="com.gh.vspace.VSpaceLoadingActivity"
|
||||
<activity
|
||||
android:name="com.gh.vspace.VSpaceLoadingActivity"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
@ -735,6 +713,22 @@
|
||||
android:name=".qa.comment.NewCommentDetailActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.mypost.MyPostActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".VerifyPhoneActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".BbsCertificationActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".discovery.DiscoveryActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<!-- <activity-->
|
||||
<!-- android:name="${applicationId}.douyinapi.DouYinEntryActivity"-->
|
||||
<!-- android:launchMode="singleTask"-->
|
||||
@ -755,19 +749,19 @@
|
||||
android:name="com.gh.gamecenter.provider.GhContentProvider"
|
||||
android:authorities="${applicationId}.provider"
|
||||
android:enabled="true"
|
||||
android:exported="true"/>
|
||||
android:exported="true" />
|
||||
|
||||
<provider
|
||||
android:name="androidx.startup.InitializationProvider"
|
||||
android:authorities="${applicationId}.androidx-startup"
|
||||
android:exported="false"
|
||||
tools:node="merge">
|
||||
<!-- If you are using androidx.startup to initialize other components -->
|
||||
<meta-data
|
||||
android:name="androidx.work.WorkManagerInitializer"
|
||||
android:value="androidx.startup"
|
||||
tools:node="remove" />
|
||||
</provider>
|
||||
<!-- <provider-->
|
||||
<!-- android:name="androidx.startup.InitializationProvider"-->
|
||||
<!-- android:authorities="${applicationId}.androidx-startup"-->
|
||||
<!-- android:exported="false"-->
|
||||
<!-- tools:node="merge">-->
|
||||
<!-- <!– If you are using androidx.startup to initialize other components –>-->
|
||||
<!-- <meta-data-->
|
||||
<!-- android:name="androidx.work.WorkManagerInitializer"-->
|
||||
<!-- android:value="androidx.startup"-->
|
||||
<!-- tools:node="remove" />-->
|
||||
<!-- </provider>-->
|
||||
|
||||
<receiver
|
||||
android:name="com.gh.gamecenter.receiver.DownloadReceiver"
|
||||
|
||||
BIN
app/src/main/assets/fonts/d_din_bold.ttf
Normal file
BIN
app/src/main/assets/fonts/d_din_bold.ttf
Normal file
Binary file not shown.
@ -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":[]}
|
||||
@ -113,7 +113,8 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
}
|
||||
}
|
||||
INSERT_GAME_COLLECTION_CODE -> {
|
||||
val gameCollectionEntity = data?.getParcelableExtra<GamesCollectionEntity>(GamesCollectionEntity::class.java.simpleName)
|
||||
val gameCollectionEntity =
|
||||
data?.getParcelableExtra<GamesCollectionEntity>(GamesCollectionEntity::class.java.simpleName)
|
||||
if (gameCollectionEntity != null) {
|
||||
mRichEditor.focusEditor()
|
||||
insertData = EditorInsertEntity.transform(gameCollectionEntity)
|
||||
@ -124,7 +125,9 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
if (data != null) mViewModel.uploadPic(data)
|
||||
}
|
||||
INSERT_MEDIA_VIDEO_CODE -> {
|
||||
val localVideoList = data?.getParcelableArrayListExtra<LocalVideoEntity>(LocalVideoEntity::class.java.name) ?: arrayListOf()
|
||||
val localVideoList =
|
||||
data?.getParcelableArrayListExtra<LocalVideoEntity>(LocalVideoEntity::class.java.name)
|
||||
?: arrayListOf()
|
||||
if (localVideoList.isNotEmpty()) {
|
||||
mRichEditor.focusEditor()
|
||||
uploadVideo(localVideoList)
|
||||
@ -210,7 +213,7 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
mViewModel.setUploadVideoListener(this)
|
||||
mKeyboardHeightProvider = KeyboardHeightProvider(this)
|
||||
mRichEditor.post { mKeyboardHeightProvider?.start() }
|
||||
mRichEditor.enableForceDark(NightModeUtils.isNightMode(this))
|
||||
mRichEditor.enableForceDark(DarkModeUtils.isDarkModeOn(this))
|
||||
// 防止个别手机在Js里无法获取粘贴内容
|
||||
mRichEditor.addJavascriptInterface(OnPasteListener(), "onPasteListener")
|
||||
mRichEditor.addJavascriptInterface(OnCursorChangeListener(), "OnCursorChangeListener")
|
||||
@ -741,12 +744,12 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
abstract fun provideViewModel(): VM
|
||||
abstract fun getVideoGuideKey(): String
|
||||
|
||||
override fun isAutoResetViewBackgroundEnabled(): Boolean =true
|
||||
override fun isAutoResetViewBackgroundEnabled(): Boolean = true
|
||||
|
||||
override fun onNightModeChange() {
|
||||
super.onNightModeChange()
|
||||
override fun onDarkModeChanged() {
|
||||
super.onDarkModeChanged()
|
||||
updateStatusBarColor(R.color.background_white, R.color.background_white)
|
||||
mRichEditor.enableForceDark(NightModeUtils.isNightMode(this))
|
||||
mRichEditor.enableForceDark(DarkModeUtils.isDarkModeOn(this))
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
86
app/src/main/java/com/gh/base/DarkModeSwitchHelper.kt
Normal file
86
app/src/main/java/com/gh/base/DarkModeSwitchHelper.kt
Normal file
@ -0,0 +1,86 @@
|
||||
package com.gh.base
|
||||
|
||||
import android.view.Gravity
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.utils.DarkModeUtils
|
||||
import com.gh.gamecenter.common.utils.DialogHelper
|
||||
import com.gh.gamecenter.common.utils.PackageFlavorHelper
|
||||
import com.gh.gamecenter.common.utils.dip2px
|
||||
import com.lzf.easyfloat.EasyFloat
|
||||
import com.lzf.easyfloat.enums.ShowPattern
|
||||
import com.lzf.easyfloat.enums.SidePattern
|
||||
|
||||
object DarkModeSwitchHelper {
|
||||
|
||||
fun showDarkModeSwitchFloatingView(activity: AppCompatActivity) {
|
||||
if (PackageFlavorHelper.IS_TEST_FLAVOR) {
|
||||
EasyFloat.with(activity)
|
||||
.setLayout(R.layout.layout_day_mode_night_mode_switch)
|
||||
.setTag("night_mode_switch_floating_view")
|
||||
.setAnimator(null)
|
||||
.setGravity(Gravity.TOP.xor(Gravity.END), 0, 114F.dip2px())
|
||||
.setSidePattern(SidePattern.RESULT_SIDE)
|
||||
.setDragEnable(true)
|
||||
.setShowPattern(ShowPattern.CURRENT_ACTIVITY)
|
||||
.registerCallback {
|
||||
createResult { _, _, view ->
|
||||
view?.setOnClickListener {
|
||||
showDarkModeSwitchDialog(activity)
|
||||
}
|
||||
}
|
||||
}
|
||||
.show()
|
||||
}
|
||||
}
|
||||
|
||||
fun dismissDarkModeSwitchFloatingView() {
|
||||
if (PackageFlavorHelper.IS_TEST_FLAVOR) {
|
||||
EasyFloat.dismiss("night_mode_switch_floating_view")
|
||||
}
|
||||
}
|
||||
|
||||
private fun showDarkModeSwitchDialog(activity: AppCompatActivity) {
|
||||
if (PackageFlavorHelper.IS_TEST_FLAVOR) {
|
||||
//切换深色模式
|
||||
var mode = "普通模式"
|
||||
var positive = "跟随系统模式"
|
||||
var negative = "深色模式"
|
||||
if (DarkModeUtils.isFollowSystemDarkModeFromSp()) {
|
||||
mode = "跟随系统模式"
|
||||
positive = "普通模式"
|
||||
negative = "深色模式"
|
||||
} else if (DarkModeUtils.isAppDarkModeEnabledFromSp()) {
|
||||
mode = "深色模式"
|
||||
positive = "跟随系统模式"
|
||||
negative = "普通模式"
|
||||
}
|
||||
DialogHelper.showDialog(
|
||||
context = activity,
|
||||
title = "选择模式",
|
||||
content = "当前为 $mode",
|
||||
confirmText = positive,
|
||||
cancelText = negative,
|
||||
confirmClickCallback = {
|
||||
if (DarkModeUtils.isFollowSystemDarkModeFromSp()) {
|
||||
DarkModeUtils.updateAppDarkModeStatusToSp(false)
|
||||
DarkModeUtils.updateFollowSystemDarkModeToSp(false)
|
||||
} else {
|
||||
DarkModeUtils.updateFollowSystemDarkModeToSp(true)
|
||||
}
|
||||
DarkModeUtils.initDarkMode()
|
||||
},
|
||||
cancelClickCallback = {
|
||||
if (DarkModeUtils.isFollowSystemDarkModeFromSp()) {
|
||||
DarkModeUtils.updateAppDarkModeStatusToSp(true)
|
||||
} else {
|
||||
DarkModeUtils.updateAppDarkModeStatusToSp(!DarkModeUtils.isAppDarkModeEnabledFromSp())
|
||||
}
|
||||
DarkModeUtils.updateFollowSystemDarkModeToSp(false)
|
||||
DarkModeUtils.initDarkMode()
|
||||
},
|
||||
extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6,7 +6,6 @@ import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.DownloadManagerActivity
|
||||
import com.gh.gamecenter.R
|
||||
@ -58,7 +57,7 @@ abstract class DownloadToolbarActivity : ToolBarActivity() {
|
||||
updateDownloadCountHint(mPackageViewModel?.filterSameUpdateLiveData?.value)
|
||||
}
|
||||
val downloadMenuView = mActionMenuView.menu.findItem(R.id.menu_download).actionView
|
||||
mDownloadCountHint = downloadMenuView.findViewById(R.id.menu_download_count_hint)
|
||||
mDownloadCountHint = downloadMenuView?.findViewById(R.id.menu_download_count_hint)
|
||||
}
|
||||
|
||||
override fun onMenuItemClick(item: MenuItem?): Boolean {
|
||||
@ -72,7 +71,7 @@ abstract class DownloadToolbarActivity : ToolBarActivity() {
|
||||
}
|
||||
|
||||
private fun updateDownloadCountHint(updateList: List<GameUpdateEntity>?) {
|
||||
if (mDownloadCountHint == null || updateList.isNullOrEmpty()) return
|
||||
if (mDownloadCountHint == null) return
|
||||
val count = DownloadManager.getInstance().getDownloadOrUpdateCount(updateList)
|
||||
if (count != null) {
|
||||
mDownloadCountHint!!.visibility = View.VISIBLE
|
||||
@ -102,10 +101,12 @@ abstract class DownloadToolbarActivity : ToolBarActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onNightModeChange() {
|
||||
super.onNightModeChange()
|
||||
override fun onDarkModeChanged() {
|
||||
super.onDarkModeChanged()
|
||||
if (showDownloadMenu() && getMenuItem(R.id.menu_download) != null) {
|
||||
(getMenuItem(R.id.menu_download).actionView.findViewById(R.id.menu_download_iv) as ImageView).setImageResource(R.drawable.toolbar_download)
|
||||
(getMenuItem(R.id.menu_download).actionView?.findViewById(R.id.menu_download_iv) as ImageView).setImageResource(
|
||||
R.drawable.toolbar_download
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -9,7 +9,6 @@ import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.MainActivity
|
||||
import com.gh.gamecenter.SplashScreenActivity
|
||||
import com.gh.gamecenter.common.utils.PackageFlavorHelper
|
||||
import com.gh.gamecenter.energy.view.EnergyCenterActivity
|
||||
import com.gh.gamecenter.forum.detail.ForumDetailActivity
|
||||
import com.gh.gamecenter.forum.list.ForumListActivity
|
||||
import com.gh.gamecenter.qa.article.detail.ArticleDetailActivity
|
||||
@ -32,7 +31,7 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
||||
override fun onActivityResumed(activity: Activity) {
|
||||
// 判断是否需要显示或隐藏返回小浮窗
|
||||
if (FloatingBackViewManager.getType().isNotEmpty()) {
|
||||
if (activity is EnergyCenterActivity
|
||||
if ((activity::class.java.name == "EnergyCenterActivity")
|
||||
&& FloatingBackViewManager.getType() == FloatingBackViewManager.TYPE_TASK
|
||||
) {
|
||||
FloatingBackViewManager.disableBackView()
|
||||
@ -58,7 +57,7 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
||||
}
|
||||
|
||||
if (PackageFlavorHelper.IS_TEST_FLAVOR && activity is AppCompatActivity) {
|
||||
NightModeSwitchHelper.showNightModeSwitchFloatingView(activity)
|
||||
DarkModeSwitchHelper.showDarkModeSwitchFloatingView(activity)
|
||||
}
|
||||
|
||||
if (activity is AppCompatActivity && activity !is SplashScreenActivity) {
|
||||
@ -78,7 +77,7 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
||||
override fun onActivityPaused(activity: Activity) {
|
||||
FloatingBackViewManager.dismissBackView()
|
||||
if (PackageFlavorHelper.IS_TEST_FLAVOR && activity is AppCompatActivity) {
|
||||
NightModeSwitchHelper.dismissNightModeSwitchFloatingView()
|
||||
DarkModeSwitchHelper.dismissDarkModeSwitchFloatingView()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,107 +0,0 @@
|
||||
package com.gh.base
|
||||
|
||||
import android.os.Build
|
||||
import android.view.Gravity
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.utils.DialogHelper
|
||||
import com.gh.gamecenter.common.utils.NightModeUtils
|
||||
import com.gh.gamecenter.common.utils.PackageFlavorHelper
|
||||
import com.gh.gamecenter.common.utils.dip2px
|
||||
import com.lzf.easyfloat.EasyFloat
|
||||
import com.lzf.easyfloat.enums.ShowPattern
|
||||
import com.lzf.easyfloat.enums.SidePattern
|
||||
|
||||
object NightModeSwitchHelper {
|
||||
|
||||
fun showNightModeSwitchFloatingView(activity: AppCompatActivity) {
|
||||
if (PackageFlavorHelper.IS_TEST_FLAVOR) {
|
||||
EasyFloat.with(activity)
|
||||
.setLayout(R.layout.layout_day_mode_night_mode_switch)
|
||||
.setTag("night_mode_switch_floating_view")
|
||||
.setAnimator(null)
|
||||
.setGravity(Gravity.TOP.xor(Gravity.END), 0, 114F.dip2px())
|
||||
.setSidePattern(SidePattern.RESULT_SIDE)
|
||||
.setDragEnable(true)
|
||||
.setShowPattern(ShowPattern.CURRENT_ACTIVITY)
|
||||
.registerCallback {
|
||||
createResult { _, _, view ->
|
||||
// val url = "https://ps.w.org/dark-mode-for-wp-dashboard/assets/icon-128x128.png"
|
||||
// view?.findViewById<ImageView>(R.id.iconIv)?.let {
|
||||
// Picasso.with(activity).load(url).into(it)
|
||||
// }
|
||||
view?.setOnClickListener {
|
||||
showNightModeSwitchDialog(activity)
|
||||
}
|
||||
}
|
||||
}
|
||||
.show()
|
||||
}
|
||||
}
|
||||
|
||||
fun dismissNightModeSwitchFloatingView() {
|
||||
if (PackageFlavorHelper.IS_TEST_FLAVOR) {
|
||||
EasyFloat.dismiss("night_mode_switch_floating_view")
|
||||
}
|
||||
}
|
||||
|
||||
private fun showNightModeSwitchDialog(activity: AppCompatActivity) {
|
||||
if (PackageFlavorHelper.IS_TEST_FLAVOR) {
|
||||
//切换深色模式
|
||||
var mode = "普通模式"
|
||||
var positive = "跟随系统模式"
|
||||
var negative ="深色模式"
|
||||
if (NightModeUtils.getSystemMode()) {
|
||||
mode = "跟随系统模式"
|
||||
positive = "普通模式"
|
||||
negative = "深色模式"
|
||||
} else if (NightModeUtils.getNightMode()) {
|
||||
mode = "深色模式"
|
||||
positive = "跟随系统模式"
|
||||
negative = "普通模式"
|
||||
}
|
||||
DialogHelper.showDialog(
|
||||
context = activity,
|
||||
title = "选择模式",
|
||||
content = "当前为 $mode",
|
||||
confirmText = positive,
|
||||
cancelText = negative,
|
||||
confirmClickCallback = {
|
||||
if (NightModeUtils.getSystemMode()) {
|
||||
NightModeUtils.setNightMode(false)
|
||||
NightModeUtils.setSystemMode(false)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
activity.delegate.localNightMode = AppCompatDelegate.MODE_NIGHT_NO
|
||||
}
|
||||
} else {
|
||||
NightModeUtils.setSystemMode(true)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
activity.delegate.localNightMode =
|
||||
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
||||
}
|
||||
}
|
||||
NightModeUtils.initNightMode()
|
||||
},
|
||||
cancelClickCallback = {
|
||||
if (NightModeUtils.getSystemMode()) {
|
||||
NightModeUtils.setNightMode(true)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
activity.delegate.localNightMode = AppCompatDelegate.MODE_NIGHT_YES
|
||||
}
|
||||
} else {
|
||||
val nightMode = NightModeUtils.getNightMode()
|
||||
NightModeUtils.setNightMode(!NightModeUtils.getNightMode())
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
activity.delegate.localNightMode =
|
||||
if (nightMode) AppCompatDelegate.MODE_NIGHT_NO else AppCompatDelegate.MODE_NIGHT_YES
|
||||
}
|
||||
}
|
||||
NightModeUtils.setSystemMode(false)
|
||||
NightModeUtils.initNightMode()
|
||||
},
|
||||
extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -10,7 +10,9 @@ import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import com.gh.common.util.*
|
||||
import com.gh.common.util.LogUtils
|
||||
import com.gh.gamecenter.*
|
||||
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
|
||||
@ -25,20 +27,19 @@ import com.gh.gamecenter.core.utils.CurrentActivityHolder
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.core.utils.MtaHelper
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.energy.utils.EnergyTaskHelper
|
||||
import com.gh.gamecenter.energy.view.EnergyCenterActivity
|
||||
import com.gh.gamecenter.energy.view.EnergyHouseActivity
|
||||
import com.gh.gamecenter.energy.EnergyBridge
|
||||
import com.gh.gamecenter.entity.MtaEvent
|
||||
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.compose.activity.ComposeAboutActivity
|
||||
import com.gh.gamecenter.setting.compose.activity.ComposeBindPhoneActivity
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Utils
|
||||
import org.json.JSONObject
|
||||
@ -130,7 +131,7 @@ class DefaultJsApi(var context: Context, val entrance: String = "") {
|
||||
|
||||
WechatBindHelper.bindWechat(wechatLoginInfoMap, object : BiCallback<Boolean, Boolean> {
|
||||
override fun onFirst(first: Boolean) {
|
||||
EnergyTaskHelper.postEnergyTask("bind_wechat")
|
||||
EnergyBridge.postEnergyTask("bind_wechat")
|
||||
handler.complete(true)
|
||||
}
|
||||
|
||||
@ -222,7 +223,7 @@ class DefaultJsApi(var context: Context, val entrance: String = "") {
|
||||
@JavascriptInterface
|
||||
fun updateRegulationTestStatus(msg: Any) {
|
||||
if (msg.toString().toLowerCase(Locale.getDefault()) == "pass") {
|
||||
EnergyTaskHelper.postEnergyTask("finish_etiquette_exam")
|
||||
EnergyBridge.postEnergyTask("finish_etiquette_exam")
|
||||
SPUtils.setString(Constants.SP_REGULATION_TEST_PASS_STATUS, "pass")
|
||||
}
|
||||
}
|
||||
@ -269,7 +270,7 @@ class DefaultJsApi(var context: Context, val entrance: String = "") {
|
||||
|
||||
@JavascriptInterface
|
||||
fun bindPhone(msg: Any) {
|
||||
val intent = BindPhoneActivity.getNormalIntent(context, false)
|
||||
val intent = ComposeBindPhoneActivity.getNormalIntent(context, false)
|
||||
context.startActivity(intent)
|
||||
}
|
||||
|
||||
@ -293,22 +294,22 @@ class DefaultJsApi(var context: Context, val entrance: String = "") {
|
||||
|
||||
@JavascriptInterface
|
||||
fun openInNewWebview(url: Any) {
|
||||
runOnUiThread { DirectUtils.directToWebView(context, url.toString(), "内部网页") }
|
||||
runOnUiThread { DirectUtils.directToWebView(context, url.toString(), entrance.ifBlank { "内部网页" }) }
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun postWearBadgeTask(msg: Any) {
|
||||
EnergyTaskHelper.postEnergyTask("wear_badge")
|
||||
EnergyBridge.postEnergyTask("wear_badge")
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun startEnergyCenter(msg: Any) {
|
||||
context.startActivity(EnergyCenterActivity.getIntent(context))
|
||||
context.startActivity(EnergyBridge.getEnergyCenterIntent(context))
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun startEnergyHouse(msg: Any) {
|
||||
context.startActivity(EnergyHouseActivity.getIntent(context))
|
||||
context.startActivity(EnergyBridge.getEnergyHouseIntent(context, null))
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
@ -373,7 +374,8 @@ class DefaultJsApi(var context: Context, val entrance: String = "") {
|
||||
runOnIoThread {
|
||||
val base64String = base64StringData.replace("data:image/png;base64", "")
|
||||
tryWithDefaultCatch {
|
||||
val imageFile = File(HaloApp.getInstance().cacheDir.absolutePath + File.separator + System.currentTimeMillis() + ".png")
|
||||
val imageFile =
|
||||
File(HaloApp.getInstance().cacheDir.absolutePath + File.separator + System.currentTimeMillis() + ".png")
|
||||
val decodedString = Base64.decode(base64String, Base64.DEFAULT)
|
||||
val bos = BufferedOutputStream(FileOutputStream(imageFile))
|
||||
bos.write(decodedString)
|
||||
@ -400,7 +402,7 @@ class DefaultJsApi(var context: Context, val entrance: String = "") {
|
||||
|
||||
@JavascriptInterface
|
||||
fun openInNewFullWebview(url: Any) {
|
||||
runOnUiThread { DirectUtils.directToFullScreenWebPage(context, url.toString(), true) }
|
||||
runOnUiThread { DirectUtils.directToFullScreenWebPage(context, url.toString(), true, entrance) }
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
@ -414,7 +416,7 @@ class DefaultJsApi(var context: Context, val entrance: String = "") {
|
||||
|
||||
@JavascriptInterface
|
||||
fun checkUpdateGhzs(msg: Any) {
|
||||
context.startActivity(AboutActivity.getIntent(context, true))
|
||||
context.startActivity(ComposeAboutActivity.getIntent(context, true))
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
|
||||
@ -74,7 +74,13 @@ object DefaultUrlHandler {
|
||||
entrance = entrance
|
||||
)
|
||||
|
||||
"column" -> SubjectActivity.startSubjectActivity(context, id, uri.getQueryParameter("name"), false, entrance)
|
||||
"column" -> SubjectActivity.startSubjectActivity(
|
||||
context,
|
||||
id,
|
||||
uri.getQueryParameter("name"),
|
||||
false,
|
||||
entrance
|
||||
)
|
||||
|
||||
"libao" -> context.startActivity(LibaoDetailActivity.getIntentById(context, id, entrance))
|
||||
|
||||
@ -93,7 +99,7 @@ object DefaultUrlHandler {
|
||||
}
|
||||
|
||||
"inurl" -> {
|
||||
DirectUtils.directToWebView(context, uri.getQueryParameter("url") ?: "")
|
||||
DirectUtils.directToWebView(context, uri.getQueryParameter("url") ?: "", entrance)
|
||||
}
|
||||
|
||||
"outurl" -> {
|
||||
@ -167,13 +173,26 @@ object DefaultUrlHandler {
|
||||
val linkEntity = VideoLinkEntity(title, categoryId, link, tagActivityId, tagActivityName)
|
||||
val simpleGameEntity = SimpleGameEntity(gameId, gameName)
|
||||
CheckLoginUtils.checkLogin(context, null, true, EntranceConsts.ENTRANCE_BROWSER) {
|
||||
DirectUtils.directToVideoManager(context, linkEntity, simpleGameEntity, EntranceConsts.ENTRANCE_BROWSER, "")
|
||||
DirectUtils.directToVideoManager(
|
||||
context,
|
||||
linkEntity,
|
||||
simpleGameEntity,
|
||||
EntranceConsts.ENTRANCE_BROWSER,
|
||||
""
|
||||
)
|
||||
}
|
||||
}
|
||||
EntranceConsts.HOST_USERHOME -> {
|
||||
val position = uri.getQueryParameter("position")
|
||||
val subtype = uri.getQueryParameter("sub_type") ?: ""
|
||||
DirectUtils.directToHomeActivity(context, id, subtype, if (position.isNullOrEmpty()) -1 else position.toInt(), entrance, "")
|
||||
DirectUtils.directToHomeActivity(
|
||||
context,
|
||||
id,
|
||||
subtype,
|
||||
if (position.isNullOrEmpty()) -1 else position.toInt(),
|
||||
entrance,
|
||||
""
|
||||
)
|
||||
}
|
||||
EntranceConsts.HOST_VIDEO_MORE -> {
|
||||
val referer = uri.getQueryParameter("referer") ?: ""
|
||||
@ -358,11 +377,16 @@ object DefaultUrlHandler {
|
||||
GameEntity(id = gameId, mName = gameName, mIcon = icon, mIconSubscript = iconSubscript)
|
||||
} else null
|
||||
val activityLabelEntity = if (activityId.isNotEmpty() && activityName.isNotEmpty()) {
|
||||
ActivityLabelEntity(id = activityId, name = activityName, original = original.ifEmpty { "false" }.toBoolean())
|
||||
} else null
|
||||
val communityEntity = if (forumId.isNotEmpty() && forumName.isNotEmpty() && forumIcon.isNotEmpty()) {
|
||||
CommunityEntity(id = forumId, name = forumName, icon = forumIcon)
|
||||
ActivityLabelEntity(
|
||||
id = activityId,
|
||||
name = activityName,
|
||||
original = original.ifEmpty { "false" }.toBoolean()
|
||||
)
|
||||
} else null
|
||||
val communityEntity =
|
||||
if (forumId.isNotEmpty() && forumName.isNotEmpty() && forumIcon.isNotEmpty()) {
|
||||
CommunityEntity(id = forumId, name = forumName, icon = forumIcon)
|
||||
} else null
|
||||
|
||||
context.startActivity(
|
||||
VideoPublishActivity.getIntent(
|
||||
@ -402,7 +426,14 @@ object DefaultUrlHandler {
|
||||
if (!TextUtils.isEmpty(qaId)) {
|
||||
directToQa(context, qaTitle, qaId)
|
||||
} else {
|
||||
directToFeedback(context, content, null, isQaFeedback, qaContentId, EntranceConsts.ENTRANCE_BROWSER)
|
||||
directToFeedback(
|
||||
context,
|
||||
content,
|
||||
null,
|
||||
isQaFeedback,
|
||||
qaContentId,
|
||||
EntranceConsts.ENTRANCE_BROWSER
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -424,7 +455,15 @@ object DefaultUrlHandler {
|
||||
val id = uri.getQueryParameter("id")
|
||||
val name = uri.getQueryParameter("name")
|
||||
val qaCollectionId = uri.getQueryParameter("collection_id")
|
||||
context.startActivity(WebActivity.getIntent(context, "$url$id", name, true, !qaCollectionId.isNullOrEmpty()))
|
||||
context.startActivity(
|
||||
WebActivity.getIntent(
|
||||
context,
|
||||
"$url$id",
|
||||
name,
|
||||
true,
|
||||
!qaCollectionId.isNullOrEmpty()
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -440,7 +479,15 @@ object DefaultUrlHandler {
|
||||
val activityId = uri.getQueryParameter("activity_id") ?: ""
|
||||
val activityName = uri.getQueryParameter("activity_name") ?: ""
|
||||
val gameId = uri.getQueryParameter("game_id") ?: ""
|
||||
context.startActivity(GameCollectionEditActivity.getIntent(context, activityId, activityName, gameId, entrance))
|
||||
context.startActivity(
|
||||
GameCollectionEditActivity.getIntent(
|
||||
context,
|
||||
activityId,
|
||||
activityName,
|
||||
gameId,
|
||||
entrance
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
else -> {
|
||||
@ -523,7 +570,13 @@ object DefaultUrlHandler {
|
||||
when {
|
||||
contains("game") -> {
|
||||
val gameId = uri.getQueryParameter("gameId") ?: uri.pathSegments.last() ?: ""
|
||||
DirectUtils.directToGameDetail(context, gameId, entrance, autoDownload = false, traceEvent = null)
|
||||
DirectUtils.directToGameDetail(
|
||||
context,
|
||||
gameId,
|
||||
entrance,
|
||||
autoDownload = false,
|
||||
traceEvent = null
|
||||
)
|
||||
}
|
||||
contains("question") -> {
|
||||
val questionId = split("/")[2]
|
||||
@ -540,7 +593,8 @@ object DefaultUrlHandler {
|
||||
var type = ""
|
||||
var typeId = ""
|
||||
val split =
|
||||
replace("/communities", "").replace("/bbs", "").replace(".html", "").split("/".toRegex()).dropLastWhile { it.isEmpty() }
|
||||
replace("/communities", "").replace("/bbs", "").replace(".html", "").split("/".toRegex())
|
||||
.dropLastWhile { it.isEmpty() }
|
||||
.toTypedArray()
|
||||
for (text in split) {
|
||||
if (TextUtils.isEmpty(communityId)) {
|
||||
|
||||
@ -37,13 +37,15 @@ object FixedRateJobHelper {
|
||||
// 时间校对,10分钟一次
|
||||
if ((mExecuteCount * CHECKER_PERIOD) % TIME_PERIOD == 0L) {
|
||||
RetrofitManager.getInstance().api.time
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : Response<TimeEntity>() {
|
||||
override fun onResponse(response: TimeEntity?) {
|
||||
val serverTime = response?.time
|
||||
serverTime?.let { timeDeltaBetweenServerAndClient = it * 1000 - System.currentTimeMillis() }
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : Response<TimeEntity>() {
|
||||
override fun onResponse(response: TimeEntity?) {
|
||||
val serverTime = response?.time
|
||||
serverTime?.let {
|
||||
timeDeltaBetweenServerAndClient = it * 1000 - System.currentTimeMillis()
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 提交曝光数据
|
||||
|
||||
@ -5,7 +5,7 @@ import com.gh.download.server.BrowserInstallHelper
|
||||
import com.gh.gamecenter.core.utils.EmptyCallback
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
|
||||
class BrowserInstallHandler:ChainHandler() {
|
||||
class BrowserInstallHandler : ChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity) {
|
||||
BrowserInstallHelper.showBrowserInstallHintDialog(context, gameEntity.isVGame(), object : EmptyCallback {
|
||||
|
||||
@ -4,7 +4,7 @@ import android.content.Context
|
||||
import com.gh.common.util.DialogUtils
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
|
||||
class OverseaDownloadHandler:ChainHandler() {
|
||||
class OverseaDownloadHandler : ChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity) {
|
||||
DialogUtils.showOverseaDownloadDialog(context, gameEntity) {
|
||||
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -8,6 +8,7 @@ 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;
|
||||
@ -21,6 +22,7 @@ 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;
|
||||
@ -62,6 +64,9 @@ public class Config {
|
||||
|
||||
private static SettingsEntity mSettingsEntity;
|
||||
private static NewSettingsEntity mNewSettingsEntity;
|
||||
|
||||
private static NewSettingsEntity.NightMode mNightModeSetting;
|
||||
private static SimulatorEntity mNewSimulatorEntity;
|
||||
private static VSetting mVSetting;
|
||||
private static GameGuidePopupEntity mGameGuidePopupEntity;
|
||||
private static SharedPreferences mDefaultSharedPreferences;
|
||||
@ -91,7 +96,6 @@ public class Config {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static boolean isShowDownload(String gameId) {
|
||||
|
||||
if (getPreferences().getBoolean(FIX_DOWNLOAD_KEY, false)) return true;
|
||||
@ -192,8 +196,9 @@ public class Config {
|
||||
getPreferences().edit().putString(SETTINGS_KEY, GsonUtils.toJson(settingsEntity)).apply();
|
||||
mSettingsEntity = settingsEntity;
|
||||
|
||||
// 更新 FIX_ARTICLE_KEY 状态
|
||||
// 更新设置状态
|
||||
mSettingsEntity.showArticleEntrance();
|
||||
mSettingsEntity.showCommunityEntrance();
|
||||
|
||||
// 加载完设置后刷新下
|
||||
PackageHelper.initList();
|
||||
@ -217,6 +222,29 @@ public class Config {
|
||||
return mSettingsEntity;
|
||||
}
|
||||
|
||||
//新模拟器
|
||||
@Nullable
|
||||
public static SimulatorEntity getNewSimulatorEntitySetting() {
|
||||
if (mNewSimulatorEntity != null) {
|
||||
return mNewSimulatorEntity;
|
||||
} else if (mNewSettingsEntity != null && mNewSettingsEntity.getSimulator() != null) {
|
||||
return mNewSettingsEntity.getSimulator();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static NewSettingsEntity.NightMode getNightModeSetting() {
|
||||
if (mNightModeSetting != null) {
|
||||
return mNightModeSetting;
|
||||
} else if (mNewSettingsEntity != null && mNewSettingsEntity.getNightMode() != null) {
|
||||
return mNewSettingsEntity.getNightMode();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static NewSettingsEntity getNewSettingsEntity() {
|
||||
if (mNewSettingsEntity == null) {
|
||||
@ -275,32 +303,12 @@ public class Config {
|
||||
|
||||
public static SharedPreferences getPreferences() {
|
||||
if (mDefaultSharedPreferences == null) {
|
||||
mDefaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(HaloApp.getInstance().getApplication());
|
||||
mDefaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(HaloApp.getInstance().getApplication());
|
||||
}
|
||||
|
||||
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();
|
||||
@ -336,20 +344,50 @@ 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));
|
||||
}
|
||||
});
|
||||
|
||||
RetrofitManager.getInstance()
|
||||
.getVApi().getSettings(BuildConfig.VERSION_NAME)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(new BiResponse<VSetting>() {
|
||||
@Override
|
||||
public void onSuccess(VSetting data) {
|
||||
mVSetting = data;
|
||||
SPUtils.setString(Constants.SP_V_SETTINGS, GsonUtils.toJson(data));
|
||||
}
|
||||
});
|
||||
if (mVSetting == null) {
|
||||
RetrofitManager.getInstance()
|
||||
.getVApi().getSettings(BuildConfig.VERSION_NAME)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(new BiResponse<VSetting>() {
|
||||
@Override
|
||||
public void onSuccess(VSetting data) {
|
||||
mVSetting = data;
|
||||
SPUtils.setString(Constants.SP_V_SETTINGS, GsonUtils.toJson(data));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (mNightModeSetting == null && mNewSimulatorEntity == null) {
|
||||
RetrofitManager.getInstance()
|
||||
.getNewApi().getNewSettings(PackageUtils.getGhVersionName(), channel)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BiResponse<NewSettingsEntity>() {
|
||||
@Override
|
||||
public void onSuccess(NewSettingsEntity data) {
|
||||
mNightModeSetting = data.getNightMode();
|
||||
mNewSimulatorEntity = data.getSimulator();
|
||||
if (HaloApp.getInstance().isNewForThisVersion && mNightModeSetting != null && mNightModeSetting.getInstall()) {
|
||||
DarkModeUtils.INSTANCE.updateFollowSystemDarkModeToSp(true);
|
||||
DarkModeUtils.INSTANCE.updateAppDarkModeStatusToSp(true);
|
||||
DarkModeUtils.INSTANCE.initDarkMode();
|
||||
}
|
||||
|
||||
if (mNewSettingsEntity != null) {
|
||||
mNewSettingsEntity.setSimulator(mNewSimulatorEntity);
|
||||
mNewSettingsEntity.setNightMode(mNightModeSetting);
|
||||
SPUtils.setString(Constants.SP_NEW_SETTINGS, GsonUtils.toJson(data));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
RetrofitManager.getInstance()
|
||||
.getApi().getGameGuidePopup(Build.MANUFACTURER, Build.VERSION.RELEASE, Build.MODEL, channel, BuildConfig.VERSION_NAME)
|
||||
|
||||
@ -67,7 +67,7 @@ object AddKaiFuBindingAdapter {
|
||||
binding.kaifuAddServerName.hint = "点击填写"
|
||||
}
|
||||
}
|
||||
binding.kaifuAddFirstName.addTextChangedListener(object :TextWatcher{
|
||||
binding.kaifuAddFirstName.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(
|
||||
s: CharSequence?,
|
||||
start: Int,
|
||||
@ -77,7 +77,7 @@ object AddKaiFuBindingAdapter {
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
if (!s.isNullOrEmpty()){
|
||||
if (!s.isNullOrEmpty()) {
|
||||
popupWindow?.dismiss()
|
||||
}
|
||||
}
|
||||
@ -104,12 +104,14 @@ object AddKaiFuBindingAdapter {
|
||||
val format = SimpleDateFormat(pattern, Locale.CHINA)
|
||||
view.setText(format.format(time * 1000))
|
||||
if (position == 0) {
|
||||
view.append(if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) Html.fromHtml(
|
||||
String.format(
|
||||
"<font color='#2496FF'>%1\$s</font>",
|
||||
" +"
|
||||
), Html.FROM_HTML_MODE_LEGACY
|
||||
) else Html.fromHtml(String.format("<font color='#2496FF'>%1\$s</font>", " +")))
|
||||
view.append(
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) Html.fromHtml(
|
||||
String.format(
|
||||
"<font color='#2496FF'>%1\$s</font>",
|
||||
" +"
|
||||
), Html.FROM_HTML_MODE_LEGACY
|
||||
) else Html.fromHtml(String.format("<font color='#2496FF'>%1\$s</font>", " +"))
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ import com.gh.gamecenter.common.baselist.LoadStatus;
|
||||
import com.gh.gamecenter.common.callback.OnViewClickListener;
|
||||
import com.gh.gamecenter.common.utils.ExtensionsKt;
|
||||
import com.gh.gamecenter.common.utils.ImageUtils;
|
||||
import com.gh.gamecenter.common.utils.NightModeUtils;
|
||||
import com.gh.gamecenter.common.utils.DarkModeUtils;
|
||||
import com.gh.gamecenter.common.view.DrawableView;
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils;
|
||||
import com.gh.gamecenter.core.utils.MtaHelper;
|
||||
@ -730,16 +730,16 @@ public class BindingAdapters {
|
||||
tagStyle.add(typeTag);
|
||||
} else {
|
||||
TagStyleEntity typeTag = new TagStyleEntity();
|
||||
boolean isNightMode = NightModeUtils.INSTANCE.isNightMode(layout.getContext());
|
||||
boolean isDarkModeOn = DarkModeUtils.INSTANCE.isDarkModeOn(layout.getContext());
|
||||
typeTag.setName(test.getType() != null ? test.getType() : "");
|
||||
typeTag.setBackground("1AFFA142");
|
||||
typeTag.setColor(isNightMode ? "EB9238" : "FFA142");
|
||||
typeTag.setColor(isDarkModeOn ? "EB9238" : "FFA142");
|
||||
tagStyle.add(typeTag);
|
||||
|
||||
TagStyleEntity timeTag = new TagStyleEntity();
|
||||
timeTag.setName(GameViewUtils.getGameTestDate(test.getStart()));
|
||||
timeTag.setBackground("1A06CEA8");
|
||||
timeTag.setColor(isNightMode ? "07A385" : "06CEA8");
|
||||
timeTag.setColor(isDarkModeOn ? "07A385" : "06CEA8");
|
||||
tagStyle.add(timeTag);
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -6,13 +6,13 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.gh.gamecenter.common.base.fragment.BaseDialogFragment
|
||||
import com.gh.common.util.DirectUtils
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.fragment.BaseDialogFragment
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.core.utils.SpanBuilder
|
||||
import com.gh.gamecenter.common.utils.dip2px
|
||||
import com.gh.gamecenter.common.view.CustomLinkMovementMethod
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.core.utils.SpanBuilder
|
||||
import com.gh.gamecenter.databinding.DialogApplyModeratorBinding
|
||||
|
||||
|
||||
@ -45,7 +45,13 @@ class ApplyModeratorDialogFragment : BaseDialogFragment() {
|
||||
val startText = "版主考核群:"
|
||||
val text = "$startText$mGroupNumber\n感谢你对论坛建设的支持\n请加入版主考核群并联系群主进行版主资格考核"
|
||||
binding.desTv.text = SpanBuilder(text)
|
||||
.click(startText.length, startText.length + mGroupNumber.length, R.color.theme_font,true) {
|
||||
.click(
|
||||
requireContext(),
|
||||
startText.length,
|
||||
startText.length + mGroupNumber.length,
|
||||
R.color.theme_font,
|
||||
true
|
||||
) {
|
||||
DirectUtils.directToQqGroup(
|
||||
requireContext(),
|
||||
mGroupKey
|
||||
|
||||
@ -32,8 +32,13 @@ import com.google.gson.reflect.TypeToken
|
||||
import com.halo.assistant.fragment.user.UserInfoEditFragment
|
||||
import com.lightgame.utils.AppManager
|
||||
|
||||
class CertificationDialog(context: Context, private val authDialogEntity: AuthDialogEntity, val gameId: String, val listener: ConfirmListener) :
|
||||
Dialog(context, R.style.GhAlertDialog) {
|
||||
class CertificationDialog(
|
||||
context: Context,
|
||||
private val authDialogEntity: AuthDialogEntity,
|
||||
val gameId: String,
|
||||
val listener: ConfirmListener
|
||||
) :
|
||||
Dialog(context, R.style.GhAlertDialog) {
|
||||
|
||||
private lateinit var view: View
|
||||
private lateinit var detailedDesTv: TextView
|
||||
@ -119,8 +124,10 @@ class CertificationDialog(context: Context, private val authDialogEntity: AuthDi
|
||||
private fun gotoLoginPage() {
|
||||
val currentActivity = AppManager.getInstance().currentActivity() ?: return
|
||||
|
||||
CheckLoginUtils.checkLogin(currentActivity as AppCompatActivity,
|
||||
null, true, "实名认证弹窗") {
|
||||
CheckLoginUtils.checkLogin(
|
||||
currentActivity as AppCompatActivity,
|
||||
null, true, "实名认证弹窗"
|
||||
) {
|
||||
if (UserManager.getInstance().isAuth) {
|
||||
listener.onConfirm()
|
||||
dismiss()
|
||||
|
||||
@ -18,19 +18,19 @@ import androidx.core.content.ContextCompat
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
import com.facebook.drawee.view.SimpleDraweeView
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.core.utils.GsonUtils
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.utils.ImageUtils
|
||||
import com.gh.gamecenter.common.utils.countDownTimer
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.common.utils.ImageUtils
|
||||
import com.gh.gamecenter.core.utils.GsonUtils
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.databinding.DialogDeviceRemindBinding
|
||||
import com.gh.gamecenter.entity.DeviceDialogEntity
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.setting.compose.activity.ComposeGameDownloadSettingActivity
|
||||
import com.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
|
||||
@ -40,7 +40,8 @@ import java.lang.ref.WeakReference
|
||||
/**
|
||||
* 设备提醒弹窗
|
||||
*/
|
||||
class DeviceRemindDialog(context: Context, val entity: DeviceDialogEntity, val gameEntity: GameEntity) : Dialog(context, R.style.GhAlertDialog) {
|
||||
class DeviceRemindDialog(context: Context, val entity: DeviceDialogEntity, val gameEntity: GameEntity) :
|
||||
Dialog(context, R.style.GhAlertDialog) {
|
||||
private val mBinding: DialogDeviceRemindBinding by lazy { DialogDeviceRemindBinding.inflate(layoutInflater) }
|
||||
private var currentPage = 0
|
||||
private var mSlideLooperInterval = 3000L
|
||||
@ -52,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(ComposeGameDownloadSettingActivity.AUTO_INSTALL_SP_KEY, true)
|
||||
if (autoInstall) {
|
||||
dismiss()
|
||||
}
|
||||
@ -78,7 +79,8 @@ class DeviceRemindDialog(context: Context, val entity: DeviceDialogEntity, val g
|
||||
val type = object : TypeToken<List<DeviceDialogEntity>>() {}.type
|
||||
val entities = GsonUtils.gson.fromJson<List<DeviceDialogEntity>>(datas, type)
|
||||
//1.判断设备是否匹配
|
||||
val entity = entities.find { it.manufacturer.toLowerCase().startsWith(Build.MANUFACTURER.toLowerCase()) }
|
||||
val entity =
|
||||
entities.find { it.manufacturer.toLowerCase().startsWith(Build.MANUFACTURER.toLowerCase()) }
|
||||
?: return Pair(false, null)
|
||||
//2.判断游戏不含剔除标签
|
||||
gameEntity.tagStyle.forEach {
|
||||
@ -189,7 +191,9 @@ class DeviceRemindDialog(context: Context, val entity: DeviceDialogEntity, val g
|
||||
|
||||
inner class BannerAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
return object : RecyclerView.ViewHolder(LayoutInflater.from(context).inflate(R.layout.item_device_remind_banner, parent, false)) {}
|
||||
return object : RecyclerView.ViewHolder(
|
||||
LayoutInflater.from(context).inflate(R.layout.item_device_remind_banner, parent, false)
|
||||
) {}
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = if (mDatas.size == 1) mDatas.size else Int.MAX_VALUE
|
||||
|
||||
@ -31,9 +31,9 @@ class GameOffServiceDialogFragment : BaseDialogFragment() {
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
return DialogGameOffServiceBinding
|
||||
.inflate(inflater)
|
||||
.apply { mBinding = this }
|
||||
.root
|
||||
.inflate(inflater)
|
||||
.apply { mBinding = this }
|
||||
.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
@ -52,16 +52,19 @@ class GameOffServiceDialogFragment : BaseDialogFragment() {
|
||||
|
||||
notEmptySite.forEachIndexed { index, site ->
|
||||
val siteTv = TextView(context)
|
||||
siteTv.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT).apply {
|
||||
siteTv.layoutParams = LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
).apply {
|
||||
topMargin = 24F.dip2px()
|
||||
if (index == notEmptySite.size - 1) bottomMargin = 8F.dip2px()
|
||||
}
|
||||
siteTv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14F)
|
||||
siteTv.setTextColor(R.color.theme_font.toColor())
|
||||
siteTv.setTextColor(R.color.theme_font.toColor(requireContext()))
|
||||
siteTv.text = site.text
|
||||
siteTv.paintFlags = siteTv.paintFlags or Paint.UNDERLINE_TEXT_FLAG
|
||||
siteTv.setOnClickListener {
|
||||
// MtaHelper.onEvent("游戏下载状态按钮", getKey(), site.text)
|
||||
// MtaHelper.onEvent("游戏下载状态按钮", getKey(), site.text)
|
||||
DirectUtils.directToWebView(requireContext(), site.url, "(关闭下载弹窗)")
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
@ -90,7 +90,11 @@ class InstallPermissionDialogFragment : BaseDialogFragment() {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun show(activity: AppCompatActivity, downloadEntity: DownloadEntity, callBack: ((isFromPermissionGrantedCallback: Boolean) -> Unit)?) {
|
||||
fun show(
|
||||
activity: AppCompatActivity,
|
||||
downloadEntity: DownloadEntity,
|
||||
callBack: ((isFromPermissionGrantedCallback: Boolean) -> Unit)?
|
||||
) {
|
||||
val isXapk = XapkInstaller.XAPK_EXTENSION_NAME == downloadEntity.path.getExtension()
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
||||
callBack?.invoke(false)
|
||||
@ -114,7 +118,8 @@ class InstallPermissionDialogFragment : BaseDialogFragment() {
|
||||
return
|
||||
}
|
||||
}
|
||||
var installPermissionDialogFragment = activity.supportFragmentManager.findFragmentByTag(InstallPermissionDialogFragment::class.java.name) as? InstallPermissionDialogFragment
|
||||
var installPermissionDialogFragment =
|
||||
activity.supportFragmentManager.findFragmentByTag(InstallPermissionDialogFragment::class.java.name) as? InstallPermissionDialogFragment
|
||||
if (installPermissionDialogFragment != null) {
|
||||
installPermissionDialogFragment.mCallBack = callBack
|
||||
installPermissionDialogFragment.isXapk = isXapk
|
||||
@ -128,7 +133,10 @@ class InstallPermissionDialogFragment : BaseDialogFragment() {
|
||||
this.isXapk = isXapk
|
||||
this.url = downloadEntity.url
|
||||
}
|
||||
installPermissionDialogFragment.show(activity.supportFragmentManager, InstallPermissionDialogFragment::class.java.name)
|
||||
installPermissionDialogFragment.show(
|
||||
activity.supportFragmentManager,
|
||||
InstallPermissionDialogFragment::class.java.name
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ import com.gh.gamecenter.databinding.DialogPrivacyProtocolNewBinding
|
||||
import com.gh.gamecenter.entity.DialogEntity
|
||||
import splitties.bundle.put
|
||||
|
||||
class NewPrivacyPolicyDialogFragment: BaseDialogFragment() {
|
||||
class NewPrivacyPolicyDialogFragment : BaseDialogFragment() {
|
||||
|
||||
private var mCallBack: ((isSuccess: Boolean) -> Unit)? = null
|
||||
private val mBinding by lazy { DialogPrivacyProtocolNewBinding.inflate(layoutInflater) }
|
||||
@ -41,10 +41,12 @@ class NewPrivacyPolicyDialogFragment: BaseDialogFragment() {
|
||||
}
|
||||
|
||||
private fun updateView() {
|
||||
val contentText = SpannableStringBuilder("1.您可以通过《光环助手隐私政策》以及《儿童隐私保护声明》,了解我们如何收集、使用、存储、保护、对外提供您的个人信息以及您享有的权利\n" +
|
||||
"2.您可以通过《接入第三方SDK目录》了解本产品接入的第三方SDK的具体信息\n" +
|
||||
"3.您可以通过《应用权限列表》了解权限申请与使用情况说明\n" +
|
||||
"4.如果您是14周岁以下的未成年人,您需要和您监护人一起仔细阅读《儿童隐私保护声明》,并在征得您监护人同意后,使用我们的产品、服务或向我们提供信息")
|
||||
val contentText = SpannableStringBuilder(
|
||||
"1.您可以通过《光环助手隐私政策》以及《儿童隐私保护声明》,了解我们如何收集、使用、存储、保护、对外提供您的个人信息以及您享有的权利\n" +
|
||||
"2.您可以通过《接入第三方SDK目录》了解本产品接入的第三方SDK的具体信息\n" +
|
||||
"3.您可以通过《应用权限列表》了解权限申请与使用情况说明\n" +
|
||||
"4.如果您是14周岁以下的未成年人,您需要和您监护人一起仔细阅读《儿童隐私保护声明》,并在征得您监护人同意后,使用我们的产品、服务或向我们提供信息"
|
||||
)
|
||||
|
||||
val privacyPolicyText = "《光环助手隐私政策》"
|
||||
val childrenPrivacyPolicyText = "《儿童隐私保护声明》"
|
||||
@ -86,13 +88,14 @@ class NewPrivacyPolicyDialogFragment: BaseDialogFragment() {
|
||||
val thirdPartySdkUrl = requireContext().getString(R.string.sdk_list_url)
|
||||
val permissionListUrl = requireContext().getString(R.string.permission_and_usage_url)
|
||||
|
||||
val selectedUrl = when (contentText.substring(hypertextPositionPair.first, hypertextPositionPair.second)) {
|
||||
privacyPolicyText -> privacyPolicyUrl
|
||||
childrenPrivacyPolicyText -> childrenPrivacyPolicyUrl
|
||||
thirdPartySdkText -> thirdPartySdkUrl
|
||||
permissionListText -> permissionListUrl
|
||||
else -> ""
|
||||
}
|
||||
val selectedUrl =
|
||||
when (contentText.substring(hypertextPositionPair.first, hypertextPositionPair.second)) {
|
||||
privacyPolicyText -> privacyPolicyUrl
|
||||
childrenPrivacyPolicyText -> childrenPrivacyPolicyUrl
|
||||
thirdPartySdkText -> thirdPartySdkUrl
|
||||
permissionListText -> permissionListUrl
|
||||
else -> ""
|
||||
}
|
||||
|
||||
DirectUtils.directToExternalBrowser(requireContext(), selectedUrl)
|
||||
}
|
||||
@ -140,10 +143,13 @@ class NewPrivacyPolicyDialogFragment: BaseDialogFragment() {
|
||||
const val KEY_DATA = "data"
|
||||
|
||||
@JvmStatic
|
||||
fun show(activity: FragmentActivity,
|
||||
privacyPolicyEntity: DialogEntity.PrivacyPolicyEntity? = null,
|
||||
callBack: ((isSuccess: Boolean) -> Unit)?) {
|
||||
var privacyDialogFragment = activity.supportFragmentManager.findFragmentByTag(NewPrivacyPolicyDialogFragment::class.java.name) as? NewPrivacyPolicyDialogFragment
|
||||
fun show(
|
||||
activity: FragmentActivity,
|
||||
privacyPolicyEntity: DialogEntity.PrivacyPolicyEntity? = null,
|
||||
callBack: ((isSuccess: Boolean) -> Unit)?
|
||||
) {
|
||||
var privacyDialogFragment =
|
||||
activity.supportFragmentManager.findFragmentByTag(NewPrivacyPolicyDialogFragment::class.java.name) as? NewPrivacyPolicyDialogFragment
|
||||
if (privacyDialogFragment != null) {
|
||||
privacyDialogFragment.mCallBack = callBack
|
||||
val transaction: FragmentTransaction = activity.supportFragmentManager.beginTransaction()
|
||||
|
||||
@ -15,21 +15,24 @@ import androidx.fragment.app.FragmentTransaction
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.gamecenter.common.base.BaseRecyclerViewHolder
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.common.util.*
|
||||
import com.gh.common.util.DirectUtils
|
||||
import com.gh.common.util.LogUtils
|
||||
import com.gh.gamecenter.common.view.CustomLinkMovementMethod
|
||||
import com.gh.common.util.PackageUtils
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.BaseRecyclerViewHolder
|
||||
import com.gh.gamecenter.common.callback.ConfirmListener
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.entity.LinkEntity
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.utils.*
|
||||
import com.gh.gamecenter.common.view.CustomLinkMovementMethod
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.core.utils.SpanBuilder
|
||||
import com.gh.gamecenter.databinding.FragmentPackageCheckBinding
|
||||
import com.gh.gamecenter.databinding.PackageCheckItemBinding
|
||||
import com.gh.gamecenter.entity.DetectionObjectEntity
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.common.entity.LinkEntity
|
||||
import com.gh.gamecenter.entity.PackageDialogEntity
|
||||
import com.gh.gamecenter.eventbus.EBPackage
|
||||
import com.halo.assistant.HaloApp
|
||||
@ -67,9 +70,14 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
if (detectionObject.packages.contains(packageName)) {
|
||||
val packageLink = gameEntity?.packageDialog?.links?.find { it.buttonLink }
|
||||
LogUtils.uploadPackageCheck(
|
||||
"pkg_check_pop_download", if (DownloadStatus.add == downloadEntity.status) "下载开始" else "下载完成",
|
||||
gameEntity, packageLink?.text ?: "", packageLink?.title
|
||||
?: "", downloadEntity.gameId, downloadEntity.getMetaExtra(Constants.GAME_NAME)
|
||||
"pkg_check_pop_download",
|
||||
if (DownloadStatus.add == downloadEntity.status) "下载开始" else "下载完成",
|
||||
gameEntity,
|
||||
packageLink?.text ?: "",
|
||||
packageLink?.title
|
||||
?: "",
|
||||
downloadEntity.gameId,
|
||||
downloadEntity.getMetaExtra(Constants.GAME_NAME)
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -105,10 +113,21 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
val spanBuilder = SpanBuilder(it.linkHintText).build()
|
||||
it.links.forEachIndexed { index, link ->
|
||||
val linkSpan = SpanBuilder(link.title ?: "").click(
|
||||
0, (link.title
|
||||
?: "").length, R.color.theme_font, true
|
||||
requireContext(),
|
||||
0,
|
||||
(link.title ?: "").length,
|
||||
R.color.theme_font,
|
||||
true
|
||||
) {
|
||||
LogUtils.uploadPackageCheck("pkg_check_pop_click", "点击链接", gameEntity, link.text, link.title, "", "")
|
||||
LogUtils.uploadPackageCheck(
|
||||
"pkg_check_pop_click",
|
||||
"点击链接",
|
||||
gameEntity,
|
||||
link.text,
|
||||
link.title,
|
||||
"",
|
||||
""
|
||||
)
|
||||
DirectUtils.directToLinkPage(requireContext(), link, "包名检测弹窗", "")
|
||||
}.build()
|
||||
spanBuilder.append(linkSpan)
|
||||
@ -165,7 +184,15 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
packageLink = entity.links.find { it.buttonLink }
|
||||
}
|
||||
if (packageLink != null) {
|
||||
LogUtils.uploadPackageCheck("pkg_check_pop_click", "点击前往下载", gameEntity, packageLink.text, packageLink.title, "", "")
|
||||
LogUtils.uploadPackageCheck(
|
||||
"pkg_check_pop_click",
|
||||
"点击前往下载",
|
||||
gameEntity,
|
||||
packageLink.text,
|
||||
packageLink.title,
|
||||
"",
|
||||
""
|
||||
)
|
||||
DirectUtils.directToLinkPage(requireContext(), packageLink, "包名检测弹窗", "")
|
||||
}
|
||||
}
|
||||
@ -318,7 +345,8 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
}
|
||||
}
|
||||
|
||||
class PackageCheckViewHolder(val binding: PackageCheckItemBinding) : BaseRecyclerViewHolder<DetectionObjectEntity>(binding.root)
|
||||
class PackageCheckViewHolder(val binding: PackageCheckItemBinding) :
|
||||
BaseRecyclerViewHolder<DetectionObjectEntity>(binding.root)
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
@ -365,7 +393,10 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkDetectionsInstalled(allInstalledPackages: List<PackageInfo>, packages: ArrayList<String>): Boolean {
|
||||
private fun checkDetectionsInstalled(
|
||||
allInstalledPackages: List<PackageInfo>,
|
||||
packages: ArrayList<String>
|
||||
): Boolean {
|
||||
var isPackagesInstalled = false
|
||||
packages.forEach { packageName ->
|
||||
val isInstalled = allInstalledPackages.find { it.packageName == packageName } != null
|
||||
@ -378,7 +409,10 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
}
|
||||
|
||||
|
||||
fun isAllPackageInstalled(allInstalledPackages: List<PackageInfo>, packageDialogEntity: PackageDialogEntity): Boolean {
|
||||
fun isAllPackageInstalled(
|
||||
allInstalledPackages: List<PackageInfo>,
|
||||
packageDialogEntity: PackageDialogEntity
|
||||
): Boolean {
|
||||
var isAllInstalled = true
|
||||
packageDialogEntity.detectionObjects.forEach loop@{ obj ->
|
||||
if (!checkDetectionsInstalled(allInstalledPackages, obj.packages)) {
|
||||
|
||||
@ -65,7 +65,8 @@ class PrivacyPolicyDialogFragment : BaseDialogFragment() {
|
||||
}
|
||||
|
||||
override fun onClick(widget: View) {
|
||||
val intent = WebActivity.getIntent(requireContext(), context!!.getString(R.string.privacy_policy_url), true)
|
||||
val intent =
|
||||
WebActivity.getIntent(requireContext(), context!!.getString(R.string.privacy_policy_url), true)
|
||||
context?.startActivity(intent)
|
||||
}
|
||||
}, skipText.length - 6, skipText.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
@ -106,7 +107,8 @@ class PrivacyPolicyDialogFragment : BaseDialogFragment() {
|
||||
}
|
||||
|
||||
override fun onClick(widget: View) {
|
||||
val intent = WebActivity.getIntent(requireContext(), context!!.getString(R.string.privacy_policy_url), true)
|
||||
val intent =
|
||||
WebActivity.getIntent(requireContext(), context!!.getString(R.string.privacy_policy_url), true)
|
||||
context?.startActivity(intent)
|
||||
}
|
||||
}, skipText.length - 9, skipText.length - 5, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
@ -164,10 +166,13 @@ class PrivacyPolicyDialogFragment : BaseDialogFragment() {
|
||||
const val KEY_DATA = "data"
|
||||
|
||||
@JvmStatic
|
||||
fun show(activity: FragmentActivity,
|
||||
privacyPolicyEntity: DialogEntity.PrivacyPolicyEntity? = null,
|
||||
callBack: ((isSuccess: Boolean) -> Unit)?) {
|
||||
var privacyDialogFragment = activity.supportFragmentManager.findFragmentByTag(PrivacyPolicyDialogFragment::class.java.name) as? PrivacyPolicyDialogFragment
|
||||
fun show(
|
||||
activity: FragmentActivity,
|
||||
privacyPolicyEntity: DialogEntity.PrivacyPolicyEntity? = null,
|
||||
callBack: ((isSuccess: Boolean) -> Unit)?
|
||||
) {
|
||||
var privacyDialogFragment =
|
||||
activity.supportFragmentManager.findFragmentByTag(PrivacyPolicyDialogFragment::class.java.name) as? PrivacyPolicyDialogFragment
|
||||
if (privacyDialogFragment != null) {
|
||||
privacyDialogFragment.mCallBack = callBack
|
||||
val transaction: FragmentTransaction = activity.supportFragmentManager.beginTransaction()
|
||||
|
||||
@ -70,7 +70,8 @@ data class ExposureEvent(
|
||||
welcomeDialogId = gameEntity?.welcomeDialogId
|
||||
?: eTrace?.firstOrNull()?.payload?.welcomeDialogId,
|
||||
welcomeDialogLinkTitle = gameEntity?.welcomeDialogTitle
|
||||
?: eTrace?.firstOrNull()?.payload?.welcomeDialogLinkTitle
|
||||
?: eTrace?.firstOrNull()?.payload?.welcomeDialogLinkTitle,
|
||||
isAdData = gameEntity?.adIconActive ?: eTrace?.firstOrNull()?.payload?.isAdData ?: false
|
||||
)
|
||||
this.id = UUID.randomUUID().toString()
|
||||
this.timeInMillisecond = System.currentTimeMillis()
|
||||
|
||||
@ -11,26 +11,32 @@ import io.reactivex.functions.Consumer
|
||||
*/
|
||||
class ExposureListener(var fragment: Fragment, var exposable: IExposable) : RecyclerView.OnScrollListener() {
|
||||
|
||||
val throttleBus: ExposureThrottleBus by lazy { ExposureThrottleBus(Consumer { commitExposure(it) }, Consumer(Throwable::printStackTrace)) }
|
||||
val throttleBus: ExposureThrottleBus by lazy {
|
||||
ExposureThrottleBus(
|
||||
Consumer { commitExposure(it) },
|
||||
Consumer(Throwable::printStackTrace)
|
||||
)
|
||||
}
|
||||
var layoutManager: LinearLayoutManager? = null
|
||||
var visibleState: ExposureThrottleBus.VisibleState? = null
|
||||
|
||||
init {
|
||||
fragment.fragmentManager?.registerFragmentLifecycleCallbacks(
|
||||
object : FragmentManager.FragmentLifecycleCallbacks() {
|
||||
override fun onFragmentPaused(fm: FragmentManager, f: Fragment) {
|
||||
if (fragment == f) {
|
||||
visibleState?.let { commitExposure(it) }
|
||||
throttleBus.clear()
|
||||
}
|
||||
object : FragmentManager.FragmentLifecycleCallbacks() {
|
||||
override fun onFragmentPaused(fm: FragmentManager, f: Fragment) {
|
||||
if (fragment == f) {
|
||||
visibleState?.let { commitExposure(it) }
|
||||
throttleBus.clear()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFragmentViewDestroyed(fm: FragmentManager, f: Fragment) {
|
||||
if (fragment == f) {
|
||||
fragment.fragmentManager?.unregisterFragmentLifecycleCallbacks(this)
|
||||
}
|
||||
override fun onFragmentViewDestroyed(fm: FragmentManager, f: Fragment) {
|
||||
if (fragment == f) {
|
||||
fragment.fragmentManager?.unregisterFragmentLifecycleCallbacks(this)
|
||||
}
|
||||
}, false)
|
||||
}
|
||||
}, false
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -43,7 +49,8 @@ class ExposureListener(var fragment: Fragment, var exposable: IExposable) : Recy
|
||||
if (layoutManager == null) layoutManager = recyclerView.layoutManager as LinearLayoutManager
|
||||
|
||||
layoutManager?.run {
|
||||
visibleState = ExposureThrottleBus.VisibleState(findFirstVisibleItemPosition(), findLastVisibleItemPosition())
|
||||
visibleState =
|
||||
ExposureThrottleBus.VisibleState(findFirstVisibleItemPosition(), findLastVisibleItemPosition())
|
||||
throttleBus.postVisibleState(visibleState!!)
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,4 +6,4 @@ import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Keep
|
||||
@Parcelize
|
||||
data class ExposureSource(var k: String, var v: String = ""): Parcelable
|
||||
data class ExposureSource(var k: String, var v: String = "") : Parcelable
|
||||
@ -23,10 +23,10 @@ class ExposureThrottleBus(var onSuccess: Consumer<VisibleState>, var onError: Co
|
||||
* throttleWithTimeout() to pass a visibleState event with a delay and drop current event if another event arrives before the timeout.
|
||||
*/
|
||||
val disposable = mPublishSubject
|
||||
.distinctUntilChanged()
|
||||
.throttleWithTimeout(THRESHOLD_TIME, TimeUnit.MILLISECONDS)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(onSuccess, onError)
|
||||
.distinctUntilChanged()
|
||||
.throttleWithTimeout(THRESHOLD_TIME, TimeUnit.MILLISECONDS)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(onSuccess, onError)
|
||||
mCompositeDisposable.add(disposable)
|
||||
}
|
||||
|
||||
|
||||
@ -81,45 +81,39 @@ object ExposureUtils {
|
||||
|
||||
@JvmStatic
|
||||
fun getDownloadType(apkEntity: ApkEntity, gameId: String, isVGame: Boolean): DownloadType {
|
||||
return if (isVGame) {
|
||||
if (PackagesManager.isCanUpdate(gameId, apkEntity.packageName)) {
|
||||
DownloadType.FUN_UPDATE
|
||||
} else {
|
||||
DownloadType.FUN_DOWNLOAD
|
||||
}
|
||||
} else if (PackageUtils.isInstalled(
|
||||
return when {
|
||||
isVGame -> getVGameDownloadType(apkEntity, gameId)
|
||||
PackageUtils.isInstalled(
|
||||
HaloApp.getInstance().application,
|
||||
apkEntity.packageName
|
||||
)
|
||||
) {
|
||||
if (PackageUtils.isSignedByGh(
|
||||
HaloApp.getInstance().application,
|
||||
apkEntity.packageName
|
||||
)
|
||||
) {
|
||||
if (PackageUtils.isCanUpdate(apkEntity, gameId)) {
|
||||
DownloadType.PLUGIN_UPDATE
|
||||
} else {
|
||||
if (Version(apkEntity.version).isHigherThan(
|
||||
PackageUtils.getVersionNameByPackageName(
|
||||
apkEntity.packageName
|
||||
)
|
||||
)
|
||||
) {
|
||||
DownloadType.UPDATE
|
||||
} else {
|
||||
DownloadType.DOWNLOAD
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!TextUtils.isEmpty(apkEntity.ghVersion)) {
|
||||
DownloadType.PLUGIN_DOWNLOAD
|
||||
} else {
|
||||
DownloadType.UPDATE
|
||||
}
|
||||
}
|
||||
} else {
|
||||
DownloadType.DOWNLOAD
|
||||
) -> getInstallDownloadType(apkEntity, gameId)
|
||||
else -> DownloadType.DOWNLOAD
|
||||
}
|
||||
}
|
||||
|
||||
private fun getVGameDownloadType(apkEntity: ApkEntity, gameId: String): DownloadType {
|
||||
return when {
|
||||
PackagesManager.isCanUpdate(gameId, apkEntity.packageName) -> DownloadType.FUN_UPDATE
|
||||
else -> DownloadType.FUN_DOWNLOAD
|
||||
}
|
||||
}
|
||||
|
||||
private fun getInstallDownloadType(apkEntity: ApkEntity, gameId: String): DownloadType {
|
||||
return when {
|
||||
PackageUtils.isSignedByGh(
|
||||
HaloApp.getInstance().application,
|
||||
apkEntity.packageName
|
||||
) -> getUpdateDownloadType(apkEntity, gameId)
|
||||
!TextUtils.isEmpty(apkEntity.ghVersion) -> DownloadType.PLUGIN_DOWNLOAD
|
||||
else -> DownloadType.UPDATE
|
||||
}
|
||||
}
|
||||
|
||||
private fun getUpdateDownloadType(apkEntity: ApkEntity, gameId: String): DownloadType {
|
||||
return when {
|
||||
PackageUtils.isCanUpdate(apkEntity, gameId) -> DownloadType.PLUGIN_UPDATE
|
||||
Version(apkEntity.version).isHigherThan(PackageUtils.getVersionNameByPackageName(apkEntity.packageName)) -> DownloadType.UPDATE
|
||||
else -> DownloadType.DOWNLOAD
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -36,6 +36,7 @@ data class RegionSetting(
|
||||
@SerializedName("button_text")
|
||||
var buttonText: String,// 按钮文案
|
||||
)
|
||||
|
||||
data class GameSpecialDownloadInfo(
|
||||
@SerializedName("game_id")
|
||||
var gameId: String = "",
|
||||
|
||||
@ -33,7 +33,8 @@ object RegionSettingHelper {
|
||||
return mFilterGameIdSet?.contains(gameId) ?: false
|
||||
}
|
||||
|
||||
fun shouldThisGameShowSpecialDownload(gameId: String) = mGameSpecialDownloadInfoList?.any { it.gameId == gameId } ?: false
|
||||
fun shouldThisGameShowSpecialDownload(gameId: String) =
|
||||
mGameSpecialDownloadInfoList?.any { it.gameId == gameId } ?: false
|
||||
|
||||
@JvmStatic
|
||||
fun getGameSpecialDownloadInfo(gameId: String) = mGameSpecialDownloadInfoList?.find { it.gameId == gameId }
|
||||
|
||||
@ -16,24 +16,30 @@ import com.gh.gamecenter.room.converter.*
|
||||
import com.gh.gamecenter.room.dao.*
|
||||
import com.halo.assistant.HaloApp
|
||||
|
||||
@Database(entities = [AnswerEntity::class, ArticleEntity::class, NewsEntity::class, HistoryGameEntity::class, MyVideoEntity::class, GamesCollectionEntity::class], version = 11, exportSchema = false)
|
||||
@TypeConverters(CountConverter::class,
|
||||
CommunityConverter::class,
|
||||
TimeConverter::class,
|
||||
AnswerUserConverter::class,
|
||||
ThumbnailConverter::class,
|
||||
TagStyleListConverter::class,
|
||||
StringArrayListConverter::class,
|
||||
ListStringConverter::class,
|
||||
CommunityVideoConverter::class,
|
||||
UserConverter::class,
|
||||
ImageInfoConverter::class,
|
||||
VideoInfoConverter::class,
|
||||
QuestionsConverter::class,
|
||||
MeConverter::class,
|
||||
SimpleGameListConverter::class,
|
||||
TagInfoListConverter::class,
|
||||
ActivityLabelListConverter::class)
|
||||
@Database(
|
||||
entities = [AnswerEntity::class, ArticleEntity::class, NewsEntity::class, HistoryGameEntity::class, MyVideoEntity::class, GamesCollectionEntity::class],
|
||||
version = 11,
|
||||
exportSchema = false
|
||||
)
|
||||
@TypeConverters(
|
||||
CountConverter::class,
|
||||
CommunityConverter::class,
|
||||
TimeConverter::class,
|
||||
AnswerUserConverter::class,
|
||||
ThumbnailConverter::class,
|
||||
TagStyleListConverter::class,
|
||||
StringArrayListConverter::class,
|
||||
ListStringConverter::class,
|
||||
CommunityVideoConverter::class,
|
||||
UserConverter::class,
|
||||
ImageInfoConverter::class,
|
||||
VideoInfoConverter::class,
|
||||
QuestionsConverter::class,
|
||||
MeConverter::class,
|
||||
SimpleGameListConverter::class,
|
||||
TagInfoListConverter::class,
|
||||
ActivityLabelListConverter::class
|
||||
)
|
||||
|
||||
abstract class HistoryDatabase : RoomDatabase() {
|
||||
|
||||
@ -109,7 +115,8 @@ abstract class HistoryDatabase : RoomDatabase() {
|
||||
|
||||
val MIGRATION_9_10: Migration = object : Migration(9, 10) {
|
||||
override fun migrate(database: SupportSQLiteDatabase) {
|
||||
database.execSQL("CREATE TABLE GamesCollectionEntity (id TEXT NOT NULL PRIMARY KEY, tags TEXT, games TEXT, title TEXT NOT NULL, intro TEXT NOT NULL, cover TEXT NOT NULL, display TEXT NOT NULL, stamp TEXT NOT NULL, count TEXT, user TEXT, me TEXT, orderTag INTEGER NOT NULL)"
|
||||
database.execSQL(
|
||||
"CREATE TABLE GamesCollectionEntity (id TEXT NOT NULL PRIMARY KEY, tags TEXT, games TEXT, title TEXT NOT NULL, intro TEXT NOT NULL, cover TEXT NOT NULL, display TEXT NOT NULL, stamp TEXT NOT NULL, count TEXT, user TEXT, me TEXT, orderTag INTEGER NOT NULL)"
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -121,17 +128,21 @@ abstract class HistoryDatabase : RoomDatabase() {
|
||||
}
|
||||
|
||||
val instance by lazy {
|
||||
Room.databaseBuilder(HaloApp.getInstance().application, HistoryDatabase::class.java, "USER_TRACK_HISTORY_DATABASE")
|
||||
.addMigrations(MIGRATION_2_3)
|
||||
.addMigrations(MIGRATION_3_4)
|
||||
.addMigrations(MIGRATION_4_5)
|
||||
.addMigrations(MIGRATION_5_6)
|
||||
.addMigrations(MIGRATION_6_7)
|
||||
.addMigrations(MIGRATION_7_8)
|
||||
.addMigrations(MIGRATION_8_9)
|
||||
.addMigrations(MIGRATION_9_10)
|
||||
.addMigrations(MIGRATION_10_11)
|
||||
.build()
|
||||
Room.databaseBuilder(
|
||||
HaloApp.getInstance().application,
|
||||
HistoryDatabase::class.java,
|
||||
"USER_TRACK_HISTORY_DATABASE"
|
||||
)
|
||||
.addMigrations(MIGRATION_2_3)
|
||||
.addMigrations(MIGRATION_3_4)
|
||||
.addMigrations(MIGRATION_4_5)
|
||||
.addMigrations(MIGRATION_5_6)
|
||||
.addMigrations(MIGRATION_6_7)
|
||||
.addMigrations(MIGRATION_7_8)
|
||||
.addMigrations(MIGRATION_8_9)
|
||||
.addMigrations(MIGRATION_9_10)
|
||||
.addMigrations(MIGRATION_10_11)
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -26,7 +26,11 @@ object HistoryHelper {
|
||||
|
||||
fun insertGamesCollectionEntity(gamesCollectionDetailEntity: GamesCollectionDetailEntity) {
|
||||
val gamesCollectionEntity = convertGamesCollectionDetailToGamesCollection(gamesCollectionDetailEntity)
|
||||
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.gamesCollectionDao().addGamesCollection(gamesCollectionEntity) } }
|
||||
runOnIoThread {
|
||||
tryCatchInRelease {
|
||||
HistoryDatabase.instance.gamesCollectionDao().addGamesCollection(gamesCollectionEntity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@ -78,27 +82,47 @@ object HistoryHelper {
|
||||
|
||||
@JvmStatic
|
||||
fun deleteNewsEntity(newsId: String) {
|
||||
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.newsDao().deleteNews(NewsEntity().apply { id = newsId }) } }
|
||||
runOnIoThread {
|
||||
tryCatchInRelease {
|
||||
HistoryDatabase.instance.newsDao().deleteNews(NewsEntity().apply { id = newsId })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun deleteGameEntity(gameId: String) {
|
||||
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.gameDao().deleteGame(HistoryGameEntity(id = gameId)) } }
|
||||
runOnIoThread {
|
||||
tryCatchInRelease {
|
||||
HistoryDatabase.instance.gameDao().deleteGame(HistoryGameEntity(id = gameId))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun deleteArticleEntity(articleId: String) {
|
||||
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.articleDao().deleteArticle(ArticleEntity(id = articleId)) } }
|
||||
runOnIoThread {
|
||||
tryCatchInRelease {
|
||||
HistoryDatabase.instance.articleDao().deleteArticle(ArticleEntity(id = articleId))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun deleteAnswerEntity(answerId: String) {
|
||||
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.answerDao().deleteAnswer(AnswerEntity().apply { primaryKey = answerId }) } }
|
||||
runOnIoThread {
|
||||
tryCatchInRelease {
|
||||
HistoryDatabase.instance.answerDao().deleteAnswer(AnswerEntity().apply { primaryKey = answerId })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun deleteVideoEntity(videoId: String) {
|
||||
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.videoHistoryDao().deleteVideo(MyVideoEntity().apply { id = videoId }) } }
|
||||
runOnIoThread {
|
||||
tryCatchInRelease {
|
||||
HistoryDatabase.instance.videoHistoryDao().deleteVideo(MyVideoEntity().apply { id = videoId })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@ -108,7 +132,12 @@ object HistoryHelper {
|
||||
|
||||
@JvmStatic
|
||||
fun deleteGamesCollectionEntity(gameCollectionId: String) {
|
||||
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.gamesCollectionDao().deleteGamesCollection(GamesCollectionEntity(id = gameCollectionId)) } }
|
||||
runOnIoThread {
|
||||
tryCatchInRelease {
|
||||
HistoryDatabase.instance.gamesCollectionDao()
|
||||
.deleteGamesCollection(GamesCollectionEntity(id = gameCollectionId))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -121,7 +150,9 @@ object HistoryHelper {
|
||||
val articleEntity = ArticleEntity()
|
||||
|
||||
articleEntity.id = articleDetailEntity.id
|
||||
articleEntity.brief = articleDetailEntity.content.removeVideoContent().removeInsertedContent().clearHtmlFormatCompletely().replace(" +".toRegex(), " ")
|
||||
articleEntity.brief =
|
||||
articleDetailEntity.content.removeVideoContent().removeInsertedContent().clearHtmlFormatCompletely()
|
||||
.replace(" +".toRegex(), " ")
|
||||
articleEntity.count = articleDetailEntity.count
|
||||
articleDetailEntity.community.id = articleDetailEntity.communityId
|
||||
articleEntity.community = articleDetailEntity.community
|
||||
@ -146,7 +177,9 @@ object HistoryHelper {
|
||||
answerEntity.vote = answerDetailEntity.vote
|
||||
answerEntity.user = answerDetailEntity.user
|
||||
answerEntity.orderTag = System.currentTimeMillis()
|
||||
answerEntity.brief = answerDetailEntity.content.removeVideoContent().removeInsertedContent().clearHtmlFormatCompletely().replace(" +".toRegex(), " ")
|
||||
answerEntity.brief =
|
||||
answerDetailEntity.content.removeVideoContent().removeInsertedContent().clearHtmlFormatCompletely()
|
||||
.replace(" +".toRegex(), " ")
|
||||
answerEntity.time = answerDetailEntity.time
|
||||
answerEntity.images = answerDetailEntity.images
|
||||
answerEntity.imagesInfo = answerDetailEntity.imagesInfo
|
||||
@ -176,7 +209,8 @@ object HistoryHelper {
|
||||
id = id ?: "",
|
||||
name = name ?: "",
|
||||
icon = icon ?: "",
|
||||
badge = badge)
|
||||
badge = badge
|
||||
)
|
||||
}
|
||||
gamesCollectionEntity.me = gamesCollectionDetailEntity.me
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ import com.gh.gamecenter.core.provider.IActivationProvider
|
||||
@Route(path = RouteConsts.provider.activation, name = "ActivationHelper暴露服务")
|
||||
class ActivationProviderImpl : IActivationProvider {
|
||||
override fun init(context: Context?) {
|
||||
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
override fun sendActivationInfo() {
|
||||
|
||||
@ -10,7 +10,7 @@ import com.halo.assistant.HaloApp
|
||||
@Route(path = RouteConsts.provider.app, name = "Application暴露服务")
|
||||
class AppProviderImpl : IAppProvider {
|
||||
override fun init(context: Context?) {
|
||||
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
override fun getAppName(): String {
|
||||
@ -21,6 +21,10 @@ class AppProviderImpl : IAppProvider {
|
||||
return HaloApp.getInstance().gid ?: ""
|
||||
}
|
||||
|
||||
override fun refreshGid() {
|
||||
HaloApp.getInstance().refreshGid()
|
||||
}
|
||||
|
||||
override fun getOaid(): String {
|
||||
return HaloApp.getInstance().oaid ?: ""
|
||||
}
|
||||
@ -29,6 +33,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 ?: ""
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
@ -9,7 +9,7 @@ import com.gh.gamecenter.core.provider.IBuildConfigProvider
|
||||
@Route(path = RouteConsts.provider.buildConfig, name = "BuildConfig暴露服务")
|
||||
class BuildConfigImpl : IBuildConfigProvider {
|
||||
override fun init(context: Context?) {
|
||||
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
override fun getApplicationId(): String = BuildConfig.APPLICATION_ID
|
||||
|
||||
@ -13,6 +13,6 @@ class CheckLoginProviderImpl : ICheckLoginProvider {
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
@ -72,7 +72,11 @@ class ConfigProviderImpl : IConfigProvider {
|
||||
return Config.WEIBO_APPKEY
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
override fun getNightModeSetting(): Boolean {
|
||||
return Config.getNightModeSetting()?.setting ?: false
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
@ -15,6 +15,6 @@ class DataUtilsProviderImpl : IDataUtilsProvider {
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
@ -19,6 +19,6 @@ class DefaultUrlHandlerProviderImpl : IDefaultUrlHandlerProvider {
|
||||
}
|
||||
|
||||
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
|
||||
@ -15,14 +16,54 @@ class DialogUtilsProviderImpl : IDialogUtilsProvider {
|
||||
override fun onConfirm() {
|
||||
confirm.invoke()
|
||||
}
|
||||
}, object :CancelListener{
|
||||
}, object : CancelListener {
|
||||
override fun onCancel() {
|
||||
cancel.invoke()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
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,7 +49,15 @@ class DirectProviderImpl : IDirectProvider {
|
||||
DirectUtils.directToLotteryParadisePage(context)
|
||||
}
|
||||
|
||||
override fun init(context: 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
|
||||
}
|
||||
}
|
||||
@ -19,7 +19,7 @@ class DownloadManagerProviderImpl : IDownloadManagerProvider {
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
}
|
||||
@ -8,7 +8,7 @@ import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.core.provider.IEntranceUtilsProvider
|
||||
|
||||
@Route(path = RouteConsts.provider.entranceUtils, name = "EntranceUtils暴露服务")
|
||||
class EntranceUtilsProviderImpl: IEntranceUtilsProvider {
|
||||
class EntranceUtilsProviderImpl : IEntranceUtilsProvider {
|
||||
override fun jumpActivity(context: Context, bundle: Bundle) {
|
||||
EntranceUtils.jumpActivity(context, bundle)
|
||||
}
|
||||
@ -18,6 +18,6 @@ class EntranceUtilsProviderImpl: IEntranceUtilsProvider {
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
@ -23,6 +23,6 @@ class ErrorHelperProviderImpl : IErrorHelperProvider {
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
@ -14,6 +14,6 @@ class FloatingBackViewManagerProviderImpl : IFloatingBackViewManagerProvider {
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
@ -14,6 +14,6 @@ class GameSubstituteRepositoryProviderImpl : IGameSubstituteRepositoryProvider {
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
@ -38,7 +38,7 @@ class HandleGameResponseProviderImpl : IHandleGameResponseProvider {
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
@ -21,6 +21,6 @@ class LinkDirectUtilsProviderImpl : ILinkDirectUtilsProvider {
|
||||
|
||||
|
||||
override fun init(context: Context?) {
|
||||
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
@ -14,6 +14,6 @@ class LogUtilsProviderImpl : ILogUtilsProvider {
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
@ -14,6 +14,6 @@ class MessageUnreadRepositoryProviderImpl : IMessageUnreadRepositoryProvider {
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
@ -14,6 +14,6 @@ class PackageHelperProviderImpl : IPackageHelperProvider {
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
@ -19,6 +19,6 @@ class PackageInstallerProviderImpl : IPackageInstallerProvider {
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
@ -34,6 +34,6 @@ class PackageUtilsProviderImpl : IPackageUtilsProvider {
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
@ -18,6 +18,6 @@ class ReservationRepositoryProviderImpl : IReservationRepositoryProvider {
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
@ -13,5 +13,7 @@ class TimeUtilProviderImpl : ITimeUtilProvider {
|
||||
|
||||
override fun currentTime() = TimeUtil.currentTime()
|
||||
|
||||
override fun init(context: Context?) {}
|
||||
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,7 +17,15 @@ class WebProviderImpl : IWebProvider {
|
||||
return WebActivity.getWebIntent(context, title, url)
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
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,11 +8,13 @@ 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?) {
|
||||
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
@ -16,10 +16,10 @@ object RemenkapaiRepository {
|
||||
fun getRemenkapai(size: Int): Observable<List<GameEntity>> {
|
||||
return if (remenkapaiList.isEmpty()) {
|
||||
RetrofitManager.getInstance().api.remenkapai
|
||||
.map(RegionSettingHelper.filterGame)
|
||||
.map { gameList -> filterEntityWithoutApk(gameList) }
|
||||
.map { pickRandomSizeEntity(size) }
|
||||
.map(ApkActiveUtils.filterMapperList)
|
||||
.map(RegionSettingHelper.filterGame)
|
||||
.map { gameList -> filterEntityWithoutApk(gameList) }
|
||||
.map { pickRandomSizeEntity(size) }
|
||||
.map(ApkActiveUtils.filterMapperList)
|
||||
} else {
|
||||
Observable.create { emitter -> emitter.onNext(pickRandomSizeEntity(size)) }
|
||||
}
|
||||
|
||||
@ -40,16 +40,19 @@ object ReservationRepository {
|
||||
fun refreshReservations() {
|
||||
if (CheckLoginUtils.isLogin()) {
|
||||
RetrofitManager.getInstance().api
|
||||
.getAllTheGameReservations(UserManager.getInstance().userId, Utils.getTime(HaloApp.getInstance().application))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : BiResponse<List<String>>() {
|
||||
.getAllTheGameReservations(
|
||||
UserManager.getInstance().userId,
|
||||
Utils.getTime(HaloApp.getInstance().application)
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : BiResponse<List<String>>() {
|
||||
|
||||
override fun onSuccess(data: List<String>) {
|
||||
mReservationSet = HashSet(data)
|
||||
}
|
||||
override fun onSuccess(data: List<String>) {
|
||||
mReservationSet = HashSet(data)
|
||||
}
|
||||
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
@ -18,10 +19,7 @@ import com.gh.gamecenter.common.base.TrackableDialog
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.AppExecutor.uiExecutor
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.core.utils.MtaHelper
|
||||
import com.gh.gamecenter.core.utils.SpeedUtils
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.core.utils.*
|
||||
import com.gh.gamecenter.entity.ApkEntity
|
||||
import com.gh.gamecenter.entity.SimulatorEntity
|
||||
import com.gh.gamecenter.entity.TrackableEntity
|
||||
@ -54,8 +52,12 @@ class SimulatorDownloadManager private constructor() {
|
||||
val size = downloadEntity.progress.toFloat() / 1024 / 1024
|
||||
val df = DecimalFormat("0.00")
|
||||
appProgressSize!!.text = "${df.format(size.toDouble())}MB"
|
||||
appProgressRemain!!.text = String.format("剩余%s", SpeedUtils.getRemainSecondTime(downloadEntity.size,
|
||||
downloadEntity.progress, downloadEntity.speed * 1024))
|
||||
appProgressRemain!!.text = String.format(
|
||||
"剩余%s", SpeedUtils.getRemainSecondTime(
|
||||
downloadEntity.size,
|
||||
downloadEntity.progress, downloadEntity.speed * 1024
|
||||
)
|
||||
)
|
||||
app_pb_progress!!.progress = (downloadEntity.percent * 10).toInt()
|
||||
|
||||
val width = app_pb_progress!!.width
|
||||
@ -73,10 +75,21 @@ class SimulatorDownloadManager private constructor() {
|
||||
appProgressPercent?.text = if (downloadEntity.percent != 100.0) "${downloadEntity.percent}%" else "100%"
|
||||
when {
|
||||
DownloadStatus.done == downloadEntity.status -> {
|
||||
val locationStr = if (simulatorLocation == SimulatorLocation.LAUNCH) "${simulatorLocation?.value}《${gameName}》" else simulatorLocation?.value
|
||||
val fileName = downloadEntity.path.substring(downloadEntity.path.lastIndexOf('/') + 1).removeSuffix(".apk")
|
||||
val locationStr =
|
||||
if (simulatorLocation == SimulatorLocation.LAUNCH) "${simulatorLocation?.value}《${gameName}》" else simulatorLocation?.value
|
||||
val fileName =
|
||||
downloadEntity.path.substring(downloadEntity.path.lastIndexOf('/') + 1).removeSuffix(".apk")
|
||||
val startTime = downloadEntity.getMetaExtra(Constants.SIMULATOR_DOWNLOAD_START_TIME)
|
||||
LogUtils.uploadSimulatorDownload("simulator_download_complete", fileName, simulator?.id, downloadEntity.name, gameId, locationStr, downloadType, startTime)
|
||||
LogUtils.uploadSimulatorDownload(
|
||||
"simulator_download_complete",
|
||||
fileName,
|
||||
simulator?.id,
|
||||
downloadEntity.name,
|
||||
gameId,
|
||||
locationStr,
|
||||
downloadType,
|
||||
startTime
|
||||
)
|
||||
DownloadManager.getInstance().cancel(downloadEntity.url, false, true, false)
|
||||
val activity = mContextRef?.get() as? AppCompatActivity
|
||||
if (activity?.isFinishing == false) {
|
||||
@ -116,58 +129,88 @@ class SimulatorDownloadManager private constructor() {
|
||||
showDownloadDialog(context, simulator, location, "", "", null)
|
||||
}
|
||||
|
||||
fun showDownloadDialog(context: Context?, simulator: SimulatorEntity?, location: SimulatorLocation, gameId: String = "", gameName: String = "", cancelCallback: (() -> Unit)? = null) {
|
||||
fun showDownloadDialog(
|
||||
context: Context?,
|
||||
simulator: SimulatorEntity?,
|
||||
location: SimulatorLocation,
|
||||
gameId: String = "",
|
||||
gameName: String = "",
|
||||
cancelCallback: (() -> Unit)? = null
|
||||
) {
|
||||
if (context == null) return
|
||||
mContextRef = WeakReference(context)
|
||||
|
||||
this.simulatorLocation = location
|
||||
this.simulator = simulator
|
||||
this.gameId = gameId
|
||||
this.gameName = gameName
|
||||
//判断是否隐藏
|
||||
if (simulator?.active == false) {
|
||||
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)
|
||||
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
|
||||
)
|
||||
DialogHelper.showDialog(
|
||||
context,
|
||||
title,
|
||||
message,
|
||||
positiveText,
|
||||
negativeText,
|
||||
trackMtaEvent = true,
|
||||
cancelClickCallback = {
|
||||
if (shouldShowUpdate && isInstalled) {
|
||||
cancelCallback?.invoke()
|
||||
MtaHelper.onEvent(trackableEntity.event, trackableEntity.key, "点击下次再说")
|
||||
PermissionHelper.checkGetInstalledAppsListBeforeAction(context, object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
//判断是否隐藏
|
||||
if (simulator?.active == false) {
|
||||
showNoneEmulatorDialog(context)
|
||||
return
|
||||
}
|
||||
},
|
||||
confirmClickCallback = {
|
||||
showDownloadingDialog(context, simulator)
|
||||
MtaHelper.onEvent(
|
||||
trackableEntity.event,
|
||||
trackableEntity.key,
|
||||
if (shouldShowUpdate && isInstalled) "点击更新" else "点击下载"
|
||||
val isInstalled = PackageUtils.isInstalledFromAllPackage(context, simulator?.apk?.packageName)
|
||||
// val versionFromInstalledApp = PackageUtils.getVersionNameByPackageName(simulator?.apk?.packageName)
|
||||
val shouldShowUpdate = PackageUtils.isInstalledApkMatchedMd5(simulator?.apk?.packageName, simulator?.apk?.md5)
|
||||
val 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 "取消"
|
||||
val trackableEntity = TrackableEntity(
|
||||
"模拟器下载",
|
||||
key = if (shouldShowUpdate && isInstalled) "更新弹窗" else "下载弹窗",
|
||||
logShowEvent = true
|
||||
)
|
||||
},
|
||||
mtaEvent = trackableEntity.event, mtaKey = trackableEntity.key,
|
||||
extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true)
|
||||
)
|
||||
if (shouldShowUpdate && isInstalled) {
|
||||
NewFlatLogUtils.logSimulatorUpdateAlertShow()
|
||||
}
|
||||
DialogHelper.showDialog(
|
||||
context,
|
||||
title,
|
||||
message,
|
||||
positiveText,
|
||||
negativeText,
|
||||
trackMtaEvent = true,
|
||||
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,
|
||||
if (shouldShowUpdate && isInstalled) "点击更新" else "点击下载"
|
||||
)
|
||||
},
|
||||
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)
|
||||
@ -225,9 +268,10 @@ class SimulatorDownloadManager private constructor() {
|
||||
ToastUtils.showToast("该模拟器暂未提供下载")
|
||||
},
|
||||
uiModificationCallback = { binding ->
|
||||
binding.confirmTv.setTextColor(R.color.text_body.toColor())
|
||||
binding.confirmTv.setTextColor(R.color.text_body.toColor(context))
|
||||
},
|
||||
extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true))
|
||||
extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true)
|
||||
)
|
||||
}
|
||||
|
||||
private fun download(simulator: SimulatorEntity?) {
|
||||
@ -264,13 +308,26 @@ class SimulatorDownloadManager private constructor() {
|
||||
downloadEntity.versionName = apkEntity.version
|
||||
|
||||
downloadEntity.addMetaExtra(Constants.EXTRA_DOWNLOAD_TYPE, Constants.SIMULATOR_DOWNLOAD)
|
||||
downloadEntity.addMetaExtra(Constants.SIMULATOR_DOWNLOAD_START_TIME, (System.currentTimeMillis() / 1000).toString())
|
||||
downloadEntity.addMetaExtra(
|
||||
Constants.SIMULATOR_DOWNLOAD_START_TIME,
|
||||
(System.currentTimeMillis() / 1000).toString()
|
||||
)
|
||||
downloadEntity.addMetaExtra(Constants.DOWNLOAD_ID, downloadId)
|
||||
uiExecutor.executeWithDelay(Runnable { DownloadManager.getInstance().add(downloadEntity) }, 200)
|
||||
|
||||
val locationStr = if (simulatorLocation == SimulatorLocation.LAUNCH) "${simulatorLocation?.value}《${gameName}》" else simulatorLocation?.value
|
||||
val locationStr =
|
||||
if (simulatorLocation == SimulatorLocation.LAUNCH) "${simulatorLocation?.value}《${gameName}》" else simulatorLocation?.value
|
||||
val fileName = downloadEntity.path.substring(downloadEntity.path.lastIndexOf('/') + 1).removeSuffix(".apk")
|
||||
LogUtils.uploadSimulatorDownload("simulator_download", fileName, simulator.id, simulator.name, gameId, locationStr, downloadType, "")
|
||||
LogUtils.uploadSimulatorDownload(
|
||||
"simulator_download",
|
||||
fileName,
|
||||
simulator.id,
|
||||
simulator.name,
|
||||
gameId,
|
||||
locationStr,
|
||||
downloadType,
|
||||
""
|
||||
)
|
||||
|
||||
downloadDialog?.show()
|
||||
}
|
||||
|
||||
@ -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,14 +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,
|
||||
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 {
|
||||
@ -107,50 +164,55 @@ 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 {
|
||||
getBitmapFormCache(it)
|
||||
}.map {
|
||||
BitmapUtils.compressBitmap(it, 100)
|
||||
}.map {
|
||||
val baos = ByteArrayOutputStream()
|
||||
it.compress(Bitmap.CompressFormat.WEBP, 100, baos)
|
||||
baos.toByteArray()
|
||||
.flatMap {
|
||||
getBitmapFormCache(it)
|
||||
}.map {
|
||||
BitmapUtils.compressBitmap(it, 100)
|
||||
}.map {
|
||||
val baos = ByteArrayOutputStream()
|
||||
it.compress(Bitmap.CompressFormat.WEBP, 100, baos)
|
||||
baos.toByteArray()
|
||||
}
|
||||
.compose(singleToMain())
|
||||
.subscribe({
|
||||
val intent = Intent()
|
||||
intent.data = Uri.fromFile(File(downloadEntity.path))
|
||||
if (gameEntity.simulatorType == "FBA" || gameEntity.simulatorType == "FBN") {
|
||||
val apkEntity = gameEntity.getApk()[0]
|
||||
intent.putExtra("rom_name", apkEntity.packageName)
|
||||
}
|
||||
.compose(singleToMain())
|
||||
.subscribe({
|
||||
val intent = Intent()
|
||||
intent.data = Uri.fromFile(File(downloadEntity.path))
|
||||
if (gameEntity.simulatorType == "FBA" || gameEntity.simulatorType == "FBN") {
|
||||
val apkEntity = gameEntity.getApk()[0]
|
||||
intent.putExtra("rom_name", apkEntity.packageName)
|
||||
}
|
||||
intent.putExtra("default_path", downloadEntity.path.substring(0, downloadEntity.path.lastIndexOf('/')))
|
||||
intent.putExtra("game_type", gameEntity.simulatorType)
|
||||
intent.putExtra("title", downloadEntity.name)
|
||||
intent.putExtra("icon", gameIcon)
|
||||
intent.putExtra("iconStream", it)
|
||||
intent.putExtra("meta", LogUtils.getMetaObject().toString())
|
||||
intent.putExtra("simulatorId", gameEntity.simulator?.id)
|
||||
intent.putExtra("simulatorName", gameEntity.simulator?.name)
|
||||
intent.putExtra("gameId", gameEntity.id)
|
||||
intent.putExtra("default_path", downloadEntity.path.substring(0, downloadEntity.path.lastIndexOf('/')))
|
||||
intent.putExtra("game_type", gameEntity.simulatorType)
|
||||
intent.putExtra("title", downloadEntity.name)
|
||||
intent.putExtra("icon", gameIcon)
|
||||
intent.putExtra("iconStream", it)
|
||||
intent.putExtra("meta", LogUtils.getMetaObject().toString())
|
||||
intent.putExtra("simulatorId", gameEntity.simulator?.id)
|
||||
intent.putExtra("simulatorName", gameEntity.simulator?.name)
|
||||
intent.putExtra("gameId", gameEntity.id)
|
||||
|
||||
val destActivity = "com.gh.emu.RequestPermissionActivity"
|
||||
intent.setClassName(gameEntity.simulator?.apk?.packageName ?: "", destActivity)
|
||||
try {
|
||||
AppManager.getInstance().recentActiveActivity?.startActivity(intent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
ToastUtils.showToast("模拟器安装错误")
|
||||
}
|
||||
val destActivity = "com.gh.emu.RequestPermissionActivity"
|
||||
intent.setClassName(gameEntity.simulator?.apk?.packageName ?: "", destActivity)
|
||||
try {
|
||||
AppManager.getInstance().recentActiveActivity?.startActivity(intent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
ToastUtils.showToast("模拟器安装错误")
|
||||
}
|
||||
|
||||
recordPlaySimulatorGames(gameEntity.id)
|
||||
}, {
|
||||
ToastUtils.showToast("跳转失败")
|
||||
})
|
||||
recordPlaySimulatorGames(gameEntity.id)
|
||||
}, {
|
||||
ToastUtils.showToast("跳转失败")
|
||||
})
|
||||
}
|
||||
|
||||
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) {
|
||||
@ -176,13 +238,13 @@ object SimulatorGameManager {
|
||||
requestMap["package"] = "-"
|
||||
val body = requestMap.createRequestBodyAny()
|
||||
RetrofitManager.getInstance().api
|
||||
.downloadSimulatorGames(HaloApp.getInstance().gid, body)
|
||||
.compose(singleToMain())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
refreshSimulatorGame(gameId, type)
|
||||
}
|
||||
})
|
||||
.downloadSimulatorGames(HaloApp.getInstance().gid, body)
|
||||
.compose(singleToMain())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
refreshSimulatorGame(gameId, type)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
@ -205,28 +267,28 @@ object SimulatorGameManager {
|
||||
if (gameArray.length() == 0) return
|
||||
|
||||
RetrofitManager.getInstance().api
|
||||
.putDownloadSimulatorGames(HaloApp.getInstance().gid, gameArray.toRequestBody())
|
||||
.compose(singleToMain())
|
||||
.subscribe(EmptyResponse())
|
||||
.putDownloadSimulatorGames(HaloApp.getInstance().gid, gameArray.toRequestBody())
|
||||
.compose(singleToMain())
|
||||
.subscribe(EmptyResponse())
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private fun refreshSimulatorGame(gameId: String, type: String) {
|
||||
val simulatorGameDao = AppDatabase.getInstance().simulatorGameDao()
|
||||
RetrofitManager.getInstance().api
|
||||
.getSimulatorGames(HaloApp.getInstance().gid, 1, getFilter(type))
|
||||
.compose(singleToMain())
|
||||
.subscribe(object : BiResponse<List<GameEntity>>() {
|
||||
override fun onSuccess(data: List<GameEntity>) {
|
||||
val simulatorGameRecordList = ArrayList<SimulatorGameRecordEntity>()
|
||||
data.forEach {
|
||||
val entity = it.convertSimulatorGameRecordEntity()
|
||||
entity.isRecentlyPlayed = it.id == gameId
|
||||
simulatorGameRecordList.add(entity)
|
||||
}
|
||||
simulatorGameDao.addSimulatorGameList(simulatorGameRecordList)
|
||||
.getSimulatorGames(HaloApp.getInstance().gid, 1, getFilter(type))
|
||||
.compose(singleToMain())
|
||||
.subscribe(object : BiResponse<List<GameEntity>>() {
|
||||
override fun onSuccess(data: List<GameEntity>) {
|
||||
val simulatorGameRecordList = ArrayList<SimulatorGameRecordEntity>()
|
||||
data.forEach {
|
||||
val entity = it.convertSimulatorGameRecordEntity()
|
||||
entity.isRecentlyPlayed = it.id == gameId
|
||||
simulatorGameRecordList.add(entity)
|
||||
}
|
||||
})
|
||||
simulatorGameDao.addSimulatorGameList(simulatorGameRecordList)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun getFilter(type: String): String {
|
||||
@ -244,9 +306,9 @@ object SimulatorGameManager {
|
||||
requestMap["package"] = packageName
|
||||
val body = requestMap.toRequestBody()
|
||||
RetrofitManager.getInstance().api
|
||||
.postPlayedGame(UserManager.getInstance().userId, body)
|
||||
.compose(singleToMain())
|
||||
.subscribe(EmptyResponse())
|
||||
.postPlayedGame(UserManager.getInstance().userId, body)
|
||||
.compose(singleToMain())
|
||||
.subscribe(EmptyResponse())
|
||||
}
|
||||
}
|
||||
|
||||
@ -261,10 +323,10 @@ object SimulatorGameManager {
|
||||
requestMap["package"] = "-"
|
||||
val body = requestMap.createRequestBodyAny()
|
||||
RetrofitManager.getInstance().api
|
||||
.playedSimulatorGames(HaloApp.getInstance().gid, body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(EmptyResponse())
|
||||
.playedSimulatorGames(HaloApp.getInstance().gid, body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(EmptyResponse())
|
||||
}
|
||||
|
||||
/**
|
||||
@ -273,14 +335,14 @@ object SimulatorGameManager {
|
||||
@SuppressLint("CheckResult")
|
||||
fun deleteSimulatorGame(gameId: String, callback: () -> Unit) {
|
||||
RetrofitManager.getInstance().api
|
||||
.deleteSimulatorGame(HaloApp.getInstance().gid, gameId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
callback.invoke()
|
||||
}
|
||||
})
|
||||
.deleteSimulatorGame(HaloApp.getInstance().gid, gameId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
callback.invoke()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
@ -292,14 +354,14 @@ object SimulatorGameManager {
|
||||
val requestMap = hashMapOf<String, Any>()
|
||||
requestMap["game_ids"] = gameIds
|
||||
RetrofitManager.getInstance().api
|
||||
.deleteSimulatorGames(HaloApp.getInstance().gid, requestMap.toRequestBody())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
callback.invoke()
|
||||
}
|
||||
})
|
||||
.deleteSimulatorGames(HaloApp.getInstance().gid, requestMap.toRequestBody())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
callback.invoke()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
@ -309,27 +371,29 @@ object SimulatorGameManager {
|
||||
@SuppressLint("CheckResult")
|
||||
fun deleteAllSimulatorGame() {
|
||||
RetrofitManager.getInstance().api
|
||||
.deleteAllSimulatorGame(HaloApp.getInstance().gid)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(EmptyResponse())
|
||||
.deleteAllSimulatorGame(HaloApp.getInstance().gid)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(EmptyResponse())
|
||||
}
|
||||
|
||||
private fun updateSimulatorConfigFile(gameId: String) {
|
||||
RetrofitManager.getInstance()
|
||||
.api
|
||||
.getGameDigest(gameId)
|
||||
.map(ApkActiveUtils.filterMapper)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : Response<GameEntity>() {
|
||||
override fun onResponse(game: GameEntity?) {
|
||||
game?.let {
|
||||
if (!TextUtils.isEmpty(game.simulatorGameConfig)) {
|
||||
val configFilePath = getPathByType(game.simulatorType + "/cheat/" + game.getApk().firstOrNull()?.packageName + ".ini")
|
||||
FileUtils.downloadAndUpdateFile(game.simulatorGameConfig, configFilePath)
|
||||
}
|
||||
.api
|
||||
.getGameDigest(gameId)
|
||||
.map(ApkActiveUtils.filterMapper)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : Response<GameEntity>() {
|
||||
override fun onResponse(game: GameEntity?) {
|
||||
game?.let {
|
||||
if (!TextUtils.isEmpty(game.simulatorGameConfig)) {
|
||||
val configFilePath = getPathByType(
|
||||
game.simulatorType + "/cheat/" + game.getApk().firstOrNull()?.packageName + ".ini"
|
||||
)
|
||||
FileUtils.downloadAndUpdateFile(game.simulatorGameConfig, configFilePath)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -22,16 +22,16 @@ object ActivationHelper {
|
||||
fun sendActivationInfo() {
|
||||
if (!mHasSentActivatedInfo) {
|
||||
RetrofitManager.getInstance()
|
||||
.api.postActivationInfo()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
super.onResponse(response)
|
||||
.api.postActivationInfo()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
super.onResponse(response)
|
||||
|
||||
mHasSentActivatedInfo = true
|
||||
SPUtils.setBoolean(HAS_SENT_ACTIVATED_INFO, true)
|
||||
}
|
||||
})
|
||||
mHasSentActivatedInfo = true
|
||||
SPUtils.setBoolean(HAS_SENT_ACTIVATED_INFO, true)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
78
app/src/main/java/com/gh/common/util/ActivityCountHelper.kt
Normal file
78
app/src/main/java/com/gh/common/util/ActivityCountHelper.kt
Normal file
@ -0,0 +1,78 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.net.Uri
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.utils.EnvHelper
|
||||
import com.gh.gamecenter.common.utils.tryWithDefaultCatch
|
||||
import com.gh.gamecenter.core.GHThreadFactory
|
||||
import java.util.concurrent.ExecutorService
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
/**
|
||||
* 活动相关数据统计辅助类
|
||||
*/
|
||||
object ActivityCountHelper {
|
||||
|
||||
private val ACTIVITY_URL_COMMON_PREF =
|
||||
if (EnvHelper.isDevEnv) Constants.ACTIVITY_DETAIL_ADDRESS_DEV else Constants.ACTIVITY_DETAIL_ADDRESS
|
||||
private var mStayTimeCount = 0
|
||||
private var mIsStayTimeCountEnabled = false
|
||||
private var mStayTimeArray = arrayOf(5, 10, 20, 40, 80, 160)
|
||||
private const val MAX_STAY_TIME = 320
|
||||
private val mThreadService: ExecutorService by lazy {
|
||||
Executors.newSingleThreadExecutor(GHThreadFactory("STAY_TIME_THREAD"))
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun postActivityPageEnter(url: String?, entrance: String) {
|
||||
if (url?.contains(ACTIVITY_URL_COMMON_PREF) == true) {
|
||||
val uri = Uri.parse(url)
|
||||
val activityId = uri.getQueryParameter("id") ?: return
|
||||
NewFlatLogUtils.logActivityPageEnter(transformEntrance(entrance), activityId)
|
||||
}
|
||||
}
|
||||
|
||||
private fun transformEntrance(originalEntrance: String): String {
|
||||
return when {
|
||||
originalEntrance.contains("(启动广告)") -> "开屏页"
|
||||
originalEntrance.contains(EntranceConsts.ENTRANCE_WELCOME) -> "首页弹窗"
|
||||
originalEntrance.contains("首页tab") -> "首页二级导航"
|
||||
originalEntrance.contains("论坛-活动") -> "活动tab"
|
||||
originalEntrance.contains("新首页-轮播图") -> "首页banner"
|
||||
originalEntrance.contains("资讯") -> "资讯广场"
|
||||
else -> originalEntrance
|
||||
}
|
||||
}
|
||||
|
||||
fun startCountStayTime(url: String) {
|
||||
if (url.contains(ACTIVITY_URL_COMMON_PREF)) {
|
||||
val uri = Uri.parse(url)
|
||||
val activityId = uri.getQueryParameter("id") ?: return
|
||||
mIsStayTimeCountEnabled = true
|
||||
mThreadService.execute {
|
||||
while (mIsStayTimeCountEnabled) {
|
||||
tryWithDefaultCatch {
|
||||
mStayTimeCount++
|
||||
when {
|
||||
mStayTimeCount % MAX_STAY_TIME == 0 -> NewFlatLogUtils.logActivityPageView(
|
||||
MAX_STAY_TIME,
|
||||
activityId
|
||||
)
|
||||
mStayTimeArray.contains(mStayTimeCount) -> NewFlatLogUtils.logActivityPageView(
|
||||
mStayTimeCount,
|
||||
activityId
|
||||
)
|
||||
}
|
||||
}
|
||||
Thread.sleep(1000)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun endCountStayTime() {
|
||||
mIsStayTimeCountEnabled = false
|
||||
mStayTimeCount = 0
|
||||
}
|
||||
}
|
||||
@ -31,14 +31,14 @@ object AdHelper {
|
||||
}
|
||||
|
||||
RetrofitManager.getInstance()
|
||||
.api
|
||||
.getSplashAd(HaloApp.getInstance().channel)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : BiResponse<StartupAdEntity>() {
|
||||
override fun onSuccess(data: StartupAdEntity) {
|
||||
startupAd.postValue(data)
|
||||
}
|
||||
})
|
||||
.api
|
||||
.getSplashAd(HaloApp.getInstance().channel)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : BiResponse<StartupAdEntity>() {
|
||||
override fun onSuccess(data: StartupAdEntity) {
|
||||
startupAd.postValue(data)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun getAd(location: String): SettingsEntity.AD? {
|
||||
@ -54,7 +54,7 @@ object AdHelper {
|
||||
val adList = Config.getSettings()?.adList ?: return null
|
||||
|
||||
var result: SettingsEntity.AD? = null
|
||||
run outside@ {
|
||||
run outside@{
|
||||
for (ad in adList) {
|
||||
if (ad.location == location) {
|
||||
result = ad
|
||||
|
||||
@ -94,7 +94,7 @@ object BbsReportHelper {
|
||||
binding.otherReasonEt.doOnTextChanged { text, start, before, count ->
|
||||
val tvCount: Int = text.toString().length
|
||||
if (tvCount >= 500) {
|
||||
binding.tvCount.setTextColor(R.color.theme_red.toColor())
|
||||
binding.tvCount.setTextColor(R.color.theme_red.toColor(binding.tvCount.context))
|
||||
}
|
||||
binding.tvCount.text = "$tvCount/500"
|
||||
}
|
||||
@ -120,7 +120,10 @@ object BbsReportHelper {
|
||||
override fun onFailure(exception: Exception) {
|
||||
super.onFailure(exception)
|
||||
if (exception is HttpException) {
|
||||
ErrorHelper.handleError(HaloApp.getInstance().application, exception.response().errorBody()?.string())
|
||||
ErrorHelper.handleError(
|
||||
HaloApp.getInstance().application,
|
||||
exception.response().errorBody()?.string()
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@ -114,18 +114,18 @@ object BbsStayTimeHelper {
|
||||
@SuppressLint("CheckResult")
|
||||
private fun postExploreFinish() {
|
||||
RetrofitManager.getInstance()
|
||||
.api
|
||||
.postExplorerFinish()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
if (!isPublishEnv()) {
|
||||
ToastUtils.toast("完成了论坛停留任务(仅测试环境有这个 toast 不要慌)")
|
||||
}
|
||||
disableStayTimeCount()
|
||||
.api
|
||||
.postExplorerFinish()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
if (!isPublishEnv()) {
|
||||
ToastUtils.toast("完成了论坛停留任务(仅测试环境有这个 toast 不要慌)")
|
||||
}
|
||||
})
|
||||
disableStayTimeCount()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.utils.singleToMain
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.google.gson.JsonObject
|
||||
|
||||
object CertificationSwitchHelper {
|
||||
|
||||
@JvmStatic
|
||||
@SuppressLint("CheckResult")
|
||||
fun getCertificationSwitch() {
|
||||
RetrofitManager.getInstance().api
|
||||
.certificationSwitch
|
||||
.compose(singleToMain())
|
||||
.subscribe(object : BiResponse<JsonObject>() {
|
||||
override fun onSuccess(data: JsonObject) {
|
||||
SPUtils.setBoolean(
|
||||
Constants.SP_CERTIFICATION_SWITCH,
|
||||
data["authentication_display_switch"].asString == "on"
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -29,14 +29,7 @@ public class CheckLoginUtils {
|
||||
LogUtils.login("activity", null, entrance);
|
||||
|
||||
if (SPUtils.getBoolean(Constants.SP_HAS_GET_PHONE_INFO) || NetworkUtils.isOpenMobileData(context)) {
|
||||
// 需要确保传入的 context 不为 application
|
||||
if (!(context instanceof Activity)) {
|
||||
context = CurrentActivityHolder.getCurrentActivity();
|
||||
}
|
||||
|
||||
if (context != null) {
|
||||
QuickLoginHelper.startLogin(context, entrance);
|
||||
}
|
||||
startQuickLogin(context, entrance);
|
||||
} else {
|
||||
// 有可能App未启动
|
||||
Bundle bundle = new Bundle();
|
||||
@ -51,6 +44,17 @@ public class CheckLoginUtils {
|
||||
}
|
||||
}
|
||||
|
||||
private static void startQuickLogin(Context context, String entrance) {
|
||||
// 需要确保传入的 context 不为 application
|
||||
if (!(context instanceof Activity)) {
|
||||
context = CurrentActivityHolder.getCurrentActivity();
|
||||
}
|
||||
|
||||
if (context != null) {
|
||||
QuickLoginHelper.startLogin(context, entrance);
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkLogin(final Context context, Bundle nextToBundle, boolean isTriggerNextStep, String entrance, OnLoginListener listener) {
|
||||
if (!isLogin()) {
|
||||
if (listener != null) Utils.toast(context, "需要登录");
|
||||
|
||||
@ -25,64 +25,70 @@ object CollectionUtils {
|
||||
fun postCollection(context: Context, content: String, type: CollectionType, listener: OnCollectionListener) {
|
||||
|
||||
val postCollection = when (type) {
|
||||
CollectionType.article -> RetrofitManager.getInstance().getApi().postCollectionArticle(UserManager.getInstance().userId, content)
|
||||
CollectionType.toolkit -> RetrofitManager.getInstance().getApi().postCollectionTools(UserManager.getInstance().userId, content)
|
||||
CollectionType.answer -> RetrofitManager.getInstance().getApi().postCollectionAnswer(UserManager.getInstance().userId, content)
|
||||
CollectionType.article -> RetrofitManager.getInstance().getApi()
|
||||
.postCollectionArticle(UserManager.getInstance().userId, content)
|
||||
CollectionType.toolkit -> RetrofitManager.getInstance().getApi()
|
||||
.postCollectionTools(UserManager.getInstance().userId, content)
|
||||
CollectionType.answer -> RetrofitManager.getInstance().getApi()
|
||||
.postCollectionAnswer(UserManager.getInstance().userId, content)
|
||||
else -> return
|
||||
}
|
||||
postCollection
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
super.onResponse(response)
|
||||
listener.onSuccess()
|
||||
EventBus.getDefault().post(EBCollectionChanged(content, true, type))
|
||||
}
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
super.onResponse(response)
|
||||
listener.onSuccess()
|
||||
EventBus.getDefault().post(EBCollectionChanged(content, true, type))
|
||||
}
|
||||
|
||||
override fun onFailure(e: HttpException?) {
|
||||
super.onFailure(e)
|
||||
if (e != null) {
|
||||
try {
|
||||
val string = e.response()?.errorBody()?.string()
|
||||
val errorBody = JSONObject(string)
|
||||
if (errorBody.getInt("code") == 403009) {
|
||||
listener.onSuccess()
|
||||
return
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
override fun onFailure(e: HttpException?) {
|
||||
super.onFailure(e)
|
||||
if (e != null) {
|
||||
try {
|
||||
val string = e.response()?.errorBody()?.string()
|
||||
val errorBody = JSONObject(string)
|
||||
if (errorBody.getInt("code") == 403009) {
|
||||
listener.onSuccess()
|
||||
return
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
listener.onError()
|
||||
}
|
||||
})
|
||||
listener.onError()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun deleteCollection(context: Context, id: String, type: CollectionType, listener: OnCollectionListener) {
|
||||
|
||||
val postCollection: Observable<ResponseBody>
|
||||
when (type) {
|
||||
CollectionType.article -> postCollection = RetrofitManager.getInstance().getApi().deletaCollectionArticle(UserManager.getInstance().userId, id)
|
||||
CollectionType.toolkit -> postCollection = RetrofitManager.getInstance().getApi().deleteCollectionTools(UserManager.getInstance().userId, id)
|
||||
CollectionType.answer -> postCollection = RetrofitManager.getInstance().getApi().deleteCollectionAnswer(UserManager.getInstance().userId, id)
|
||||
CollectionType.article -> postCollection =
|
||||
RetrofitManager.getInstance().getApi().deletaCollectionArticle(UserManager.getInstance().userId, id)
|
||||
CollectionType.toolkit -> postCollection =
|
||||
RetrofitManager.getInstance().getApi().deleteCollectionTools(UserManager.getInstance().userId, id)
|
||||
CollectionType.answer -> postCollection =
|
||||
RetrofitManager.getInstance().getApi().deleteCollectionAnswer(UserManager.getInstance().userId, id)
|
||||
else -> return
|
||||
}
|
||||
postCollection
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
super.onResponse(response)
|
||||
listener.onSuccess()
|
||||
EventBus.getDefault().post(EBCollectionChanged(id, false, type))
|
||||
}
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
super.onResponse(response)
|
||||
listener.onSuccess()
|
||||
EventBus.getDefault().post(EBCollectionChanged(id, false, type))
|
||||
}
|
||||
|
||||
override fun onFailure(e: HttpException?) {
|
||||
super.onFailure(e)
|
||||
listener.onError()
|
||||
}
|
||||
})
|
||||
override fun onFailure(e: HttpException?) {
|
||||
super.onFailure(e)
|
||||
listener.onError()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -162,7 +162,8 @@ object CommentHelper {
|
||||
}
|
||||
if (questionId != null &&
|
||||
commentEntity.me?.isModerator == true &&
|
||||
(commentEntity.me?.moderatorPermissions?.highlightAnswer ?: Permissions.GUEST) > Permissions.GUEST && !commentEntity.choiceness
|
||||
(commentEntity.me?.moderatorPermissions?.highlightAnswer
|
||||
?: Permissions.GUEST) > Permissions.GUEST && !commentEntity.choiceness
|
||||
) {
|
||||
dialogOptions.add("加精选")
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ public class CommentUtils {
|
||||
|
||||
LinearLayout container = new LinearLayout(context);
|
||||
container.setOrientation(LinearLayout.VERTICAL);
|
||||
container.setBackgroundColor(Color.WHITE);
|
||||
container.setBackgroundColor(ContextCompat.getColor(context, R.color.background_white));
|
||||
container.setPadding(0, DisplayUtils.dip2px(context, 12), 0, DisplayUtils.dip2px(context, 12));
|
||||
|
||||
List<String> dialogType = new ArrayList<>();
|
||||
@ -168,7 +168,7 @@ public class CommentUtils {
|
||||
LinearLayout container = new LinearLayout(context);
|
||||
container.setOrientation(LinearLayout.VERTICAL);
|
||||
container.setPadding(0, DisplayUtils.dip2px(context, 12), 0, DisplayUtils.dip2px(context, 12));
|
||||
container.setBackgroundColor(Color.WHITE);
|
||||
container.setBackgroundColor(ContextCompat.getColor(context, R.color.background_white));
|
||||
|
||||
for (final String s : arrReportType) {
|
||||
TextView reportTypeTv = new TextView(context);
|
||||
|
||||
@ -24,127 +24,120 @@ object ConcernUtils {
|
||||
/**
|
||||
* autoConcern:是否自动关注'关联关注'
|
||||
*/
|
||||
fun postConcernGameId(context: Context, gameId: String, listener: onConcernListener?, autoConcern: Boolean = false) {
|
||||
fun postConcernGameId(
|
||||
context: Context,
|
||||
gameId: String,
|
||||
listener: onConcernListener?,
|
||||
autoConcern: Boolean = false
|
||||
) {
|
||||
val mode = if (autoConcern) "auto" else "manual"
|
||||
|
||||
val userId = UserManager.getInstance().userId
|
||||
if (TextUtils.isEmpty(userId)) return
|
||||
|
||||
RetrofitManager.getInstance().api
|
||||
.postConcern(UserManager.getInstance().userId, gameId, mode)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
super.onResponse(response)
|
||||
listener?.onSuccess()
|
||||
EventBus.getDefault().post(EBConcernChanged(gameId, true))
|
||||
dispatchFollowChangeEventToFlutter(gameId, true)
|
||||
}
|
||||
.postConcern(UserManager.getInstance().userId, gameId, mode)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
super.onResponse(response)
|
||||
listener?.onSuccess()
|
||||
EventBus.getDefault().post(EBConcernChanged(gameId, true))
|
||||
}
|
||||
|
||||
override fun onFailure(e: HttpException?) {
|
||||
super.onFailure(e)
|
||||
listener?.onError()
|
||||
}
|
||||
})
|
||||
override fun onFailure(e: HttpException?) {
|
||||
super.onFailure(e)
|
||||
listener?.onError()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun deleteConcernData(context: Context, gameId: String, listener: onConcernListener?) {
|
||||
RetrofitManager.getInstance().api
|
||||
.deleteConcern(UserManager.getInstance().userId, gameId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
super.onResponse(response)
|
||||
listener?.onSuccess()
|
||||
EventBus.getDefault().post(EBConcernChanged(gameId, false))
|
||||
dispatchFollowChangeEventToFlutter(gameId, false)
|
||||
}
|
||||
.deleteConcern(UserManager.getInstance().userId, gameId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
super.onResponse(response)
|
||||
listener?.onSuccess()
|
||||
EventBus.getDefault().post(EBConcernChanged(gameId, false))
|
||||
}
|
||||
|
||||
override fun onFailure(e: HttpException?) {
|
||||
super.onFailure(e)
|
||||
listener?.onError()
|
||||
}
|
||||
})
|
||||
override fun onFailure(e: HttpException?) {
|
||||
super.onFailure(e)
|
||||
listener?.onError()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun updateConcernData(context: Context, data: JSONArray) {
|
||||
val body = RequestBody.create(MediaType.parse("application/json"),
|
||||
data.toString())
|
||||
val body = RequestBody.create(
|
||||
MediaType.parse("application/json"),
|
||||
data.toString()
|
||||
)
|
||||
RetrofitManager.getInstance().api
|
||||
.putConcern(UserManager.getInstance().userId, body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
EventBus.getDefault().post(EBConcernChanged())
|
||||
}
|
||||
})
|
||||
.putConcern(UserManager.getInstance().userId, body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
EventBus.getDefault().post(EBConcernChanged())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun deleteConcernQuestions(context: Context, questionsId: String, listener: onConcernListener?) {
|
||||
RetrofitManager.getInstance().api
|
||||
.deleteConcernQuestions(UserManager.getInstance().userId, questionsId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
super.onResponse(response)
|
||||
listener?.onSuccess()
|
||||
}
|
||||
.deleteConcernQuestions(UserManager.getInstance().userId, questionsId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
super.onResponse(response)
|
||||
listener?.onSuccess()
|
||||
}
|
||||
|
||||
override fun onFailure(e: HttpException?) {
|
||||
super.onFailure(e)
|
||||
listener?.onError()
|
||||
var errorString: String? = null
|
||||
try {
|
||||
errorString = e?.response()?.errorBody()?.string()
|
||||
} catch (e1: Exception) {
|
||||
e1.printStackTrace()
|
||||
}
|
||||
ErrorHelper.handleError(context, errorString, false)
|
||||
override fun onFailure(e: HttpException?) {
|
||||
super.onFailure(e)
|
||||
listener?.onError()
|
||||
var errorString: String? = null
|
||||
try {
|
||||
errorString = e?.response()?.errorBody()?.string()
|
||||
} catch (e1: Exception) {
|
||||
e1.printStackTrace()
|
||||
}
|
||||
})
|
||||
ErrorHelper.handleError(context, errorString, false)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun postConcernQuestions(context: Context, questionsId: String, listener: onConcernListener?) {
|
||||
RetrofitManager.getInstance().api
|
||||
.postConcernQuestions(UserManager.getInstance().userId, questionsId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
super.onResponse(response)
|
||||
listener?.onSuccess()
|
||||
.postConcernQuestions(UserManager.getInstance().userId, questionsId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
super.onResponse(response)
|
||||
listener?.onSuccess()
|
||||
}
|
||||
|
||||
override fun onFailure(e: HttpException?) {
|
||||
super.onFailure(e)
|
||||
listener?.onError()
|
||||
var errorString: String? = null
|
||||
try {
|
||||
errorString = e?.response()?.errorBody()?.string()
|
||||
} catch (e1: Exception) {
|
||||
e1.printStackTrace()
|
||||
}
|
||||
|
||||
override fun onFailure(e: HttpException?) {
|
||||
super.onFailure(e)
|
||||
listener?.onError()
|
||||
var errorString: String? = null
|
||||
try {
|
||||
errorString = e?.response()?.errorBody()?.string()
|
||||
} catch (e1: Exception) {
|
||||
e1.printStackTrace()
|
||||
}
|
||||
ErrorHelper.handleError(context, errorString, false)
|
||||
}
|
||||
})
|
||||
ErrorHelper.handleError(context, errorString, false)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 通知Flutter游戏关注状态发生变化
|
||||
* 请不要随意修改方法名
|
||||
* @param gameId 游戏ID
|
||||
* @param follow 关注状态
|
||||
*/
|
||||
@JvmStatic
|
||||
fun dispatchFollowChangeEventToFlutter(gameId: String, follow: Boolean) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
interface onConcernListener {
|
||||
fun onSuccess()
|
||||
fun onError()
|
||||
|
||||
@ -12,7 +12,6 @@ import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.gh.base.GlobalActivityManager;
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.common.base.activity.BaseActivity;
|
||||
@ -23,6 +22,7 @@ import com.gh.gamecenter.core.AppExecutor;
|
||||
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.login.entity.IdCardEntity;
|
||||
import com.gh.gamecenter.login.entity.UserInfoEntity;
|
||||
import com.gh.gamecenter.provider.GhContentProvider;
|
||||
@ -33,9 +33,6 @@ import com.halo.assistant.HaloApp;
|
||||
import com.lightgame.config.CommonDebug;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import io.sentry.Sentry;
|
||||
import io.sentry.android.core.SentryAndroid;
|
||||
@ -47,6 +44,10 @@ import kotlin.Pair;
|
||||
*/
|
||||
public class DataUtils {
|
||||
|
||||
private DataUtils() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化各种统计工具,仅在release build(非debug)模式启用统计
|
||||
*/
|
||||
@ -54,16 +55,16 @@ public class DataUtils {
|
||||
if (CommonDebug.IS_DEBUG) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// 初始化 Sentry 约占用 90ms,这里切换到子线程初始化
|
||||
AppExecutor.getIoExecutor().execute(() -> initSentry(context, channel));
|
||||
}
|
||||
|
||||
|
||||
private static void initSentry(Context context, String channel) {
|
||||
SentryAndroid.init(context, options -> {
|
||||
// Sentry 疯狂报 ANR (很大一部分还是莫名奇妙的 ANR)严重影响到其它闪退日志的收集
|
||||
// 这里将它局限到只有官网渠道的包才统计 ANR
|
||||
if ("GH_206".equals(channel) || "GH_BETA".equals(channel)) {
|
||||
if ("GH_206".equals(channel) || "GH_BETA".equals(channel) || com.gh.gamecenter.common.BuildConfig.BUILD_TIME != 0) {
|
||||
options.setAnrEnabled(true);
|
||||
options.setAnrTimeoutIntervalMillis(6000);
|
||||
} else {
|
||||
@ -71,11 +72,11 @@ public class DataUtils {
|
||||
}
|
||||
|
||||
options.setDebug(BuildConfig.DEBUG);
|
||||
options.setEnableSessionTracking(true);
|
||||
options.setEnableAutoSessionTracking(true);
|
||||
options.setEnvironment(BuildConfig.FLAVOR);
|
||||
options.setEnableSystemEventBreadcrumbs(false);
|
||||
options.setDsn("https://6b1caf0d17c1408e8680f3f73ff80bd0@sentry.shanqu.cc/22");
|
||||
|
||||
|
||||
options.setBeforeSend((event, hint) -> {
|
||||
if (BuildConfig.DEBUG) {
|
||||
return null;
|
||||
@ -95,7 +96,7 @@ public class DataUtils {
|
||||
return breadcrumb;
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
Sentry.configureScope(scope -> {
|
||||
if (com.gh.gamecenter.common.BuildConfig.BUILD_TIME != 0L) {
|
||||
scope.setTag("alias", "内测版" + BuildConfig.VERSION_NAME);
|
||||
@ -163,7 +164,14 @@ public class DataUtils {
|
||||
}
|
||||
|
||||
// new GhContentProvider().localInsert( HaloApp.getInstance().getApplication(),values);
|
||||
HaloApp.getInstance().getContentResolver().insert(Uri.parse("content://com.gh.gamecenter.provider/certification"), values);
|
||||
try {
|
||||
// Unknown URL content://com.gh.gamecenter.provider/certification
|
||||
// TODO 将 com.gh.gamecenter 改成 BuildConfig.ApplicationID
|
||||
HaloApp.getInstance().getContentResolver().insert(Uri.parse("content://com.gh.gamecenter.provider/certification"), values);
|
||||
} catch (Exception exception) {
|
||||
SentryHelper.INSTANCE.onEvent("CERTIFICATION_INSERT_ERROR", "exception_digest", exception.getLocalizedMessage());
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -248,7 +248,8 @@ public class DetailDownloadUtils {
|
||||
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 {
|
||||
|
||||
@ -24,18 +24,18 @@ object DeviceTokenUtils {
|
||||
fun syncServerTime(context: Context) {
|
||||
val sp = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
RetrofitManager.getInstance().api.time
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<TimeEntity>() {
|
||||
override fun onResponse(response: TimeEntity?) {
|
||||
val editor = sp.edit()
|
||||
response?.time?.let {
|
||||
editor.putLong("server_time", it)
|
||||
editor.putLong("client_time", System.currentTimeMillis() / 1000)
|
||||
editor.apply()
|
||||
}
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<TimeEntity>() {
|
||||
override fun onResponse(response: TimeEntity?) {
|
||||
val editor = sp.edit()
|
||||
response?.time?.let {
|
||||
editor.putLong("server_time", it)
|
||||
editor.putLong("client_time", System.currentTimeMillis() / 1000)
|
||||
editor.apply()
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
|
||||
@ -6,13 +6,11 @@ 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;
|
||||
@ -51,6 +49,7 @@ import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.filter.RegionSetting;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.ShellActivity;
|
||||
import com.gh.gamecenter.SuggestionActivity;
|
||||
import com.gh.gamecenter.adapter.ReportReasonAdapter;
|
||||
import com.gh.gamecenter.adapter.viewholder.PrivacyPolicyItemViewHolder;
|
||||
@ -80,6 +79,7 @@ import com.gh.gamecenter.databinding.DialogBindPhoneBinding;
|
||||
import com.gh.gamecenter.databinding.DialogOverseaConfirmationBinding;
|
||||
import com.gh.gamecenter.databinding.DialogPackageParseErrorBinding;
|
||||
import com.gh.gamecenter.databinding.DialogReceiveLibaoSuccessBinding;
|
||||
import com.gh.gamecenter.databinding.DialogRelievePhoneBinding;
|
||||
import com.gh.gamecenter.databinding.DialogReportReasonBinding;
|
||||
import com.gh.gamecenter.databinding.DialogWechatReserveSuccessBinding;
|
||||
import com.gh.gamecenter.databinding.ImprintContentItemBinding;
|
||||
@ -93,10 +93,9 @@ 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.retrofit.RetrofitManager;
|
||||
import com.gh.gamecenter.setting.GameDownloadSettingFragment;
|
||||
import com.gh.gamecenter.setting.compose.activity.ComposeBindPhoneActivity;
|
||||
import com.gh.gamecenter.setting.compose.activity.ComposeGameDownloadSettingActivity;
|
||||
import com.gh.gamecenter.suggest.SuggestType;
|
||||
import com.halo.assistant.HaloApp;
|
||||
import com.lightgame.adapter.BaseRecyclerAdapter;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
import com.lightgame.utils.AppManager;
|
||||
@ -217,7 +216,7 @@ public class DialogUtils {
|
||||
} else if (NetworkUtils.isWifiConnected(context)
|
||||
|| filter4GorSize(context, size)) {
|
||||
callBack.onResponse(false);
|
||||
} else if (!SPUtils.getBoolean(GameDownloadSettingFragment.getTrafficDownloadHintKey(), true)) {
|
||||
} else if (!SPUtils.getBoolean(ComposeGameDownloadSettingActivity.getTrafficDownloadHintKey(), true)) {
|
||||
AppExecutor.getUiExecutor().executeWithDelay(() -> Utils.toast(context, "当前使用移动网络下载,请注意流量消耗"), 500);
|
||||
callBack.onResponse(false);
|
||||
} else {
|
||||
@ -289,7 +288,7 @@ public class DialogUtils {
|
||||
// MtaHelper.onEvent("移动网络下载", NetworkUtils.getMobileNetworkType(finalContext), "连上WiFi后自动下载");
|
||||
});
|
||||
allowAlways.setOnClickListener(v -> {
|
||||
SPUtils.setBoolean(GameDownloadSettingFragment.getTrafficDownloadHintKey(), false);
|
||||
SPUtils.setBoolean(ComposeGameDownloadSettingActivity.getTrafficDownloadHintKey(), false);
|
||||
AppExecutor.getUiExecutor().executeWithDelay(() -> {
|
||||
// 显示了弹窗以后,即便下面这个 toast 放在 listener.onConfirm 后调用也是显示 listener.onConfirm 里的 toast
|
||||
// 喷了,延时包治疑难杂症
|
||||
@ -1324,6 +1323,7 @@ public class DialogUtils {
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
|
||||
public static void showGameH5DownloadDialog(Context context, GameEntity gameEntity, RegionSetting.GameH5Download gameH5Download) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
@ -1867,31 +1867,13 @@ public class DialogUtils {
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public static void showEnergyDialog(Context context, String userName, long energy) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.DialogWindowTransparent);
|
||||
|
||||
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_energy, null);
|
||||
((TextView) contentView.findViewById(R.id.userName)).setText("\"" + userName + "\"");
|
||||
((TextView) contentView.findViewById(R.id.energy)).setText(energy + "");
|
||||
|
||||
contentView.findViewById(R.id.dialog_positive).setOnClickListener(v -> {
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(contentView);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public static void showSimulatorParseErrorDialog(Context context, String gameId, String gameName, ConfirmListener confirmListener) {
|
||||
context = checkDialogContext(context);
|
||||
final Dialog dialog = new Dialog(context, R.style.GhAlertDialog);
|
||||
|
||||
DialogPackageParseErrorBinding binding = DialogPackageParseErrorBinding.inflate(LayoutInflater.from(context), null, false);
|
||||
Context finalContext = context;
|
||||
SpannableStringBuilder builder = new SpanBuilder("您也可以点击提交反馈跟我们联系").click(6, 10, R.color.theme_font, true, new Function0<Unit>() {
|
||||
SpannableStringBuilder builder = new SpanBuilder("您也可以点击提交反馈跟我们联系").click(context, 6, 10, R.color.theme_font, true, new Function0<Unit>() {
|
||||
@Override
|
||||
public Unit invoke() {
|
||||
SimpleGameEntity entity = new SimpleGameEntity(gameId, gameName, "");
|
||||
@ -1923,13 +1905,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);
|
||||
@ -1975,19 +1965,6 @@ public class DialogUtils {
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public static void showSignRuleDialog(Context context) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.DialogWindowTransparent);
|
||||
|
||||
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_sign_rule, null);
|
||||
contentView.findViewById(R.id.dialog_ok).setOnClickListener(v -> dialog.dismiss());
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(contentView);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public static Dialog showBindPhoneDialog(Context context, ConfirmListener listener) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
@ -2088,6 +2065,32 @@ public class DialogUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void showRelievePhoneDialog(Context context) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.DialogWindowTransparent);
|
||||
DialogRelievePhoneBinding binding = DialogRelievePhoneBinding.inflate(LayoutInflater.from(context));
|
||||
|
||||
Context finalContext = context;
|
||||
binding.realNameBtn.setOnClickListener(v -> {
|
||||
dialog.dismiss();
|
||||
Intent intent = ShellActivity.getIntent(finalContext, ShellActivity.Type.REAL_NAME_INFO);
|
||||
finalContext.startActivity(intent);
|
||||
});
|
||||
|
||||
binding.bindPhoneBtn.setOnClickListener(v -> {
|
||||
dialog.dismiss();
|
||||
Intent intent = ComposeBindPhoneActivity.getNormalIntent(finalContext, false);
|
||||
finalContext.startActivity(intent);
|
||||
});
|
||||
|
||||
binding.cancelBtn.setOnClickListener(v -> dialog.dismiss());
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(binding.getRoot());
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context may be is application context
|
||||
* @return activity context
|
||||
|
||||
@ -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.compose.activity.ComposeBindPhoneActivity
|
||||
import com.gh.gamecenter.setting.compose.activity.ComposeSettingActivity
|
||||
import com.gh.gamecenter.subject.SubjectActivity
|
||||
import com.gh.gamecenter.suggest.SuggestType
|
||||
import com.gh.gamecenter.tag.TagsActivity
|
||||
@ -95,7 +97,14 @@ object DirectUtils {
|
||||
* 跳转到特定页面,根据 [type] 决定跳转页面,[path] 为跳转前的页面名称
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToSpecificPage(context: Context, type: String, link: String, text: String? = "", entrance: String? = null, path: String? = null) {
|
||||
fun directToSpecificPage(
|
||||
context: Context,
|
||||
type: String,
|
||||
link: String,
|
||||
text: String? = "",
|
||||
entrance: String? = null,
|
||||
path: String? = null
|
||||
) {
|
||||
when (type) {
|
||||
HOST_ARTICLE -> directToArticle(context, id = link, entrance = entrance)
|
||||
|
||||
@ -111,9 +120,19 @@ object DirectUtils {
|
||||
|
||||
HOST_WEB -> directToWebView(context, url = link, entrance = entrance)
|
||||
|
||||
HOST_DOWNLOAD -> directToDownloadManagerAndStartDownload(context, gameId = link, packageName = text, entrance = entrance)
|
||||
HOST_DOWNLOAD -> directToDownloadManagerAndStartDownload(
|
||||
context,
|
||||
gameId = link,
|
||||
packageName = text,
|
||||
entrance = entrance
|
||||
)
|
||||
|
||||
HOST_UPDATE -> directToDownloadManagerAndStartUpdate(context, gameId = link, packageName = text, entrance = entrance)
|
||||
HOST_UPDATE -> directToDownloadManagerAndStartUpdate(
|
||||
context,
|
||||
gameId = link,
|
||||
packageName = text,
|
||||
entrance = entrance
|
||||
)
|
||||
|
||||
HOST_LIBAO -> directToGiftDetail(context, giftId = link, entrance = entrance)
|
||||
|
||||
@ -126,7 +145,13 @@ object DirectUtils {
|
||||
directToLinkPage(context, linkEntity, entrance, path, null)
|
||||
}
|
||||
|
||||
fun directToLinkPage(context: Context, linkEntity: LinkEntity, entrance: String, path: String, exposureEvent: ExposureEvent? = null) {
|
||||
fun directToLinkPage(
|
||||
context: Context,
|
||||
linkEntity: LinkEntity,
|
||||
entrance: String,
|
||||
path: String,
|
||||
exposureEvent: ExposureEvent? = null
|
||||
) {
|
||||
directToLinkPage(context, linkEntity, entrance, path, exposureEvent, null)
|
||||
}
|
||||
|
||||
@ -158,7 +183,8 @@ object DirectUtils {
|
||||
"common_collection",
|
||||
"game_list",
|
||||
"game_list_detail",
|
||||
"bbs_video"
|
||||
"bbs_video",
|
||||
"explore_column"
|
||||
)
|
||||
|
||||
fun directToLinkPage(
|
||||
@ -209,9 +235,21 @@ object DirectUtils {
|
||||
directToCommunity(context, CommunityEntity(linkEntity.link!!, linkEntity.text!!))
|
||||
}
|
||||
|
||||
"community_article", "社区文章" -> directToCommunityArticle(context, linkEntity.community!!, linkEntity.link!!, entrance, path)
|
||||
"community_article", "社区文章" -> directToCommunityArticle(
|
||||
context,
|
||||
linkEntity.community!!,
|
||||
linkEntity.link!!,
|
||||
entrance,
|
||||
path
|
||||
)
|
||||
|
||||
"community_column", "社区专题" -> directToCommunityColumn(context, linkEntity.community, linkEntity.link!!, entrance, path)
|
||||
"community_column", "社区专题" -> directToCommunityColumn(
|
||||
context,
|
||||
linkEntity.community,
|
||||
linkEntity.link!!,
|
||||
entrance,
|
||||
path
|
||||
)
|
||||
|
||||
"community_special_column" -> directAskColumnDetail(
|
||||
context, linkEntity.link
|
||||
@ -223,7 +261,11 @@ object DirectUtils {
|
||||
linkEntity.link!!.contains("v.douyin") && PackageHelper.localPackageNameSet.contains("com.ss.android.ugc.aweme") -> {
|
||||
directDouyin(context, "1402577827140941")
|
||||
}
|
||||
else -> directToWebView(context, url = linkEntity.link!!, entrance = BaseActivity.mergeEntranceAndPath(entrance, path))
|
||||
else -> directToWebView(
|
||||
context,
|
||||
url = linkEntity.link!!,
|
||||
entrance = BaseActivity.mergeEntranceAndPath(entrance, path)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -233,7 +275,16 @@ object DirectUtils {
|
||||
|
||||
"qqqun", "QQ群" -> directToQqGroup(context, linkEntity.link!!)
|
||||
|
||||
"tag" -> context.startActivity(TagsActivity.getIntent(context, linkEntity.text!!, linkEntity.title, entrance, path, exposureEvent?.source))
|
||||
"tag" -> context.startActivity(
|
||||
TagsActivity.getIntent(
|
||||
context,
|
||||
linkEntity.text!!,
|
||||
linkEntity.title,
|
||||
entrance,
|
||||
path,
|
||||
exposureEvent?.source
|
||||
)
|
||||
)
|
||||
|
||||
"all_community_article" -> directSimpleArticleList(
|
||||
context, linkEntity.link
|
||||
@ -244,7 +295,14 @@ object DirectUtils {
|
||||
|
||||
"catalog" -> directCatalog(context, linkEntity.link!!, linkEntity.text!!, entrance, path)
|
||||
|
||||
"category_v2" -> directCategoryV2(context, linkEntity.link!!, linkEntity.text!!, entrance, path, exposureEvent)
|
||||
"category_v2" -> directCategoryV2(
|
||||
context,
|
||||
linkEntity.link!!,
|
||||
linkEntity.text!!,
|
||||
entrance,
|
||||
path,
|
||||
exposureEvent
|
||||
)
|
||||
|
||||
"block", "版块" -> {
|
||||
if (linkEntity.link.isNullOrEmpty()) return
|
||||
@ -300,7 +358,7 @@ object DirectUtils {
|
||||
|
||||
"mobile_bind" -> {
|
||||
CheckLoginUtils.checkLogin(context, entrance) {
|
||||
context.startActivity(BindPhoneActivity.getNormalIntent(context, false))
|
||||
context.startActivity(ComposeBindPhoneActivity.getNormalIntent(context, false))
|
||||
}
|
||||
}
|
||||
|
||||
@ -330,7 +388,7 @@ object DirectUtils {
|
||||
|
||||
"etiquette_exam" -> directToRegulationTestPage(context)
|
||||
|
||||
"setting" -> context.startActivity(SettingActivity.getIntent(context, false, entrance))
|
||||
"setting" -> context.startActivity(ComposeSettingActivity.getIntent(context, false, entrance))
|
||||
|
||||
"index_page" -> directToHomeTab(context)
|
||||
|
||||
@ -365,7 +423,13 @@ object DirectUtils {
|
||||
|
||||
"halo_tab" -> directToPersonalTab(context)
|
||||
|
||||
"common_collection" -> directToCommonCollectionDetail(context, linkEntity.link ?: "", linkEntity.blockId, linkEntity.blockName, entrance)
|
||||
"common_collection" -> directToCommonCollectionDetail(
|
||||
context,
|
||||
linkEntity.link ?: "",
|
||||
linkEntity.blockId,
|
||||
linkEntity.blockName,
|
||||
entrance
|
||||
)
|
||||
|
||||
//"h5_game_center" -> directLetoGameCenter(context)
|
||||
|
||||
@ -373,6 +437,8 @@ object DirectUtils {
|
||||
|
||||
"game_list_detail" -> directToGameCollectionDetail(context, linkEntity.link ?: "", entrance)
|
||||
|
||||
"explore_column" -> context.startActivity(DiscoveryActivity.getIntent(context, entrance))
|
||||
|
||||
"" -> {
|
||||
// do nothing
|
||||
}
|
||||
@ -416,7 +482,13 @@ object DirectUtils {
|
||||
* 跳转至专题合集
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToColumnCollection(context: Context, id: String, position: Int = -1, entrance: String, columnName: String = "") {
|
||||
fun directToColumnCollection(
|
||||
context: Context,
|
||||
id: String,
|
||||
position: Int = -1,
|
||||
entrance: String,
|
||||
columnName: String = ""
|
||||
) {
|
||||
if (id.isEmpty()) return
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_TO, ColumnCollectionDetailActivity::class.java.name)
|
||||
@ -594,7 +666,12 @@ object DirectUtils {
|
||||
* 跳转到游戏评分详情
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToGameRatingDetail(context: Context, gameId: String? = "", commentId: String? = "", entrance: String? = null) {
|
||||
fun directToGameRatingDetail(
|
||||
context: Context,
|
||||
gameId: String? = "",
|
||||
commentId: String? = "",
|
||||
entrance: String? = null
|
||||
) {
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
bundle.putString(KEY_GAMEID, gameId)
|
||||
@ -618,7 +695,12 @@ object DirectUtils {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun directToGameDetail(context: Context, id: String, defaultTab: Int = GameDetailFragment.INDEX_DESC, entrance: String? = null) {
|
||||
fun directToGameDetail(
|
||||
context: Context,
|
||||
id: String,
|
||||
defaultTab: Int = GameDetailFragment.INDEX_DESC,
|
||||
entrance: String? = null
|
||||
) {
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_TO, GameDetailActivity::class.java.name)
|
||||
bundle.putString(KEY_ENTRANCE, entrance)
|
||||
@ -634,14 +716,23 @@ object DirectUtils {
|
||||
|
||||
// 专栏
|
||||
@JvmStatic
|
||||
fun directToSubject(context: Context, id: String, subjectName: String? = "", entrance: String? = null, exposureEvent: ExposureEvent? = null) {
|
||||
fun directToSubject(
|
||||
context: Context,
|
||||
id: String,
|
||||
subjectName: String? = "",
|
||||
entrance: String? = null,
|
||||
exposureEvent: ExposureEvent? = null
|
||||
) {
|
||||
if (id.isEmpty()) return
|
||||
val bundle = Bundle()
|
||||
val subjectData = SubjectData(subjectId = id, subjectName = subjectName, isOrder = false)
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
bundle.putString(KEY_TO, SubjectActivity::class.java.name)
|
||||
bundle.putParcelable(EntranceConsts.KEY_SUBJECT_DATA, subjectData)
|
||||
if (exposureEvent != null) bundle.putParcelableArrayList(KEY_EXPOSURE_SOURCE_LIST, ArrayList(exposureEvent.source))
|
||||
if (exposureEvent != null) bundle.putParcelableArrayList(
|
||||
KEY_EXPOSURE_SOURCE_LIST,
|
||||
ArrayList(exposureEvent.source)
|
||||
)
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
|
||||
@ -693,7 +784,12 @@ object DirectUtils {
|
||||
* 跳转到下载管理器并开始下载 [gameId] 和 [packageName] 用于唯一确定一个下载文件
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToDownloadManagerAndStartDownload(context: Context, gameId: String? = "", packageName: String? = "", entrance: String? = null) {
|
||||
fun directToDownloadManagerAndStartDownload(
|
||||
context: Context,
|
||||
gameId: String? = "",
|
||||
packageName: String? = "",
|
||||
entrance: String? = null
|
||||
) {
|
||||
DownloadHelper.createABrandNewDownloadTaskQuietly(gameId, packageName) {
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
@ -706,7 +802,12 @@ object DirectUtils {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun directToDownloadManagerAndStartUpdate(context: Context, gameId: String? = "", packageName: String? = "", entrance: String? = null) {
|
||||
fun directToDownloadManagerAndStartUpdate(
|
||||
context: Context,
|
||||
gameId: String? = "",
|
||||
packageName: String? = "",
|
||||
entrance: String? = null
|
||||
) {
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
bundle.putString(KEY_TO, DownloadManagerActivity.TAG)
|
||||
@ -892,7 +993,13 @@ object DirectUtils {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun directToCommunityArticle(context: Context, articleId: String?, communityId: String?, entrance: String?, path: String?) {
|
||||
fun directToCommunityArticle(
|
||||
context: Context,
|
||||
articleId: String?,
|
||||
communityId: String?,
|
||||
entrance: String?,
|
||||
path: String?
|
||||
) {
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
bundle.putString(KEY_PATH, path)
|
||||
@ -903,7 +1010,13 @@ object DirectUtils {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun directToCommunityArticle(context: Context, community: CommunityEntity?, articleId: String?, entrance: String?, path: String?) {
|
||||
fun directToCommunityArticle(
|
||||
context: Context,
|
||||
community: CommunityEntity?,
|
||||
articleId: String?,
|
||||
entrance: String?,
|
||||
path: String?
|
||||
) {
|
||||
if (articleId.isNullOrEmpty()) return
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
@ -918,7 +1031,13 @@ object DirectUtils {
|
||||
* 跳转到社区专题
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToCommunityColumn(context: Context, community: CommunityEntity?, subjectId: String, entrance: String?, path: String?) {
|
||||
fun directToCommunityColumn(
|
||||
context: Context,
|
||||
community: CommunityEntity?,
|
||||
subjectId: String,
|
||||
entrance: String?,
|
||||
path: String?
|
||||
) {
|
||||
if (subjectId.isEmpty()) return
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_PATH, path)
|
||||
@ -1008,7 +1127,12 @@ object DirectUtils {
|
||||
* @param fixedTopAmwayCommentId 需要置顶的安利Id
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToAmway(context: Context, fixedTopAmwayCommentId: String? = null, entrance: String? = null, path: String? = "") {
|
||||
fun directToAmway(
|
||||
context: Context,
|
||||
fixedTopAmwayCommentId: String? = null,
|
||||
entrance: String? = null,
|
||||
path: String? = ""
|
||||
) {
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
bundle.putString(KEY_TO, AmwayActivity::class.java.name)
|
||||
@ -1083,8 +1207,14 @@ object DirectUtils {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun directToFullScreenWebPage(context: Context, url: String, webViewHandleBackPressed: Boolean = false) {
|
||||
context.startActivity(FullScreenWebActivity.getIntent(context, url, webViewHandleBackPressed))
|
||||
@JvmOverloads
|
||||
fun directToFullScreenWebPage(
|
||||
context: Context,
|
||||
url: String,
|
||||
webViewHandleBackPressed: Boolean = false,
|
||||
entrance: String? = null
|
||||
) {
|
||||
context.startActivity(FullScreenWebActivity.getIntent(context, url, webViewHandleBackPressed, entrance))
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@ -1149,7 +1279,13 @@ object DirectUtils {
|
||||
* 跳转分类
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directCategoryDirectory(context: Context, categoryId: String, categoryTitle: String, entrance: String? = null, path: String? = "") {
|
||||
fun directCategoryDirectory(
|
||||
context: Context,
|
||||
categoryId: String,
|
||||
categoryTitle: String,
|
||||
entrance: String? = null,
|
||||
path: String? = ""
|
||||
) {
|
||||
if (categoryId.isEmpty()) return
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_TO, CategoryDirectoryActivity::class.java.name)
|
||||
@ -1198,7 +1334,10 @@ object DirectUtils {
|
||||
bundle.putString(KEY_CATEGORY_ID, categoryId)
|
||||
bundle.putString(KEY_CATEGORY_TITLE, categoryTitle)
|
||||
bundle.putString(KEY_ENTRANCE, BaseActivity.mergeEntranceAndPath(entrance, path))
|
||||
if (exposureEvent != null) bundle.putParcelableArrayList(KEY_EXPOSURE_SOURCE_LIST, ArrayList(exposureEvent.source))
|
||||
if (exposureEvent != null) bundle.putParcelableArrayList(
|
||||
KEY_EXPOSURE_SOURCE_LIST,
|
||||
ArrayList(exposureEvent.source)
|
||||
)
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
|
||||
@ -1206,7 +1345,13 @@ object DirectUtils {
|
||||
* 跳转到问题标签详情
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directAskColumnLabelDetail(context: Context, tag: String, community: CommunityEntity, entrance: String? = null, path: String? = "") {
|
||||
fun directAskColumnLabelDetail(
|
||||
context: Context,
|
||||
tag: String,
|
||||
community: CommunityEntity,
|
||||
entrance: String? = null,
|
||||
path: String? = ""
|
||||
) {
|
||||
// val bundle = Bundle()
|
||||
// bundle.putString(KEY_TO, AskColumnDetailActivity::class.java.name)
|
||||
// bundle.putString(KEY_ASK_TAG, tag)
|
||||
@ -1220,7 +1365,13 @@ object DirectUtils {
|
||||
* 跳转到专栏详情
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directAskColumnDetail(context: Context, columnId: String, community: CommunityEntity, entrance: String? = null, path: String? = "") {
|
||||
fun directAskColumnDetail(
|
||||
context: Context,
|
||||
columnId: String,
|
||||
community: CommunityEntity,
|
||||
entrance: String? = null,
|
||||
path: String? = ""
|
||||
) {
|
||||
// if (columnId.isEmpty()) return
|
||||
// val bundle = Bundle()
|
||||
// bundle.putString(KEY_TO, AskColumnDetailActivity::class.java.name)
|
||||
@ -1430,7 +1581,13 @@ object DirectUtils {
|
||||
Constants.COMMODITY_DETAIL_ADDRESS
|
||||
}
|
||||
|
||||
url = String.format(Locale.CHINA, "%s&shopid=%s×tamp=%d", url, commodityId, (Date().time / 1000 / 1000.toFloat()).roundToInt())
|
||||
url = String.format(
|
||||
Locale.CHINA,
|
||||
"%s&shopid=%s×tamp=%d",
|
||||
url,
|
||||
commodityId,
|
||||
(Date().time / 1000 / 1000.toFloat()).roundToInt()
|
||||
)
|
||||
directToFullScreenWebPage(context, url, true)
|
||||
}
|
||||
|
||||
@ -1450,7 +1607,13 @@ object DirectUtils {
|
||||
Constants.ENERGY_RECORD_ADDRESS
|
||||
}
|
||||
|
||||
url = String.format(Locale.CHINA, "%s&position=%s×tamp=%d", url, position, (Date().time / 1000 / 1000.toFloat()).roundToInt())
|
||||
url = String.format(
|
||||
Locale.CHINA,
|
||||
"%s&position=%s×tamp=%d",
|
||||
url,
|
||||
position,
|
||||
(Date().time / 1000 / 1000.toFloat()).roundToInt()
|
||||
)
|
||||
directToFullScreenWebPage(context, url, true)
|
||||
}
|
||||
|
||||
@ -1478,7 +1641,13 @@ object DirectUtils {
|
||||
Constants.ORDER_DETAIL_ADDRESS
|
||||
}
|
||||
|
||||
url = String.format(Locale.CHINA, "%s&order_id=%s×tamp=%d", url, orderId, (Date().time / 1000 / 1000.toFloat()).roundToInt())
|
||||
url = String.format(
|
||||
Locale.CHINA,
|
||||
"%s&order_id=%s×tamp=%d",
|
||||
url,
|
||||
orderId,
|
||||
(Date().time / 1000 / 1000.toFloat()).roundToInt()
|
||||
)
|
||||
directToFullScreenWebPage(context, url, true)
|
||||
}
|
||||
|
||||
@ -1665,7 +1834,7 @@ object DirectUtils {
|
||||
|
||||
url = String.format(
|
||||
Locale.CHINA,
|
||||
"%s&id=%s&category_id=%s×tamp=%d",
|
||||
"%s?from=ghzs&id=%s&category_id=%s×tamp=%d",
|
||||
url,
|
||||
activityId,
|
||||
categoryId,
|
||||
|
||||
@ -13,7 +13,12 @@ object DownloadDialogHelper {
|
||||
* [callback] 执行点击关闭以后会执行的代码块,没有弹窗也会执行这个代码块
|
||||
*/
|
||||
@JvmStatic
|
||||
fun findAvailableDialogAndShow(context: Context, gameEntity: GameEntity, apkEntity: ApkEntity, callback: EmptyCallback) {
|
||||
fun findAvailableDialogAndShow(
|
||||
context: Context,
|
||||
gameEntity: GameEntity,
|
||||
apkEntity: ApkEntity,
|
||||
callback: EmptyCallback
|
||||
) {
|
||||
val dialog = retrieveAvailableDialog(gameEntity, apkEntity)
|
||||
if (dialog != null) {
|
||||
showDownloadDialog(context, dialog, callback)
|
||||
@ -37,57 +42,65 @@ object DownloadDialogHelper {
|
||||
// 共有 8 种可能
|
||||
// 1. 不指定包名、机型和系统版本
|
||||
if (dialog.rule.packageName.isEmpty()
|
||||
&& dialog.rule.models.isEmpty()
|
||||
&& dialog.rule.systemVersions.isEmpty()) {
|
||||
&& dialog.rule.models.isEmpty()
|
||||
&& dialog.rule.systemVersions.isEmpty()
|
||||
) {
|
||||
return dialog
|
||||
}
|
||||
|
||||
// 2. 指定包名不管机型和系统
|
||||
if (dialog.rule.packageName == apkEntity.packageName
|
||||
&& dialog.rule.models.isEmpty()
|
||||
&& dialog.rule.systemVersions.isEmpty()) {
|
||||
&& dialog.rule.models.isEmpty()
|
||||
&& dialog.rule.systemVersions.isEmpty()
|
||||
) {
|
||||
return dialog
|
||||
}
|
||||
|
||||
// 3. 指定机型不管包名和系统
|
||||
if (dialog.rule.models.contains(Build.MODEL)
|
||||
&& dialog.rule.packageName.isEmpty()
|
||||
&& dialog.rule.systemVersions.isEmpty()) {
|
||||
&& dialog.rule.packageName.isEmpty()
|
||||
&& dialog.rule.systemVersions.isEmpty()
|
||||
) {
|
||||
return dialog
|
||||
}
|
||||
|
||||
// 4. 指定系统不管包名和机型
|
||||
if (dialog.rule.systemVersions.contains(Build.VERSION.RELEASE)
|
||||
&& dialog.rule.packageName.isEmpty()
|
||||
&& dialog.rule.models.isEmpty()) {
|
||||
&& dialog.rule.packageName.isEmpty()
|
||||
&& dialog.rule.models.isEmpty()
|
||||
) {
|
||||
return dialog
|
||||
}
|
||||
|
||||
// 5. 指定包名和机型不管系统
|
||||
if (dialog.rule.packageName == apkEntity.packageName
|
||||
&& dialog.rule.models.contains(Build.MODEL)
|
||||
&& dialog.rule.systemVersions.isEmpty()) {
|
||||
&& dialog.rule.models.contains(Build.MODEL)
|
||||
&& dialog.rule.systemVersions.isEmpty()
|
||||
) {
|
||||
return dialog
|
||||
}
|
||||
|
||||
// 6. 指定包名和系统不管机型
|
||||
if (dialog.rule.packageName == apkEntity.packageName
|
||||
&& dialog.rule.systemVersions.contains(Build.VERSION.RELEASE)
|
||||
&& dialog.rule.models.isEmpty()) {
|
||||
&& dialog.rule.systemVersions.contains(Build.VERSION.RELEASE)
|
||||
&& dialog.rule.models.isEmpty()
|
||||
) {
|
||||
return dialog
|
||||
}
|
||||
|
||||
// 7. 指定机型和系统不管包名
|
||||
if (dialog.rule.systemVersions.contains(Build.VERSION.RELEASE)
|
||||
&& dialog.rule.models.contains(Build.MODEL)
|
||||
&& dialog.rule.packageName.isEmpty()) {
|
||||
&& dialog.rule.models.contains(Build.MODEL)
|
||||
&& dialog.rule.packageName.isEmpty()
|
||||
) {
|
||||
return dialog
|
||||
}
|
||||
|
||||
// 8.指定包名、机型和系统版本
|
||||
if (dialog.rule.packageName == apkEntity.packageName
|
||||
&& dialog.rule.models.contains(Build.MODEL)
|
||||
&& dialog.rule.systemVersions.contains(Build.VERSION.RELEASE)) {
|
||||
&& dialog.rule.models.contains(Build.MODEL)
|
||||
&& dialog.rule.systemVersions.contains(Build.VERSION.RELEASE)
|
||||
) {
|
||||
return dialog
|
||||
}
|
||||
} else return null
|
||||
|
||||
@ -25,34 +25,38 @@ object DownloadHelper {
|
||||
}
|
||||
|
||||
RetrofitManager.getInstance()
|
||||
.api
|
||||
.getGameDigest(gameId)
|
||||
.map(ApkActiveUtils.filterMapper)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : Response<GameEntity>() {
|
||||
override fun onResponse(response: GameEntity?) {
|
||||
response?.let {
|
||||
if (response.getApk().size > 1) {
|
||||
for (apk in response.getApk()) {
|
||||
if (packageName == apk.packageName) {
|
||||
DownloadManager.createDownload(HaloApp.getInstance().application,
|
||||
apk, response, "", EntranceConsts.ENTRANCE_RECOMMEND, "", false, null)
|
||||
block.invoke()
|
||||
}
|
||||
.api
|
||||
.getGameDigest(gameId)
|
||||
.map(ApkActiveUtils.filterMapper)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : Response<GameEntity>() {
|
||||
override fun onResponse(response: GameEntity?) {
|
||||
response?.let {
|
||||
if (response.getApk().size > 1) {
|
||||
for (apk in response.getApk()) {
|
||||
if (packageName == apk.packageName) {
|
||||
DownloadManager.createDownload(
|
||||
HaloApp.getInstance().application,
|
||||
apk, response, "", EntranceConsts.ENTRANCE_RECOMMEND, "", false, null
|
||||
)
|
||||
block.invoke()
|
||||
}
|
||||
} else if (response.getApk().size == 1) {
|
||||
DownloadManager.createDownload(HaloApp.getInstance().application,
|
||||
response, "", EntranceConsts.ENTRANCE_RECOMMEND, "", false, null)
|
||||
block.invoke()
|
||||
}
|
||||
} else if (response.getApk().size == 1) {
|
||||
DownloadManager.createDownload(
|
||||
HaloApp.getInstance().application,
|
||||
response, "", EntranceConsts.ENTRANCE_RECOMMEND, "", false, null
|
||||
)
|
||||
block.invoke()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailure(e: HttpException?) {
|
||||
e?.printStackTrace()
|
||||
block.invoke()
|
||||
}
|
||||
})
|
||||
override fun onFailure(e: HttpException?) {
|
||||
e?.printStackTrace()
|
||||
block.invoke()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@ -14,6 +14,7 @@ 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
|
||||
@ -32,7 +33,7 @@ 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.utils.EnergyTaskHelper
|
||||
import com.gh.gamecenter.energy.EnergyBridge
|
||||
import com.gh.gamecenter.entity.PluginLocation
|
||||
import com.gh.gamecenter.gamedetail.dialog.GamePermissionDialogFragment
|
||||
import com.gh.gamecenter.manager.PackagesManager
|
||||
@ -80,7 +81,13 @@ object DownloadItemUtils {
|
||||
if (!queue.contains(platform) && !TextUtils.isEmpty(platform)) {
|
||||
queue.offer(platform)
|
||||
if (AppDebugConfig.IS_DEBUG) {
|
||||
AppDebugConfig.logMethodWithParams(DownloadItemUtils::class.java, queue.size, gameEntity.brief, downloadEntity.platform, index)
|
||||
AppDebugConfig.logMethodWithParams(
|
||||
DownloadItemUtils::class.java,
|
||||
queue.size,
|
||||
gameEntity.brief,
|
||||
downloadEntity.platform,
|
||||
index
|
||||
)
|
||||
}
|
||||
// 有两个平台同时下载的时候启用
|
||||
if (queue.size == 2) {
|
||||
@ -127,7 +134,15 @@ object DownloadItemUtils {
|
||||
context: Context, gameEntity: GameEntity, holder: GameViewHolder,
|
||||
isShowPlatform: Boolean, hideDownloadBtnIfNoAvailableContent: Boolean
|
||||
) {
|
||||
updateItem(context, gameEntity, holder, isShowPlatform, PluginLocation.only_game, hideDownloadBtnIfNoAvailableContent, null)
|
||||
updateItem(
|
||||
context,
|
||||
gameEntity,
|
||||
holder,
|
||||
isShowPlatform,
|
||||
PluginLocation.only_game,
|
||||
hideDownloadBtnIfNoAvailableContent,
|
||||
null
|
||||
)
|
||||
}
|
||||
|
||||
fun updateItem(
|
||||
@ -152,7 +167,13 @@ object DownloadItemUtils {
|
||||
// 显示预约
|
||||
if (gameEntity.isReservable) {
|
||||
updateItemViewStatus(holder, false, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
|
||||
updateDownloadButton(context, holder.gameDownloadBtn, gameEntity, hideDownloadBtnIfNoAvailableContent, pluginLocation)
|
||||
updateDownloadButton(
|
||||
context,
|
||||
holder.gameDownloadBtn,
|
||||
gameEntity,
|
||||
hideDownloadBtnIfNoAvailableContent,
|
||||
pluginLocation
|
||||
)
|
||||
return
|
||||
}
|
||||
if (gameEntity.getApk().isEmpty() || gameEntity.downloadOffStatus != null) {
|
||||
@ -162,7 +183,13 @@ object DownloadItemUtils {
|
||||
} else {
|
||||
updatePluginItem(context, holder, gameEntity, isShowPlatform, briefStyle, isShowRecommendStar)
|
||||
}
|
||||
updateDownloadButton(context, holder.gameDownloadBtn, gameEntity, hideDownloadBtnIfNoAvailableContent, pluginLocation)
|
||||
updateDownloadButton(
|
||||
context,
|
||||
holder.gameDownloadBtn,
|
||||
gameEntity,
|
||||
hideDownloadBtnIfNoAvailableContent,
|
||||
pluginLocation
|
||||
)
|
||||
}
|
||||
|
||||
fun updateDownloadButton(
|
||||
@ -265,11 +292,12 @@ object DownloadItemUtils {
|
||||
} else {
|
||||
setText(R.string.install)
|
||||
}
|
||||
buttonStyle = if (downloadEntity.isPluggable && PackagesManager.isInstalled(downloadEntity.packageName)) {
|
||||
DownloadButton.ButtonStyle.PLUGIN
|
||||
} else {
|
||||
DownloadButton.ButtonStyle.NORMAL
|
||||
}
|
||||
buttonStyle =
|
||||
if (downloadEntity.isPluggable && PackagesManager.isInstalled(downloadEntity.packageName)) {
|
||||
DownloadButton.ButtonStyle.PLUGIN
|
||||
} else {
|
||||
DownloadButton.ButtonStyle.NORMAL
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -350,12 +378,20 @@ object DownloadItemUtils {
|
||||
holder.gameDownloadSpeed.text = String.format(
|
||||
"%s - %s(剩%s)", platform,
|
||||
SpeedUtils.getSpeed(downloadEntity.speed),
|
||||
SpeedUtils.getRemainTime(downloadEntity.size, downloadEntity.progress, downloadEntity.speed * 1024)
|
||||
SpeedUtils.getRemainTime(
|
||||
downloadEntity.size,
|
||||
downloadEntity.progress,
|
||||
downloadEntity.speed * 1024
|
||||
)
|
||||
)
|
||||
} else {
|
||||
holder.gameDownloadSpeed.text = String.format(
|
||||
"%s(剩%s)", SpeedUtils.getSpeed(downloadEntity.speed),
|
||||
SpeedUtils.getRemainTime(downloadEntity.size, downloadEntity.progress, downloadEntity.speed * 1024)
|
||||
SpeedUtils.getRemainTime(
|
||||
downloadEntity.size,
|
||||
downloadEntity.progress,
|
||||
downloadEntity.speed * 1024
|
||||
)
|
||||
)
|
||||
}
|
||||
holder.gameDownloadPercentage.text = downloadEntity.percent.toString() + "%"
|
||||
@ -380,7 +416,8 @@ object DownloadItemUtils {
|
||||
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.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%"
|
||||
@ -504,7 +541,19 @@ object DownloadItemUtils {
|
||||
traceEvent: ExposureEvent?,
|
||||
clickCallback: EmptyCallback?
|
||||
) {
|
||||
setOnClickListener(context, downloadBtn, gameEntity, position, adapter, entrance, location, traceEvent, clickCallback, null, null)
|
||||
setOnClickListener(
|
||||
context,
|
||||
downloadBtn,
|
||||
gameEntity,
|
||||
position,
|
||||
adapter,
|
||||
entrance,
|
||||
location,
|
||||
traceEvent,
|
||||
clickCallback,
|
||||
null,
|
||||
null
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -618,7 +667,7 @@ object DownloadItemUtils {
|
||||
}
|
||||
})
|
||||
}
|
||||
},object : CancelListener {
|
||||
}, object : CancelListener {
|
||||
override fun onCancel() {
|
||||
NewFlatLogUtils.logMyGameCancelReserveDialogClick(
|
||||
"关闭弹窗",
|
||||
@ -648,7 +697,13 @@ object DownloadItemUtils {
|
||||
if (isPlay) {
|
||||
HistoryHelper.insertGameEntity(gameEntity)
|
||||
}
|
||||
val i = WebActivity.getIntentForWebGame(context, gameEntity.h5Link!!.link, gameEntity.name, isPlay, linkEntity.closeButton)
|
||||
val i = WebActivity.getIntentForWebGame(
|
||||
context,
|
||||
gameEntity.h5Link!!.link,
|
||||
gameEntity.name,
|
||||
isPlay,
|
||||
linkEntity.closeButton
|
||||
)
|
||||
context.startActivity(i)
|
||||
}
|
||||
} else if (gameEntity.getApk().size == 1) {
|
||||
@ -657,7 +712,17 @@ object DownloadItemUtils {
|
||||
override fun onCallback() {
|
||||
allStateClickCallback?.onCallback()
|
||||
clickCallback?.onCallback()
|
||||
onNormalClick(context, downloadBtn, gameEntity, position, adapter, entrance, location, traceEvent, refreshCallback)
|
||||
onNormalClick(
|
||||
context,
|
||||
downloadBtn,
|
||||
gameEntity,
|
||||
position,
|
||||
adapter,
|
||||
entrance,
|
||||
location,
|
||||
traceEvent,
|
||||
refreshCallback
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -705,6 +770,7 @@ object DownloadItemUtils {
|
||||
val apk = gameEntity.getApk().safelyGetInRelease(0) ?: return
|
||||
if (str == context.getString(R.string.download)) {
|
||||
ChainBuilder().apply {
|
||||
addHandler(UpdateNewSimulatorHandler())
|
||||
addHandler(GamePermissionHandler())
|
||||
addHandler(BrowserInstallHandler())
|
||||
addHandler(PackageCheckHandler())
|
||||
@ -773,10 +839,17 @@ object DownloadItemUtils {
|
||||
} else if (str == context.getString(R.string.install)) {
|
||||
val downloadEntity = SimulatorGameManager.findDownloadEntityByUrl(apk.url)
|
||||
if (gameEntity.simulator != null) {
|
||||
val isInstalled = PackageUtils.isInstalledFromAllPackage(context, gameEntity.simulator!!.apk!!.packageName)
|
||||
if (downloadEntity != null && SimulatorGameManager.isSimulatorGame(gameEntity) && !isInstalled) {
|
||||
val isInstalled =
|
||||
PackageUtils.isInstalledFromAllPackage(context, gameEntity.simulator!!.apk!!.packageName)
|
||||
val isInstalledNewSimulator = SimulatorGameManager.isNewSimulatorInstalled(context)
|
||||
val isInstalledOldSimulator = SimulatorGameManager.isOldSimulatorInstalled(context)
|
||||
var simulator = gameEntity.simulator
|
||||
if (!isInstalledOldSimulator) {
|
||||
simulator = Config.getNewSimulatorEntitySetting()
|
||||
}
|
||||
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
|
||||
@ -789,10 +862,13 @@ object DownloadItemUtils {
|
||||
install(context, gameEntity, position, adapter, refreshCallback)
|
||||
}
|
||||
} else if (str == context.getString(R.string.launch)) {
|
||||
EnergyTaskHelper.postEnergyTask("play_game", gameEntity.id, gameEntity.getApk()[0].packageName)
|
||||
|
||||
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)
|
||||
@ -800,6 +876,7 @@ object DownloadItemUtils {
|
||||
download(context, gameEntity, downloadBtn, entrance, location, false, traceEvent)
|
||||
return
|
||||
}
|
||||
NewFlatLogUtils.logSimulatorGameCardClick("启动")
|
||||
SimulatorGameManager.launchSimulatorGame(downloadEntity, gameEntity)
|
||||
}
|
||||
return
|
||||
@ -857,7 +934,15 @@ object DownloadItemUtils {
|
||||
|
||||
val msg = FileUtils.isCanDownload(context, gameEntity.getApk()[0].size)
|
||||
if (TextUtils.isEmpty(msg)) {
|
||||
DownloadManager.createDownload(context, gameEntity, context.getString(R.string.download), entrance, location, isSubscribe, traceEvent)
|
||||
DownloadManager.createDownload(
|
||||
context,
|
||||
gameEntity,
|
||||
context.getString(R.string.download),
|
||||
entrance,
|
||||
location,
|
||||
isSubscribe,
|
||||
traceEvent
|
||||
)
|
||||
Utils.toast(context, gameEntity.name + "已加入下载队列")
|
||||
downloadBtn.setText(R.string.downloading)
|
||||
downloadBtn.buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_NORMAL
|
||||
|
||||
@ -13,7 +13,10 @@ import com.gh.common.xapk.XapkUnzipStatus
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.common.utils.getMetaExtra
|
||||
import com.gh.gamecenter.common.utils.isSimulatorGame
|
||||
import com.gh.gamecenter.common.utils.isVGame
|
||||
import com.gh.gamecenter.common.utils.tryCatchInRelease
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.core.utils.SpeedUtils
|
||||
import com.halo.assistant.HaloApp
|
||||
@ -51,7 +54,7 @@ object DownloadNotificationHelper {
|
||||
|
||||
val intent = Intent()
|
||||
if (entity.status == DownloadStatus.done && xapkStatus != XapkUnzipStatus.FAILURE.name) {
|
||||
intent.putExtra(EntranceConsts.KEY_DATA, entity.toJson())
|
||||
intent.putExtra(EntranceConsts.KEY_URL, entity.url)
|
||||
intent.putExtra(EntranceConsts.KEY_PATH, entity.path)
|
||||
intent.action = ACTION_INSTALL
|
||||
} else if (entity.isVGame()) {
|
||||
@ -59,31 +62,38 @@ object DownloadNotificationHelper {
|
||||
} else {
|
||||
intent.action = ACTION_DOWNLOAD
|
||||
}
|
||||
val pendingIntent = PendingIntent.getBroadcast(HaloApp.getInstance().application,
|
||||
downloadNotificationId,
|
||||
intent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
val pendingIntent = PendingIntent.getBroadcast(
|
||||
HaloApp.getInstance().application,
|
||||
downloadNotificationId,
|
||||
intent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT
|
||||
)
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val channel = NotificationChannel(DOWNLOAD_CHANNEL_ID, DOWNLOAD_CHANNEL_ID, NotificationManager.IMPORTANCE_LOW)
|
||||
val channel =
|
||||
NotificationChannel(DOWNLOAD_CHANNEL_ID, DOWNLOAD_CHANNEL_ID, NotificationManager.IMPORTANCE_LOW)
|
||||
notificationManager.createNotificationChannel(channel)
|
||||
}
|
||||
|
||||
val whenTime = 1000 * 60 * (System.currentTimeMillis() / 1000 / 60)
|
||||
val builder = NotificationCompat.Builder(HaloApp.getInstance().application, DOWNLOAD_CHANNEL_ID)
|
||||
.setContentTitle(entity.name)
|
||||
.setSmallIcon(getNotificationIcon())
|
||||
.setContentIntent(pendingIntent)
|
||||
.setGroup(DOWNLOAD_GROUP_KEY)
|
||||
.setWhen(whenTime)
|
||||
.setContentTitle(entity.name)
|
||||
.setSmallIcon(getNotificationIcon())
|
||||
.setContentIntent(pendingIntent)
|
||||
.setGroup(DOWNLOAD_GROUP_KEY)
|
||||
.setWhen(whenTime)
|
||||
|
||||
if (xapkStatus == XapkUnzipStatus.FAILURE.name) {
|
||||
builder.setContentText("《" + entity.name + "》解压失败,点击查看详情~")
|
||||
} else {
|
||||
when (entity.status) {
|
||||
DownloadStatus.downloading -> builder.setContentText(String.format("%s(剩%s)",
|
||||
DownloadStatus.downloading -> builder.setContentText(
|
||||
String.format(
|
||||
"%s(剩%s)",
|
||||
SpeedUtils.getSpeed(entity.speed),
|
||||
SpeedUtils.getRemainTime(entity.size, entity.progress, entity.speed * 1024)))
|
||||
SpeedUtils.getRemainTime(entity.size, entity.progress, entity.speed * 1024)
|
||||
)
|
||||
)
|
||||
DownloadStatus.done -> builder.setContentText("下载完成,点击立即安装")
|
||||
DownloadStatus.waiting -> builder.setContentText("等待中")
|
||||
DownloadStatus.subscribe,
|
||||
@ -113,18 +123,19 @@ object DownloadNotificationHelper {
|
||||
}
|
||||
|
||||
if (entity.status == DownloadStatus.delete
|
||||
|| entity.status == DownloadStatus.cancel
|
||||
|| entity.status == DownloadStatus.hijack
|
||||
|| entity.status == DownloadStatus.unqualified
|
||||
|| entity.status == DownloadStatus.unavailable
|
||||
|| entity.status == DownloadStatus.banned
|
||||
|| entity.status == DownloadStatus.uncertificated
|
||||
|| entity.status == DownloadStatus.notfound
|
||||
|| entity.status == DownloadStatus.overflow
|
||||
|| (entity.status == DownloadStatus.done // 触发安装事件以后也 cancel 掉通知
|
||||
&& !entity.meta[Constants.MARK_ALREADY_TRIGGERED_INSTALLATION].isNullOrEmpty()
|
||||
&& xapkStatus != XapkUnzipStatus.FAILURE.name)
|
||||
|| entity.status == DownloadStatus.done && entity.isSimulatorGame()) {//模拟器游戏下载完需要cancel掉通知
|
||||
|| entity.status == DownloadStatus.cancel
|
||||
|| entity.status == DownloadStatus.hijack
|
||||
|| entity.status == DownloadStatus.unqualified
|
||||
|| entity.status == DownloadStatus.unavailable
|
||||
|| entity.status == DownloadStatus.banned
|
||||
|| entity.status == DownloadStatus.uncertificated
|
||||
|| entity.status == DownloadStatus.notfound
|
||||
|| entity.status == DownloadStatus.overflow
|
||||
|| (entity.status == DownloadStatus.done // 触发安装事件以后也 cancel 掉通知
|
||||
&& !entity.meta[Constants.MARK_ALREADY_TRIGGERED_INSTALLATION].isNullOrEmpty()
|
||||
&& xapkStatus != XapkUnzipStatus.FAILURE.name)
|
||||
|| entity.status == DownloadStatus.done && entity.isSimulatorGame()
|
||||
) {//模拟器游戏下载完需要cancel掉通知
|
||||
requireUpdateNotificationGroupDelay = true
|
||||
notificationManager.cancel(entity.path, DOWNLOAD_NOTIFICATION_ID)
|
||||
} else {
|
||||
@ -171,7 +182,8 @@ object DownloadNotificationHelper {
|
||||
// 删除组可能会把组内所有通知一并删除
|
||||
notificationManager.cancel(DOWNLOAD_NOTIFICATION_FOLD_ID)
|
||||
} else if (downloadNotificationSize != 0 && downloadGroupNotificationSize == 0) {
|
||||
val groupBuilder = NotificationCompat.Builder(HaloApp.getInstance().application, DOWNLOAD_CHANNEL_ID)
|
||||
val groupBuilder =
|
||||
NotificationCompat.Builder(HaloApp.getInstance().application, DOWNLOAD_CHANNEL_ID)
|
||||
.setSmallIcon(getNotificationIcon())
|
||||
.setGroup(DOWNLOAD_GROUP_KEY)
|
||||
.setGroupSummary(true)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.preference.PreferenceManager
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.common.exposure.ExposureUtils
|
||||
import com.gh.common.simulator.SimulatorDownloadManager
|
||||
import com.gh.common.simulator.SimulatorGameManager
|
||||
@ -16,13 +16,13 @@ import com.gh.gamecenter.common.eventbus.EBShowDialog
|
||||
import com.gh.gamecenter.common.retrofit.Response
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.utils.*
|
||||
import com.gh.gamecenter.energy.utils.EnergyTaskHelper
|
||||
import com.gh.gamecenter.energy.EnergyBridge
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
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.compose.activity.ComposeGameDownloadSettingActivity
|
||||
import com.gh.gamecenter.suggest.SuggestType
|
||||
import com.gh.vspace.VHelper
|
||||
import com.halo.assistant.HaloApp
|
||||
@ -139,7 +139,7 @@ object DownloadObserver {
|
||||
// 删除任务
|
||||
downloadEntity.status = DownloadStatus.cancel
|
||||
downloadManager.cancel(downloadEntity.url)
|
||||
}else if (DownloadStatus.banned == downloadEntity.status) {
|
||||
} else if (DownloadStatus.banned == downloadEntity.status) {
|
||||
ToastUtils.showToast("网络异常")
|
||||
// 删除任务
|
||||
downloadEntity.status = DownloadStatus.cancel
|
||||
@ -202,11 +202,7 @@ object DownloadObserver {
|
||||
|
||||
GameActivityDownloadHelper.clear()
|
||||
|
||||
EnergyTaskHelper.postEnergyTask(
|
||||
"download_game",
|
||||
downloadEntity.gameId,
|
||||
downloadEntity.packageName
|
||||
)
|
||||
EnergyBridge.postEnergyTask("download_game", downloadEntity.gameId, downloadEntity.packageName)
|
||||
val platform = PlatformUtils.getInstance(mApplication)
|
||||
.getPlatformName(downloadEntity.platform)
|
||||
if (platform != null) {
|
||||
@ -219,7 +215,10 @@ object DownloadObserver {
|
||||
downloadEntity.path
|
||||
)
|
||||
)
|
||||
downloadEntity.isPlugin -> Utils.toast(mApplication, downloadEntity.name + " - " + platform + " - 下载完成")
|
||||
downloadEntity.isPlugin -> Utils.toast(
|
||||
mApplication,
|
||||
downloadEntity.name + " - " + platform + " - 下载完成"
|
||||
)
|
||||
else -> {
|
||||
if (downloadEntity.isVGame()) {
|
||||
VHelper.showFloatingWindow(downloadEntity.packageName)
|
||||
@ -240,29 +239,39 @@ 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
|
||||
if (!isInstalledOldSimulator || isInstalledNewSimulator) { //如果没有安装任一旧的模拟器 或者下载了新模拟器 则使用新版本模拟器
|
||||
Config.getNewSimulatorEntitySetting().let {
|
||||
simulator = it!!
|
||||
}
|
||||
}
|
||||
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 {
|
||||
val downloadType = downloadEntity.getMetaExtra(Constants.EXTRA_DOWNLOAD_TYPE)
|
||||
// 是否是自动安装
|
||||
val isAutoInstall = SPUtils.getBoolean(GameDownloadSettingFragment.AUTO_INSTALL_SP_KEY, true)
|
||||
val isAutoInstall = SPUtils.getBoolean(ComposeGameDownloadSettingActivity.AUTO_INSTALL_SP_KEY, true)
|
||||
if (downloadType == Constants.SIMULATOR_DOWNLOAD || isAutoInstall) {
|
||||
if (FileUtils.isEmptyFile(downloadEntity.path)) {
|
||||
Utils.toast(mApplication, R.string.install_failure_hint)
|
||||
downloadManager.cancel(downloadEntity.url)
|
||||
} else {
|
||||
if (PackageUtils.isCanLaunchSetup(mApplication, downloadEntity.path) || downloadType == Constants.SMOOTH_GAME) {
|
||||
if (PackageUtils.isCanLaunchSetup(
|
||||
mApplication,
|
||||
downloadEntity.path
|
||||
) || downloadType == Constants.SMOOTH_GAME
|
||||
) {
|
||||
downloadEntity.meta[Constants.MARK_ALREADY_TRIGGERED_INSTALLATION] = "YES"
|
||||
tryWithDefaultCatch {
|
||||
PackageInstaller.install(mApplication, downloadEntity, false)
|
||||
@ -309,15 +318,23 @@ object DownloadObserver {
|
||||
if (downloadType == Constants.SIMULATOR_DOWNLOAD) {
|
||||
val currentActivity = AppManager.getInstance().currentActivity()
|
||||
?: return
|
||||
DialogUtils.showSimulatorParseErrorDialog(currentActivity, downloadEntity.gameId, downloadEntity.name,object :ConfirmListener{
|
||||
override fun onConfirm() {
|
||||
val simulator = HaloApp.get(downloadEntity.name, true) as? SimulatorEntity
|
||||
?: return
|
||||
DownloadManager.getInstance().cancel(downloadEntity.url, true, true, false)
|
||||
SimulatorDownloadManager.getInstance()
|
||||
.showDownloadDialog(currentActivity, simulator, SimulatorDownloadManager.SimulatorLocation.SIMULATOR_GAME)
|
||||
}
|
||||
})
|
||||
DialogUtils.showSimulatorParseErrorDialog(
|
||||
currentActivity,
|
||||
downloadEntity.gameId,
|
||||
downloadEntity.name,
|
||||
object : ConfirmListener {
|
||||
override fun onConfirm() {
|
||||
val simulator = HaloApp.get(downloadEntity.name, true) as? SimulatorEntity
|
||||
?: return
|
||||
DownloadManager.getInstance().cancel(downloadEntity.url, true, true, false)
|
||||
SimulatorDownloadManager.getInstance()
|
||||
.showDownloadDialog(
|
||||
currentActivity,
|
||||
simulator,
|
||||
SimulatorDownloadManager.SimulatorLocation.SIMULATOR_GAME
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -345,7 +362,8 @@ object DownloadObserver {
|
||||
if (downloadEntity.isPluggable) {
|
||||
type = ExposureUtils.DownloadType.PLUGIN_DOWNLOAD
|
||||
}
|
||||
val isPlatformRecommend = java.lang.Boolean.parseBoolean(downloadEntity.getMetaExtra(Constants.IS_PLATFORM_RECOMMEND))
|
||||
val isPlatformRecommend =
|
||||
java.lang.Boolean.parseBoolean(downloadEntity.getMetaExtra(Constants.IS_PLATFORM_RECOMMEND))
|
||||
ExposureUtils.logADownloadCompleteExposureEvent(
|
||||
GameEntity(
|
||||
id = downloadEntity.gameId,
|
||||
|
||||
@ -90,6 +90,7 @@ public class EntranceUtils {
|
||||
context.startActivity(SplashScreenActivity.getSplashScreenIntent(context, bundle));
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveShortcut(String activityName, @Nullable Bundle bundle) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
if (activityName.contains("MainActivity")) {
|
||||
|
||||
@ -9,6 +9,7 @@ import androidx.appcompat.app.AppCompatActivity
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.ShellActivity
|
||||
import com.gh.gamecenter.VerifyPhoneActivity
|
||||
import com.gh.gamecenter.WebActivity
|
||||
import com.gh.gamecenter.common.avoidcallback.AvoidOnResultManager
|
||||
import com.gh.gamecenter.common.avoidcallback.Callback
|
||||
@ -20,6 +21,7 @@ import com.gh.gamecenter.common.utils.toColor
|
||||
import com.gh.gamecenter.common.utils.toObject
|
||||
import com.gh.gamecenter.entity.ErrorEntity
|
||||
import com.halo.assistant.fragment.user.UserInfoEditFragment
|
||||
import com.halo.assistant.fragment.user.VerifyPhoneFragment
|
||||
import com.lightgame.utils.AppManager
|
||||
import com.lightgame.utils.Utils
|
||||
import retrofit2.HttpException
|
||||
@ -65,7 +67,14 @@ object ErrorHelper {
|
||||
* [showHighPriorityHint] 用来标识有同样错误码可以触发两种处理时,为 true 时选择重要的
|
||||
*/
|
||||
@JvmStatic
|
||||
fun handleError(context: Context, errorString: String?, showHighPriorityHint: Boolean = false, realNameConfirmListener: ConfirmListener? = null) {
|
||||
@JvmOverloads
|
||||
fun handleError(
|
||||
context: Context,
|
||||
errorString: String?,
|
||||
showHighPriorityHint: Boolean = false,
|
||||
realNameConfirmListener: ConfirmListener? = null,
|
||||
entrance: String = ""
|
||||
) {
|
||||
val errorEntity = errorString?.toObject<ErrorEntity>()
|
||||
|
||||
if (errorEntity == null) {
|
||||
@ -78,7 +87,7 @@ object ErrorHelper {
|
||||
return
|
||||
}
|
||||
|
||||
handleError(context, showHighPriorityHint, errorEntity, realNameConfirmListener)
|
||||
handleError(context, showHighPriorityHint, errorEntity, realNameConfirmListener, entrance)
|
||||
}
|
||||
|
||||
/***
|
||||
@ -102,7 +111,8 @@ object ErrorHelper {
|
||||
context: Context,
|
||||
showHighPriorityHint: Boolean = false,
|
||||
errorEntity: ErrorEntity,
|
||||
realNameConfirmListener: ConfirmListener? = null
|
||||
realNameConfirmListener: ConfirmListener? = null,
|
||||
entrance: String = ""
|
||||
) {
|
||||
when (errorEntity.code) {
|
||||
403050,
|
||||
@ -159,17 +169,7 @@ object ErrorHelper {
|
||||
403115 -> Utils.toast(context, "请求太频繁了,稍微休息一下")
|
||||
403119 -> Utils.toast(context, "不能重复修改实名")
|
||||
|
||||
403020 -> if (showHighPriorityHint) {
|
||||
DialogHelper.showDialog(
|
||||
context,
|
||||
"提醒",
|
||||
"提问过于频繁,请先休息一下哦",
|
||||
"知道了", "",
|
||||
extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true)
|
||||
)
|
||||
} else {
|
||||
Utils.toast(context, R.string.comment_failed_toofrequent)
|
||||
}
|
||||
403020 -> handleAskFrequentlyError(context, showHighPriorityHint)
|
||||
|
||||
403021 -> Utils.toast(context, R.string.comment_failed_illegal)
|
||||
|
||||
@ -179,51 +179,152 @@ object ErrorHelper {
|
||||
// 多设备登录同一帐号,不需要这里处理
|
||||
}
|
||||
|
||||
403209 -> {
|
||||
DialogHelper.showDialog(
|
||||
context,
|
||||
"实名提醒",
|
||||
errorEntity.data?.title ?: "",
|
||||
"前往实名认证", "以后再说",
|
||||
uiModificationCallback = { binding ->
|
||||
binding.hintTv.visibility = View.VISIBLE
|
||||
binding.hintTv.layoutParams =
|
||||
(binding.hintTv.layoutParams as ViewGroup.MarginLayoutParams).apply { setMargins(0, 8F.dip2px(), 0, 0) }
|
||||
binding.lineView.layoutParams =
|
||||
(binding.lineView.layoutParams as ViewGroup.MarginLayoutParams).apply { setMargins(0, 23F.dip2px(), 0, 0) }
|
||||
binding.hintTv.text = errorEntity.data?.text
|
||||
binding.hintTv.setTextColor(R.color.theme_font.toColor(context))
|
||||
binding.hintTv.setOnClickListener {
|
||||
errorEntity.data?.toLinkEntity()?.let { entity ->
|
||||
DirectUtils.directToLinkPage(context, entity, "实名提醒弹窗", "")
|
||||
}
|
||||
}
|
||||
},
|
||||
confirmClickCallback = {
|
||||
val currentActivity = AppManager.getInstance().currentActivity() ?: return@showDialog
|
||||
AvoidOnResultManager.getInstance(currentActivity as AppCompatActivity)
|
||||
.startForResult(
|
||||
ShellActivity.getIntent(
|
||||
context,
|
||||
ShellActivity.Type.REAL_NAME_INFO,
|
||||
), object : Callback {
|
||||
override fun onActivityResult(resultCode: Int, data: Intent?) {
|
||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
val isAuthSuccess =
|
||||
data.getBooleanExtra(UserInfoEditFragment.AUTH_SUCCESS, false)
|
||||
if (isAuthSuccess) {
|
||||
realNameConfirmListener?.onConfirm()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
}
|
||||
403209 -> handleRealNameError(context, errorEntity, realNameConfirmListener)
|
||||
|
||||
403210 -> handleVerifyPhoneError(context, errorEntity, realNameConfirmListener, entrance)
|
||||
|
||||
else -> Utils.toast(context, R.string.post_failure_hint)
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleAskFrequentlyError(context: Context, showHighPriorityHint: Boolean) {
|
||||
if (showHighPriorityHint) {
|
||||
DialogHelper.showDialog(
|
||||
context,
|
||||
"提醒",
|
||||
"提问过于频繁,请先休息一下哦",
|
||||
"知道了", "",
|
||||
extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true)
|
||||
)
|
||||
} else {
|
||||
Utils.toast(context, R.string.comment_failed_toofrequent)
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleRealNameError(
|
||||
context: Context,
|
||||
errorEntity: ErrorEntity,
|
||||
realNameConfirmListener: ConfirmListener?
|
||||
) {
|
||||
DialogHelper.showDialog(
|
||||
context,
|
||||
"实名提醒",
|
||||
errorEntity.data?.title ?: "",
|
||||
"前往实名认证", "以后再说",
|
||||
uiModificationCallback = { binding ->
|
||||
binding.hintTv.visibility = View.VISIBLE
|
||||
binding.hintTv.layoutParams =
|
||||
(binding.hintTv.layoutParams as ViewGroup.MarginLayoutParams).apply {
|
||||
setMargins(
|
||||
0,
|
||||
8F.dip2px(),
|
||||
0,
|
||||
0
|
||||
)
|
||||
}
|
||||
binding.lineView.layoutParams =
|
||||
(binding.lineView.layoutParams as ViewGroup.MarginLayoutParams).apply {
|
||||
setMargins(
|
||||
0,
|
||||
23F.dip2px(),
|
||||
0,
|
||||
0
|
||||
)
|
||||
}
|
||||
binding.hintTv.text = errorEntity.data?.text
|
||||
binding.hintTv.setTextColor(R.color.theme_font.toColor(context))
|
||||
binding.hintTv.setOnClickListener {
|
||||
errorEntity.data?.toLinkEntity()?.let { entity ->
|
||||
DirectUtils.directToLinkPage(context, entity, "实名提醒弹窗", "")
|
||||
}
|
||||
}
|
||||
},
|
||||
confirmClickCallback = {
|
||||
val currentActivity = AppManager.getInstance().currentActivity() ?: return@showDialog
|
||||
AvoidOnResultManager.getInstance(currentActivity as AppCompatActivity)
|
||||
.startForResult(
|
||||
ShellActivity.getIntent(
|
||||
context,
|
||||
ShellActivity.Type.REAL_NAME_INFO,
|
||||
), object : Callback {
|
||||
override fun onActivityResult(resultCode: Int, data: Intent?) {
|
||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
val isAuthSuccess =
|
||||
data.getBooleanExtra(UserInfoEditFragment.AUTH_SUCCESS, false)
|
||||
if (isAuthSuccess) {
|
||||
realNameConfirmListener?.onConfirm()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
private fun handleVerifyPhoneError(
|
||||
context: Context,
|
||||
errorEntity: ErrorEntity,
|
||||
realNameConfirmListener: ConfirmListener?,
|
||||
entrance: String
|
||||
) {
|
||||
DialogHelper.showDialog(
|
||||
context,
|
||||
"手机号验证",
|
||||
errorEntity.data?.title ?: "",
|
||||
"前往手机号验证", "以后再说",
|
||||
uiModificationCallback = { binding ->
|
||||
binding.hintTv.visibility = View.VISIBLE
|
||||
binding.hintTv.layoutParams =
|
||||
(binding.hintTv.layoutParams as ViewGroup.MarginLayoutParams).apply {
|
||||
setMargins(
|
||||
0,
|
||||
8F.dip2px(),
|
||||
0,
|
||||
0
|
||||
)
|
||||
}
|
||||
binding.lineView.layoutParams =
|
||||
(binding.lineView.layoutParams as ViewGroup.MarginLayoutParams).apply {
|
||||
setMargins(
|
||||
0,
|
||||
23F.dip2px(),
|
||||
0,
|
||||
0
|
||||
)
|
||||
}
|
||||
binding.hintTv.text = errorEntity.data?.text
|
||||
binding.hintTv.setTextColor(R.color.theme_font.toColor(context))
|
||||
binding.hintTv.setOnClickListener {
|
||||
errorEntity.data?.toLinkEntity()?.let { entity ->
|
||||
DirectUtils.directToLinkPage(context, entity, "手机号验证", "")
|
||||
NewFlatLogUtils.logPhoneNumberVerifyDialogClick(entrance, "点击了解更多")
|
||||
}
|
||||
}
|
||||
},
|
||||
confirmClickCallback = {
|
||||
val currentActivity = AppManager.getInstance().currentActivity() ?: return@showDialog
|
||||
AvoidOnResultManager.getInstance(currentActivity as AppCompatActivity)
|
||||
.startForResult(
|
||||
VerifyPhoneActivity.getIntent(context), object : Callback {
|
||||
override fun onActivityResult(resultCode: Int, data: Intent?) {
|
||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
val isVerifySuccess =
|
||||
data.getBooleanExtra(VerifyPhoneFragment.VERIFY_SUCCESS, false)
|
||||
if (isVerifySuccess) {
|
||||
realNameConfirmListener?.onConfirm()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
NewFlatLogUtils.logPhoneNumberVerifyDialogClick(entrance, "前往手机号验证")
|
||||
NewFlatLogUtils.logPhoneNumberVerifyDialogShow("手机号验证弹窗-前往验证")
|
||||
},
|
||||
cancelClickCallback = {
|
||||
NewFlatLogUtils.logPhoneNumberVerifyDialogClick(entrance, "以后再说")
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
private fun handleErrorWithGameCollectionBannedDialog(context: Context, errorEntity: ErrorEntity?) {
|
||||
val bannedType = if (errorEntity?.data?.alwaysBlock == true) {
|
||||
""
|
||||
|
||||
@ -7,7 +7,7 @@ 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.view.EnergyCenterActivity
|
||||
import com.gh.gamecenter.energy.EnergyBridge
|
||||
import com.lightgame.utils.Util_System_Keyboard
|
||||
import com.lzf.easyfloat.EasyFloat
|
||||
import com.lzf.easyfloat.enums.ShowPattern
|
||||
@ -38,55 +38,55 @@ object FloatingBackViewManager {
|
||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN) return
|
||||
|
||||
EasyFloat.with(activity)
|
||||
.setLayout(R.layout.layout_task_back)
|
||||
.setTag(FLOATING_BACK_VIEW)
|
||||
.setAnimator(null)
|
||||
.setGravity(Gravity.TOP.xor(Gravity.START), 0, mLastPositionY)
|
||||
.setSidePattern(SidePattern.LEFT)
|
||||
.setShowPattern(ShowPattern.CURRENT_ACTIVITY)
|
||||
.registerCallback {
|
||||
createResult { _, _, view ->
|
||||
val titleView = view?.findViewById<TextView>(R.id.titleTv)
|
||||
.setLayout(R.layout.layout_task_back)
|
||||
.setTag(FLOATING_BACK_VIEW)
|
||||
.setAnimator(null)
|
||||
.setGravity(Gravity.TOP.xor(Gravity.START), 0, mLastPositionY)
|
||||
.setSidePattern(SidePattern.LEFT)
|
||||
.setShowPattern(ShowPattern.CURRENT_ACTIVITY)
|
||||
.registerCallback {
|
||||
createResult { _, _, view ->
|
||||
val titleView = view?.findViewById<TextView>(R.id.titleTv)
|
||||
|
||||
view?.setOnClickListener {
|
||||
// 先收起键盘
|
||||
Util_System_Keyboard.hideSoftKeyboard(activity)
|
||||
view?.setOnClickListener {
|
||||
// 先收起键盘
|
||||
Util_System_Keyboard.hideSoftKeyboard(activity)
|
||||
|
||||
if (mType == TYPE_ACTIVITY) {
|
||||
titleView?.text = "返回活动"
|
||||
if (mType == TYPE_ACTIVITY) {
|
||||
titleView?.text = "返回活动"
|
||||
|
||||
DirectUtils.directToWebView(activity, mActivityUrl, ("返回活动浮窗"))
|
||||
} else if (mType == TYPE_TASK) {
|
||||
titleView?.text = "返回任务"
|
||||
DirectUtils.directToWebView(activity, mActivityUrl, ("返回活动浮窗"))
|
||||
} else if (mType == TYPE_TASK) {
|
||||
titleView?.text = "返回任务"
|
||||
|
||||
activity.startActivity(EnergyCenterActivity.getIntent(activity))
|
||||
}
|
||||
|
||||
disableBackView()
|
||||
}
|
||||
}
|
||||
|
||||
dragEnd { view ->
|
||||
val statusBarHeight = DisplayUtils.getStatusBarHeight(activity.resources)
|
||||
|
||||
// 记录停止拖动的最后位置
|
||||
val outLocation = IntArray(2)
|
||||
view.getLocationInWindow(outLocation)
|
||||
val yOffset = outLocation[1]
|
||||
|
||||
if (yOffset <= statusBarHeight) {
|
||||
// 判断状态栏是否被消费
|
||||
if (yOffset == view.y.toInt()) {
|
||||
view.y = statusBarHeight.toFloat()
|
||||
} else {
|
||||
view.y = 0F
|
||||
}
|
||||
activity.startActivity(EnergyBridge.getEnergyCenterIntent(activity))
|
||||
}
|
||||
|
||||
mLastPositionY = yOffset
|
||||
disableBackView()
|
||||
}
|
||||
}
|
||||
.show()
|
||||
|
||||
dragEnd { view ->
|
||||
val statusBarHeight = DisplayUtils.getStatusBarHeight(activity.resources)
|
||||
|
||||
// 记录停止拖动的最后位置
|
||||
val outLocation = IntArray(2)
|
||||
view.getLocationInWindow(outLocation)
|
||||
val yOffset = outLocation[1]
|
||||
|
||||
if (yOffset <= statusBarHeight) {
|
||||
// 判断状态栏是否被消费
|
||||
if (yOffset == view.y.toInt()) {
|
||||
view.y = statusBarHeight.toFloat()
|
||||
} else {
|
||||
view.y = 0F
|
||||
}
|
||||
}
|
||||
|
||||
mLastPositionY = yOffset
|
||||
}
|
||||
}
|
||||
.show()
|
||||
}
|
||||
|
||||
/**
|
||||
@ -125,7 +125,7 @@ object FloatingBackViewManager {
|
||||
/**
|
||||
* 返回小浮窗类型是否为活动
|
||||
*/
|
||||
fun isTypeActivity() : Boolean {
|
||||
fun isTypeActivity(): Boolean {
|
||||
return mType == TYPE_ACTIVITY
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user