Compare commits
271 Commits
v4.3.8-218
...
v4.5.2-252
| Author | SHA1 | Date | |
|---|---|---|---|
| 0d9a4baf32 | |||
| 3a9132ff8c | |||
| 02a6ec9f7d | |||
| c779d775e3 | |||
| 3fbcd33f98 | |||
| dbcdd7f3cc | |||
| 69d9854b44 | |||
| 5246d6e743 | |||
| b20d598751 | |||
| 85e9799f20 | |||
| 6b533c8d09 | |||
| 2797135db4 | |||
| 7507a027da | |||
| 9873ae8946 | |||
| a5ef80ba33 | |||
| dfdd12bf18 | |||
| 9daf01d9a5 | |||
| ee7ed1fed2 | |||
| 08474a660e | |||
| d8dfe00057 | |||
| 6bd175f72b | |||
| 72b6b3042a | |||
| 3317b178ac | |||
| c86e7ba6ee | |||
| 14c5e4e963 | |||
| 6db8179f4d | |||
| 65c2571329 | |||
| 4810803988 | |||
| f3f030edb1 | |||
| 2ac2a3bf48 | |||
| cd104e4688 | |||
| e2de8cfb47 | |||
| c9f9451dee | |||
| 73c39edd3f | |||
| 7f739798ab | |||
| e41cf76d26 | |||
| 113d446e47 | |||
| 882ac7d67d | |||
| d94be8092b | |||
| b9138ae810 | |||
| 715cecd44b | |||
| dd756fce00 | |||
| 56a003704d | |||
| 50421e0b70 | |||
| 9f0d00f793 | |||
| a56fd8ff18 | |||
| f86fc7b0e1 | |||
| e6197776ca | |||
| 0415ae261b | |||
| d5313c7f98 | |||
| 360231e01f | |||
| 4d86d6f96b | |||
| dd03daae84 | |||
| 5d285fd60e | |||
| 7d4206bcd8 | |||
| a816636d9a | |||
| c6a5522b35 | |||
| 8b888f0ab4 | |||
| ef41a3aea5 | |||
| ba2206931f | |||
| ef4b7b28d8 | |||
| 4a5f12d341 | |||
| ced96f5f70 | |||
| 4180d87b36 | |||
| 2b7f802584 | |||
| 3e9a348019 | |||
| 9725402623 | |||
| 9827b04057 | |||
| b3052485f5 | |||
| d3dc09d377 | |||
| 58905c14a8 | |||
| aadbbbf2ea | |||
| 5256a9b267 | |||
| 0ded7b33f2 | |||
| cdc3158f30 | |||
| 06de179c9e | |||
| f32dc628ef | |||
| 62e371c928 | |||
| 84bcc481af | |||
| 085ddd4ea6 | |||
| b3e859678e | |||
| 7f586fbf13 | |||
| 9dab3dd263 | |||
| 3ee30f05f0 | |||
| 69c8c51000 | |||
| 28742f54bb | |||
| f62751423d | |||
| b0b699679e | |||
| 3c55284d86 | |||
| b6ae508cf0 | |||
| c13ee31ece | |||
| c87a1ba56e | |||
| 9f07cc7720 | |||
| 7bdfe7cef3 | |||
| 667126f92c | |||
| 0409d33d5e | |||
| 14e8285c0f | |||
| c7d63f9df1 | |||
| e2d9ad07d1 | |||
| 9287b6ac4c | |||
| 450da5e0db | |||
| 0397092414 | |||
| ddc515b490 | |||
| a6edde7853 | |||
| 80282f7bcc | |||
| 664df5cb44 | |||
| 8396a55ed2 | |||
| 5ee3f597bd | |||
| 9c8bd9f85e | |||
| 4321e0a33c | |||
| 6f75229209 | |||
| d6bd561e58 | |||
| c957d7585c | |||
| db0e92fd68 | |||
| 992446cf70 | |||
| dcfa52b05a | |||
| 2a06c41dca | |||
| 24214c5d6b | |||
| c839eff88d | |||
| 663505fdc9 | |||
| 641a820ea5 | |||
| bb3f888f88 | |||
| 75bdf6f251 | |||
| 0cacc15e7d | |||
| e4c2ac0aae | |||
| 7acf4c5941 | |||
| 8b22361213 | |||
| a1dee46436 | |||
| 49bf8c9e30 | |||
| 407686ca5b | |||
| 89b7b45ba0 | |||
| b00e7a2826 | |||
| 383d6e7700 | |||
| edce98e4c6 | |||
| a2c3873c8d | |||
| 7990353d08 | |||
| a7b138b2b2 | |||
| 951768e070 | |||
| 69f29fe83b | |||
| 88e28b2388 | |||
| 538bc6f97c | |||
| b1940125f4 | |||
| e1f8e293c2 | |||
| 0a49f27ed2 | |||
| 5dc7badc97 | |||
| d185d39985 | |||
| d9c98d39b5 | |||
| 6949f2b2ff | |||
| 2141440ec4 | |||
| 464c212638 | |||
| dbe74b2091 | |||
| ba55a5a61c | |||
| 452a94f4a2 | |||
| 310be97fe4 | |||
| 2fc45777e4 | |||
| da283fc1f6 | |||
| fee4e4635c | |||
| ebcd50cdee | |||
| cd922dd286 | |||
| 97598d7330 | |||
| 0db59a56d0 | |||
| bee3f5957e | |||
| 65d4b43c9c | |||
| 41f510d333 | |||
| 64d5af036c | |||
| b4c827bddf | |||
| caf3dfa9ee | |||
| c5c10ab208 | |||
| c2251e1ad6 | |||
| bd6d51dab3 | |||
| 1cf9bfcca3 | |||
| 992ec7bfe8 | |||
| cc39bfd06c | |||
| 15d0ad6f49 | |||
| a2e2379073 | |||
| d2431ed8ff | |||
| 80818dee55 | |||
| f2d0916a16 | |||
| 2fa84e0ce1 | |||
| 6fcd8397b6 | |||
| 3478aaba2f | |||
| 1f0b9a95e2 | |||
| 5cdc1635ca | |||
| c9f5cfd4aa | |||
| d6c1f692be | |||
| 12e6fb8330 | |||
| ad857d4500 | |||
| 43d8d24c1c | |||
| a34ee5a753 | |||
| ca39f723e1 | |||
| 3db784509b | |||
| e8f63ea99f | |||
| 97ac4b03a3 | |||
| 883a948b7b | |||
| 261e0cc45a | |||
| 0357a0a71e | |||
| d87de59427 | |||
| d5ee01a2e1 | |||
| 3563637919 | |||
| d881e08aee | |||
| f5ff838d2f | |||
| 52c1b08e59 | |||
| 652972f49d | |||
| 0d122cf8ba | |||
| 2b115c4058 | |||
| cfca7db4ef | |||
| 5f66c029fb | |||
| 8635652fe2 | |||
| a890ad532c | |||
| 65c9d2be2a | |||
| 9620e26f6a | |||
| e4ca1d8406 | |||
| 74ebaa592b | |||
| f9b689efdb | |||
| ed458f08ad | |||
| 9822646acc | |||
| 4259078420 | |||
| 3b9db4e964 | |||
| b7e6cd08fd | |||
| bba1e6f10c | |||
| 3fe2973968 | |||
| b16d33d9fa | |||
| e1a7ed9049 | |||
| 11354030e8 | |||
| ee109060fc | |||
| eebc0c1096 | |||
| 4ec45e2a27 | |||
| 12143f7f95 | |||
| 7025dc45bd | |||
| 772e7861e2 | |||
| ff71c9a3e8 | |||
| b7001cc996 | |||
| 83658e47f8 | |||
| 0699d3ccc4 | |||
| f80b998e98 | |||
| 91e84be708 | |||
| f589c286c6 | |||
| 379650a0f5 | |||
| 3796eb46bd | |||
| c240048c5e | |||
| 2f81c9240d | |||
| da0dc3df97 | |||
| d73c0f2044 | |||
| a6f9e12082 | |||
| 1086574b33 | |||
| 58631d540c | |||
| 08763aeb2d | |||
| 039d0ca06c | |||
| f39574c8b3 | |||
| 6067a52fb1 | |||
| a1298547d1 | |||
| 6a6378f635 | |||
| 920050efc8 | |||
| 103ecc10d3 | |||
| f90e9a8085 | |||
| caa37ead4b | |||
| d18eeaf346 | |||
| b98d287843 | |||
| 66fb57f708 | |||
| 8001ce2603 | |||
| b1079e84d8 | |||
| 93126517b6 | |||
| 9687ddcd54 | |||
| 04c49cbad7 | |||
| 229eaa0859 | |||
| b2100fe0e5 | |||
| fefe29a0b8 | |||
| 6efc1e06bb | |||
| e51439d584 | |||
| 658fb8579c | |||
| f21d86c8a7 |
135
app/build.gradle
135
app/build.gradle
@ -6,6 +6,8 @@ apply plugin: 'kotlin-kapt'
|
||||
// apkChannelPackage
|
||||
apply plugin: 'channel'
|
||||
|
||||
import groovy.xml.XmlUtil
|
||||
|
||||
//apply from: 'tinker-support.gradle'
|
||||
|
||||
android {
|
||||
@ -18,6 +20,10 @@ android {
|
||||
enabled = true
|
||||
}
|
||||
|
||||
viewBinding {
|
||||
enabled = true
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
@ -125,15 +131,27 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
flavorDimensions "nonsense"
|
||||
flavorDimensions("env")
|
||||
|
||||
sourceSets {
|
||||
publish {
|
||||
java.srcDirs = ['src/main/java']
|
||||
}
|
||||
internal {
|
||||
java.srcDirs = ['src/main/java']
|
||||
}
|
||||
tea {
|
||||
java.srcDirs = ['src/main/java', 'src/tea/java']
|
||||
}
|
||||
gdt {
|
||||
java.srcDirs = ['src/main/java', 'src/gdt/java']
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 多渠道打包,渠道请参考"channel.txt"文件,所有渠道值均通过java code设置
|
||||
*/
|
||||
productFlavors {
|
||||
// publish release host
|
||||
publish {
|
||||
dimension "nonsense"
|
||||
dimension "env"
|
||||
buildConfigField "String", "API_HOST", "\"${API_HOST}\""
|
||||
|
||||
buildConfigField "String", "SENSITIVE_API_HOST", "\"${SENSITIVE_API_HOST}\""
|
||||
@ -144,7 +162,7 @@ android {
|
||||
}
|
||||
// internal test dev host
|
||||
internal {
|
||||
dimension "nonsense"
|
||||
dimension "env"
|
||||
versionNameSuffix "-debug"
|
||||
|
||||
buildConfigField "String", "API_HOST", "\"${DEV_API_HOST}\""
|
||||
@ -155,6 +173,30 @@ android {
|
||||
buildConfigField "String", "UMENG_MESSAGE_SECRET", "\"${DEV_UMENG_MESSAGE_SECRET}\""
|
||||
buildConfigField "String", "BUGLY_APPID", "\"${DEV_BUGLY_APPID}\""
|
||||
}
|
||||
|
||||
tea {
|
||||
dimension "env"
|
||||
|
||||
buildConfigField "String", "API_HOST", "\"${API_HOST}\""
|
||||
|
||||
buildConfigField "String", "SENSITIVE_API_HOST", "\"${SENSITIVE_API_HOST}\""
|
||||
|
||||
buildConfigField "String", "UMENG_APPKEY", "\"${UMENG_APPKEY}\""
|
||||
buildConfigField "String", "UMENG_MESSAGE_SECRET", "\"${UMENG_MESSAGE_SECRET}\""
|
||||
buildConfigField "String", "BUGLY_APPID", "\"${BUGLY_APPID}\""
|
||||
}
|
||||
|
||||
gdt {
|
||||
dimension "env"
|
||||
|
||||
buildConfigField "String", "API_HOST", "\"${API_HOST}\""
|
||||
|
||||
buildConfigField "String", "SENSITIVE_API_HOST", "\"${SENSITIVE_API_HOST}\""
|
||||
|
||||
buildConfigField "String", "UMENG_APPKEY", "\"${UMENG_APPKEY}\""
|
||||
buildConfigField "String", "UMENG_MESSAGE_SECRET", "\"${UMENG_MESSAGE_SECRET}\""
|
||||
buildConfigField "String", "BUGLY_APPID", "\"${BUGLY_APPID}\""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -184,6 +226,7 @@ repositories {
|
||||
dependencies {
|
||||
|
||||
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
|
||||
gdtImplementation fileTree(include: ['*.jar', '*.aar'], dir: 'src/gdt/libs')
|
||||
|
||||
testImplementation 'junit:junit:4.12'
|
||||
|
||||
@ -192,6 +235,7 @@ dependencies {
|
||||
debugImplementation "com.facebook.stetho:stetho-okhttp3:${stetho}"
|
||||
debugImplementation "com.squareup.okhttp3:logging-interceptor:${okHttp}"
|
||||
debugImplementation "com.gu.android:toolargetool:${toolargetool}"
|
||||
debugImplementation "com.github.nichbar:WhatTheStack:$whatTheStack"
|
||||
|
||||
implementation "androidx.core:core:${core}"
|
||||
implementation "androidx.fragment:fragment:${fragment}"
|
||||
@ -288,7 +332,7 @@ dependencies {
|
||||
|
||||
debugImplementation "com.github.nichbar.chucker:library:$chucker"
|
||||
releaseImplementation "com.github.nichbar.chucker:library-no-op:$chucker"
|
||||
// implementation "com.bytedance.applog:RangersAppLog-Lite-cn:$bytedanceApplog"
|
||||
teaImplementation "com.bytedance.applog:RangersAppLog-Lite-cn:$bytedanceApplog"
|
||||
// implementation "com.bytedance.ies.ugc.aweme:opensdk-china-external:$bytedanceAweme"
|
||||
// implementation "com.bytedance.ies.ugc.aweme:opensdk-common:$bytedanceAweme"
|
||||
|
||||
@ -298,6 +342,8 @@ dependencies {
|
||||
|
||||
implementation "net.lingala.zip4j:zip4j:${zip4j}"
|
||||
|
||||
implementation "io.sentry:sentry-android:$sentry"
|
||||
|
||||
implementation("com.github.piasy:BigImageViewer:$bigImageViewer", {
|
||||
exclude group: 'com.squareup.okhttp3'
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
@ -370,3 +416,78 @@ if (propFile.exists()) {
|
||||
// task.name.startsWith('merge') && task.name.endsWith('Resources')
|
||||
// }.each { t -> t.dependsOn generateMetaJson }
|
||||
//}
|
||||
|
||||
|
||||
project.afterEvaluate {
|
||||
def variants = null
|
||||
try {
|
||||
variants = android.applicationVariants
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace()
|
||||
try {
|
||||
variants = android.libraryVariants
|
||||
} catch (Throwable tt) {
|
||||
tt.printStackTrace()
|
||||
}
|
||||
}
|
||||
if (variants != null) {
|
||||
variants.all { variant ->
|
||||
variant.outputs.each { output ->
|
||||
def task = output.processManifestProvider.get()
|
||||
if (task == null) {
|
||||
return
|
||||
}
|
||||
|
||||
/**
|
||||
* 为 Manifest 的 Activity 的 configChanges 添加自己手动处理 configurationChanges 配置 [https://developer.android.com/guide/topics/resources/runtime-changes]
|
||||
* AGP 4.1.0 从 ProcessManifest task 里拿 manifest 的 API 变更调整可以参考这里 [https://github.com/Tencent/tinker/pull/1476/commits/d71645729b13d545ca4ba6826f93fbf558751434]
|
||||
* (搞半天还是不会抽离方法,有空再把 gradle 改成用 kotlin 实现吧)
|
||||
*/
|
||||
task.doLast {
|
||||
def manifestFile = new File(multiApkManifestOutputDirectory.get().asFile, "AndroidManifest.xml")
|
||||
if (manifestFile == null || !manifestFile.exists()) {
|
||||
return
|
||||
}
|
||||
def parser = new XmlSlurper(false, true)
|
||||
def manifest = parser.parse(manifestFile)
|
||||
def app = manifest.'application'[0]
|
||||
app.'activity'.each { act ->
|
||||
String value = act.attributes()['android:configChanges']
|
||||
if (value == null || value.isEmpty()) {
|
||||
value = "keyboardHidden|orientation|screenSize|screenLayout|density|fontScale|locale"
|
||||
act.attributes()['androidconfigChanges'] = value
|
||||
} else {
|
||||
String[] valueSplit = value.split("\\|")
|
||||
if (!valueSplit.contains("keyboardHidden")) {
|
||||
value += "|keyboardHidden"
|
||||
}
|
||||
if (!valueSplit.contains("orientation")) {
|
||||
value += "|orientation"
|
||||
}
|
||||
if (!valueSplit.contains("screenSize")) {
|
||||
value += "|screenSize"
|
||||
}
|
||||
if (!valueSplit.contains("screenLayout")) {
|
||||
value += "|screenLayout"
|
||||
}
|
||||
if (!valueSplit.contains("density")) {
|
||||
value += "|density"
|
||||
}
|
||||
if (!valueSplit.contains("fontScale")) {
|
||||
value += "|fontScale"
|
||||
}
|
||||
if (!valueSplit.contains("locale")) {
|
||||
value += "|locale"
|
||||
}
|
||||
act.attributes()['android:configChanges'] = value
|
||||
}
|
||||
}
|
||||
|
||||
def tmpManifest = XmlUtil.serialize(manifest).replaceAll("androidconfigChanges", "android:configChanges")
|
||||
manifest = parser.parseText(tmpManifest)
|
||||
manifestFile.setText(XmlUtil.serialize(manifest), "utf-8")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -241,6 +241,13 @@
|
||||
-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.** { *; }
|
||||
@ -258,4 +265,7 @@
|
||||
|
||||
-keep class com.alibaba.sdk.android.**{*;}
|
||||
-keep class com.ut.**{*;}
|
||||
-keep class com.ta.**{*;}
|
||||
-keep class com.ta.**{*;}
|
||||
|
||||
-keep class com.gh.gamecenter.GdtHelper { *; }
|
||||
-keep class com.gh.gamecenter.TeaHelper { *; }
|
||||
75
app/src/gdt/java/com/gh/gamecenter/GdtHelper.kt
Normal file
75
app/src/gdt/java/com/gh/gamecenter/GdtHelper.kt
Normal file
@ -0,0 +1,75 @@
|
||||
package com.gh.gamecenter
|
||||
|
||||
import android.app.Application
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
import com.gh.common.util.ToastUtils
|
||||
import com.lightgame.utils.Utils
|
||||
import com.qq.gdt.action.GDTAction
|
||||
import org.json.JSONObject
|
||||
|
||||
/**
|
||||
* 广点通辅助类 [https://gitlab.ghzhushou.com/pm/halo-app-issues/issues/403]
|
||||
*
|
||||
* 更换帐号 [https://gitlab.ghzs.com/pm/yunying/issues/893]
|
||||
*/
|
||||
object GdtHelper {
|
||||
|
||||
const val NETWORK_TYPE = "NETWORK_TYPE"
|
||||
const val PAGE_TYPE = "PAGE_TYPE"
|
||||
const val CONTENT_TYPE = "CONTENT_TYPE"
|
||||
const val CONTENT_ID = "CONTENT_ID"
|
||||
const val KEYWORD = "KEYWORD"
|
||||
const val GAME_ID = "GAME_ID"
|
||||
const val SCORE = "SCORE"
|
||||
const val PLATFORM = "PLATFORM"
|
||||
|
||||
@JvmStatic
|
||||
fun init(application: Application, channel: String) {
|
||||
if (shouldUseGdtHelper()) {
|
||||
if (channel == "GH_728") {
|
||||
GDTAction.init(application, "1111012969", "9d3d9da5b0948a317c03d08f14d445dc")
|
||||
} else if (channel == "GH_729") {
|
||||
GDTAction.init(application, "1111013063", "f53dabf458a356b101d99fc4069eb7f1")
|
||||
} else {
|
||||
GDTAction.init(application, "1110680399", "f5ddaafbf520d7d7385499232a408d0a")
|
||||
}
|
||||
}
|
||||
Utils.log("init GdtHelper")
|
||||
}
|
||||
|
||||
// fun logAction(type: String) {
|
||||
// if (shouldUseGdtHelper()) {
|
||||
// GDTAction.logAction(type)
|
||||
// Utils.log("GDT", type)
|
||||
// }
|
||||
// }
|
||||
@JvmStatic
|
||||
fun logAction(type: String, vararg kv: String?) {
|
||||
try {
|
||||
val actionParam = JSONObject()
|
||||
for (i in kv.indices) {
|
||||
if (i % 2 != 0) {
|
||||
val key = kv[i - 1]
|
||||
val value = kv[i]
|
||||
if (!TextUtils.isEmpty(key) && !TextUtils.isEmpty(value)) {
|
||||
actionParam.put(key, value)
|
||||
}
|
||||
}
|
||||
}
|
||||
Utils.log("GDT", "$type + [${kv.joinToString(" , ")}]")
|
||||
GDTAction.logAction(type, actionParam)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
// TODO 确认开启的渠道条件
|
||||
private fun shouldUseGdtHelper(): Boolean {
|
||||
return true
|
||||
//
|
||||
// val channel = HaloApp.getInstance().channel
|
||||
// return !(TextUtils.isEmpty(channel) || channel.contains("GDT".toLowerCase(Locale.CHINA)))
|
||||
}
|
||||
|
||||
}
|
||||
BIN
app/src/gdt/libs/GDTActionSDK.min.1.6.10.aar
Normal file
BIN
app/src/gdt/libs/GDTActionSDK.min.1.6.10.aar
Normal file
Binary file not shown.
@ -9,8 +9,6 @@
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<!-- 允许应用程序读取扩展存储器 -->
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<!-- 允许挂载和反挂载文件系统可移动存储 -->
|
||||
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
|
||||
<!-- 允许应用程序访问Wi-Fi网络状态信息 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<!-- 允许应用程序获取网络信息状态 -->
|
||||
@ -25,15 +23,15 @@
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
|
||||
<!-- 允许应用程序打开系统窗口,显示其他应用程序 -->
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
<!-- 修改系统设置的权限 -->
|
||||
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
|
||||
<!-- 创建快捷方式的权限 -->
|
||||
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
|
||||
|
||||
<uses-permission
|
||||
android:name="android.permission.PACKAGE_USAGE_STATS"
|
||||
tools:ignore="ProtectedPermissions" />
|
||||
|
||||
<!-- bugly with tinker -->
|
||||
<uses-permission android:name="android.permission.READ_LOGS" />
|
||||
<!-- <uses-permission android:name="android.permission.READ_LOGS" />-->
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
|
||||
<!--可选,穿山甲提供“获取地理位置权限”和“不给予地理位置权限,开发者传入地理位置参数”两种方式上报用户位置,两种方式均可不选,添加位置权限或参数将帮助投放定位广告-->
|
||||
@ -45,13 +43,13 @@
|
||||
|
||||
<uses-sdk tools:overrideLibrary="com.shuyu.gsyvideoplayer,
|
||||
com.shuyu.gsyvideoplayer.lib,
|
||||
com.haroldadmin.whatthestack,
|
||||
com.shuyu.gsyvideoplayer.armv7a,
|
||||
com.shuyu.gsyvideoplayer.x86,
|
||||
com.shuyu.gsy.base,
|
||||
com.google.android.exoplayer2,
|
||||
tv.danmaku.ijk.media.exo2,
|
||||
pl.droidsonroids.gif,
|
||||
com.donkingliang.consecutivescroller" />
|
||||
pl.droidsonroids.gif" />
|
||||
|
||||
<!-- 去掉 SDK 一些流氓权限 -->
|
||||
<uses-permission
|
||||
@ -77,6 +75,10 @@
|
||||
tools:replace="android:allowBackup"
|
||||
tools:targetApi="n">
|
||||
|
||||
<meta-data
|
||||
android:name="io.sentry.auto-init"
|
||||
android:value="false" />
|
||||
|
||||
<!--android:launchMode = "singleTask"-->
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.SplashScreenActivity"
|
||||
@ -460,7 +462,7 @@
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.video.upload.view.UploadVideoActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden"/>
|
||||
android:windowSoftInputMode="stateHidden" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.video.game.GameVideoActivity"
|
||||
@ -575,18 +577,38 @@
|
||||
<activity
|
||||
android:name=".personalhome.background.BackgroundClipActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/TransparentStatusBarAndNavigationBar"/>
|
||||
android:theme="@style/TransparentStatusBarAndNavigationBar" />
|
||||
|
||||
<activity
|
||||
android:name=".personalhome.excellentcomments.ExcellentCommentsActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<!-- 使用小米/华为推送弹窗功能提高推送成功率-->
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.PushProxyActivity"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTask"
|
||||
android:theme="@android:style/Theme.Translucent" />
|
||||
android:name=".simulatorgame.SimulatorGameActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".simulatorgame.SimulatorManagementActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".catalog.CatalogActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".catalog.NewCatalogListActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".forum.search.ForumOrUserSearchActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<!-- <!– 使用小米/华为推送弹窗功能提高推送成功率–>-->
|
||||
<!-- <activity-->
|
||||
<!-- android:name="com.gh.gamecenter.PushProxyActivity"-->
|
||||
<!-- android:exported="true"-->
|
||||
<!-- android:launchMode="singleTask"-->
|
||||
<!-- android:theme="@android:style/Theme.Translucent" />-->
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.SkipActivity"
|
||||
@ -598,6 +620,14 @@
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<data android:scheme="market" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
@ -608,11 +638,11 @@
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@android:style/Theme.Translucent.NoTitleBar"></activity>
|
||||
|
||||
<!-- <activity-->
|
||||
<!-- android:name="${applicationId}.douyinapi.DouYinEntryActivity"-->
|
||||
<!-- android:launchMode="singleTask"-->
|
||||
<!-- android:taskAffinity="${applicationId}"-->
|
||||
<!-- android:exported="true" />-->
|
||||
<!-- <activity-->
|
||||
<!-- android:name="${applicationId}.douyinapi.DouYinEntryActivity"-->
|
||||
<!-- android:launchMode="singleTask"-->
|
||||
<!-- android:taskAffinity="${applicationId}"-->
|
||||
<!-- android:exported="true" />-->
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
@ -647,45 +677,45 @@
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<!-- <receiver android:name="com.gh.gamecenter.receiver.UmengMessageReceiver">-->
|
||||
<!-- <intent-filter>-->
|
||||
<!-- <action android:name="com.gh.gamecenter.UMENG" />-->
|
||||
<!-- </intent-filter>-->
|
||||
<!-- </receiver>-->
|
||||
<!-- <receiver android:name="com.gh.gamecenter.receiver.UmengMessageReceiver">-->
|
||||
<!-- <intent-filter>-->
|
||||
<!-- <action android:name="com.gh.gamecenter.UMENG" />-->
|
||||
<!-- </intent-filter>-->
|
||||
<!-- </receiver>-->
|
||||
|
||||
<!-- <!–魅族push应用定义消息receiver声明 –>-->
|
||||
<!-- <receiver android:name="com.gh.gamecenter.receiver.UmengMeizuPushReceiver">-->
|
||||
<!-- <intent-filter>-->
|
||||
<!-- <!– 接收push消息 –>-->
|
||||
<!-- <action android:name="com.meizu.flyme.push.intent.MESSAGE" />-->
|
||||
<!-- <!– 接收register消息 –>-->
|
||||
<!-- <action android:name="com.meizu.flyme.push.intent.REGISTER.FEEDBACK" />-->
|
||||
<!-- <!– 接收unregister消息–>-->
|
||||
<!-- <action android:name="com.meizu.flyme.push.intent.UNREGISTER.FEEDBACK" />-->
|
||||
<!-- <!– 兼容低版本Flyme3推送服务配置 –>-->
|
||||
<!-- <action android:name="com.meizu.c2dm.intent.REGISTRATION" />-->
|
||||
<!-- <action android:name="com.meizu.c2dm.intent.RECEIVE" />-->
|
||||
<!-- <!–魅族push应用定义消息receiver声明 –>-->
|
||||
<!-- <receiver android:name="com.gh.gamecenter.receiver.UmengMeizuPushReceiver">-->
|
||||
<!-- <intent-filter>-->
|
||||
<!-- <!– 接收push消息 –>-->
|
||||
<!-- <action android:name="com.meizu.flyme.push.intent.MESSAGE" />-->
|
||||
<!-- <!– 接收register消息 –>-->
|
||||
<!-- <action android:name="com.meizu.flyme.push.intent.REGISTER.FEEDBACK" />-->
|
||||
<!-- <!– 接收unregister消息–>-->
|
||||
<!-- <action android:name="com.meizu.flyme.push.intent.UNREGISTER.FEEDBACK" />-->
|
||||
<!-- <!– 兼容低版本Flyme3推送服务配置 –>-->
|
||||
<!-- <action android:name="com.meizu.c2dm.intent.REGISTRATION" />-->
|
||||
<!-- <action android:name="com.meizu.c2dm.intent.RECEIVE" />-->
|
||||
|
||||
<!-- <category android:name="${applicationId}" />-->
|
||||
<!-- </intent-filter>-->
|
||||
<!-- </receiver>-->
|
||||
<!-- <category android:name="${applicationId}" />-->
|
||||
<!-- </intent-filter>-->
|
||||
<!-- </receiver>-->
|
||||
|
||||
<receiver
|
||||
android:name="com.gh.common.im.ImReceiver"
|
||||
android:enabled="true">
|
||||
<intent-filter android:priority="2147483647">
|
||||
<action android:name="com.gh.im" />
|
||||
<action android:name="action_finish" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<!-- <receiver-->
|
||||
<!-- android:name="com.gh.common.im.ImReceiver"-->
|
||||
<!-- android:enabled="true">-->
|
||||
<!-- <intent-filter android:priority="2147483647">-->
|
||||
<!-- <action android:name="com.gh.im" />-->
|
||||
<!-- <action android:name="action_finish" />-->
|
||||
<!-- </intent-filter>-->
|
||||
<!-- </receiver>-->
|
||||
|
||||
<!-- <meta-data-->
|
||||
<!-- android:name="com.huawei.hms.client.appid"-->
|
||||
<!-- android:value="@string/huawei_push_appid" />-->
|
||||
<!-- <meta-data-->
|
||||
<!-- android:name="com.huawei.hms.client.appid"-->
|
||||
<!-- android:value="@string/huawei_push_appid" />-->
|
||||
|
||||
<!-- <service-->
|
||||
<!-- android:name="com.gh.base.GHUmengNotificationService"-->
|
||||
<!-- android:permission="android.permission.BIND_JOB_SERVICE" />-->
|
||||
<!-- <service-->
|
||||
<!-- android:name="com.gh.base.GHUmengNotificationService"-->
|
||||
<!-- android:permission="android.permission.BIND_JOB_SERVICE" />-->
|
||||
|
||||
<!--<service android:name = "com.gh.gamecenter.statistics.AppStaticService" />-->
|
||||
|
||||
|
||||
@ -1,40 +0,0 @@
|
||||
emoji_kf_1.png,:smile:
|
||||
emoji_kf_2.png,:smiley:
|
||||
emoji_kf_3.png,:laughing:
|
||||
emoji_kf_4.png,:blush:
|
||||
emoji_kf_5.png,:heart_eyes:
|
||||
emoji_kf_6.png,:smirk:
|
||||
emoji_kf_7.png,:flushed:
|
||||
emoji_kf_8.png,:kissing_heart:
|
||||
emoji_kf_9.png,:grin:
|
||||
emoji_kf_10.png,:wink:
|
||||
emoji_kf_11.png,:stuck_out_tongue_winking_eye:
|
||||
emoji_kf_12.png,:stuck_out_tongue_closed eyes:
|
||||
emoji_kf_13.png,:worried:
|
||||
emoji_kf_14.png,:sleeping:
|
||||
emoji_kf_15.png,:expressionless:
|
||||
emoji_kf_16.png,:sweat_smile:
|
||||
emoji_kf_17.png,:joy:
|
||||
emoji_kf_18.png,:cold_sweat:
|
||||
emoji_kf_19.png,:sob:
|
||||
emoji_kf_20.png,:angry:
|
||||
emoji_kf_21.png,:mask:
|
||||
emoji_kf_22.png,:scream:
|
||||
emoji_kf_23.png,:sunglasses:
|
||||
emoji_kf_24.png,:heart:
|
||||
emoji_kf_25.png,:broken_heart:
|
||||
emoji_kf_26.png,:star:
|
||||
emoji_kf_27.png,:anger:
|
||||
emoji_kf_28.png,:exclamation:
|
||||
emoji_kf_29.png,:question:
|
||||
emoji_kf_30.png,:zzz:
|
||||
emoji_kf_31.png,:thumbsup:
|
||||
emoji_kf_32.png,:thumbsdown:
|
||||
emoji_kf_33.png,:ok_hand:
|
||||
emoji_kf_34.png,:punch:
|
||||
emoji_kf_35.png,:yeah:
|
||||
emoji_kf_36.png,:clap:
|
||||
emoji_kf_37.png,:muscle:
|
||||
emoji_kf_38.png,:pray:
|
||||
emoji_kf_39.png,:skull:
|
||||
emoji_kf_40.png,:trollface:
|
||||
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 15 KiB |
@ -1,5 +0,0 @@
|
||||
# This is a simple Microlog configuration file
|
||||
microlog.level=DEBUG
|
||||
microlog.appender=LogCatAppender;FileAppender
|
||||
microlog.formatter=PatternFormatter
|
||||
microlog.formatter.PatternFormatter.pattern=%c [%P] %m %T
|
||||
@ -26,6 +26,8 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import io.sentry.core.Sentry;
|
||||
|
||||
public class AppUncaughtHandler implements UncaughtExceptionHandler {
|
||||
|
||||
private Context mContext;
|
||||
@ -45,7 +47,9 @@ public class AppUncaughtHandler implements UncaughtExceptionHandler {
|
||||
Looper.loop();
|
||||
}
|
||||
});
|
||||
|
||||
saveLocalLog(mContext, ex);
|
||||
Sentry.captureException(ex);
|
||||
restart(mContext);
|
||||
}
|
||||
|
||||
|
||||
@ -32,13 +32,17 @@ import com.gh.common.util.ExtensionsKt;
|
||||
import com.gh.common.util.MtaHelper;
|
||||
import com.gh.common.util.PackageInstaller;
|
||||
import com.gh.common.util.RunningUtils;
|
||||
import com.gh.common.util.SPUtils;
|
||||
import com.gh.common.util.ShareUtils;
|
||||
import com.gh.common.util.StringUtils;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.LoginActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.SplashScreenActivity;
|
||||
import com.gh.gamecenter.eventbus.EBShowDialog;
|
||||
import com.lightgame.BaseAppCompatActivity;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
import com.lightgame.download.FileUtils;
|
||||
import com.lightgame.utils.Utils;
|
||||
import com.tencent.tauth.Tencent;
|
||||
@ -122,6 +126,23 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy
|
||||
if (BuildConfig.DEBUG) {
|
||||
Utils.log("ACTIVITY_ENTRANCE -> " + mEntrance);
|
||||
}
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
String xapkUnzipActivity = SPUtils.getString(Constants.SP_XAPK_UNZIP_ACTIVITY);
|
||||
String xapkUrl = SPUtils.getString(Constants.SP_XAPK_URL);
|
||||
Utils.log("页面重建了--" + xapkUnzipActivity + "--" + xapkUrl);
|
||||
if (this.getClass().getName().equals(SplashScreenActivity.class.getName())) {
|
||||
SPUtils.setString(Constants.SP_XAPK_UNZIP_ACTIVITY, "");
|
||||
SPUtils.setString(Constants.SP_XAPK_URL, "");
|
||||
return;
|
||||
}
|
||||
if (this.getClass().getName().equals(xapkUnzipActivity) && !TextUtils.isEmpty(xapkUrl)) {
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance(this).getDownloadEntityByUrl(xapkUrl);
|
||||
PackageInstaller.install(this, downloadEntity, false);
|
||||
SPUtils.setString(Constants.SP_XAPK_UNZIP_ACTIVITY, "");
|
||||
SPUtils.setString(Constants.SP_XAPK_URL, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
|
||||
@ -4,7 +4,6 @@ import android.app.Activity;
|
||||
import android.app.Application.ActivityLifecycleCallbacks;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.gh.common.im.ImManager;
|
||||
import com.gh.common.notifier.Notifier;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.download.DownloadManager;
|
||||
@ -39,7 +38,6 @@ public class GHActivityLifecycleCallbacksImpl implements ActivityLifecycleCallba
|
||||
|
||||
if (HaloApp.isUserAcceptPrivacyPolicy(activity)) {
|
||||
DataUtils.onResume(activity);
|
||||
ImManager.updateFloatingWindow();
|
||||
//FIXME 这里应该只是部分Activity需要
|
||||
try {
|
||||
// 初始化gameMap
|
||||
|
||||
@ -81,8 +81,13 @@ public class WaitingDialogFragment extends BaseDialogFragment {
|
||||
|
||||
@Override
|
||||
public void dismiss() {
|
||||
dismissAllowingStateLoss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismissAllowingStateLoss() {
|
||||
mBackListener = null;
|
||||
super.dismiss();
|
||||
super.dismissAllowingStateLoss();
|
||||
}
|
||||
|
||||
public static class WaitingDialogData {
|
||||
|
||||
@ -252,6 +252,11 @@ class DefaultJsApi(var context: Context) {
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun openInNewWebview(url: Any) {
|
||||
runOnUiThread { DirectUtils.directToWebView(context, url.toString(), "内部网页") }
|
||||
}
|
||||
|
||||
@Keep
|
||||
internal data class ImageEvent(var imageList: ArrayList<String> = arrayListOf(), var position: Int = 0)
|
||||
|
||||
|
||||
@ -51,6 +51,9 @@ public class Constants {
|
||||
|
||||
public static final String EXTRA_DOWNLOAD_TYPE = "extra_download_type";
|
||||
public static final String SILENT_UPDATE = "静默更新";
|
||||
public static final String SIMULATOR_DOWNLOAD = "下载模拟器";
|
||||
public static final String SIMULATOR_GAME = "simulator_game";
|
||||
public static final String SIMULATOR_DOWNLOAD_START_TIME = "simulator_download_start_time";
|
||||
public static final String LAST_GHZS_UPDATE_FILE_SIZE = "last_ghzs_update_file_size";
|
||||
|
||||
// 新用户首次启动光环的时间
|
||||
@ -118,9 +121,19 @@ public class Constants {
|
||||
public static final String SP_WECHAT_SHOW_BIND_PHONE_TIME = "wechat_show_bind_phone_time" + HaloApp.getInstance().getGid();
|
||||
public static final String SP_WEIBO_SHOW_BIND_PHONE_TIME = "weibo_show_bind_phone_time" + HaloApp.getInstance().getGid();
|
||||
public static final String SP_DOUYIN_SHOW_BIND_PHONE_TIME = "douyin_show_bind_phone_time" + HaloApp.getInstance().getGid();
|
||||
//隐私政策是否有更新
|
||||
public static final String SP_PRIVACY_CURRENT_MD5 = "sp_privacy_current_md5";
|
||||
public static final String SP_PRIVACY_MINE_MD5 = "sp_privacy_mine_md5";
|
||||
public static final String SP_PRIVACY_SETTING_MD5 = "sp_privacy_setting_md5";
|
||||
public static final String SP_PRIVACY_MD5 = "sp_privacy_md5";
|
||||
|
||||
public static final String SP_IS_USER_ACCEPTED_PRIVACY_STATEMENT = "has_user_accepted_privacy_statement";
|
||||
public static final String SP_BRAND_NEW_USER = "brand_new_user";
|
||||
//包名检测是否点击不再提示
|
||||
public static final String SP_PACKAGE_CHECK = "package_check";
|
||||
|
||||
public static final String SP_XAPK_UNZIP_ACTIVITY = "xapk_unzip_activity";
|
||||
public static final String SP_XAPK_URL = "xapk_url";
|
||||
|
||||
//手机号码匹配规则
|
||||
public static final String REGEX_MOBILE = "^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$";
|
||||
|
||||
@ -24,10 +24,13 @@ import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.gh.base.OnViewClickListener;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.dialog.CertificationDialog;
|
||||
import com.gh.common.dialog.PackageCheckDialogFragment;
|
||||
import com.gh.common.dialog.ReserveDialogFragment;
|
||||
import com.gh.common.exposure.ExposureEvent;
|
||||
import com.gh.common.history.HistoryHelper;
|
||||
import com.gh.common.repository.ReservationRepository;
|
||||
import com.gh.common.simulator.SimulatorDownloadManager;
|
||||
import com.gh.common.simulator.SimulatorGameManager;
|
||||
import com.gh.common.util.CheckLoginUtils;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
@ -42,7 +45,6 @@ import com.gh.common.util.NewsUtils;
|
||||
import com.gh.common.util.NumberUtils;
|
||||
import com.gh.common.util.PackageInstaller;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.PermissionHelper;
|
||||
import com.gh.common.util.PlatformUtils;
|
||||
import com.gh.common.util.ReservationHelper;
|
||||
import com.gh.common.view.DownloadProgressBar;
|
||||
@ -72,6 +74,7 @@ import com.lightgame.utils.Utils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -253,6 +256,14 @@ public class BindingAdapters {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* lazy 的 paddingTop
|
||||
*/
|
||||
@BindingAdapter("lazyPaddingLeft")
|
||||
public static void lazyPaddingLeft(View view, int paddingLeftInDp) {
|
||||
view.setPadding(DisplayUtils.dip2px(paddingLeftInDp), view.getPaddingTop(), view.getPaddingRight(), view.getPaddingBottom());
|
||||
}
|
||||
|
||||
/**
|
||||
* lazy 的 paddingTop
|
||||
*/
|
||||
@ -436,12 +447,23 @@ public class BindingAdapters {
|
||||
case PLUGIN:
|
||||
if (gameEntity.getApk().size() == 1) {
|
||||
ApkEntity apk = gameEntity.getApk().get(0);
|
||||
DownloadDialogHelper.findAvailableDialogAndShow(v.getContext(), gameEntity, apk, () -> {
|
||||
CertificationDialog.showCertificationDialog(v.getContext(), gameEntity, () -> {
|
||||
DialogUtils.showVersionNumberDialog(v.getContext(), gameEntity, () -> {
|
||||
DialogUtils.showOverseaDownloadDialog(v.getContext(), gameEntity, () -> {
|
||||
DialogUtils.checkDownload(v.getContext(), apk.getSize(),
|
||||
isSubscribe -> download(progressBar, gameEntity, traceEvent, isSubscribe, entrance, location));
|
||||
DownloadEntity downloadEntity = SimulatorGameManager.findDownloadEntityByUrl(apk.getUrl());
|
||||
if (gameEntity.getSimulator() != null) {
|
||||
boolean isInstalled = PackageUtils.isInstalledFromAllPackage(v.getContext(), gameEntity.getSimulator().getApk().getPackageName());
|
||||
if (downloadEntity != null && SimulatorGameManager.isSimulatorGame(gameEntity) && !isInstalled) {
|
||||
SimulatorDownloadManager.getInstance().showDownloadDialog(v.getContext(), gameEntity.getSimulator(),
|
||||
SimulatorDownloadManager.SimulatorLocation.LAUNCH, gameEntity.getId(), gameEntity.getName(), null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
PackageCheckDialogFragment.show((AppCompatActivity) v.getContext(), gameEntity.getPackageDialog(), () -> {
|
||||
DownloadDialogHelper.findAvailableDialogAndShow(v.getContext(), gameEntity, apk, () -> {
|
||||
CertificationDialog.showCertificationDialog(v.getContext(), gameEntity, () -> {
|
||||
DialogUtils.showVersionNumberDialog(v.getContext(), gameEntity, () -> {
|
||||
DialogUtils.showOverseaDownloadDialog(v.getContext(), gameEntity, () -> {
|
||||
DialogUtils.checkDownload(v.getContext(), apk.getSize(),
|
||||
isSubscribe -> download(progressBar, gameEntity, traceEvent, isSubscribe, entrance, location));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -461,6 +483,20 @@ public class BindingAdapters {
|
||||
break;
|
||||
case LAUNCH_OR_OPEN:
|
||||
if (gameEntity.getApk().size() == 1) {
|
||||
//启动模拟器游戏
|
||||
if (SimulatorGameManager.isSimulatorGame(gameEntity)) {
|
||||
DownloadEntity downloadEntity = SimulatorGameManager.findDownloadEntityByUrl(gameEntity.getApk().get(0).getUrl());
|
||||
if (downloadEntity != null) {
|
||||
File file = new File(downloadEntity.getPath());
|
||||
if (!file.exists()) {
|
||||
download(progressBar, gameEntity, traceEvent, false, entrance, location);
|
||||
return;
|
||||
}
|
||||
|
||||
SimulatorGameManager.launchSimulatorGame(downloadEntity, gameEntity);
|
||||
}
|
||||
return;
|
||||
}
|
||||
DataUtils.onGameLaunchEvent(v.getContext(), gameEntity.getName(), gameEntity.getApk().get(0).getPlatform(), location);
|
||||
PackageUtils.launchApplicationByPackageName(v.getContext(), gameEntity.getApk().get(0).getPackageName());
|
||||
} else {
|
||||
@ -483,13 +519,11 @@ public class BindingAdapters {
|
||||
break;
|
||||
case RESERVABLE:
|
||||
CheckLoginUtils.checkLogin(progressBar.getContext(), "", () -> {
|
||||
PermissionHelper.checkReadPhoneStatePermissionBeforeAction(progressBar.getContext(), () -> {
|
||||
ReserveDialogFragment dialogFragment = ReserveDialogFragment.getInstance(gameEntity, () -> {
|
||||
LogUtils.logReservation(gameEntity, traceEvent);
|
||||
updateReservation(progressBar, gameEntity);
|
||||
});
|
||||
dialogFragment.show(((AppCompatActivity) progressBar.getContext()).getSupportFragmentManager(), "reserve");
|
||||
ReserveDialogFragment dialogFragment = ReserveDialogFragment.getInstance(gameEntity, () -> {
|
||||
LogUtils.logReservation(gameEntity, traceEvent);
|
||||
updateReservation(progressBar, gameEntity);
|
||||
});
|
||||
dialogFragment.show(((AppCompatActivity) progressBar.getContext()).getSupportFragmentManager(), "reserve");
|
||||
});
|
||||
break;
|
||||
case RESERVED:
|
||||
@ -516,9 +550,12 @@ public class BindingAdapters {
|
||||
HistoryHelper.insertGameEntity(gameEntity);
|
||||
}
|
||||
|
||||
Intent i = new Intent(WebActivity.getIntentForWebGame(progressBar.getContext(), linkEntity.getLink(), gameEntity.getName(), isPlay,linkEntity.getCloseButton()));
|
||||
Intent i = new Intent(WebActivity.getIntentForWebGame(progressBar.getContext(), linkEntity.getLink(), gameEntity.getName(), isPlay, linkEntity.getCloseButton()));
|
||||
progressBar.getContext().startActivity(i);
|
||||
break;
|
||||
case UPDATING:
|
||||
Utils.toast(progressBar.getContext(), "正在加急更新版本,敬请后续留意");
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
@ -548,10 +585,14 @@ public class BindingAdapters {
|
||||
} else {
|
||||
if (offStatus != null && "dialog".equals(offStatus)) {
|
||||
progressBar.setText("查看");
|
||||
progressBar.setDownloadType(DownloadProgressBar.DownloadType.NONE);
|
||||
} else if ("updating".equals(offStatus)) {
|
||||
progressBar.setText("更新中");
|
||||
progressBar.setDownloadType(DownloadProgressBar.DownloadType.UPDATING);
|
||||
} else {
|
||||
progressBar.setText("暂无");
|
||||
progressBar.setDownloadType(DownloadProgressBar.DownloadType.NONE);
|
||||
}
|
||||
progressBar.setDownloadType(DownloadProgressBar.DownloadType.NONE);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -118,7 +118,9 @@ class CertificationDialog(context: Context, private val authDialogEntity: AuthDi
|
||||
|
||||
//跳转登录页面
|
||||
private fun gotoLoginPage() {
|
||||
CheckLoginUtils.checkLogin(AppManager.getInstance().currentActivity() as AppCompatActivity,
|
||||
val currentActivity = AppManager.getInstance().currentActivity() ?: return
|
||||
|
||||
CheckLoginUtils.checkLogin(currentActivity as AppCompatActivity,
|
||||
null, true, "实名认证弹窗") {
|
||||
if (UserManager.getInstance().isAuth) {
|
||||
listener.onConfirm()
|
||||
@ -129,7 +131,9 @@ class CertificationDialog(context: Context, private val authDialogEntity: AuthDi
|
||||
|
||||
//跳转实名认证页面
|
||||
private fun gotoAuthPage() {
|
||||
AvoidOnResultManager.getInstance(AppManager.getInstance().currentActivity() as AppCompatActivity)
|
||||
val currentActivity = AppManager.getInstance().currentActivity() ?: return
|
||||
|
||||
AvoidOnResultManager.getInstance(currentActivity as AppCompatActivity)
|
||||
.startForResult(UserInfoEditActivity.getIntent(context, UserViewModel.TYPE_ID_CARD), object : Callback {
|
||||
override fun onActivityResult(resultCode: Int, data: Intent?) {
|
||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
|
||||
@ -48,7 +48,7 @@ class GameOffServiceDialogFragment
|
||||
siteTv.setOnClickListener {
|
||||
// MtaHelper.onEvent("游戏下载状态按钮", getKey(), site.text)
|
||||
DirectUtils.directToWebView(requireContext(), site.url, "(关闭下载弹窗)")
|
||||
dismiss()
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
container.addView(siteTv)
|
||||
|
||||
@ -13,16 +13,19 @@ import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.fragment.app.FragmentTransaction
|
||||
import com.airbnb.lottie.LottieAnimationView
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.common.util.MtaHelper
|
||||
import com.gh.common.util.PermissionHelper
|
||||
import com.gh.common.util.PermissionHelper.INSTALL_PERMISS_CODE
|
||||
import com.gh.common.util.goneIf
|
||||
import com.gh.common.constant.Constants
|
||||
import com.gh.common.util.*
|
||||
import com.gh.common.util.PermissionHelper.INSTALL_PERMISSION_CODE
|
||||
import com.gh.common.xapk.XapkInstaller
|
||||
import com.gh.gamecenter.R
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import kotlin.random.Random
|
||||
|
||||
class InstallPermissionDialogFragment : BaseTrackableDialogFragment() {
|
||||
|
||||
lateinit var mView: View
|
||||
var isXapk = false
|
||||
var url: String = ""
|
||||
var mCallBack: (() -> Unit)? = null
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
@ -35,16 +38,26 @@ class InstallPermissionDialogFragment : BaseTrackableDialogFragment() {
|
||||
val closeTv = mView.findViewById<TextView>(R.id.closeTv)
|
||||
val closeIv = mView.findViewById<ImageView>(R.id.closeIv)
|
||||
val activateTv = mView.findViewById<TextView>(R.id.activateTv)
|
||||
val contentTv = mView.findViewById<TextView>(R.id.contentTv)
|
||||
val switchLottie = mView.findViewById<LottieAnimationView>(R.id.switchLottie)
|
||||
contentTv.text = if (isXapk) "未授权下解压XAPK可能导致解压失败" else "以保证游戏的安装和更新"
|
||||
|
||||
switchLottie.setAnimation("lottie/install_permission_switch.json")
|
||||
switchLottie.playAnimation()
|
||||
|
||||
val randomNumber = Random.nextInt(2)
|
||||
val randomNumber = if (isXapk) 1 else Random.nextInt(2)
|
||||
closeTv.goneIf(randomNumber == 0)
|
||||
closeIv.goneIf(randomNumber != 0)
|
||||
if (isXapk) {
|
||||
closeTv.text = "暂不,尝试解压"
|
||||
closeIv.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
closeTv.setOnClickListener {
|
||||
MtaHelper.onEvent(getEvent(), getKey(), "文案样式_点击以后再说")
|
||||
if (isXapk) {
|
||||
mCallBack?.invoke()
|
||||
}
|
||||
dismiss()
|
||||
}
|
||||
closeIv.setOnClickListener {
|
||||
@ -54,12 +67,18 @@ class InstallPermissionDialogFragment : BaseTrackableDialogFragment() {
|
||||
activateTv.setOnClickListener {
|
||||
MtaHelper.onEvent(getEvent(), getKey(), if (randomNumber == 0) "文案样式_点击立即开启" else "图标样式_点击立即开启")
|
||||
PermissionHelper.toInstallPermissionSetting(requireActivity())
|
||||
if (isXapk) {
|
||||
SPUtils.setString(Constants.SP_XAPK_UNZIP_ACTIVITY, requireActivity().javaClass.name)
|
||||
SPUtils.setString(Constants.SP_XAPK_URL, url)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (resultCode == RESULT_OK && requestCode == INSTALL_PERMISS_CODE) {
|
||||
if (resultCode == RESULT_OK && requestCode == INSTALL_PERMISSION_CODE) {
|
||||
SPUtils.setString(Constants.SP_XAPK_UNZIP_ACTIVITY, "")
|
||||
SPUtils.setString(Constants.SP_XAPK_URL, "")
|
||||
mCallBack?.invoke()
|
||||
dismiss()
|
||||
}
|
||||
@ -71,30 +90,43 @@ class InstallPermissionDialogFragment : BaseTrackableDialogFragment() {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun show(activity: AppCompatActivity, callBack: (() -> Unit)?) {
|
||||
fun show(activity: AppCompatActivity, downloadEntity: DownloadEntity, callBack: (() -> Unit)?) {
|
||||
val isXapk = XapkInstaller.XAPK_EXTENSION_NAME == downloadEntity.path.getExtension()
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
||||
callBack?.invoke()
|
||||
return
|
||||
}
|
||||
if (!Config.isPermissionPopupSwitchOpen()) {
|
||||
callBack?.invoke()
|
||||
return
|
||||
}
|
||||
val haveInstallPermission = activity.packageManager.canRequestPackageInstalls();
|
||||
val haveInstallPermission = activity.packageManager.canRequestPackageInstalls()
|
||||
if (haveInstallPermission) {
|
||||
callBack?.invoke()
|
||||
return
|
||||
|
||||
}
|
||||
if (isXapk) {
|
||||
val xapkUnzipVersions = Config.getSettings()?.permissionPopupAppliedVersions?.xapkUnzip
|
||||
if (xapkUnzipVersions?.contains(Build.VERSION.SDK_INT.toString()) == false) {
|
||||
callBack?.invoke()
|
||||
return
|
||||
}
|
||||
} else {
|
||||
val installVersions = Config.getSettings()?.permissionPopupAppliedVersions?.install
|
||||
if (installVersions?.contains(Build.VERSION.SDK_INT.toString()) == false) {
|
||||
callBack?.invoke()
|
||||
return
|
||||
}
|
||||
}
|
||||
var installPermissionDialogFragment = activity.supportFragmentManager.findFragmentByTag(InstallPermissionDialogFragment::class.java.simpleName) as? InstallPermissionDialogFragment
|
||||
if (installPermissionDialogFragment != null) {
|
||||
installPermissionDialogFragment.mCallBack = callBack
|
||||
installPermissionDialogFragment.isXapk = isXapk
|
||||
installPermissionDialogFragment.url = downloadEntity.url
|
||||
val transaction: FragmentTransaction = activity.supportFragmentManager.beginTransaction()
|
||||
transaction.show(installPermissionDialogFragment)
|
||||
transaction.commit()
|
||||
} else {
|
||||
installPermissionDialogFragment = InstallPermissionDialogFragment().apply {
|
||||
mCallBack = callBack
|
||||
this.mCallBack = callBack
|
||||
this.isXapk = isXapk
|
||||
this.url = downloadEntity.url
|
||||
}
|
||||
installPermissionDialogFragment.show(activity.supportFragmentManager, InstallPermissionDialogFragment::class.java.simpleName)
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@ package com.gh.common.dialog
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.content.res.AssetManager
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.provider.Settings
|
||||
|
||||
@ -0,0 +1,305 @@
|
||||
package com.gh.common.dialog
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.RelativeLayout
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.FragmentTransaction
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.base.BaseRecyclerViewHolder
|
||||
import com.gh.common.constant.Constants
|
||||
import com.gh.common.util.*
|
||||
import com.gh.common.view.CustomLinkMovementMethod
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.databinding.FragmentPackageCheckBinding
|
||||
import com.gh.gamecenter.databinding.PackageCheckItemBinding
|
||||
import com.gh.gamecenter.entity.DetectionObjectEntity
|
||||
import com.gh.gamecenter.entity.PackageDialogEntity
|
||||
import com.gh.gamecenter.eventbus.EBPackage
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.adapter.BaseRecyclerAdapter
|
||||
import com.lightgame.dialog.BaseDialogFragment
|
||||
import io.reactivex.disposables.Disposable
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
/**
|
||||
* 包名检测弹窗
|
||||
*/
|
||||
class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
|
||||
private lateinit var binding: FragmentPackageCheckBinding
|
||||
private var mTotalWidth = 0f
|
||||
private val mDuration = 3000
|
||||
private var mDisposable: Disposable? = null
|
||||
private var mAdapter: PackageCheckAdapter? = null
|
||||
var packageDialogEntity: PackageDialogEntity? = null
|
||||
var callBack: DialogUtils.ConfirmListener? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
EventBus.getDefault().register(this)
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
binding = FragmentPackageCheckBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
packageDialogEntity?.let {
|
||||
changeParams(it.detectionObjects.size)
|
||||
|
||||
binding.packageRv.layoutManager = LinearLayoutManager(requireContext())
|
||||
mAdapter = PackageCheckAdapter(requireContext(), it.detectionObjects)
|
||||
binding.packageRv.adapter = mAdapter
|
||||
|
||||
binding.titleTv.text = it.title
|
||||
binding.contentTv.text = it.content
|
||||
|
||||
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) {
|
||||
DirectUtils.directToLinkPage(requireContext(), link, "包名检测弹窗", "")
|
||||
}.build()
|
||||
spanBuilder.append(linkSpan)
|
||||
if (index != it.links.size - 1) {
|
||||
spanBuilder.append("、")
|
||||
}
|
||||
}
|
||||
binding.linkHintTv.text = spanBuilder
|
||||
binding.linkHintTv.movementMethod = CustomLinkMovementMethod.getInstance()
|
||||
|
||||
when (it.level) {
|
||||
"HINT_SKIP" -> {
|
||||
binding.cancelTv.text = "取消"
|
||||
binding.noRemindAgainCb.visibility = View.GONE
|
||||
}
|
||||
"ALWAYS_HINT" -> {
|
||||
binding.cancelTv.text = "我知道了"
|
||||
binding.noRemindAgainCb.visibility = View.GONE
|
||||
}
|
||||
else -> {
|
||||
binding.cancelTv.text = "我知道了"
|
||||
binding.noRemindAgainCb.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
initListener(it)
|
||||
}
|
||||
checkPackage()
|
||||
}
|
||||
|
||||
private fun changeParams(size: Int) {
|
||||
val params = binding.packageRv.layoutParams as LinearLayout.LayoutParams
|
||||
params.height = if (size > 3) (28f.dip2px() * 3.5).toInt() else 28f.dip2px() * size
|
||||
binding.packageRv.layoutParams = params
|
||||
}
|
||||
|
||||
private fun initListener(entity: PackageDialogEntity) {
|
||||
binding.downloadBtn.setOnClickListener {
|
||||
if (binding.noRemindAgainCb.isChecked) {
|
||||
SPUtils.setBoolean(Constants.SP_PACKAGE_CHECK, true)
|
||||
}
|
||||
val isAllPackageInstalled = isAllPackageInstalled(entity)
|
||||
if (isAllPackageInstalled) {
|
||||
callBack?.onConfirm()
|
||||
dismissAllowingStateLoss()
|
||||
} else {
|
||||
val packageLink = entity.links.find { it.buttonLink }
|
||||
if (packageLink != null) {
|
||||
DirectUtils.directToLinkPage(requireContext(), packageLink, "包名检测弹窗", "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
binding.cancelTv.setOnClickListener {
|
||||
if (entity.level != "HINT_SKIP") {
|
||||
callBack?.onConfirm()
|
||||
}
|
||||
if (binding.noRemindAgainCb.isChecked) {
|
||||
SPUtils.setBoolean(Constants.SP_PACKAGE_CHECK, true)
|
||||
}
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkPackage() {
|
||||
var index = 0
|
||||
mTotalWidth = (DisplayUtils.getScreenWidth() - 108f.dip2px()).toFloat()
|
||||
mDisposable = rxTimer(1) {
|
||||
val width = (mTotalWidth / mDuration) * it
|
||||
val params = binding.progressView.layoutParams as RelativeLayout.LayoutParams
|
||||
params.width = width.toInt()
|
||||
binding.progressView.layoutParams = params
|
||||
|
||||
packageDialogEntity?.detectionObjects?.let { objects ->
|
||||
if (objects.isNotEmpty()) {
|
||||
val averageTime = if (objects.size == 1) {
|
||||
mDuration
|
||||
} else {
|
||||
mDuration / objects.size
|
||||
}
|
||||
if (it != 0L && it % averageTime == 0L && index < objects.size) {
|
||||
mAdapter?.notifyPackages()
|
||||
binding.packageRv.smoothScrollToPosition(index)
|
||||
index++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (it >= mDuration) {
|
||||
mDisposable?.dispose()
|
||||
binding.downloadBtn.isEnabled = true
|
||||
binding.progressText.text = "检测完成"
|
||||
binding.progressView.background = ContextCompat.getDrawable(requireContext(), R.drawable.package_check_complete_bg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
val width = requireContext().resources.displayMetrics.widthPixels - 60F.dip2px()
|
||||
val height = ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
dialog?.window?.setLayout(width, height)
|
||||
dialog?.setCanceledOnTouchOutside(true)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
packageDialogEntity?.let {
|
||||
if (isAllPackageInstalled(it)) {
|
||||
callBack?.onConfirm()
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
EventBus.getDefault().unregister(this)
|
||||
if (mDisposable?.isDisposed == false) {
|
||||
mDisposable?.dispose()
|
||||
}
|
||||
}
|
||||
|
||||
//安装、卸载事件
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onEventMainThread(busFour: EBPackage) {
|
||||
if ("安装" == busFour.type || "卸载" == busFour.type) {
|
||||
mAdapter?.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
class PackageCheckAdapter(val context: Context, val entities: ArrayList<DetectionObjectEntity>) : BaseRecyclerAdapter<RecyclerView.ViewHolder>(context) {
|
||||
private var index = -1
|
||||
|
||||
fun notifyPackages() {
|
||||
index++
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
return PackageCheckViewHolder(PackageCheckItemBinding.bind(LayoutInflater.from(context).inflate(R.layout.package_check_item, parent, false)))
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = entities.size
|
||||
|
||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||
if (holder is PackageCheckViewHolder) {
|
||||
val entity = entities[position]
|
||||
holder.binding.entity = entity
|
||||
if (position <= index) {
|
||||
var isAllInstalled = false
|
||||
entity.packages.forEach { packageName ->
|
||||
val isInstalled = PackageUtils.getInstalledPackages(context, 0).find { it.packageName == packageName } != null
|
||||
if (isInstalled) {
|
||||
isAllInstalled = true
|
||||
return@forEach
|
||||
}
|
||||
}
|
||||
if (isAllInstalled) {
|
||||
holder.binding.statusTv.text = "已安装"
|
||||
holder.binding.statusTv.setTextColor(ContextCompat.getColor(context, R.color.theme_font))
|
||||
} else {
|
||||
holder.binding.statusTv.text = "未安装"
|
||||
holder.binding.statusTv.setTextColor(ContextCompat.getColor(context, R.color.text_FF4147))
|
||||
}
|
||||
holder.binding.statusTv.visibility = View.VISIBLE
|
||||
} else {
|
||||
holder.binding.statusTv.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class PackageCheckViewHolder(val binding: PackageCheckItemBinding) : BaseRecyclerViewHolder<DetectionObjectEntity>(binding.root)
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun show(activity: AppCompatActivity, packageDialogEntity: PackageDialogEntity?, callBack: DialogUtils.ConfirmListener) {
|
||||
if (packageDialogEntity == null) {
|
||||
callBack.onConfirm()
|
||||
return
|
||||
}
|
||||
if (isAllPackageInstalled(packageDialogEntity)) {
|
||||
callBack.onConfirm()
|
||||
return
|
||||
}
|
||||
val isChoose = SPUtils.getBoolean(Constants.SP_PACKAGE_CHECK, false)
|
||||
if (packageDialogEntity.level == "OPTIONAL_HINT" && isChoose) {
|
||||
callBack.onConfirm()
|
||||
return
|
||||
}
|
||||
|
||||
var dialogFragment = activity.supportFragmentManager.findFragmentByTag(PackageCheckDialogFragment::class.java.simpleName) as? PackageCheckDialogFragment
|
||||
if (dialogFragment == null) {
|
||||
dialogFragment = PackageCheckDialogFragment()
|
||||
dialogFragment.packageDialogEntity = packageDialogEntity
|
||||
dialogFragment.callBack = callBack
|
||||
|
||||
dialogFragment.show(activity.supportFragmentManager, PackageCheckDialogFragment::class.java.simpleName)
|
||||
} else {
|
||||
dialogFragment.packageDialogEntity = packageDialogEntity
|
||||
dialogFragment.callBack = callBack
|
||||
|
||||
val transaction: FragmentTransaction = activity.supportFragmentManager.beginTransaction()
|
||||
transaction.show(dialogFragment)
|
||||
transaction.commit()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun isAllPackageInstalled(packageDialogEntity: PackageDialogEntity): Boolean {
|
||||
var isAllInstalled = true
|
||||
|
||||
val isPackagesInstall: (ArrayList<String>) -> Boolean = { packages ->
|
||||
var isPackagesInstalled = false
|
||||
packages.forEach {packageName->
|
||||
val isInstalled = PackageUtils.getInstalledPackages(HaloApp.getInstance().application, 0).find { it.packageName == packageName } != null
|
||||
if (isInstalled) {
|
||||
isPackagesInstalled = true
|
||||
return@forEach
|
||||
}
|
||||
}
|
||||
isPackagesInstalled
|
||||
}
|
||||
|
||||
packageDialogEntity.detectionObjects.forEach loop@{ obj ->
|
||||
if (!isPackagesInstall(obj.packages)) {
|
||||
isAllInstalled = false
|
||||
return isAllInstalled
|
||||
}
|
||||
}
|
||||
return isAllInstalled
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2,23 +2,27 @@ package com.gh.common.dialog
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.DialogInterface
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.text.SpannableStringBuilder
|
||||
import android.text.Spanned
|
||||
import android.text.TextPaint
|
||||
import android.text.method.ScrollingMovementMethod
|
||||
import android.text.style.ClickableSpan
|
||||
import android.view.*
|
||||
import android.webkit.WebSettings
|
||||
import android.webkit.WebView
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.FragmentTransaction
|
||||
import com.gh.base.fragment.BaseDialogFragment
|
||||
import com.gh.common.util.DirectUtils.directToExternalBrowser
|
||||
import com.gh.common.util.dip2px
|
||||
import com.gh.common.view.CustomLinkMovementMethod
|
||||
import com.gh.gamecenter.R
|
||||
|
||||
class PrivacyDialogFragment : BaseDialogFragment() {
|
||||
|
||||
private val mLocalPrivacyHtml = "file:///android_asset/privacy_policies.html"
|
||||
private val mLocalRegulationHtml = "file:///android_asset/user_regulation.html"
|
||||
// private val mLocalPrivacyHtml = "file:///android_asset/privacy_policies.html"
|
||||
// private val mLocalRegulationHtml = "file:///android_asset/user_regulation.html"
|
||||
|
||||
var containerView: View? = null
|
||||
var mCallBack: ((isSuccess: Boolean) -> Unit)? = null
|
||||
@ -30,83 +34,80 @@ class PrivacyDialogFragment : BaseDialogFragment() {
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val mWebViewPrivacy = containerView?.findViewById<WebView>(R.id.webView)
|
||||
val mWebViewRegulation = containerView?.findViewById<WebView>(R.id.webView2)
|
||||
// val mWebViewPrivacy = containerView?.findViewById<WebView>(R.id.webView)
|
||||
// val mWebViewRegulation = containerView?.findViewById<WebView>(R.id.webView2)
|
||||
//
|
||||
// mWebViewPrivacy?.isHorizontalScrollBarEnabled = false
|
||||
// mWebViewRegulation?.isHorizontalScrollBarEnabled = false
|
||||
|
||||
mWebViewPrivacy?.isHorizontalScrollBarEnabled = false
|
||||
mWebViewRegulation?.isHorizontalScrollBarEnabled = false
|
||||
val contentTv = containerView?.findViewById<TextView>(R.id.contentTv)
|
||||
val descTv = containerView?.findViewById<TextView>(R.id.descTv)
|
||||
contentTv?.movementMethod = ScrollingMovementMethod()
|
||||
|
||||
val mTitlePrivacyTv = containerView?.findViewById<TextView>(R.id.privacyTitleTv)
|
||||
val mTitleRegulationTv = containerView?.findViewById<TextView>(R.id.userRegulationTitleTv)
|
||||
|
||||
val settingsArrayList = arrayListOf(mWebViewPrivacy?.settings, mWebViewRegulation?.settings)
|
||||
|
||||
for (settings in settingsArrayList) {
|
||||
settings?.javaScriptEnabled = true
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
settings?.mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW
|
||||
}
|
||||
// 避免提示网页有害信息不能访问
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
settings?.safeBrowsingEnabled = false
|
||||
val skipText = SpannableStringBuilder("查看完整版的隐私政策和用户协议")
|
||||
skipText.setSpan(object : ClickableSpan() {
|
||||
override fun updateDrawState(ds: TextPaint) {
|
||||
super.updateDrawState(ds)
|
||||
ds.color = ContextCompat.getColor(requireContext(), R.color.theme_font)
|
||||
ds.isUnderlineText = false
|
||||
}
|
||||
|
||||
// 适配大于屏幕宽度的页面
|
||||
settings?.useWideViewPort = true
|
||||
settings?.loadWithOverviewMode = true
|
||||
settings?.domStorageEnabled = true
|
||||
|
||||
// 自适应屏幕
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
settings?.layoutAlgorithm = WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING
|
||||
override fun onClick(widget: View) {
|
||||
directToExternalBrowser(context!!, context!!.getString(R.string.privacy_policy_url))
|
||||
}
|
||||
}
|
||||
}, skipText.length - 9, skipText.length - 5, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
|
||||
// if (NetworkUtils.isNetworkConnected(requireContext())) {
|
||||
// mWebViewPrivacy?.loadUrl(requireContext().getString(R.string.privacy_policy_url))
|
||||
// mWebViewRegulation?.loadUrl(requireContext().getString(R.string.user_regulation_url))
|
||||
// } else {
|
||||
mWebViewPrivacy?.loadUrl(mLocalPrivacyHtml)
|
||||
mWebViewRegulation?.loadUrl(mLocalRegulationHtml)
|
||||
// }
|
||||
skipText.setSpan(object : ClickableSpan() {
|
||||
override fun updateDrawState(ds: TextPaint) {
|
||||
super.updateDrawState(ds)
|
||||
ds.color = ContextCompat.getColor(requireContext(), R.color.theme_font)
|
||||
ds.isUnderlineText = false
|
||||
}
|
||||
|
||||
// val client = object : WebViewClient() {
|
||||
// override fun onReceivedError(view: WebView?, request: WebResourceRequest?, error: WebResourceError?) {
|
||||
// super.onReceivedError(view, request, error)
|
||||
// if (view == mWebViewPrivacy) {
|
||||
// view?.loadUrl(mLocalPrivacyHtml)
|
||||
// } else {
|
||||
// view?.loadUrl(mLocalRegulationHtml)
|
||||
// }
|
||||
override fun onClick(widget: View) {
|
||||
directToExternalBrowser(requireContext(), requireContext().getString(R.string.disclaimer_url))
|
||||
}
|
||||
}, skipText.length - 4, skipText.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
descTv?.movementMethod = CustomLinkMovementMethod()
|
||||
descTv?.text = skipText
|
||||
|
||||
// val mWebViewPrivacy = containerView?.findViewById<WebView>(R.id.webView)
|
||||
//
|
||||
// mWebViewPrivacy?.isHorizontalScrollBarEnabled = false
|
||||
//
|
||||
// val settingsArrayList = arrayListOf(mWebViewPrivacy?.settings, mWebViewRegulation?.settings)
|
||||
//
|
||||
// for (settings in settingsArrayList) {
|
||||
// settings?.javaScriptEnabled = true
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
// settings?.mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW
|
||||
// }
|
||||
// // 避免提示网页有害信息不能访问
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// settings?.safeBrowsingEnabled = false
|
||||
// }
|
||||
//
|
||||
// // 适配大于屏幕宽度的页面
|
||||
// settings?.useWideViewPort = true
|
||||
// settings?.loadWithOverviewMode = true
|
||||
// settings?.domStorageEnabled = true
|
||||
//
|
||||
// // 自适应屏幕
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
// settings?.layoutAlgorithm = WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING
|
||||
// }
|
||||
// }
|
||||
|
||||
// mWebViewPrivacy?.webViewClient = client
|
||||
// mWebViewRegulation?.webViewClient = client
|
||||
|
||||
mTitlePrivacyTv?.setOnClickListener {
|
||||
mTitlePrivacyTv.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.white))
|
||||
mTitleRegulationTv?.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.text_F5F5F5))
|
||||
|
||||
mWebViewPrivacy?.visibility = View.VISIBLE
|
||||
mWebViewRegulation?.visibility = View.GONE
|
||||
}
|
||||
|
||||
mTitleRegulationTv?.setOnClickListener {
|
||||
mTitlePrivacyTv?.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.text_F5F5F5))
|
||||
mTitleRegulationTv.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.white))
|
||||
|
||||
mWebViewPrivacy?.visibility = View.GONE
|
||||
mWebViewRegulation?.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
containerView?.findViewById<View>(R.id.refuseTv)?.setOnClickListener {
|
||||
mCallBack?.invoke(false)
|
||||
dismiss()
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
containerView?.findViewById<View>(R.id.agreeTv)?.setOnClickListener {
|
||||
mCallBack?.invoke(true)
|
||||
dismiss()
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -24,6 +24,7 @@ object MetaUtil {
|
||||
|
||||
private var m: Meta? = null
|
||||
private var imei: String? = null
|
||||
private var base64EncodedImei: String? = null
|
||||
private var androidId: String? = null
|
||||
|
||||
fun refreshMeta() {
|
||||
@ -104,6 +105,20 @@ object MetaUtil {
|
||||
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getBase64EncodedIMEI(): String {
|
||||
if (TextUtils.isEmpty(base64EncodedImei) && imei != null) {
|
||||
try {
|
||||
base64EncodedImei = android.util.Base64.encodeToString(getIMEI().trim().toByteArray(), android.util.Base64.NO_WRAP)
|
||||
} catch (e: java.lang.Exception) {
|
||||
e.printStackTrace()
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
return base64EncodedImei ?: ""
|
||||
}
|
||||
|
||||
fun getModel(): String? {
|
||||
return Build.MODEL
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import com.gh.common.runOnIoThread
|
||||
import com.gh.common.util.clearHtmlFormatCompletely
|
||||
import com.gh.common.util.removeInsertedContent
|
||||
import com.gh.common.util.removeVideoContent
|
||||
import com.gh.common.util.tryCatchInRelease
|
||||
import com.gh.gamecenter.entity.*
|
||||
import com.gh.gamecenter.qa.entity.AnswerDetailEntity
|
||||
import com.gh.gamecenter.qa.entity.AnswerEntity
|
||||
@ -14,27 +15,28 @@ object HistoryHelper {
|
||||
|
||||
fun insertAnswerEntity(answerDetailEntity: AnswerDetailEntity) {
|
||||
val answerEntity = convertAnswerDetailToAnswer(answerDetailEntity)
|
||||
runOnIoThread { HistoryDatabase.instance.answerDao().addAnswer(answerEntity) }
|
||||
// 偶尔有设备会出现磁盘满了写不进数据库的问题 database or disk is full 异常,毕竟只是插入个本地历史,这里直接捕抓
|
||||
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.answerDao().addAnswer(answerEntity) } }
|
||||
}
|
||||
|
||||
fun insertArticleEntity(articleDetailEntity: ArticleDetailEntity) {
|
||||
val articleEntity = convertArticleDetailToArticle(articleDetailEntity)
|
||||
runOnIoThread { HistoryDatabase.instance.articleDao().addArticle(articleEntity) }
|
||||
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.articleDao().addArticle(articleEntity) } }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun insertGameEntity(gameEntity: GameEntity) {
|
||||
val historyGameEntity = convertGameEntityToHistoryGameEntity(gameEntity)
|
||||
runOnIoThread { HistoryDatabase.instance.gameDao().addGame(historyGameEntity) }
|
||||
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.gameDao().addGame(historyGameEntity) } }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun insertGameEntity(updateEntity: GameUpdateEntity) {
|
||||
val historyGameEntity = convertGameUpdateEntityToHistoryGameEntity(updateEntity)
|
||||
runOnIoThread { HistoryDatabase.instance.gameDao().addGame(historyGameEntity) }
|
||||
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.gameDao().addGame(historyGameEntity) } }
|
||||
}
|
||||
|
||||
private fun convertGameUpdateEntityToHistoryGameEntity(updateEntity: GameUpdateEntity): HistoryGameEntity{
|
||||
private fun convertGameUpdateEntityToHistoryGameEntity(updateEntity: GameUpdateEntity): HistoryGameEntity {
|
||||
val historyGame = HistoryGameEntity()
|
||||
|
||||
historyGame.orderTag = System.currentTimeMillis()
|
||||
|
||||
@ -1,67 +1,67 @@
|
||||
package com.gh.common.im
|
||||
|
||||
import android.app.Activity
|
||||
import androidx.core.view.ViewCompat
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
||||
object ImHintHelper {
|
||||
|
||||
@JvmStatic
|
||||
fun show(activity: Activity?) {
|
||||
activity?.let {
|
||||
var hintView = retrieveHintViewFromActivity(it)
|
||||
if (hintView == null) {
|
||||
hintView = ImHintView(it)
|
||||
hintView.showDot(ImManager.shouldShowFloatingWindowDot)
|
||||
|
||||
val decorView = it.window.decorView as ViewGroup
|
||||
it.runOnUiThread {
|
||||
decorView.addView(hintView)
|
||||
}
|
||||
} else {
|
||||
hintView.showDot(ImManager.shouldShowFloatingWindowDot)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun dismiss(activity: Activity?) {
|
||||
activity?.let {
|
||||
clearCurrent(it)
|
||||
}
|
||||
}
|
||||
|
||||
private fun retrieveHintViewFromActivity(activity: Activity?) : ImHintView? {
|
||||
(activity?.window?.decorView as? ViewGroup)?.let {
|
||||
for (i in 0..it.childCount) {
|
||||
val childView = if (it.getChildAt(i) is ImHintView) it.getChildAt(i) as ImHintView else null
|
||||
if (childView != null && childView.windowToken != null) {
|
||||
return childView
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
private fun clearCurrent(activity: Activity?) {
|
||||
(activity?.window?.decorView as? ViewGroup)?.let {
|
||||
for (i in 0..it.childCount) {
|
||||
val childView = if (it.getChildAt(i) is ImHintView) it.getChildAt(i) as ImHintView else null
|
||||
if (childView != null && childView.windowToken != null) {
|
||||
ViewCompat.animate(childView).alpha(0f).withEndAction(getRemoveViewRunnable(childView))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getRemoveViewRunnable(childView: View?): Runnable {
|
||||
return Runnable {
|
||||
childView?.let {
|
||||
(childView.parent as? ViewGroup)?.removeView(childView)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//package com.gh.common.im
|
||||
//
|
||||
//import android.app.Activity
|
||||
//import androidx.core.view.ViewCompat
|
||||
//import android.view.View
|
||||
//import android.view.ViewGroup
|
||||
//
|
||||
//object ImHintHelper {
|
||||
//
|
||||
// @JvmStatic
|
||||
// fun show(activity: Activity?) {
|
||||
// activity?.let {
|
||||
// var hintView = retrieveHintViewFromActivity(it)
|
||||
// if (hintView == null) {
|
||||
// hintView = ImHintView(it)
|
||||
// hintView.showDot(ImManager.shouldShowFloatingWindowDot)
|
||||
//
|
||||
// val decorView = it.window.decorView as ViewGroup
|
||||
// it.runOnUiThread {
|
||||
// decorView.addView(hintView)
|
||||
// }
|
||||
// } else {
|
||||
// hintView.showDot(ImManager.shouldShowFloatingWindowDot)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @JvmStatic
|
||||
// fun dismiss(activity: Activity?) {
|
||||
// activity?.let {
|
||||
// clearCurrent(it)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private fun retrieveHintViewFromActivity(activity: Activity?) : ImHintView? {
|
||||
// (activity?.window?.decorView as? ViewGroup)?.let {
|
||||
// for (i in 0..it.childCount) {
|
||||
// val childView = if (it.getChildAt(i) is ImHintView) it.getChildAt(i) as ImHintView else null
|
||||
// if (childView != null && childView.windowToken != null) {
|
||||
// return childView
|
||||
// }
|
||||
// }
|
||||
// return null
|
||||
// }
|
||||
// return null
|
||||
// }
|
||||
//
|
||||
// private fun clearCurrent(activity: Activity?) {
|
||||
// (activity?.window?.decorView as? ViewGroup)?.let {
|
||||
// for (i in 0..it.childCount) {
|
||||
// val childView = if (it.getChildAt(i) is ImHintView) it.getChildAt(i) as ImHintView else null
|
||||
// if (childView != null && childView.windowToken != null) {
|
||||
// ViewCompat.animate(childView).alpha(0f).withEndAction(getRemoveViewRunnable(childView))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private fun getRemoveViewRunnable(childView: View?): Runnable {
|
||||
// return Runnable {
|
||||
// childView?.let {
|
||||
// (childView.parent as? ViewGroup)?.removeView(childView)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@ -1,45 +1,45 @@
|
||||
package com.gh.common.im
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.util.TypedValue
|
||||
import android.view.View
|
||||
import android.widget.RelativeLayout
|
||||
import androidx.core.view.ViewCompat
|
||||
import com.gh.common.util.DisplayUtils
|
||||
import com.gh.gamecenter.R
|
||||
import kotlinx.android.synthetic.main.view_im_hint.view.*
|
||||
|
||||
class ImHintView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0)
|
||||
: RelativeLayout(context, attrs, defStyle) {
|
||||
|
||||
init {
|
||||
inflate(context, R.layout.view_im_hint, this)
|
||||
|
||||
ViewCompat.setTranslationZ(this, Integer.MAX_VALUE.toFloat() - 1)
|
||||
|
||||
ivContainer.setOnClickListener {
|
||||
if (context is Activity) {
|
||||
ImManager.startChatActivity(context)
|
||||
ImManager.removeNotification()
|
||||
}
|
||||
}
|
||||
|
||||
val lp = ivContainer.layoutParams as RelativeLayout.LayoutParams
|
||||
|
||||
lp.setMargins(0, 0, dp2px(30f), dp2px(106f) + DisplayUtils.retrieveNavigationHeight(context))
|
||||
}
|
||||
|
||||
fun showDot(show: Boolean) {
|
||||
if (show) {
|
||||
unreadDot.visibility = View.VISIBLE
|
||||
} else {
|
||||
unreadDot.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
private fun dp2px(dp: Float): Int {
|
||||
return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, context.applicationContext.resources.displayMetrics).toInt()
|
||||
}
|
||||
}
|
||||
//package com.gh.common.im
|
||||
//
|
||||
//import android.app.Activity
|
||||
//import android.content.Context
|
||||
//import android.util.AttributeSet
|
||||
//import android.util.TypedValue
|
||||
//import android.view.View
|
||||
//import android.widget.RelativeLayout
|
||||
//import androidx.core.view.ViewCompat
|
||||
//import com.gh.common.util.DisplayUtils
|
||||
//import com.gh.gamecenter.R
|
||||
//import kotlinx.android.synthetic.main.view_im_hint.view.*
|
||||
//
|
||||
//class ImHintView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0)
|
||||
// : RelativeLayout(context, attrs, defStyle) {
|
||||
//
|
||||
// init {
|
||||
// inflate(context, R.layout.view_im_hint, this)
|
||||
//
|
||||
// ViewCompat.setTranslationZ(this, Integer.MAX_VALUE.toFloat() - 1)
|
||||
//
|
||||
// ivContainer.setOnClickListener {
|
||||
// if (context is Activity) {
|
||||
// ImManager.startChatActivity(context)
|
||||
// ImManager.removeNotification()
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// val lp = ivContainer.layoutParams as RelativeLayout.LayoutParams
|
||||
//
|
||||
// lp.setMargins(0, 0, dp2px(30f), dp2px(106f) + DisplayUtils.retrieveNavigationHeight(context))
|
||||
// }
|
||||
//
|
||||
// fun showDot(show: Boolean) {
|
||||
// if (show) {
|
||||
// unreadDot.visibility = View.VISIBLE
|
||||
// } else {
|
||||
// unreadDot.visibility = View.GONE
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private fun dp2px(dp: Float): Int {
|
||||
// return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, context.applicationContext.resources.displayMetrics).toInt()
|
||||
// }
|
||||
//}
|
||||
@ -4,6 +4,7 @@ import android.content.Context
|
||||
import android.database.ContentObserver
|
||||
import android.media.AudioManager
|
||||
import android.os.Handler
|
||||
import com.gh.common.util.tryCatchInRelease
|
||||
|
||||
class VolumeObserver(var context: Context, handler: Handler, var callback: MuteCallback? = null)
|
||||
: ContentObserver(handler) {
|
||||
@ -11,7 +12,8 @@ class VolumeObserver(var context: Context, handler: Handler, var callback: MuteC
|
||||
|
||||
init {
|
||||
val audio = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||
previousVolume = audio.getStreamVolume(AudioManager.STREAM_MUSIC)
|
||||
// 部分设备的 audioManager getStreamVolume 内部会触发空指针 :(
|
||||
tryCatchInRelease { previousVolume = audio.getStreamVolume(AudioManager.STREAM_MUSIC) }
|
||||
}
|
||||
|
||||
override fun onChange(selfChange: Boolean) {
|
||||
|
||||
@ -0,0 +1,244 @@
|
||||
package com.gh.common.simulator
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.view.Window
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.TextView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.g00fy2.versioncompare.Version
|
||||
import com.gh.common.AppExecutor.uiExecutor
|
||||
import com.gh.common.constant.Constants
|
||||
import com.gh.common.dialog.TrackableDialog
|
||||
import com.gh.common.util.*
|
||||
import com.gh.common.util.PackageInstaller.getDownloadPath
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.entity.ApkEntity
|
||||
import com.gh.gamecenter.entity.SimulatorEntity
|
||||
import com.gh.gamecenter.entity.TrackableEntity
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.download.*
|
||||
import com.lightgame.utils.Utils
|
||||
import java.text.DecimalFormat
|
||||
|
||||
class SimulatorDownloadManager private constructor() {
|
||||
|
||||
private var app_pb_progress: ProgressBar? = null
|
||||
private var appProgressSize: TextView? = null
|
||||
private var appProgressRemain: TextView? = null
|
||||
private var appProgressPercent: TextView? = null
|
||||
private var appProgressFilling: View? = null
|
||||
private var appProgressAnchor: View? = null
|
||||
private var downloadDialog: Dialog? = null
|
||||
|
||||
private var simulatorLocation: SimulatorLocation? = null
|
||||
private var simulator: SimulatorEntity? = null
|
||||
private var gameId: String = ""
|
||||
private var gameName: String = ""
|
||||
private var downloadType: String = ""
|
||||
|
||||
private val dataWatcher = object : DataWatcher() {
|
||||
override fun onDataChanged(downloadEntity: DownloadEntity?) {
|
||||
if (downloadEntity?.isSimulatorDownload() == true) {
|
||||
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))
|
||||
app_pb_progress!!.progress = (downloadEntity.percent * 10).toInt()
|
||||
|
||||
val width = app_pb_progress!!.width
|
||||
val marLeft = (downloadEntity.percent / 100 * width).toInt()
|
||||
val anchorLp = appProgressAnchor!!.layoutParams
|
||||
if (anchorLp is ConstraintLayout.LayoutParams) {
|
||||
anchorLp.leftMargin = marLeft
|
||||
appProgressAnchor!!.layoutParams = anchorLp
|
||||
}
|
||||
|
||||
val fillingLp = appProgressFilling!!.layoutParams
|
||||
fillingLp.width = marLeft + DisplayUtils.dip2px(5f)
|
||||
appProgressFilling!!.layoutParams = fillingLp
|
||||
|
||||
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 startTime = downloadEntity.getMetaExtra(Constants.SIMULATOR_DOWNLOAD_START_TIME)
|
||||
LogUtils.uploadSimulatorDownload("simulator_download_complete", fileName, simulator?.id, downloadEntity.name, gameId, locationStr, downloadType, startTime)
|
||||
DownloadManager.getInstance(HaloApp.getInstance().application).cancel(downloadEntity.url, false, true)
|
||||
downloadDialog?.dismiss()
|
||||
}
|
||||
DownloadStatus.neterror == downloadEntity.status -> {
|
||||
ToastUtils.showToast("网络不稳定,下载任务已暂停")
|
||||
}
|
||||
DownloadStatus.timeout == downloadEntity.status -> {
|
||||
ToastUtils.showToast("网络不稳定,下载任务已暂停")
|
||||
}
|
||||
DownloadStatus.notfound == downloadEntity.status -> {
|
||||
ToastUtils.showToast("下载链接异常,请稍后重试")
|
||||
}
|
||||
DownloadStatus.hijack == downloadEntity.status -> {
|
||||
ToastUtils.showToast("网络劫持,请稍后重试")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun showDownloadDialog(context: Context, simulator: SimulatorEntity?, location: SimulatorLocation) {
|
||||
showDownloadDialog(context, simulator, location, "", "", null)
|
||||
}
|
||||
|
||||
fun showDownloadDialog(context: Context, simulator: SimulatorEntity?, location: SimulatorLocation, gameId: String = "", gameName: String = "", cancelCallback: (() -> Unit)? = null) {
|
||||
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.getVersionByPackage(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
|
||||
)
|
||||
DialogUtils.showNewAlertDialog(context, title, message, negativeText, positiveText, trackableEntity, Gravity.LEFT, {
|
||||
if (shouldShowUpdate && isInstalled) {
|
||||
cancelCallback?.invoke()
|
||||
MtaHelper.onEvent(trackableEntity.event, trackableEntity.key, "点击下次再说")
|
||||
}
|
||||
}, {
|
||||
showDownloadingDialog(context, simulator)
|
||||
MtaHelper.onEvent(trackableEntity.event, trackableEntity.key, if (shouldShowUpdate && isInstalled) "点击更新" else "点击下载")
|
||||
})
|
||||
}
|
||||
|
||||
private fun showDownloadingDialog(context: Context, simulator: SimulatorEntity?) {
|
||||
val msg = FileUtils.isCanDownload(context, simulator?.apk?.size)
|
||||
if (!msg.isNullOrEmpty()) {
|
||||
Utils.toast(context, msg)
|
||||
return
|
||||
}
|
||||
if (NetworkUtils.isMobileConnected(context)) {
|
||||
Utils.toast(context, "当前使用移动数据进行下载")
|
||||
}
|
||||
|
||||
downloadDialog = TrackableDialog(context, R.style.GhAlertDialog, "模拟器下载", "下载中弹窗")
|
||||
downloadDialog?.window?.setBackgroundDrawableResource(R.color.transparent)
|
||||
|
||||
val view = View.inflate(context, R.layout.download_simulator_dialog, null)
|
||||
|
||||
app_pb_progress = view.findViewById(R.id.progress)
|
||||
appProgressSize = view.findViewById(R.id.size)
|
||||
appProgressRemain = view.findViewById(R.id.remain)
|
||||
appProgressAnchor = view.findViewById(R.id.progress_anchor)
|
||||
appProgressPercent = view.findViewById(R.id.percent)
|
||||
appProgressFilling = view.findViewById(R.id.progress_filling)
|
||||
|
||||
view.findViewById<View>(R.id.app_tv_cancel).setOnClickListener {
|
||||
DownloadManager.getInstance(context).pause(simulator?.apk?.url)
|
||||
MtaHelper.onEvent("模拟器下载", "下载中弹窗", "点击关闭")
|
||||
downloadDialog?.dismiss()
|
||||
}
|
||||
|
||||
downloadDialog?.setOnDismissListener {
|
||||
DownloadManager.getInstance(context).removeObserver(dataWatcher)
|
||||
}
|
||||
|
||||
downloadDialog?.setCanceledOnTouchOutside(false)
|
||||
downloadDialog?.setCancelable(false)
|
||||
downloadDialog?.closeOptionsMenu()
|
||||
downloadDialog?.requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||
downloadDialog?.setContentView(view)
|
||||
val params = downloadDialog?.window?.attributes
|
||||
params?.width = context.resources.displayMetrics.widthPixels - DisplayUtils.dip2px(60f)
|
||||
downloadDialog?.window?.attributes = params
|
||||
|
||||
download(context, simulator)
|
||||
}
|
||||
|
||||
private fun showNoneEmulatorDialog(context: Context) {
|
||||
val dialog = DialogUtils.showNewAlertDialog(context, "安装模拟器", "模拟器游戏需要先下载安装对应的模拟器,才可以运行", "取消", "暂无下载", null, {
|
||||
ToastUtils.showToast("该模拟器暂未提供下载")
|
||||
})
|
||||
dialog?.window?.findViewById<TextView>(R.id.confirm)?.setTextColor(ContextCompat.getColor(context, R.color.text_cccccc))
|
||||
}
|
||||
|
||||
private fun download(context: Context, simulator: SimulatorEntity?) {
|
||||
val apkEntity = simulator?.apk ?: return
|
||||
DownloadManager.getInstance(context).pauseAll()
|
||||
|
||||
val entity = DownloadManager.getInstance(context).getDownloadEntityByUrl(apkEntity.url)
|
||||
if (entity != null) {
|
||||
when (entity.status) {
|
||||
DownloadStatus.pause, DownloadStatus.subscribe,
|
||||
DownloadStatus.neterror, DownloadStatus.timeout -> {
|
||||
DownloadManager.getInstance(context).addObserver(dataWatcher)
|
||||
uiExecutor.executeWithDelay(Runnable { DownloadManager.getInstance(context).resume(entity, true) }, 200)
|
||||
downloadDialog?.show()
|
||||
}
|
||||
DownloadStatus.done -> DataChanger.notifyDataChanged(entity)
|
||||
|
||||
else -> createDownload(context, apkEntity, simulator)
|
||||
}
|
||||
} else {
|
||||
createDownload(context, apkEntity, simulator)
|
||||
}
|
||||
}
|
||||
|
||||
private fun createDownload(context: Context, apkEntity: ApkEntity, simulator: SimulatorEntity) {
|
||||
DownloadManager.getInstance(context).addObserver(dataWatcher)
|
||||
val downloadEntity = DownloadEntity()
|
||||
downloadEntity.url = apkEntity.url
|
||||
downloadEntity.name = simulator.name
|
||||
downloadEntity.path = getDownloadPath(simulator.name, apkEntity.format)
|
||||
downloadEntity.platform = apkEntity.getPlatform()
|
||||
downloadEntity.packageName = apkEntity.packageName
|
||||
downloadEntity.versionName = apkEntity.version
|
||||
|
||||
downloadEntity.addMetaExtra(Constants.EXTRA_DOWNLOAD_TYPE, Constants.SIMULATOR_DOWNLOAD)
|
||||
downloadEntity.addMetaExtra(Constants.SIMULATOR_DOWNLOAD_START_TIME, (System.currentTimeMillis() / 1000).toString())
|
||||
uiExecutor.executeWithDelay(Runnable { DownloadManager.getInstance(context).add(downloadEntity) }, 200)
|
||||
|
||||
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, "")
|
||||
|
||||
downloadDialog?.show()
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
@Volatile
|
||||
private var instance: SimulatorDownloadManager? = null
|
||||
|
||||
@JvmStatic
|
||||
fun getInstance(): SimulatorDownloadManager {
|
||||
return instance ?: synchronized(this) {
|
||||
instance ?: SimulatorDownloadManager().also { instance = it }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
enum class SimulatorLocation(val value: String) {
|
||||
LAUNCH("启动"),
|
||||
SIMULATOR_GAME("模拟器游戏"),
|
||||
SIMULATOR_MANAGE("模拟器游戏-模拟器管理")
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,219 @@
|
||||
package com.gh.common.simulator
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.text.TextUtils
|
||||
import com.g00fy2.versioncompare.Version
|
||||
import com.gh.common.util.*
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.manager.UserManager
|
||||
import com.gh.gamecenter.retrofit.BiResponse
|
||||
import com.gh.gamecenter.retrofit.EmptyResponse
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.download.DownloadDao
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import com.lightgame.download.FileUtils
|
||||
import com.lightgame.utils.AppManager
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.ResponseBody
|
||||
import java.io.File
|
||||
|
||||
|
||||
object SimulatorGameManager {
|
||||
|
||||
private val gamePath = FileUtils.getDownloadPath(HaloApp.getInstance().application, "emulator_game")
|
||||
|
||||
@JvmStatic
|
||||
fun getPathByType(type: String) = "${gamePath}/${type}"
|
||||
|
||||
@JvmStatic
|
||||
fun deleteLocalGames(names: List<String>) {
|
||||
val downloadEntityList = DownloadDao.getInstance(HaloApp.getInstance().application).all
|
||||
names.forEach { name ->
|
||||
val downloadEntity = downloadEntityList.find { it.name == name }
|
||||
if (downloadEntity != null) {
|
||||
val file = File(downloadEntity.path)
|
||||
if (file.exists()) {
|
||||
file.delete()
|
||||
DownloadDao.getInstance(HaloApp.getInstance().application).delete(downloadEntity.url)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun deleteLocalGame(name: String) {
|
||||
val downloadEntityList = DownloadDao.getInstance(HaloApp.getInstance().application).all
|
||||
val downloadEntity = downloadEntityList.find { it.name == name }
|
||||
if (downloadEntity != null) {
|
||||
val file = File(downloadEntity.path)
|
||||
if (file.exists()) {
|
||||
file.delete()
|
||||
DownloadDao.getInstance(HaloApp.getInstance().application).delete(downloadEntity.url)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun findDownloadEntityByUrl(url: String?): DownloadEntity? {
|
||||
val downloadEntity = DownloadDao.getInstance(HaloApp.getInstance().application).get(url)
|
||||
if (downloadEntity != null) {
|
||||
val isFileCompleted = DownloadManager.getInstance(HaloApp.getInstance().application).isFileCompleted(url)
|
||||
if (downloadEntity.isSimulatorGame() && isFileCompleted) {
|
||||
return downloadEntity
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun isSimulatorGame(gameEntity: GameEntity) = gameEntity.category == "simulator"
|
||||
|
||||
|
||||
@JvmStatic
|
||||
fun launchSimulatorGame(downloadEntity: DownloadEntity, gameEntity: GameEntity) {
|
||||
val versionFromInstalledApp = PackageUtils.getVersionByPackage(gameEntity.simulator?.apk?.packageName)
|
||||
val shouldShowUpdate = Version(gameEntity.simulator?.apk?.version).isHigherThan(versionFromInstalledApp)
|
||||
if (shouldShowUpdate) {
|
||||
SimulatorDownloadManager.getInstance().showDownloadDialog(AppManager.getInstance().recentActiveActivity, gameEntity.simulator,
|
||||
SimulatorDownloadManager.SimulatorLocation.LAUNCH, gameEntity.id, gameEntity.name
|
||||
?: "") {
|
||||
jumpToSimulator(downloadEntity, gameEntity)
|
||||
}
|
||||
} else {
|
||||
jumpToSimulator(downloadEntity, gameEntity)
|
||||
}
|
||||
}
|
||||
|
||||
private fun jumpToSimulator(downloadEntity: DownloadEntity, gameEntity: GameEntity) {
|
||||
val intent = Intent()
|
||||
intent.data = Uri.fromFile(File(downloadEntity.path))
|
||||
if (gameEntity.simulatorType == "FBA") {
|
||||
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", gameEntity.icon ?: "")
|
||||
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("模拟器安装错误")
|
||||
}
|
||||
|
||||
recordPlaySimulatorGames(gameEntity.id)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 记录设备下载的模拟器游戏
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
@JvmStatic
|
||||
fun recordDownloadSimulatorGames(gameId: String) {
|
||||
val requestMap = hashMapOf<String, Any>()
|
||||
requestMap["game_id"] = gameId
|
||||
requestMap["package"] = "-"
|
||||
val body = requestMap.createRequestBodyAny()
|
||||
RetrofitManager.getInstance(HaloApp.getInstance().application).api
|
||||
.downloadSimulatorGames(HaloApp.getInstance().gid, body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(EmptyResponse())
|
||||
}
|
||||
|
||||
/**
|
||||
* 标记已玩过
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
fun postPlayedGame(gameId: String, packageName: String) {
|
||||
if (!TextUtils.isEmpty(gameId) && UserManager.getInstance().isLoggedIn) {
|
||||
val requestMap = hashMapOf<String, Any>()
|
||||
requestMap["game_id"] = gameId
|
||||
requestMap["package"] = packageName
|
||||
val body = requestMap.toRequestBody()
|
||||
RetrofitManager.getInstance(HaloApp.getInstance().application).api
|
||||
.postPlayedGame(UserManager.getInstance().userId, body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(EmptyResponse())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 记录启动设备上的模拟器游戏
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
fun recordPlaySimulatorGames(gameId: String) {
|
||||
val requestMap = hashMapOf<String, Any>()
|
||||
requestMap["game_id"] = gameId
|
||||
requestMap["package"] = "-"
|
||||
val body = requestMap.createRequestBodyAny()
|
||||
RetrofitManager.getInstance(HaloApp.getInstance().application).api
|
||||
.playedSimulatorGames(HaloApp.getInstance().gid, body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(EmptyResponse())
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除设备下载模拟器游戏的记录
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
fun deleteSimulatorGame(gameId: String, callback: () -> Unit) {
|
||||
RetrofitManager.getInstance(HaloApp.getInstance().application).api
|
||||
.deleteSimulatorGame(HaloApp.getInstance().gid, gameId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
callback.invoke()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除设备下载模拟器游戏的记录
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
fun deleteSimulatorGames(gameIds: List<String>, callback: () -> Unit) {
|
||||
val requestMap = hashMapOf<String, Any>()
|
||||
requestMap["game_ids"] = gameIds
|
||||
RetrofitManager.getInstance(HaloApp.getInstance().application).api
|
||||
.deleteSimulatorGames(HaloApp.getInstance().gid, requestMap.toRequestBody())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
callback.invoke()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除设备下载模拟器游戏的记录
|
||||
*/
|
||||
@JvmStatic
|
||||
@SuppressLint("CheckResult")
|
||||
fun deleteAllSimulatorGame() {
|
||||
RetrofitManager.getInstance(HaloApp.getInstance().application).api
|
||||
.deleteAllSimulatorGame(HaloApp.getInstance().gid)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(EmptyResponse())
|
||||
}
|
||||
}
|
||||
@ -5,11 +5,12 @@ import com.gh.gamecenter.entity.SettingsEntity
|
||||
|
||||
object AdHelper {
|
||||
|
||||
// 搜索为空/求版本/意见反馈-功能收录/发现
|
||||
// 搜索为空/求版本/意见反馈-功能收录/发现/模拟器游戏
|
||||
const val LOCATION_SEARCH_EMPTY = "search_empty"
|
||||
const val LOCATION_GAME_REQUEST_VERSION = "game_request_version"
|
||||
const val LOCATION_SUGGESTION_FUNCTION = "suggestion_function"
|
||||
const val LOCATION_DISCOVER = "discover"
|
||||
const val LOCATION_SIMULATOR_GAME = "simulator_game"
|
||||
|
||||
fun getAd(location: String): SettingsEntity.AD? {
|
||||
val adList = Config.getSettings()?.adList ?: return null
|
||||
@ -34,4 +35,19 @@ object AdHelper {
|
||||
return discoverAdList
|
||||
}
|
||||
|
||||
fun getAdForLocation(location: String): SettingsEntity.AD? {
|
||||
val adList = Config.getSettings()?.adList ?: return null
|
||||
|
||||
var result: SettingsEntity.AD? = null
|
||||
run outside@ {
|
||||
for (ad in adList) {
|
||||
if (ad.location == location) {
|
||||
result = ad
|
||||
return@outside
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
}
|
||||
@ -33,6 +33,7 @@ object CommentHelper {
|
||||
showConversation: Boolean,
|
||||
articleId: String,
|
||||
communityId: String,
|
||||
isShowTop: Boolean = false,
|
||||
ignoreModerator: Boolean = false,
|
||||
listener: OnCommentOptionClickListener?) {
|
||||
showCommentOptions(view = view,
|
||||
@ -40,6 +41,7 @@ object CommentHelper {
|
||||
showConversation = showConversation,
|
||||
articleId = articleId,
|
||||
communityId = communityId,
|
||||
isShowTop = isShowTop,
|
||||
ignoreModerator = ignoreModerator,
|
||||
listener = listener)
|
||||
}
|
||||
@ -79,11 +81,16 @@ object CommentHelper {
|
||||
communityId: String? = null,
|
||||
answerId: String? = null,
|
||||
videoId: String? = null,
|
||||
isShowTop: Boolean = false,
|
||||
ignoreModerator: Boolean = false,
|
||||
isVideoAuthor: Boolean = false,
|
||||
listener: OnCommentOptionClickListener? = null) {
|
||||
val context = view.context
|
||||
val dialogOptions = ArrayList<String>()
|
||||
if (isShowTop && articleId != null && commentEntity.me?.isArticleOrAnswerAuthor == true) {
|
||||
dialogOptions.add(if (commentEntity.isTop) "取消置顶" else "置顶")
|
||||
}
|
||||
|
||||
dialogOptions.add("复制")
|
||||
if (commentEntity.user.id != UserManager.getInstance().userId) {
|
||||
dialogOptions.add("投诉")
|
||||
|
||||
@ -2,7 +2,6 @@ package com.gh.common.util;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Dialog;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.text.TextUtils;
|
||||
@ -12,6 +11,9 @@ import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.gh.gamecenter.CommentDetailActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.CommentViewHolder;
|
||||
@ -39,8 +41,6 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.ResponseBody;
|
||||
@ -529,10 +529,7 @@ public class CommentUtils {
|
||||
|
||||
//复制文字
|
||||
public static void copyText(String copyContent, Context context) {
|
||||
ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
cmb.setText(copyContent);
|
||||
|
||||
ToastUtils.INSTANCE.showToast("复制成功");
|
||||
ExtensionsKt.copyTextAndToast(copyContent, "复制成功");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -57,6 +57,9 @@ public class DataLogUtils {
|
||||
map.put("channel", channel);
|
||||
|
||||
Map<String, String> params = new HashMap<>();
|
||||
if ("search-hot-tag".equals(topic) || "game".equals(topic) || "slide".equals(topic)) {
|
||||
params.put("meta", LogUtils.getMetaObject().toString());
|
||||
}
|
||||
params.put("topic", topic);
|
||||
params.put("source", "GH-ASSIST-Client");
|
||||
params.put("time", String.valueOf(Utils.getTime(context)));
|
||||
|
||||
@ -3,11 +3,13 @@ package com.gh.common.util;
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.gh.common.constant.Constants;
|
||||
import com.gh.common.exposure.meta.MetaUtil;
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gid.GidCallback;
|
||||
import com.gh.gid.GidHelper;
|
||||
import com.halo.assistant.HaloApp;
|
||||
@ -16,7 +18,10 @@ import com.lightgame.utils.Utils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import io.sentry.android.core.SentryAndroid;
|
||||
import io.sentry.core.Sentry;
|
||||
import io.sentry.core.protocol.User;
|
||||
|
||||
/**
|
||||
* Created by LGT on 2016/6/15.
|
||||
@ -35,6 +40,35 @@ public class DataUtils {
|
||||
if (CommonDebug.IS_DEBUG) {
|
||||
return;
|
||||
}
|
||||
|
||||
SentryAndroid.init(context, options -> {
|
||||
options.setDebug(BuildConfig.DEBUG);
|
||||
options.setEnableSessionTracking(true);
|
||||
options.setEnvironment(BuildConfig.FLAVOR);
|
||||
options.setDsn("https://6b1caf0d17c1408e8680f3f73ff80bd0@sentry.ghzs.com/22");
|
||||
|
||||
options.setBeforeSend((event, hint) -> {
|
||||
if (BuildConfig.DEBUG) {
|
||||
return null;
|
||||
} else {
|
||||
return event;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Sentry.configureScope(scope -> {
|
||||
User user = new User();
|
||||
user.setId(HaloApp.getInstance().getGid());
|
||||
scope.setUser(user);
|
||||
|
||||
if (BuildConfig.BUILD_TIME != 0L) {
|
||||
scope.setTag("alias", "内测版" + BuildConfig.VERSION_NAME + "_" + BuildConfig.BUILD_TIME);
|
||||
} else {
|
||||
scope.setTag("alias", "正式版" + BuildConfig.VERSION_NAME);
|
||||
scope.setTag("channel", channel);
|
||||
}
|
||||
});
|
||||
|
||||
//TalkingData
|
||||
// try {
|
||||
// TCAgent.LOG_ON = false;
|
||||
@ -139,8 +173,8 @@ public class DataUtils {
|
||||
}
|
||||
|
||||
public static void onEvent(Context var0, String var1, String var2) {
|
||||
Properties prop = new Properties();
|
||||
prop.setProperty(var1, var2);
|
||||
// Properties prop = new Properties();
|
||||
// prop.setProperty(var1, var2);
|
||||
// StatService.trackCustomKVEvent(var0, var1, prop);
|
||||
}
|
||||
|
||||
@ -161,64 +195,64 @@ public class DataUtils {
|
||||
}
|
||||
|
||||
public static void onEvent(Context var0, String var1, String var2, Map<String, Object> var3) {
|
||||
Properties prop = new Properties();
|
||||
prop.setProperty("label", var2);
|
||||
for (String key : var3.keySet()) {
|
||||
prop.setProperty(key, var3.get(key) + "");
|
||||
}
|
||||
// Properties prop = new Properties();
|
||||
// prop.setProperty("label", var2);
|
||||
// for (String key : var3.keySet()) {
|
||||
// prop.setProperty(key, var3.get(key) + "");
|
||||
// }
|
||||
// StatService.trackCustomKVEvent(var0, var1, prop);
|
||||
}
|
||||
|
||||
public static void trackTimeEvent(Context context, String eventId, int costTime, String... kv) {
|
||||
|
||||
Properties prop = new Properties();
|
||||
for (int i = 0; i < kv.length; i++) {
|
||||
if (i % 2 != 0 || i != 0) {
|
||||
String key = kv[i - 1];
|
||||
String value = kv[i];
|
||||
if (!TextUtils.isEmpty(key) && !TextUtils.isEmpty(value)) {
|
||||
prop.setProperty(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (prop.size() == 0) return;
|
||||
|
||||
//
|
||||
// Properties prop = new Properties();
|
||||
// for (int i = 0; i < kv.length; i++) {
|
||||
// if (i % 2 != 0 || i != 0) {
|
||||
// String key = kv[i - 1];
|
||||
// String value = kv[i];
|
||||
// if (!TextUtils.isEmpty(key) && !TextUtils.isEmpty(value)) {
|
||||
// prop.setProperty(key, value);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (prop.size() == 0) return;
|
||||
//
|
||||
// StatService.trackCustomKVTimeIntervalEvent(context, costTime, eventId, prop);
|
||||
}
|
||||
|
||||
// 游戏下载
|
||||
public static void onGameDownloadEvent(Context context, String gameName, String platform, String entrance, String status, String method) {
|
||||
// Map<String, Object> kv = new HashMap<>();
|
||||
//
|
||||
// platform = PlatformUtils.getInstance(HaloApp.getInstance().getApplication()).getPlatformName(platform);
|
||||
//
|
||||
// kv.put("版本", platform);
|
||||
// kv.put("用户机型", Build.MODEL);
|
||||
// kv.put("设备IMEI", Util_System_Phone_State.getDeviceId(HaloApp.getInstance().getApplication()));
|
||||
// kv.put("网络状态", DeviceUtils.getNetwork(HaloApp.getInstance().getApplication()));
|
||||
// kv.put("光环助手版本", BuildConfig.VERSION_NAME);
|
||||
// kv.put("位置", entrance);
|
||||
// kv.put("类型", method);
|
||||
// kv.put("厂商", Build.MANUFACTURER);
|
||||
// kv.put("Android版本", Build.VERSION.RELEASE);
|
||||
// onEvent(context, "游戏下载", gameName, kv);
|
||||
//
|
||||
// Map<String, Object> kv2 = new HashMap<>();
|
||||
// kv2.put("状态", status);
|
||||
// kv2.put("位置", entrance);
|
||||
//
|
||||
// if (status.equals("开始")) {
|
||||
// kv2.put("版本", entrance + "-开始");
|
||||
// kv2.put("游戏分平台", gameName + "-" + platform + "-开始");
|
||||
// kv2.put("光环助手版本", BuildConfig.VERSION_NAME + "-开始");
|
||||
// } else {
|
||||
// kv2.put("版本", platform);
|
||||
// kv2.put("游戏分平台", gameName + "-" + platform);
|
||||
// kv2.put("光环助手版本", BuildConfig.VERSION_NAME);
|
||||
// }
|
||||
//
|
||||
// onEvent(context, "游戏下载位置", gameName, kv2);
|
||||
Map<String, Object> kv = new HashMap<>();
|
||||
|
||||
platform = PlatformUtils.getInstance(HaloApp.getInstance().getApplication()).getPlatformName(platform);
|
||||
|
||||
kv.put("版本", platform);
|
||||
kv.put("用户机型", Build.MODEL);
|
||||
kv.put("设备IMEI", MetaUtil.getIMEI());
|
||||
kv.put("网络状态", DeviceUtils.getNetwork(HaloApp.getInstance().getApplication()));
|
||||
kv.put("光环助手版本", BuildConfig.VERSION_NAME);
|
||||
kv.put("位置", entrance);
|
||||
kv.put("类型", method);
|
||||
kv.put("厂商", Build.MANUFACTURER);
|
||||
kv.put("Android版本", Build.VERSION.RELEASE);
|
||||
onEvent(context, "游戏下载", gameName, kv);
|
||||
|
||||
Map<String, Object> kv2 = new HashMap<>();
|
||||
kv2.put("状态", status);
|
||||
kv2.put("位置", entrance);
|
||||
|
||||
if (status.equals("开始")) {
|
||||
kv2.put("版本", entrance + "-开始");
|
||||
kv2.put("游戏分平台", gameName + "-" + platform + "-开始");
|
||||
kv2.put("光环助手版本", BuildConfig.VERSION_NAME + "-开始");
|
||||
} else {
|
||||
kv2.put("版本", platform);
|
||||
kv2.put("游戏分平台", gameName + "-" + platform);
|
||||
kv2.put("光环助手版本", BuildConfig.VERSION_NAME);
|
||||
}
|
||||
|
||||
onEvent(context, "游戏下载位置", gameName, kv2);
|
||||
}
|
||||
|
||||
// 游戏更新
|
||||
|
||||
@ -5,6 +5,7 @@ import android.view.View;
|
||||
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.repository.ReservationRepository;
|
||||
import com.gh.common.simulator.SimulatorGameManager;
|
||||
import com.gh.common.view.DownloadProgressBar;
|
||||
import com.gh.common.xapk.XapkInstaller;
|
||||
import com.gh.common.xapk.XapkUnzipStatus;
|
||||
@ -66,6 +67,9 @@ public class DetailDownloadUtils {
|
||||
if ("dialog".equals(viewHolder.gameEntity.getDownloadOffStatus())) {
|
||||
viewHolder.mDownloadPb.setText(TextUtils.isEmpty(viewHolder.gameEntity.getDownloadOffText()) ? "查看详情" : viewHolder.gameEntity.getDownloadOffText());
|
||||
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.NONE_WITH_HINT);
|
||||
} else if ("updating".equals(viewHolder.gameEntity.getDownloadOffStatus())) {
|
||||
viewHolder.mDownloadPb.setText(TextUtils.isEmpty(viewHolder.gameEntity.getDownloadOffText()) ? "更新中" : viewHolder.gameEntity.getDownloadOffText());
|
||||
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.UPDATING);
|
||||
} else {
|
||||
viewHolder.mDownloadPb.setText(TextUtils.isEmpty(viewHolder.gameEntity.getDownloadOffText()) ? "暂无下载" : viewHolder.gameEntity.getDownloadOffText());
|
||||
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.NONE);
|
||||
@ -148,13 +152,25 @@ public class DetailDownloadUtils {
|
||||
}
|
||||
break;
|
||||
case done:
|
||||
viewHolder.mDownloadPb.setText(R.string.install);
|
||||
if (downloadEntity.isPluggable()
|
||||
&& PackagesManager.isInstalled(downloadEntity.getPackageName())) {
|
||||
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.INSTALL_PLUGIN);
|
||||
} else {
|
||||
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.INSTALL_NORMAL);
|
||||
if (SimulatorGameManager.isSimulatorGame(viewHolder.gameEntity)){
|
||||
boolean isInstalled = PackageUtils.isInstalledFromAllPackage(viewHolder.context, viewHolder.gameEntity.getSimulator().getApk().getPackageName());
|
||||
if (isInstalled){
|
||||
viewHolder.mDownloadPb.setText(R.string.launch);
|
||||
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.LAUNCH_OR_OPEN);
|
||||
}else{
|
||||
viewHolder.mDownloadPb.setText(R.string.install);
|
||||
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.INSTALL_NORMAL);
|
||||
}
|
||||
}else{
|
||||
viewHolder.mDownloadPb.setText(R.string.install);
|
||||
if (downloadEntity.isPluggable()
|
||||
&& PackagesManager.isInstalled(downloadEntity.getPackageName())) {
|
||||
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.INSTALL_PLUGIN);
|
||||
} else {
|
||||
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.INSTALL_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case cancel:
|
||||
case hijack:
|
||||
|
||||
@ -4,12 +4,15 @@ import android.app.Activity;
|
||||
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.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
@ -32,6 +35,13 @@ import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.facebook.drawee.generic.GenericDraweeHierarchy;
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.gh.common.AppExecutor;
|
||||
@ -71,13 +81,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public class DialogUtils {
|
||||
|
||||
public static Dialog showWaitDialog(Context context, String msg) {
|
||||
@ -347,10 +350,21 @@ public class DialogUtils {
|
||||
* @param cmListener 确认按钮监听
|
||||
*/
|
||||
public static Dialog showNewAlertDialog(Context context, String title, CharSequence message
|
||||
, String negative, String positive, final CancelListener clListener, final ConfirmListener cmListener) {
|
||||
, String negative, String positive, TrackableEntity trackableEntity, int gravity, final CancelListener clListener, final ConfirmListener cmListener) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.GhAlertDialog);
|
||||
final Dialog dialog;
|
||||
if (trackableEntity != null) {
|
||||
dialog = new TrackableDialog(context,
|
||||
R.style.GhAlertDialog,
|
||||
trackableEntity.getEvent(),
|
||||
trackableEntity.getKey(),
|
||||
trackableEntity.getValue(),
|
||||
trackableEntity.getCancelValue(),
|
||||
trackableEntity.getKeyBackValue(),
|
||||
trackableEntity.getLogShowEvent());
|
||||
} else {
|
||||
dialog = new Dialog(context, R.style.GhAlertDialog);
|
||||
}
|
||||
|
||||
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_new_alert, null);
|
||||
|
||||
@ -359,6 +373,8 @@ public class DialogUtils {
|
||||
TextView cancelBtn = contentView.findViewById(R.id.cancel);
|
||||
TextView confirmBtn = contentView.findViewById(R.id.confirm);
|
||||
View middleLine = contentView.findViewById(R.id.middle_line);
|
||||
titleTv.setGravity(gravity);
|
||||
contentTv.setGravity(gravity);
|
||||
|
||||
titleTv.setText(title);
|
||||
contentTv.setText(message);
|
||||
@ -395,6 +411,11 @@ public class DialogUtils {
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public static Dialog showNewAlertDialog(Context context, String title, CharSequence message
|
||||
, String negative, String positive, final CancelListener clListener, final ConfirmListener cmListener) {
|
||||
return showNewAlertDialog(context, title, message, negative, positive, null, Gravity.LEFT, clListener, cmListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Material Design 风格弹窗
|
||||
*
|
||||
@ -967,13 +988,13 @@ public class DialogUtils {
|
||||
WindowManager.LayoutParams params = window.getAttributes();
|
||||
params.horizontalMargin = 0;
|
||||
params.width = context.getResources().getDisplayMetrics().widthPixels - DisplayUtils.dip2px(40);
|
||||
int height = context.getResources().getDisplayMetrics().heightPixels - DisplayUtils.dip2px(120);
|
||||
int maxHeight = DisplayUtils.dip2px(446);
|
||||
if (height > maxHeight) {
|
||||
params.height = maxHeight;
|
||||
} else {
|
||||
params.height = height;
|
||||
}
|
||||
// int height = context.getResources().getDisplayMetrics().heightPixels - DisplayUtils.dip2px(120);
|
||||
// int maxHeight = DisplayUtils.dip2px(446);
|
||||
// if (height > maxHeight) {
|
||||
// params.height = maxHeight;
|
||||
// } else {
|
||||
// params.height = height;
|
||||
// }
|
||||
window.setAttributes(params);
|
||||
}
|
||||
|
||||
@ -1006,8 +1027,6 @@ public class DialogUtils {
|
||||
hierarchy.setPlaceholderImage(R.drawable.permission_storage);
|
||||
} else if (position == 1) {
|
||||
hierarchy.setPlaceholderImage(R.drawable.permission_phone_state);
|
||||
} else {
|
||||
hierarchy.setPlaceholderImage(R.drawable.permission_sdk);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1859,6 +1878,30 @@ public class DialogUtils {
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public static void showShortCutPermissionDialog(Context context) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.DialogWindowTransparent);
|
||||
|
||||
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_shortcut_permission, null);
|
||||
|
||||
Context finalContext = context;
|
||||
contentView.findViewById(R.id.dialog_positive).setOnClickListener(v -> {
|
||||
dialog.dismiss();
|
||||
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
intent.setData(Uri.parse("package:" + finalContext.getPackageName()));
|
||||
finalContext.startActivity(intent);
|
||||
});
|
||||
|
||||
contentView.findViewById(R.id.dialog_negative).setOnClickListener(v -> {
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(contentView);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context may be is application context
|
||||
* @return activity context
|
||||
|
||||
@ -22,6 +22,7 @@ import com.gh.common.exposure.ExposureType
|
||||
import com.gh.common.util.EntranceUtils.*
|
||||
import com.gh.gamecenter.*
|
||||
import com.gh.gamecenter.amway.AmwayActivity
|
||||
import com.gh.gamecenter.catalog.CatalogActivity
|
||||
import com.gh.gamecenter.category.CategoryDirectoryActivity
|
||||
import com.gh.gamecenter.download.DownloadFragment.Companion.INDEX_UPDATE
|
||||
import com.gh.gamecenter.entity.*
|
||||
@ -57,7 +58,6 @@ import com.gh.gamecenter.video.detail.VideoDetailContainerViewModel
|
||||
import com.gh.gamecenter.video.game.GameVideoActivity
|
||||
import com.gh.gamecenter.video.videomanager.VideoManagerActivity
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Util_System_ClipboardManager
|
||||
import com.lightgame.utils.Utils
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
@ -133,7 +133,9 @@ object DirectUtils {
|
||||
"server",
|
||||
"top_game_comment",
|
||||
"wechat_bind",
|
||||
"video")
|
||||
"video",
|
||||
"catalog"
|
||||
)
|
||||
|
||||
fun directToLinkPage(context: Context,
|
||||
linkEntity: LinkEntity,
|
||||
@ -200,6 +202,8 @@ object DirectUtils {
|
||||
|
||||
"category", "分类" -> directCategoryDirectory(context, linkEntity.link!!, linkEntity.text!!)
|
||||
|
||||
"catalog" -> directCatalog(context, linkEntity.link!!, linkEntity.text!!, entrance, path)
|
||||
|
||||
"block", "版块" -> {
|
||||
if (linkEntity.link.isNullOrEmpty()) return
|
||||
directToBlock(context,
|
||||
@ -575,7 +579,7 @@ object DirectUtils {
|
||||
@JvmStatic
|
||||
fun directToExternalBrowser(context: Context, url: String) {
|
||||
if (url.isEmpty()) return
|
||||
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
|
||||
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(Uri.decode(url)))
|
||||
if (context !is AppCompatActivity) {
|
||||
browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
}
|
||||
@ -606,8 +610,7 @@ object DirectUtils {
|
||||
context.startActivity(intent)
|
||||
} else {
|
||||
// 没有安装QQ 复制账号
|
||||
Util_System_ClipboardManager.setText(context, qq)
|
||||
Utils.toast(context, "已复制 QQ $qq")
|
||||
qq?.copyTextAndToast("已复制 QQ $qq")
|
||||
}
|
||||
}
|
||||
|
||||
@ -889,6 +892,20 @@ object DirectUtils {
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转新分类
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directCatalog(context: Context, catalogId: String, catalogTitle: String, entrance: String? = null, path: String? = "") {
|
||||
if (catalogId.isEmpty()) return
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_TO, CatalogActivity::class.java.name)
|
||||
bundle.putString(KEY_CATALOG_ID, catalogId)
|
||||
bundle.putString(KEY_CATALOG_TITLE, catalogTitle)
|
||||
bundle.putString(KEY_ENTRANCE, BaseActivity.mergeEntranceAndPath(entrance, path))
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到问题标签详情
|
||||
*/
|
||||
|
||||
@ -8,13 +8,22 @@ import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.collection.ArrayMap;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.dialog.CertificationDialog;
|
||||
import com.gh.common.dialog.DeviceRemindDialog;
|
||||
import com.gh.common.dialog.PackageCheckDialogFragment;
|
||||
import com.gh.common.dialog.ReserveDialogFragment;
|
||||
import com.gh.common.exposure.ExposureEvent;
|
||||
import com.gh.common.history.HistoryHelper;
|
||||
import com.gh.common.repository.ReservationRepository;
|
||||
import com.gh.common.simulator.SimulatorDownloadManager;
|
||||
import com.gh.common.simulator.SimulatorGameManager;
|
||||
import com.gh.common.xapk.XapkInstaller;
|
||||
import com.gh.common.xapk.XapkUnzipStatus;
|
||||
import com.gh.download.DownloadManager;
|
||||
@ -34,14 +43,9 @@ import com.lightgame.download.DownloadStatus;
|
||||
import com.lightgame.download.FileUtils;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.collection.ArrayMap;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
/**
|
||||
* todo 下载判断不能以按钮文案为判断条件,否则按钮文案修改时又要修改判断逻辑
|
||||
*/
|
||||
@ -195,6 +199,10 @@ public class DownloadItemUtils {
|
||||
holder.gameDownloadBtn.setText("查看");
|
||||
holder.gameDownloadBtn.setTextColor(ContextCompat.getColor(context, R.color.white));
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_download_style);
|
||||
} else if ("updating".equals(offStatus)) {
|
||||
holder.gameDownloadBtn.setText("更新中");
|
||||
holder.gameDownloadBtn.setTextColor(ContextCompat.getColor(context, R.color.white));
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.download_button_updating_style);
|
||||
} else {
|
||||
holder.gameDownloadBtn.setText("暂无");
|
||||
holder.gameDownloadBtn.setTextColor(ContextCompat.getColor(context, R.color.button_gray));
|
||||
@ -223,9 +231,18 @@ public class DownloadItemUtils {
|
||||
if (entryMap != null && !entryMap.isEmpty()) {
|
||||
DownloadEntity downloadEntity = entryMap.get(apkEntity.getPlatform());
|
||||
if (downloadEntity != null) {
|
||||
// 更改进度条和提示文本的状态
|
||||
changeStatus(context, holder, downloadEntity, isShowPlatform, true);
|
||||
return;
|
||||
if (ExtensionsKt.isSimulatorGame(downloadEntity)) {
|
||||
if (downloadEntity.getStatus() != DownloadStatus.done) {
|
||||
// 更改进度条和提示文本的状态
|
||||
changeStatus(context, holder, downloadEntity, isShowPlatform, true);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// 更改进度条和提示文本的状态
|
||||
changeStatus(context, holder, downloadEntity, isShowPlatform, true);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -403,7 +420,7 @@ public class DownloadItemUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param clickCallback 供那些需要知道点击回调的地方使用
|
||||
* @param clickCallback 供那些需要知道点击回调的地方使用,触发具体响应才会回调
|
||||
*/
|
||||
public static void setOnClickListener(final Context context,
|
||||
final TextView downloadBtn,
|
||||
@ -415,27 +432,50 @@ public class DownloadItemUtils {
|
||||
final ExposureEvent traceEvent,
|
||||
@Nullable final EmptyCallback clickCallback) {
|
||||
|
||||
setOnClickListener(context, downloadBtn, gameEntity, position, adapter, entrance, location, traceEvent, clickCallback, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param allStateClickCallback 供那些需要知道点击回调的地方使用,只要触发点击动作就会回调
|
||||
*/
|
||||
public static void setOnClickListener(final Context context,
|
||||
final TextView downloadBtn,
|
||||
final GameEntity gameEntity,
|
||||
final int position,
|
||||
final RecyclerView.Adapter<? extends RecyclerView.ViewHolder> adapter,
|
||||
final String entrance,
|
||||
final String location,
|
||||
final ExposureEvent traceEvent,
|
||||
@Nullable final EmptyCallback clickCallback,
|
||||
@Nullable final EmptyCallback allStateClickCallback) {
|
||||
|
||||
if (gameEntity.isReservable()) {
|
||||
if (!ReservationRepository.thisGameHasBeenReserved(gameEntity.getId())) {
|
||||
downloadBtn.setOnClickListener(v -> {
|
||||
if (allStateClickCallback != null) {
|
||||
allStateClickCallback.onCallback();
|
||||
}
|
||||
|
||||
CheckLoginUtils.checkLogin(context, entrance, () -> {
|
||||
if (clickCallback != null) {
|
||||
clickCallback.onCallback();
|
||||
}
|
||||
PermissionHelper.checkReadPhoneStatePermissionBeforeAction(context, () -> {
|
||||
ReserveDialogFragment dialogFragment = ReserveDialogFragment.getInstance(
|
||||
gameEntity,
|
||||
() -> {
|
||||
LogUtils.logReservation(gameEntity, traceEvent);
|
||||
adapter.notifyItemChanged(position);
|
||||
}
|
||||
);
|
||||
dialogFragment.show(((AppCompatActivity) context).getSupportFragmentManager(), "reserve");
|
||||
});
|
||||
ReserveDialogFragment dialogFragment = ReserveDialogFragment.getInstance(
|
||||
gameEntity,
|
||||
() -> {
|
||||
LogUtils.logReservation(gameEntity, traceEvent);
|
||||
adapter.notifyItemChanged(position);
|
||||
}
|
||||
);
|
||||
dialogFragment.show(((AppCompatActivity) context).getSupportFragmentManager(), "reserve");
|
||||
});
|
||||
});
|
||||
} else {
|
||||
downloadBtn.setOnClickListener(v -> {
|
||||
if (allStateClickCallback != null) {
|
||||
allStateClickCallback.onCallback();
|
||||
}
|
||||
|
||||
if (clickCallback != null) {
|
||||
clickCallback.onCallback();
|
||||
}
|
||||
@ -459,6 +499,10 @@ public class DownloadItemUtils {
|
||||
|
||||
if (gameEntity.getApk().size() == 0 && gameEntity.getH5Link() != null) {
|
||||
downloadBtn.setOnClickListener(v -> {
|
||||
if (allStateClickCallback != null) {
|
||||
allStateClickCallback.onCallback();
|
||||
}
|
||||
|
||||
MtaHelper.onEvent("H5页面", "入口", "列表页_" + gameEntity.getName());
|
||||
|
||||
LinkEntity linkEntity = gameEntity.getH5Link();
|
||||
@ -468,12 +512,16 @@ public class DownloadItemUtils {
|
||||
HistoryHelper.insertGameEntity(gameEntity);
|
||||
}
|
||||
|
||||
Intent i = WebActivity.getIntentForWebGame(context, gameEntity.getH5Link().getLink(), gameEntity.getName(), isPlay,linkEntity.getCloseButton());
|
||||
Intent i = WebActivity.getIntentForWebGame(context, gameEntity.getH5Link().getLink(), gameEntity.getName(), isPlay, linkEntity.getCloseButton());
|
||||
context.startActivity(i);
|
||||
});
|
||||
} else if (gameEntity.getApk().size() == 1) {
|
||||
downloadBtn.setOnClickListener(v -> {
|
||||
EmptyCallback clickRunnable = () -> {
|
||||
if (allStateClickCallback != null) {
|
||||
allStateClickCallback.onCallback();
|
||||
}
|
||||
|
||||
if (clickCallback != null) {
|
||||
clickCallback.onCallback();
|
||||
}
|
||||
@ -489,6 +537,10 @@ public class DownloadItemUtils {
|
||||
});
|
||||
} else {
|
||||
downloadBtn.setOnClickListener(v -> {
|
||||
if (allStateClickCallback != null) {
|
||||
allStateClickCallback.onCallback();
|
||||
}
|
||||
|
||||
if (clickCallback != null) {
|
||||
clickCallback.onCallback();
|
||||
}
|
||||
@ -506,7 +558,6 @@ public class DownloadItemUtils {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void onNormalClick(final Context context,
|
||||
@ -532,23 +583,27 @@ public class DownloadItemUtils {
|
||||
|
||||
if (str.equals(context.getString(R.string.download))) {
|
||||
// 先弹下载弹窗(如果需要的话)
|
||||
DownloadDialogHelper.findAvailableDialogAndShow(context, gameEntity, apk, () -> {
|
||||
CertificationDialog.showCertificationDialog(context, gameEntity, () -> {
|
||||
DialogUtils.showOverseaDownloadDialog(context, gameEntity, () -> {
|
||||
DialogUtils.checkDownload(context, apk.getSize(),
|
||||
isSubscribe -> download(context, gameEntity, downloadBtn, entrance, location, isSubscribe, traceEvent));
|
||||
PackageCheckDialogFragment.show((AppCompatActivity) context, gameEntity.getPackageDialog(), () -> {
|
||||
DownloadDialogHelper.findAvailableDialogAndShow(context, gameEntity, apk, () -> {
|
||||
CertificationDialog.showCertificationDialog(context, gameEntity, () -> {
|
||||
DialogUtils.showOverseaDownloadDialog(context, gameEntity, () -> {
|
||||
DialogUtils.checkDownload(context, apk.getSize(),
|
||||
isSubscribe -> download(context, gameEntity, downloadBtn, entrance, location, isSubscribe, traceEvent));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
DataLogUtils.uploadGameLog(context, gameEntity.getId(), gameEntity.getName(), entrance);
|
||||
} else if (str.equals(context.getString(R.string.attempt))) {
|
||||
DownloadDialogHelper.findAvailableDialogAndShow(context, gameEntity, apk, () -> {
|
||||
CertificationDialog.showCertificationDialog(context, gameEntity, () -> {
|
||||
DialogUtils.showVersionNumberDialog(context, gameEntity, () -> {
|
||||
DialogUtils.showOverseaDownloadDialog(context, gameEntity, () -> {
|
||||
DialogUtils.checkDownload(context, apk.getSize(),
|
||||
isSubscribe -> download(context, gameEntity, downloadBtn, entrance, location, isSubscribe, traceEvent));
|
||||
PackageCheckDialogFragment.show((AppCompatActivity) context, gameEntity.getPackageDialog(), () -> {
|
||||
DownloadDialogHelper.findAvailableDialogAndShow(context, gameEntity, apk, () -> {
|
||||
CertificationDialog.showCertificationDialog(context, gameEntity, () -> {
|
||||
DialogUtils.showVersionNumberDialog(context, gameEntity, () -> {
|
||||
DialogUtils.showOverseaDownloadDialog(context, gameEntity, () -> {
|
||||
DialogUtils.checkDownload(context, apk.getSize(),
|
||||
isSubscribe -> download(context, gameEntity, downloadBtn, entrance, location, isSubscribe, traceEvent));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -570,8 +625,30 @@ public class DownloadItemUtils {
|
||||
});
|
||||
}
|
||||
} else if (str.equals(context.getString(R.string.install))) {
|
||||
DownloadEntity downloadEntity = SimulatorGameManager.findDownloadEntityByUrl(apk.getUrl());
|
||||
if (gameEntity.getSimulator() != null) {
|
||||
boolean isInstalled = PackageUtils.isInstalledFromAllPackage(context, gameEntity.getSimulator().getApk().getPackageName());
|
||||
if (downloadEntity != null && SimulatorGameManager.isSimulatorGame(gameEntity) && !isInstalled) {
|
||||
SimulatorDownloadManager.getInstance().showDownloadDialog(context, gameEntity.getSimulator(),
|
||||
SimulatorDownloadManager.SimulatorLocation.LAUNCH, gameEntity.getId(), gameEntity.getName(), null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
install(context, gameEntity, position, adapter);
|
||||
} else if (str.equals(context.getString(R.string.launch))) {
|
||||
//启动模拟器游戏
|
||||
if (SimulatorGameManager.isSimulatorGame(gameEntity)) {
|
||||
DownloadEntity downloadEntity = SimulatorGameManager.findDownloadEntityByUrl(gameEntity.getApk().get(0).getUrl());
|
||||
if (downloadEntity != null) {
|
||||
File file = new File(downloadEntity.getPath());
|
||||
if (!file.exists()) {
|
||||
download(context, gameEntity, downloadBtn, entrance, location, false, traceEvent);
|
||||
return;
|
||||
}
|
||||
SimulatorGameManager.launchSimulatorGame(downloadEntity, gameEntity);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (entrance.contains("我的游戏")) {
|
||||
MtaHelper.onEvent("我的游戏_启动", "启动", gameEntity.getName());
|
||||
}
|
||||
|
||||
@ -45,6 +45,7 @@ object DownloadNotificationHelper {
|
||||
val xapkStatus = entity.meta[XapkInstaller.XAPK_UNZIP_STATUS]
|
||||
|
||||
if (entity.getMetaExtra(Constants.EXTRA_DOWNLOAD_TYPE) == Constants.SILENT_UPDATE) return
|
||||
if (entity.getMetaExtra(Constants.EXTRA_DOWNLOAD_TYPE) == Constants.SIMULATOR_DOWNLOAD) return
|
||||
|
||||
val intent = Intent()
|
||||
if (entity.status == DownloadStatus.done && xapkStatus != XapkUnzipStatus.FAILURE.name) {
|
||||
@ -114,7 +115,8 @@ object DownloadNotificationHelper {
|
||||
|| entity.status == DownloadStatus.overflow
|
||||
|| (entity.status == DownloadStatus.done // 触发安装事件以后也 cancel 掉通知
|
||||
&& !entity.meta[Constants.MARK_ALREADY_TRIGGERED_INSTALLATION].isNullOrEmpty()
|
||||
&& xapkStatus != XapkUnzipStatus.FAILURE.name)) {
|
||||
&& xapkStatus != XapkUnzipStatus.FAILURE.name)
|
||||
||entity.status == DownloadStatus.done && entity.isSimulatorGame()) {//模拟器游戏下载完需要cancel掉通知
|
||||
requireUpdateNotificationGroupDelay = true
|
||||
notificationManager.cancel(entity.path, DOWNLOAD_NOTIFICATION_ID)
|
||||
} else {
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import android.preference.PreferenceManager
|
||||
import com.gh.base.BaseActivity
|
||||
import com.gh.common.constant.Constants
|
||||
import com.gh.common.exposure.ExposureUtils
|
||||
import com.gh.common.exposure.meta.MetaUtil
|
||||
import com.gh.common.simulator.SimulatorDownloadManager
|
||||
import com.gh.common.simulator.SimulatorGameManager
|
||||
import com.gh.common.xapk.XapkInstaller
|
||||
import com.gh.download.DownloadDataHelper
|
||||
import com.gh.download.DownloadManager
|
||||
@ -75,9 +76,10 @@ object DownloadObserver {
|
||||
// MtaHelper.onEventWithBasicDeviceInfo("下载失败弹窗",
|
||||
// "游戏", downloadEntity.name,
|
||||
// "平台", downloadEntity.platform)
|
||||
val currentActivity = AppManager.getInstance().currentActivity() ?: return
|
||||
|
||||
DialogUtils.showAlertDialog(AppManager.getInstance().currentActivity(), "下载失败", "下载链接已失效,建议提交反馈", "立即反馈", "取消", {
|
||||
SuggestionActivity.startSuggestionActivity(AppManager.getInstance().currentActivity(),
|
||||
DialogUtils.showAlertDialog(currentActivity, "下载失败", "下载链接已失效,建议提交反馈", "立即反馈", "取消", {
|
||||
SuggestionActivity.startSuggestionActivity(currentActivity,
|
||||
SuggestType.gameQuestion, "notfound",
|
||||
StringUtils.buildString(downloadEntity.name, ",问题反馈:下载链接失效"),
|
||||
SimpleGameEntity(gameId, downloadEntity.name, ""))
|
||||
@ -113,7 +115,9 @@ object DownloadObserver {
|
||||
// 会有 ActivityNotFoundException 异常,catch 掉不管了
|
||||
tryWithDefaultCatch {
|
||||
if (Constants.SILENT_UPDATE != downloadEntity.getMetaExtra(Constants.EXTRA_DOWNLOAD_TYPE)) {
|
||||
PackageInstaller.install(mApplication, downloadEntity)
|
||||
// TODO 在 Android 11 上没有授权安装未知应用的权限前第一次调用这个方法系统会杀掉我们的进程...
|
||||
// 没能找到类似的解释,最接近的是这个 https://issuetracker.google.com/issues/154157387,但也只是点授权杀进程而已
|
||||
PackageInstaller.install(mApplication, downloadEntity);
|
||||
DataLogUtils.uploadUpgradeLog(mApplication, "install") //上传更新安装数据
|
||||
}
|
||||
}
|
||||
@ -133,20 +137,38 @@ object DownloadObserver {
|
||||
Utils.toast(mApplication, downloadEntity.name + " - 下载完成")
|
||||
}
|
||||
if (!downloadEntity.isPluggable) {
|
||||
// 是否是自动安装
|
||||
if (PreferenceManager.getDefaultSharedPreferences(mApplication).getBoolean(SettingsFragment.AUTO_INSTALL_SP_KEY, true)) {
|
||||
if (FileUtils.isEmptyFile(downloadEntity.path)) {
|
||||
Utils.toast(mApplication, R.string.install_failure_hint)
|
||||
downloadManager.cancel(downloadEntity.url)
|
||||
} else {
|
||||
if (PackageUtils.isCanLaunchSetup(mApplication, downloadEntity.path)) {
|
||||
downloadEntity.meta[Constants.MARK_ALREADY_TRIGGERED_INSTALLATION] = "YES"
|
||||
tryWithDefaultCatch {
|
||||
PackageInstaller.install(mApplication, downloadEntity, false)
|
||||
}
|
||||
if (downloadEntity.isSimulatorGame()) {
|
||||
val gameEntity = HaloApp.get(GameEntity::class.java.simpleName, true) as? GameEntity
|
||||
if (gameEntity?.simulator != null) {
|
||||
val isInstalled = PackageUtils.isInstalledFromAllPackage(HaloApp.getInstance().application, gameEntity.simulator!!.apk!!.packageName)
|
||||
if (!isInstalled) {
|
||||
val currentActivity = AppManager.getInstance().currentActivity() ?: return
|
||||
|
||||
SimulatorDownloadManager.getInstance().showDownloadDialog(currentActivity, gameEntity.simulator,
|
||||
SimulatorDownloadManager.SimulatorLocation.LAUNCH, gameEntity.id, gameEntity.name
|
||||
?: "", null)
|
||||
}
|
||||
SimulatorGameManager.recordDownloadSimulatorGames(gameEntity.id)
|
||||
SimulatorGameManager.postPlayedGame(gameEntity.id, downloadEntity.packageName)
|
||||
}
|
||||
} else {
|
||||
val downloadType = downloadEntity.getMetaExtra(Constants.EXTRA_DOWNLOAD_TYPE)
|
||||
// 是否是自动安装
|
||||
val isAutoInstall = PreferenceManager.getDefaultSharedPreferences(mApplication).getBoolean(SettingsFragment.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 {
|
||||
// 弹出卸载提示框
|
||||
EventBus.getDefault().post(EBShowDialog(BaseActivity.PLUGGABLE, downloadEntity.path))
|
||||
if (PackageUtils.isCanLaunchSetup(mApplication, downloadEntity.path)) {
|
||||
downloadEntity.meta[Constants.MARK_ALREADY_TRIGGERED_INSTALLATION] = "YES"
|
||||
tryWithDefaultCatch {
|
||||
PackageInstaller.install(mApplication, downloadEntity, false)
|
||||
}
|
||||
} else {
|
||||
// 弹出卸载提示框
|
||||
EventBus.getDefault().post(EBShowDialog(BaseActivity.PLUGGABLE, downloadEntity.path))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -157,15 +179,15 @@ object DownloadObserver {
|
||||
}
|
||||
|
||||
// 下载过程分析统计
|
||||
val pm = mApplication.packageManager
|
||||
val packageInfo = pm.getPackageArchiveInfo(downloadEntity.path, PackageManager.GET_ACTIVITIES)
|
||||
if (packageInfo == null) {
|
||||
// val pm = mApplication.packageManager
|
||||
// val packageInfo = pm.getPackageArchiveInfo(downloadEntity.path, 0)
|
||||
// if (packageInfo == null) {
|
||||
// MtaHelper.onEventWithBasicDeviceInfo("解析包错误分析",
|
||||
// "游戏名字", downloadEntity.name + ":" + PlatformUtils.getInstance(mApplication).getPlatformName(downloadEntity.platform))
|
||||
//
|
||||
// MtaHelper.onEventWithBasicDeviceInfo("解析包错误_新",
|
||||
// "游戏", downloadEntity.name + ":" + PlatformUtils.getInstance(mApplication).getPlatformName(downloadEntity.platform))
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
if (downloadEntity.status == DownloadStatus.done) {
|
||||
|
||||
@ -90,6 +90,7 @@ public class EntranceUtils {
|
||||
public static final String HOST_FORUM_DETAIL = "forum_detail";
|
||||
public static final String HOST_GAME_RATING_DETAIL = "game_rating_detail";
|
||||
public static final String HOST_HELP_AND_FEEDBACK = "help_and_feedback";
|
||||
public static final String HOST_LAUNCH_SIMULATOR_GAME = "launch_simulator_game";
|
||||
public static final String KEY_DATA = "data";
|
||||
public static final String KEY_MESSAGE = "message";
|
||||
public static final String KEY_MESSAGE_ID = "message_id";
|
||||
@ -212,6 +213,14 @@ public class EntranceUtils {
|
||||
public static final String KEY_CONFLICT_PHONE = "conflictPhone";
|
||||
public static final String KEY_CONFLICT_USER = "conflictUser";
|
||||
public static final String KEY_BBS_ID = "bbs_id";
|
||||
public static final String KEY_DIAGNOSIS = "diagnosis";
|
||||
public static final String KEY_SIMULATOR = "simulator";
|
||||
public static final String KEY_MARKET_DETAILS = "market_details";
|
||||
public static final String KEY_CATALOG_ID = "catalogId";
|
||||
public static final String KEY_PRIMARY_CATALOG_ID = "primaryCatalogId";
|
||||
public static final String KEY_PRIMARY_CATALOG_NAME = "primaryCatalogName";
|
||||
public static final String KEY_CATALOG_TITLE = "catalog_title";
|
||||
public static final String KEY_CATALOG_INIT_TITLE = "catalog_init_title";
|
||||
|
||||
public static void jumpActivity(Context context, Bundle bundle) {
|
||||
bundle.putBoolean(KEY_REQUIRE_REDIRECT, true);
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.animation.Animator
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.GradientDrawable
|
||||
@ -43,8 +44,11 @@ import com.halo.assistant.HaloApp
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import com.lightgame.utils.Utils
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.ObservableTransformer
|
||||
import io.reactivex.SingleTransformer
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.RequestBody
|
||||
import java.net.URI
|
||||
@ -124,6 +128,20 @@ fun ViewPager.addOnScrollStateChanged(onStateChanged: ((state: Int) -> Unit)? =
|
||||
addOnPageChangeListener(listener)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fragment related
|
||||
*/
|
||||
inline fun <reified T : Fragment> Fragment.fragmentFromActivity() =
|
||||
parentFragmentManager.findFragmentByTag(T::class.java.simpleName) as? T
|
||||
?: parentFragmentManager.fragmentFactory.instantiate(requireContext().classLoader, T::class.java.canonicalName) as T
|
||||
|
||||
|
||||
inline fun <reified T : Fragment> Fragment.fragmentFromParentFragment() =
|
||||
childFragmentManager.findFragmentByTag(T::class.java.simpleName) as? T
|
||||
?: childFragmentManager.fragmentFactory.instantiate(requireContext().classLoader, T::class.java.canonicalName) as T
|
||||
|
||||
|
||||
/**
|
||||
* RecyclerView Extensions
|
||||
*/
|
||||
@ -329,6 +347,15 @@ fun throwExceptionInDebug(message: String = "", predicate: Boolean = true) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 在自动打包的包里弹 toast
|
||||
*/
|
||||
fun toastInInternalRelease(content: String) {
|
||||
if (BuildConfig.BUILD_TIME != 0L) {
|
||||
Utils.toast(HaloApp.getInstance(), content)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 主动抛出异常
|
||||
*/
|
||||
@ -388,11 +415,25 @@ fun String.getFirstElementDividedByDivider(divider: String): String {
|
||||
return this
|
||||
}
|
||||
|
||||
fun String.copyText() {
|
||||
this.copyTextAndToast("")
|
||||
}
|
||||
|
||||
fun String.copyTextAndToast(toastText: String = "复制成功") {
|
||||
val application = HaloApp.getInstance().application
|
||||
val cmb = application.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
cmb.text = this
|
||||
ToastUtils.showToast(toastText)
|
||||
try {
|
||||
val application = HaloApp.getInstance().application
|
||||
val cmb = application.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
val clip = ClipData.newPlainText(null, this)
|
||||
cmb.primaryClip = clip
|
||||
|
||||
if (!TextUtils.isEmpty(toastText)) {
|
||||
ToastUtils.showToast(toastText)
|
||||
}
|
||||
} catch (e: SecurityException) {
|
||||
// 在一些情况下会报以下这样的错误,可能是以浮动窗口显示然后没有焦点?(https://developer.android.com/about/versions/10/privacy/changes#clipboard-data)
|
||||
// java.lang.Throwable: java.lang.SecurityException: com.xunmeng.pinduoduo from uid 10317 not allowed to perform READ_CLIPBOARD
|
||||
ToastUtils.showToast("复制失败,请重试")
|
||||
}
|
||||
}
|
||||
|
||||
fun Map<String, String>.createRequestBody(): RequestBody {
|
||||
@ -436,6 +477,7 @@ fun Float.sp2px(): Int {
|
||||
return (this * scale + 0.5f).toInt()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PopupWindow 自动适配方向
|
||||
* 弹出与锚点右对齐
|
||||
@ -559,6 +601,19 @@ fun TextView.setTextChangedListener(action: (s: CharSequence, start: Int, before
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* ArrayList related
|
||||
*/
|
||||
fun <T> ArrayList<T>.safelyGetInRelease(index: Int): T? {
|
||||
return if (index >= size) {
|
||||
throwExceptionInDebug("这里触发了数组越界,请检查")
|
||||
toastInInternalRelease("这个操作可能触发闪退,请确定复现方式并联系开发处理")
|
||||
null
|
||||
} else {
|
||||
this[index]
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 拦截 TextView 中的 Url Span,用应用内页面的形式打开链接
|
||||
* @param shrankText 未展开时的文字
|
||||
@ -662,6 +717,14 @@ fun DownloadEntity.isSilentUpdate(): Boolean {
|
||||
return Constants.SILENT_UPDATE == getMetaExtra(Constants.EXTRA_DOWNLOAD_TYPE)
|
||||
}
|
||||
|
||||
fun DownloadEntity.isSimulatorDownload(): Boolean {
|
||||
return Constants.SIMULATOR_DOWNLOAD == getMetaExtra(Constants.EXTRA_DOWNLOAD_TYPE)
|
||||
}
|
||||
|
||||
fun DownloadEntity.isSimulatorGame(): Boolean {
|
||||
return getMetaExtra(Constants.SIMULATOR_GAME).isNotEmpty()
|
||||
}
|
||||
|
||||
/**
|
||||
* Process related
|
||||
*/
|
||||
@ -841,4 +904,18 @@ fun SeekBar.doOnSeekBarChangeListener(progressChange: ((progress: Int) -> Unit)?
|
||||
onStopTrackingTouch?.invoke()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun <T> observableToMain(): ObservableTransformer<T, T> {
|
||||
return ObservableTransformer { upstream ->
|
||||
upstream.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> singleToMain(): SingleTransformer<T, T> {
|
||||
return SingleTransformer { upstream ->
|
||||
upstream.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
}
|
||||
}
|
||||
@ -5,9 +5,8 @@ import android.graphics.Color;
|
||||
import android.text.TextUtils;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.simulator.SimulatorGameManager;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.entity.ApkEntity;
|
||||
@ -24,6 +23,8 @@ import com.lightgame.download.DownloadStatus;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
public class GameUtils {
|
||||
|
||||
/**
|
||||
@ -116,16 +117,27 @@ public class GameUtils {
|
||||
installCount++;
|
||||
}
|
||||
}
|
||||
if (SimulatorGameManager.isSimulatorGame(gameEntity)) {
|
||||
DownloadEntity simulatorDownloadEntity = SimulatorGameManager.findDownloadEntityByUrl(apkEntity.getUrl());
|
||||
if (simulatorDownloadEntity != null && gameEntity.getSimulator() != null) {
|
||||
boolean isInstalled = PackageUtils.isInstalledFromAllPackage(context, gameEntity.getSimulator().getApk().getPackageName());
|
||||
if (isInstalled) {
|
||||
installCount++;
|
||||
} else {
|
||||
doneCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (doneCount != 0) {
|
||||
return context.getString(R.string.install);
|
||||
} else if (pluginCount != 0) {
|
||||
return context.getString(R.string.pluggable);
|
||||
} else if (updateCount != 0) {
|
||||
return context.getString(R.string.update);
|
||||
} else if (installCount != 0) {
|
||||
if (installCount != 0) {
|
||||
return context.getString(R.string.launch);
|
||||
} else if (gameEntity.getVersionNumber().contains("无版号") && Config.isGameDomeSwitchOpen()) {
|
||||
} else if (pluginCount != 0 && !SimulatorGameManager.isSimulatorGame(gameEntity)) {
|
||||
return context.getString(R.string.pluggable);
|
||||
} else if (updateCount != 0 && !SimulatorGameManager.isSimulatorGame(gameEntity)) {
|
||||
return context.getString(R.string.update);
|
||||
} else if (doneCount != 0) {
|
||||
return context.getString(R.string.install);
|
||||
} else if (gameEntity.getVersionNumber().contains("无版号") && Config.isGameDomeSwitchOpen() && !SimulatorGameManager.isSimulatorGame(gameEntity)) {
|
||||
return context.getString(R.string.attempt);
|
||||
} else {
|
||||
return context.getString(R.string.download);
|
||||
@ -238,7 +250,7 @@ public class GameUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
collectionEntity.setSaveApkEntity(saveApkEntity);
|
||||
return collectionEntity;
|
||||
}
|
||||
|
||||
@ -1,55 +0,0 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.app.Application
|
||||
|
||||
/**
|
||||
* 广点通辅助类 [https://gitlab.ghzhushou.com/pm/halo-app-issues/issues/403]
|
||||
*
|
||||
* 更换帐号 [https://gitlab.ghzs.com/pm/yunying/issues/893]
|
||||
*/
|
||||
object GdtHelper {
|
||||
|
||||
const val NETWORK_TYPE = "NETWORK_TYPE"
|
||||
const val PAGE_TYPE = "PAGE_TYPE"
|
||||
const val CONTENT_TYPE = "CONTENT_TYPE"
|
||||
const val CONTENT_ID = "CONTENT_ID"
|
||||
const val KEYWORD = "KEYWORD"
|
||||
const val GAME_ID = "GAME_ID"
|
||||
const val SCORE = "SCORE"
|
||||
const val PLATFORM = "PLATFORM"
|
||||
|
||||
fun init(application: Application, channel: String) {
|
||||
// if (channel == "GH_728") {
|
||||
// GDTAction.init(application, "1111012969", "9d3d9da5b0948a317c03d08f14d445dc")
|
||||
// } else if (channel == "GH_729") {
|
||||
// GDTAction.init(application, "1111013063", "f53dabf458a356b101d99fc4069eb7f1")
|
||||
// } else {
|
||||
// GDTAction.init(application, "1110680399", "f5ddaafbf520d7d7385499232a408d0a")
|
||||
// }
|
||||
}
|
||||
|
||||
fun logAction(type: String) {
|
||||
// GDTAction.logAction(type)
|
||||
// Utils.log("GDT", type)
|
||||
}
|
||||
|
||||
fun logAction(type: String, vararg kv: String?) {
|
||||
// try {
|
||||
// val actionParam = JSONObject()
|
||||
// for (i in kv.indices) {
|
||||
// if (i % 2 != 0) {
|
||||
// val key = kv[i - 1]
|
||||
// val value = kv[i]
|
||||
// if (!TextUtils.isEmpty(key) && !TextUtils.isEmpty(value)) {
|
||||
// actionParam.put(key, value)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// Utils.log("GDT", "$type + [${kv.joinToString(" , ")}]")
|
||||
// GDTAction.logAction(type, actionParam)
|
||||
// } catch (e: Exception) {
|
||||
// e.printStackTrace()
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
@ -10,6 +10,8 @@ import org.json.JSONArray
|
||||
* Created by khy on 11/10/17.
|
||||
*/
|
||||
object GsonUtils {
|
||||
|
||||
@JvmStatic
|
||||
val gson: Gson = Gson()
|
||||
val gsonThatIgnoreNull: Gson = GsonBuilder().serializeNulls().create()
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ object HomePluggableHelper {
|
||||
if (apkList.isNotEmpty()) {
|
||||
val apk = apkList.first()
|
||||
val tag = if (isNever) "never" else apk.version ?: ""
|
||||
mHomePluggableFilterDao.addData(HomePluggableFilterEntity(pkgName = apk.packageName, tag = tag, active = isNever))
|
||||
tryCatchInRelease { mHomePluggableFilterDao.addData(HomePluggableFilterEntity(pkgName = apk.packageName, tag = tag, active = isNever)) }
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ object HomePluggableHelper {
|
||||
for (entity in filterList) {
|
||||
entity.active = true
|
||||
}
|
||||
mHomePluggableFilterDao.addData(filterList)
|
||||
tryCatchInRelease { mHomePluggableFilterDao.addData(filterList) }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -67,4 +67,15 @@ public class HtmlUtils {
|
||||
|
||||
return htmlStr.trim(); //返回文本字符串
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤掉标签,保留标签内容
|
||||
*/
|
||||
public static String filterHtmlLabel(String htmlStr) {
|
||||
String regEx_html = "<[^>]+>([\\s\\S]*?)<\\/[^>]+>"; //定义HTML标签的正则表达式
|
||||
Pattern p_html = Pattern.compile(regEx_html, Pattern.CASE_INSENSITIVE);
|
||||
Matcher m_html = p_html.matcher(htmlStr);
|
||||
htmlStr = m_html.replaceAll("$1"); //过滤html标签
|
||||
return htmlStr.trim(); //返回文本字符串
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,14 +10,20 @@ import android.net.Uri
|
||||
import android.os.Build
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.facebook.common.executors.CallerThreadExecutor
|
||||
import com.facebook.common.references.CloseableReference
|
||||
import com.facebook.datasource.DataSource
|
||||
import com.facebook.drawee.backends.pipeline.Fresco
|
||||
import com.facebook.drawee.controller.BaseControllerListener
|
||||
import com.facebook.drawee.controller.ControllerListener
|
||||
import com.facebook.drawee.drawable.ScalingUtils
|
||||
import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder
|
||||
import com.facebook.drawee.view.SimpleDraweeView
|
||||
import com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber
|
||||
import com.facebook.imagepipeline.image.CloseableImage
|
||||
import com.facebook.imagepipeline.image.ImageInfo
|
||||
import com.facebook.imagepipeline.request.ImageRequest
|
||||
import com.facebook.imagepipeline.request.ImageRequestBuilder
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.common.structure.FixedSizeLinkedHashSet
|
||||
import com.gh.gamecenter.R
|
||||
@ -223,11 +229,44 @@ object ImageUtils {
|
||||
.build()
|
||||
}
|
||||
|
||||
// 获取bitmap (使用 fresco 获取 gif bitmap 会为空,https://github.com/facebook/fresco/issues/241)
|
||||
// 所以这里换用 picasso
|
||||
/**
|
||||
* 获取bitmap (使用 fresco 获取 gif 的 bitmap 会为空,https://github.com/facebook/fresco/issues/241)
|
||||
* 所以当 url 以 .gif 结尾时换用 picasso 获取
|
||||
* 优先使用 fresco 是因为可能已经有了缓存
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
@JvmStatic
|
||||
fun getBitmap(url: String, callback: BiCallback<Bitmap, Boolean>) {
|
||||
if (url.endsWith(".gif")) {
|
||||
getBitmapWithPicasso(url, callback)
|
||||
} else {
|
||||
getBitmapWithFresco(url, callback)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getBitmapWithFresco(url: String, callback: BiCallback<Bitmap, Boolean>) {
|
||||
val imageRequest = ImageRequestBuilder
|
||||
.newBuilderWithSource(Uri.parse(url))
|
||||
.build()
|
||||
Fresco.getImagePipeline()
|
||||
.fetchDecodedImage(imageRequest, HaloApp.getInstance().application)
|
||||
.subscribe(object : BaseBitmapDataSubscriber() {
|
||||
override fun onFailureImpl(dataSource: DataSource<CloseableReference<CloseableImage>>) {
|
||||
callback.onSecond(true)
|
||||
}
|
||||
|
||||
override fun onNewResultImpl(bitmap: Bitmap?) {
|
||||
if (bitmap != null) {
|
||||
callback.onFirst(bitmap)
|
||||
} else {
|
||||
callback.onSecond(true)
|
||||
}
|
||||
}
|
||||
}, CallerThreadExecutor.getInstance())
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private fun getBitmapWithPicasso(url: String, callback: BiCallback<Bitmap, Boolean>) {
|
||||
Single.just(url)
|
||||
.map { Picasso.with(HaloApp.getInstance().application).load(url).priority(Picasso.Priority.HIGH).get() }
|
||||
.subscribeOn(Schedulers.io())
|
||||
@ -240,68 +279,74 @@ object ImageUtils {
|
||||
})
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun display(view: SimpleDraweeView?, url: String?) {
|
||||
display(view, url, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 规则 width>0 Wifi/4G:x2 traffic:x1
|
||||
* 第一种方案:通过LayoutParams获取 可以快速(无延迟)获取宽高,但是无法获取wrap_content和match_parent的View
|
||||
* 第二种方案(备用方案):有延迟,View的宽高需要在Measure过程后才能确定,能够在这里获取到正确的宽高
|
||||
* @param isAutoPlayGif 是否禁止播放动图
|
||||
*/
|
||||
@JvmStatic
|
||||
fun display(view: SimpleDraweeView?, url: String?) {
|
||||
url?.let {
|
||||
val width = view?.layoutParams?.width
|
||||
val height = view?.layoutParams?.height
|
||||
fun display(view: SimpleDraweeView?, url: String?, isAutoPlayGif: Boolean = true) {
|
||||
if (url == null) return
|
||||
|
||||
var lowResUrl = ""
|
||||
var highResUrl = ""
|
||||
val width = view?.layoutParams?.width
|
||||
val height = view?.layoutParams?.height
|
||||
|
||||
// 找同一图片地址已加载过的图片作为低质量预览图
|
||||
// TODO 根据实际请求大小(w_width)来避免小图用大图作为低质量图片
|
||||
for (cachedImageUrl in mImageUrlCacheSet) {
|
||||
if (cachedImageUrl.contains(url)) {
|
||||
lowResUrl = cachedImageUrl
|
||||
break
|
||||
}
|
||||
var lowResUrl = ""
|
||||
var highResUrl = ""
|
||||
|
||||
// 找同一图片地址已加载过的图片作为低质量预览图
|
||||
// TODO 根据实际请求大小(w_width)来避免小图用大图作为低质量图片
|
||||
for (cachedImageUrl in mImageUrlCacheSet) {
|
||||
if (url.isNotEmpty() && cachedImageUrl.contains(url)) {
|
||||
lowResUrl = cachedImageUrl
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
val loadImageClosure: (autoPlay: Boolean, highResUrl: String, lowResUrl: String) -> Unit = { autoPlay, hUrl, lUrl ->
|
||||
view?.controller = Fresco.newDraweeControllerBuilder()
|
||||
.setImageRequest(ImageRequest.fromUri(hUrl))
|
||||
.apply {
|
||||
if (lUrl.isNotEmpty()
|
||||
&& lUrl != hUrl
|
||||
&& hUrl != view?.getTag(R.string.highResImageTag)) {
|
||||
lowResImageRequest = ImageRequest.fromUri(lUrl)
|
||||
}
|
||||
autoPlayAnimations = autoPlay
|
||||
val loadImageClosure: (autoPlay: Boolean, highResUrl: String, lowResUrl: String) -> Unit = { autoPlay, hUrl, lUrl ->
|
||||
view?.controller = Fresco.newDraweeControllerBuilder()
|
||||
.setImageRequest(ImageRequest.fromUri(hUrl))
|
||||
.apply {
|
||||
if (lUrl.isNotEmpty()
|
||||
&& lUrl != hUrl
|
||||
&& hUrl != view?.getTag(R.string.highResImageTag)) {
|
||||
lowResImageRequest = ImageRequest.fromUri(lUrl)
|
||||
}
|
||||
.build()
|
||||
autoPlayAnimations = autoPlay
|
||||
}
|
||||
.build()
|
||||
|
||||
view?.setTag(R.string.highResImageTag, highResUrl)
|
||||
view?.setTag(R.string.highResImageTag, highResUrl)
|
||||
}
|
||||
|
||||
val shouldLoadAsGif = url.endsWith(".gif") && isAutoPlayGif && view?.getTag(R.id.tag_show_gif) != false
|
||||
|
||||
if (shouldLoadAsGif && view?.tag == url) return
|
||||
|
||||
if (width != null && width > 0) {
|
||||
highResUrl = if (shouldLoadAsGif) {
|
||||
resizeGif(url, width, height ?: 0)
|
||||
} else {
|
||||
getTransformLimitUrl(url, width, view.context) ?: ""
|
||||
}
|
||||
|
||||
val shouldLoadAsGif = it.endsWith(".gif") && view?.getTag(R.id.tag_show_gif) != false
|
||||
|
||||
if (shouldLoadAsGif && view?.tag == url) return
|
||||
|
||||
if (width != null && width > 0) {
|
||||
loadImageClosure(shouldLoadAsGif, highResUrl, lowResUrl)
|
||||
} else {
|
||||
view?.post {
|
||||
highResUrl = if (shouldLoadAsGif) {
|
||||
resizeGif(url, width, height ?: 0)
|
||||
resizeGif(url, view.width, height ?: 0)
|
||||
} else {
|
||||
getTransformLimitUrl(url, width, view.context) ?: ""
|
||||
getTransformLimitUrl(url, view.width, view.context) ?: ""
|
||||
}
|
||||
loadImageClosure(shouldLoadAsGif, highResUrl, lowResUrl)
|
||||
} else {
|
||||
view?.post {
|
||||
highResUrl = if (shouldLoadAsGif) {
|
||||
resizeGif(url, view.width, height ?: 0)
|
||||
} else {
|
||||
getTransformLimitUrl(url, view.width, view.context) ?: ""
|
||||
}
|
||||
loadImageClosure(shouldLoadAsGif, highResUrl, lowResUrl)
|
||||
}
|
||||
}
|
||||
view?.tag = url
|
||||
}
|
||||
view?.tag = url
|
||||
}
|
||||
|
||||
// Wifi/4G:x2 traffic:x1
|
||||
|
||||
@ -48,7 +48,7 @@ public class InstallUtils {
|
||||
public void handleMessage(Message msg) {
|
||||
if (msg.what == INSTALL_WHAT && packageManager != null) {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
List<PackageInfo> packageInfos = packageManager.getInstalledPackages(0);
|
||||
List<PackageInfo> packageInfos = PackageUtils.getInstalledPackages(context, 0);
|
||||
for (PackageInfo packageInfo : packageInfos) {
|
||||
if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
|
||||
list.add(packageInfo.packageName);
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.graphics.Color;
|
||||
@ -11,6 +10,8 @@ import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.LibaoDetailAdapter;
|
||||
@ -36,7 +37,6 @@ import org.json.JSONObject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
@ -237,85 +237,160 @@ public class LibaoUtils {
|
||||
|
||||
// 领取限制
|
||||
CheckLoginUtils.checkLogin(context, "礼包详情-[" + btnStatus + "]", () -> {
|
||||
PermissionHelper.checkReadPhoneStatePermissionBeforeAction(context, () -> {
|
||||
if ("领取".equals(btnStatus) || "淘号".equals(btnStatus)) {
|
||||
if (isInstallRequired && !isAppInstalled(context, libaoEntity.getPackageName())) {
|
||||
String platform;
|
||||
if (TextUtils.isEmpty(libaoEntity.getPlatform())) {
|
||||
platform = "";
|
||||
} else {
|
||||
platform = PlatformUtils.getInstance(context).getPlatformName(libaoEntity.getPlatform());
|
||||
}
|
||||
if ("领取".equals(btnStatus) || "淘号".equals(btnStatus)) {
|
||||
if (isInstallRequired && !isAppInstalled(context, libaoEntity.getPackageName())) {
|
||||
String platform;
|
||||
if (TextUtils.isEmpty(libaoEntity.getPlatform())) {
|
||||
platform = "";
|
||||
} else {
|
||||
platform = PlatformUtils.getInstance(context).getPlatformName(libaoEntity.getPlatform());
|
||||
}
|
||||
|
||||
boolean isExistPlatform = false;
|
||||
ArrayList<ApkEntity> apk = adapter.getGameEntity().getApk();
|
||||
for (ApkEntity apkEntity : apk) {
|
||||
if (TextUtils.isEmpty(libaoEntity.getPlatform())) break;
|
||||
if (libaoEntity.getPlatform().equals(apkEntity.getPlatform())) {
|
||||
isExistPlatform = true;
|
||||
break;
|
||||
}
|
||||
boolean isExistPlatform = false;
|
||||
ArrayList<ApkEntity> apk = adapter.getGameEntity().getApk();
|
||||
for (ApkEntity apkEntity : apk) {
|
||||
if (TextUtils.isEmpty(libaoEntity.getPlatform())) break;
|
||||
if (libaoEntity.getPlatform().equals(apkEntity.getPlatform())) {
|
||||
isExistPlatform = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
String dialogContent = context.getString(R.string.ling_rules_dialog, libaoEntity.getGame().getName(), platform);
|
||||
boolean finalIsExistPlatform = isExistPlatform;
|
||||
DialogUtils.showWarningDialog(context, "条件不符",
|
||||
Html.fromHtml(dialogContent), isExistPlatform ? "关闭" : null,
|
||||
isExistPlatform ? "立即安装" : "关闭",
|
||||
() -> {
|
||||
if (finalIsExistPlatform) {
|
||||
adapter.openDownload(libaoEntity.getPlatform());
|
||||
}
|
||||
}, null);
|
||||
String dialogContent = context.getString(R.string.ling_rules_dialog, libaoEntity.getGame().getName(), platform);
|
||||
boolean finalIsExistPlatform = isExistPlatform;
|
||||
DialogUtils.showWarningDialog(context, "条件不符",
|
||||
Html.fromHtml(dialogContent), isExistPlatform ? "关闭" : null,
|
||||
isExistPlatform ? "立即安装" : "关闭",
|
||||
() -> {
|
||||
if (finalIsExistPlatform) {
|
||||
adapter.openDownload(libaoEntity.getPlatform());
|
||||
}
|
||||
}, null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch (btnStatus) {
|
||||
case "未开始":
|
||||
Utils.toast(context, "还没到开始领取时间");
|
||||
break;
|
||||
case "查看":
|
||||
if (!TextUtils.isEmpty(libaoEntity.getDes())) {
|
||||
DialogUtils.showAlertDialog(v.getContext(), "使用说明",
|
||||
Html.fromHtml(libaoEntity.getDes()), "关闭", null, null, null);
|
||||
}
|
||||
break;
|
||||
case "再领一个":
|
||||
case "领取":
|
||||
if ("repeatLing".equals(status)) {
|
||||
DialogUtils.showWarningDialog(context, "礼包刷新提醒"
|
||||
, "礼包每天0点刷新,换新区或者换新角色需要继续领取礼包的童鞋,请于明天0点之后回来即可[再领一个]"
|
||||
, null, "知道了", null, null);
|
||||
} else {
|
||||
libaoLing(context, libaoBtn, libaoEntity, adapter, isInstallRequired, null, entrance);
|
||||
}
|
||||
break;
|
||||
case "再淘一个":
|
||||
case "淘号":
|
||||
if ("repeatTao".equals(status)) {
|
||||
Utils.toast(context, "没到重复淘号时间, 礼包每天0点刷新");
|
||||
return;
|
||||
}
|
||||
}
|
||||
final Dialog loadingDialog = DialogUtils.showWaitDialog(context, "淘号中...");
|
||||
postLibaoTao(context, libaoEntity.getId(), new PostLibaoListener() {
|
||||
@Override
|
||||
public void postSucceed(Object response) {
|
||||
|
||||
switch (btnStatus) {
|
||||
case "未开始":
|
||||
Utils.toast(context, "还没到开始领取时间");
|
||||
break;
|
||||
case "查看":
|
||||
if (!TextUtils.isEmpty(libaoEntity.getDes())) {
|
||||
DialogUtils.showAlertDialog(v.getContext(), "使用说明",
|
||||
Html.fromHtml(libaoEntity.getDes()), "关闭", null, null, null);
|
||||
}
|
||||
break;
|
||||
case "再领一个":
|
||||
case "领取":
|
||||
if ("repeatLing".equals(status)) {
|
||||
DialogUtils.showWarningDialog(context, "礼包刷新提醒"
|
||||
, "礼包每天0点刷新,换新区或者换新角色需要继续领取礼包的童鞋,请于明天0点之后回来即可[再领一个]"
|
||||
, null, "知道了", null, null);
|
||||
} else {
|
||||
libaoLing(context, libaoBtn, libaoEntity, adapter, isInstallRequired, null, entrance);
|
||||
}
|
||||
break;
|
||||
case "再淘一个":
|
||||
case "淘号":
|
||||
if ("repeatTao".equals(status)) {
|
||||
Utils.toast(context, "没到重复淘号时间, 礼包每天0点刷新");
|
||||
return;
|
||||
}
|
||||
final Dialog loadingDialog = DialogUtils.showWaitDialog(context, "淘号中...");
|
||||
postLibaoTao(context, libaoEntity.getId(), new PostLibaoListener() {
|
||||
@Override
|
||||
public void postSucceed(Object response) {
|
||||
if (loadingDialog != null) loadingDialog.dismiss();
|
||||
|
||||
if (loadingDialog != null) loadingDialog.dismiss();
|
||||
JSONObject responseBody = (JSONObject) response;
|
||||
String libaoCode = null;
|
||||
try {
|
||||
libaoCode = responseBody.getString("code");
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
JSONObject responseBody = (JSONObject) response;
|
||||
String libaoCode = null;
|
||||
if (TextUtils.isEmpty(libaoCode)) {
|
||||
try {
|
||||
libaoCode = responseBody.getString("code");
|
||||
String detail = responseBody.getString("detail");
|
||||
switch (detail) {
|
||||
case "maintaining":
|
||||
Utils.toast(context, "网络状态异常,请稍后再试");
|
||||
break;
|
||||
case "fail to compete":
|
||||
Utils.toast(context, "淘号失败,稍后重试");
|
||||
break;
|
||||
default:
|
||||
Utils.toast(context, "淘号异常");
|
||||
break;
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(libaoCode)) {
|
||||
Utils.toast(context, "淘号成功");
|
||||
|
||||
libaoEntity.setStatus("taoed");
|
||||
|
||||
EventBus.getDefault().post(new EBReuse("libaoChanged"));
|
||||
|
||||
adapter.initLibaoCode(new UserDataLibaoEntity(libaoCode, "tao", Utils.getTime(context)));
|
||||
|
||||
final String finalLibaoCode = libaoCode;
|
||||
|
||||
DialogUtils.showWarningDialog(context, "淘号成功"
|
||||
, Html.fromHtml(context.getString(R.string.taoed_dialog, libaoCode))
|
||||
, "关闭", " 复制礼包码"
|
||||
, () -> {
|
||||
copyLink(finalLibaoCode, context);
|
||||
if (isInstallRequired) {
|
||||
libaoBtn.postDelayed(() -> {
|
||||
Spanned msg = Html.fromHtml(
|
||||
context.getString(R.string.taoed_copy_dialog
|
||||
, finalLibaoCode));
|
||||
lunningAppDialog(context
|
||||
, msg, libaoEntity);
|
||||
}, 300);
|
||||
}
|
||||
}, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postFailed(Throwable error) {
|
||||
Utils.log("---" + error.toString());
|
||||
|
||||
if (loadingDialog != null) loadingDialog.dismiss();
|
||||
|
||||
if (error instanceof HttpException) {
|
||||
HttpException exception = (HttpException) error;
|
||||
if (exception.code() == 403) {
|
||||
try {
|
||||
String detail = responseBody.getString("detail");
|
||||
JSONObject errorJson = new JSONObject(exception.response().errorBody().string());
|
||||
String detail = errorJson.getString("detail");
|
||||
// Utils.toast(context, "返回::" + detail);
|
||||
switch (detail) {
|
||||
case "coming":
|
||||
Utils.toast(context, "礼包领取时间未开始");
|
||||
break;
|
||||
case "finish":
|
||||
Utils.toast(context, "礼包领取时间已结束");
|
||||
break;
|
||||
case "fetched":
|
||||
Utils.toast(context, "你今天已领过这个礼包了, 不能再淘号");
|
||||
|
||||
libaoBtn.setText("已淘号");
|
||||
libaoBtn.setBackgroundResource(R.drawable.libao_taoed_style);
|
||||
libaoBtn.setTextColor(ContextCompat.getColorStateList(context, R.color.libao_taoed_selector));
|
||||
libaoEntity.setStatus("taoed");
|
||||
break;
|
||||
case "try tao":
|
||||
case "used up":
|
||||
DialogUtils.showHintDialog(context, "礼包已领光"
|
||||
, "手速不够快,礼包已经被抢光了,十分抱歉", "知道了");
|
||||
break;
|
||||
case "maintaining":
|
||||
Utils.toast(context, "网络状态异常,请稍后再试");
|
||||
break;
|
||||
@ -323,101 +398,24 @@ public class LibaoUtils {
|
||||
Utils.toast(context, "淘号失败,稍后重试");
|
||||
break;
|
||||
default:
|
||||
Utils.toast(context, "淘号异常");
|
||||
Utils.toast(context, "操作失败");
|
||||
break;
|
||||
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
Utils.toast(context, "礼包处理异常" + ex.toString());
|
||||
}
|
||||
return;
|
||||
} else if (exception.code() == 401) {
|
||||
return;
|
||||
}
|
||||
|
||||
Utils.toast(context, "淘号成功");
|
||||
|
||||
libaoEntity.setStatus("taoed");
|
||||
|
||||
EventBus.getDefault().post(new EBReuse("libaoChanged"));
|
||||
|
||||
adapter.initLibaoCode(new UserDataLibaoEntity(libaoCode, "tao", Utils.getTime(context)));
|
||||
|
||||
final String finalLibaoCode = libaoCode;
|
||||
|
||||
DialogUtils.showWarningDialog(context, "淘号成功"
|
||||
, Html.fromHtml(context.getString(R.string.taoed_dialog, libaoCode))
|
||||
, "关闭", " 复制礼包码"
|
||||
, () -> {
|
||||
copyLink(finalLibaoCode, context);
|
||||
if (isInstallRequired) {
|
||||
libaoBtn.postDelayed(() -> {
|
||||
Spanned msg = Html.fromHtml(
|
||||
context.getString(R.string.taoed_copy_dialog
|
||||
, finalLibaoCode));
|
||||
lunningAppDialog(context
|
||||
, msg, libaoEntity);
|
||||
}, 300);
|
||||
}
|
||||
}, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postFailed(Throwable error) {
|
||||
Utils.log("---" + error.toString());
|
||||
|
||||
if (loadingDialog != null) loadingDialog.dismiss();
|
||||
|
||||
if (error instanceof HttpException) {
|
||||
HttpException exception = (HttpException) error;
|
||||
if (exception.code() == 403) {
|
||||
try {
|
||||
JSONObject errorJson = new JSONObject(exception.response().errorBody().string());
|
||||
String detail = errorJson.getString("detail");
|
||||
// Utils.toast(context, "返回::" + detail);
|
||||
switch (detail) {
|
||||
case "coming":
|
||||
Utils.toast(context, "礼包领取时间未开始");
|
||||
break;
|
||||
case "finish":
|
||||
Utils.toast(context, "礼包领取时间已结束");
|
||||
break;
|
||||
case "fetched":
|
||||
Utils.toast(context, "你今天已领过这个礼包了, 不能再淘号");
|
||||
|
||||
libaoBtn.setText("已淘号");
|
||||
libaoBtn.setBackgroundResource(R.drawable.libao_taoed_style);
|
||||
libaoBtn.setTextColor(ContextCompat.getColorStateList(context, R.color.libao_taoed_selector));
|
||||
libaoEntity.setStatus("taoed");
|
||||
break;
|
||||
case "try tao":
|
||||
case "used up":
|
||||
DialogUtils.showHintDialog(context, "礼包已领光"
|
||||
, "手速不够快,礼包已经被抢光了,十分抱歉", "知道了");
|
||||
break;
|
||||
case "maintaining":
|
||||
Utils.toast(context, "网络状态异常,请稍后再试");
|
||||
break;
|
||||
case "fail to compete":
|
||||
Utils.toast(context, "淘号失败,稍后重试");
|
||||
break;
|
||||
default:
|
||||
Utils.toast(context, "操作失败");
|
||||
break;
|
||||
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
Utils.toast(context, "礼包处理异常" + ex.toString());
|
||||
}
|
||||
return;
|
||||
} else if (exception.code() == 401) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
Utils.toast(context, "发生异常");
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
});
|
||||
Utils.toast(context, "发生异常");
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -458,7 +456,7 @@ public class LibaoUtils {
|
||||
adapter.notifyDataSetChanged();
|
||||
final String finalLibaoCode = libaoCode;
|
||||
NotificationHelper.showNotificationHintDialog(NotificationUgc.GIFT, isShow -> {
|
||||
if (!isShow){
|
||||
if (!isShow) {
|
||||
DialogUtils.showWarningDialog(context, "领取成功", Html.fromHtml(context.getString(R.string.linged_dialog, finalLibaoCode))
|
||||
, "关闭", " 复制礼包码"
|
||||
, () -> {
|
||||
@ -547,8 +545,7 @@ public class LibaoUtils {
|
||||
}
|
||||
|
||||
public static boolean isAppInstalled(Context context, String packageName) {
|
||||
final android.content.pm.PackageManager packageManager = context.getPackageManager();
|
||||
List<PackageInfo> pinfo = packageManager.getInstalledPackages(0);
|
||||
List<PackageInfo> pinfo = PackageUtils.getInstalledPackages(context, 0);
|
||||
if (pinfo != null) {
|
||||
for (int i = 0; i < pinfo.size(); i++) {
|
||||
String pn = pinfo.get(i).packageName;
|
||||
@ -576,10 +573,7 @@ public class LibaoUtils {
|
||||
|
||||
//复制文字
|
||||
public static void copyLink(String copyContent, Context context) {
|
||||
ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
cmb.setText(copyContent);
|
||||
|
||||
Utils.toast(context, copyContent + " 复制成功");
|
||||
ExtensionsKt.copyTextAndToast(copyContent, copyContent + " 复制成功");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6,8 +6,6 @@ import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.gh.common.constant.Constants;
|
||||
import com.gh.common.exposure.ExposureEntity;
|
||||
import com.gh.common.exposure.ExposureEvent;
|
||||
@ -34,6 +32,8 @@ import org.json.JSONObject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.RequestBody;
|
||||
@ -518,4 +518,169 @@ public class LogUtils {
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(new EmptyResponse<>());
|
||||
}
|
||||
|
||||
public static JSONObject getMetaObject() {
|
||||
Meta meta = MetaUtil.INSTANCE.getMeta();
|
||||
JSONObject metaObject = new JSONObject();
|
||||
try {
|
||||
metaObject.put("android_id", meta.getAndroid_id());
|
||||
metaObject.put("android_sdk", meta.getAndroid_sdk());
|
||||
metaObject.put("android_version", meta.getAndroid_version());
|
||||
metaObject.put("appVersion", meta.getAppVersion());
|
||||
metaObject.put("channel", meta.getChannel());
|
||||
metaObject.put("gid", meta.getGid());
|
||||
metaObject.put("imei", meta.getImei());
|
||||
metaObject.put("mac", meta.getMac());
|
||||
metaObject.put("manufacturer", meta.getManufacturer());
|
||||
metaObject.put("model", meta.getModel());
|
||||
metaObject.put("network", meta.getNetwork());
|
||||
metaObject.put("os", meta.getOs());
|
||||
metaObject.put("userId", meta.getUserId());
|
||||
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return metaObject;
|
||||
}
|
||||
|
||||
private static void uploadCommunity(JSONObject object) {
|
||||
try {
|
||||
object.put("meta", getMetaObject());
|
||||
object.put("timestamp", System.currentTimeMillis() / 1000);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (BuildConfig.DEBUG) {
|
||||
Utils.log("LogUtils->" + object.toString());
|
||||
}
|
||||
LoghubUtils.log(object, "community", false);
|
||||
}
|
||||
|
||||
public static void uploadAccessToBbs(String bbsId, String location) {
|
||||
JSONObject object = new JSONObject();
|
||||
JSONObject payload = new JSONObject();
|
||||
try {
|
||||
payload.put("location", location);//关注板块/文章外所属论坛/游戏详情/文章内所属论坛
|
||||
payload.put("bbs_id", bbsId);
|
||||
|
||||
object.put("event", "access_to_bbs");
|
||||
object.put("payload", payload);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
uploadCommunity(object);
|
||||
}
|
||||
|
||||
public static void uploadAccessBbsTab() {
|
||||
JSONObject object = new JSONObject();
|
||||
try {
|
||||
object.put("event", "main_tab[bbs]");
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
uploadCommunity(object);
|
||||
}
|
||||
|
||||
|
||||
public static void uploadSimulatorDownload(String event, String fileName, String simulatorId, String simulatorName, String gameId, String location, String downloadType, String startTime) {
|
||||
JSONObject object = new JSONObject();
|
||||
JSONObject payload = new JSONObject();
|
||||
try {
|
||||
object.put("event", event);// 取值有[开始, 完成] [simulator_download, simulator_download_complete]
|
||||
object.put("meta", getMetaObject());
|
||||
object.put("timestamp", System.currentTimeMillis() / 1000);
|
||||
|
||||
payload.put("filename", fileName);// 下载模拟器文件名,每次新创建的下载任务文件名都不同,可以用来关联同一次的下载开始与完成
|
||||
payload.put("simulator_id", simulatorId);
|
||||
payload.put("simulator_name", simulatorName);
|
||||
payload.put("location", location);//启动《具体的游戏名称》/模拟器游戏/模拟器游戏-模拟器管理
|
||||
payload.put("game_id", gameId);//如果是 启动《游戏名称》 这种方式, 记录这个游戏具体的游戏ID
|
||||
payload.put("download_type", downloadType);// update/download 下载类型(更新/下载)
|
||||
if (!TextUtils.isEmpty(startTime) && event.equals("simulator_download_complete")) {
|
||||
payload.put("simulator_download_timestamp", startTime);// 对应的下载开始时间
|
||||
}
|
||||
object.put("payload", payload);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (BuildConfig.DEBUG) {
|
||||
Utils.log("LogUtils->" + object.toString());
|
||||
}
|
||||
LoghubUtils.log(object, "event", false);
|
||||
}
|
||||
|
||||
public static void uploadSearchGame(String event, String location, String key, String searchType) {
|
||||
uploadSearchClick(event, location, key, searchType, "", "");
|
||||
}
|
||||
|
||||
public static void uploadSearchClick(String event, String location, String key, String searchType, String gameId, String gameName) {
|
||||
JSONObject object = new JSONObject();
|
||||
JSONObject payload = new JSONObject();
|
||||
try {
|
||||
object.put("event", event);
|
||||
object.put("location", location);
|
||||
object.put("meta", getMetaObject());
|
||||
object.put("timestamp", System.currentTimeMillis() / 1000);
|
||||
|
||||
payload.put("key", key); //搜索关键词
|
||||
payload.put("search_type", searchType); //搜索类型, 有四种取值 默认搜索/历史搜索/自动搜索/主动搜索
|
||||
payload.put("game_id", gameId); //event为search_click才取值
|
||||
payload.put("game_name", gameName); //event为search_click才取值
|
||||
object.put("payload", payload);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (BuildConfig.DEBUG) {
|
||||
Utils.log("LogUtils->" + object.toString());
|
||||
}
|
||||
LoghubUtils.log(object, "event", false);
|
||||
}
|
||||
|
||||
public static void logNewCatalogAppearanceEvent(String entrance, String key) {
|
||||
logCatalogEvent("access_to_classification", entrance, key, -1, -1, -1, -1);
|
||||
}
|
||||
|
||||
public static void logSubCatalogClickEvent(String entrance, String key, int seq1) {
|
||||
logCatalogEvent("click_first_classification", entrance, key, seq1, -1, -1, -1);
|
||||
}
|
||||
|
||||
public static void logSubCatalogContentClickEvent(String entrance, String key, int seq1, int seq2) {
|
||||
logCatalogEvent("click_secondary_classification", entrance, key, seq1, seq2, -1, -1);
|
||||
}
|
||||
|
||||
public static void logSpecialCatalogContentClickEvent(String entrance, String key, int seq1, int seqContent) {
|
||||
logCatalogEvent("click_content", entrance, key, seq1, -1, seqContent, -1);
|
||||
}
|
||||
|
||||
public static void logSpecialCatalogSpecificContentClickEvent(String entrance, String key, int seq1, int seqContent, int seqContentList) {
|
||||
logCatalogEvent("click_content_list", entrance, key, seq1, -1, seqContent, seqContentList);
|
||||
}
|
||||
|
||||
private static void logCatalogEvent(String event, String entrance, String key, int seq1, int seq2, int seqContent, int seqContentList) {
|
||||
JSONObject object = new JSONObject();
|
||||
JSONObject payload = new JSONObject();
|
||||
try {
|
||||
object.put("event", event);
|
||||
object.put("meta", getMetaObject());
|
||||
object.put("timestamp", System.currentTimeMillis() / 1000);
|
||||
|
||||
payload.put("entrance", entrance); //入口分类, 分为 首页或版块,
|
||||
payload.put("key", key); //搜索类型, 有四种取值 默认搜索/历史搜索/自动搜索/主动搜索
|
||||
payload.put("seq_1st", seq1); //从0开始,默认-1表示没有
|
||||
payload.put("seq_2nd", seq2); //从0开始,默认-1表示没有
|
||||
payload.put("seq_content", seqContent); //精选页上 图片、专题-全部按钮、专题合集-全部按钮 的排序;从0开始,默认-1表示没有
|
||||
payload.put("seq_content_list", seqContentList);
|
||||
object.put("payload", payload);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (BuildConfig.DEBUG) {
|
||||
Utils.log("LogUtils->" + object.toString());
|
||||
}
|
||||
LoghubUtils.log(object, "event", false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ object MtaHelper {
|
||||
// if (kv.size == 1) {
|
||||
// prop.setProperty(kv[0], kv[0])
|
||||
// StatService.trackCustomKVEvent(HaloApp.getInstance().application, eventId, prop)
|
||||
// Utils.log("MTA","$eventId + [${kv.joinToString(" , ")}]")
|
||||
// Utils.log("MTA", "$eventId + [${kv.joinToString(" , ")}]")
|
||||
// return
|
||||
// }
|
||||
//
|
||||
@ -23,7 +23,7 @@ object MtaHelper {
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Utils.log("MTA","$eventId + [${kv.joinToString(" , ")}]")
|
||||
// Utils.log("MTA", "$eventId + [${kv.joinToString(" , ")}]")
|
||||
// StatService.trackCustomKVEvent(HaloApp.getInstance().application, eventId, prop)
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ object MtaHelper {
|
||||
// }
|
||||
//
|
||||
// if (prop.size == 0) return
|
||||
// Utils.log("MTA","$eventId + [${kv.joinToString(" , ")}] + last $time seconds")
|
||||
// Utils.log("MTA", "$eventId + [${kv.joinToString(" , ")}] + last $time seconds")
|
||||
// StatService.trackCustomKVTimeIntervalEvent(HaloApp.getInstance().application, time, eventId, prop)
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ object MtaHelper {
|
||||
// prop.setProperty("GID", HaloApp.getInstance().gid)
|
||||
// }
|
||||
//
|
||||
// Utils.log("MTA","$eventId + [${kv.joinToString(" , ")}]")
|
||||
// Utils.log("MTA", "$eventId + [${kv.joinToString(" , ")}]")
|
||||
// StatService.trackCustomKVEvent(HaloApp.getInstance().application, eventId, prop)
|
||||
}
|
||||
|
||||
|
||||
@ -5,15 +5,10 @@ import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.app.NotificationManagerCompat
|
||||
import com.gh.common.constant.Constants
|
||||
import com.gh.common.dialog.NotificationHintDialogFragment
|
||||
import com.gh.gamecenter.entity.NotificationHint
|
||||
import com.gh.gamecenter.entity.NotificationUgc
|
||||
import com.gh.gamecenter.retrofit.BiResponse
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.AppManager
|
||||
import com.lightgame.utils.Utils
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
||||
object NotificationHelper {
|
||||
|
||||
@ -159,6 +154,7 @@ object NotificationHelper {
|
||||
callBack?.invoke(false)
|
||||
} else {
|
||||
callBack?.invoke(true)
|
||||
if (activity.supportFragmentManager.isStateSaved) return
|
||||
NotificationHintDialogFragment.getInstance(ugc).show(activity.supportFragmentManager, "notification")
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ object PackageHelper {
|
||||
private fun getAllPackageName(context: Context): HashSet<String> {
|
||||
val set = HashSet<String>()
|
||||
return try {
|
||||
val packageInfos = context.applicationContext.packageManager.getInstalledPackages(0)
|
||||
val packageInfos = PackageUtils.getInstalledPackages(context, 0)
|
||||
for (packageInfo in packageInfos) {
|
||||
if (packageInfo.applicationInfo.flags and ApplicationInfo.FLAG_SYSTEM == 0) {
|
||||
if (context.packageName != packageInfo.packageName) {
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
@ -38,13 +39,17 @@ object PackageInstaller {
|
||||
*/
|
||||
@JvmStatic
|
||||
fun install(context: Context, downloadEntity: DownloadEntity, showUnzipToast: Boolean) {
|
||||
InstallPermissionDialogFragment.show(AppManager.getInstance().currentActivity() as AppCompatActivity) {
|
||||
val pkgPath = downloadEntity.path
|
||||
val isXapk = XapkInstaller.XAPK_EXTENSION_NAME == pkgPath.getExtension()
|
||||
|
||||
val currentActivity = AppManager.getInstance().currentActivity() ?: return
|
||||
|
||||
InstallPermissionDialogFragment.show(currentActivity as AppCompatActivity, downloadEntity) {
|
||||
// 取消状态栏下载完成的通知,若存在
|
||||
downloadEntity.meta[Constants.MARK_ALREADY_TRIGGERED_INSTALLATION] = "YES"
|
||||
DownloadNotificationHelper.addOrUpdateDownloadNotification(downloadEntity)
|
||||
|
||||
val pkgPath = downloadEntity.path
|
||||
if (XapkInstaller.XAPK_EXTENSION_NAME == pkgPath.getExtension()) {
|
||||
if (isXapk) {
|
||||
XapkInstaller.install(context, downloadEntity, showUnzipToast)
|
||||
} else {
|
||||
install(context, downloadEntity.path)
|
||||
@ -113,6 +118,9 @@ object PackageInstaller {
|
||||
val uninstallIntent = Intent()
|
||||
uninstallIntent.action = Intent.ACTION_DELETE
|
||||
uninstallIntent.addCategory(Intent.CATEGORY_DEFAULT)
|
||||
if (context !is Activity) {
|
||||
uninstallIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
}
|
||||
val packageName = PackageUtils.getPackageNameByPath(context, path)
|
||||
uninstallIntent.data = Uri.parse("package:$packageName")
|
||||
InstallUtils.getInstance(context).addUninstall(packageName)
|
||||
|
||||
@ -30,8 +30,11 @@ import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.CertificateFactory;
|
||||
import java.security.cert.X509Certificate;
|
||||
@ -182,6 +185,11 @@ public class PackageUtils {
|
||||
|
||||
public static boolean compareSignatureBetweenInstalledAppWithApk(Context context, String packageName, String apkFilePath) {
|
||||
try {
|
||||
// 统计签名比较使用的频率 (大文件会触发 ANR)
|
||||
SentryHelper.INSTANCE.onEvent(
|
||||
"SIGNATURE_COMPARE",
|
||||
"packageName", packageName);
|
||||
|
||||
Signature sig = context.getPackageManager().getPackageInfo(packageName, PackageManager.GET_SIGNATURES).signatures[0];
|
||||
|
||||
// Fuck HUAWEI, 华为系统调用 getPackageArchiveInfo 获取魔羯 apk 的签名时会耗时超过5秒造成 ANR,没有找到解决方法
|
||||
@ -286,7 +294,7 @@ public class PackageUtils {
|
||||
*/
|
||||
public static String getPackageNameByPath(Context context, String path) {
|
||||
PackageManager packageManager = context.getApplicationContext().getPackageManager();
|
||||
PackageInfo info = packageManager.getPackageArchiveInfo(path, PackageManager.GET_ACTIVITIES);
|
||||
PackageInfo info = packageManager.getPackageArchiveInfo(path, 0);
|
||||
if (info != null) {
|
||||
ApplicationInfo appInfo = info.applicationInfo;
|
||||
return appInfo.packageName;
|
||||
@ -304,6 +312,11 @@ public class PackageUtils {
|
||||
return intent != null;
|
||||
}
|
||||
|
||||
public static boolean isInstalledFromAllPackage(Context context, String packageName) {
|
||||
ArrayList<String> allPackageName = getAllPackageName(context);
|
||||
return allPackageName.contains(packageName);
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取应用第一次安装的时间
|
||||
*/
|
||||
@ -365,7 +378,7 @@ public class PackageUtils {
|
||||
*/
|
||||
public static ArrayList<String> getAllPackageName(Context context) {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
List<PackageInfo> packageInfos = context.getApplicationContext().getPackageManager().getInstalledPackages(0);
|
||||
List<PackageInfo> packageInfos = getInstalledPackages(context, 0);
|
||||
for (PackageInfo packageInfo : packageInfos) {
|
||||
if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
|
||||
if (!context.getPackageName().equals(packageInfo.packageName)) {
|
||||
@ -380,7 +393,7 @@ public class PackageUtils {
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
try {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
List<PackageInfo> packageInfos = pm.getInstalledPackages(0);
|
||||
List<PackageInfo> packageInfos = getInstalledPackages(context, 0);
|
||||
for (PackageInfo packageInfo : packageInfos) {
|
||||
if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
@ -552,4 +565,42 @@ public class PackageUtils {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 在5.1系统手机使用PackageManager获取已安装应用容易发生Package manager has died异常
|
||||
* https://stackoverflow.com/questions/13235793/transactiontoolargeeception-when-trying-to-get-a-list-of-applications-installed/30062632#30062632
|
||||
*/
|
||||
public static List<PackageInfo> getInstalledPackages(Context context, int flags) {
|
||||
final PackageManager pm = context.getPackageManager();
|
||||
try {
|
||||
return pm.getInstalledPackages(flags);
|
||||
} catch (Exception ignored) {
|
||||
//we don't care why it didn't succeed. We'll do it using an alternative way instead
|
||||
}
|
||||
// use fallback:
|
||||
Process process;
|
||||
List<PackageInfo> result = new ArrayList<>();
|
||||
BufferedReader bufferedReader = null;
|
||||
try {
|
||||
process = Runtime.getRuntime().exec("pm list packages");
|
||||
bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
String line;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
final String packageName = line.substring(line.indexOf(':') + 1);
|
||||
final PackageInfo packageInfo = pm.getPackageInfo(packageName, flags);
|
||||
result.add(packageInfo);
|
||||
}
|
||||
process.waitFor();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (bufferedReader != null)
|
||||
try {
|
||||
bufferedReader.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -8,13 +8,12 @@ import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.provider.Settings
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import com.tbruyelle.rxpermissions2.RxPermissions
|
||||
|
||||
object PermissionHelper {
|
||||
|
||||
const val INSTALL_PERMISS_CODE = 100
|
||||
const val INSTALL_PERMISSION_CODE = 100
|
||||
|
||||
@JvmStatic
|
||||
fun requestReadPhoneStateAndStoragePermissionFromStartUp(context: Context) {
|
||||
@ -233,7 +232,7 @@ object PermissionHelper {
|
||||
} else {
|
||||
val packageURI = Uri.fromParts("package", activity.packageName, null)
|
||||
val intent = Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES, packageURI)
|
||||
activity.startActivityForResult(intent, INSTALL_PERMISS_CODE)
|
||||
activity.startActivityForResult(intent, INSTALL_PERMISSION_CODE)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
47
app/src/main/java/com/gh/common/util/SentryHelper.kt
Normal file
47
app/src/main/java/com/gh/common/util/SentryHelper.kt
Normal file
@ -0,0 +1,47 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.text.TextUtils
|
||||
import com.lightgame.utils.Utils
|
||||
import io.sentry.core.Sentry
|
||||
import io.sentry.core.SentryEvent
|
||||
import io.sentry.core.SentryLevel
|
||||
import io.sentry.core.protocol.Message
|
||||
|
||||
object SentryHelper {
|
||||
|
||||
/**
|
||||
* 注意 tag-key 不支持中文
|
||||
*/
|
||||
fun onEvent(eventId: String, vararg kv: String?) {
|
||||
val sentryEvent = SentryEvent()
|
||||
val message = Message()
|
||||
message.message = eventId
|
||||
sentryEvent.message = message
|
||||
sentryEvent.level = SentryLevel.LOG
|
||||
|
||||
for (i in kv.indices) {
|
||||
if (i % 2 != 0) {
|
||||
val key = kv[i - 1]
|
||||
val value = kv[i]
|
||||
if (!TextUtils.isEmpty(key) && !TextUtils.isEmpty(value)) {
|
||||
sentryEvent.setTag(key, value)
|
||||
debugOnly {
|
||||
throwExceptionInDebug("tag-key 不支持中文", isContainChinese(key))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Utils.log("Sentry", "$eventId + [${kv.joinToString(" , ")}]")
|
||||
Sentry.captureEvent(sentryEvent)
|
||||
}
|
||||
|
||||
// 判断一个字符串是否含有中文
|
||||
private fun isContainChinese(str: String?): Boolean {
|
||||
if (str == null) return false
|
||||
for (c in str.toCharArray()) {
|
||||
if (c.toInt() in 0x4E00..0x9FA5) return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
@ -1,11 +1,9 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
@ -91,7 +89,8 @@ public class ShareUtils {
|
||||
communityArticle("文章详情"),
|
||||
video("视频"),
|
||||
web("web链接"),
|
||||
userHome("个人主页");
|
||||
userHome("个人主页"),
|
||||
qaDetail("QA内容详情");
|
||||
|
||||
private String name;
|
||||
|
||||
@ -158,8 +157,7 @@ public class ShareUtils {
|
||||
|
||||
//检查是否安装手机QQ
|
||||
public static boolean isQQClientAvailable(Context context) {
|
||||
final PackageManager packageManager = context.getPackageManager();
|
||||
List<PackageInfo> pinfo = packageManager.getInstalledPackages(0);
|
||||
List<PackageInfo> pinfo = PackageUtils.getInstalledPackages(context, 0);
|
||||
if (pinfo != null) {
|
||||
for (int i = 0; i < pinfo.size(); i++) {
|
||||
String pn = pinfo.get(i).packageName;
|
||||
@ -563,6 +561,10 @@ public class ShareUtils {
|
||||
private void sinaWeiboShare() {
|
||||
WbSdk.install(mContext, new AuthInfo(mContext, Config.WEIBO_APPKEY, "http://www.sina.com", WEIBO_SCOPE));
|
||||
|
||||
if (mShareEntrance == ShareEntrance.qaDetail) {
|
||||
mTitle = "向你推荐:" + mTitle + " @光环助手 " + shareUrl;
|
||||
mSummary = "";
|
||||
}
|
||||
Activity activity = mActivity.get();
|
||||
if (activity != null) {
|
||||
Intent intent = WeiBoShareActivity.getWeiboshareIntent(
|
||||
@ -591,8 +593,6 @@ public class ShareUtils {
|
||||
smsBody = mTitle + shareUrl;
|
||||
break;
|
||||
case plugin:
|
||||
smsBody = "向你推荐:" + mTitle + "(光环加速版)_光环助手:" + shareUrl;
|
||||
break;
|
||||
case game:
|
||||
smsBody = "向你推荐:" + mTitle + "_光环助手:" + shareUrl;
|
||||
break;
|
||||
@ -606,6 +606,9 @@ public class ShareUtils {
|
||||
case communityArticle:
|
||||
smsBody = mTitle + " - 光环助手" + shareUrl;
|
||||
break;
|
||||
case qaDetail:
|
||||
smsBody = "向你推荐:" + mTitle + " @光环助手 " + shareUrl;
|
||||
break;
|
||||
default:
|
||||
smsBody = mTitle;
|
||||
break;
|
||||
@ -619,7 +622,7 @@ public class ShareUtils {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (mShareEntrance != ShareEntrance.shareGh ) {
|
||||
if (mShareEntrance != ShareEntrance.shareGh) {
|
||||
safelyDismiss();
|
||||
}
|
||||
}
|
||||
@ -628,13 +631,11 @@ public class ShareUtils {
|
||||
private void copyLink(String copyContent) {
|
||||
shareType = "copy_link";
|
||||
LogUtils.uploadShareType(shareType, shareEntrance.getName(), shareUrl, mTitle, mSummary, resourceId);
|
||||
ClipboardManager cmb = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
cmb.setText(copyContent);
|
||||
if (mShareEntrance != ShareEntrance.shareGh) {
|
||||
Utils.toast(mContext, "复制成功");
|
||||
ExtensionsKt.copyTextAndToast(copyContent, "复制成功");
|
||||
safelyDismiss();
|
||||
} else {
|
||||
Utils.toast(mContext, "复制成功,请到微信/QQ粘贴分享");
|
||||
ExtensionsKt.copyTextAndToast(copyContent, "复制成功,请到微信/QQ粘贴分享");
|
||||
}
|
||||
}
|
||||
|
||||
@ -746,7 +747,7 @@ public class ShareUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void safelyDismiss() {
|
||||
if (popupWindow.get() != null) {
|
||||
popupWindow.get().dismiss();
|
||||
|
||||
@ -13,7 +13,7 @@ import androidx.core.content.ContextCompat
|
||||
import com.gh.common.view.CenterImageSpan
|
||||
import com.halo.assistant.HaloApp
|
||||
|
||||
class SpanBuilder(content: String) {
|
||||
class SpanBuilder(content: CharSequence) {
|
||||
private var spannableString: SpannableStringBuilder = SpannableStringBuilder(content)
|
||||
|
||||
fun color(context: Context, start: Int, end: Int, colorRes: Int): SpanBuilder {
|
||||
@ -70,12 +70,12 @@ class SpanBuilder(content: String) {
|
||||
return this
|
||||
}
|
||||
|
||||
fun click(start: Int, end: Int, colorRes: Int, onClick: () -> Unit): SpanBuilder {
|
||||
fun click(start: Int, end: Int, colorRes: Int, isUnderlineText: Boolean = false, onClick: () -> Unit): SpanBuilder {
|
||||
val clickSpan = object : ClickableSpan() {
|
||||
override fun updateDrawState(ds: TextPaint) {
|
||||
super.updateDrawState(ds)
|
||||
ds.color = ContextCompat.getColor(HaloApp.getInstance().application, colorRes)
|
||||
ds.isUnderlineText = false
|
||||
ds.isUnderlineText = isUnderlineText
|
||||
}
|
||||
|
||||
override fun onClick(widget: View) {
|
||||
|
||||
@ -1,32 +0,0 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.content.Context
|
||||
|
||||
/**
|
||||
* 今日头条的激活统计 SDK https://gitlab.ghzs.com/pm/halo-app-issues/issues/567
|
||||
*
|
||||
* 更新 SDK https://gitlab.ghzs.com/pm/halo-app-issues/issues/743
|
||||
*/
|
||||
object TeaHelper {
|
||||
|
||||
@JvmStatic
|
||||
fun init(context: Context, channel: String) {
|
||||
// val config = InitConfig("163824", channel)
|
||||
// config.setUriConfig(UriConfig.DEFAULT)
|
||||
// config.appName = "guanghuan1"
|
||||
// config.setEnablePlay(true)
|
||||
// AppLog.setEnableLog(false)
|
||||
// AppLog.init(context, config)
|
||||
//
|
||||
// AppLog.setOaidObserver {
|
||||
// HaloApp.getInstance().oaid = it.id
|
||||
// Utils.log("oaid is $it.id")
|
||||
// MetaUtil.refreshMeta()
|
||||
// }
|
||||
//
|
||||
// // gameReportHelper ?!
|
||||
// GameReportHelper.onEventRegister("wechat", true)
|
||||
// GameReportHelper.onEventPurchase("gift", "flower", "008", 1, "wechat", "¥", true, 1)
|
||||
}
|
||||
|
||||
}
|
||||
@ -22,10 +22,11 @@ object TimeUtils {
|
||||
return formatter.format(date)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getFormatTime(time: Long, pattern: String = "yyyy-MM-dd"): String {
|
||||
val f = SimpleDateFormat(pattern, Locale.CHINA)
|
||||
f.timeZone = TimeZone.getTimeZone("Asia/Shanghai")
|
||||
return f.format(Date(time * 1000))
|
||||
return f.format(Date(getJavaTimestamp(time)))
|
||||
}
|
||||
|
||||
fun getFormatDate(timestamp: Long): String {
|
||||
|
||||
@ -56,4 +56,10 @@ object ToastUtils {
|
||||
}
|
||||
mOneTime = mTwoTime
|
||||
}
|
||||
|
||||
fun toast(message: String) {
|
||||
if (mToast != null) mToast?.cancel()
|
||||
mToast = ToastHandler.INSTANCE.getToastInstance(HaloApp.getInstance().application, message, Toast.LENGTH_SHORT)
|
||||
mToast?.show()
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,6 @@ package com.gh.common.view
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.*
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
@ -14,7 +13,6 @@ import com.gh.common.util.ImageUtils
|
||||
import com.gh.common.util.rxTimer
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.entity.SettingsEntity
|
||||
import com.squareup.picasso.Picasso
|
||||
import io.reactivex.disposables.Disposable
|
||||
import kotlin.math.abs
|
||||
|
||||
|
||||
@ -4,7 +4,9 @@ import android.content.Context
|
||||
import android.os.Build
|
||||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
import android.widget.LinearLayout
|
||||
import androidx.annotation.Nullable
|
||||
import androidx.core.view.children
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleObserver
|
||||
import androidx.lifecycle.OnLifecycleEvent
|
||||
@ -12,13 +14,15 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import java.lang.ref.WeakReference
|
||||
import java.util.*
|
||||
|
||||
class AutoScrollRecyclerView(context: Context, @Nullable attrs: AttributeSet?) : RecyclerView(context, attrs), LifecycleObserver {
|
||||
class AutoScrollRecyclerViewContainerView(context: Context, @Nullable attrs: AttributeSet?)
|
||||
: LinearLayout(context, attrs), LifecycleObserver {
|
||||
|
||||
var autoScrollTask: AutoScrollTask?
|
||||
|
||||
private var mIsScrolling = false
|
||||
private var mIsScrollable = false
|
||||
private var mOnItemTouchListener: OnItemTouchListener? = null
|
||||
|
||||
private var mOnItemTouchListener: RecyclerView.OnItemTouchListener? = null
|
||||
|
||||
init {
|
||||
autoScrollTask = AutoScrollTask(this)
|
||||
@ -28,20 +32,23 @@ class AutoScrollRecyclerView(context: Context, @Nullable attrs: AttributeSet?) :
|
||||
super.onAttachedToWindow()
|
||||
|
||||
if (mOnItemTouchListener == null) {
|
||||
mOnItemTouchListener = object : OnItemTouchListener {
|
||||
mOnItemTouchListener = object : RecyclerView.OnItemTouchListener {
|
||||
override fun onTouchEvent(rv: RecyclerView, e: MotionEvent) {}
|
||||
override fun onInterceptTouchEvent(rv: RecyclerView, e: MotionEvent) = rv.scrollState == SCROLL_STATE_DRAGGING
|
||||
override fun onInterceptTouchEvent(rv: RecyclerView, e: MotionEvent) = rv.scrollState == RecyclerView.SCROLL_STATE_DRAGGING
|
||||
override fun onRequestDisallowInterceptTouchEvent(disallowIntercept: Boolean) {}
|
||||
}
|
||||
}
|
||||
|
||||
removeOnItemTouchListener(mOnItemTouchListener!!)
|
||||
addOnItemTouchListener(mOnItemTouchListener!!)
|
||||
for (child in children) {
|
||||
if (child is RecyclerView) {
|
||||
child.removeOnItemTouchListener(mOnItemTouchListener!!)
|
||||
child.addOnItemTouchListener(mOnItemTouchListener!!)
|
||||
}
|
||||
}
|
||||
|
||||
resumeScrolling()
|
||||
}
|
||||
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
|
||||
@ -72,20 +79,24 @@ class AutoScrollRecyclerView(context: Context, @Nullable attrs: AttributeSet?) :
|
||||
private const val AUTO_SCROLL_INTERVAL: Long = 10
|
||||
}
|
||||
|
||||
class AutoScrollTask(reference: AutoScrollRecyclerView?) : Runnable {
|
||||
private val mReference: WeakReference<AutoScrollRecyclerView?>?
|
||||
class AutoScrollTask(reference: AutoScrollRecyclerViewContainerView?) : Runnable {
|
||||
private val mReference: WeakReference<AutoScrollRecyclerViewContainerView?>?
|
||||
private val mScrollSlop = if (Build.MODEL.toLowerCase(Locale.getDefault()) == "mumu") 1 else 2
|
||||
|
||||
override fun run() {
|
||||
val recyclerView: AutoScrollRecyclerView? = mReference?.get()
|
||||
if (recyclerView != null && recyclerView.mIsScrolling && recyclerView.mIsScrollable) {
|
||||
recyclerView.scrollBy(mScrollSlop, mScrollSlop)
|
||||
recyclerView.postDelayed(recyclerView.autoScrollTask, AUTO_SCROLL_INTERVAL)
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
mReference = WeakReference(reference)
|
||||
}
|
||||
|
||||
override fun run() {
|
||||
val containerView: AutoScrollRecyclerViewContainerView? = mReference?.get()
|
||||
if (containerView != null && containerView.mIsScrolling && containerView.mIsScrollable) {
|
||||
for (child in containerView.children) {
|
||||
if (child is RecyclerView) {
|
||||
child.scrollBy(mScrollSlop, mScrollSlop)
|
||||
}
|
||||
}
|
||||
containerView.postDelayed(containerView.autoScrollTask, AUTO_SCROLL_INTERVAL)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -29,6 +29,7 @@ class AvatarBorderView : ConstraintLayout {
|
||||
private var mBadgeWidth = 30f
|
||||
private var mAvatarBorderColor = Color.parseColor("#ffffff")
|
||||
private var mAvatarBorderWidth = 2f.dip2px().toFloat()
|
||||
private var mRatio = 0f
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
|
||||
@ -50,6 +51,9 @@ class AvatarBorderView : ConstraintLayout {
|
||||
if (ta.hasValue(R.styleable.AvatarBorderView_border_width)) {
|
||||
mAvatarBorderWidth = ta.getDimension(R.styleable.AvatarBorderView_border_width, mAvatarBorderWidth)
|
||||
}
|
||||
if (ta.hasValue(R.styleable.AvatarBorderView_border_ratio)) {
|
||||
mRatio = ta.getFloat(R.styleable.AvatarBorderView_border_ratio, 0f)
|
||||
}
|
||||
mAvatarBorderColor = ta.getColor(R.styleable.AvatarBorderView_border_color, mAvatarBorderColor)
|
||||
ta.recycle()
|
||||
|
||||
@ -74,8 +78,13 @@ class AvatarBorderView : ConstraintLayout {
|
||||
}
|
||||
borderView?.apply {
|
||||
val params = layoutParams
|
||||
params.width = (mAvatarWidth * 3 / 2).toInt()
|
||||
params.height = (mAvatarWidth * 3 / 2).toInt()
|
||||
if (mRatio > 0) {
|
||||
params.width = (mAvatarWidth * mRatio).toInt()
|
||||
params.height = (mAvatarWidth * mRatio).toInt()
|
||||
} else {
|
||||
params.width = (mAvatarWidth * 3 / 2).toInt()
|
||||
params.height = (mAvatarWidth * 3 / 2).toInt()
|
||||
}
|
||||
layoutParams = params
|
||||
}
|
||||
badgeView?.apply {
|
||||
|
||||
301
app/src/main/java/com/gh/common/view/CatalogFilterView.kt
Normal file
301
app/src/main/java/com/gh/common/view/CatalogFilterView.kt
Normal file
@ -0,0 +1,301 @@
|
||||
package com.gh.common.view
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.PopupWindow
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.gh.common.util.toColor
|
||||
import com.gh.common.util.visibleIf
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.entity.CatalogEntity
|
||||
import com.gh.gamecenter.entity.SubjectSettingEntity
|
||||
import com.google.android.flexbox.FlexboxLayout
|
||||
|
||||
class CatalogFilterView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : LinearLayout(context, attrs, defStyleAttr) {
|
||||
|
||||
private var mTypeTv: TextView
|
||||
private var mCatalogTv: TextView
|
||||
private var mSizeTv: TextView
|
||||
private var mTypeContainer: View
|
||||
private var mCatalogContainer: View
|
||||
private var mSizeContainer: View
|
||||
|
||||
private var mTypeFilterArray = ArrayList<SortType>()
|
||||
private var mCatalogFilterArray = ArrayList<CatalogEntity.SubCatalogEntity>()
|
||||
private var sizeFilterArray: ArrayList<SubjectSettingEntity.Size>? = null
|
||||
|
||||
private var mOnCatalogFilterSetupListener: OnCatalogFilterSetupListener? = null
|
||||
|
||||
init {
|
||||
View.inflate(context, R.layout.layout_catalog_filter, this)
|
||||
|
||||
mTypeTv = findViewById(R.id.type_tv)
|
||||
mCatalogTv = findViewById(R.id.catalog_tv)
|
||||
mSizeTv = findViewById(R.id.size_tv)
|
||||
mTypeContainer = findViewById(R.id.container_type)
|
||||
mCatalogContainer = findViewById(R.id.container_catalog)
|
||||
mSizeContainer = findViewById(R.id.container_size)
|
||||
|
||||
mTypeContainer.setOnClickListener {
|
||||
showSelectTypePopupWindow(this, mTypeTv, mTypeTv.text.toString())
|
||||
}
|
||||
|
||||
mCatalogContainer.setOnClickListener {
|
||||
showSelectCatalogPopupWindow(this, mCatalogTv, mCatalogTv.text.toString())
|
||||
}
|
||||
|
||||
mSizeContainer.setOnClickListener {
|
||||
showSelectSizePopupWindow(this, mSizeTv, mSizeTv.text.toString())
|
||||
}
|
||||
}
|
||||
|
||||
fun setTypeList(switch: CatalogEntity.CatalogSwitch) {
|
||||
switch.run {
|
||||
if ("on" == hotSort) mTypeFilterArray.add(SortType.RECOMMENDED)
|
||||
if ("on" == newSort) mTypeFilterArray.add(SortType.NEWEST)
|
||||
if ("on" == starSort) mTypeFilterArray.add(SortType.RATING)
|
||||
}
|
||||
if (mTypeFilterArray.isNotEmpty()) mTypeTv.text = mTypeFilterArray[0].value
|
||||
}
|
||||
|
||||
fun setCatalogList(subCatalogList: List<CatalogEntity.SubCatalogEntity>, initCatalogName: String) {
|
||||
mCatalogFilterArray = ArrayList(subCatalogList)
|
||||
mCatalogTv.text = initCatalogName
|
||||
}
|
||||
|
||||
fun setOnConfigSetupListener(onCatalogFilterSetupListener: OnCatalogFilterSetupListener) {
|
||||
mOnCatalogFilterSetupListener = onCatalogFilterSetupListener
|
||||
}
|
||||
|
||||
private fun toggleHighlightedTextView(targetTextView: TextView, highlightIt: Boolean) {
|
||||
if (highlightIt) {
|
||||
targetTextView.background = ContextCompat.getDrawable(targetTextView.context, R.drawable.bg_tag_text)
|
||||
targetTextView.setTextColor(Color.WHITE)
|
||||
} else {
|
||||
targetTextView.background = null
|
||||
targetTextView.setTextColor(ContextCompat.getColor(targetTextView.context, R.color.text_757575))
|
||||
}
|
||||
}
|
||||
|
||||
private fun showSelectTypePopupWindow(containerView: View, typeTv: TextView, typeText: String) {
|
||||
val drawableUp = ContextCompat.getDrawable(typeTv.context, R.drawable.ic_filter_arrow_up)
|
||||
val drawableDown = ContextCompat.getDrawable(typeTv.context, R.drawable.ic_filter_arrow_down)
|
||||
drawableUp?.setBounds(0, 0, drawableUp.minimumWidth, drawableUp.minimumHeight)
|
||||
drawableDown?.setBounds(0, 0, drawableDown.minimumWidth, drawableDown.minimumHeight)
|
||||
|
||||
typeTv.setTextColor(R.color.theme_font.toColor())
|
||||
typeTv.setCompoundDrawables(null, null, drawableUp, null)
|
||||
|
||||
val inflater = LayoutInflater.from(typeTv.context)
|
||||
val layout = inflater.inflate(R.layout.layout_filter_size, null)
|
||||
val popupWindow = PopupWindow(
|
||||
layout,
|
||||
LayoutParams.MATCH_PARENT,
|
||||
LayoutParams.WRAP_CONTENT)
|
||||
|
||||
val flexboxLayout = layout.findViewById<FlexboxLayout>(R.id.flexbox)
|
||||
val backgroundView = layout.findViewById<View>(R.id.background)
|
||||
|
||||
backgroundView.setOnClickListener {
|
||||
popupWindow.dismiss()
|
||||
}
|
||||
|
||||
for (type in mTypeFilterArray) {
|
||||
val item = inflater.inflate(R.layout.item_filter_size, flexboxLayout, false)
|
||||
|
||||
// 单列 3 个,强行设置宽度为屏幕的 1/3
|
||||
val width = typeTv.context.resources.displayMetrics.widthPixels / 3
|
||||
val height = item.layoutParams.height
|
||||
|
||||
item.layoutParams = ViewGroup.LayoutParams(width, height)
|
||||
flexboxLayout.addView(item)
|
||||
|
||||
val tv = item.findViewById<TextView>(R.id.size_tv)
|
||||
tv.text = type.value
|
||||
|
||||
toggleHighlightedTextView(tv, typeText == type.value)
|
||||
|
||||
tv.tag = type.value
|
||||
|
||||
item.setOnClickListener {
|
||||
toggleHighlightedTextView(tv, true)
|
||||
popupWindow.dismiss()
|
||||
typeTv.text = type.value
|
||||
|
||||
mOnCatalogFilterSetupListener?.onSetupSortType(type)
|
||||
}
|
||||
}
|
||||
|
||||
popupWindow.setOnDismissListener {
|
||||
typeTv.setTextColor(R.color.text_757575.toColor())
|
||||
typeTv.setCompoundDrawables(null, null, drawableDown, null)
|
||||
}
|
||||
|
||||
popupWindow.isTouchable = true
|
||||
popupWindow.isFocusable = true
|
||||
popupWindow.animationStyle = 0
|
||||
popupWindow.showAsDropDown(containerView, 0, 0)
|
||||
}
|
||||
|
||||
private fun showSelectCatalogPopupWindow(containerView: View, catalogTv: TextView, catalogText: String) {
|
||||
val drawableUp = ContextCompat.getDrawable(catalogTv.context, R.drawable.ic_filter_arrow_up)
|
||||
val drawableDown = ContextCompat.getDrawable(catalogTv.context, R.drawable.ic_filter_arrow_down)
|
||||
drawableUp?.setBounds(0, 0, drawableUp.minimumWidth, drawableUp.minimumHeight)
|
||||
drawableDown?.setBounds(0, 0, drawableDown.minimumWidth, drawableDown.minimumHeight)
|
||||
|
||||
catalogTv.setTextColor(R.color.theme_font.toColor())
|
||||
catalogTv.setCompoundDrawables(null, null, drawableUp, null)
|
||||
|
||||
val inflater = LayoutInflater.from(catalogTv.context)
|
||||
val layout = inflater.inflate(R.layout.layout_filter_size, null)
|
||||
val popupWindow = PopupWindow(
|
||||
layout,
|
||||
LayoutParams.MATCH_PARENT,
|
||||
LayoutParams.WRAP_CONTENT)
|
||||
|
||||
val flexboxLayout = layout.findViewById<FlexboxLayout>(R.id.flexbox)
|
||||
val backgroundView = layout.findViewById<View>(R.id.background)
|
||||
|
||||
backgroundView.setOnClickListener {
|
||||
popupWindow.dismiss()
|
||||
}
|
||||
|
||||
for (entity in mCatalogFilterArray) {
|
||||
val item = inflater.inflate(R.layout.item_filter_size, flexboxLayout, false)
|
||||
|
||||
// 单列 3 个,强行设置宽度为屏幕的 1/3
|
||||
val width = catalogTv.context.resources.displayMetrics.widthPixels / 3
|
||||
val height = item.layoutParams.height
|
||||
|
||||
item.layoutParams = ViewGroup.LayoutParams(width, height)
|
||||
flexboxLayout.addView(item)
|
||||
|
||||
val tv = item.findViewById<TextView>(R.id.size_tv)
|
||||
val iv = item.findViewById<ImageView>(R.id.recommend_iv)
|
||||
tv.text = entity.name
|
||||
iv.visibleIf(entity.recommended)
|
||||
|
||||
toggleHighlightedTextView(tv, catalogText == entity.name)
|
||||
|
||||
tv.tag = entity.name
|
||||
|
||||
item.setOnClickListener {
|
||||
toggleHighlightedTextView(tv, true)
|
||||
popupWindow.dismiss()
|
||||
catalogTv.text = entity.name
|
||||
|
||||
mOnCatalogFilterSetupListener?.onSetupSortCatalog(entity)
|
||||
}
|
||||
}
|
||||
|
||||
popupWindow.setOnDismissListener {
|
||||
catalogTv.setTextColor(R.color.text_757575.toColor())
|
||||
catalogTv.setCompoundDrawables(null, null, drawableDown, null)
|
||||
}
|
||||
|
||||
popupWindow.isTouchable = true
|
||||
popupWindow.isFocusable = true
|
||||
popupWindow.animationStyle = 0
|
||||
popupWindow.showAsDropDown(containerView, 0, 0)
|
||||
}
|
||||
|
||||
private fun showSelectSizePopupWindow(containerView: View, sizeTv: TextView, sizeText: String) {
|
||||
val drawableUp = ContextCompat.getDrawable(sizeTv.context, R.drawable.ic_filter_arrow_up)
|
||||
val drawableDown = ContextCompat.getDrawable(sizeTv.context, R.drawable.ic_filter_arrow_down)
|
||||
drawableUp?.setBounds(0, 0, drawableUp.minimumWidth, drawableUp.minimumHeight)
|
||||
drawableDown?.setBounds(0, 0, drawableDown.minimumWidth, drawableDown.minimumHeight)
|
||||
|
||||
sizeTv.setTextColor(R.color.theme_font.toColor())
|
||||
sizeTv.setCompoundDrawables(null, null, drawableUp, null)
|
||||
|
||||
val inflater = LayoutInflater.from(sizeTv.context)
|
||||
val layout = inflater.inflate(R.layout.layout_filter_size, null)
|
||||
val popupWindow = PopupWindow(
|
||||
layout,
|
||||
LayoutParams.MATCH_PARENT,
|
||||
LayoutParams.WRAP_CONTENT)
|
||||
|
||||
val flexboxLayout = layout.findViewById<FlexboxLayout>(R.id.flexbox)
|
||||
val backgroundView = layout.findViewById<View>(R.id.background)
|
||||
|
||||
sizeFilterArray = if (sizeFilterArray == null) {
|
||||
getDefaultSizeFilterArray()
|
||||
} else {
|
||||
sizeFilterArray?.apply {
|
||||
if (firstOrNull()?.text != "全部大小") {
|
||||
add(0, SubjectSettingEntity.Size(min = -1, max = -1, text = "全部大小"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
backgroundView.setOnClickListener {
|
||||
popupWindow.dismiss()
|
||||
}
|
||||
|
||||
for (size in sizeFilterArray!!) {
|
||||
val item = inflater.inflate(R.layout.item_filter_size, flexboxLayout, false)
|
||||
|
||||
// 单列 3 个,强行设置宽度为屏幕的 1/3
|
||||
val width = sizeTv.context.resources.displayMetrics.widthPixels / 3
|
||||
val height = item.layoutParams.height
|
||||
|
||||
item.layoutParams = ViewGroup.LayoutParams(width, height)
|
||||
flexboxLayout.addView(item)
|
||||
|
||||
val tv = item.findViewById<TextView>(R.id.size_tv)
|
||||
tv.text = size.text
|
||||
|
||||
toggleHighlightedTextView(tv, sizeText == size.text)
|
||||
|
||||
tv.tag = size.text
|
||||
|
||||
item.setOnClickListener {
|
||||
toggleHighlightedTextView(tv, true)
|
||||
popupWindow.dismiss()
|
||||
sizeTv.text = size.text
|
||||
|
||||
mOnCatalogFilterSetupListener?.onSetupSortSize(size)
|
||||
}
|
||||
}
|
||||
|
||||
popupWindow.setOnDismissListener {
|
||||
sizeTv.setTextColor(R.color.text_757575.toColor())
|
||||
sizeTv.setCompoundDrawables(null, null, drawableDown, null)
|
||||
}
|
||||
|
||||
popupWindow.isTouchable = true
|
||||
popupWindow.isFocusable = true
|
||||
popupWindow.animationStyle = 0
|
||||
popupWindow.showAsDropDown(containerView, 0, 0)
|
||||
}
|
||||
|
||||
private fun getDefaultSizeFilterArray(): ArrayList<SubjectSettingEntity.Size> {
|
||||
return arrayListOf<SubjectSettingEntity.Size>().apply {
|
||||
add(SubjectSettingEntity.Size(min = -1, max = -1, text = "全部大小"))
|
||||
add(SubjectSettingEntity.Size(min = -1, max = 100, text = "100M以下"))
|
||||
add(SubjectSettingEntity.Size(min = 100, max = 300, text = "100-300M"))
|
||||
add(SubjectSettingEntity.Size(min = 300, max = 500, text = "300-500M"))
|
||||
add(SubjectSettingEntity.Size(min = 500, max = 1000, text = "500M-1G"))
|
||||
add(SubjectSettingEntity.Size(min = 1000, max = -1, text = "1G以上"))
|
||||
}
|
||||
}
|
||||
|
||||
interface OnCatalogFilterSetupListener {
|
||||
fun onSetupSortSize(sortSize: SubjectSettingEntity.Size)
|
||||
fun onSetupSortType(sortType: SortType)
|
||||
fun onSetupSortCatalog(sortCatalog: CatalogEntity.SubCatalogEntity)
|
||||
}
|
||||
|
||||
enum class SortType(val value: String) {
|
||||
RECOMMENDED("热门推荐"),
|
||||
NEWEST("最新上线"),
|
||||
RATING("最高评分")
|
||||
}
|
||||
}
|
||||
@ -12,7 +12,7 @@ import android.widget.PopupWindow
|
||||
import android.widget.TextView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.gh.common.util.DisplayUtils
|
||||
import com.gh.common.util.toColor
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.entity.SubjectSettingEntity
|
||||
import com.google.android.flexbox.FlexboxLayout
|
||||
@ -69,16 +69,13 @@ class ConfigFilterView @JvmOverloads constructor(context: Context, attrs: Attrib
|
||||
mOnConfigFilterSetupListener = onConfigFilterSetupListener
|
||||
}
|
||||
|
||||
fun toggleHighlightedTextView(targetTextView: TextView, highlightIt: Boolean) {
|
||||
private fun toggleHighlightedTextView(targetTextView: TextView, highlightIt: Boolean) {
|
||||
if (highlightIt) {
|
||||
targetTextView.background = ContextCompat.getDrawable(targetTextView.context, R.drawable.text_blue_background)
|
||||
targetTextView.background = ContextCompat.getDrawable(targetTextView.context, R.drawable.bg_tag_text)
|
||||
targetTextView.setTextColor(Color.WHITE)
|
||||
} else {
|
||||
val colorDrawable = GradientDrawable()
|
||||
colorDrawable.setColor(Color.WHITE)
|
||||
colorDrawable.cornerRadius = DisplayUtils.dip2px(1.5f).toFloat()
|
||||
targetTextView.background = colorDrawable
|
||||
targetTextView.setTextColor(ContextCompat.getColor(targetTextView.context, R.color.text_3a3a3a))
|
||||
targetTextView.background = null
|
||||
targetTextView.setTextColor(ContextCompat.getColor(targetTextView.context, R.color.text_757575))
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,8 +85,8 @@ class ConfigFilterView @JvmOverloads constructor(context: Context, attrs: Attrib
|
||||
drawableUp?.setBounds(0, 0, drawableUp.minimumWidth, drawableUp.minimumHeight)
|
||||
drawableDown?.setBounds(0, 0, drawableDown.minimumWidth, drawableDown.minimumHeight)
|
||||
|
||||
sizeTv.setTextColor(R.color.theme_font.toColor())
|
||||
sizeTv.setCompoundDrawables(null, null, drawableUp, null)
|
||||
sizeTv.text = "收起"
|
||||
|
||||
val inflater = LayoutInflater.from(sizeTv.context)
|
||||
val layout = inflater.inflate(R.layout.layout_filter_size, null)
|
||||
@ -146,25 +143,24 @@ class ConfigFilterView @JvmOverloads constructor(context: Context, attrs: Attrib
|
||||
}
|
||||
|
||||
popupWindow.setOnDismissListener {
|
||||
sizeTv.setTextColor(R.color.text_757575.toColor())
|
||||
sizeTv.setCompoundDrawables(null, null, drawableDown, null)
|
||||
if (sizeTv.text == "收起") {
|
||||
sizeTv.text = sizeText
|
||||
}
|
||||
}
|
||||
|
||||
popupWindow.isTouchable = true
|
||||
popupWindow.isFocusable = true
|
||||
popupWindow.animationStyle = 0
|
||||
popupWindow.showAsDropDown(containerView, 0, 0)
|
||||
}
|
||||
|
||||
private fun getDefaultSizeFilterArray(): ArrayList<SubjectSettingEntity.Size> {
|
||||
return arrayListOf<SubjectSettingEntity.Size>().apply {
|
||||
add(SubjectSettingEntity.Size(min = -1, max = -1, text = "全部大小"))
|
||||
add(SubjectSettingEntity.Size(min = -1, max = 20, text = "20M以下"))
|
||||
add(SubjectSettingEntity.Size(min = 20, max = 50, text = "20-50M"))
|
||||
add(SubjectSettingEntity.Size(min = 50, max = 100, text = "50-100M"))
|
||||
add(SubjectSettingEntity.Size(min = 100, max = 500, text = "100-500M"))
|
||||
add(SubjectSettingEntity.Size(min = 500, max = -1, text = "500M以上"))
|
||||
add(SubjectSettingEntity.Size(min = -1, max = 100, text = "100M以下"))
|
||||
add(SubjectSettingEntity.Size(min = 100, max = 300, text = "100-300M"))
|
||||
add(SubjectSettingEntity.Size(min = 300, max = 500, text = "300-500M"))
|
||||
add(SubjectSettingEntity.Size(min = 500, max = 1000, text = "500M-1G"))
|
||||
add(SubjectSettingEntity.Size(min = 1000, max = -1, text = "1G以上"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -39,6 +39,7 @@ public class DownloadProgressBar extends ProgressBar {
|
||||
RESERVABLE,
|
||||
RESERVED,
|
||||
H5_GAME,
|
||||
UPDATING,
|
||||
|
||||
XAPK_UNZIPPING,
|
||||
XAPK_SUCCESS,
|
||||
@ -212,17 +213,21 @@ public class DownloadProgressBar extends ProgressBar {
|
||||
break;
|
||||
case RESERVABLE:
|
||||
setProgressDrawable(getResources().getDrawable(R.drawable.button_reserve));
|
||||
mDefaultColor = ContextCompat.getColor(getContext(), R.color.all_white);
|
||||
mDefaultColor = ContextCompat.getColor(getContext(), R.color.white);
|
||||
break;
|
||||
case UPDATING:
|
||||
setProgressDrawable(getResources().getDrawable(R.drawable.download_button_updating_style));
|
||||
mDefaultColor = ContextCompat.getColor(getContext(), R.color.white);
|
||||
break;
|
||||
case RESERVED:
|
||||
setProgressDrawable(getResources().getDrawable(R.drawable.game_item_btn_pause_dn));
|
||||
mDefaultColor = ContextCompat.getColor(getContext(), R.color.all_white);
|
||||
mDefaultColor = ContextCompat.getColor(getContext(), R.color.white);
|
||||
break;
|
||||
case XAPK_FAILURE:
|
||||
case XAPK_SUCCESS:
|
||||
case XAPK_UNZIPPING:
|
||||
setProgressDrawable(getResources().getDrawable(R.drawable.progressbar_xapk_detail_style));
|
||||
mDefaultColor = ContextCompat.getColor(getContext(), R.color.all_white);
|
||||
mDefaultColor = ContextCompat.getColor(getContext(), R.color.white);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ import android.text.TextUtils
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.facebook.drawee.generic.RoundingParams
|
||||
import com.facebook.drawee.view.SimpleDraweeView
|
||||
import com.gh.common.util.DisplayUtils
|
||||
@ -18,6 +19,7 @@ class GameIconView : ConstraintLayout {
|
||||
|
||||
private var mCornerRadius = 10
|
||||
private var mBorderColor = 0
|
||||
private var mGameIconOverlayColor = 0
|
||||
private var mBorderWidth = 1
|
||||
private var mFadeDuration = -1
|
||||
|
||||
@ -36,11 +38,15 @@ class GameIconView : ConstraintLayout {
|
||||
val ta = context.obtainStyledAttributes(attrs, R.styleable.GameIconView)
|
||||
mCornerRadius = ta.getDimensionPixelSize(R.styleable.GameIconView_gameIconCornerRadius, DisplayUtils.dip2px(10F))
|
||||
mBorderColor = ta.getColor(R.styleable.GameIconView_gameIconBorderColor, 0)
|
||||
mGameIconOverlayColor = ta.getColor(R.styleable.GameIconView_gameIconOverlayColor, 0)
|
||||
mBorderWidth = ta.getDimensionPixelSize(R.styleable.GameIconView_gameIconBorderWidth, 1)
|
||||
mFadeDuration = ta.getInt(R.styleable.GameIconView_gameIconFadeDuration, -1)
|
||||
ta.recycle()
|
||||
|
||||
val roundingParams = RoundingParams.fromCornersRadius(mCornerRadius.toFloat())
|
||||
if (mGameIconOverlayColor != 0) {
|
||||
roundingParams.overlayColor = mGameIconOverlayColor
|
||||
}
|
||||
|
||||
if (mBorderColor != 0) {
|
||||
roundingParams.setBorder(mBorderColor, mBorderWidth.toFloat())
|
||||
|
||||
@ -32,7 +32,7 @@ class ReserveDialog : BaseDialogFragment() {
|
||||
binding.more.setOnClickListener {
|
||||
val intent = MyGameActivity.getIntentWithConfig(requireContext(), 2)
|
||||
startActivity(intent)
|
||||
dismiss()
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
binding.recyclerView.layoutManager = if (mReserveList.size > 4) {
|
||||
GridLayoutManager(context, 4)
|
||||
@ -54,7 +54,7 @@ class ReserveDialog : BaseDialogFragment() {
|
||||
holder.binding.game = entity
|
||||
holder.itemView.setOnClickListener {
|
||||
GameDetailActivity.startGameDetailActivity(mContext, entity.id, "(预约弹窗)")
|
||||
dismiss()
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,70 @@
|
||||
package com.gh.common.view
|
||||
|
||||
import android.text.Selection
|
||||
import android.text.Spannable
|
||||
import android.text.method.LinkMovementMethod
|
||||
import android.text.style.ClickableSpan
|
||||
import android.text.style.URLSpan
|
||||
import android.view.MotionEvent
|
||||
import android.view.ViewGroup
|
||||
import android.view.ViewParent
|
||||
import android.widget.TextView
|
||||
import com.gh.common.DefaultUrlHandler
|
||||
|
||||
/**
|
||||
* 拦截处理以 "ghzhushou://" 起始的 URLSpan
|
||||
*/
|
||||
class UrlInterceptedLinkMovementMethod : LinkMovementMethod() {
|
||||
|
||||
override fun onTouchEvent(widget: TextView, buffer: Spannable, event: MotionEvent): Boolean {
|
||||
val action = event.action
|
||||
var isTouchEventConsumed = false
|
||||
if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_DOWN) {
|
||||
var x = event.x.toInt()
|
||||
var y = event.y.toInt()
|
||||
x -= widget.totalPaddingLeft
|
||||
y -= widget.totalPaddingTop
|
||||
x += widget.scrollX
|
||||
y += widget.scrollY
|
||||
val layout = widget.layout
|
||||
val line = layout.getLineForVertical(y)
|
||||
val off = layout.getOffsetForHorizontal(line, x.toFloat())
|
||||
val links = buffer.getSpans(off, off, ClickableSpan::class.java)
|
||||
if (links.size != 0) {
|
||||
val link = links[0]
|
||||
if (action == MotionEvent.ACTION_UP) {
|
||||
if (link is URLSpan && link.url.contains("ghzhushou")) {
|
||||
DefaultUrlHandler.interceptUrl(widget.context, link.url, "")
|
||||
} else {
|
||||
link.onClick(widget)
|
||||
}
|
||||
} else if (action == MotionEvent.ACTION_DOWN) {
|
||||
// do nothing
|
||||
}
|
||||
isTouchEventConsumed = true
|
||||
} else {
|
||||
Selection.removeSelection(buffer)
|
||||
}
|
||||
}
|
||||
|
||||
//解决点击事件冲突问题
|
||||
if (!isTouchEventConsumed && event.action == MotionEvent.ACTION_UP) {
|
||||
val parent: ViewParent? = iterateViewParentForClicking(widget.parent) //处理widget的父控件点击事件
|
||||
if (parent is ViewGroup) {
|
||||
return parent.performClick()
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private fun iterateViewParentForClicking(parent: ViewParent): ViewParent? {
|
||||
return if (parent is ViewGroup) {
|
||||
if (parent.hasOnClickListeners()) {
|
||||
parent
|
||||
} else {
|
||||
iterateViewParentForClicking(parent.getParent())
|
||||
}
|
||||
} else null
|
||||
}
|
||||
|
||||
}
|
||||
@ -86,7 +86,7 @@ class WelcomeDialog : BaseDialogFragment() {
|
||||
|
||||
mDismissByClickImage = true
|
||||
|
||||
dismiss()
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
binding.ivOpeningCover.loadingCallback = object : WrapContentDraweeView.LoadingCallback {
|
||||
@ -102,15 +102,24 @@ class WelcomeDialog : BaseDialogFragment() {
|
||||
}
|
||||
|
||||
binding.ivCloseBackup.setOnClickListener {
|
||||
dismiss()
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
binding.ivClose.setOnClickListener {
|
||||
dismiss()
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
binding.welcome = mWelcomeEntity
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun dismissAllowingStateLoss() {
|
||||
try {
|
||||
mDismissByClickImage = false
|
||||
super.dismissAllowingStateLoss()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
override fun dismiss() {
|
||||
try {
|
||||
mDismissByClickImage = false
|
||||
|
||||
146
app/src/main/java/com/gh/common/view/ZoomCoordinatorLayout.java
Normal file
146
app/src/main/java/com/gh/common/view/ZoomCoordinatorLayout.java
Normal file
@ -0,0 +1,146 @@
|
||||
package com.gh.common.view;
|
||||
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
|
||||
public class ZoomCoordinatorLayout extends CoordinatorLayout {
|
||||
private View mZoomView;
|
||||
private int mZoomViewWidth;
|
||||
private int mZoomViewHeight;
|
||||
|
||||
private float firstPosition;//记录第一次按下的位置
|
||||
private boolean isScrolling;//是否正在缩放
|
||||
private boolean isScrollDown;//是否下滑
|
||||
|
||||
private float mScrollRate = 0.6f;//缩放系数,缩放系数越大,变化的越大
|
||||
private float mReplyRate = 0.3f;//回调系数,越大,回调越慢
|
||||
private View mMoveView;
|
||||
private View mMoveView2;
|
||||
private int height,height2;
|
||||
/**
|
||||
* 初始坐标
|
||||
*/
|
||||
private float mInitialY, mInitialX;
|
||||
|
||||
|
||||
public ZoomCoordinatorLayout(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public ZoomCoordinatorLayout(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public ZoomCoordinatorLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
public void setZoomView(View mZoomView) {
|
||||
this.mZoomView = mZoomView;
|
||||
}
|
||||
|
||||
public void setMoveView(View mMoveView1, View mMoveView2) {
|
||||
this.mMoveView = mMoveView1;
|
||||
this.mMoveView2 = mMoveView2;
|
||||
height = mMoveView.getMeasuredHeight();
|
||||
height2 = mMoveView2.getMeasuredHeight();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean dispatchTouchEvent(MotionEvent ev) {
|
||||
int[] location = new int[2];
|
||||
mZoomView.getLocationOnScreen(location);
|
||||
int y = location[1];
|
||||
|
||||
|
||||
if (mZoomViewWidth <= 0 || mZoomViewHeight <= 0) {
|
||||
mZoomViewWidth = mZoomView.getMeasuredWidth();
|
||||
mZoomViewHeight = mZoomView.getMeasuredHeight();
|
||||
}
|
||||
|
||||
switch (ev.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
mInitialX = ev.getX();
|
||||
mInitialY = ev.getY();
|
||||
break;
|
||||
case MotionEvent.ACTION_UP:
|
||||
if(isScrollDown) break;
|
||||
//手指离开后恢复图片
|
||||
isScrolling = false;
|
||||
replyImage();
|
||||
break;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
if(y != 0 || (ev.getY() - mInitialY) < 0) return super.dispatchTouchEvent(ev);
|
||||
isScrollDown = false;
|
||||
if (!isScrolling) {
|
||||
if (getScrollY() == 0) {
|
||||
firstPosition = ev.getY();// 滚动到顶部时记录位置,否则正常返回
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
int distance = (int) ((ev.getY() - firstPosition) * mScrollRate); // 滚动距离乘以一个系数
|
||||
if (distance < 0) { // 当前位置比记录位置要小,正常返回
|
||||
isScrollDown = true;
|
||||
break;
|
||||
}
|
||||
// 处理放大
|
||||
isScrolling = true;
|
||||
setZoom(distance);
|
||||
|
||||
return super.dispatchTouchEvent(ev);
|
||||
}
|
||||
return super.dispatchTouchEvent(ev);
|
||||
|
||||
}
|
||||
|
||||
private void scrollDown(float zoom) {
|
||||
mMoveView2.setScrollY(-(int)(height2 * ((height2 + zoom) / height2)));
|
||||
}
|
||||
|
||||
//回弹动画
|
||||
private void replyImage() {
|
||||
float distance = mZoomView.getMeasuredWidth() - mZoomViewWidth;
|
||||
ValueAnimator valueAnimator = ValueAnimator.ofFloat(distance, 0f).setDuration((long) (distance * mReplyRate));
|
||||
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
setZoom((Float) animation.getAnimatedValue());
|
||||
}
|
||||
|
||||
});
|
||||
valueAnimator.start();
|
||||
|
||||
// mMoveView.setScrollY(height);
|
||||
// mMoveView2.setScrollY(height2);
|
||||
}
|
||||
|
||||
public void setZoom(float zoom) {
|
||||
if (mZoomViewWidth <= 0 || mZoomViewHeight <= 0) {
|
||||
return;
|
||||
}
|
||||
ViewGroup.LayoutParams lp = mZoomView.getLayoutParams();
|
||||
lp.width = (int) (mZoomViewWidth * ((mZoomViewWidth + zoom) / mZoomViewWidth));
|
||||
lp.height = (int) (mZoomViewHeight * ((mZoomViewWidth + zoom) / mZoomViewWidth));
|
||||
mZoomView.setLayoutParams(lp);
|
||||
int margin = (lp.width - mZoomViewWidth) / 2;
|
||||
mZoomView.setTranslationX(-margin);
|
||||
|
||||
// try {
|
||||
// CollapsingToolbarLayout parent = (CollapsingToolbarLayout) (mMoveView.getParent());
|
||||
// ViewGroup.LayoutParams layoutParams = parent.getLayoutParams();
|
||||
// layoutParams.height = lp.height;
|
||||
// parent.setLayoutParams(layoutParams);
|
||||
// }catch (Exception e){
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,12 +1,9 @@
|
||||
package com.gh.common.xapk
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import com.gh.common.AppExecutor
|
||||
import com.gh.common.exposure.meta.MetaUtil
|
||||
import com.gh.common.util.*
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.download.DataChanger
|
||||
import com.lightgame.download.DownloadEntity
|
||||
@ -124,14 +121,9 @@ object XapkInstaller : IXapkUnzipListener {
|
||||
DownloadManager.getInstance(mContext).updateDownloadEntity(downloadEntity)
|
||||
}
|
||||
|
||||
MtaHelper.onEvent("解压失败"
|
||||
, "安卓版本", Build.VERSION.RELEASE
|
||||
, "IMEI", MetaUtil.getIMEI()
|
||||
, "光环版本", BuildConfig.VERSION_NAME
|
||||
, "厂商", Build.MANUFACTURER
|
||||
, "机型", Build.MODEL
|
||||
, "游戏", downloadEntity.name
|
||||
, "网络状态", DeviceUtils.getNetwork(HaloApp.getInstance().application))
|
||||
SentryHelper.onEvent("XAPK_UNZIP_ERROR",
|
||||
"gameName", downloadEntity.name,
|
||||
"errorDigest", exception.localizedMessage)
|
||||
|
||||
debugOnly {
|
||||
Utils.log("unzip", "onFailure->$exception")
|
||||
@ -142,7 +134,14 @@ object XapkInstaller : IXapkUnzipListener {
|
||||
mXapkUnzipThreadMap.remove(downloadEntity.path)
|
||||
|
||||
AppExecutor.uiExecutor.execute {
|
||||
val pkgPath = checkNotNull(downloadEntity.meta[XAPK_PACKAGE_PATH_TAG])
|
||||
val pkgPath = downloadEntity.meta[XAPK_PACKAGE_PATH_TAG]
|
||||
|
||||
if (pkgPath == null) {
|
||||
Utils.toast(mContext, "下载出错,请重新下载!")
|
||||
|
||||
return@execute
|
||||
}
|
||||
|
||||
PackageInstaller.install(mContext, pkgPath)
|
||||
|
||||
downloadEntity.meta[XAPK_UNZIP_PERCENT] = "100.0"
|
||||
|
||||
@ -1,11 +1,14 @@
|
||||
package com.gh.download
|
||||
|
||||
import android.content.pm.PackageManager
|
||||
import com.gh.common.constant.Constants
|
||||
import com.gh.common.exposure.meta.MetaUtil.getMeta
|
||||
import com.gh.common.loghub.LoghubUtils
|
||||
import com.gh.common.util.DeviceUtils
|
||||
import com.gh.common.util.*
|
||||
import com.gh.common.xapk.XapkInstaller
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.download.DataChanger
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import com.lightgame.download.DownloadStatus
|
||||
import com.lightgame.utils.Utils
|
||||
@ -49,9 +52,12 @@ object DownloadDataHelper {
|
||||
} else if (status == DownloadStatus.subscribe || status == DownloadStatus.neterror || status == DownloadStatus.timeout) {
|
||||
"暂停下载-连上WiFi自动下载"
|
||||
} else if (status == DownloadStatus.done) {
|
||||
if(downloadEntity.isSimulatorGame()){
|
||||
return "下载完成"
|
||||
}
|
||||
val pm = HaloApp.getInstance().application.applicationContext.packageManager
|
||||
val packageInfo = pm.getPackageArchiveInfo(downloadEntity.path, PackageManager.GET_ACTIVITIES)
|
||||
if (packageInfo == null) {
|
||||
val packageInfo = pm.getPackageArchiveInfo(downloadEntity.path, 0)
|
||||
if (packageInfo == null && XapkInstaller.PACKAGE_EXTENSION_NAME == downloadEntity.path.getExtension()) {
|
||||
"解析包错误"
|
||||
} else {
|
||||
"下载完成"
|
||||
@ -66,7 +72,7 @@ object DownloadDataHelper {
|
||||
"解析包错误-下载过程中"
|
||||
} else if (status == DownloadStatus.hijack || status == DownloadStatus.notfound) {
|
||||
"下载失败"
|
||||
} else if (status == DownloadStatus.redirected) {
|
||||
} else if (status == DownloadStatus.redirected) {
|
||||
"重定向至最终地址"
|
||||
} else {
|
||||
"未知状态"
|
||||
@ -272,7 +278,12 @@ object DownloadDataHelper {
|
||||
fun uploadDownloadHeartbeat(upload: Boolean) {
|
||||
val allDownloadEntity = DownloadManager.getInstance(HaloApp.getInstance().application).allDownloadEntity
|
||||
for (downloadEntity in allDownloadEntity) {
|
||||
if (downloadEntity.status == DownloadStatus.downloading) {
|
||||
|
||||
/**
|
||||
* 在后台唤醒的情况下 下载状态可能无法修正
|
||||
* see [DownloadManager.initDownloadService]
|
||||
*/
|
||||
if (downloadEntity.status == DownloadStatus.downloading && DataChanger.downloadingTasks[downloadEntity.url] != null) {
|
||||
var sheet = mDownloadHeartbeatSheet[downloadEntity.url]
|
||||
if (sheet == null) {
|
||||
sheet = JSONObject()
|
||||
|
||||
@ -18,6 +18,7 @@ import com.gh.common.exposure.ExposureEvent;
|
||||
import com.gh.common.exposure.ExposureUtils;
|
||||
import com.gh.common.exposure.meta.MetaUtil;
|
||||
import com.gh.common.history.HistoryHelper;
|
||||
import com.gh.common.simulator.SimulatorGameManager;
|
||||
import com.gh.common.util.AppDebugConfig;
|
||||
import com.gh.common.util.DataCollectionUtils;
|
||||
import com.gh.common.util.DeviceUtils;
|
||||
@ -149,6 +150,8 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
// 只有下载模块需要这坨东西,因此移动到这里初始化
|
||||
ConnectionUtils.initHttpsUrlConnection(context);
|
||||
|
||||
updateMetaMap();
|
||||
|
||||
// DownloadNotification.showDownloadingNotification(mContext);
|
||||
|
||||
lastTimeMap = new ArrayMap<>();
|
||||
@ -244,10 +247,24 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
}
|
||||
}
|
||||
|
||||
String path;
|
||||
if (SimulatorGameManager.isSimulatorGame(gameEntity)) {
|
||||
path = SimulatorGameManager.getPathByType(gameEntity.getSimulatorType()) + "/" + gameEntity.getName() + "." + apkEntity.getFormat();
|
||||
} else {
|
||||
path = PackageInstaller.getDownloadPath(gameEntity.getName(), apkEntity.getFormat());
|
||||
}
|
||||
|
||||
File file = new File(path);
|
||||
DownloadEntity entity = DownloadDao.getInstance(context).get(apkEntity.getUrl());
|
||||
//判断当前链接没有下载记录并且文件已经存在则删除这个文件
|
||||
if (entity == null && file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
|
||||
DownloadEntity downloadEntity = new DownloadEntity();
|
||||
downloadEntity.setUrl(apkEntity.getUrl());
|
||||
downloadEntity.setName(gameEntity.getName());
|
||||
downloadEntity.setPath(PackageInstaller.getDownloadPath(gameEntity.getName(), apkEntity.getFormat()));
|
||||
downloadEntity.setPath(path);
|
||||
downloadEntity.setETag(apkEntity.getEtag());
|
||||
downloadEntity.setIcon(gameEntity.getIcon());
|
||||
downloadEntity.setPlatform(apkEntity.getPlatform());
|
||||
@ -258,6 +275,10 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
downloadEntity.setVersionName(apkEntity.getVersion());
|
||||
ExtensionsKt.addMetaExtra(downloadEntity, Constants.RAW_GAME_ICON, gameEntity.getRawIcon());
|
||||
ExtensionsKt.addMetaExtra(downloadEntity, Constants.GAME_ICON_SUBSCRIPT, gameEntity.getIconSubscript());
|
||||
if (SimulatorGameManager.isSimulatorGame(gameEntity)) {
|
||||
ExtensionsKt.addMetaExtra(downloadEntity, Constants.SIMULATOR_GAME, apkEntity.getFormat());
|
||||
HaloApp.put(GameEntity.class.getSimpleName(), gameEntity);
|
||||
}
|
||||
int installed = 0;
|
||||
for (ApkEntity apk : gameEntity.getApk()) {
|
||||
if (PackagesManager.INSTANCE.isInstalled(apk.getPackageName())) {
|
||||
@ -273,8 +294,6 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
downloadEntity.setUpdate(true);
|
||||
}
|
||||
|
||||
updateMetaMap();
|
||||
|
||||
downloadEntity.setPlugin(!TextUtils.isEmpty(apkEntity.getGhVersion()));
|
||||
|
||||
ExposureUtils.DownloadType downloadType = ExposureUtils.getDownloadType(apkEntity, gameEntity.getId());
|
||||
@ -305,12 +324,24 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
// GdtHelper.PLATFORM, downloadEntity.getPlatform());
|
||||
}
|
||||
|
||||
public void removeAllTaskThatFileDoesNotExist() {
|
||||
for (DownloadEntity entity : getAllDownloadEntity()) {
|
||||
if (entity.getStatus() == DownloadStatus.done) {
|
||||
if (FileUtils.isEmptyFile(entity.getPath())) {
|
||||
cancel(entity.getUrl());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加一个下载任务
|
||||
*
|
||||
* @param downloadEntity
|
||||
*/
|
||||
public void add(DownloadEntity downloadEntity) {
|
||||
updateMetaMap();
|
||||
|
||||
if (downloadEntity != null) {
|
||||
String url = downloadEntity.getUrl();
|
||||
checkDownloadEntryRecordValidate(url);
|
||||
@ -368,6 +399,8 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
* @param downloadEntity
|
||||
*/
|
||||
public void subscribe(DownloadEntity downloadEntity) {
|
||||
updateMetaMap();
|
||||
|
||||
if (downloadEntity != null) {
|
||||
String url = downloadEntity.getUrl();
|
||||
checkDownloadEntryRecordValidate(url);
|
||||
@ -509,6 +542,17 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
return all != null ? all : new ArrayList<>();
|
||||
}
|
||||
|
||||
public List<DownloadEntity> getAllSimulatorDownloadEntity() {
|
||||
List<DownloadEntity> downloadEntityList = mDownloadDao.getAll();
|
||||
ArrayList<DownloadEntity> filteredDownloadEntityList = new ArrayList<>();
|
||||
for (DownloadEntity downloadEntity : downloadEntityList) {
|
||||
if (ExtensionsKt.isSimulatorGame(downloadEntity) && downloadEntity.getStatus() == DownloadStatus.done) {
|
||||
filteredDownloadEntityList.add(downloadEntity);
|
||||
}
|
||||
}
|
||||
return filteredDownloadEntityList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有下载列表中的任务排除静默更新
|
||||
*/
|
||||
@ -526,9 +570,18 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
if (downloadEntityList == null) return filteredDownloadEntityList;
|
||||
|
||||
for (DownloadEntity downloadEntity : downloadEntityList) {
|
||||
if (!Constants.SILENT_UPDATE.equals(ExtensionsKt.getMetaExtra(downloadEntity, Constants.EXTRA_DOWNLOAD_TYPE))) {
|
||||
filteredDownloadEntityList.add(downloadEntity);
|
||||
if (!ExtensionsKt.isSimulatorGame(downloadEntity)) {
|
||||
if (!Constants.SILENT_UPDATE.equals(ExtensionsKt.getMetaExtra(downloadEntity, Constants.EXTRA_DOWNLOAD_TYPE)) &&
|
||||
!Constants.SIMULATOR_DOWNLOAD.equals(ExtensionsKt.getMetaExtra(downloadEntity, Constants.EXTRA_DOWNLOAD_TYPE))) {
|
||||
|
||||
filteredDownloadEntityList.add(downloadEntity);
|
||||
}
|
||||
} else {
|
||||
if (downloadEntity.getStatus() != DownloadStatus.done) {
|
||||
filteredDownloadEntityList.add(downloadEntity);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return filteredDownloadEntityList;
|
||||
@ -943,7 +996,7 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
map.put(HttpDnsManager.GID, HaloApp.getInstance().getGid());
|
||||
map.put(HttpDnsManager.OAID, HaloApp.getInstance().getOAID());
|
||||
map.put(HttpDnsManager.USER_ID, UserManager.getInstance().getUserId());
|
||||
map.put(HttpDnsManager.IMEI, MetaUtil.INSTANCE.getIMEI());
|
||||
map.put(HttpDnsManager.IMEI, MetaUtil.getBase64EncodedIMEI());
|
||||
|
||||
HttpDnsManager.metaMap = map;
|
||||
}
|
||||
|
||||
203
app/src/main/java/com/gh/download/PackageObserver.kt
Normal file
203
app/src/main/java/com/gh/download/PackageObserver.kt
Normal file
@ -0,0 +1,203 @@
|
||||
package com.gh.download
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.NotificationManager
|
||||
import android.content.Context
|
||||
import android.preference.PreferenceManager
|
||||
import android.text.TextUtils
|
||||
import com.gh.common.constant.Constants
|
||||
import com.gh.common.loghub.LoghubUtils
|
||||
import com.gh.common.runOnIoThread
|
||||
import com.gh.common.util.*
|
||||
import com.gh.gamecenter.entity.GameDigestEntity
|
||||
import com.gh.gamecenter.eventbus.EBPackage
|
||||
import com.gh.gamecenter.manager.UserManager
|
||||
import com.gh.gamecenter.packagehelper.PackageRepository
|
||||
import com.gh.gamecenter.packagehelper.PackageViewModel
|
||||
import com.gh.gamecenter.retrofit.EmptyResponse
|
||||
import com.gh.gamecenter.retrofit.Response
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.halo.assistant.fragment.SettingsFragment
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import com.lightgame.utils.Utils
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.RequestBody
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
import java.util.*
|
||||
|
||||
object PackageObserver {
|
||||
|
||||
private val mPackageViewModel: PackageViewModel
|
||||
by lazy { PackageViewModel(HaloApp.getInstance().application, PackageRepository) }
|
||||
|
||||
@JvmStatic
|
||||
fun onPackageChanged(busFour: EBPackage) {
|
||||
val application = HaloApp.getInstance().application
|
||||
val packageName = busFour.packageName
|
||||
val versionName = busFour.versionName
|
||||
var gameId = ""
|
||||
var mDownloadEntity: DownloadEntity? = null
|
||||
val sp = PreferenceManager.getDefaultSharedPreferences(application)
|
||||
|
||||
for (downloadEntity in DownloadManager.getInstance(application).allDownloadEntity) {
|
||||
if (packageName == downloadEntity.packageName) {
|
||||
mDownloadEntity = downloadEntity
|
||||
gameId = mDownloadEntity.getRealGameId(Constants.GAME_ID_DIVIDER)
|
||||
if (TextUtils.isEmpty(busFour.versionName)) {
|
||||
// 没有版本号的事件直接选用第一个找到的 downloadEntity
|
||||
break
|
||||
} else {
|
||||
// 有版本号的事件直接尽量找到版本一致的 downloadEntity
|
||||
if (versionName == downloadEntity.versionName) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ("安装" == busFour.type) {
|
||||
mPackageViewModel.addInstalledGame(packageName)
|
||||
|
||||
// TODO 这个取消通知栏看起来没什么用,没在其它地方看到它,暂且保留一个版本
|
||||
// 删除下载完成 弹窗
|
||||
val nManager = application.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
nManager.cancel(packageName.hashCode())
|
||||
|
||||
if (mDownloadEntity != null) {
|
||||
if (mDownloadEntity.isPluggable) {
|
||||
val kv6: MutableMap<String, Any> = HashMap()
|
||||
kv6["安装或卸载"] = "安装完成"
|
||||
DataUtils.onEvent(application, "插件化", mDownloadEntity.name, kv6)
|
||||
|
||||
// DataUtils.onMtaEvent(this,
|
||||
// "插件化_新",
|
||||
// "位置", mDownloadEntity.getEntrance(),
|
||||
// "游戏", mDownloadEntity.getName() + "-" + mDownloadEntity.getPlatform(),
|
||||
// "操作", "安装完成",
|
||||
// "网络状态", DeviceUtils.getNetwork(HaloApp.getInstance().getApplication()));
|
||||
}
|
||||
|
||||
// 没有光环 ID 的都记录一下游戏 ID,供'我的游戏'区分同包名不同插件用
|
||||
val gh_id = PackageUtils.getMetaData(application, mDownloadEntity.packageName, "gh_id")
|
||||
if (gh_id == null) {
|
||||
ThirdPartyPackageHelper.saveGameId(mDownloadEntity.packageName, mDownloadEntity.gameId)
|
||||
}
|
||||
DownloadManager.getInstance(application).cancel(
|
||||
mDownloadEntity.url, false, true) // 默认不删除安装包 mSp.getBoolean("autodelete", true)
|
||||
}
|
||||
if (sp.getBoolean(SettingsFragment.CONCERN_GAME_SP_KEY, true)) { //设置页面控制是否安装后自动关注
|
||||
// 安装后关注游戏
|
||||
val finalDownloadEntity = mDownloadEntity
|
||||
RetrofitManager.getInstance(application).sensitiveApi
|
||||
.getGameDigestByPackageName(UrlFilterUtils.getFilterQuery("package", packageName))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<List<GameDigestEntity?>?>() {
|
||||
override fun onResponse(response: List<GameDigestEntity?>?) {
|
||||
for (gameDigestEntity in response!!) {
|
||||
if (!TextUtils.isEmpty(gameDigestEntity?.id)) { // 关注游戏
|
||||
if (finalDownloadEntity != null && gameDigestEntity?.id == finalDownloadEntity.getRealGameId(Constants.GAME_ID_DIVIDER)) {
|
||||
ConcernUtils.postConcernGameId(application, gameDigestEntity?.id ?: "", null, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
runOnIoThread { postNewlyInstalledApp(gameId, packageName) }
|
||||
}
|
||||
|
||||
if ("卸载" == busFour.type) {
|
||||
mPackageViewModel.addUninstalledGame(packageName)
|
||||
if (mDownloadEntity != null && mDownloadEntity.isPluggable) {
|
||||
val kv6: MutableMap<String, Any> = HashMap()
|
||||
kv6["安装或卸载"] = "卸载完成"
|
||||
DataUtils.onEvent(application, "插件化", mDownloadEntity.name, kv6)
|
||||
|
||||
// DataUtils.onMtaEvent(this,
|
||||
// "插件化_新",
|
||||
// "位置", mDownloadEntity.getEntrance(),
|
||||
// "游戏", mDownloadEntity.getName() + "-" + mDownloadEntity.getPlatform(),
|
||||
// "操作", "卸载完成",
|
||||
// "网络状态", DeviceUtils.getNetwork(HaloApp.getInstance().getApplication()));
|
||||
PackageInstaller.install(application, mDownloadEntity)
|
||||
}
|
||||
|
||||
// 更新已安装游戏
|
||||
deleteInstalledPackage(packageName)
|
||||
}
|
||||
DataCollectionUtils.uploadInorunstall(application, busFour.type, busFour.packageName)
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private fun postNewlyInstalledApp(gameId: String, packageName: String) {
|
||||
|
||||
// 发送应用变更前都检查一下是否需要把所有应用都上传
|
||||
PackageRepository.checkAndUploadAppList()
|
||||
|
||||
// 更新已安装游戏
|
||||
val packageObject = PackageUtils.getAppBasicInfoByPackageName(packageName)
|
||||
val dataObject = JSONObject()
|
||||
val wrapperObject = JSONObject()
|
||||
try {
|
||||
dataObject.put("type", "POST")
|
||||
dataObject.put("device_id", HaloApp.getInstance().gid)
|
||||
dataObject.put("app", packageObject)
|
||||
dataObject.put("time", Utils.getTime(HaloApp.getInstance().application))
|
||||
wrapperObject.put("content", dataObject.toString())
|
||||
} catch (e: JSONException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
LoghubUtils.log(wrapperObject, "halo-api-device-installed", true)
|
||||
val requestBody = RequestBody.create(MediaType.parse("application/json"),
|
||||
packageObject.toString())
|
||||
// 更新已安装游戏
|
||||
RetrofitManager.getInstance(HaloApp.getInstance().application).api
|
||||
.postNewlyInstalledApp(HaloApp.getInstance().gid, requestBody)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(EmptyResponse())
|
||||
if (!TextUtils.isEmpty(gameId) && UserManager.getInstance().isLoggedIn) {
|
||||
val jsonObject = JSONObject()
|
||||
try {
|
||||
jsonObject.put("game_id", gameId)
|
||||
jsonObject.put("package", packageName)
|
||||
val rBody = RequestBody.create(MediaType.parse("application/json"), jsonObject.toString())
|
||||
RetrofitManager.getInstance(HaloApp.getInstance().application).api
|
||||
.postPlayedGame(UserManager.getInstance().userId, rBody)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(EmptyResponse())
|
||||
} catch (e: JSONException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private fun deleteInstalledPackage(packageName: String) {
|
||||
|
||||
// 发送应用变更前都检查一下是否需要把所有应用都上传
|
||||
PackageRepository.checkAndUploadAppList()
|
||||
|
||||
// 删除已安装游戏
|
||||
val dataObject = JSONObject()
|
||||
val wrapperObject = JSONObject()
|
||||
try {
|
||||
dataObject.put("type", "DELETE")
|
||||
dataObject.put("device_id", HaloApp.getInstance().gid)
|
||||
dataObject.put("package", packageName)
|
||||
dataObject.put("time", Utils.getTime(HaloApp.getInstance().application))
|
||||
wrapperObject.put("content", dataObject.toString())
|
||||
} catch (e: JSONException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
LoghubUtils.log(wrapperObject, "halo-api-device-installed", true)
|
||||
|
||||
}
|
||||
}
|
||||
@ -140,7 +140,7 @@ class DownloadDialog : BaseDialogFragment(), View.OnTouchListener {
|
||||
}
|
||||
})
|
||||
mViewModel.dismissLiveData.observe(this, Observer {
|
||||
dismiss()
|
||||
dismissAllowingStateLoss()
|
||||
})
|
||||
|
||||
mElapsedHelper = TimeElapsedHelper()
|
||||
@ -173,7 +173,7 @@ class DownloadDialog : BaseDialogFragment(), View.OnTouchListener {
|
||||
postBrowseMta()
|
||||
mViewModel.collectionLiveData.postValue(null)
|
||||
} else {
|
||||
dismiss()
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
mGestureDetector = GestureDetector(requireContext(), SingleTapConfirm())
|
||||
@ -332,7 +332,7 @@ class DownloadDialog : BaseDialogFragment(), View.OnTouchListener {
|
||||
MotionEvent.ACTION_UP,
|
||||
MotionEvent.ACTION_OUTSIDE -> {
|
||||
if (mBinding.root.y >= mBinding.root.height / 2) {
|
||||
dismiss()
|
||||
dismissAllowingStateLoss()
|
||||
} else {
|
||||
resetDialogPosition(300)
|
||||
}
|
||||
|
||||
@ -2,11 +2,13 @@ package com.gh.download.dialog
|
||||
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.gh.base.BaseActivity
|
||||
import com.gh.base.BaseRecyclerViewHolder
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.common.dialog.CertificationDialog
|
||||
import com.gh.common.dialog.DeviceRemindDialog
|
||||
import com.gh.common.dialog.PackageCheckDialogFragment
|
||||
import com.gh.common.exposure.ExposureEvent
|
||||
import com.gh.common.util.*
|
||||
import com.gh.common.util.DirectUtils.directToLinkPage
|
||||
@ -24,6 +26,7 @@ import com.lightgame.download.DownloadStatus
|
||||
import com.lightgame.download.FileUtils
|
||||
import com.lightgame.utils.AppManager
|
||||
import com.lightgame.utils.Utils
|
||||
import io.sentry.core.protocol.App
|
||||
|
||||
class DownloadDialogItemViewHolder(val binding: DownloadDialogItemBinding) : BaseRecyclerViewHolder<Any>(binding.root) {
|
||||
|
||||
@ -278,19 +281,21 @@ class DownloadDialogItemViewHolder(val binding: DownloadDialogItemBinding) : Bas
|
||||
if (msg.isNullOrEmpty()) {
|
||||
DownloadDialogHelper.findAvailableDialogAndShow(context, gameEntity, apkEntity, object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
CertificationDialog.showCertificationDialog(context, gameEntity, DialogUtils.ConfirmListener {
|
||||
DialogUtils.checkDownload(context, apkEntity.size) { isSubscribe ->
|
||||
DownloadManager.createDownload(
|
||||
context,
|
||||
apkEntity,
|
||||
gameEntity,
|
||||
downloadMethod,
|
||||
entrance,
|
||||
location,
|
||||
isSubscribe, traceEvent)
|
||||
PackageCheckDialogFragment.show(context as AppCompatActivity, gameEntity.packageDialog, DialogUtils.ConfirmListener {
|
||||
CertificationDialog.showCertificationDialog(context, gameEntity, DialogUtils.ConfirmListener {
|
||||
DialogUtils.checkDownload(context, apkEntity.size) { isSubscribe ->
|
||||
DownloadManager.createDownload(
|
||||
context,
|
||||
apkEntity,
|
||||
gameEntity,
|
||||
downloadMethod,
|
||||
entrance,
|
||||
location,
|
||||
isSubscribe, traceEvent)
|
||||
|
||||
DeviceRemindDialog.showDeviceRemindDialog(context, gameEntity)
|
||||
}
|
||||
DeviceRemindDialog.showDeviceRemindDialog(context, gameEntity)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
@ -28,7 +28,7 @@ class DownloadLinkDialog : BaseDialogFragment() {
|
||||
mLinkEntity.content, "text/html", "utf-8", null)
|
||||
|
||||
binding.confirm.setOnClickListener {
|
||||
dismiss()
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
return binding.root
|
||||
}
|
||||
|
||||
@ -19,6 +19,7 @@ import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RestrictTo;
|
||||
import androidx.lifecycle.ViewModelProviders;
|
||||
|
||||
import com.gh.base.AppUncaughtHandler;
|
||||
@ -30,9 +31,9 @@ import com.gh.common.avoidcallback.AvoidOnResultManager;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.constant.Constants;
|
||||
import com.gh.common.exposure.meta.MetaUtil;
|
||||
import com.gh.common.im.ImManager;
|
||||
import com.gh.common.loghub.LoghubUtils;
|
||||
import com.gh.common.repository.ReservationRepository;
|
||||
import com.gh.common.simulator.SimulatorGameManager;
|
||||
import com.gh.common.util.ActivationHelper;
|
||||
import com.gh.common.util.ClassUtils;
|
||||
import com.gh.common.util.ConcernUtils;
|
||||
@ -44,6 +45,8 @@ import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.DirectUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.common.util.ExtensionsKt;
|
||||
import com.gh.common.util.GsonUtils;
|
||||
import com.gh.common.util.HomePluggableHelper;
|
||||
import com.gh.common.util.LogUtils;
|
||||
import com.gh.common.util.LunchType;
|
||||
@ -55,11 +58,13 @@ import com.gh.common.util.PlatformUtils;
|
||||
import com.gh.common.util.SPUtils;
|
||||
import com.gh.common.util.ShareUtils;
|
||||
import com.gh.common.util.ThirdPartyPackageHelper;
|
||||
import com.gh.common.util.ToastUtils;
|
||||
import com.gh.common.util.UrlFilterUtils;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.gamecenter.download.DownloadFragment;
|
||||
import com.gh.gamecenter.entity.CommunityEntity;
|
||||
import com.gh.gamecenter.entity.GameDigestEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.entity.InnerMetaInfoEntity;
|
||||
import com.gh.gamecenter.entity.NotificationUgc;
|
||||
import com.gh.gamecenter.eventbus.EBNetworkState;
|
||||
@ -67,6 +72,7 @@ import com.gh.gamecenter.eventbus.EBPackage;
|
||||
import com.gh.gamecenter.eventbus.EBReuse;
|
||||
import com.gh.gamecenter.eventbus.EBSkip;
|
||||
import com.gh.gamecenter.fragment.MainWrapperFragment;
|
||||
import com.gh.gamecenter.gamedetail.GameDetailFragment;
|
||||
import com.gh.gamecenter.manager.DataCollectionManager;
|
||||
import com.gh.gamecenter.manager.UpdateManager;
|
||||
import com.gh.gamecenter.manager.UserManager;
|
||||
@ -74,12 +80,15 @@ import com.gh.gamecenter.normal.NormalFragment;
|
||||
import com.gh.gamecenter.packagehelper.PackageRepository;
|
||||
import com.gh.gamecenter.packagehelper.PackageViewModel;
|
||||
import com.gh.gamecenter.qa.CommunityFragment;
|
||||
import com.gh.gamecenter.retrofit.BiResponse;
|
||||
import com.gh.gamecenter.retrofit.EmptyResponse;
|
||||
import com.gh.gamecenter.retrofit.Response;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
import com.gh.gamecenter.suggest.SuggestSelectFragment;
|
||||
import com.gh.gamecenter.suggest.SuggestType;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.halo.assistant.HaloApp;
|
||||
import com.halo.assistant.fragment.SettingsFragment;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
@ -91,6 +100,7 @@ import com.lightgame.utils.Utils;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
@ -115,13 +125,16 @@ import okhttp3.RequestBody;
|
||||
import okhttp3.ResponseBody;
|
||||
|
||||
import static com.gh.common.util.EntranceUtils.ENTRANCE_BROWSER;
|
||||
import static com.gh.common.util.EntranceUtils.HOST_LAUNCH_SIMULATOR_GAME;
|
||||
import static com.gh.common.util.EntranceUtils.HOST_QQ;
|
||||
import static com.gh.common.util.EntranceUtils.HOST_QQ_GROUP;
|
||||
import static com.gh.common.util.EntranceUtils.HOST_WEB;
|
||||
import static com.gh.common.util.EntranceUtils.KEY_DATA;
|
||||
import static com.gh.common.util.EntranceUtils.KEY_MARKET_DETAILS;
|
||||
import static com.gh.common.util.EntranceUtils.KEY_NEXT_TO;
|
||||
import static com.gh.common.util.EntranceUtils.KEY_TO;
|
||||
import static com.gh.common.util.EntranceUtils.KEY_TYPE;
|
||||
import static com.gh.common.util.ExtensionsKt.singleToMain;
|
||||
import static com.gh.gamecenter.fragment.MainWrapperFragment.INDEX_PERSONAL;
|
||||
import static com.gh.gamecenter.personal.PersonalFragment.LOGIN_TAG;
|
||||
import static com.gh.gamecenter.personal.PersonalFragment.LOGOUT_TAG;
|
||||
@ -170,6 +183,8 @@ public class MainActivity extends BaseActivity {
|
||||
if (!this.isFinishing()) {
|
||||
LogUtils.uploadDevice(lunchType);
|
||||
ActivationHelper.sendActivationInfo();
|
||||
// 第一次打开App删除模拟器游戏记录
|
||||
SimulatorGameManager.deleteAllSimulatorGame();
|
||||
}
|
||||
}, 2000L);
|
||||
getPluginUpdate();
|
||||
@ -210,10 +225,10 @@ public class MainActivity extends BaseActivity {
|
||||
checkNotificationPermission();
|
||||
|
||||
// 初始化 IM,只有在 APP 刚启动时执行
|
||||
if (HaloApp.get(SHOULD_INIT_IM, false) != null) {
|
||||
HaloApp.put(SHOULD_INIT_IM, false);
|
||||
handler.postDelayed(ImManager::attachIm, 1000);
|
||||
}
|
||||
// if (HaloApp.get(SHOULD_INIT_IM, false) != null) {
|
||||
// HaloApp.put(SHOULD_INIT_IM, false);
|
||||
// handler.postDelayed(ImManager::attachIm, 1000);
|
||||
// }
|
||||
|
||||
ReservationRepository.refreshReservations();
|
||||
|
||||
@ -258,7 +273,6 @@ public class MainActivity extends BaseActivity {
|
||||
HomePluggableHelper.activationFilterData();
|
||||
});
|
||||
|
||||
|
||||
//启动app删除视频缓存文件
|
||||
AppExecutor.getIoExecutor().execute(() -> {
|
||||
try {
|
||||
@ -378,6 +392,23 @@ public class MainActivity extends BaseActivity {
|
||||
DirectUtils.directToExternalBrowser(this, url);
|
||||
}
|
||||
break;
|
||||
case HOST_LAUNCH_SIMULATOR_GAME:
|
||||
String json = getIntent().getStringExtra(EntranceUtils.KEY_GAME);
|
||||
GameEntity gameEntity = GsonUtils.getGson().fromJson(json, new TypeToken<GameEntity>(){}.getType());
|
||||
DownloadEntity downloadEntity = SimulatorGameManager.findDownloadEntityByUrl(gameEntity.getApk().get(0).getUrl());
|
||||
if (downloadEntity != null) {
|
||||
File file = new File(downloadEntity.getPath());
|
||||
if (!file.exists()) {
|
||||
ToastUtils.INSTANCE.showToast("文件已被删除,无法启动");
|
||||
return;
|
||||
}
|
||||
|
||||
SimulatorGameManager.launchSimulatorGame(downloadEntity, gameEntity);
|
||||
}
|
||||
break;
|
||||
case KEY_MARKET_DETAILS:
|
||||
redirectGameDetail(bundle.getString(KEY_DATA));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -391,6 +422,28 @@ public class MainActivity extends BaseActivity {
|
||||
}, 500);
|
||||
}
|
||||
|
||||
/**
|
||||
* 应用跳转
|
||||
* @param packageName
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
private void redirectGameDetail(String packageName) {
|
||||
RetrofitManager.getInstance(this).getApi().redirectGameDetail(packageName)
|
||||
.compose(singleToMain())
|
||||
.subscribe(new BiResponse<JsonObject>() {
|
||||
@Override
|
||||
public void onSuccess(JsonObject data) {
|
||||
String gameId = data.get("game_id").getAsString();
|
||||
DirectUtils.directToGameDetail(MainActivity.this, gameId, GameDetailFragment.INDEX_DESC, "应用跳转");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NotNull Exception exception) {
|
||||
super.onFailure(exception);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void checkNotificationPermission() {
|
||||
// 仅登录后再启动光环时请求一次权限
|
||||
if (UserManager.getInstance().isLoggedIn()) {
|
||||
@ -422,6 +475,7 @@ public class MainActivity extends BaseActivity {
|
||||
|| PackageUtils.isSignedByGh(getApplicationContext(), entity.getPackageName()))) {
|
||||
continue;
|
||||
}
|
||||
if (ExtensionsKt.isSimulatorGame(entity)) continue;
|
||||
if (downloadEntity == null) {
|
||||
downloadEntity = entity;
|
||||
} else if (entity.getEnd() > downloadEntity.getEnd()) {
|
||||
@ -691,184 +745,6 @@ public class MainActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEventMainThread(EBPackage busFour) {
|
||||
final String packageName = busFour.getPackageName();
|
||||
final String versionName = busFour.getVersionName();
|
||||
String gameId = "";
|
||||
|
||||
DownloadEntity mDownloadEntity = null;
|
||||
for (DownloadEntity downloadEntity : DownloadManager.getInstance(getApplicationContext()).getAllDownloadEntity()) {
|
||||
if (packageName.equals(downloadEntity.getPackageName())) {
|
||||
mDownloadEntity = downloadEntity;
|
||||
gameId = mDownloadEntity.getRealGameId(Constants.GAME_ID_DIVIDER);
|
||||
if (TextUtils.isEmpty(busFour.getVersionName())) {
|
||||
// 没有版本号的事件直接选用第一个找到的 downloadEntity
|
||||
break;
|
||||
} else {
|
||||
// 有版本号的事件直接尽量找到版本一致的 downloadEntity
|
||||
if (versionName.equals(downloadEntity.getVersionName())) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ("安装".equals(busFour.getType())) {
|
||||
mPackageViewModel.addInstalledGame(packageName);
|
||||
|
||||
// 删除下载完成 弹窗
|
||||
NotificationManager nManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nManager.cancel(packageName.hashCode());
|
||||
|
||||
if (mDownloadEntity != null) {
|
||||
if (mDownloadEntity.isPluggable()) {
|
||||
Map<String, Object> kv6 = new HashMap<>();
|
||||
kv6.put("安装或卸载", "安装完成");
|
||||
DataUtils.onEvent(this, "插件化", mDownloadEntity.getName(), kv6);
|
||||
|
||||
// DataUtils.onMtaEvent(this,
|
||||
// "插件化_新",
|
||||
// "位置", mDownloadEntity.getEntrance(),
|
||||
// "游戏", mDownloadEntity.getName() + "-" + mDownloadEntity.getPlatform(),
|
||||
// "操作", "安装完成",
|
||||
// "网络状态", DeviceUtils.getNetwork(HaloApp.getInstance().getApplication()));
|
||||
}
|
||||
|
||||
// 没有光环 ID 的都记录一下游戏 ID,供'我的游戏'区分同包名不同插件用
|
||||
Object gh_id = PackageUtils.getMetaData(this, mDownloadEntity.getPackageName(), "gh_id");
|
||||
if (gh_id == null) {
|
||||
ThirdPartyPackageHelper.saveGameId(mDownloadEntity.getPackageName(), mDownloadEntity.getGameId());
|
||||
}
|
||||
DownloadManager.getInstance(getApplicationContext()).cancel(
|
||||
mDownloadEntity.getUrl(), false, true); // 默认不删除安装包 mSp.getBoolean("autodelete", true)
|
||||
}
|
||||
|
||||
|
||||
if (mSp.getBoolean(SettingsFragment.CONCERN_GAME_SP_KEY, true)) { //设置页面控制是否安装后自动关注
|
||||
// 安装后关注游戏
|
||||
DownloadEntity finalDownloadEntity = mDownloadEntity;
|
||||
RetrofitManager.getInstance(this).getSensitiveApi().getGameDigestByPackageName(UrlFilterUtils.getFilterQuery("package", packageName))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Response<List<GameDigestEntity>>() {
|
||||
@Override
|
||||
public void onResponse(List<GameDigestEntity> response) {
|
||||
for (GameDigestEntity gameDigestEntity : response) {
|
||||
if (!TextUtils.isEmpty(gameDigestEntity.getId())) { // 关注游戏
|
||||
if (finalDownloadEntity != null && gameDigestEntity.getId().equals(finalDownloadEntity.getRealGameId(Constants.GAME_ID_DIVIDER))) {
|
||||
ConcernUtils.INSTANCE.postConcernGameId(MainActivity.this, gameDigestEntity.getId(), null, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
postNewlyInstalledApp(gameId, packageName);
|
||||
}
|
||||
if ("卸载".equals(busFour.getType())) {
|
||||
mPackageViewModel.addUninstalledGame(packageName);
|
||||
|
||||
if (mDownloadEntity != null && mDownloadEntity.isPluggable()) {
|
||||
Map<String, Object> kv6 = new HashMap<>();
|
||||
kv6.put("安装或卸载", "卸载完成");
|
||||
DataUtils.onEvent(this, "插件化", mDownloadEntity.getName(), kv6);
|
||||
|
||||
// DataUtils.onMtaEvent(this,
|
||||
// "插件化_新",
|
||||
// "位置", mDownloadEntity.getEntrance(),
|
||||
// "游戏", mDownloadEntity.getName() + "-" + mDownloadEntity.getPlatform(),
|
||||
// "操作", "卸载完成",
|
||||
// "网络状态", DeviceUtils.getNetwork(HaloApp.getInstance().getApplication()));
|
||||
|
||||
PackageInstaller.install(this, mDownloadEntity);
|
||||
}
|
||||
|
||||
// 更新已安装游戏
|
||||
deleteInstalledPackage(packageName);
|
||||
}
|
||||
|
||||
DataCollectionUtils.uploadInorunstall(this, busFour.getType(), busFour.getPackageName());
|
||||
}
|
||||
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
@SuppressLint("CheckResult")
|
||||
private void postNewlyInstalledApp(String gameId, String packageName) {
|
||||
|
||||
// 发送应用变更前都检查一下是否需要把所有应用都上传
|
||||
PackageRepository.checkAndUploadAppList();
|
||||
|
||||
// 更新已安装游戏
|
||||
JSONObject packageObject = PackageUtils.getAppBasicInfoByPackageName(packageName);
|
||||
JSONObject dataObject = new JSONObject();
|
||||
JSONObject wrapperObject = new JSONObject();
|
||||
try {
|
||||
dataObject.put("type", "POST");
|
||||
dataObject.put("device_id", HaloApp.getInstance().getGid());
|
||||
dataObject.put("app", packageObject);
|
||||
dataObject.put("time", Utils.getTime(getApplicationContext()));
|
||||
wrapperObject.put("content", dataObject.toString());
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
LoghubUtils.log(wrapperObject, "halo-api-device-installed", true);
|
||||
|
||||
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"),
|
||||
packageObject.toString());
|
||||
// 更新已安装游戏
|
||||
RetrofitManager.getInstance(MainActivity.this).getApi()
|
||||
.postNewlyInstalledApp(HaloApp.getInstance().getGid(), requestBody)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(new EmptyResponse<>());
|
||||
|
||||
if (!TextUtils.isEmpty(gameId) && UserManager.getInstance().isLoggedIn()) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
try {
|
||||
jsonObject.put("game_id", gameId);
|
||||
jsonObject.put("package", packageName);
|
||||
RequestBody rBody = RequestBody.create(MediaType.parse("application/json"), jsonObject.toString());
|
||||
|
||||
RetrofitManager.getInstance(MainActivity.this).getApi()
|
||||
.postPlayedGame(UserManager.getInstance().getUserId(), rBody)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(new EmptyResponse<>());
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void deleteInstalledPackage(String packageName) {
|
||||
|
||||
// 发送应用变更前都检查一下是否需要把所有应用都上传
|
||||
PackageRepository.checkAndUploadAppList();
|
||||
|
||||
// 删除已安装游戏
|
||||
JSONObject dataObject = new JSONObject();
|
||||
JSONObject wrapperObject = new JSONObject();
|
||||
try {
|
||||
dataObject.put("type", "DELETE");
|
||||
dataObject.put("device_id", HaloApp.getInstance().getGid());
|
||||
dataObject.put("package", packageName);
|
||||
dataObject.put("time", Utils.getTime(getApplicationContext()));
|
||||
wrapperObject.put("content", dataObject.toString());
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
LoghubUtils.log(wrapperObject, "halo-api-device-installed", true);
|
||||
|
||||
// 删除已安装游戏
|
||||
RetrofitManager.getInstance(MainActivity.this).getApi()
|
||||
.deleteInstalledApp(HaloApp.getInstance().getGid(), packageName)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(new EmptyResponse<>());
|
||||
}
|
||||
|
||||
// 接收登录和登出更新事件统计的 Meta
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEventMainThread(EBReuse reuse) {
|
||||
|
||||
@ -18,10 +18,7 @@ import android.webkit.WebViewClient
|
||||
import android.widget.ScrollView
|
||||
import android.widget.TextView
|
||||
import com.gh.base.ToolBarActivity
|
||||
import com.gh.common.util.CommentUtils
|
||||
import com.gh.common.util.DeviceUtils
|
||||
import com.gh.common.util.DialogUtils
|
||||
import com.gh.common.util.tryCatchInRelease
|
||||
import com.gh.common.util.*
|
||||
import com.gh.gamecenter.retrofit.Response
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.ObservableOnSubscribe
|
||||
@ -44,6 +41,7 @@ class NetworkDiagnosisActivity : ToolBarActivity() {
|
||||
private val mProgress by bindView<TextView>(R.id.network_diagnosis_progress)
|
||||
private val mWebView by bindView<WebView>(R.id.network_diagnosis_web)
|
||||
private val mScrollView by bindView<ScrollView>(R.id.network_diagnosis_scrollview)
|
||||
private val mSuggestBtn by bindView<TextView>(R.id.network_diagnosis_suggest)
|
||||
|
||||
private val builder = SpannableStringBuilder()
|
||||
|
||||
@ -163,9 +161,9 @@ class NetworkDiagnosisActivity : ToolBarActivity() {
|
||||
|
||||
fun setResultProgress(progress: Int) {
|
||||
mProgress.text = "正在进行网络诊断 $progress%"
|
||||
mBaseHandler.post(Runnable {
|
||||
mBaseHandler.post {
|
||||
mScrollView.fullScroll(ScrollView.FOCUS_DOWN)
|
||||
})
|
||||
}
|
||||
|
||||
mProgressData = progress
|
||||
}
|
||||
@ -208,6 +206,12 @@ class NetworkDiagnosisActivity : ToolBarActivity() {
|
||||
builder.append("\n")
|
||||
builder.append("\n")
|
||||
builder.append(mSuccessHint)
|
||||
mSuggestBtn.run {
|
||||
visibility = View.VISIBLE
|
||||
setOnClickListener {
|
||||
startActivity(SuggestionActivity.getIntentFromNetworkDiagnosis(this@NetworkDiagnosisActivity, builder.toString().replace(mSuccessHint, "")))
|
||||
}
|
||||
}
|
||||
|
||||
builder.setSpan(object : ClickableSpan() {
|
||||
override fun updateDrawState(ds: TextPaint) {
|
||||
@ -222,7 +226,7 @@ class NetworkDiagnosisActivity : ToolBarActivity() {
|
||||
}, builder.length - mSuccessHint.length, builder.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
|
||||
mResult.text = builder
|
||||
mResult.setMovementMethod(LinkMovementMethod.getInstance())
|
||||
mResult.movementMethod = LinkMovementMethod.getInstance()
|
||||
setResultProgress(100)
|
||||
}
|
||||
}, 1000)
|
||||
@ -237,14 +241,14 @@ class NetworkDiagnosisActivity : ToolBarActivity() {
|
||||
+ ".jpg"
|
||||
)
|
||||
if (!file.exists()) {
|
||||
file.getParentFile().mkdirs()
|
||||
file.parentFile.mkdirs()
|
||||
file.createNewFile()
|
||||
}
|
||||
val fos = FileOutputStream(file)
|
||||
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, fos)
|
||||
fos.flush()
|
||||
fos.close()
|
||||
return file.getAbsolutePath();
|
||||
return file.absolutePath;
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
@ -252,14 +256,14 @@ class NetworkDiagnosisActivity : ToolBarActivity() {
|
||||
}
|
||||
|
||||
override fun handleBackPressed(): Boolean {
|
||||
if (mProgressData < 100) {
|
||||
return if (mProgressData < 100) {
|
||||
DialogUtils.showAlertDialog(this, "确认退出", "网络诊断还未完成,退出会终止所有诊断进程,确定退出吗?"
|
||||
, "确定", "取消", DialogUtils.ConfirmListener {
|
||||
finish()
|
||||
}, null)
|
||||
return true
|
||||
true
|
||||
} else {
|
||||
return false
|
||||
false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -7,13 +7,11 @@ import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.EditText
|
||||
import androidx.core.widget.doAfterTextChanged
|
||||
import androidx.core.widget.doOnTextChanged
|
||||
import com.gh.base.BaseActivity
|
||||
import com.gh.common.util.DataCollectionUtils
|
||||
import com.gh.common.util.EntranceUtils
|
||||
import com.gh.common.util.TextHelper
|
||||
import com.gh.common.util.goneIf
|
||||
import com.gh.common.util.*
|
||||
import com.gh.gamecenter.DisplayType.*
|
||||
import com.gh.gamecenter.db.SearchHistoryDao
|
||||
import com.gh.gamecenter.eventbus.EBSearch
|
||||
@ -24,12 +22,15 @@ import com.lightgame.utils.Util_System_Keyboard
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
import kotlinx.android.synthetic.main.toolbar_search.*
|
||||
import kotterknife.bindView
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
open class SearchActivity : BaseActivity() {
|
||||
|
||||
private val searchEt by bindView<EditText>(R.id.searchEt)
|
||||
|
||||
private var mDao: SearchHistoryDao? = null
|
||||
|
||||
protected var mSearchKey: String? = null
|
||||
@ -56,6 +57,7 @@ open class SearchActivity : BaseActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
val hint = intent.getStringExtra(EntranceUtils.KEY_HINT)
|
||||
val searchImmediately = intent.getBooleanExtra(KEY_SEARCH_IMMEDIATELY, false)
|
||||
var ignoreTextChanges = savedInstanceState != null
|
||||
|
||||
mDao = SearchHistoryDao(this)
|
||||
mPublishSubject = PublishSubject.create()
|
||||
@ -65,24 +67,30 @@ open class SearchActivity : BaseActivity() {
|
||||
.distinctUntilChanged()
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
if (searchEt.text.isNotEmpty()) {
|
||||
if (searchEt.text.isNotEmpty()
|
||||
&& searchEt.text != searchEt.hint
|
||||
&& !ignoreTextChanges) {
|
||||
search(SearchType.AUTO, it)
|
||||
}
|
||||
|
||||
ignoreTextChanges = false
|
||||
}
|
||||
|
||||
initSearchBar()
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
mDisplayType = DisplayType.fromInt(savedInstanceState.getInt(KEY_DISPLAY_TYPE, 0))
|
||||
mSearchKey = savedInstanceState.getString(EntranceUtils.KEY_SEARCHKEY, null)
|
||||
mSearchType = SearchType.fromString(savedInstanceState.getString(KEY_SEARCH_TYPE, null))
|
||||
if (mDisplayType != DisplayType.DEFAULT && !TextUtils.isEmpty(mSearchKey)) {
|
||||
search(mSearchType, mSearchKey)
|
||||
}
|
||||
} else if (!TextUtils.isEmpty(hint)) {
|
||||
// 子 Fragment 自己恢复状态
|
||||
// if (savedInstanceState != null) {
|
||||
// mDisplayType = DisplayType.fromInt(savedInstanceState.getInt(KEY_DISPLAY_TYPE, 0))
|
||||
// mSearchKey = savedInstanceState.getString(EntranceUtils.KEY_SEARCHKEY, null)
|
||||
// mSearchType = SearchType.fromString(savedInstanceState.getString(KEY_SEARCH_TYPE, null))
|
||||
// if (mDisplayType != DisplayType.DEFAULT && !TextUtils.isEmpty(mSearchKey)) {
|
||||
// search(mSearchType, mSearchKey)
|
||||
// }
|
||||
// } else
|
||||
if (!TextUtils.isEmpty(hint)) {
|
||||
searchEt.hint = hint
|
||||
if (searchImmediately) {
|
||||
mDisplayType = DisplayType.GAME_DETAIL
|
||||
mDisplayType = GAME_DETAIL
|
||||
mDao?.add(hint)
|
||||
search(SearchType.DEFAULT, hint)
|
||||
}
|
||||
@ -90,7 +98,8 @@ open class SearchActivity : BaseActivity() {
|
||||
searchEt.hint = "搜索游戏..."
|
||||
}
|
||||
|
||||
if (mDisplayType == DisplayType.DEFAULT) {
|
||||
if (savedInstanceState == null
|
||||
&& mDisplayType == DisplayType.DEFAULT) {
|
||||
updateDisplayType(DisplayType.DEFAULT)
|
||||
}
|
||||
}
|
||||
@ -136,26 +145,29 @@ open class SearchActivity : BaseActivity() {
|
||||
when (type) {
|
||||
SearchType.AUTO -> {
|
||||
mSearchKey = key
|
||||
updateDisplayType(DisplayType.GAME_DIGEST)
|
||||
updateDisplayType(GAME_DIGEST)
|
||||
LogUtils.uploadSearchGame("searching", "搜索页", key, "自动搜索")
|
||||
}
|
||||
SearchType.DEFAULT -> {
|
||||
mSearchKey = key
|
||||
searchEt.setText(key)
|
||||
searchEt.setSelection(searchEt.text.length)
|
||||
updateDisplayType(DisplayType.GAME_DETAIL)
|
||||
updateDisplayType(GAME_DETAIL)
|
||||
LogUtils.uploadSearchGame("searching", "搜索页", key, "默认搜索")
|
||||
// MtaHelper.onEvent("游戏搜索", "默认搜索", key)
|
||||
}
|
||||
SearchType.HOT -> {
|
||||
mSearchKey = key
|
||||
searchEt.setText(key)
|
||||
searchEt.setSelection(searchEt.text.length)
|
||||
updateDisplayType(DisplayType.GAME_DETAIL)
|
||||
updateDisplayType(GAME_DETAIL)
|
||||
}
|
||||
SearchType.HISTORY -> {
|
||||
mSearchKey = key
|
||||
searchEt.setText(key)
|
||||
searchEt.setSelection(searchEt.text.length)
|
||||
updateDisplayType(DisplayType.GAME_DETAIL)
|
||||
updateDisplayType(GAME_DETAIL)
|
||||
LogUtils.uploadSearchGame("searching", "搜索页", key, "历史搜索")
|
||||
// MtaHelper.onEvent("游戏搜索", "历史搜索", key)
|
||||
}
|
||||
SearchType.MANUAL -> {
|
||||
@ -166,15 +178,16 @@ open class SearchActivity : BaseActivity() {
|
||||
mDao?.add(hint)
|
||||
search(SearchType.DEFAULT, hint)
|
||||
}
|
||||
} else if (newSearchKey != mSearchKey || mDisplayType != DisplayType.GAME_DETAIL) {
|
||||
} else if (newSearchKey != mSearchKey || mDisplayType != GAME_DETAIL) {
|
||||
mSearchKey = newSearchKey
|
||||
if (!TextUtils.isEmpty(mSearchKey)) {
|
||||
mDao?.add(mSearchKey)
|
||||
updateDisplayType(DisplayType.GAME_DETAIL)
|
||||
updateDisplayType(GAME_DETAIL)
|
||||
} else {
|
||||
toast("请输入搜索内容")
|
||||
}
|
||||
}
|
||||
LogUtils.uploadSearchGame("searching", "搜索页", newSearchKey, "主动搜索")
|
||||
// MtaHelper.onEvent("游戏搜索", "主动搜索", newSearchKey)
|
||||
}
|
||||
}
|
||||
@ -232,7 +245,7 @@ open class SearchActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val KEY_SEARCH_TYPE = "search_type"
|
||||
const val KEY_SEARCH_TYPE = "search_type"
|
||||
private const val KEY_DISPLAY_TYPE = "display_type"
|
||||
private const val KEY_SEARCH_IMMEDIATELY = "search_immediately"
|
||||
|
||||
@ -273,11 +286,13 @@ enum class SearchType(var value: String) {
|
||||
* [DEFAULT] 默认搜索页
|
||||
* [GAME_DIGEST] 游戏为部分文字样式的列表
|
||||
* [GAME_DETAIL] 游戏全为标准样式的列表
|
||||
* [FORUM_OR_USER] 论坛内容和用户
|
||||
*/
|
||||
enum class DisplayType(var value: Int) {
|
||||
DEFAULT(0),
|
||||
GAME_DIGEST(1),
|
||||
GAME_DETAIL(2);
|
||||
GAME_DETAIL(2),
|
||||
FORUM_OR_USER(3);
|
||||
|
||||
companion object {
|
||||
fun fromInt(typeInt: Int) = values().find { typeInt == it.value } ?: DEFAULT
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package com.gh.gamecenter;
|
||||
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
@ -10,15 +9,16 @@ import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.gh.base.ToolBarActivity;
|
||||
import com.gh.common.util.ExtensionsKt;
|
||||
import com.gh.common.util.MessageShareUtils;
|
||||
import com.gh.common.util.MtaHelper;
|
||||
import com.gh.common.util.QRCodeUtils;
|
||||
import com.gh.common.util.ShareUtils;
|
||||
import com.lightgame.utils.Utils;
|
||||
import com.tencent.tauth.Tencent;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
@ -73,9 +73,6 @@ public class ShareGhActivity extends ToolBarActivity {
|
||||
@OnClick(R.id.gh_address_tv)
|
||||
public void copyAddress() {
|
||||
MtaHelper.onEvent("我的光环_新", "分享光环", "复制官网");
|
||||
ClipboardManager cmb = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
cmb.setText(getString(R.string.gh_website_url_100));
|
||||
|
||||
Utils.toast(this, "网址复制成功,请到微信/QQ粘贴分享");
|
||||
ExtensionsKt.copyTextAndToast(getString(R.string.gh_website_url_100), "网址复制成功,请到微信/QQ粘贴分享");
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,310 +80,325 @@ public class SkipActivity extends BaseActivity {
|
||||
Uri uri = getIntent().getData();
|
||||
Bundle bundle;
|
||||
if (uri != null) {
|
||||
if (CommonDebug.IS_DEBUG) {
|
||||
Utils.log("SkipActivity:: Uri=>" + uri.toString());
|
||||
}
|
||||
String host = uri.getHost();
|
||||
String path = uri.getPath();
|
||||
if ("ghzhushou".equals(uri.getScheme())) {
|
||||
if (CommonDebug.IS_DEBUG) {
|
||||
Utils.log("SkipActivity:: Uri=>" + uri.toString());
|
||||
}
|
||||
String host = uri.getHost();
|
||||
String path = uri.getPath();
|
||||
|
||||
String to = uri.getQueryParameter("to");
|
||||
String type = uri.getQueryParameter("type");
|
||||
String name = uri.getQueryParameter("name");
|
||||
String referer = uri.getQueryParameter("referer");
|
||||
String id = uri.getQueryParameter("id");
|
||||
if (!TextUtils.isEmpty(path)) {
|
||||
path = path.substring(1);
|
||||
}
|
||||
String to = uri.getQueryParameter("to");
|
||||
String type = uri.getQueryParameter("type");
|
||||
String name = uri.getQueryParameter("name");
|
||||
String referer = uri.getQueryParameter("referer");
|
||||
String id = uri.getQueryParameter("id");
|
||||
if (!TextUtils.isEmpty(path)) {
|
||||
path = path.substring(1);
|
||||
}
|
||||
|
||||
if (host != null) {
|
||||
Intent intent;
|
||||
switch (host) {
|
||||
case HOST_ARTICLE:
|
||||
DirectUtils.directToArticle(this, path, ENTRANCE_BROWSER);
|
||||
break;
|
||||
case HOST_GAME:
|
||||
DirectUtils.directToGameDetail(this, path, ENTRANCE_BROWSER, "true".equals(uri.getQueryParameter("auto_download")), to, null);
|
||||
break;
|
||||
case HOST_COLUMN:
|
||||
DirectUtils.directToSubject(this, path, uri.getQueryParameter(KEY_NAME), ENTRANCE_BROWSER);
|
||||
break;
|
||||
case HOST_SUGGESTION:
|
||||
String platform = uri.getQueryParameter(KEY_PLATFORM);
|
||||
String platformName = PlatformUtils.getInstance(this).getPlatformName(platform);
|
||||
String gameId = uri.getQueryParameter(EntranceUtils.KEY_GAMEID);
|
||||
String packageMd5 = uri.getQueryParameter(EntranceUtils.KEY_PACKAGE_MD5);
|
||||
String content = (TextUtils.isEmpty(gameId) || TextUtils.isEmpty(packageMd5)) ?
|
||||
String.format("%s-%s-V%s,",
|
||||
uri.getQueryParameter(KEY_GAME_NAME),
|
||||
TextUtils.isEmpty(platformName) ? platform : platformName,
|
||||
uri.getQueryParameter(KEY_VERSION)) :
|
||||
String.format("%s-%s-V%s\n游戏ID:%s\n游戏包MD5:%s\n",
|
||||
uri.getQueryParameter(KEY_GAME_NAME),
|
||||
TextUtils.isEmpty(platformName) ? platform : platformName,
|
||||
uri.getQueryParameter(KEY_VERSION), gameId, packageMd5);
|
||||
String qaId = uri.getQueryParameter("qa_id");
|
||||
String qaTitle = uri.getQueryParameter(EntranceUtils.KEY_QA_TITLE);
|
||||
if (!TextUtils.isEmpty(qaId)) {
|
||||
DirectUtils.directToQa(this, qaTitle, qaId);
|
||||
} else {
|
||||
DirectUtils.directToFeedback(this, content, ENTRANCE_BROWSER);
|
||||
}
|
||||
break;
|
||||
case HOST_DOWNLOAD:
|
||||
DirectUtils.directToDownloadManagerAndStartUpdate(this, path, uri.getQueryParameter(KEY_PACKAGENAME), ENTRANCE_BROWSER);
|
||||
break;
|
||||
case HOST_ANSWER:
|
||||
DirectUtils.directToAnswerDetail(this, path, ENTRANCE_BROWSER, "浏览器");
|
||||
break;
|
||||
case HOST_QUESTION:
|
||||
DirectUtils.directToQuestionDetail(this, path, ENTRANCE_BROWSER, "浏览器");
|
||||
break;
|
||||
case HOST_TOOLBOX:
|
||||
DirectUtils.directToToolbox(this, uri.getQueryParameter("gameId"), uri.getQueryParameter("toolboxUrl"), ENTRANCE_BROWSER);
|
||||
break;
|
||||
case HOST_COMMUNITY:
|
||||
UserManager.getInstance().setCommunityData(new CommunityEntity(path, name));
|
||||
// 把切换放到 MainActivity 处理
|
||||
if (RunningUtils.isRunning(this)
|
||||
&& MainActivity.class.getName().equals(RunningUtils.getBaseActivity(this))) {
|
||||
intent = new Intent(this, MainActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
intent.putExtra(MainActivity.SWITCH_TO_COMMUNITY, true);
|
||||
} else {
|
||||
bundle = new Bundle();
|
||||
bundle.putBoolean(MainActivity.SWITCH_TO_COMMUNITY, true);
|
||||
intent = SplashScreenActivity.getSplashScreenIntent(this, bundle);
|
||||
}
|
||||
startActivity(intent);
|
||||
break;
|
||||
// 社区文章格式一
|
||||
case "community.article":
|
||||
DirectUtils.directToCommunityArticle(this, uri.getQueryParameter("articleId"), uri.getQueryParameter("communityId"), ENTRANCE_BROWSER, "浏览器");
|
||||
break;
|
||||
// 社区文章格式二
|
||||
case "communities":
|
||||
String communityId = "";
|
||||
String typeId = "";
|
||||
String[] split = path.split("/");
|
||||
for (String text : split) {
|
||||
if (TextUtils.isEmpty(communityId)) {
|
||||
communityId = text;
|
||||
continue;
|
||||
}
|
||||
if (TextUtils.isEmpty(type)) {
|
||||
type = text;
|
||||
continue;
|
||||
}
|
||||
if (TextUtils.isEmpty(typeId)) {
|
||||
typeId = text;
|
||||
}
|
||||
}
|
||||
if ("articles".equals(type)) {
|
||||
DirectUtils.directToCommunityArticle(this, typeId, communityId, ENTRANCE_BROWSER, "浏览器");
|
||||
if (host != null) {
|
||||
Intent intent;
|
||||
switch (host) {
|
||||
case HOST_ARTICLE:
|
||||
DirectUtils.directToArticle(this, path, ENTRANCE_BROWSER);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case HOST_VIDEO:
|
||||
DirectUtils.directToVideoDetail(this, path, VideoDetailContainerViewModel.Location.HOTTEST_GAME_VIDEO.getValue(),
|
||||
false, id, ENTRANCE_BROWSER, "浏览器", TextUtils.isEmpty(referer) ? "" : referer);
|
||||
break;
|
||||
case HOST_UPLOAD_VIDEO://跳转上传视频
|
||||
String titleParameter = uri.getQueryParameter("title");
|
||||
String title = TextUtils.isEmpty(titleParameter) ? "" : "#" + titleParameter + "#";
|
||||
String categoryId = uri.getQueryParameter("category_id");
|
||||
String link = uri.getQueryParameter("link");
|
||||
gameId = uri.getQueryParameter("gameId");
|
||||
String gameName = uri.getQueryParameter("gameName");
|
||||
String tagActivityId = uri.getQueryParameter("tagActivityId");
|
||||
String tagActivityName = uri.getQueryParameter("tagActivityName");
|
||||
VideoLinkEntity linkEntity = new VideoLinkEntity(title, categoryId, link, tagActivityId, tagActivityName);
|
||||
|
||||
SimpleGameEntity simpleGameEntity = new SimpleGameEntity(gameId != null ? gameId : "", gameName != null ? gameName : "", "");
|
||||
Bundle nextToBundle = VideoManagerActivity.getVideoManagerBundle(linkEntity, simpleGameEntity, EntranceUtils.ENTRANCE_BROWSER, "");
|
||||
CheckLoginUtils.checkLogin(this, nextToBundle, true, EntranceUtils.ENTRANCE_BROWSER, () ->
|
||||
DirectUtils.directToVideoManager(SkipActivity.this, linkEntity, simpleGameEntity, EntranceUtils.ENTRANCE_BROWSER, "浏览器"));
|
||||
break;
|
||||
case HOST_VIDEO_SINGLE:
|
||||
DirectUtils.directToVideoDetail(this, path, VideoDetailContainerViewModel.Location.SINGLE_VIDEO.getValue(),
|
||||
false, "", ENTRANCE_BROWSER, "浏览器", TextUtils.isEmpty(referer) ? "" : referer);
|
||||
break;
|
||||
case HOST_VIDEO_MORE:
|
||||
gameId = uri.getQueryParameter("gameId");
|
||||
String act = uri.getQueryParameter("act");
|
||||
String fieldId = uri.getQueryParameter("fieldId");
|
||||
String sectionName = uri.getQueryParameter("sectionName");
|
||||
String paginationType = uri.getQueryParameter("paginationType");//活动分页方式 page filter
|
||||
String location;
|
||||
if (!TextUtils.isEmpty(act)) {
|
||||
location = VideoDetailContainerViewModel.Location.VIDEO_ACTIVITY.getValue();
|
||||
} else if (!TextUtils.isEmpty(fieldId)) {
|
||||
location = VideoDetailContainerViewModel.Location.GAME_ZONE.getValue();
|
||||
} else {
|
||||
location = path;
|
||||
}
|
||||
DirectUtils.directToVideoDetail(this, path, location,
|
||||
false, TextUtils.isEmpty(gameId) ? "" : gameId, ENTRANCE_BROWSER, "浏览器", TextUtils.isEmpty(referer) ? "" : referer,
|
||||
TextUtils.isEmpty(type) ? "" : type, TextUtils.isEmpty(act) ? "" : act, TextUtils.isEmpty(paginationType) ? "page" : paginationType, TextUtils.isEmpty(fieldId) ? "" : fieldId,
|
||||
TextUtils.isEmpty(sectionName) ? "" : sectionName);
|
||||
break;
|
||||
case HOST_VIDEO_STREAMING_HOME:
|
||||
// 把切换放到 MainActivity 处理
|
||||
if (RunningUtils.isRunning(this)
|
||||
&& MainActivity.class.getName().equals(RunningUtils.getBaseActivity(this))) {
|
||||
intent = new Intent(this, MainActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
intent.putExtra(MainActivity.SWITCH_TO_VIDEO, true);
|
||||
} else {
|
||||
bundle = new Bundle();
|
||||
bundle.putBoolean(MainActivity.SWITCH_TO_VIDEO, true);
|
||||
intent = SplashScreenActivity.getSplashScreenIntent(this, bundle);
|
||||
}
|
||||
startActivity(intent);
|
||||
break;
|
||||
case HOST_VIDEO_STREAMING_DESC:
|
||||
DirectUtils.directToGameDetailVideoStreaming(this, path, ENTRANCE_BROWSER);
|
||||
break;
|
||||
case HOST_VIDEO_COLLECTION:
|
||||
DirectUtils.directToGameVideo(this, path, ENTRANCE_BROWSER, "浏览器");
|
||||
break;
|
||||
case HOST_QQ:
|
||||
bundle = new Bundle();
|
||||
bundle.putString(KEY_TO, HOST_QQ);
|
||||
bundle.putString(KEY_DATA, path);
|
||||
EntranceUtils.jumpActivity(this, bundle);
|
||||
break;
|
||||
case HOST_QQ_GROUP:
|
||||
bundle = new Bundle();
|
||||
bundle.putString(KEY_TO, HOST_QQ_GROUP);
|
||||
bundle.putString(KEY_DATA, path);
|
||||
EntranceUtils.jumpActivity(this, bundle);
|
||||
break;
|
||||
case HOST_QQ_QUN:
|
||||
String key = uri.getQueryParameter("key");
|
||||
bundle = new Bundle();
|
||||
bundle.putString(KEY_TO, HOST_QQ_GROUP);
|
||||
bundle.putString(KEY_DATA, key);
|
||||
EntranceUtils.jumpActivity(this, bundle);
|
||||
break;
|
||||
case HOST_WEB:
|
||||
bundle = new Bundle();
|
||||
bundle.putString(KEY_TO, HOST_WEB);
|
||||
bundle.putString(KEY_DATA, to);
|
||||
bundle.putString(KEY_TYPE, type);
|
||||
EntranceUtils.jumpActivity(this, bundle);
|
||||
break;
|
||||
case HOST_LIBAO:
|
||||
DirectUtils.directToGiftDetail(this, path, ENTRANCE_BROWSER);
|
||||
break;
|
||||
case HOST_USERHOME:
|
||||
String position = uri.getQueryParameter("position");
|
||||
DirectUtils.directToHomeActivity(this, path, TextUtils.isEmpty(position) ? -1 : Integer.parseInt(position), ENTRANCE_BROWSER, "浏览器");
|
||||
break;
|
||||
case HOST_COMMUNITY_COLUMN:
|
||||
CommunityEntity community = new CommunityEntity();
|
||||
community.setId(uri.getQueryParameter("community_id"));
|
||||
community.setName(uri.getQueryParameter("community_name"));
|
||||
String columnId = uri.getQueryParameter("column_id");
|
||||
DirectUtils.directToCommunityColumn(this, community, columnId, ENTRANCE_BROWSER, "");
|
||||
break;
|
||||
|
||||
case HOST_CATEGORY:
|
||||
title = uri.getQueryParameter("title");
|
||||
DirectUtils.directCategoryDirectory(this, path, title, ENTRANCE_BROWSER, "浏览器");
|
||||
break;
|
||||
case HOST_COLUMN_COLLECTION:
|
||||
DirectUtils.directToColumnCollection(this, path, -1, ENTRANCE_BROWSER, "浏览器");
|
||||
break;
|
||||
case HOST_COMMUNITY_QUESTION_LABEL_DETAIL:
|
||||
community = new CommunityEntity();
|
||||
community.setId(uri.getQueryParameter("community_id"));
|
||||
community.setName(uri.getQueryParameter("community_name"));
|
||||
String tag = uri.getQueryParameter("tag");
|
||||
DirectUtils.directAskColumnLabelDetail(this, tag, community, ENTRANCE_BROWSER, "浏览器");
|
||||
break;
|
||||
case HOST_COMMUNITY_COLUMN_DETAIL:
|
||||
community = new CommunityEntity();
|
||||
community.setId(uri.getQueryParameter("community_id"));
|
||||
community.setName(uri.getQueryParameter("community_name"));
|
||||
columnId = uri.getQueryParameter("column_id");
|
||||
DirectUtils.directAskColumnDetail(this, columnId, community, ENTRANCE_BROWSER, "浏览器");
|
||||
break;
|
||||
case EntranceUtils.HOST_BLOCK:
|
||||
name = uri.getQueryParameter("name");
|
||||
SubjectRecommendEntity entity = new SubjectRecommendEntity();
|
||||
entity.setLink(path);
|
||||
entity.setName(name);
|
||||
entity.setText(name);
|
||||
DirectUtils.directToBlock(this, entity, mEntrance);
|
||||
break;
|
||||
|
||||
case EntranceUtils.HOST_SERVER_BLOCK:
|
||||
DirectUtils.directToGameServers(this, ENTRANCE_BROWSER, "浏览器");
|
||||
break;
|
||||
|
||||
case EntranceUtils.HOST_AMWAY_BLOCK:
|
||||
DirectUtils.directToAmway(this, null, ENTRANCE_BROWSER, "浏览器");
|
||||
break;
|
||||
|
||||
case EntranceUtils.HOST_HELP:
|
||||
name = uri.getQueryParameter("name");
|
||||
DirectUtils.directToQa(this, name, path);
|
||||
break;
|
||||
|
||||
case EntranceUtils.HOST_HELP_COLLECTION:
|
||||
name = uri.getQueryParameter("name");
|
||||
DirectUtils.directToQaCollection(this, name, path);
|
||||
break;
|
||||
case EntranceUtils.HOST_GAME_UPLOAD:
|
||||
DirectUtils.directGameUpload(this, ENTRANCE_BROWSER, "浏览器");
|
||||
break;
|
||||
case EntranceUtils.HOST_GAME_ZONE:
|
||||
String zoneUrl = uri.getQueryParameter("url");
|
||||
DirectUtils.directGameZone(this, path, zoneUrl, ENTRANCE_BROWSER);
|
||||
break;
|
||||
case EntranceUtils.HOST_LINK:
|
||||
try {
|
||||
String dataString = uri.getQueryParameter("data");
|
||||
if (!TextUtils.isEmpty(dataString)) {
|
||||
byte[] linkData = Base64.decode(dataString, Base64.DEFAULT);
|
||||
String linkDataString = new String(linkData, "UTF-8");
|
||||
LinkEntity le = GsonUtils.INSTANCE.getGson().fromJson(linkDataString, LinkEntity.class);
|
||||
DirectUtils.directToLinkPage(this, le, ENTRANCE_BROWSER, "");
|
||||
case HOST_GAME:
|
||||
DirectUtils.directToGameDetail(this, path, ENTRANCE_BROWSER, "true".equals(uri.getQueryParameter("auto_download")), to, null);
|
||||
break;
|
||||
case HOST_COLUMN:
|
||||
DirectUtils.directToSubject(this, path, uri.getQueryParameter(KEY_NAME), ENTRANCE_BROWSER);
|
||||
break;
|
||||
case HOST_SUGGESTION:
|
||||
String platform = uri.getQueryParameter(KEY_PLATFORM);
|
||||
String platformName = PlatformUtils.getInstance(this).getPlatformName(platform);
|
||||
String gameId = uri.getQueryParameter(EntranceUtils.KEY_GAMEID);
|
||||
String packageMd5 = uri.getQueryParameter(EntranceUtils.KEY_PACKAGE_MD5);
|
||||
String content = (TextUtils.isEmpty(gameId) || TextUtils.isEmpty(packageMd5)) ?
|
||||
String.format("%s-%s-V%s,",
|
||||
uri.getQueryParameter(KEY_GAME_NAME),
|
||||
TextUtils.isEmpty(platformName) ? platform : platformName,
|
||||
uri.getQueryParameter(KEY_VERSION)) :
|
||||
String.format("%s-%s-V%s\n游戏ID:%s\n游戏包MD5:%s\n",
|
||||
uri.getQueryParameter(KEY_GAME_NAME),
|
||||
TextUtils.isEmpty(platformName) ? platform : platformName,
|
||||
uri.getQueryParameter(KEY_VERSION), gameId, packageMd5);
|
||||
String qaId = uri.getQueryParameter("qa_id");
|
||||
String qaTitle = uri.getQueryParameter(EntranceUtils.KEY_QA_TITLE);
|
||||
if (!TextUtils.isEmpty(qaId)) {
|
||||
DirectUtils.directToQa(this, qaTitle, qaId);
|
||||
} else {
|
||||
DirectUtils.directToFeedback(this, content, ENTRANCE_BROWSER);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
toast(e.getMessage());
|
||||
}
|
||||
break;
|
||||
case EntranceUtils.HOST_GAME_NEWS:
|
||||
DirectUtils.directToGameNews(
|
||||
this,
|
||||
uri.getQueryParameter(EntranceUtils.KEY_GAME_ID),
|
||||
uri.getQueryParameter(EntranceUtils.KEY_GAME_NAME),
|
||||
EntranceUtils.ENTRANCE_BROWSER);
|
||||
break;
|
||||
case EntranceUtils.HOST_GAME_CALENDAR:
|
||||
DirectUtils.directToGameServerCalendar(this, uri.getQueryParameter(EntranceUtils.KEY_GAME_ID));
|
||||
break;
|
||||
case EntranceUtils.HOST_HISTORY_APK:
|
||||
DirectUtils.directToHistoryApk(this, uri.getQueryParameter(EntranceUtils.KEY_GAME_ID));
|
||||
break;
|
||||
case EntranceUtils.HOST_FORUM_DETAIL:
|
||||
DirectUtils.directForumDetail(this, id, ENTRANCE_BROWSER);
|
||||
break;
|
||||
case EntranceUtils.HOST_GAME_RATING_DETAIL:
|
||||
DirectUtils.directToGameRatingDetail(this, uri.getQueryParameter(EntranceUtils.KEY_GAME_ID), uri.getQueryParameter(EntranceUtils.KEY_COMMENT_ID), ENTRANCE_BROWSER);
|
||||
break;
|
||||
case EntranceUtils.HOST_FORUM:
|
||||
DirectUtils.directToForum(this);
|
||||
break;
|
||||
case EntranceUtils.HOST_HELP_AND_FEEDBACK:
|
||||
position = uri.getQueryParameter("position");
|
||||
DirectUtils.directToHelpAndFeedback(this, TextUtils.isEmpty(position) ? 0 : Integer.parseInt(position));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case HOST_DOWNLOAD:
|
||||
DirectUtils.directToDownloadManagerAndStartUpdate(this, path, uri.getQueryParameter(KEY_PACKAGENAME), ENTRANCE_BROWSER);
|
||||
break;
|
||||
case HOST_ANSWER:
|
||||
DirectUtils.directToAnswerDetail(this, path, ENTRANCE_BROWSER, "浏览器");
|
||||
break;
|
||||
case HOST_QUESTION:
|
||||
DirectUtils.directToQuestionDetail(this, path, ENTRANCE_BROWSER, "浏览器");
|
||||
break;
|
||||
case HOST_TOOLBOX:
|
||||
DirectUtils.directToToolbox(this, uri.getQueryParameter("gameId"), uri.getQueryParameter("toolboxUrl"), ENTRANCE_BROWSER);
|
||||
break;
|
||||
case HOST_COMMUNITY:
|
||||
UserManager.getInstance().setCommunityData(new CommunityEntity(path, name));
|
||||
// 把切换放到 MainActivity 处理
|
||||
if (RunningUtils.isRunning(this)
|
||||
&& MainActivity.class.getName().equals(RunningUtils.getBaseActivity(this))) {
|
||||
intent = new Intent(this, MainActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
intent.putExtra(MainActivity.SWITCH_TO_COMMUNITY, true);
|
||||
} else {
|
||||
bundle = new Bundle();
|
||||
bundle.putBoolean(MainActivity.SWITCH_TO_COMMUNITY, true);
|
||||
intent = SplashScreenActivity.getSplashScreenIntent(this, bundle);
|
||||
}
|
||||
startActivity(intent);
|
||||
break;
|
||||
// 社区文章格式一
|
||||
case "community.article":
|
||||
DirectUtils.directToCommunityArticle(this, uri.getQueryParameter("articleId"), uri.getQueryParameter("communityId"), ENTRANCE_BROWSER, "浏览器");
|
||||
break;
|
||||
// 社区文章格式二
|
||||
case "communities":
|
||||
String communityId = "";
|
||||
String typeId = "";
|
||||
String[] split = path.split("/");
|
||||
for (String text : split) {
|
||||
if (TextUtils.isEmpty(communityId)) {
|
||||
communityId = text;
|
||||
continue;
|
||||
}
|
||||
if (TextUtils.isEmpty(type)) {
|
||||
type = text;
|
||||
continue;
|
||||
}
|
||||
if (TextUtils.isEmpty(typeId)) {
|
||||
typeId = text;
|
||||
}
|
||||
}
|
||||
if ("articles".equals(type)) {
|
||||
DirectUtils.directToCommunityArticle(this, typeId, communityId, ENTRANCE_BROWSER, "浏览器");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case HOST_VIDEO:
|
||||
DirectUtils.directToVideoDetail(this, path, VideoDetailContainerViewModel.Location.HOTTEST_GAME_VIDEO.getValue(),
|
||||
false, id, ENTRANCE_BROWSER, "浏览器", TextUtils.isEmpty(referer) ? "" : referer);
|
||||
break;
|
||||
case HOST_UPLOAD_VIDEO://跳转上传视频
|
||||
String titleParameter = uri.getQueryParameter("title");
|
||||
String title = TextUtils.isEmpty(titleParameter) ? "" : "#" + titleParameter + "#";
|
||||
String categoryId = uri.getQueryParameter("category_id");
|
||||
String link = uri.getQueryParameter("link");
|
||||
gameId = uri.getQueryParameter("gameId");
|
||||
String gameName = uri.getQueryParameter("gameName");
|
||||
String tagActivityId = uri.getQueryParameter("tagActivityId");
|
||||
String tagActivityName = uri.getQueryParameter("tagActivityName");
|
||||
VideoLinkEntity linkEntity = new VideoLinkEntity(title, categoryId, link, tagActivityId, tagActivityName);
|
||||
|
||||
SimpleGameEntity simpleGameEntity = new SimpleGameEntity(gameId != null ? gameId : "", gameName != null ? gameName : "", "");
|
||||
Bundle nextToBundle = VideoManagerActivity.getVideoManagerBundle(linkEntity, simpleGameEntity, EntranceUtils.ENTRANCE_BROWSER, "");
|
||||
CheckLoginUtils.checkLogin(this, nextToBundle, true, EntranceUtils.ENTRANCE_BROWSER, () ->
|
||||
DirectUtils.directToVideoManager(SkipActivity.this, linkEntity, simpleGameEntity, EntranceUtils.ENTRANCE_BROWSER, "浏览器"));
|
||||
break;
|
||||
case HOST_VIDEO_SINGLE:
|
||||
DirectUtils.directToVideoDetail(this, path, VideoDetailContainerViewModel.Location.SINGLE_VIDEO.getValue(),
|
||||
false, "", ENTRANCE_BROWSER, "浏览器", TextUtils.isEmpty(referer) ? "" : referer);
|
||||
break;
|
||||
case HOST_VIDEO_MORE:
|
||||
gameId = uri.getQueryParameter("gameId");
|
||||
String act = uri.getQueryParameter("act");
|
||||
String fieldId = uri.getQueryParameter("fieldId");
|
||||
String sectionName = uri.getQueryParameter("sectionName");
|
||||
String paginationType = uri.getQueryParameter("paginationType");//活动分页方式 page filter
|
||||
String location;
|
||||
if (!TextUtils.isEmpty(act)) {
|
||||
location = VideoDetailContainerViewModel.Location.VIDEO_ACTIVITY.getValue();
|
||||
} else if (!TextUtils.isEmpty(fieldId)) {
|
||||
location = VideoDetailContainerViewModel.Location.GAME_ZONE.getValue();
|
||||
} else {
|
||||
location = path;
|
||||
}
|
||||
DirectUtils.directToVideoDetail(this, path, location,
|
||||
false, TextUtils.isEmpty(gameId) ? "" : gameId, ENTRANCE_BROWSER, "浏览器", TextUtils.isEmpty(referer) ? "" : referer,
|
||||
TextUtils.isEmpty(type) ? "" : type, TextUtils.isEmpty(act) ? "" : act, TextUtils.isEmpty(paginationType) ? "page" : paginationType, TextUtils.isEmpty(fieldId) ? "" : fieldId,
|
||||
TextUtils.isEmpty(sectionName) ? "" : sectionName);
|
||||
break;
|
||||
case HOST_VIDEO_STREAMING_HOME:
|
||||
// 把切换放到 MainActivity 处理
|
||||
if (RunningUtils.isRunning(this)
|
||||
&& MainActivity.class.getName().equals(RunningUtils.getBaseActivity(this))) {
|
||||
intent = new Intent(this, MainActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
intent.putExtra(MainActivity.SWITCH_TO_VIDEO, true);
|
||||
} else {
|
||||
bundle = new Bundle();
|
||||
bundle.putBoolean(MainActivity.SWITCH_TO_VIDEO, true);
|
||||
intent = SplashScreenActivity.getSplashScreenIntent(this, bundle);
|
||||
}
|
||||
startActivity(intent);
|
||||
break;
|
||||
case HOST_VIDEO_STREAMING_DESC:
|
||||
DirectUtils.directToGameDetailVideoStreaming(this, path, ENTRANCE_BROWSER);
|
||||
break;
|
||||
case HOST_VIDEO_COLLECTION:
|
||||
DirectUtils.directToGameVideo(this, path, ENTRANCE_BROWSER, "浏览器");
|
||||
break;
|
||||
case HOST_QQ:
|
||||
bundle = new Bundle();
|
||||
bundle.putString(KEY_TO, HOST_QQ);
|
||||
bundle.putString(KEY_DATA, path);
|
||||
EntranceUtils.jumpActivity(this, bundle);
|
||||
break;
|
||||
case HOST_QQ_GROUP:
|
||||
bundle = new Bundle();
|
||||
bundle.putString(KEY_TO, HOST_QQ_GROUP);
|
||||
bundle.putString(KEY_DATA, path);
|
||||
EntranceUtils.jumpActivity(this, bundle);
|
||||
break;
|
||||
case HOST_QQ_QUN:
|
||||
String key = uri.getQueryParameter("key");
|
||||
bundle = new Bundle();
|
||||
bundle.putString(KEY_TO, HOST_QQ_GROUP);
|
||||
bundle.putString(KEY_DATA, key);
|
||||
EntranceUtils.jumpActivity(this, bundle);
|
||||
break;
|
||||
case HOST_WEB:
|
||||
bundle = new Bundle();
|
||||
bundle.putString(KEY_TO, HOST_WEB);
|
||||
bundle.putString(KEY_DATA, to);
|
||||
bundle.putString(KEY_TYPE, type);
|
||||
EntranceUtils.jumpActivity(this, bundle);
|
||||
break;
|
||||
case HOST_LIBAO:
|
||||
DirectUtils.directToGiftDetail(this, path, ENTRANCE_BROWSER);
|
||||
break;
|
||||
case HOST_USERHOME:
|
||||
String position = uri.getQueryParameter("position");
|
||||
DirectUtils.directToHomeActivity(this, path, TextUtils.isEmpty(position) ? -1 : Integer.parseInt(position), ENTRANCE_BROWSER, "浏览器");
|
||||
break;
|
||||
case HOST_COMMUNITY_COLUMN:
|
||||
CommunityEntity community = new CommunityEntity();
|
||||
community.setId(uri.getQueryParameter("community_id"));
|
||||
community.setName(uri.getQueryParameter("community_name"));
|
||||
String columnId = uri.getQueryParameter("column_id");
|
||||
DirectUtils.directToCommunityColumn(this, community, columnId, ENTRANCE_BROWSER, "");
|
||||
break;
|
||||
|
||||
case HOST_CATEGORY:
|
||||
title = uri.getQueryParameter("title");
|
||||
DirectUtils.directCategoryDirectory(this, path, title, ENTRANCE_BROWSER, "浏览器");
|
||||
break;
|
||||
case HOST_COLUMN_COLLECTION:
|
||||
DirectUtils.directToColumnCollection(this, path, -1, ENTRANCE_BROWSER, "浏览器");
|
||||
break;
|
||||
case HOST_COMMUNITY_QUESTION_LABEL_DETAIL:
|
||||
community = new CommunityEntity();
|
||||
community.setId(uri.getQueryParameter("community_id"));
|
||||
community.setName(uri.getQueryParameter("community_name"));
|
||||
String tag = uri.getQueryParameter("tag");
|
||||
DirectUtils.directAskColumnLabelDetail(this, tag, community, ENTRANCE_BROWSER, "浏览器");
|
||||
break;
|
||||
case HOST_COMMUNITY_COLUMN_DETAIL:
|
||||
community = new CommunityEntity();
|
||||
community.setId(uri.getQueryParameter("community_id"));
|
||||
community.setName(uri.getQueryParameter("community_name"));
|
||||
columnId = uri.getQueryParameter("column_id");
|
||||
DirectUtils.directAskColumnDetail(this, columnId, community, ENTRANCE_BROWSER, "浏览器");
|
||||
break;
|
||||
case EntranceUtils.HOST_BLOCK:
|
||||
name = uri.getQueryParameter("name");
|
||||
SubjectRecommendEntity entity = new SubjectRecommendEntity();
|
||||
entity.setLink(path);
|
||||
entity.setName(name);
|
||||
entity.setText(name);
|
||||
DirectUtils.directToBlock(this, entity, mEntrance);
|
||||
break;
|
||||
|
||||
case EntranceUtils.HOST_SERVER_BLOCK:
|
||||
DirectUtils.directToGameServers(this, ENTRANCE_BROWSER, "浏览器");
|
||||
break;
|
||||
|
||||
case EntranceUtils.HOST_AMWAY_BLOCK:
|
||||
DirectUtils.directToAmway(this, null, ENTRANCE_BROWSER, "浏览器");
|
||||
break;
|
||||
|
||||
case EntranceUtils.HOST_HELP:
|
||||
name = uri.getQueryParameter("name");
|
||||
DirectUtils.directToQa(this, name, path);
|
||||
break;
|
||||
|
||||
case EntranceUtils.HOST_HELP_COLLECTION:
|
||||
name = uri.getQueryParameter("name");
|
||||
DirectUtils.directToQaCollection(this, name, path);
|
||||
break;
|
||||
case EntranceUtils.HOST_GAME_UPLOAD:
|
||||
DirectUtils.directGameUpload(this, ENTRANCE_BROWSER, "浏览器");
|
||||
break;
|
||||
case EntranceUtils.HOST_GAME_ZONE:
|
||||
String zoneUrl = uri.getQueryParameter("url");
|
||||
DirectUtils.directGameZone(this, path, zoneUrl, ENTRANCE_BROWSER);
|
||||
break;
|
||||
case EntranceUtils.HOST_LINK:
|
||||
try {
|
||||
String dataString = uri.getQueryParameter("data");
|
||||
if (!TextUtils.isEmpty(dataString)) {
|
||||
byte[] linkData = Base64.decode(dataString, Base64.DEFAULT);
|
||||
String linkDataString = new String(linkData, "UTF-8");
|
||||
LinkEntity le = GsonUtils.INSTANCE.getGson().fromJson(linkDataString, LinkEntity.class);
|
||||
DirectUtils.directToLinkPage(this, le, ENTRANCE_BROWSER, "");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
toast(e.getMessage());
|
||||
}
|
||||
break;
|
||||
case EntranceUtils.HOST_GAME_NEWS:
|
||||
DirectUtils.directToGameNews(
|
||||
this,
|
||||
uri.getQueryParameter(EntranceUtils.KEY_GAME_ID),
|
||||
uri.getQueryParameter(EntranceUtils.KEY_GAME_NAME),
|
||||
EntranceUtils.ENTRANCE_BROWSER);
|
||||
break;
|
||||
case EntranceUtils.HOST_GAME_CALENDAR:
|
||||
DirectUtils.directToGameServerCalendar(this, uri.getQueryParameter(EntranceUtils.KEY_GAME_ID));
|
||||
break;
|
||||
case EntranceUtils.HOST_HISTORY_APK:
|
||||
DirectUtils.directToHistoryApk(this, uri.getQueryParameter(EntranceUtils.KEY_GAME_ID));
|
||||
break;
|
||||
case EntranceUtils.HOST_FORUM_DETAIL:
|
||||
DirectUtils.directForumDetail(this, id, ENTRANCE_BROWSER);
|
||||
break;
|
||||
case EntranceUtils.HOST_GAME_RATING_DETAIL:
|
||||
DirectUtils.directToGameRatingDetail(this, uri.getQueryParameter(EntranceUtils.KEY_GAME_ID), uri.getQueryParameter(EntranceUtils.KEY_COMMENT_ID), ENTRANCE_BROWSER);
|
||||
break;
|
||||
case EntranceUtils.HOST_FORUM:
|
||||
DirectUtils.directToForum(this);
|
||||
break;
|
||||
case EntranceUtils.HOST_HELP_AND_FEEDBACK:
|
||||
position = uri.getQueryParameter("position");
|
||||
DirectUtils.directToHelpAndFeedback(this, TextUtils.isEmpty(position) ? 0 : Integer.parseInt(position));
|
||||
break;
|
||||
default:
|
||||
EntranceUtils.jumpActivity(this, new Bundle()); // 跳转至首页
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if ("market".equals(uri.getScheme())) {
|
||||
String host = uri.getHost();
|
||||
String id = uri.getQueryParameter("id");
|
||||
if (host != null) {
|
||||
if ("details".equals(host)) {
|
||||
bundle = new Bundle();
|
||||
bundle.putString(KEY_TO, EntranceUtils.KEY_MARKET_DETAILS);
|
||||
bundle.putString(KEY_DATA, id);
|
||||
EntranceUtils.jumpActivity(this, bundle);
|
||||
} else {
|
||||
EntranceUtils.jumpActivity(this, new Bundle()); // 跳转至首页
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package com.gh.gamecenter;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
@ -15,6 +16,12 @@ import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.viewpager.widget.PagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.g00fy2.versioncompare.Version;
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.common.AppExecutor;
|
||||
@ -23,6 +30,7 @@ import com.gh.common.constant.Constants;
|
||||
import com.gh.common.dialog.PrivacyDialogFragment;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DeviceTokenUtils;
|
||||
import com.gh.common.util.DeviceUtils;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.EmptyCallback;
|
||||
import com.gh.common.util.GameSubstituteRepositoryHelper;
|
||||
@ -32,7 +40,6 @@ import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.PlatformUtils;
|
||||
import com.gh.common.util.SPUtils;
|
||||
import com.gh.common.util.TagUtils;
|
||||
import com.gh.common.util.TeaHelper;
|
||||
import com.gh.common.util.UsageStatsHelper;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.gamecenter.entity.AuthDialogEntity;
|
||||
@ -50,17 +57,14 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.viewpager.widget.PagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.ResponseBody;
|
||||
@ -74,7 +78,8 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
|
||||
private SharedPreferences mSharedPreferences;
|
||||
|
||||
private boolean isNewFirstLaunch;
|
||||
private boolean mIsNewForThisVersion;
|
||||
private boolean mStartMainActivityDirectly = false; // 是否不需要用户点击立即体验就直接跳转首页
|
||||
|
||||
private static final int REQUEST_PERMISSION_TAG = 30001;
|
||||
private String[] mPermissions = {
|
||||
@ -94,7 +99,7 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
isNewFirstLaunch = mSharedPreferences.getBoolean("isNewFirstLaunchV" + PackageUtils.getVersionName(), true);
|
||||
mIsNewForThisVersion = mSharedPreferences.getBoolean("isNewFirstLaunchV" + PackageUtils.getVersionName(), true);
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
@ -105,13 +110,14 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
// 判断是不是这个版本的新用户
|
||||
if (isNewFirstLaunch) {
|
||||
if (mIsNewForThisVersion) {
|
||||
mContentView.setPadding(0, 0, 0, 0);
|
||||
ViewPager guideLayout = findViewById(R.id.splash_intro_vp_guide);
|
||||
guideLayout.setAdapter(new GuidePagerAdapter());
|
||||
|
||||
// 判断是不是光环的新用户
|
||||
if (SPUtils.getBoolean(Constants.SP_BRAND_NEW_USER, true)) {
|
||||
mStartMainActivityDirectly = true;
|
||||
SPUtils.setLong(Constants.SP_INITIAL_USAGE_TIME, System.currentTimeMillis());
|
||||
HaloApp.getInstance().isBrandNewInstall = true;
|
||||
showPrivacyDialog(guideLayout);
|
||||
@ -124,6 +130,9 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
} else {
|
||||
launchMainActivity();
|
||||
}
|
||||
|
||||
SPUtils.setString(Constants.SP_XAPK_UNZIP_ACTIVITY, "");
|
||||
SPUtils.setString(Constants.SP_XAPK_URL, "");
|
||||
}
|
||||
|
||||
private void showPrivacyDialog(ViewPager guideLayout) {
|
||||
@ -136,7 +145,7 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
requestPermission();
|
||||
});
|
||||
} else {
|
||||
DialogUtils.showPrivacyPolicyDisallowDialog(this, PrivacyPolicyEntity.createDefaultData(),()->{
|
||||
DialogUtils.showPrivacyPolicyDisallowDialog(this, PrivacyPolicyEntity.createDefaultData(), () -> {
|
||||
showPrivacyDialog(guideLayout);
|
||||
});
|
||||
}
|
||||
@ -245,7 +254,7 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
if (isNewFirstLaunch) {
|
||||
if (mIsNewForThisVersion) {
|
||||
return R.layout.activity_splash_intro;
|
||||
} else {
|
||||
return 0;
|
||||
@ -255,7 +264,7 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
|
||||
if (isNewFirstLaunch && EasyPermissions.hasPermissions(this, mPermissions)) {
|
||||
if (mIsNewForThisVersion && EasyPermissions.hasPermissions(this, mPermissions)) {
|
||||
launchMainActivity();
|
||||
} else {
|
||||
return true;
|
||||
@ -282,9 +291,7 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
|
||||
prefetchData();
|
||||
|
||||
// 在可能获取了相关权限后才初始化SDK/发送激活数据
|
||||
TeaHelper.init(getApplication(), HaloApp.getInstance().getChannel());
|
||||
// GdtHelper.INSTANCE.logAction(ActionType.START_APP, GdtHelper.NETWORK_TYPE, DeviceUtils.getNetwork(this));
|
||||
uploadTeaAndGdtData();
|
||||
|
||||
Bundle bundle = getIntent().getExtras();
|
||||
Intent intent = new Intent(SplashScreenActivity.this, MainActivity.class);
|
||||
@ -293,6 +300,33 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
finish();
|
||||
}
|
||||
|
||||
private void uploadTeaAndGdtData(){
|
||||
// 在可能获取了相关权限后才初始化SDK/发送激活数据
|
||||
// TeaHelper.init(getApplication(), HaloApp.getInstance().getChannel());
|
||||
try {
|
||||
Class<?> clazz = Class.forName("com.gh.gamecenter.TeaHelper");
|
||||
Method method = clazz.getMethod("init", Context.class, String.class);
|
||||
method.invoke(null, getApplication(), HaloApp.getInstance().getChannel());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// GdtHelper.INSTANCE.logAction(ActionType.START_APP, GdtHelper.NETWORK_TYPE, DeviceUtils.getNetwork(this));
|
||||
try {
|
||||
Class<?> clazz = Class.forName("com.gh.gamecenter.GdtHelper");
|
||||
Field field = clazz.getDeclaredField("NETWORK_TYPE");
|
||||
String type = (String) field.get(null);
|
||||
Method method = clazz.getMethod("logAction", String.class, String[].class);
|
||||
|
||||
Class<?> actionTypeClazz = Class.forName("com.qq.gdt.action.ActionType");
|
||||
Field typeField = actionTypeClazz.getDeclaredField("START_APP");
|
||||
String actionType = (String) typeField.get(null);
|
||||
|
||||
method.invoke(null, actionType, new String[]{type, DeviceUtils.getNetwork(this)});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void getUniqueId() {
|
||||
DataUtils.getGid();
|
||||
}
|
||||
@ -336,6 +370,9 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
MtaHelper.onEvent("授权情况", "启动授权", "都授权");
|
||||
// 检查是否有旧版本光环,有就删掉
|
||||
AppExecutor.getIoExecutor().execute(this::deleteOutdatedUpdatePackage);
|
||||
if (mStartMainActivityDirectly) {
|
||||
launchMainActivity();
|
||||
}
|
||||
} else {
|
||||
ActivityCompat.requestPermissions(this, mPermissions, REQUEST_PERMISSION_TAG);
|
||||
}
|
||||
@ -350,12 +387,22 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
intent.setData(Uri.parse("package:" + getPackageName()));
|
||||
startActivity(intent);
|
||||
}, () -> logGrantedPermission(perms));
|
||||
}, () -> {
|
||||
logGrantedPermission(perms);
|
||||
if (mStartMainActivityDirectly) {
|
||||
launchMainActivity();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
DialogUtils.showPermissionDialog(this, "权限申请",
|
||||
"在设置-应用-光环助手-权限中开启存储和手机信息权限,以保证能正常使用相关功能", "重试", "放弃",
|
||||
this::checkAndRequestPermission,
|
||||
() -> logGrantedPermission(perms));
|
||||
() -> {
|
||||
logGrantedPermission(perms);
|
||||
if (mStartMainActivityDirectly) {
|
||||
launchMainActivity();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -40,7 +40,6 @@ import com.gh.common.AppExecutor;
|
||||
import com.gh.common.dialog.TrackableDialog;
|
||||
import com.gh.common.exposure.meta.MetaUtil;
|
||||
import com.gh.common.filter.RegionSettingHelper;
|
||||
import com.gh.common.im.ImManager;
|
||||
import com.gh.common.util.AdHelper;
|
||||
import com.gh.common.util.ApkActiveUtils;
|
||||
import com.gh.common.util.CheckLoginUtils;
|
||||
@ -56,6 +55,7 @@ import com.gh.common.util.NotificationHelper;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.ShareUtils;
|
||||
import com.gh.common.util.TextHelper;
|
||||
import com.gh.common.util.TimeUtils;
|
||||
import com.gh.common.util.ToastUtils;
|
||||
import com.gh.common.util.UploadImageUtils;
|
||||
import com.gh.common.util.UrlFilterUtils;
|
||||
@ -230,6 +230,8 @@ public class SuggestionActivity extends ToolBarActivity implements OnRequestCall
|
||||
private String mHideHint;
|
||||
private String mSuggestContent;
|
||||
private String mSuggestHintType;
|
||||
private String mDiagnosisResult;
|
||||
private String mDiagnosisMessage;
|
||||
|
||||
private boolean mAgreePostPic;
|
||||
private boolean fromRating = false;
|
||||
@ -292,6 +294,14 @@ public class SuggestionActivity extends ToolBarActivity implements OnRequestCall
|
||||
return intent;
|
||||
}
|
||||
|
||||
public static Intent getIntentFromNetworkDiagnosis(Context context, String diagnosis) {
|
||||
Intent intent = new Intent(context, SuggestionActivity.class);
|
||||
intent.putExtra(EntranceUtils.KEY_SUGGESTTYPE, SuggestType.normal);
|
||||
intent.putExtra(EntranceUtils.KEY_CONTENT, "网络诊断结果" + TimeUtils.getFormatTime(System.currentTimeMillis(), "yyyy.MM.dd"));
|
||||
intent.putExtra(EntranceUtils.KEY_DIAGNOSIS, diagnosis);
|
||||
return intent;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_suggest;
|
||||
@ -357,6 +367,10 @@ public class SuggestionActivity extends ToolBarActivity implements OnRequestCall
|
||||
mFunctionTypeName = getResources().getStringArray(R.array.suggest_function_type);
|
||||
mGameEntity = extras.getParcelable(SimpleGameEntity.class.getSimpleName());
|
||||
fromRating = extras.getBoolean(FROM_RATING_KEY, false);
|
||||
mDiagnosisResult = extras.getString(EntranceUtils.KEY_DIAGNOSIS, "");
|
||||
if (!mDiagnosisResult.isEmpty()) {
|
||||
mDiagnosisMessage = mSuggestContent;
|
||||
}
|
||||
|
||||
setNavigationTitle("意见反馈-" + mSuggestType.getType());
|
||||
|
||||
@ -945,9 +959,7 @@ public class SuggestionActivity extends ToolBarActivity implements OnRequestCall
|
||||
mSuggestEmailEt.requestFocus();
|
||||
mSuggestEmailEt.postDelayed(() -> Util_System_Keyboard.showSoftKeyboard(getApplicationContext(), mSuggestEmailEt), 300);
|
||||
},
|
||||
() -> {
|
||||
postSuggestion(email);
|
||||
});
|
||||
() -> postSuggestion(email));
|
||||
}
|
||||
|
||||
private void postPic(final String email) {
|
||||
@ -1043,11 +1055,11 @@ public class SuggestionActivity extends ToolBarActivity implements OnRequestCall
|
||||
params.put("suggestion_type", "版权申诉");
|
||||
|
||||
sendSuggestion(new JSONObject(params));
|
||||
if (CheckLoginUtils.isLogin()) {
|
||||
// 创建一条信息至七陌客服
|
||||
String feedbackType = "意见反馈-" + mSuggestType.getType();
|
||||
ImManager.sendFeedbackMessage(feedbackType + ": " + mExplanationEt.getText().toString());
|
||||
}
|
||||
// if (CheckLoginUtils.isLogin()) {
|
||||
// // 创建一条信息至七陌客服
|
||||
// String feedbackType = "意见反馈-" + mSuggestType.getType();
|
||||
// ImManager.sendFeedbackMessage(feedbackType + ": " + mExplanationEt.getText().toString());
|
||||
// }
|
||||
}
|
||||
|
||||
private void initPostData(String email, JSONArray picArray) {
|
||||
@ -1067,9 +1079,12 @@ public class SuggestionActivity extends ToolBarActivity implements OnRequestCall
|
||||
|
||||
if (fromRating) {
|
||||
params.put("suggestion_type", mSuggestType.getType() + "(评论)");
|
||||
} else if (!mDiagnosisResult.isEmpty()){
|
||||
params.put("suggestion_type", "网络诊断");
|
||||
} else {
|
||||
params.put("suggestion_type", mSuggestType.getType());
|
||||
}
|
||||
|
||||
if (mGameEntity != null) {
|
||||
params.put("game_id", mGameEntity.getId());
|
||||
}
|
||||
@ -1092,6 +1107,9 @@ public class SuggestionActivity extends ToolBarActivity implements OnRequestCall
|
||||
} else {
|
||||
message = mSuggestGameName.getText() + "-" + mPlatformEt.getText() + "," + content;
|
||||
}
|
||||
} else if (mSuggestType == SuggestType.normal && !mDiagnosisResult.isEmpty()) {
|
||||
message = mDiagnosisMessage;
|
||||
params.put("log", mDiagnosisResult);
|
||||
} else {
|
||||
message = content;
|
||||
if (mSuggestType == SuggestType.crash) {
|
||||
@ -1116,11 +1134,11 @@ public class SuggestionActivity extends ToolBarActivity implements OnRequestCall
|
||||
|
||||
sendSuggestion(jsonObject);
|
||||
|
||||
if (CheckLoginUtils.isLogin()) {
|
||||
// 创建一条信息至七陌客服
|
||||
String feedbackType = "意见反馈-" + mSuggestType.getType();
|
||||
ImManager.sendFeedbackMessage(feedbackType + ": " + message);
|
||||
}
|
||||
// if (CheckLoginUtils.isLogin()) {
|
||||
// // 创建一条信息至七陌客服
|
||||
// String feedbackType = "意见反馈-" + mSuggestType.getType();
|
||||
// ImManager.sendFeedbackMessage(feedbackType + ": " + message);
|
||||
// }
|
||||
}
|
||||
|
||||
private void sendSuggestion(JSONObject jsonObject) {
|
||||
|
||||
@ -223,6 +223,18 @@ public class WebActivity extends NormalActivity {
|
||||
return getTargetIntent(context, WebActivity.class, WebFragment.class, bundle);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static Intent getIntent(Context context, String url, String title, int qaType) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(EntranceUtils.KEY_URL, url);
|
||||
bundle.putString(EntranceUtils.KEY_GAMENAME, title);
|
||||
bundle.putBoolean(WebFragment.KEY_COMPLETION_TITLE, false);
|
||||
bundle.putBoolean(WebFragment.KEY_LEAVE_WEB_PAGE_TO_HANDLE_TITLE, false);
|
||||
bundle.putBoolean(WebFragment.KEY_OPEN_NATIVE_PAGE, false);
|
||||
bundle.putInt(WebFragment.KEY_QA_TYPE, qaType);
|
||||
return getTargetIntent(context, WebActivity.class, WebFragment.class, bundle);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static Intent getIntentByUrl(Context context, String url) {
|
||||
return getIntentByUrl(context, url, false);
|
||||
|
||||
@ -17,6 +17,7 @@ import androidx.core.content.ContextCompat;
|
||||
import com.gh.common.util.BitmapUtils;
|
||||
import com.gh.common.util.MtaHelper;
|
||||
import com.gh.common.util.PackageInstaller;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.KcSelectGameViewHolder;
|
||||
import com.gh.gamecenter.entity.InstallGameEntity;
|
||||
@ -106,7 +107,7 @@ public class CleanApkAdapter extends BaseRecyclerAdapter<KcSelectGameViewHolder>
|
||||
for (String apk_path : mApkPath) {
|
||||
InstallGameEntity apkEntity = new InstallGameEntity();
|
||||
PackageManager pm = mContext.getApplicationContext().getPackageManager();
|
||||
PackageInfo packageInfo = pm.getPackageArchiveInfo(apk_path, PackageManager.GET_ACTIVITIES);
|
||||
PackageInfo packageInfo = pm.getPackageArchiveInfo(apk_path, 0);
|
||||
if (packageInfo == null) continue;
|
||||
|
||||
ApplicationInfo appInfo = packageInfo.applicationInfo;
|
||||
@ -132,7 +133,7 @@ public class CleanApkAdapter extends BaseRecyclerAdapter<KcSelectGameViewHolder>
|
||||
/**安装处理类型*/
|
||||
/** 得到包名 */
|
||||
String packageName = packageInfo.packageName;
|
||||
int type = doType(pm, packageName);
|
||||
int type = doType(packageName);
|
||||
apkEntity.setInstallStatus(type);
|
||||
|
||||
mApkList.add(apkEntity);
|
||||
@ -176,8 +177,8 @@ public class CleanApkAdapter extends BaseRecyclerAdapter<KcSelectGameViewHolder>
|
||||
}
|
||||
}
|
||||
|
||||
private int doType(PackageManager pm, String packageName) {
|
||||
List<PackageInfo> pakageinfos = pm.getInstalledPackages(0);
|
||||
private int doType(String packageName) {
|
||||
List<PackageInfo> pakageinfos = PackageUtils.getInstalledPackages(mContext, 0);
|
||||
for (PackageInfo pi : pakageinfos) {
|
||||
if ((pi.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
|
||||
String pi_packageName = pi.packageName;
|
||||
|
||||
@ -5,12 +5,19 @@ import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.gh.common.dialog.CertificationDialog;
|
||||
import com.gh.common.dialog.DeviceRemindDialog;
|
||||
import com.gh.common.dialog.GameOffServiceDialogFragment;
|
||||
import com.gh.common.dialog.PackageCheckDialogFragment;
|
||||
import com.gh.common.dialog.ReserveDialogFragment;
|
||||
import com.gh.common.exposure.ExposureEvent;
|
||||
import com.gh.common.history.HistoryHelper;
|
||||
import com.gh.common.simulator.SimulatorDownloadManager;
|
||||
import com.gh.common.simulator.SimulatorGameManager;
|
||||
import com.gh.common.util.CheckLoginUtils;
|
||||
import com.gh.common.util.DataLogUtils;
|
||||
import com.gh.common.util.DataUtils;
|
||||
@ -37,13 +44,12 @@ import com.gh.gamecenter.eventbus.EBReuse;
|
||||
import com.gh.gamecenter.gamedetail.GameDetailFragment;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
import com.lightgame.download.FileUtils;
|
||||
import com.lightgame.utils.AppManager;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Created by khy on 27/06/17.
|
||||
@ -161,16 +167,18 @@ public class DetailViewHolder {
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(mViewHolder.context, () -> {
|
||||
if (mGameEntity.getApk().size() == 1) {
|
||||
ApkEntity apk = mGameEntity.getApk().get(0);
|
||||
DownloadDialogHelper.findAvailableDialogAndShow(mViewHolder.context, mGameEntity, apk,
|
||||
() -> {
|
||||
CertificationDialog.showCertificationDialog(mViewHolder.context, mGameEntity, () -> {
|
||||
DialogUtils.showVersionNumberDialog(mViewHolder.context, mGameEntity, () -> {
|
||||
DialogUtils.showOverseaDownloadDialog(mViewHolder.context, mGameEntity, () -> {
|
||||
DialogUtils.checkDownload(mViewHolder.context, apk.getSize(), this::download);
|
||||
});
|
||||
PackageCheckDialogFragment.show((AppCompatActivity) mViewHolder.context, mGameEntity.getPackageDialog(), () -> {
|
||||
DownloadDialogHelper.findAvailableDialogAndShow(mViewHolder.context, mGameEntity, apk, () -> {
|
||||
CertificationDialog.showCertificationDialog(mViewHolder.context, mGameEntity, () -> {
|
||||
DialogUtils.showVersionNumberDialog(mViewHolder.context, mGameEntity, () -> {
|
||||
DialogUtils.showOverseaDownloadDialog(mViewHolder.context, mGameEntity, () -> {
|
||||
DialogUtils.checkDownload(mViewHolder.context, apk.getSize(), this::download);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
} else {
|
||||
CertificationDialog.showCertificationDialog(mViewHolder.context, mGameEntity, () -> {
|
||||
DialogUtils.showVersionNumberDialog(mViewHolder.context, mGameEntity, () -> {
|
||||
@ -187,6 +195,20 @@ public class DetailViewHolder {
|
||||
break;
|
||||
case LAUNCH_OR_OPEN:
|
||||
if (mGameEntity.getApk().size() == 1) {
|
||||
//启动模拟器游戏
|
||||
if (SimulatorGameManager.isSimulatorGame(mGameEntity)) {
|
||||
DownloadEntity downloadEntity = SimulatorGameManager.findDownloadEntityByUrl(mGameEntity.getApk().get(0).getUrl());
|
||||
if (downloadEntity != null) {
|
||||
File file = new File(downloadEntity.getPath());
|
||||
if (!file.exists()) {
|
||||
download(false);
|
||||
return;
|
||||
}
|
||||
SimulatorGameManager.launchSimulatorGame(downloadEntity, mGameEntity);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
DataUtils.onGameLaunchEvent(mViewHolder.context, mGameEntity.getName(), mGameEntity.getApk().get(0).getPlatform(), mName);
|
||||
PackageUtils.launchApplicationByPackageName(mViewHolder.context, mGameEntity.getApk().get(0).getPackageName());
|
||||
} else {
|
||||
@ -202,26 +224,41 @@ public class DetailViewHolder {
|
||||
break;
|
||||
case INSTALL_PLUGIN:
|
||||
case INSTALL_NORMAL:
|
||||
ApkEntity apk = mGameEntity.getApk().get(0);
|
||||
DownloadEntity downloadEntity = SimulatorGameManager.findDownloadEntityByUrl(apk.getUrl());
|
||||
if (mGameEntity.getSimulator() != null) {
|
||||
boolean isInstalled = PackageUtils.isInstalledFromAllPackage(mViewHolder.context, mGameEntity.getSimulator().getApk().getPackageName());
|
||||
if (downloadEntity != null && SimulatorGameManager.isSimulatorGame(mGameEntity) && !isInstalled) {
|
||||
SimulatorDownloadManager.getInstance().showDownloadDialog(mViewHolder.context, mGameEntity.getSimulator(),
|
||||
SimulatorDownloadManager.SimulatorLocation.LAUNCH, mGameEntity.getId(), mGameEntity.getName(), null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(mViewHolder.context, () -> {
|
||||
if (mDownloadEntity == null) {
|
||||
mDownloadEntity = DownloadManager.getInstance(mViewHolder.context).getDownloadEntityByUrl(mGameEntity.getApk().get(0).getUrl());
|
||||
}
|
||||
if (mDownloadEntity != null) {
|
||||
PackageInstaller.install(mViewHolder.context, mDownloadEntity);
|
||||
final String path = mDownloadEntity.getPath();
|
||||
if (FileUtils.isEmptyFile(path)) {
|
||||
Utils.toast(mViewHolder.context, R.string.install_failure_hint);
|
||||
DownloadManager.getInstance(mViewHolder.context).cancel(mDownloadEntity.getUrl());
|
||||
} else {
|
||||
PackageInstaller.install(mViewHolder.context, mDownloadEntity);
|
||||
}
|
||||
}
|
||||
});
|
||||
break;
|
||||
case RESERVABLE:
|
||||
CheckLoginUtils.checkLogin(mViewHolder.context, mEntrance, () -> {
|
||||
PermissionHelper.checkReadPhoneStatePermissionBeforeAction(mViewHolder.context, () -> {
|
||||
ReserveDialogFragment dialogFragment = ReserveDialogFragment.getInstance(
|
||||
mGameEntity,
|
||||
() -> {
|
||||
LogUtils.logReservation(mGameEntity, mTraceEvent);
|
||||
DetailDownloadUtils.detailInitDownload(mViewHolder, false);
|
||||
});
|
||||
dialogFragment.show(((AppCompatActivity) mViewHolder.context).getSupportFragmentManager(), "reserve");
|
||||
});
|
||||
ReserveDialogFragment dialogFragment = ReserveDialogFragment.getInstance(
|
||||
mGameEntity,
|
||||
() -> {
|
||||
LogUtils.logReservation(mGameEntity, mTraceEvent);
|
||||
DetailDownloadUtils.detailInitDownload(mViewHolder, false);
|
||||
});
|
||||
dialogFragment.show(((AppCompatActivity) mViewHolder.context).getSupportFragmentManager(), "reserve");
|
||||
});
|
||||
break;
|
||||
case RESERVED:
|
||||
@ -251,7 +288,9 @@ public class DetailViewHolder {
|
||||
Intent i = new Intent(WebActivity.getIntentForWebGame(mViewHolder.context, linkEntity.getLink(), mGameEntity.getName(), isPlay, linkEntity.getCloseButton()));
|
||||
mViewHolder.context.startActivity(i);
|
||||
break;
|
||||
|
||||
case UPDATING:
|
||||
Utils.toast(mViewHolder.context, "正在加急更新版本,敬请后续留意");
|
||||
break;
|
||||
default:
|
||||
Intent intent = DownloadManagerActivity.getDownloadMangerIntent(mViewHolder.context,
|
||||
mGameEntity.getApk().get(0).getUrl(),
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
package com.gh.gamecenter.adapter.viewholder
|
||||
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import com.gh.base.BaseRecyclerViewHolder
|
||||
import com.gh.gamecenter.R
|
||||
import kotterknife.bindView
|
||||
|
||||
class SimulatorHeaderViewHolder(view: View) : BaseRecyclerViewHolder<Any>(view) {
|
||||
val managerBtn by bindView<TextView>(R.id.btn_manager)
|
||||
val simulatorBtn by bindView<TextView>(R.id.btn_simulator)
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
package com.gh.gamecenter.adapter.viewholder
|
||||
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import com.gh.base.BaseRecyclerViewHolder
|
||||
import com.gh.gamecenter.R
|
||||
import kotterknife.bindView
|
||||
|
||||
class SimulatorManagementViewHolder(view: View) : BaseRecyclerViewHolder<Any>(view) {
|
||||
val simulatorName by bindView<TextView>(R.id.simulator_name)
|
||||
val simulatorInstallBtn by bindView<TextView>(R.id.simulator_install_btn)
|
||||
}
|
||||
@ -63,7 +63,7 @@ class AmwaySearchActivity : SearchActivity() {
|
||||
val transaction = supportFragmentManager.beginTransaction()
|
||||
when (type) {
|
||||
DisplayType.DEFAULT -> {
|
||||
val fragment = supportFragmentManager.findFragmentByTag(AmwaySearchDefaultFragment::class.java.simpleName)
|
||||
val fragment = supportFragmentManager.findFragmentByTag(SearchDefaultFragment::class.java.simpleName)
|
||||
?: AmwaySearchDefaultFragment()
|
||||
transaction.replace(R.id.search_result, fragment, SearchDefaultFragment::class.java.simpleName)
|
||||
}
|
||||
|
||||
@ -44,14 +44,10 @@ class AmwaySearchViewHolder(var binding: AmwaySearchItemBinding, val mViewModel:
|
||||
it.context.showRegulationTestDialogIfNeeded {
|
||||
val installPackageName = mViewModel.canUserCommentThisGame(gameEntity)
|
||||
if (gameEntity.directComment || !installPackageName.isNullOrEmpty()) {
|
||||
PermissionHelper.checkReadPhoneStatePermissionBeforeAction(activity, object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
MtaHelper.onEvent("发表评论", "进入", "选中游戏_${gameEntity.name}")
|
||||
val intent = RatingEditActivity.getIntent(binding.root.context, gameEntity, 0.0F, installPackageName, true)
|
||||
activity.startActivity(intent)
|
||||
activity.finish()
|
||||
}
|
||||
})
|
||||
MtaHelper.onEvent("发表评论", "进入", "选中游戏_${gameEntity.name}")
|
||||
val intent = RatingEditActivity.getIntent(binding.root.context, gameEntity, 0.0F, installPackageName, true)
|
||||
activity.startActivity(intent)
|
||||
activity.finish()
|
||||
} else {
|
||||
Utils.toast(activity, "安装游戏后才能评论哦")
|
||||
}
|
||||
|
||||
@ -0,0 +1,34 @@
|
||||
package com.gh.gamecenter.catalog
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.gh.common.util.EntranceUtils
|
||||
import com.gh.gamecenter.NormalActivity
|
||||
import com.gh.gamecenter.R
|
||||
|
||||
class CatalogActivity : NormalActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setToolbarMenu(R.menu.menu_download)
|
||||
}
|
||||
|
||||
override fun showDownloadMenu(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun provideNormalIntent(): Intent {
|
||||
return getTargetIntent(this, CatalogActivity::class.java, CatalogFragment::class.java)
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun getIntent(context: Context, catalogId: String, catalogTitle: String, entrance: String): Intent {
|
||||
val bundle = Bundle()
|
||||
bundle.putString(EntranceUtils.KEY_CATALOG_ID, catalogId)
|
||||
bundle.putString(EntranceUtils.KEY_CATALOG_TITLE, catalogTitle)
|
||||
bundle.putString(EntranceUtils.KEY_ENTRANCE, entrance)
|
||||
return getTargetIntent(context, CatalogActivity::class.java, CatalogFragment::class.java, bundle)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
package com.gh.gamecenter.catalog
|
||||
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import com.gh.base.BaseRecyclerViewHolder
|
||||
import com.gh.common.util.toColor
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.databinding.CatalogItemBinding
|
||||
import com.gh.gamecenter.entity.CatalogEntity
|
||||
import com.lightgame.adapter.BaseRecyclerAdapter
|
||||
|
||||
class CatalogAdapter(context: Context,
|
||||
private val mFragment: CatalogFragment,
|
||||
private val mViewModel: CatalogViewModel,
|
||||
private val mList: List<CatalogEntity.SubCatalogEntity>)
|
||||
: BaseRecyclerAdapter<CatalogAdapter.CatalogItemViewHolder>(context) {
|
||||
|
||||
override fun getItemCount() = mList.size
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) =
|
||||
CatalogItemViewHolder(DataBindingUtil.inflate(mLayoutInflater, R.layout.catalog_item,parent, false))
|
||||
|
||||
override fun onBindViewHolder(holder: CatalogItemViewHolder, position: Int) {
|
||||
holder.binding.run {
|
||||
val catalogEntity = mList[position]
|
||||
entity = catalogEntity
|
||||
executePendingBindings()
|
||||
if (catalogEntity.name == mViewModel.selectedCatalogName) {
|
||||
selectedTag.visibility = View.VISIBLE
|
||||
catalogName.setTextColor(R.color.theme_font.toColor())
|
||||
root.setBackgroundColor(R.color.white.toColor())
|
||||
} else {
|
||||
selectedTag.visibility = View.GONE
|
||||
catalogName.setTextColor(R.color.text_333333.toColor())
|
||||
root.setBackgroundColor(R.color.text_F5F5F5.toColor())
|
||||
}
|
||||
root.setOnClickListener {
|
||||
if (catalogEntity.name != mViewModel.selectedCatalogName) {
|
||||
mViewModel.selectedCatalogName = catalogEntity.name
|
||||
mViewModel.logSubCatalogClick(position)
|
||||
mFragment.changeCatalog(position)
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class CatalogItemViewHolder(val binding: CatalogItemBinding) : BaseRecyclerViewHolder<Any>(binding.root)
|
||||
}
|
||||
116
app/src/main/java/com/gh/gamecenter/catalog/CatalogFragment.kt
Normal file
116
app/src/main/java/com/gh/gamecenter/catalog/CatalogFragment.kt
Normal file
@ -0,0 +1,116 @@
|
||||
package com.gh.gamecenter.catalog
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.lifecycle.Observer
|
||||
import com.gh.common.util.EntranceUtils
|
||||
import com.gh.common.util.viewModelProviderFromParent
|
||||
import com.gh.common.view.FixLinearLayoutManager
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.databinding.FragmentCatalogBinding
|
||||
import com.gh.gamecenter.entity.CatalogEntity
|
||||
import com.gh.gamecenter.normal.NormalFragment
|
||||
|
||||
class CatalogFragment : NormalFragment() {
|
||||
|
||||
private lateinit var mBinding: FragmentCatalogBinding
|
||||
private lateinit var mViewModel: CatalogViewModel
|
||||
private lateinit var mEntity: CatalogEntity
|
||||
private lateinit var mSpecialCatalogFragment: SpecialCatalogFragment
|
||||
private lateinit var mSubCatalogFragment: SubCatalogFragment
|
||||
|
||||
private var mCatalogId: String = ""
|
||||
private var mCatalogTitle: String = ""
|
||||
|
||||
override fun getLayoutId() = 0
|
||||
|
||||
override fun getInflatedLayout() = FragmentCatalogBinding.inflate(layoutInflater).apply { mBinding = this }.root
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
mCatalogId = arguments?.getString(EntranceUtils.KEY_CATALOG_ID) ?: ""
|
||||
mCatalogTitle = arguments?.getString(EntranceUtils.KEY_CATALOG_TITLE) ?: ""
|
||||
mViewModel = viewModelProviderFromParent(CatalogViewModel.Factory(mCatalogId, mCatalogTitle))
|
||||
|
||||
mViewModel.validEntranceName = if (mEntrance.contains("首页")) "首页" else "板块"
|
||||
mViewModel.logAppearance()
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
setNavigationTitle(mCatalogTitle)
|
||||
mViewModel.catalogs.observe(viewLifecycleOwner, Observer {
|
||||
mBinding.run {
|
||||
reuseLoading.root.visibility = View.GONE
|
||||
if (it != null) {
|
||||
reuseNoConnection.root.visibility = View.GONE
|
||||
if (it.subCatalog.isNotEmpty()) {
|
||||
containerCatalog.visibility = View.VISIBLE
|
||||
reuseNoneData.root.visibility = View.GONE
|
||||
mEntity = it
|
||||
if (mEntity.hasSpecial) {
|
||||
val specialEntity = CatalogEntity.SubCatalogEntity(name = "精选")
|
||||
(mEntity.subCatalog as ArrayList).add(0, specialEntity)
|
||||
}
|
||||
initView()
|
||||
} else {
|
||||
containerCatalog.visibility = View.GONE
|
||||
reuseNoneData.root.visibility = View.VISIBLE
|
||||
}
|
||||
} else {
|
||||
containerCatalog.visibility = View.GONE
|
||||
reuseNoneData.root.visibility = View.GONE
|
||||
reuseNoConnection.root.visibility = View.VISIBLE
|
||||
reuseNoConnection.root.setOnClickListener {
|
||||
reuseLoading.root.visibility = View.VISIBLE
|
||||
mViewModel.getCatalogs()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
mEntity.run {
|
||||
if (subCatalog.isNotEmpty()) {
|
||||
mViewModel.selectedCatalogName = subCatalog[0].name
|
||||
mBinding.rvCatalog.layoutManager = FixLinearLayoutManager(requireContext())
|
||||
mBinding.rvCatalog.adapter = CatalogAdapter(requireContext(), this@CatalogFragment, mViewModel, subCatalog)
|
||||
|
||||
if (hasSpecial) {
|
||||
mSpecialCatalogFragment = childFragmentManager.findFragmentByTag(SpecialCatalogFragment::class.java.simpleName) as? SpecialCatalogFragment ?: SpecialCatalogFragment()
|
||||
mSpecialCatalogFragment.arguments = bundleOf(EntranceUtils.KEY_CATALOG_ID to mEntity.id)
|
||||
childFragmentManager.beginTransaction().replace(R.id.container_sub_catalog, mSpecialCatalogFragment, SpecialCatalogFragment::class.java.simpleName).commitAllowingStateLoss()
|
||||
} else {
|
||||
mSubCatalogFragment = childFragmentManager.findFragmentByTag(SubCatalogFragment::class.java.simpleName) as? SubCatalogFragment ?: SubCatalogFragment()
|
||||
mSubCatalogFragment.arguments = bundleOf(EntranceUtils.KEY_CATALOG_ID to mEntity.id, EntranceUtils.KEY_PRIMARY_CATALOG_ID to subCatalog[0].id)
|
||||
childFragmentManager.beginTransaction().replace(R.id.container_sub_catalog, mSubCatalogFragment, SubCatalogFragment::class.java.simpleName).commitAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun changeCatalog(position: Int) {
|
||||
mEntity.run {
|
||||
if (hasSpecial) {
|
||||
if (mViewModel.selectedCatalogPosition == 0) {
|
||||
mSubCatalogFragment = childFragmentManager.findFragmentByTag(SubCatalogFragment::class.java.simpleName) as? SubCatalogFragment ?: SubCatalogFragment()
|
||||
mSubCatalogFragment.arguments = bundleOf(EntranceUtils.KEY_CATALOG_ID to mEntity.id, EntranceUtils.KEY_PRIMARY_CATALOG_ID to subCatalog[position].id)
|
||||
childFragmentManager.beginTransaction().replace(R.id.container_sub_catalog, mSubCatalogFragment, SubCatalogFragment::class.java.simpleName).commitAllowingStateLoss()
|
||||
} else {
|
||||
if (position == 0) {
|
||||
mSpecialCatalogFragment = childFragmentManager.findFragmentByTag(SpecialCatalogFragment::class.java.simpleName) as? SpecialCatalogFragment ?: SpecialCatalogFragment()
|
||||
mSpecialCatalogFragment.arguments = bundleOf(EntranceUtils.KEY_CATALOG_ID to mEntity.id)
|
||||
childFragmentManager.beginTransaction().replace(R.id.container_sub_catalog, mSpecialCatalogFragment, SpecialCatalogFragment::class.java.simpleName).commitAllowingStateLoss()
|
||||
} else {
|
||||
mSubCatalogFragment.changeSubCatalog(subCatalog[position].id)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mSubCatalogFragment.changeSubCatalog(subCatalog[position].id)
|
||||
}
|
||||
mViewModel.selectedCatalogPosition = position
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,77 @@
|
||||
package com.gh.gamecenter.catalog
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Application
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.gh.common.exposure.ExposureSource
|
||||
import com.gh.common.util.LogUtils
|
||||
import com.gh.gamecenter.entity.CatalogEntity
|
||||
import com.gh.gamecenter.retrofit.BiResponse
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
||||
class CatalogViewModel(application: Application, private val catalogId: String, val catalogTitle: String)
|
||||
: AndroidViewModel(application) {
|
||||
|
||||
private val api = RetrofitManager.getInstance(getApplication()).api
|
||||
var catalogs = MutableLiveData<CatalogEntity>()
|
||||
|
||||
var selectedCatalogName: String = ""
|
||||
var selectedCatalogPosition: Int = 0
|
||||
|
||||
var validEntranceName: String = ""
|
||||
|
||||
val basicExposureSource by lazy { ExposureSource("分类", catalogTitle) }
|
||||
|
||||
init {
|
||||
getCatalogs()
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
fun getCatalogs() {
|
||||
api.getCatalogs(catalogId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : BiResponse<CatalogEntity>() {
|
||||
override fun onSuccess(data: CatalogEntity) {
|
||||
catalogs.postValue(data)
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
super.onFailure(exception)
|
||||
catalogs.postValue(null)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun logAppearance() {
|
||||
LogUtils.logNewCatalogAppearanceEvent(validEntranceName, catalogTitle)
|
||||
}
|
||||
|
||||
fun logSubCatalogClick(position: Int) {
|
||||
LogUtils.logSubCatalogClickEvent(validEntranceName, "${catalogTitle}_${selectedCatalogName}", position)
|
||||
}
|
||||
|
||||
fun logSubCatalogContentClick(itemName: String, listPosition: Int) {
|
||||
LogUtils.logSubCatalogContentClickEvent(validEntranceName, "${catalogTitle}_${selectedCatalogName}_${itemName}", selectedCatalogPosition, listPosition)
|
||||
}
|
||||
|
||||
fun logSpecialCatalogContentClick(contentType: String, contentName: String, listPosition: Int) {
|
||||
LogUtils.logSpecialCatalogContentClickEvent(validEntranceName, "${catalogTitle}_${contentType}_${contentName}", selectedCatalogPosition, listPosition)
|
||||
}
|
||||
|
||||
fun logSpecialCatalogSpecificContentClick(contentType: String, contentName: String, targetName: String, listPosition: Int, specificListPosition: Int) {
|
||||
LogUtils.logSpecialCatalogSpecificContentClickEvent(validEntranceName, "${catalogTitle}_${contentType}_${contentName}_${targetName}", selectedCatalogPosition, listPosition, specificListPosition)
|
||||
}
|
||||
|
||||
class Factory(private val catalogId: String, private val catalogTitle: String) : ViewModelProvider.NewInstanceFactory() {
|
||||
override fun <T : ViewModel> create(modelClass: Class<T>): T {
|
||||
return CatalogViewModel(HaloApp.getInstance().application, catalogId, catalogTitle) as T
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user