Compare commits
10 Commits
v5.19.3-73
...
feature-mo
| Author | SHA1 | Date | |
|---|---|---|---|
| 04468c0627 | |||
| e585d905ac | |||
| 1f066e676f | |||
| a08f3aa9ac | |||
| f799096655 | |||
| 431aa52e49 | |||
| 26d6e4086a | |||
| 7e999784b7 | |||
| f07bcc89e8 | |||
| 22cff4ed72 |
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -8,6 +8,3 @@
|
||||
[submodule "module_common/src/debug/assets/assistant-android-mock"]
|
||||
path = module_common/src/debug/assets/assistant-android-mock
|
||||
url = git@git.shanqu.cc:halo/android/assistant-android-mock.git
|
||||
[submodule "ndownload"]
|
||||
path = ndownload
|
||||
url = git@git.shanqu.cc:android/ndownload.git
|
||||
|
||||
@ -127,7 +127,7 @@ android {
|
||||
variantFilter { variant ->
|
||||
def names = variant.flavors*.name
|
||||
def isDebugType = variant.buildType.name == "debug"
|
||||
if ((names.contains("tea") || name.contains("kuaishou")) && isDebugType) {
|
||||
if ((names.contains("tea")) && isDebugType) {
|
||||
setIgnore(true)
|
||||
}
|
||||
}
|
||||
@ -144,9 +144,6 @@ android {
|
||||
tea {
|
||||
java.srcDirs = ['src/main/java', 'src/tea/java']
|
||||
}
|
||||
kuaishou {
|
||||
java.srcDirs = ['src/main/java', 'src/kuaishou/java']
|
||||
}
|
||||
}
|
||||
|
||||
productFlavors {
|
||||
@ -184,16 +181,6 @@ android {
|
||||
|
||||
manifestPlaceholders.put("APPLOG_SCHEME", "rangersapplog.byAx6uYt".toLowerCase())
|
||||
}
|
||||
|
||||
kuaishou {
|
||||
dimension "env"
|
||||
|
||||
buildConfigField "String", "DEV_API_HOST", "\"${API_HOST}\""
|
||||
buildConfigField "String", "NEW_DEV_API_HOST", "\"${NEW_API_HOST}\""
|
||||
buildConfigField "String", "DEV_VAPI_HOST", "\"${VAPI_HOST}\""
|
||||
buildConfigField "String", "QUICK_LOGIN_APPID", "\"${QUICK_LOGIN_APPID}\""
|
||||
buildConfigField "String", "QUICK_LOGIN_APPKEY", "\"${QUICK_LOGIN_APPKEY}\""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -208,7 +195,6 @@ dependencies {
|
||||
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
|
||||
|
||||
teaImplementation fileTree(include: ['*.jar', '*.aar'], dir: 'src/tea/libs')
|
||||
kuaishouImplementation fileTree(include: ['*.jar', '*.aar'], dir: 'src/kuaishou/libs')
|
||||
testImplementation 'junit:junit:4.12'
|
||||
|
||||
debugImplementation "com.squareup.leakcanary:leakcanary-android:${leakcanary}"
|
||||
@ -274,7 +260,6 @@ dependencies {
|
||||
compileOnly "com.github.axen1314.lancet:lancet-base:${lancet_version}"
|
||||
kapt "com.alibaba:arouter-compiler:$arouterVersion"
|
||||
|
||||
implementation project(':ndownload')
|
||||
implementation project(':vspace-bridge:vspace')
|
||||
|
||||
implementation (project(':module_common')) {
|
||||
@ -283,16 +268,7 @@ dependencies {
|
||||
implementation(project(':module_login')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
implementation(project(':module_setting')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
// implementation(project(':module_setting_compose')) {
|
||||
// exclude group: 'androidx.swiperefreshlayout'
|
||||
// }
|
||||
implementation(project(':module_core_feature')){
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
implementation(project(':module_feedback')) {
|
||||
implementation(project(':module_setting_compose')) {
|
||||
exclude group: 'androidx.swiperefreshlayout'
|
||||
}
|
||||
// 默认不接入光能模块,提高编译速度
|
||||
|
||||
0
module_lib/quick_login_android_5.9.4.aar → app/libs/quick_login_android_5.9.4.aar
Normal file → Executable file
0
module_lib/quick_login_android_5.9.4.aar → app/libs/quick_login_android_5.9.4.aar
Normal file → Executable file
@ -17,30 +17,15 @@
|
||||
-dontwarn com.j256.**
|
||||
|
||||
### app models
|
||||
-keep class com.gh.common.view.* {*;}
|
||||
-keep class com.gh.gamecenter.db.info.* {*;}
|
||||
-keep class com.gh.gamecenter.entity.** {<fields>;}
|
||||
-keep class com.gh.gamecenter.qa.entity.** {<fields>;}
|
||||
-keep class com.gh.gamecenter.BR
|
||||
-keep class com.gh.gamecenter.entity.* {*;}
|
||||
-keep class com.gh.gamecenter.qa.entity.* {*;}
|
||||
-keep class com.gh.gamecenter.retrofit.* {*;}
|
||||
-keep class com.gh.gamecenter.eventbus.* {*;}
|
||||
-keep class com.gh.gamecenter.home.gamecollection.GameCollectionStackLayout {*;}
|
||||
-keep class com.gh.gamecenter.home.gamecollection.GameCollectionStackAnimation {*;}
|
||||
-keep class com.gh.gamecenter.video.detail.* {*;}
|
||||
-keep class com.gh.gamecenter.home.gamecollection.* {*;}
|
||||
|
||||
# Prevent R8 from leaving Data object members always null
|
||||
-keepclassmembers,allowobfuscation class * {
|
||||
@com.google.gson.annotations.SerializedName <fields>;
|
||||
}
|
||||
|
||||
# Prevent proguard from stripping interface information from TypeAdapter, TypeAdapterFactory,
|
||||
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
|
||||
-keep class * extends com.google.gson.TypeAdapter
|
||||
-keep class * implements com.google.gson.TypeAdapterFactory
|
||||
-keep class * implements com.google.gson.JsonSerializer
|
||||
-keep class * implements com.google.gson.JsonDeserializer
|
||||
|
||||
# Retain generic signatures of TypeToken and its subclasses with R8 version 3.0 and higher.
|
||||
-keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken
|
||||
-keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken
|
||||
|
||||
# TODO What's this ?
|
||||
-ignorewarnings
|
||||
@ -54,7 +39,7 @@
|
||||
-dontwarn com.shuyu.gsyvideoplayer.utils.**
|
||||
-keep class tv.danmaku.ijk.* { *; }
|
||||
-dontwarn tv.danmaku.ijk.**
|
||||
-keep public class * extends android.view.View {
|
||||
-keep public class * extends android.view.View{
|
||||
*** get*();
|
||||
void set*(***);
|
||||
public <init>(android.content.Context);
|
||||
@ -69,4 +54,15 @@
|
||||
-keep class com.lzf.easyfloat.* {*;}
|
||||
|
||||
### dokit
|
||||
-keep class com.didichuxing.** {*;}
|
||||
-keep class com.didichuxing.** {*;}
|
||||
|
||||
# Flutter模块
|
||||
-keep class com.gh.common.util.DirectUtils {
|
||||
public static void directToQa(...);
|
||||
public static void directToQaCollection(...);
|
||||
public static void directToGift(...);
|
||||
public static void directToConcernInfo(...);
|
||||
public static void directToFeedback(...);
|
||||
public static void directToSuggestion(...);
|
||||
}
|
||||
|
||||
|
||||
@ -1,16 +1,14 @@
|
||||
package com.gh.gamecenter.provider
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Application
|
||||
import android.text.TextUtils
|
||||
import com.gh.gamecenter.common.constant.Config
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.utils.PackageFlavorHelper
|
||||
import com.gh.gamecenter.core.provider.IFlavorProvider
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.leon.channel.helper.ChannelReaderUtil
|
||||
|
||||
class FlavorProviderImp : IFlavorProvider {
|
||||
class ChannelProviderImp : ChannelProvider {
|
||||
override fun getChannelStr(application: Application): String {
|
||||
var channel = ChannelReaderUtil.getChannel(application)
|
||||
if (channel == null || TextUtils.isEmpty(channel.trim())) {
|
||||
@ -25,12 +23,4 @@ class FlavorProviderImp : IFlavorProvider {
|
||||
}
|
||||
return channel
|
||||
}
|
||||
|
||||
override fun init(application: Application, activity: Activity) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
override fun logEvent(content: String) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
package com.gh.gamecenter
|
||||
|
||||
import android.content.Context
|
||||
import com.kwai.monitor.log.TurboAgent
|
||||
import com.kwai.monitor.log.TurboConfig
|
||||
|
||||
object KuaishouHelper {
|
||||
private const val APP_ID = "80655"
|
||||
private const val APP_NAME = "guanghuanzhushou_1"
|
||||
|
||||
@JvmStatic
|
||||
fun init(context: Context, channel: String) {
|
||||
TurboAgent.init(
|
||||
TurboConfig.TurboConfigBuilder.create(context)
|
||||
.setAppId(APP_ID)
|
||||
.setAppName(APP_NAME)
|
||||
.setAppChannel(channel)
|
||||
.build()
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun onEvent(type: String) {
|
||||
when (type) {
|
||||
"EVENT_ACTIVE" -> TurboAgent.onAppActive()
|
||||
"active_register" -> TurboAgent.onRegister()
|
||||
"EVENT_NEXTDAY_STAY" -> TurboAgent.onNextDayStay()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,48 +0,0 @@
|
||||
package com.gh.gamecenter.provider
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Application
|
||||
import android.text.TextUtils
|
||||
import com.gh.gamecenter.KuaishouHelper
|
||||
import com.gh.gamecenter.core.provider.IFlavorProvider
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.core.utils.TimeUtils
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.leon.channel.helper.ChannelReaderUtil
|
||||
|
||||
class FlavorProviderImp : IFlavorProvider {
|
||||
|
||||
override fun init(application: Application, activity: Activity) {
|
||||
KuaishouHelper.init(application, getChannelStr(application))
|
||||
|
||||
if (HaloApp.getInstance().isBrandNewInstall) {
|
||||
logEvent("EVENT_ACTIVE")
|
||||
SPUtils.setLong("TIME_OF_BRAND_NEW_INSTALL", System.currentTimeMillis() / 1000)
|
||||
} else {
|
||||
val shouldSendRetentionLogEvent =
|
||||
SPUtils.getBoolean("SHOULD_SEND_RETENTION_EVENT", true)
|
||||
val installTimeNotToday =
|
||||
!TimeUtils.isToday(SPUtils.getLong("TIME_OF_BRAND_NEW_INSTALL", System.currentTimeMillis() / 1000))
|
||||
if (shouldSendRetentionLogEvent && installTimeNotToday) {
|
||||
logEvent("EVENT_NEXTDAY_STAY")
|
||||
SPUtils.setBoolean("SHOULD_SEND_RETENTION_EVENT", false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getChannelStr(application: Application): String {
|
||||
var channel = ChannelReaderUtil.getChannel(application)
|
||||
if (channel == null || TextUtils.isEmpty(channel.trim())) {
|
||||
channel = KUAISHOU_CHANNEL
|
||||
}
|
||||
return channel
|
||||
}
|
||||
|
||||
override fun logEvent(content: String) {
|
||||
KuaishouHelper.onEvent(content)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val KUAISHOU_CHANNEL = "KS-GHZS-01"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@ -6,11 +6,6 @@
|
||||
<queries>
|
||||
<package android:name="com.gh.gamecenter" />
|
||||
</queries>
|
||||
|
||||
<queries>
|
||||
<package android:name="com.lg.vspace" />
|
||||
</queries>
|
||||
|
||||
<!-- 允许应用程序访问网络连接 -->
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<!-- 允许应用程序写入外部存储,如SD卡上写文件 -->
|
||||
@ -254,6 +249,9 @@
|
||||
android:configChanges="orientation|screenSize|keyboardHidden"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.SuggestionActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.VoteActivity"
|
||||
android:screenOrientation="portrait"
|
||||
@ -437,6 +435,10 @@
|
||||
android:name="com.gh.gamecenter.qa.editor.LocalMediaActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.mygame.PlayedGameActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.servers.GameServersActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
@ -453,6 +455,15 @@
|
||||
android:name="com.halo.assistant.fragment.user.UserPortraitCropImageActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.HelpAndFeedbackActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.help.HelpDetailActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.qa.comment.CommentActivity"
|
||||
android:theme="@style/Theme.Transparent"
|
||||
@ -476,6 +487,10 @@
|
||||
android:name="com.gh.gamecenter.gamedetail.fuli.kaifu.ServersCalendarActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name="com.gh.gamecenter.QaActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".qa.answer.draft.AnswerDraftActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
@ -714,19 +729,6 @@
|
||||
android:name=".discovery.DiscoveryActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".cloudarchive.CloudArchiveManagerActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".savegame.GameArchiveListActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".discovery.interestedgame.InterestedGameActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
|
||||
<!-- <activity-->
|
||||
<!-- android:name="${applicationId}.douyinapi.DouYinEntryActivity"-->
|
||||
<!-- android:launchMode="singleTask"-->
|
||||
@ -749,26 +751,6 @@
|
||||
android:enabled="true"
|
||||
android:exported="true" />
|
||||
|
||||
<provider
|
||||
android:name="com.gh.vspace.VFileProvider"
|
||||
android:authorities="${applicationId}.virtual_file_provider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/provider_paths" />
|
||||
</provider>
|
||||
|
||||
|
||||
<service
|
||||
android:name=".aidl.CommunicationService"
|
||||
android:enabled="true"
|
||||
android:exported="true" >
|
||||
<intent-filter>
|
||||
<action android:name="com.gh.gamecenter.aidl.CommunicationService"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<!-- <provider-->
|
||||
<!-- android:name="androidx.startup.InitializationProvider"-->
|
||||
<!-- android:authorities="${applicationId}.androidx-startup"-->
|
||||
|
||||
BIN
app/src/main/assets/fonts/d_din_bold.ttf
Normal file
BIN
app/src/main/assets/fonts/d_din_bold.ttf
Normal file
Binary file not shown.
Binary file not shown.
@ -1 +0,0 @@
|
||||
{"v":"5.9.1","fr":60,"ip":0,"op":100,"w":64,"h":64,"nm":"多版本下载提示_dark","ddd":0,"assets":[{"id":"comp_0","nm":"arrow 合成_dark","fr":60,"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"arrow","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.333],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":0,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":24,"s":[100]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.667],"y":[0]},"t":76,"s":[100]},{"t":100,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.333,"y":1},"o":{"x":0.364,"y":0},"t":0,"s":[28,-12,0],"to":[0,6.382,0],"ti":[0,-0.284,0]},{"i":{"x":0.667,"y":0.667},"o":{"x":0.333,"y":0.333},"t":24,"s":[28,28,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.667,"y":1},"o":{"x":0.667,"y":0},"t":76,"s":[28,28,0],"to":[0,6.667,0],"ti":[0,-6.667,0]},{"t":100,"s":[28,68,0]}],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[0,2],[0,-2]],"c":false},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ind":1,"ty":"sh","ix":2,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[-2,0],[0,2]],"c":false},"ix":2},"nm":"路径 2","mn":"ADBE Vector Shape - Group","hd":false},{"ind":2,"ty":"sh","ix":3,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[2,0],[0,2]],"c":false},"ix":2},"nm":"路径 3","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.333,0.333],"y":[1,1]},"o":{"x":[0.333,0.333],"y":[0,0]},"t":0,"s":[80,120]},{"i":{"x":[0.667,0.667],"y":[1,1]},"o":{"x":[0.667,0.667],"y":[0,0]},"t":24,"s":[100,100]},{"i":{"x":[0.667,0.667],"y":[1,1]},"o":{"x":[0.667,0.667],"y":[0,0]},"t":76,"s":[100,100]},{"t":100,"s":[80,120]}],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.156862750649,0.533333361149,0.878431379795,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"stroke","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[400,400],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"Vector 97","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":100,"st":0,"bm":0}]}],"layers":[{"ddd":0,"ind":1,"ty":0,"nm":"arrow 合成_dark","refId":"comp_0","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[32,32,0],"ix":2,"l":2},"a":{"a":0,"k":[28,28,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"w":56,"h":56,"ip":0,"op":100,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"base","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[32,32,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[15,15],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"椭圆路径 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[0.156862750649,0.533333361149,0.878431379795,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"stroke","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0.137254908681,0.137254908681,0.137254908681,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"filling","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[400,400],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"Ellipse 44","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":100,"st":0,"bm":0}],"markers":[]}
|
||||
@ -1 +0,0 @@
|
||||
{"v":"5.9.1","fr":60,"ip":0,"op":100,"w":64,"h":64,"nm":"多版本下载提示_light","ddd":0,"assets":[{"id":"comp_0","nm":"arrow 合成_light","fr":60,"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"arrow","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.333],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":0,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":24,"s":[100]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.667],"y":[0]},"t":76,"s":[100]},{"t":100,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.333,"y":1},"o":{"x":0.364,"y":0},"t":0,"s":[28,-12,0],"to":[0,6.382,0],"ti":[0,-0.284,0]},{"i":{"x":0.667,"y":0.667},"o":{"x":0.333,"y":0.333},"t":24,"s":[28,28,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.667,"y":1},"o":{"x":0.667,"y":0},"t":76,"s":[28,28,0],"to":[0,6.667,0],"ti":[0,-6.667,0]},{"t":100,"s":[28,68,0]}],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[0,2],[0,-2]],"c":false},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ind":1,"ty":"sh","ix":2,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[-2,0],[0,2]],"c":false},"ix":2},"nm":"路径 2","mn":"ADBE Vector Shape - Group","hd":false},{"ind":2,"ty":"sh","ix":3,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[2,0],[0,2]],"c":false},"ix":2},"nm":"路径 3","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.333,0.333],"y":[1,1]},"o":{"x":[0.333,0.333],"y":[0,0]},"t":0,"s":[80,120]},{"i":{"x":[0.667,0.667],"y":[1,1]},"o":{"x":[0.667,0.667],"y":[0,0]},"t":24,"s":[100,100]},{"i":{"x":[0.667,0.667],"y":[1,1]},"o":{"x":[0.667,0.667],"y":[0,0]},"t":76,"s":[100,100]},{"t":100,"s":[80,120]}],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.141176477075,0.588235318661,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"stroke","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[400,400],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"Vector 97","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":100,"st":0,"bm":0}]}],"layers":[{"ddd":0,"ind":1,"ty":0,"nm":"arrow 合成_light","refId":"comp_0","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[32,32,0],"ix":2,"l":2},"a":{"a":0,"k":[28,28,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"w":56,"h":56,"ip":0,"op":100,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"base","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[32,32,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[15,15],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"椭圆路径 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[0.141176477075,0.588235318661,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"stroke","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"filling","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[400,400],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"Ellipse 44","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":100,"st":0,"bm":0}],"markers":[]}
|
||||
@ -6,7 +6,6 @@ import android.app.Activity
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.view.View
|
||||
@ -26,10 +25,9 @@ import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.core.runOnIoThread
|
||||
import com.gh.gamecenter.core.utils.*
|
||||
import com.gh.gamecenter.entity.*
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.qa.editor.*
|
||||
import com.gh.gamecenter.feature.entity.AnswerEntity
|
||||
import com.gh.gamecenter.feature.entity.ArticleEntity
|
||||
import com.gh.gamecenter.qa.entity.AnswerEntity
|
||||
import com.gh.gamecenter.qa.entity.ArticleEntity
|
||||
import com.gh.gamecenter.qa.entity.EditorInsertEntity
|
||||
import com.gh.gamecenter.video.poster.PosterEditActivity
|
||||
import com.gh.gamecenter.video.upload.UploadManager
|
||||
@ -216,8 +214,6 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
mKeyboardHeightProvider = KeyboardHeightProvider(this)
|
||||
mRichEditor.post { mKeyboardHeightProvider?.start() }
|
||||
mRichEditor.enableForceDark(DarkModeUtils.isDarkModeOn(this))
|
||||
mRichEditor.setEditorBackgroundColor(R.color.background_white.toColor(this))
|
||||
mRichEditor.setEditorFontColor(if (mIsDarkModeOn) Color.parseColor("#C2C2C2") else Color.parseColor("#4A4A4A"))
|
||||
// 防止个别手机在Js里无法获取粘贴内容
|
||||
mRichEditor.addJavascriptInterface(OnPasteListener(), "onPasteListener")
|
||||
mRichEditor.addJavascriptInterface(OnCursorChangeListener(), "OnCursorChangeListener")
|
||||
@ -477,14 +473,14 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
private fun chooseImage() {
|
||||
MtaHelper.onEvent(mtaEventName(), "插入图片", "插入图片")
|
||||
val imageCount = mViewModel.quoteCountEntity.imageCount
|
||||
if (imageCount >= MAX_IMAGE_COUNT) {
|
||||
if (imageCount >= MAX_MEDIA_COUNT) {
|
||||
toast(R.string.answer_edit_max_img_hint)
|
||||
return
|
||||
}
|
||||
try {
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(this, object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
val maxChooseCount = if (imageCount + 10 <= MAX_IMAGE_COUNT) 10 else MAX_IMAGE_COUNT - imageCount
|
||||
val maxChooseCount = if (imageCount + 10 <= MAX_MEDIA_COUNT) 10 else MAX_MEDIA_COUNT - imageCount
|
||||
val intent = LocalMediaActivity.getIntent(
|
||||
this@BaseRichEditorActivity,
|
||||
LocalMediaActivity.ChooseType.IMAGE,
|
||||
@ -754,8 +750,6 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
super.onDarkModeChanged()
|
||||
updateStatusBarColor(R.color.background_white, R.color.background_white)
|
||||
mRichEditor.enableForceDark(DarkModeUtils.isDarkModeOn(this))
|
||||
mRichEditor.setEditorBackgroundColor(R.color.background_white.toColor(this))
|
||||
mRichEditor.setEditorFontColor(if (mIsDarkModeOn) Color.parseColor("#C2C2C2") else Color.parseColor("#4A4A4A"))
|
||||
}
|
||||
|
||||
companion object {
|
||||
@ -776,7 +770,6 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
const val INSERT_VIDEO_CODE = 415
|
||||
const val MAX_INPUT_TEXT_NUM = 10000
|
||||
const val MAX_MEDIA_COUNT = 20
|
||||
const val MAX_IMAGE_COUNT = 35
|
||||
|
||||
const val REQUEST_CODE_IMAGE = 120
|
||||
const val INSERT_MEDIA_VIDEO_CODE = 121
|
||||
|
||||
@ -9,17 +9,16 @@ import android.text.TextUtils
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.MediatorLiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.base.fragment.WaitingDialogFragment
|
||||
import com.gh.gamecenter.common.retrofit.Response
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.runOnUiThread
|
||||
import com.gh.gamecenter.core.utils.MD5Utils
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.common.entity.ErrorEntity
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.utils.*
|
||||
import com.gh.gamecenter.entity.ErrorEntity
|
||||
import com.gh.gamecenter.entity.LocalVideoEntity
|
||||
import com.gh.gamecenter.entity.QuoteCountEntity
|
||||
import com.gh.gamecenter.qa.BbsType
|
||||
import com.gh.gamecenter.common.retrofit.Response
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.gh.gamecenter.retrofit.service.ApiService
|
||||
import com.gh.gamecenter.video.upload.OnUploadListener
|
||||
@ -33,12 +32,20 @@ import okhttp3.ResponseBody
|
||||
import retrofit2.HttpException
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.util.*
|
||||
import kotlin.collections.HashMap
|
||||
import kotlin.collections.LinkedHashMap
|
||||
import kotlin.collections.List
|
||||
import kotlin.collections.Map
|
||||
import kotlin.collections.find
|
||||
import kotlin.collections.forEach
|
||||
import kotlin.collections.set
|
||||
|
||||
// TODO: 移动到module_bbs模块
|
||||
abstract class BaseRichEditorViewModel(application: Application) : AndroidViewModel(application) {
|
||||
val mApi: ApiService = RetrofitManager.getInstance().api
|
||||
val processDialog = MediatorLiveData<WaitingDialogFragment.WaitingDialogData>()
|
||||
val uploadingImage = ArrayList<LinkedHashMap<String, String>>()
|
||||
val chooseImagesUpload = MutableLiveData<LinkedHashMap<String, String>>()
|
||||
val chooseImagesUploadSuccess = MutableLiveData<LinkedHashMap<String, String>>()
|
||||
var uploadImageSubscription: Disposable? = null
|
||||
@ -63,10 +70,7 @@ abstract class BaseRichEditorViewModel(application: Application) : AndroidViewMo
|
||||
//检查图片是否符合规则并上传图片
|
||||
fun uploadPic(data: Intent) {
|
||||
val uris = Matisse.obtainResult(data)
|
||||
val rawImgUrlList = ArrayList<String>() // 需要上传图片的原始地址列表
|
||||
val uploadingImgList = ArrayList<String>() // 正在上传图片的地址列表(已压缩处理)
|
||||
val compressedImgUrlList = ArrayList<String>() // 压缩处理后图片的地址列表
|
||||
|
||||
val pictureList = ArrayList<String>()
|
||||
for (uri in uris) {
|
||||
val picturePath = PathUtils.getPath(getApplication(), uri)
|
||||
if (picturePath != null) {
|
||||
@ -80,12 +84,12 @@ abstract class BaseRichEditorViewModel(application: Application) : AndroidViewMo
|
||||
continue
|
||||
}
|
||||
Utils.log("picturePath = $picturePath")
|
||||
rawImgUrlList.add(picturePath)
|
||||
pictureList.add(picturePath)
|
||||
} else {
|
||||
Utils.log("picturePath is null")
|
||||
}
|
||||
}
|
||||
if (rawImgUrlList.size == 0) return
|
||||
if (pictureList.size == 0) return
|
||||
val imageType = when (getRichType()) {
|
||||
RichType.ARTICLE -> UploadImageUtils.UploadType.community_article
|
||||
RichType.QUESTION -> UploadImageUtils.UploadType.question
|
||||
@ -93,7 +97,7 @@ abstract class BaseRichEditorViewModel(application: Application) : AndroidViewMo
|
||||
}
|
||||
uploadImageSubscription = UploadImageUtils.compressAndUploadImageList(
|
||||
imageType,
|
||||
rawImgUrlList,
|
||||
pictureList,
|
||||
false,
|
||||
object : UploadImageUtils.OnUploadImageListListener {
|
||||
override fun onProgress(total: Long, progress: Long) {}
|
||||
@ -103,108 +107,87 @@ abstract class BaseRichEditorViewModel(application: Application) : AndroidViewMo
|
||||
imageUrls.forEach {
|
||||
chooseImageMd5Map[MD5Utils.getUrlMD5(it)] = ""
|
||||
}
|
||||
uploadingImgList.addAll(imageUrls)
|
||||
compressedImgUrlList.addAll(imageUrls)
|
||||
uploadingImage.add(chooseImageMd5Map)
|
||||
chooseImagesUpload.postValue(chooseImageMd5Map)
|
||||
}
|
||||
|
||||
override fun onSingleSuccess(imageUrlMap: Map<String, String>) {
|
||||
imageUrlMap.forEach {
|
||||
if (uploadingImgList.contains(it.key)) {
|
||||
uploadingImgList.remove(it.key)
|
||||
}
|
||||
}
|
||||
override fun onSingleSuccess(imageUrl: Map<String, String>) {
|
||||
val map = LinkedHashMap<String, String>()
|
||||
for (key in imageUrlMap.keys) {
|
||||
for (key in imageUrl.keys) {
|
||||
map[MD5Utils.getUrlMD5(key)] = FILE_HOST + key.decodeURI()
|
||||
mapImages[TextUtils.htmlEncode(key).decodeURI()] = imageUrlMap[key] ?: ""
|
||||
mapImages[TextUtils.htmlEncode(key).decodeURI()] = imageUrl[key] ?: ""
|
||||
}
|
||||
chooseImagesUploadSuccess.value = map
|
||||
chooseImagesUploadSuccess.postValue(map)
|
||||
}
|
||||
|
||||
override fun onSuccess(imageUrlMap: LinkedHashMap<String, String>, errorMap: Map<String, Exception>) {
|
||||
imageUrlMap.forEach {
|
||||
if (uploadingImgList.contains(it.key)) {
|
||||
uploadingImgList.remove(it.key)
|
||||
}
|
||||
override fun onSuccess(
|
||||
imageUrl: LinkedHashMap<String, String>,
|
||||
errorMap: Map<String, Exception>
|
||||
) {
|
||||
val uploadMap = uploadingImage.find {
|
||||
it.containsKey(
|
||||
MD5Utils.getUrlMD5(
|
||||
imageUrl.entries.iterator().next().key
|
||||
)
|
||||
)
|
||||
}
|
||||
uploadMap?.let {
|
||||
uploadingImage.remove(uploadMap)
|
||||
}
|
||||
|
||||
var errorSize = compressedImgUrlList.size - imageUrlMap.size
|
||||
if (errorSize > 0 || uploadingImgList.isNotEmpty()) {
|
||||
val errorImageMap = LinkedHashMap<String, String>()
|
||||
val errorSize = pictureList.size - imageUrl.size
|
||||
if (errorSize > 0) {
|
||||
val map = LinkedHashMap<String, String>()
|
||||
for (key in errorMap.keys) {
|
||||
errorImageMap[MD5Utils.getUrlMD5(key)] = ""
|
||||
map[MD5Utils.getUrlMD5(key)] = ""
|
||||
}
|
||||
//value为空会删除PlaceholderImage
|
||||
chooseImagesUploadSuccess.postValue(map)
|
||||
|
||||
for (rawImgUrl in compressedImgUrlList) {
|
||||
if (!imageUrlMap.containsKey(rawImgUrl)) {
|
||||
errorImageMap[MD5Utils.getUrlMD5(rawImgUrl)] = ""
|
||||
for (error in errorMap.values) {
|
||||
if (error is HttpException && error.code() == 403) {
|
||||
Utils.toast(getApplication(), errorSize.toString() + "张违规图片上传失败")
|
||||
return
|
||||
}
|
||||
}
|
||||
errorSize = if (errorMap.isEmpty()) {
|
||||
errorImageMap.size
|
||||
} else {
|
||||
errorMap.size + errorImageMap.size
|
||||
}
|
||||
|
||||
// value为空会删除PlaceholderImage
|
||||
chooseImagesUploadSuccess.value = errorImageMap
|
||||
|
||||
if (handleUploadError(errorSize, errorMap)) return
|
||||
|
||||
if (errorSize > 0) {
|
||||
ToastUtils.showToast(errorSize.toString() + "张图片上传失败")
|
||||
}
|
||||
Utils.toast(getApplication(), errorSize.toString() + "张图片上传失败")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onError(errorMap: Map<String, Exception>) {
|
||||
val errorSize = uploadingImgList.size
|
||||
if (uploadingImgList.size > 0) {
|
||||
val errorSize = errorMap.size
|
||||
if (errorSize > 0) {
|
||||
val map = LinkedHashMap<String, String>()
|
||||
for (key in uploadingImgList) {
|
||||
for (key in errorMap.keys) {
|
||||
map[MD5Utils.getUrlMD5(key)] = ""
|
||||
}
|
||||
// value为空会删除PlaceholderImage
|
||||
chooseImagesUploadSuccess.value = map
|
||||
//value为空会删除PlaceholderImage
|
||||
chooseImagesUploadSuccess.postValue(map)
|
||||
}
|
||||
|
||||
if (handleUploadError(errorSize, errorMap)) return
|
||||
|
||||
if (errorSize == 0) return
|
||||
|
||||
for (error in errorMap.values) {
|
||||
if (error is HttpException && error.code() == 403) {
|
||||
val e = error.response()?.errorBody()?.string()?.toObject<ErrorEntity>()
|
||||
if (e != null && e.code == 403017) {
|
||||
Utils.toast(
|
||||
getApplication(),
|
||||
errorSize.toString() + "张图片的宽或高超过限制,请裁剪后上传"
|
||||
)
|
||||
} else {
|
||||
Utils.toast(getApplication(), errorSize.toString() + "张违规图片上传失败")
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
if (errorSize == 1) {
|
||||
ToastUtils.showToast("图片上传失败")
|
||||
Utils.toast(getApplication(), "图片上传失败")
|
||||
} else {
|
||||
ToastUtils.showToast(errorSize.toString() + "张图片上传失败")
|
||||
Utils.toast(getApplication(), errorSize.toString() + "张图片上传失败")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理上传错误 (包括超时 cancel 的异常)
|
||||
* @return 如果 toast 过了就返回 true
|
||||
*/
|
||||
private fun handleUploadError(
|
||||
errorSize: Int,
|
||||
errorMap: Map<String, Exception>
|
||||
): Boolean {
|
||||
for (error in errorMap.values) {
|
||||
if (error is HttpException && error.code() == 403) {
|
||||
val e = error.response()?.errorBody()?.string()?.toObject<ErrorEntity>()
|
||||
if (e != null && e.code == 403017) {
|
||||
ToastUtils.showToast(errorSize.toString() + "张图片的宽或高超过限制,请裁剪后上传")
|
||||
} else {
|
||||
ToastUtils.showToast(errorSize.toString() + "张违规图片上传失败")
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
fun uploadPoster(picturePath: String) {
|
||||
processDialog.postValue(WaitingDialogFragment.WaitingDialogData("封面上传中...", true))
|
||||
uploadImageSubscription =
|
||||
|
||||
@ -6,9 +6,14 @@ import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.gh.common.util.FloatingBackViewManager
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.SingletonWebActivity
|
||||
import com.gh.gamecenter.MainActivity
|
||||
import com.gh.gamecenter.SplashScreenActivity
|
||||
import com.gh.gamecenter.common.utils.PackageFlavorHelper
|
||||
import com.gh.gamecenter.forum.detail.ForumDetailActivity
|
||||
import com.gh.gamecenter.forum.list.ForumListActivity
|
||||
import com.gh.gamecenter.qa.article.detail.ArticleDetailActivity
|
||||
import com.gh.gamecenter.qa.questions.newdetail.NewQuestionDetailActivity
|
||||
import com.gh.gamecenter.qa.video.detail.ForumVideoDetailActivity
|
||||
import com.gh.vspace.VHelper
|
||||
import com.halo.assistant.HaloApp
|
||||
|
||||
@ -30,7 +35,7 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
||||
&& FloatingBackViewManager.getType() == FloatingBackViewManager.TYPE_TASK
|
||||
) {
|
||||
FloatingBackViewManager.disableBackView()
|
||||
} else if (activity is SingletonWebActivity
|
||||
} else if (!shouldShowActivityBackView(activity)
|
||||
&& FloatingBackViewManager.getType() == FloatingBackViewManager.TYPE_ACTIVITY
|
||||
) {
|
||||
FloatingBackViewManager.disableBackView()
|
||||
@ -60,6 +65,15 @@ class GlobalActivityLifecycleObserver : Application.ActivityLifecycleCallbacks {
|
||||
}
|
||||
}
|
||||
|
||||
private fun shouldShowActivityBackView(activity: Activity): Boolean {
|
||||
return (activity is MainActivity
|
||||
|| activity is ArticleDetailActivity
|
||||
|| activity is ForumVideoDetailActivity
|
||||
|| activity is ForumDetailActivity
|
||||
|| activity is ForumListActivity
|
||||
|| activity is NewQuestionDetailActivity)
|
||||
}
|
||||
|
||||
override fun onActivityPaused(activity: Activity) {
|
||||
FloatingBackViewManager.dismissBackView()
|
||||
if (PackageFlavorHelper.IS_TEST_FLAVOR && activity is AppCompatActivity) {
|
||||
|
||||
@ -4,38 +4,33 @@ import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.util.Base64
|
||||
import android.view.View
|
||||
import android.webkit.JavascriptInterface
|
||||
import androidx.annotation.Keep
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.gh.common.util.*
|
||||
import com.gh.common.util.LogUtils
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.download.PackageObserver
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.gh.gamecenter.ImageViewerActivity
|
||||
import com.gh.gamecenter.WebActivity
|
||||
import com.gh.gamecenter.common.callback.BiCallback
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.common.entity.NotificationUgc
|
||||
import com.gh.gamecenter.common.loghub.LoghubUtils
|
||||
import com.gh.gamecenter.common.provider.IHelpAndFeedbackProvider
|
||||
import com.gh.gamecenter.common.tracker.Tracker
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.common.view.dsbridge.CompletionHandler
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.core.runOnIoThread
|
||||
import com.gh.gamecenter.core.runOnUiThread
|
||||
import com.gh.gamecenter.core.utils.*
|
||||
import com.gh.gamecenter.core.utils.CurrentActivityHolder
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.core.utils.MtaHelper
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.energy.EnergyBridge
|
||||
import com.gh.gamecenter.eventbus.EBPackage
|
||||
import com.gh.gamecenter.feature.entity.Badge
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.MtaEvent
|
||||
import com.gh.gamecenter.help.QaFeedbackDialogFragment
|
||||
import com.gh.gamecenter.login.entity.Badge
|
||||
import com.gh.gamecenter.login.user.LoginTag
|
||||
import com.gh.gamecenter.login.user.UserManager
|
||||
import com.gh.gamecenter.login.user.UserRepository
|
||||
@ -43,12 +38,9 @@ import com.gh.gamecenter.login.utils.LoginHelper
|
||||
import com.gh.gamecenter.login.utils.QuickLoginHelper
|
||||
import com.gh.gamecenter.login.view.LoginActivity
|
||||
import com.gh.gamecenter.personalhome.border.AvatarBorderActivity
|
||||
import com.gh.gamecenter.setting.SettingBridge
|
||||
import com.gh.vspace.VHelper
|
||||
import com.gh.gamecenter.setting.compose.activity.ComposeAboutActivity
|
||||
import com.gh.gamecenter.setting.compose.activity.ComposeBindPhoneActivity
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.download.DataWatcher
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import com.lightgame.download.DownloadStatus.*
|
||||
import com.lightgame.utils.Utils
|
||||
import org.json.JSONObject
|
||||
import java.io.BufferedOutputStream
|
||||
@ -56,18 +48,9 @@ import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.util.*
|
||||
|
||||
class DefaultJsApi(var context: Context, val entrance: String = "", private var mFragment: Fragment? = null) {
|
||||
class DefaultJsApi(var context: Context, val entrance: String = "") {
|
||||
|
||||
private var mLoginHandler: CompletionHandler<Any>? = null
|
||||
private var mDownloadWatcher: DataWatcher? = null
|
||||
private var mDownloadUrlSet: HashSet<String>? = null
|
||||
private var mDownloadHandler: CompletionHandler<Any>? = null
|
||||
|
||||
init {
|
||||
if (mFragment != null) {
|
||||
autoUnregisterDownloadObserverIfNeeded(mFragment)
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun isGhzs(msg: Any): String {
|
||||
@ -81,7 +64,9 @@ class DefaultJsApi(var context: Context, val entrance: String = "", private var
|
||||
|
||||
@JavascriptInterface
|
||||
fun logMtaEvent(event: Any) {
|
||||
// do nothing, mta is deprecated
|
||||
val mtaEvent = event.toString().toObject() ?: MtaEvent()
|
||||
|
||||
MtaHelper.onEvent(mtaEvent.name, mtaEvent.key, mtaEvent.value)
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
@ -182,18 +167,7 @@ class DefaultJsApi(var context: Context, val entrance: String = "", private var
|
||||
@JavascriptInterface
|
||||
fun startApp(msg: Any) {
|
||||
val packageName = msg.toString()
|
||||
val context = HaloApp.getInstance().application
|
||||
|
||||
runOnUiThread {
|
||||
// 若畅玩列表中安装了,优先启动畅玩游戏
|
||||
if (VHelper.isInstalled(packageName)) {
|
||||
if (!VHelper.showDialogIfVSpaceIsNeeded(context)) {
|
||||
VHelper.launch(context, packageName)
|
||||
}
|
||||
} else {
|
||||
PackageUtils.launchApplicationByPackageName(context, packageName)
|
||||
}
|
||||
}
|
||||
PackageUtils.launchApplicationByPackageName(HaloApp.getInstance().application, packageName)
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
@ -296,7 +270,7 @@ class DefaultJsApi(var context: Context, val entrance: String = "", private var
|
||||
|
||||
@JavascriptInterface
|
||||
fun bindPhone(msg: Any) {
|
||||
val intent = SettingBridge.getBindPhoneNormalIntent(context, false)
|
||||
val intent = ComposeBindPhoneActivity.getNormalIntent(context, false)
|
||||
context.startActivity(intent)
|
||||
}
|
||||
|
||||
@ -340,9 +314,7 @@ class DefaultJsApi(var context: Context, val entrance: String = "", private var
|
||||
|
||||
@JavascriptInterface
|
||||
fun showQaFeedbackDialog(msg: Any) {
|
||||
val mHelpAndFeedbackHelp =
|
||||
ARouter.getInstance().build(RouteConsts.provider.helpAndFeedback).navigation() as? IHelpAndFeedbackProvider
|
||||
mHelpAndFeedbackHelp?.showQaFeedbackDialogFragment(context as AppCompatActivity, msg.toString())
|
||||
QaFeedbackDialogFragment.show(context as AppCompatActivity, msg.toString())
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
@ -389,6 +361,11 @@ class DefaultJsApi(var context: Context, val entrance: String = "", private var
|
||||
FloatingBackViewManager.enableBackView(FloatingBackViewManager.TYPE_ACTIVITY, msg.toString())
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun startBBSStayTimeCount(msg: Any) {
|
||||
BbsStayTimeHelper.enableStayTimeCount(msg.toString().toInt())
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun saveBase64ImageToGallery(msg: Any) {
|
||||
val base64StringData = msg.toString()
|
||||
@ -428,9 +405,18 @@ class DefaultJsApi(var context: Context, val entrance: String = "", private var
|
||||
runOnUiThread { DirectUtils.directToFullScreenWebPage(context, url.toString(), true, entrance) }
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun startGameCollectionSquareBrowseTask(event: Any) {
|
||||
val browseTimeEvent = event.toString().toObject() ?: BrowseTaskEvent()
|
||||
GameCollectionSquareBrowseTaskHelper.enableBrowseTimeCount(
|
||||
browseTimeEvent.timeout.toInt(),
|
||||
browseTimeEvent.isFinished == "true"
|
||||
)
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun checkUpdateGhzs(msg: Any) {
|
||||
context.startActivity(SettingBridge.getAboutIntent(context, true))
|
||||
context.startActivity(ComposeAboutActivity.getIntent(context, true))
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
@ -453,182 +439,17 @@ class DefaultJsApi(var context: Context, val entrance: String = "", private var
|
||||
|
||||
@JavascriptInterface
|
||||
fun getEntrance(msg: Any): String {
|
||||
return when {
|
||||
entrance.contains("论坛-活动") -> "社区-活动tab-活动banner"
|
||||
entrance.contains("启动弹窗") -> "首页_弹窗"
|
||||
entrance.contains("新首页-轮播图") -> "首页banner"
|
||||
entrance.contains("论坛banner") -> "社区banner"
|
||||
entrance.contains("启动广告") -> "app_开屏文案"
|
||||
// entrance.contains("资讯广场-轮播图") -> "资讯_活动banner"
|
||||
entrance.contains("通用链接合集") -> "资讯_活动banner"
|
||||
entrance.contains("视频流广告位") -> "视频流_广告位"
|
||||
entrance.contains("我的光环banner") -> "我的光环_banner"
|
||||
entrance.contains("论坛详情页置顶栏") -> "社区_论坛置顶"
|
||||
|
||||
else -> entrance
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun getInstallStatus(event: Any): String {
|
||||
val localInstalledPackageList = PackageUtils.getAllPackageName(HaloApp.getInstance().application)
|
||||
val packageNameList: ArrayList<String> = event.toString().toObject() ?: ArrayList()
|
||||
val installStatusMap: HashMap<String, Boolean> = hashMapOf()
|
||||
|
||||
for (packageName in packageNameList) {
|
||||
installStatusMap[packageName] =
|
||||
localInstalledPackageList.contains(packageName) || VHelper.isInstalled(packageName)
|
||||
}
|
||||
|
||||
return installStatusMap.toJson()
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun installDownloadedGame(event: Any) {
|
||||
val url = event.toString()
|
||||
val vUrl = VHelper.getVUrl(url)
|
||||
|
||||
val downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(url, null, false)
|
||||
?: DownloadManager.getInstance().getDownloadEntitySnapshot(vUrl, null, false)
|
||||
|
||||
downloadEntity?.let {
|
||||
PackageInstaller.install(context, it, showUnzipToast = false)
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun registerDownloadCallback(msg: Any, handler: CompletionHandler<Any>) {
|
||||
val downloadUrlSet: HashSet<String> = msg.toString().toObject() ?: return
|
||||
|
||||
mDownloadHandler = handler
|
||||
mDownloadUrlSet = downloadUrlSet
|
||||
|
||||
if (mDownloadWatcher == null) {
|
||||
mDownloadWatcher = object : DataWatcher() {
|
||||
override fun onDataInit(downloadEntity: DownloadEntity) {
|
||||
onDataChanged(downloadEntity)
|
||||
}
|
||||
|
||||
override fun onDataChanged(downloadEntity: DownloadEntity?) {
|
||||
val url = VHelper.getOriginalUrl(downloadEntity?.url)
|
||||
|
||||
if (downloadEntity != null && mDownloadUrlSet?.contains(url) == true) {
|
||||
mDownloadHandler?.setProgressData(
|
||||
SimpleDownloadEntity.fromDownloadEntity(downloadEntity).toJson()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
DownloadManager.getInstance().addObserver(mDownloadWatcher)
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun registerPackageChangesCallback(msg: Any, handler: CompletionHandler<Any>) {
|
||||
PackageObserver.registerPackageChangeChangeListener(object : PackageObserver.PackageChangeListener {
|
||||
override fun onChanged(data: EBPackage) {
|
||||
handler.setProgressData(data.toJson())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun startDownload(msg: Any) {
|
||||
val gameEntity: GameEntity? = msg.toString().toObject()
|
||||
|
||||
if (gameEntity == null) {
|
||||
ToastUtils.toast("下载异常,请稍后重试")
|
||||
return
|
||||
}
|
||||
|
||||
runOnUiThread {
|
||||
// 用一个假的 view 来当 downloadView
|
||||
val stubView = View(context)
|
||||
DownloadItemUtils.setOnClickListener(
|
||||
position = 0,
|
||||
context = context,
|
||||
downloadBtn = stubView,
|
||||
gameEntity = gameEntity,
|
||||
adapter = null,
|
||||
entrance = "(网页活动)",
|
||||
location = "",
|
||||
traceEvent = null,
|
||||
clickCallback = null,
|
||||
refreshCallback = null,
|
||||
allStateClickCallback = null
|
||||
)
|
||||
|
||||
stubView.performClick()
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun resumeDownload(msg: Any) {
|
||||
val url = msg.toString()
|
||||
|
||||
DownloadManager.getInstance().resumeDownload(url)
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun pauseDownload(msg: Any) {
|
||||
val url = msg.toString()
|
||||
|
||||
DownloadManager.getInstance().pause(url)
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
fun shareText(event: Any) {
|
||||
val textShareEvent = event.toString().toObject() ?: TextShareEvent()
|
||||
if (textShareEvent.text.isNotEmpty() && textShareEvent.type.isNotEmpty()) {
|
||||
val activity = CurrentActivityHolder.getCurrentActivity()
|
||||
MessageShareUtils.getInstance(activity).shareTextFromWeb(activity, textShareEvent.text, textShareEvent.type)
|
||||
}
|
||||
}
|
||||
|
||||
private fun autoUnregisterDownloadObserverIfNeeded(fragment: Fragment?) {
|
||||
fragment?.parentFragmentManager?.registerFragmentLifecycleCallbacks(
|
||||
object : FragmentManager.FragmentLifecycleCallbacks() {
|
||||
override fun onFragmentViewDestroyed(fm: FragmentManager, f: Fragment) {
|
||||
super.onFragmentViewDestroyed(fm, f)
|
||||
if (f === fragment) {
|
||||
fragment.parentFragmentManager.unregisterFragmentLifecycleCallbacks(this)
|
||||
|
||||
if (mDownloadWatcher != null) {
|
||||
DownloadManager.getInstance().removeObserver(mDownloadWatcher)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFragmentResumed(fm: FragmentManager, f: Fragment) {
|
||||
super.onFragmentResumed(fm, f)
|
||||
|
||||
if (f === fragment && mDownloadWatcher != null) {
|
||||
DownloadManager.getInstance().addObserver(mDownloadWatcher)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFragmentPaused(fm: FragmentManager, f: Fragment) {
|
||||
super.onFragmentPaused(fm, f)
|
||||
|
||||
if (f === fragment && mDownloadWatcher != null) {
|
||||
DownloadManager.getInstance().removeObserver(mDownloadWatcher)
|
||||
}
|
||||
}
|
||||
}, false
|
||||
)
|
||||
return entrance
|
||||
}
|
||||
|
||||
@Keep
|
||||
internal class ImageEvent(var imageList: ArrayList<String> = arrayListOf(), var position: Int = 0)
|
||||
internal data class ImageEvent(var imageList: ArrayList<String> = arrayListOf(), var position: Int = 0)
|
||||
|
||||
@Keep
|
||||
internal class ImageShareEvent(var image: String = "", var type: String = "")
|
||||
internal data class ImageShareEvent(var image: String = "", var type: String = "")
|
||||
|
||||
@Keep
|
||||
internal class TextShareEvent(var text: String = "", var type: String = "")
|
||||
|
||||
@Keep
|
||||
internal class InviteFriendsEvent(
|
||||
internal data class InviteFriendsEvent(
|
||||
var type: String = "",
|
||||
var way: String = "",
|
||||
var url: String = "",
|
||||
@ -636,48 +457,16 @@ class DefaultJsApi(var context: Context, val entrance: String = "", private var
|
||||
)
|
||||
|
||||
@Keep
|
||||
internal class LogEvent(var jsonString: String = "", var logStore: String = "")
|
||||
internal data class LogEvent(var jsonString: String = "", var logStore: String = "")
|
||||
|
||||
@Keep
|
||||
class GameActivityEvent(
|
||||
internal data class BrowseTaskEvent(var timeout: String = "", var isFinished: String = "")
|
||||
|
||||
@Keep
|
||||
data class GameActivityEvent(
|
||||
var gameId: String = "",
|
||||
var activityTitle: String = "",
|
||||
var activityId: String = "",
|
||||
var platform: String = ""
|
||||
)
|
||||
|
||||
@Keep
|
||||
class SimpleDownloadEntity(
|
||||
var url: String = "",
|
||||
var progress: Float = 0F,
|
||||
var status: String = "" // DOWNLOADING, PAUSED, DOWNLOADED, ERROR, UNKNOWN
|
||||
) {
|
||||
companion object {
|
||||
fun fromDownloadEntity(downloadEntity: DownloadEntity): SimpleDownloadEntity {
|
||||
val status: String = when (downloadEntity.status) {
|
||||
add,
|
||||
download,
|
||||
downloading -> "DOWNLOADING"
|
||||
|
||||
done -> "DOWNLOADED"
|
||||
|
||||
pause,
|
||||
resume,
|
||||
subscribe,
|
||||
waiting -> "PAUSED"
|
||||
|
||||
cancel,
|
||||
delete -> "UNKNOWN"
|
||||
|
||||
else -> "ERROR"
|
||||
}
|
||||
|
||||
return SimpleDownloadEntity(
|
||||
url = VHelper.getOriginalUrl(downloadEntity.url),
|
||||
progress = downloadEntity.percent.toFloat(),
|
||||
status = status
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,29 +15,25 @@ import com.gh.common.util.DirectUtils.directToGameVideo
|
||||
import com.gh.common.util.DirectUtils.directToLegacyVideoDetail
|
||||
import com.gh.common.util.DirectUtils.directToLinkPage
|
||||
import com.gh.common.util.DirectUtils.directToQa
|
||||
import com.gh.gamecenter.*
|
||||
import com.gh.gamecenter.core.utils.GsonUtils.gson
|
||||
import com.gh.gamecenter.LibaoDetailActivity
|
||||
import com.gh.gamecenter.MainActivity
|
||||
import com.gh.gamecenter.NewsDetailActivity
|
||||
import com.gh.gamecenter.WebActivity
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.entity.CommunityEntity
|
||||
import com.gh.gamecenter.common.entity.LinkEntity
|
||||
import com.gh.gamecenter.common.eventbus.EBReuse
|
||||
import com.gh.gamecenter.common.entity.SimpleGameEntity
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.common.utils.DialogHelper
|
||||
import com.gh.gamecenter.common.utils.EnvHelper
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.entity.*
|
||||
import com.gh.gamecenter.eventbus.EBSkip
|
||||
import com.gh.gamecenter.fragment.MainWrapperFragment
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.utils.PlatformUtils
|
||||
import com.gh.gamecenter.gamecollection.publish.GameCollectionEditActivity
|
||||
import com.gh.gamecenter.qa.BbsType
|
||||
import com.gh.gamecenter.qa.video.publish.VideoPublishActivity
|
||||
import com.gh.gamecenter.subject.SubjectActivity
|
||||
import com.gh.gamecenter.video.detail.VideoDetailContainerViewModel
|
||||
import com.lightgame.utils.Utils
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import java.nio.charset.Charset
|
||||
|
||||
object DefaultUrlHandler {
|
||||
@ -189,12 +185,10 @@ object DefaultUrlHandler {
|
||||
EntranceConsts.HOST_USERHOME -> {
|
||||
val position = uri.getQueryParameter("position")
|
||||
val subtype = uri.getQueryParameter("sub_type") ?: ""
|
||||
val subGameType = uri.getQueryParameter("sub_game_type") ?: "game_collection"
|
||||
DirectUtils.directToHomeActivity(
|
||||
context,
|
||||
id,
|
||||
subtype,
|
||||
subGameType,
|
||||
if (position.isNullOrEmpty()) -1 else position.toInt(),
|
||||
entrance,
|
||||
""
|
||||
@ -266,6 +260,21 @@ object DefaultUrlHandler {
|
||||
EntranceConsts.HOST_COLUMN -> {
|
||||
DirectUtils.directToSubject(context, id, uri.getQueryParameter(EntranceConsts.KEY_NAME), entrance)
|
||||
}
|
||||
EntranceConsts.HOST_COMMUNITY_QUESTION_LABEL_DETAIL -> {
|
||||
val community = CommunityEntity()
|
||||
community.id = uri.getQueryParameter("community_id") ?: ""
|
||||
community.name = uri.getQueryParameter("community_name") ?: ""
|
||||
val tag = uri.getQueryParameter("tag") ?: ""
|
||||
DirectUtils.directAskColumnLabelDetail(context, tag, community, entrance, "")
|
||||
}
|
||||
EntranceConsts.HOST_COMMUNITY_COLUMN_DETAIL -> {
|
||||
val community = CommunityEntity()
|
||||
community.id = uri.getQueryParameter("community_id") ?: ""
|
||||
community.name = uri.getQueryParameter("community_name") ?: ""
|
||||
val columnId = uri.getQueryParameter("column_id") ?: ""
|
||||
DirectUtils.directAskColumnDetail(context, columnId, community, entrance, "")
|
||||
}
|
||||
|
||||
EntranceConsts.HOST_BLOCK -> {
|
||||
val name = uri.getQueryParameter("name")
|
||||
?: ""
|
||||
@ -481,18 +490,6 @@ object DefaultUrlHandler {
|
||||
)
|
||||
}
|
||||
|
||||
EntranceConsts.HOST_GAME_LIBRARY -> {
|
||||
DirectUtils.directToMainActivity(context)
|
||||
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_GAME))
|
||||
}
|
||||
|
||||
EntranceConsts.HOST_HOME_GAME_COLLECTION_SQUARE -> {
|
||||
DirectUtils.directToMainActivity(context)
|
||||
EventBus.getDefault()
|
||||
.post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_HOME))
|
||||
EventBus.getDefault().post(EBReuse(host))
|
||||
}
|
||||
|
||||
else -> {
|
||||
if (bringAppToFront) {
|
||||
DirectUtils.directToMainActivity(context)
|
||||
|
||||
@ -2,15 +2,14 @@ package com.gh.common
|
||||
|
||||
import com.gh.common.exposure.ExposureManager
|
||||
import com.gh.common.filter.RegionSettingHelper
|
||||
import com.gh.common.util.AdHelper
|
||||
import com.gh.common.videolog.VideoRecordUtils
|
||||
import com.gh.download.DownloadDataHelper
|
||||
import com.gh.gamecenter.common.loghub.LoghubUtils
|
||||
import com.gh.gamecenter.common.retrofit.Response
|
||||
import com.gh.gamecenter.common.utils.doOnMainProcessOnly
|
||||
import com.gh.gamecenter.common.utils.tryCatchInRelease
|
||||
import com.gh.gamecenter.core.runOnUiThread
|
||||
import com.gh.common.videolog.VideoRecordUtils
|
||||
import com.gh.download.DownloadDataHelper
|
||||
import com.gh.gamecenter.entity.TimeEntity
|
||||
import com.gh.gamecenter.common.retrofit.Response
|
||||
import com.gh.gamecenter.core.runOnUiThread
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
@ -21,12 +20,11 @@ object FixedRateJobHelper {
|
||||
private const val TIME_PERIOD: Long = 600 * 1000L
|
||||
private const val LOGHUB_PERIOD: Long = 120 * 1000L
|
||||
private const val EXPOSURE_PERIOD: Long = 300 * 1000L
|
||||
private const val REGION_SETTING_PERIOD: Long = 30 * 1000L
|
||||
private const val REGION_SETTING_PERIOD: Long = 300 * 1000L
|
||||
private const val VIDEO_RECORD_PERIOD: Long = 60 * 1000L
|
||||
|
||||
private const val DOWNLOAD_HEARTBEAT_PERIOD: Long = 60 * 1000L
|
||||
private const val DOWNLOAD_HEARTBEAT_SHEET_PERIOD: Long = 15 * 1000L
|
||||
private const val STARTUP_AD: Long = 30 * 60 * 1000L
|
||||
|
||||
private var mExecuteCount: Int = 0
|
||||
|
||||
@ -84,11 +82,6 @@ object FixedRateJobHelper {
|
||||
VideoRecordUtils.commitVideoRecord()
|
||||
}
|
||||
|
||||
// 获取启动广告
|
||||
if ((mExecuteCount * CHECKER_PERIOD) % STARTUP_AD == 0L) {
|
||||
AdHelper.getSettingAdCache()
|
||||
}
|
||||
|
||||
// ExposureUtils.logADownloadCompleteExposureEvent(GameEntity(id = mExecuteCount.toString(), name = "测试曝光上传"), platform = "", trace = null, downloadType = ExposureUtils.DownloadType.DOWNLOAD)
|
||||
mExecuteCount++
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@ package com.gh.common.chain
|
||||
import android.content.Context
|
||||
import com.gh.download.server.BrowserInstallHelper
|
||||
import com.gh.gamecenter.core.utils.EmptyCallback
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
|
||||
class BrowserInstallHandler : ChainHandler() {
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ package com.gh.common.chain
|
||||
|
||||
import android.content.Context
|
||||
import com.gh.common.dialog.CertificationDialog
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
|
||||
class CertificationHandler : ChainHandler() {
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package com.gh.common.chain
|
||||
|
||||
import android.content.Context
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
|
||||
abstract class ChainHandler {
|
||||
private var next: ChainHandler? = null
|
||||
|
||||
@ -3,7 +3,7 @@ package com.gh.common.chain
|
||||
import android.content.Context
|
||||
import com.gh.common.util.DialogUtils
|
||||
import com.gh.gamecenter.common.utils.safelyGetInRelease
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
|
||||
class CheckDownloadHandler : ChainHandler() {
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ package com.gh.common.chain
|
||||
import android.content.Context
|
||||
import com.gh.gamecenter.common.utils.PermissionHelper
|
||||
import com.gh.gamecenter.core.utils.EmptyCallback
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
|
||||
class CheckStoragePermissionHandler : ChainHandler() {
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ import android.content.Context
|
||||
import com.gh.common.util.DownloadDialogHelper
|
||||
import com.gh.gamecenter.common.utils.safelyGetInRelease
|
||||
import com.gh.gamecenter.core.utils.EmptyCallback
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
|
||||
class DownloadDialogHelperHandler : ChainHandler() {
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ package com.gh.common.chain
|
||||
|
||||
import android.content.Context
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.gamedetail.dialog.GamePermissionDialogFragment
|
||||
|
||||
class GamePermissionHandler : ChainHandler() {
|
||||
|
||||
@ -2,7 +2,7 @@ package com.gh.common.chain
|
||||
|
||||
import android.content.Context
|
||||
import com.gh.common.util.DialogUtils
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
|
||||
class OverseaDownloadHandler : ChainHandler() {
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ package com.gh.common.chain
|
||||
import android.content.Context
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.gh.common.dialog.PackageCheckDialogFragment
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
|
||||
class PackageCheckHandler : ChainHandler() {
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ package com.gh.common.chain
|
||||
import android.content.Context
|
||||
import com.gh.common.simulator.NewSimulatorGameManager
|
||||
import com.gh.common.simulator.SimulatorGameManager
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
|
||||
class UpdateNewSimulatorHandler: ChainHandler() {
|
||||
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
package com.gh.common.chain
|
||||
|
||||
import android.content.Context
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.vspace.VHelper
|
||||
|
||||
class ValidateVSpaceHandler : ChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity) {
|
||||
VHelper.validateVSpaceBeforeAction(context, gameEntity) {
|
||||
VHelper.validateVSpaceBeforeAction(context, gameEntity, true) {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
} else {
|
||||
|
||||
@ -1,33 +1,18 @@
|
||||
package com.gh.common.chain
|
||||
|
||||
import android.content.Context
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.utils.DialogHelper
|
||||
import com.gh.gamecenter.common.utils.toResString
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.common.util.DialogUtils
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
|
||||
class VersionNumberHandler : ChainHandler() {
|
||||
|
||||
override fun handleRequest(context: Context, gameEntity: GameEntity) {
|
||||
val confirmCallback = {
|
||||
DialogUtils.showVersionNumberDialog(context, gameEntity) {
|
||||
if (hasNext()) {
|
||||
getNext()?.handleRequest(context, gameEntity)
|
||||
} else {
|
||||
processEndCallback?.invoke(null)
|
||||
}
|
||||
}
|
||||
if (!gameEntity.isShowVersionNumber()) {
|
||||
confirmCallback.invoke()
|
||||
} else {
|
||||
DialogHelper.showGuideDialog(
|
||||
context,
|
||||
"温馨提示",
|
||||
gameEntity.getVersionNumberString(),
|
||||
"继续下载",
|
||||
R.string.cancel.toResString(),
|
||||
{ confirmCallback.invoke() },
|
||||
extraConfig = DialogHelper.Config(titleIcon = R.drawable.ic_dialog_tips)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8,26 +8,24 @@ import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.gh.common.util.AdHelper;
|
||||
import com.gh.gamecenter.common.utils.DarkModeUtils;
|
||||
import com.gh.gamecenter.common.utils.EnvHelper;
|
||||
import com.gh.gamecenter.common.constant.Constants;
|
||||
import com.gh.gamecenter.core.utils.GsonUtils;
|
||||
import com.gh.common.util.PackageHelper;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.common.constant.CommonConsts;
|
||||
import com.gh.gamecenter.common.constant.Constants;
|
||||
import com.gh.gamecenter.common.eventbus.EBReuse;
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse;
|
||||
import com.gh.gamecenter.common.retrofit.Response;
|
||||
import com.gh.gamecenter.common.utils.DarkModeUtils;
|
||||
import com.gh.gamecenter.common.utils.EnvHelper;
|
||||
import com.gh.gamecenter.core.utils.GsonUtils;
|
||||
import com.gh.gamecenter.SuggestionActivity;
|
||||
import com.gh.gamecenter.core.utils.SPUtils;
|
||||
import com.gh.gamecenter.entity.GameGuidePopupEntity;
|
||||
import com.gh.gamecenter.entity.NewApiSettingsEntity;
|
||||
import com.gh.gamecenter.entity.NewSettingsEntity;
|
||||
import com.gh.gamecenter.entity.NewsEntity;
|
||||
import com.gh.gamecenter.entity.SettingsEntity;
|
||||
import com.gh.gamecenter.common.eventbus.EBReuse;
|
||||
import com.gh.gamecenter.entity.SimulatorEntity;
|
||||
import com.gh.gamecenter.entity.VSetting;
|
||||
import com.gh.gamecenter.feature.entity.NewsEntity;
|
||||
import com.gh.gamecenter.feature.entity.SettingsEntity;
|
||||
import com.gh.gamecenter.feature.entity.SimulatorEntity;
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse;
|
||||
import com.gh.gamecenter.common.retrofit.Response;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
import com.gh.vspace.VHelper;
|
||||
import com.halo.assistant.HaloApp;
|
||||
@ -66,9 +64,8 @@ public class Config {
|
||||
|
||||
private static SettingsEntity mSettingsEntity;
|
||||
private static NewSettingsEntity mNewSettingsEntity;
|
||||
private static NewApiSettingsEntity mNewApiSettingsEntity;
|
||||
|
||||
private static NewApiSettingsEntity.NightMode mNightModeSetting;
|
||||
private static NewSettingsEntity.NightMode mNightModeSetting;
|
||||
private static SimulatorEntity mNewSimulatorEntity;
|
||||
private static VSetting mVSetting;
|
||||
private static GameGuidePopupEntity mGameGuidePopupEntity;
|
||||
@ -207,7 +204,7 @@ public class Config {
|
||||
PackageHelper.initList();
|
||||
|
||||
// 初始化畅玩相关的东西
|
||||
VHelper.init(HaloApp.getInstance(), false);
|
||||
VHelper.init(HaloApp.getInstance());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -230,32 +227,24 @@ public class Config {
|
||||
public static SimulatorEntity getNewSimulatorEntitySetting() {
|
||||
if (mNewSimulatorEntity != null) {
|
||||
return mNewSimulatorEntity;
|
||||
} else if (mNewApiSettingsEntity != null && mNewApiSettingsEntity.getSimulator() != null) {
|
||||
return mNewApiSettingsEntity.getSimulator();
|
||||
} else if (mNewSettingsEntity != null && mNewSettingsEntity.getSimulator() != null) {
|
||||
return mNewSettingsEntity.getSimulator();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static NewApiSettingsEntity.NightMode getNightModeSetting() {
|
||||
public static NewSettingsEntity.NightMode getNightModeSetting() {
|
||||
if (mNightModeSetting != null) {
|
||||
return mNightModeSetting;
|
||||
} else if (mNewApiSettingsEntity != null && mNewApiSettingsEntity.getNightMode() != null) {
|
||||
return mNewApiSettingsEntity.getNightMode();
|
||||
} else if (mNewSettingsEntity != null && mNewSettingsEntity.getNightMode() != null) {
|
||||
return mNewSettingsEntity.getNightMode();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean getUserInterestedGame() {
|
||||
if (mNewApiSettingsEntity != null) {
|
||||
return mNewApiSettingsEntity.getUserInterestedGame();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static NewSettingsEntity getNewSettingsEntity() {
|
||||
if (mNewSettingsEntity == null) {
|
||||
@ -271,26 +260,6 @@ public class Config {
|
||||
return mNewSettingsEntity;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static NewApiSettingsEntity getNewApiSettingsEntity() {
|
||||
if (mNewApiSettingsEntity == null) {
|
||||
try {
|
||||
String json = SPUtils.getString(Constants.SP_NEW_API_SETTINGS);
|
||||
if (!TextUtils.isEmpty(json)) {
|
||||
mNewApiSettingsEntity = GsonUtils.fromJson(json, NewApiSettingsEntity.class);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return mNewApiSettingsEntity;
|
||||
}
|
||||
|
||||
public static void updateNewApiSettings(NewApiSettingsEntity settingsEntity) {
|
||||
mNewApiSettingsEntity = settingsEntity;
|
||||
SPUtils.setString(Constants.SP_NEW_API_SETTINGS, GsonUtils.toJson(settingsEntity));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static VSetting getVSettingEntity() {
|
||||
if (mVSetting == null) {
|
||||
@ -354,7 +323,7 @@ public class Config {
|
||||
|
||||
// 意见反馈
|
||||
SharedPreferences.Editor edit = getPreferences().edit();
|
||||
edit.putString(CommonConsts.SUGGESTION_HINT_TYPE,
|
||||
edit.putString(SuggestionActivity.SUGGESTION_HINT_TYPE,
|
||||
GsonUtils.toJson(response.getSuggestion()));
|
||||
edit.apply();
|
||||
|
||||
@ -375,6 +344,9 @@ public class Config {
|
||||
@Override
|
||||
public void onSuccess(NewSettingsEntity data) {
|
||||
mNewSettingsEntity = data;
|
||||
if (mNightModeSetting != null) {
|
||||
mNewSettingsEntity.setNightMode(mNightModeSetting);
|
||||
}
|
||||
SPUtils.setString(Constants.SP_NEW_SETTINGS, GsonUtils.toJson(data));
|
||||
}
|
||||
});
|
||||
@ -392,23 +364,27 @@ public class Config {
|
||||
});
|
||||
}
|
||||
|
||||
if (mNewApiSettingsEntity == null) {
|
||||
if (mNightModeSetting == null && mNewSimulatorEntity == null) {
|
||||
RetrofitManager.getInstance()
|
||||
.getNewApi().getNewSettings(PackageUtils.getGhVersionName(), channel)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BiResponse<NewApiSettingsEntity>() {
|
||||
.subscribe(new BiResponse<NewSettingsEntity>() {
|
||||
@Override
|
||||
public void onSuccess(NewApiSettingsEntity data) {
|
||||
mNewApiSettingsEntity = data;
|
||||
public void onSuccess(NewSettingsEntity data) {
|
||||
mNightModeSetting = data.getNightMode();
|
||||
mNewSimulatorEntity = data.getSimulator();
|
||||
if (HaloApp.getInstance().isNewForThisVersion && mNightModeSetting != null && mNightModeSetting.getInstall()) {
|
||||
DarkModeUtils.INSTANCE.updateFollowSystemDarkModeToSp(true);
|
||||
DarkModeUtils.INSTANCE.updateAppDarkModeStatusToSp(true);
|
||||
DarkModeUtils.INSTANCE.initDarkMode();
|
||||
}
|
||||
AdHelper.prefetchStartUpAd(mNewApiSettingsEntity);
|
||||
SPUtils.setString(Constants.SP_NEW_API_SETTINGS, GsonUtils.toJson(data));
|
||||
|
||||
if (mNewSettingsEntity != null) {
|
||||
mNewSettingsEntity.setSimulator(mNewSimulatorEntity);
|
||||
mNewSettingsEntity.setNightMode(mNightModeSetting);
|
||||
SPUtils.setString(Constants.SP_NEW_SETTINGS, GsonUtils.toJson(data));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.databinding.KaifuAddItemBinding
|
||||
import com.gh.gamecenter.databinding.LayoutAddKaifuPopupBinding
|
||||
import com.gh.gamecenter.databinding.LayoutPopupContainerBinding
|
||||
import com.gh.gamecenter.feature.entity.ServerCalendarEntity
|
||||
import com.gh.gamecenter.entity.ServerCalendarEntity
|
||||
import com.gh.gamecenter.servers.add.AddKaiFuPopupAdapter
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
@ -31,7 +31,7 @@ import com.gh.common.chain.PackageCheckHandler;
|
||||
import com.gh.common.chain.ValidateVSpaceHandler;
|
||||
import com.gh.common.chain.VersionNumberHandler;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent;
|
||||
import com.gh.common.exposure.ExposureEvent;
|
||||
import com.gh.common.filter.RegionSetting;
|
||||
import com.gh.common.filter.RegionSettingHelper;
|
||||
import com.gh.common.history.HistoryHelper;
|
||||
@ -46,11 +46,10 @@ import com.gh.common.util.LogUtils;
|
||||
import com.gh.common.util.NewsUtils;
|
||||
import com.gh.common.util.PackageInstaller;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.gamecenter.feature.utils.PlatformUtils;
|
||||
import com.gh.common.util.PlatformUtils;
|
||||
import com.gh.common.util.ReservationHelper;
|
||||
import com.gh.gamecenter.feature.view.DownloadButton;
|
||||
import com.gh.gamecenter.feature.view.GameIconView;
|
||||
import com.gh.gamecenter.common.view.NoEllipsizeSpaceTextView;
|
||||
import com.gh.common.view.DownloadButton;
|
||||
import com.gh.common.view.GameIconView;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.download.dialog.DownloadDialog;
|
||||
import com.gh.gamecenter.DownloadManagerActivity;
|
||||
@ -66,17 +65,17 @@ import com.gh.gamecenter.core.utils.DisplayUtils;
|
||||
import com.gh.gamecenter.core.utils.MtaHelper;
|
||||
import com.gh.gamecenter.core.utils.NumberUtils;
|
||||
import com.gh.gamecenter.databinding.KaifuDetailItemRowBinding;
|
||||
import com.gh.gamecenter.feature.entity.ApkEntity;
|
||||
import com.gh.gamecenter.feature.entity.GameEntity;
|
||||
import com.gh.gamecenter.entity.ApkEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.common.entity.LinkEntity;
|
||||
import com.gh.gamecenter.feature.entity.PluginLocation;
|
||||
import com.gh.gamecenter.feature.entity.ServerCalendarEntity;
|
||||
import com.gh.gamecenter.feature.entity.TagStyleEntity;
|
||||
import com.gh.gamecenter.feature.entity.TestEntity;
|
||||
import com.gh.gamecenter.entity.PluginLocation;
|
||||
import com.gh.gamecenter.entity.ServerCalendarEntity;
|
||||
import com.gh.gamecenter.entity.TagStyleEntity;
|
||||
import com.gh.gamecenter.entity.TestEntity;
|
||||
import com.gh.gamecenter.common.eventbus.EBReuse;
|
||||
import com.gh.gamecenter.gamedetail.dialog.GamePermissionDialogFragment;
|
||||
import com.gh.gamecenter.manager.PackagesManager;
|
||||
import com.gh.gamecenter.feature.entity.CommunityVideoEntity;
|
||||
import com.gh.gamecenter.qa.entity.CommunityVideoEntity;
|
||||
import com.gh.vspace.VDownloadManagerActivity;
|
||||
import com.gh.vspace.VHelper;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
@ -785,7 +784,7 @@ public class BindingAdapters {
|
||||
}
|
||||
}
|
||||
|
||||
public static void setGameName(NoEllipsizeSpaceTextView view, GameEntity game, boolean isShowPlatform, @Nullable Boolean isShowSuffix) {
|
||||
public static void setGameName(TextView view, GameEntity game, boolean isShowPlatform, @Nullable Boolean isShowSuffix) {
|
||||
if (isShowSuffix == null) isShowSuffix = true; // 默认显示
|
||||
if (isShowPlatform && game.getApk().size() > 0) {
|
||||
view.setText(String.format("%s - %s", !isShowSuffix ? game.getNameWithoutSuffix() : game.getName(),
|
||||
@ -843,7 +842,7 @@ public class BindingAdapters {
|
||||
int start = index;
|
||||
int end = start + tag.getName().length() + ((i != showCount - 1) ? 1 : 0);
|
||||
index = end;
|
||||
span.setSpan(new ForegroundColorSpan(ExtensionsKt.hexStringToIntColor("#" + tag.getColor(), Color.WHITE)),
|
||||
span.setSpan(new ForegroundColorSpan(Color.parseColor("#" + tag.getColor())),
|
||||
start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
view.setText(span);
|
||||
@ -851,11 +850,11 @@ public class BindingAdapters {
|
||||
|
||||
public static void setVideoData(TextView view, int count) {
|
||||
if (count > 0) {
|
||||
ExtensionsKt.setDrawableStart(view, ContextCompat.getDrawable(view.getContext(), R.drawable.ic_video_data_up), null, null);
|
||||
view.setCompoundDrawablesWithIntrinsicBounds(ContextCompat.getDrawable(view.getContext(), R.drawable.ic_video_data_up), null, null, null);
|
||||
view.setTextColor(ContextCompat.getColor(view.getContext(), R.color.text_EA3333));
|
||||
view.setText(count + "");
|
||||
} else {
|
||||
ExtensionsKt.removeDrawable(view);
|
||||
view.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
|
||||
view.setTextColor(ContextCompat.getColor(view.getContext(), R.color.text_subtitleDesc));
|
||||
view.setText("-");
|
||||
}
|
||||
|
||||
@ -24,9 +24,9 @@ import com.gh.gamecenter.common.callback.ConfirmListener
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.core.utils.GsonUtils
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.feature.entity.AuthDialogEntity
|
||||
import com.gh.gamecenter.feature.entity.AuthDialogLevel
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.AuthDialogEntity
|
||||
import com.gh.gamecenter.entity.AuthDialogLevel
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.login.user.UserManager
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.halo.assistant.fragment.user.UserInfoEditFragment
|
||||
|
||||
@ -28,7 +28,8 @@ import com.gh.gamecenter.core.utils.GsonUtils
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.databinding.DialogDeviceRemindBinding
|
||||
import com.gh.gamecenter.entity.DeviceDialogEntity
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.setting.compose.activity.ComposeGameDownloadSettingActivity
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.lightgame.download.DataWatcher
|
||||
import com.lightgame.download.DownloadEntity
|
||||
@ -52,7 +53,7 @@ class DeviceRemindDialog(context: Context, val entity: DeviceDialogEntity, val g
|
||||
private val dataWatcher = object : DataWatcher() {
|
||||
override fun onDataChanged(downloadEntity: DownloadEntity) {
|
||||
if (downloadEntity.status == DownloadStatus.done && downloadEntity.name == gameEntity.name) {
|
||||
val autoInstall = SPUtils.getBoolean(Constants.SP_AUTO_INSTALL, true)
|
||||
val autoInstall = SPUtils.getBoolean(ComposeGameDownloadSettingActivity.AUTO_INSTALL_SP_KEY, true)
|
||||
if (autoInstall) {
|
||||
dismiss()
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ import com.gh.gamecenter.common.utils.dip2px
|
||||
import com.gh.gamecenter.common.utils.toColor
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.databinding.DialogGameOffServiceBinding
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
|
||||
// 游戏关闭下载弹窗
|
||||
class GameOffServiceDialogFragment : BaseDialogFragment() {
|
||||
|
||||
@ -13,11 +13,13 @@ import androidx.fragment.app.FragmentActivity
|
||||
import androidx.fragment.app.FragmentTransaction
|
||||
import com.gh.common.util.DirectUtils
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.WebActivity
|
||||
import com.gh.gamecenter.common.base.fragment.BaseDialogFragment
|
||||
import com.gh.gamecenter.common.utils.dip2px
|
||||
import com.gh.gamecenter.common.view.CustomLinkMovementMethod
|
||||
import com.gh.gamecenter.databinding.DialogPrivacyProtocolNewBinding
|
||||
import com.gh.gamecenter.entity.DialogEntity
|
||||
import splitties.bundle.put
|
||||
|
||||
class NewPrivacyPolicyDialogFragment : BaseDialogFragment() {
|
||||
|
||||
@ -159,7 +161,7 @@ class NewPrivacyPolicyDialogFragment : BaseDialogFragment() {
|
||||
}
|
||||
}
|
||||
privacyDialogFragment.arguments = Bundle().apply {
|
||||
putParcelable(KEY_DATA, privacyPolicyEntity)
|
||||
put(KEY_DATA, privacyPolicyEntity)
|
||||
}
|
||||
privacyDialogFragment.show(
|
||||
activity.supportFragmentManager,
|
||||
|
||||
@ -31,9 +31,9 @@ import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.core.utils.SpanBuilder
|
||||
import com.gh.gamecenter.databinding.FragmentPackageCheckBinding
|
||||
import com.gh.gamecenter.databinding.PackageCheckItemBinding
|
||||
import com.gh.gamecenter.feature.entity.DetectionObjectEntity
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.entity.PackageDialogEntity
|
||||
import com.gh.gamecenter.entity.DetectionObjectEntity
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.PackageDialogEntity
|
||||
import com.gh.gamecenter.eventbus.EBPackage
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.adapter.BaseRecyclerAdapter
|
||||
@ -303,7 +303,7 @@ class PackageCheckDialogFragment : BaseDialogFragment() {
|
||||
//安装、卸载事件
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onEventMainThread(busFour: EBPackage) {
|
||||
if (busFour.isInstalledOrUninstalled()) {
|
||||
if ("安装" == busFour.type || "卸载" == busFour.type) {
|
||||
mAllInstalledPackages = PackageUtils.getInstalledPackages(HaloApp.getInstance().application, 0)
|
||||
mAdapter?.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
@ -23,6 +23,7 @@ import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.databinding.DialogPrivacyProtocolBinding
|
||||
import com.gh.gamecenter.entity.DialogEntity
|
||||
import com.lightgame.utils.AppManager
|
||||
import splitties.bundle.put
|
||||
|
||||
class PrivacyPolicyDialogFragment : BaseDialogFragment() {
|
||||
|
||||
@ -183,7 +184,7 @@ class PrivacyPolicyDialogFragment : BaseDialogFragment() {
|
||||
}
|
||||
}
|
||||
privacyDialogFragment.arguments = Bundle().apply {
|
||||
putParcelable(KEY_DATA, privacyPolicyEntity)
|
||||
put(KEY_DATA, privacyPolicyEntity)
|
||||
}
|
||||
privacyDialogFragment.show(
|
||||
activity.supportFragmentManager,
|
||||
|
||||
@ -15,7 +15,7 @@ import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.view.FixLinearLayoutManager
|
||||
import com.gh.gamecenter.databinding.DialogReserveBinding
|
||||
import com.gh.gamecenter.databinding.DialogReserveItemBinding
|
||||
import com.gh.gamecenter.common.entity.SimpleGameEntity
|
||||
import com.gh.gamecenter.entity.SimpleGameEntity
|
||||
import com.gh.gamecenter.mygame.MyGameActivity
|
||||
import com.lightgame.adapter.BaseRecyclerAdapter
|
||||
|
||||
|
||||
@ -1,19 +1,16 @@
|
||||
package com.gh.gamecenter.feature.exposure
|
||||
package com.gh.common.exposure
|
||||
|
||||
import android.os.Parcelable
|
||||
import androidx.annotation.Keep
|
||||
import androidx.room.PrimaryKey
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.gh.common.exposure.time.TimeUtil
|
||||
import com.gh.download.server.BrowserInstallHelper
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.common.entity.ExposureEntity
|
||||
import com.gh.gamecenter.common.exposure.meta.Meta
|
||||
import com.gh.gamecenter.common.exposure.meta.MetaUtil
|
||||
import com.gh.gamecenter.common.utils.getFirstElementDividedByDivider
|
||||
import com.gh.gamecenter.core.provider.IBrowserInstallHelperProvider
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.exposure.time.TimeUtil
|
||||
import com.gh.gamecenter.feature.provider.IRegionSettingHelperProvider
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import com.lightgame.utils.Utils
|
||||
import kotlinx.parcelize.IgnoredOnParcel
|
||||
@ -32,7 +29,7 @@ data class ExposureEvent(
|
||||
var timeInMillisecond: Long = System.currentTimeMillis(),
|
||||
@PrimaryKey
|
||||
var id: String = UUID.randomUUID().toString(),
|
||||
) : Parcelable, Cloneable {
|
||||
) : Parcelable {
|
||||
|
||||
@Transient
|
||||
@IgnoredOnParcel
|
||||
@ -48,13 +45,6 @@ data class ExposureEvent(
|
||||
eTrace: List<ExposureEvent>? = null,
|
||||
event: ExposureType = ExposureType.EXPOSURE
|
||||
) {
|
||||
if (gameEntity?.adIconActive == true) {
|
||||
gameEntity.isAdData = true
|
||||
}
|
||||
val browserInstallHelper = ARouter.getInstance().build(RouteConsts.provider.browserInstallHelper)
|
||||
.navigation() as? IBrowserInstallHelperProvider
|
||||
val regionSettingHelper = ARouter.getInstance().build(RouteConsts.provider.regionSettingHelper)
|
||||
.navigation() as? IRegionSettingHelperProvider
|
||||
this.payload = ExposureEntity(
|
||||
gameId = gameEntity?.id?.getFirstElementDividedByDivider(DownloadEntity.GAME_ID_DIVIDER),
|
||||
gameName = eTrace?.firstOrNull()?.payload?.gameName
|
||||
@ -66,8 +56,7 @@ data class ExposureEvent(
|
||||
?: gameEntity?.subjectData?.id,
|
||||
isMirrorData = eTrace?.firstOrNull()?.payload?.isMirrorData
|
||||
?: gameEntity?.shouldUseMirrorInfo() ?: false,
|
||||
isWebDownload = (browserInstallHelper?.isUseBrowserToInstallEnabled()
|
||||
?: false) && browserInstallHelper?.shouldUseBrowserToInstall() ?: false, // 实时的值,不用从 eTrace 里取
|
||||
isWebDownload = BrowserInstallHelper.isUseBrowserToInstallEnabled() && BrowserInstallHelper.shouldUseBrowserToInstall(), // 实时的值,不用从 eTrace 里取
|
||||
sequence = eTrace?.firstOrNull()?.payload?.sequence ?: gameEntity?.sequence,
|
||||
outerSequence = eTrace?.firstOrNull()?.payload?.outerSequence
|
||||
?: gameEntity?.outerSequence,
|
||||
@ -82,10 +71,7 @@ data class ExposureEvent(
|
||||
?: eTrace?.firstOrNull()?.payload?.welcomeDialogId,
|
||||
welcomeDialogLinkTitle = gameEntity?.welcomeDialogTitle
|
||||
?: eTrace?.firstOrNull()?.payload?.welcomeDialogLinkTitle,
|
||||
isAdData = gameEntity?.isAdData ?: eTrace?.firstOrNull()?.payload?.isAdData ?: false,
|
||||
country = regionSettingHelper?.getIpInfo()?.country ?: "",
|
||||
province = regionSettingHelper?.getIpInfo()?.province ?: "",
|
||||
city = regionSettingHelper?.getIpInfo()?.city ?: ""
|
||||
isAdData = gameEntity?.adIconActive ?: eTrace?.firstOrNull()?.payload?.isAdData ?: false
|
||||
)
|
||||
this.id = UUID.randomUUID().toString()
|
||||
this.timeInMillisecond = System.currentTimeMillis()
|
||||
@ -138,10 +124,6 @@ data class ExposureEvent(
|
||||
return flags == FLAG_IN_USE
|
||||
}
|
||||
|
||||
fun deepCopy(): ExposureEvent {
|
||||
return super.clone() as ExposureEvent
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val sPoolSync = Any()
|
||||
private var sPool: ExposureEvent? = null
|
||||
@ -4,7 +4,6 @@ import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import io.reactivex.functions.Consumer
|
||||
|
||||
/**
|
||||
|
||||
@ -5,7 +5,6 @@ import com.gh.gamecenter.BuildConfig
|
||||
import com.gh.gamecenter.common.loghub.LoghubHelper
|
||||
import com.gh.gamecenter.common.utils.FixedSizeLinkedHashSet
|
||||
import com.gh.gamecenter.common.utils.toJson
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.lightgame.utils.Utils
|
||||
|
||||
/**
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.gh.gamecenter.feature.exposure
|
||||
package com.gh.common.exposure
|
||||
|
||||
import android.os.Parcelable
|
||||
import androidx.annotation.Keep
|
||||
@ -6,4 +6,4 @@ import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Keep
|
||||
@Parcelize
|
||||
class ExposureSource(var k: String, var v: String = "") : Parcelable
|
||||
data class ExposureSource(var k: String, var v: String = "") : Parcelable
|
||||
@ -1,20 +1,16 @@
|
||||
package com.gh.common.exposure
|
||||
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
|
||||
object ExposureTraceUtils {
|
||||
|
||||
fun appendTrace(event: ExposureEvent?): List<ExposureEvent> {
|
||||
val traceList = arrayListOf<ExposureEvent>()
|
||||
|
||||
event?.let {
|
||||
//这里使用deepCopy,是为了防止循环引用调用hashCode方法触发StackOverflowError错误
|
||||
val deepCopy = it.deepCopy()
|
||||
if (deepCopy.eTrace == null) {
|
||||
traceList.add(deepCopy)
|
||||
if (event.eTrace == null) {
|
||||
traceList.add(event)
|
||||
} else {
|
||||
traceList.addAll(deepCopy.eTrace!!)
|
||||
traceList.add(flattenTrace(deepCopy))
|
||||
traceList.addAll(event.eTrace!!)
|
||||
traceList.add(flattenTrace(event))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.gh.gamecenter.feature.exposure
|
||||
package com.gh.common.exposure
|
||||
|
||||
enum class ExposureType {
|
||||
EXPOSURE,
|
||||
@ -5,10 +5,8 @@ import com.g00fy2.versioncompare.Version
|
||||
import com.gh.common.util.PackageUtils
|
||||
import com.gh.gamecenter.common.utils.FixedSizeLinkedHashSet
|
||||
import com.gh.gamecenter.common.utils.toObject
|
||||
import com.gh.gamecenter.feature.entity.ApkEntity
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.gh.gamecenter.feature.exposure.ExposureType
|
||||
import com.gh.gamecenter.entity.ApkEntity
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.manager.PackagesManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.download.DownloadEntity
|
||||
@ -24,7 +22,7 @@ object ExposureUtils {
|
||||
traceEvent: ExposureEvent?,
|
||||
downloadType: DownloadType
|
||||
): ExposureEvent {
|
||||
val gameEntity = entity.copy()
|
||||
val gameEntity = entity.clone()
|
||||
gameEntity.id = if (entity.id.contains(DownloadEntity.GAME_ID_DIVIDER)) {
|
||||
entity.id.split(DownloadEntity.GAME_ID_DIVIDER).toTypedArray()[0]
|
||||
} else {
|
||||
@ -51,12 +49,11 @@ object ExposureUtils {
|
||||
entity: GameEntity,
|
||||
platform: String?,
|
||||
trace: String?,
|
||||
speed: Long,
|
||||
host: String? = "unknown",
|
||||
path: String? = "unknown",
|
||||
downloadType: DownloadType
|
||||
) {
|
||||
val gameEntity = entity.copy()
|
||||
val gameEntity = entity.clone()
|
||||
gameEntity.platform = platform
|
||||
gameEntity.downloadCompleteType = downloadType.toString()
|
||||
val traceEvent = trace?.toObject<ExposureEvent>()
|
||||
@ -78,8 +75,6 @@ object ExposureUtils {
|
||||
)
|
||||
exposureEvent.payload.host = host
|
||||
exposureEvent.payload.path = path
|
||||
exposureEvent.payload.speed = speed
|
||||
|
||||
ExposureManager.log(exposureEvent)
|
||||
ExposureManager.commitSavedExposureEvents(forcedUpload = true)
|
||||
}
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
package com.gh.common.exposure
|
||||
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
|
||||
/**
|
||||
* 统计曝光的列表的 adapter 需要实现这个接口
|
||||
*/
|
||||
|
||||
15
app/src/main/java/com/gh/common/exposure/time/TimeUtil.kt
Normal file
15
app/src/main/java/com/gh/common/exposure/time/TimeUtil.kt
Normal file
@ -0,0 +1,15 @@
|
||||
package com.gh.common.exposure.time
|
||||
|
||||
import com.gh.common.FixedRateJobHelper
|
||||
|
||||
object TimeUtil {
|
||||
|
||||
fun currentTimeMillis(): Long {
|
||||
return FixedRateJobHelper.timeDeltaBetweenServerAndClient + System.currentTimeMillis()
|
||||
}
|
||||
|
||||
fun currentTime(): Int {
|
||||
return ((FixedRateJobHelper.timeDeltaBetweenServerAndClient + System.currentTimeMillis()) / 1000).toInt()
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,11 +1,10 @@
|
||||
package com.gh.common.filter
|
||||
|
||||
import androidx.annotation.Keep
|
||||
import com.gh.gamecenter.feature.entity.IpInfo
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
@Keep
|
||||
class RegionSetting(
|
||||
data class RegionSetting(
|
||||
@SerializedName("game_mirror")
|
||||
var mirrorGameIdSet: HashSet<String>,
|
||||
@SerializedName("game_block")
|
||||
@ -15,13 +14,11 @@ class RegionSetting(
|
||||
@SerializedName("game_h5_download")
|
||||
var gameH5DownloadList: List<GameH5Download>,
|
||||
@SerializedName("game_special_download")
|
||||
var gameSpecialDownloadInfoList: List<GameSpecialDownloadInfo>,
|
||||
@SerializedName("ip_info")
|
||||
var ipInfo: IpInfo? = null
|
||||
var gameSpecialDownloadInfoList: List<GameSpecialDownloadInfo>
|
||||
) {
|
||||
|
||||
@Keep
|
||||
class ChannelControl(
|
||||
data class ChannelControl(
|
||||
@SerializedName("game_category")
|
||||
var gameCategory: String,
|
||||
@SerializedName("effect")
|
||||
@ -29,7 +26,7 @@ class RegionSetting(
|
||||
)
|
||||
|
||||
@Keep
|
||||
class GameH5Download(
|
||||
data class GameH5Download(
|
||||
@SerializedName("game_id")
|
||||
var gameId: String,// 游戏id
|
||||
@SerializedName("h5_link")
|
||||
@ -40,7 +37,7 @@ class RegionSetting(
|
||||
var buttonText: String,// 按钮文案
|
||||
)
|
||||
|
||||
class GameSpecialDownloadInfo(
|
||||
data class GameSpecialDownloadInfo(
|
||||
@SerializedName("game_id")
|
||||
var gameId: String = "",
|
||||
@SerializedName("bbs_id")
|
||||
|
||||
@ -1,16 +1,14 @@
|
||||
package com.gh.common.filter
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.common.utils.debounceActionWithInterval
|
||||
import com.gh.gamecenter.common.utils.toJson
|
||||
import com.gh.gamecenter.common.utils.toObject
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.entity.IpInfo
|
||||
import com.gh.gamecenter.feature.entity.SimpleGame
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import io.reactivex.functions.Function
|
||||
@ -23,10 +21,8 @@ object RegionSettingHelper {
|
||||
private var mDisplayMirrorIfoGameIdSet: HashSet<String>? = hashSetOf()
|
||||
private var mGameH5DownloadList: List<RegionSetting.GameH5Download>? = listOf()
|
||||
private var mGameSpecialDownloadInfoList: List<RegionSetting.GameSpecialDownloadInfo>? = listOf()
|
||||
private var mIpInfo: IpInfo? = null
|
||||
|
||||
private const val SP_SETTING = "region_setting"
|
||||
const val SP_SETTING_FAILURE = "region_setting_failure"
|
||||
|
||||
fun shouldThisGameDisplayMirrorInfo(gameId: String): Boolean {
|
||||
return mDisplayMirrorIfoGameIdSet?.contains(gameId) ?: false
|
||||
@ -43,8 +39,6 @@ object RegionSettingHelper {
|
||||
@JvmStatic
|
||||
fun getGameSpecialDownloadInfo(gameId: String) = mGameSpecialDownloadInfoList?.find { it.gameId == gameId }
|
||||
|
||||
fun getIpInfo(): IpInfo? = mIpInfo
|
||||
|
||||
@JvmStatic
|
||||
fun filterGame(list: List<GameEntity>?): ArrayList<GameEntity> {
|
||||
if (list == null) return arrayListOf()
|
||||
@ -58,19 +52,6 @@ object RegionSettingHelper {
|
||||
return listCopy
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun filterSimpleGame(list: List<SimpleGame>?): ArrayList<SimpleGame> {
|
||||
if (list == null) return arrayListOf()
|
||||
|
||||
if (mFilterGameIdSet?.isEmpty() == true) {
|
||||
if (list is ArrayList) return list
|
||||
}
|
||||
|
||||
val listCopy: ArrayList<SimpleGame> = if (list is ArrayList) list else ArrayList(list)
|
||||
listCopy.removeAll { mFilterGameIdSet?.contains(it.id) ?: false }
|
||||
return listCopy
|
||||
}
|
||||
|
||||
@JvmField
|
||||
var filterGame = Function { list: List<GameEntity> ->
|
||||
filterGame(list)
|
||||
@ -107,10 +88,9 @@ object RegionSettingHelper {
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
SPUtils.getString(SP_SETTING).toObject<RegionSetting>()?.let {
|
||||
SPUtils.getString(SP_SETTING)?.toObject<RegionSetting>()?.let {
|
||||
updateSettingsInMemory(it)
|
||||
}
|
||||
SPUtils.setBoolean(SP_SETTING_FAILURE, true)
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -122,7 +102,6 @@ object RegionSettingHelper {
|
||||
mChannelControl = data.channelControl
|
||||
mGameH5DownloadList = data.gameH5DownloadList
|
||||
mGameSpecialDownloadInfoList = data.gameSpecialDownloadInfoList
|
||||
mIpInfo = data.ipInfo
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -9,17 +9,16 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
import com.gh.gamecenter.entity.GamesCollectionEntity
|
||||
import com.gh.gamecenter.entity.HistoryGameEntity
|
||||
import com.gh.gamecenter.entity.MyVideoEntity
|
||||
import com.gh.gamecenter.feature.entity.NewsEntity
|
||||
import com.gh.gamecenter.feature.entity.AnswerEntity
|
||||
import com.gh.gamecenter.feature.entity.ArticleEntity
|
||||
import com.gh.gamecenter.feature.room.converter.*
|
||||
import com.gh.gamecenter.entity.NewsEntity
|
||||
import com.gh.gamecenter.qa.entity.AnswerEntity
|
||||
import com.gh.gamecenter.qa.entity.ArticleEntity
|
||||
import com.gh.gamecenter.room.converter.*
|
||||
import com.gh.gamecenter.room.dao.*
|
||||
import com.halo.assistant.HaloApp
|
||||
|
||||
@Database(
|
||||
entities = [AnswerEntity::class, ArticleEntity::class, NewsEntity::class, HistoryGameEntity::class, MyVideoEntity::class, GamesCollectionEntity::class],
|
||||
version = 12,
|
||||
version = 11,
|
||||
exportSchema = false
|
||||
)
|
||||
@TypeConverters(
|
||||
@ -29,7 +28,6 @@ import com.halo.assistant.HaloApp
|
||||
AnswerUserConverter::class,
|
||||
ThumbnailConverter::class,
|
||||
TagStyleListConverter::class,
|
||||
TagStyleConverter::class,
|
||||
StringArrayListConverter::class,
|
||||
ListStringConverter::class,
|
||||
CommunityVideoConverter::class,
|
||||
@ -129,13 +127,6 @@ abstract class HistoryDatabase : RoomDatabase() {
|
||||
}
|
||||
}
|
||||
|
||||
val MIGRATION_11_12: Migration = object : Migration(11, 12) {
|
||||
override fun migrate(database: SupportSQLiteDatabase) {
|
||||
database.execSQL("Alter TABLE HistoryGameEntity add subtitle TEXT NOT NULL DEFAULT ''")
|
||||
database.execSQL("Alter TABLE HistoryGameEntity add subtitleStyle TEXT")
|
||||
}
|
||||
}
|
||||
|
||||
val instance by lazy {
|
||||
Room.databaseBuilder(
|
||||
HaloApp.getInstance().application,
|
||||
@ -151,7 +142,6 @@ abstract class HistoryDatabase : RoomDatabase() {
|
||||
.addMigrations(MIGRATION_8_9)
|
||||
.addMigrations(MIGRATION_9_10)
|
||||
.addMigrations(MIGRATION_10_11)
|
||||
.addMigrations(MIGRATION_11_12)
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,12 +6,10 @@ import com.gh.gamecenter.common.utils.removeVideoContent
|
||||
import com.gh.gamecenter.common.utils.tryCatchInRelease
|
||||
import com.gh.gamecenter.core.runOnIoThread
|
||||
import com.gh.gamecenter.entity.*
|
||||
import com.gh.gamecenter.feature.entity.AnswerEntity
|
||||
import com.gh.gamecenter.feature.entity.ArticleEntity
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.entity.NewsEntity
|
||||
import com.gh.gamecenter.qa.entity.AnswerDetailEntity
|
||||
import com.gh.gamecenter.qa.entity.AnswerEntity
|
||||
import com.gh.gamecenter.qa.entity.ArticleDetailEntity
|
||||
import com.gh.gamecenter.qa.entity.ArticleEntity
|
||||
|
||||
object HistoryHelper {
|
||||
|
||||
@ -73,8 +71,6 @@ object HistoryHelper {
|
||||
historyGame.name = gameEntity.name
|
||||
historyGame.tagStyle = gameEntity.tagStyle
|
||||
historyGame.tag = gameEntity.getTag()
|
||||
historyGame.subtitle = gameEntity.subtitle
|
||||
historyGame.subtitleStyle = gameEntity.subtitleStyle
|
||||
return historyGame
|
||||
}
|
||||
|
||||
|
||||
@ -1,19 +0,0 @@
|
||||
package com.gh.common.provider
|
||||
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gh.common.util.AdHelper
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.feature.entity.SettingsEntity
|
||||
import com.gh.gamecenter.feature.provider.IAdHelperProvider
|
||||
|
||||
@Route(path = RouteConsts.provider.adHelper, name = "AdHelper暴露服务")
|
||||
class AdHelperProviderImpl : IAdHelperProvider {
|
||||
override fun getSuggestionFunctionAd(): SettingsEntity.AD? {
|
||||
return AdHelper.getAd(AdHelper.LOCATION_SUGGESTION_FUNCTION)
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
@ -5,7 +5,6 @@ import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.core.provider.IAppProvider
|
||||
import com.gh.gamecenter.core.provider.IFlavorProvider
|
||||
import com.halo.assistant.HaloApp
|
||||
|
||||
@Route(path = RouteConsts.provider.app, name = "Application暴露服务")
|
||||
@ -57,16 +56,4 @@ class AppProviderImpl : IAppProvider {
|
||||
override fun isUserAcceptPrivacyPolicy(context: Context): Boolean {
|
||||
return HaloApp.isUserAcceptPrivacyPolicy(context)
|
||||
}
|
||||
|
||||
override fun put(key: String, any: Any) {
|
||||
HaloApp.put(key, any)
|
||||
}
|
||||
|
||||
override fun get(key: String, isRemove: Boolean): Any? {
|
||||
return HaloApp.get(key, isRemove)
|
||||
}
|
||||
|
||||
override fun getFlavorProvider(): IFlavorProvider {
|
||||
return HaloApp.getInstance().flavorProvider
|
||||
}
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
package com.gh.common.provider
|
||||
|
||||
import android.content.Context
|
||||
import android.widget.LinearLayout
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gh.common.databind.BindingAdapters
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.common.view.NoEllipsizeSpaceTextView
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.provider.IBindingAdaptersProvider
|
||||
|
||||
@Route(path = RouteConsts.provider.bindingAdapters, name = "BindingAdapters暴露服务")
|
||||
class BindingAdaptersProviderImpl : IBindingAdaptersProvider {
|
||||
override fun setGameName(
|
||||
view: NoEllipsizeSpaceTextView,
|
||||
game: GameEntity,
|
||||
isShowPlatform: Boolean,
|
||||
isShowSuffix: Boolean
|
||||
) {
|
||||
BindingAdapters.setGameName(view, game, isShowPlatform, isShowSuffix)
|
||||
}
|
||||
|
||||
override fun setGameTags(layout: LinearLayout, gameEntity: GameEntity) {
|
||||
BindingAdapters.setGameTags(layout, gameEntity)
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
@ -60,14 +60,6 @@ class ConfigProviderImpl : IConfigProvider {
|
||||
return Config.getSettings()?.support?.qq ?: ""
|
||||
}
|
||||
|
||||
override fun getQQun(): String {
|
||||
return Config.getSettings()?.support?.qQun ?: ""
|
||||
}
|
||||
|
||||
override fun getQQunKey(): String {
|
||||
return Config.getSettings()?.support?.qQunKey ?: ""
|
||||
}
|
||||
|
||||
override fun getQuickLoginAppId(): String {
|
||||
return Config.QUICK_LOGIN_APPID
|
||||
}
|
||||
@ -84,10 +76,6 @@ class ConfigProviderImpl : IConfigProvider {
|
||||
return Config.getNightModeSetting()?.setting ?: false
|
||||
}
|
||||
|
||||
override fun isShowPlugin(gameId: String): Boolean {
|
||||
return Config.isShowPlugin(gameId)
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@ -25,6 +25,23 @@ class DialogUtilsProviderImpl : IDialogUtilsProvider {
|
||||
|
||||
override fun showWaitDialog(context: Context, string: String): Dialog = DialogUtils.showWaitDialog(context, string)
|
||||
|
||||
override fun showForceDialog(
|
||||
context: Context,
|
||||
title: String,
|
||||
message: CharSequence,
|
||||
positive: String,
|
||||
negative: String,
|
||||
confirm: () -> Unit,
|
||||
cancel: () -> Unit
|
||||
) {
|
||||
DialogUtils.showForceDialog(context, title, message, positive, negative,
|
||||
{ confirm.invoke() }, object :CancelListener{
|
||||
override fun onCancel() {
|
||||
cancel.invoke()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun showUsageStatsDialog(context: Context, confirm: () -> Unit, cancel: () -> Unit) {
|
||||
DialogUtils.showUsageStatsDialog(context,
|
||||
{ confirm.invoke() }, object :CancelListener{
|
||||
|
||||
@ -57,18 +57,6 @@ class DirectProviderImpl : IDirectProvider {
|
||||
DirectUtils.directToSuggestion(context, diagnosis = diagnosis)
|
||||
}
|
||||
|
||||
override fun directToQa(context: Context, text: String?, id: String) {
|
||||
DirectUtils.directToQa(context, text, id)
|
||||
}
|
||||
|
||||
override fun directToHelpAndFeedback(context: Context, position: Int) {
|
||||
DirectUtils.directToHelpAndFeedback(context, position)
|
||||
}
|
||||
|
||||
override fun directToQqGroup(context: Context, groupNumber: String?): Boolean {
|
||||
return DirectUtils.directToQqGroup(context, groupNumber)
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
package com.gh.common.provider
|
||||
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gh.common.FixedRateJobHelper
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.core.provider.IFixedRateJobHelperProvider
|
||||
|
||||
@Route(path = RouteConsts.provider.fixedRateJobHelper, name = "FixedRateJobHelper暴露服务")
|
||||
class FixedRateJobHelperProviderImpl : IFixedRateJobHelperProvider {
|
||||
override fun getTimeDeltaBetweenServerAndClient(): Long {
|
||||
return FixedRateJobHelper.timeDeltaBetweenServerAndClient
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
@ -1,46 +0,0 @@
|
||||
package com.gh.common.provider
|
||||
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gh.gamecenter.GameDetailActivity
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.gh.gamecenter.feature.provider.IGameDetailProvider
|
||||
|
||||
@Route(path = RouteConsts.provider.gameDetail, name = "GameDetailActivity暴露服务")
|
||||
class GameDetailProviderImpl : IGameDetailProvider {
|
||||
override fun startGameDetailActivity(
|
||||
context: Context,
|
||||
gameId: String,
|
||||
entrance: String?,
|
||||
traceEvent: ExposureEvent?
|
||||
) {
|
||||
GameDetailActivity.startGameDetailActivity(context, gameId, entrance, traceEvent)
|
||||
}
|
||||
override fun startGameDetailActivity(
|
||||
context: Context,
|
||||
gameEntity: GameEntity?,
|
||||
entrance: String,
|
||||
defaultTab: Int,
|
||||
isSkipGameComment: Boolean,
|
||||
scrollToLibao: Boolean,
|
||||
scrollToServer: Boolean,
|
||||
traceEvent: ExposureEvent?
|
||||
) {
|
||||
GameDetailActivity.startGameDetailActivity(
|
||||
context,
|
||||
gameEntity,
|
||||
entrance,
|
||||
defaultTab,
|
||||
isSkipGameComment,
|
||||
scrollToLibao,
|
||||
scrollToServer,
|
||||
traceEvent
|
||||
)
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
@ -3,13 +3,13 @@ package com.gh.common.provider
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gh.common.filter.RegionSettingHelper
|
||||
import com.gh.gamecenter.feature.utils.ApkActiveUtils
|
||||
import com.gh.common.util.ApkActiveUtils
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.common.utils.countOccurrences
|
||||
import com.gh.gamecenter.core.provider.IHandleGameResponseProvider
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
|
||||
@Route(path = RouteConsts.provider.handleGameResponse, name = "处理游戏类型返回")
|
||||
class HandleGameResponseProviderImpl : IHandleGameResponseProvider {
|
||||
|
||||
@ -5,8 +5,6 @@ import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gh.common.util.DirectUtils
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.common.entity.LinkEntity
|
||||
import com.gh.gamecenter.common.entity.SimpleGameEntity
|
||||
import com.gh.gamecenter.common.entity.SuggestType
|
||||
import com.gh.gamecenter.common.provider.ILinkDirectUtilsProvider
|
||||
|
||||
@Route(path = RouteConsts.provider.linkDirectUtils, name = "DirectUtils暴露服务,主要是暴露directToLinkPage方法")
|
||||
@ -21,35 +19,6 @@ class LinkDirectUtilsProviderImpl : ILinkDirectUtilsProvider {
|
||||
DirectUtils.directToLinkPage(context, linkEntity, entrance, path)
|
||||
}
|
||||
|
||||
override fun directToSuggestion(context: Context, type: SuggestType, requestCode: Int?) {
|
||||
DirectUtils.directToSuggestion(context, type, requestCode)
|
||||
}
|
||||
|
||||
override fun directToSuggestion(
|
||||
context: Context,
|
||||
type: SuggestType,
|
||||
suggestHintType: String?,
|
||||
content: String?,
|
||||
isQaFeedback: Boolean,
|
||||
qaContentId: String
|
||||
) {
|
||||
DirectUtils.directToSuggestion(context, type, suggestHintType, content, isQaFeedback, qaContentId)
|
||||
}
|
||||
|
||||
override fun directToSuggestion(
|
||||
context: Context,
|
||||
type: SuggestType,
|
||||
suggestHintType: String?,
|
||||
content: String?,
|
||||
game: SimpleGameEntity,
|
||||
platform: String
|
||||
) {
|
||||
DirectUtils.directToSuggestion(context, type, suggestHintType, content, game, platform)
|
||||
}
|
||||
|
||||
override fun directToSuggestion(context: Context, type: SuggestType, hiddenHint: String) {
|
||||
DirectUtils.directToSuggestion(context, type, hiddenHint)
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
// Do nothing
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
package com.gh.common.provider
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gh.gamecenter.MainActivity
|
||||
import com.gh.gamecenter.WebActivity
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.core.provider.IMainProvider
|
||||
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
package com.gh.common.provider
|
||||
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.core.provider.IPackagesManagerProvider
|
||||
import com.gh.gamecenter.manager.PackagesManager
|
||||
|
||||
@Route(path = RouteConsts.provider.packagesManager, name = "PackagesManager暴露服务")
|
||||
class PackagesManagerProviderImpl: IPackagesManagerProvider {
|
||||
override fun isCanPluggable(gameId: String?, packageName: String?): Boolean {
|
||||
return PackagesManager.isCanPluggable(gameId, packageName)
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
package com.gh.common.provider
|
||||
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gh.common.filter.RegionSettingHelper
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.entity.IpInfo
|
||||
import com.gh.gamecenter.feature.provider.IRegionSettingHelperProvider
|
||||
|
||||
@Route(path = RouteConsts.provider.regionSettingHelper, name = "RegionSettingHelper暴露服务")
|
||||
class RegionSettingHelperProviderImpl : IRegionSettingHelperProvider {
|
||||
override fun shouldThisGameDisplayMirrorInfo(gameId: String): Boolean {
|
||||
return RegionSettingHelper.shouldThisGameDisplayMirrorInfo(gameId)
|
||||
}
|
||||
|
||||
override fun shouldThisGameShowSpecialDownload(gameId: String): Boolean {
|
||||
return RegionSettingHelper.shouldThisGameShowSpecialDownload(gameId)
|
||||
}
|
||||
|
||||
override fun filterGame(list: List<GameEntity>): ArrayList<GameEntity> {
|
||||
return RegionSettingHelper.filterGame(list)
|
||||
}
|
||||
|
||||
override fun getIpInfo(): IpInfo? {
|
||||
return RegionSettingHelper.getIpInfo()
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,7 @@ package com.gh.common.provider
|
||||
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gh.gamecenter.feature.exposure.time.TimeUtil
|
||||
import com.gh.common.exposure.time.TimeUtil
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.core.provider.ITimeUtilProvider
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ import android.os.Build
|
||||
import androidx.annotation.RequiresApi
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gh.common.util.UsageStatsHelper
|
||||
import com.gh.common.util.WechatBindHelper
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.core.provider.IUsageStatsHelperProvider
|
||||
|
||||
|
||||
@ -1,26 +0,0 @@
|
||||
package com.gh.common.provider
|
||||
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.core.provider.IVHelperProvider
|
||||
import com.gh.vspace.VHelper
|
||||
|
||||
@Route(path = RouteConsts.provider.vhelper, name = "VHelper暴露服务")
|
||||
class VHelperProviderImpl: IVHelperProvider {
|
||||
override fun getPlatformV(): String {
|
||||
return VHelper.PLATFORM_V
|
||||
}
|
||||
|
||||
override fun getVUrl(originUrl: String?): String {
|
||||
return VHelper.getVUrl(originUrl)
|
||||
}
|
||||
|
||||
override fun isVGameOn(): Boolean {
|
||||
return VHelper.isVGameOn()
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
@ -25,16 +25,6 @@ class WebProviderImpl : IWebProvider {
|
||||
return WebActivity.getSecurityCertificationIntent(context)
|
||||
}
|
||||
|
||||
override fun getQAIntent(
|
||||
context: Context?,
|
||||
url: String?,
|
||||
title: String?,
|
||||
isWebPageHandleBackPressed: Boolean,
|
||||
qaType: Int
|
||||
): Intent {
|
||||
return WebActivity.getQAIntent(context, url, title, isWebPageHandleBackPressed, qaType)
|
||||
}
|
||||
|
||||
override fun init(context: Context?) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@ -0,0 +1,57 @@
|
||||
package com.gh.common.repository
|
||||
|
||||
import com.gh.common.filter.RegionSettingHelper
|
||||
import com.gh.common.util.ApkActiveUtils
|
||||
import com.gh.gamecenter.core.utils.RandomUtils
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import io.reactivex.Observable
|
||||
|
||||
// 热门卡牌的仓库
|
||||
object RemenkapaiRepository {
|
||||
|
||||
var remenkapaiList = arrayListOf<GameEntity>()
|
||||
|
||||
@JvmStatic
|
||||
fun getRemenkapai(size: Int): Observable<List<GameEntity>> {
|
||||
return if (remenkapaiList.isEmpty()) {
|
||||
RetrofitManager.getInstance().api.remenkapai
|
||||
.map(RegionSettingHelper.filterGame)
|
||||
.map { gameList -> filterEntityWithoutApk(gameList) }
|
||||
.map { pickRandomSizeEntity(size) }
|
||||
.map(ApkActiveUtils.filterMapperList)
|
||||
} else {
|
||||
Observable.create { emitter -> emitter.onNext(pickRandomSizeEntity(size)) }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择随机数量的热门卡牌
|
||||
*/
|
||||
private fun pickRandomSizeEntity(size: Int): List<GameEntity> {
|
||||
if (size > remenkapaiList.size) return remenkapaiList
|
||||
|
||||
val randomGameList = arrayListOf<GameEntity>()
|
||||
val randomArray = RandomUtils.getRandomArray(size, remenkapaiList.size)
|
||||
for (i in randomArray) {
|
||||
randomGameList.add(remenkapaiList[i])
|
||||
}
|
||||
return randomGameList
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤没有 Apk 的实体
|
||||
*/
|
||||
private fun filterEntityWithoutApk(gameList: List<GameEntity>): List<GameEntity> {
|
||||
val realGameList = arrayListOf<GameEntity>()
|
||||
for (gameEntity in gameList) {
|
||||
val apk = gameEntity.getApk()
|
||||
if (apk.size != 0) {
|
||||
realGameList.add(gameEntity)
|
||||
}
|
||||
}
|
||||
remenkapaiList = realGameList
|
||||
return remenkapaiList
|
||||
}
|
||||
|
||||
}
|
||||
@ -7,9 +7,12 @@ import android.content.Intent
|
||||
import android.graphics.Bitmap
|
||||
import android.view.Gravity
|
||||
import androidx.core.content.FileProvider
|
||||
import com.g00fy2.versioncompare.Version
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.common.util.DownloadItemUtils
|
||||
import com.gh.common.util.LogUtils
|
||||
import com.gh.common.util.NewFlatLogUtils
|
||||
import com.gh.common.util.PackageUtils
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
@ -17,7 +20,7 @@ import com.gh.gamecenter.core.utils.EmptyCallback
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.core.utils.TimeUtils
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import com.lightgame.utils.AppManager
|
||||
|
||||
@ -8,6 +8,7 @@ import android.widget.ProgressBar
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.g00fy2.versioncompare.Version
|
||||
import com.gh.common.util.LogUtils
|
||||
import com.gh.common.util.NewFlatLogUtils
|
||||
import com.gh.common.util.PackageInstaller
|
||||
@ -19,8 +20,8 @@ import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.AppExecutor.uiExecutor
|
||||
import com.gh.gamecenter.core.utils.*
|
||||
import com.gh.gamecenter.feature.entity.ApkEntity
|
||||
import com.gh.gamecenter.feature.entity.SimulatorEntity
|
||||
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.*
|
||||
@ -145,31 +146,21 @@ class SimulatorDownloadManager private constructor() {
|
||||
|
||||
PermissionHelper.checkGetInstalledAppsListBeforeAction(context, object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
val isInstalledNewSimulator =
|
||||
SimulatorGameManager.isNewSimulatorInstalled(HaloApp.getInstance().application)
|
||||
//当没有安装新版本模拟器时候 判断是否隐藏
|
||||
if (simulator?.active == false && !isInstalledNewSimulator) {
|
||||
//判断是否隐藏
|
||||
if (simulator?.active == false) {
|
||||
showNoneEmulatorDialog(context)
|
||||
return
|
||||
}
|
||||
var isInstalled = PackageUtils.isInstalledFromAllPackage(
|
||||
context,
|
||||
simulator?.apk?.packageName
|
||||
)
|
||||
//模拟器管理界面还是用之前的逻辑
|
||||
if (isInstalledNewSimulator && location != SimulatorLocation.SIMULATOR_MANAGE) {
|
||||
isInstalled = isInstalledNewSimulator
|
||||
}
|
||||
val isInstalled = PackageUtils.isInstalledFromAllPackage(context, simulator?.apk?.packageName)
|
||||
// val versionFromInstalledApp = PackageUtils.getVersionNameByPackageName(simulator?.apk?.packageName)
|
||||
val shouldShowUpdate =
|
||||
PackageUtils.isInstalledApkMatchedMd5(simulator?.apk?.packageName, simulator?.apk?.md5)
|
||||
val shouldShowUpdate = PackageUtils.isInstalledApkMatchedMd5(simulator?.apk?.packageName, simulator?.apk?.md5)
|
||||
val showAlertTag = SPUtils.getString(SimulatorGameManager.SIMULATOR_UPDATE_SHOW_ALERT_TAG, "") //当天是否弹过
|
||||
val todayIsShow = showAlertTag == TimeUtils.getToday()
|
||||
downloadType = if (shouldShowUpdate && isInstalled) "update" else "download"
|
||||
if (downloadType == "update" && todayIsShow && location != SimulatorLocation.SIMULATOR_MANAGE) {
|
||||
if (downloadType == "update" && todayIsShow && location != SimulatorLocation.SIMULATOR_MANAGE){
|
||||
return
|
||||
}
|
||||
if (downloadType == "download" && isInstalled) {
|
||||
if (downloadType == "download" && isInstalled){
|
||||
return
|
||||
}
|
||||
val title = if (shouldShowUpdate && isInstalled) "更新模拟器" else "安装模拟器"
|
||||
|
||||
@ -8,7 +8,7 @@ import android.graphics.Bitmap
|
||||
import android.net.Uri
|
||||
import android.text.TextUtils
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.gamecenter.feature.utils.ApkActiveUtils
|
||||
import com.gh.common.util.ApkActiveUtils
|
||||
import com.gh.common.util.LogUtils
|
||||
import com.gh.common.util.PackageUtils
|
||||
import com.gh.download.DownloadManager
|
||||
@ -22,8 +22,8 @@ import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.core.utils.TimeUtils
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.core.utils.UrlFilterUtils
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.entity.SimulatorGameRecordEntity
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.SimulatorGameRecordEntity
|
||||
import com.gh.gamecenter.login.user.UserManager
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.gh.gamecenter.room.AppDatabase
|
||||
|
||||
@ -4,17 +4,25 @@ import android.net.Uri
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.utils.EnvHelper
|
||||
import com.gh.gamecenter.common.utils.tryWithDefaultCatch
|
||||
import com.gh.gamecenter.core.GHThreadFactory
|
||||
import java.util.concurrent.ExecutorService
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
/**
|
||||
* 活动相关数据统计辅助类
|
||||
*/
|
||||
object ActivityCountHelper {
|
||||
|
||||
private const val MAX_STAY_TIME = 320
|
||||
private val ACTIVITY_URL_COMMON_PREF by lazy {
|
||||
private val ACTIVITY_URL_COMMON_PREF =
|
||||
if (EnvHelper.isDevEnv) Constants.ACTIVITY_DETAIL_ADDRESS_DEV else Constants.ACTIVITY_DETAIL_ADDRESS
|
||||
}
|
||||
private var mStayTimeCount = 0
|
||||
private var mIsStayTimeCountEnabled = false
|
||||
private var mStayTimeArray = arrayOf(5, 10, 20, 40, 80, 160)
|
||||
private const val MAX_STAY_TIME = 320
|
||||
private val mThreadService: ExecutorService by lazy {
|
||||
Executors.newSingleThreadExecutor(GHThreadFactory("STAY_TIME_THREAD"))
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun postActivityPageEnter(url: String?, entrance: String) {
|
||||
@ -37,20 +45,34 @@ object ActivityCountHelper {
|
||||
}
|
||||
}
|
||||
|
||||
fun handleStayTime(url: String, stayTime: Int) {
|
||||
fun startCountStayTime(url: String) {
|
||||
if (url.contains(ACTIVITY_URL_COMMON_PREF)) {
|
||||
val uri = Uri.parse(url)
|
||||
val activityId = uri.getQueryParameter("id") ?: return
|
||||
when {
|
||||
stayTime % MAX_STAY_TIME == 0 -> NewFlatLogUtils.logActivityPageView(
|
||||
MAX_STAY_TIME,
|
||||
activityId
|
||||
)
|
||||
mStayTimeArray.contains(stayTime) -> NewFlatLogUtils.logActivityPageView(
|
||||
stayTime,
|
||||
activityId
|
||||
)
|
||||
mIsStayTimeCountEnabled = true
|
||||
mThreadService.execute {
|
||||
while (mIsStayTimeCountEnabled) {
|
||||
tryWithDefaultCatch {
|
||||
mStayTimeCount++
|
||||
when {
|
||||
mStayTimeCount % MAX_STAY_TIME == 0 -> NewFlatLogUtils.logActivityPageView(
|
||||
MAX_STAY_TIME,
|
||||
activityId
|
||||
)
|
||||
mStayTimeArray.contains(mStayTimeCount) -> NewFlatLogUtils.logActivityPageView(
|
||||
mStayTimeCount,
|
||||
activityId
|
||||
)
|
||||
}
|
||||
}
|
||||
Thread.sleep(1000)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun endCountStayTime() {
|
||||
mIsStayTimeCountEnabled = false
|
||||
mStayTimeCount = 0
|
||||
}
|
||||
}
|
||||
@ -1,15 +1,15 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.gamecenter.common.retrofit.Response
|
||||
import com.gh.gamecenter.common.utils.ImageUtils
|
||||
import com.gh.gamecenter.common.utils.observableToMain
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.entity.NewApiSettingsEntity
|
||||
import com.gh.gamecenter.common.utils.NetworkUtils
|
||||
import com.gh.gamecenter.entity.SettingsEntity
|
||||
import com.gh.gamecenter.entity.StartupAdEntity
|
||||
import com.gh.gamecenter.feature.entity.SettingsEntity
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
||||
object AdHelper {
|
||||
|
||||
@ -19,40 +19,24 @@ object AdHelper {
|
||||
const val LOCATION_SUGGESTION_FUNCTION = "suggestion_function"
|
||||
const val LOCATION_SIMULATOR_GAME = "simulator_game"
|
||||
|
||||
@JvmStatic
|
||||
fun getStartUpAd(): StartupAdEntity? {
|
||||
return Config.getNewApiSettingsEntity()?.startAd
|
||||
}
|
||||
@JvmField
|
||||
var startupAd = MutableLiveData<StartupAdEntity>()
|
||||
|
||||
@JvmStatic
|
||||
fun getStartUp(): StartupAdEntity? {
|
||||
return Config.getNewApiSettingsEntity()?.startup
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun prefetchStartUpAd(settingsEntity: NewApiSettingsEntity) {
|
||||
if (settingsEntity.startAd != null && !settingsEntity.startAd?.img.isNullOrEmpty()) {
|
||||
val screenWidth = DisplayUtils.getScreenWidth()
|
||||
val transformedUrl = ImageUtils.getTransformedUrl(settingsEntity.startAd?.img, screenWidth) ?: return
|
||||
ImageUtils.prefetchToDiskCache(transformedUrl)
|
||||
@SuppressLint("CheckResult")
|
||||
fun getStartUpAd() {
|
||||
if (!NetworkUtils.isNetworkConnected(HaloApp.getInstance())) {
|
||||
startupAd.postValue(null)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
fun getSettingAdCache() {
|
||||
RetrofitManager.getInstance().newApi
|
||||
.getSettingAdCache(HaloApp.getInstance().channel)
|
||||
.compose(observableToMain())
|
||||
.subscribe(object : Response<NewApiSettingsEntity>() {
|
||||
override fun onResponse(response: NewApiSettingsEntity?) {
|
||||
super.onResponse(response)
|
||||
val settings = Config.getNewApiSettingsEntity()
|
||||
if (settings != null) {
|
||||
settings.startAd = response?.startAd
|
||||
Config.updateNewApiSettings(settings)
|
||||
if (response != null) {
|
||||
prefetchStartUpAd(response)
|
||||
}
|
||||
}
|
||||
RetrofitManager.getInstance()
|
||||
.api
|
||||
.getSplashAd(HaloApp.getInstance().channel)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : BiResponse<StartupAdEntity>() {
|
||||
override fun onSuccess(data: StartupAdEntity) {
|
||||
startupAd.postValue(data)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
package com.gh.gamecenter.feature.utils;
|
||||
package com.gh.common.util;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.gh.gamecenter.common.constant.RouteConsts;
|
||||
import com.gh.gamecenter.core.provider.IPackagesManagerProvider;
|
||||
import com.gh.gamecenter.feature.BuildConfig;
|
||||
import com.gh.gamecenter.feature.entity.ApkEntity;
|
||||
import com.gh.gamecenter.feature.entity.GameEntity;
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.entity.ApkEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.manager.PackagesManager;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import java.util.List;
|
||||
@ -26,8 +24,7 @@ public class ApkActiveUtils {
|
||||
ApkEntity apkEntity = apkList.get(i);
|
||||
String packageName = apkEntity.getPackageName();
|
||||
String id = gameEntity.getId();
|
||||
IPackagesManagerProvider provider = (IPackagesManagerProvider)ARouter.getInstance().build(RouteConsts.provider.packagesManager).navigation();
|
||||
if (!apkEntity.isActive() && !provider.isCanPluggable(id, packageName)) {
|
||||
if (!apkEntity.isActive() && !PackagesManager.INSTANCE.isCanPluggable(id, packageName)) {
|
||||
apkList.remove(i);
|
||||
i--;
|
||||
}
|
||||
@ -1,253 +0,0 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import android.view.Window
|
||||
import android.widget.TextView
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.gh.download.simple.AutoUnregisteredSimpleDownloadListener
|
||||
import com.gh.download.simple.DownloadListener
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.eventbus.EBReuse
|
||||
import com.gh.gamecenter.common.utils.DialogHelper
|
||||
import com.gh.gamecenter.common.utils.dip2px
|
||||
import com.gh.gamecenter.common.utils.roundTo
|
||||
import com.gh.gamecenter.common.utils.toResString
|
||||
import com.gh.gamecenter.core.runOnUiThread
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.databinding.DialogArchiveLoadingBinding
|
||||
import com.gh.gamecenter.entity.ArchiveEntity
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.gh.vspace.VArchiveHelper
|
||||
import com.gh.vspace.VHelper
|
||||
import com.lg.download.DownloadError
|
||||
import com.lg.download.DownloadStatus
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import splitties.systemservices.layoutInflater
|
||||
|
||||
/**
|
||||
* 云存档下载按钮辅助类
|
||||
*/
|
||||
object ArchiveDownloadButtonHelper {
|
||||
|
||||
fun bindItem(
|
||||
context: Context,
|
||||
entrance: String,
|
||||
fragment: Fragment,
|
||||
packageName: String,
|
||||
archiveEntity: ArchiveEntity,
|
||||
downloadBtn: TextView,
|
||||
downloadCompletedListener: (() -> Unit)? = null
|
||||
) {
|
||||
downloadBtn.text = if (VArchiveHelper.isArchiveDownloaded(archiveEntity.md5)) {
|
||||
R.string.archive_apply.toResString()
|
||||
} else {
|
||||
R.string.archive_download.toResString()
|
||||
}
|
||||
downloadBtn.setOnClickListener {
|
||||
when {
|
||||
// 检查是否已安装畅玩助手
|
||||
!VHelper.isVSpaceInstalled(context) -> showVspaceTipDialog(context)
|
||||
// 检查是否已安装游戏
|
||||
!VHelper.isInstalled(packageName) -> {
|
||||
// 检查游戏是否在安装中
|
||||
if (!VHelper.isInstalling(packageName)) {
|
||||
showDownloadTipDialog(context)
|
||||
} else {
|
||||
ToastUtils.toast("游戏正在安装中,请稍候")
|
||||
}
|
||||
}
|
||||
// 检查本地是否已下载存档
|
||||
VArchiveHelper.isArchiveDownloaded(archiveEntity.md5) -> showApplyArchiveTipDialog(
|
||||
context,
|
||||
entrance,
|
||||
packageName,
|
||||
archiveEntity
|
||||
)
|
||||
// 检查完毕下载存档
|
||||
else -> downloadArchive(
|
||||
context,
|
||||
entrance,
|
||||
fragment,
|
||||
packageName,
|
||||
archiveEntity,
|
||||
downloadBtn,
|
||||
downloadCompletedListener
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showVspaceTipDialog(context: Context) {
|
||||
NewFlatLogUtils.logCloudArchiveVSpaceDownloadDialogShow()
|
||||
DialogHelper.showDialog(
|
||||
context,
|
||||
R.string.archive_dialog_title.toResString(),
|
||||
R.string.archive_vspace_dialog_content.toResString(),
|
||||
R.string.archive_vspace_dialog_confirm.toResString(),
|
||||
R.string.cancel.toResString(),
|
||||
{
|
||||
NewFlatLogUtils.logCloudArchiveVSpaceDownloadDialogClick(R.string.archive_vspace_dialog_confirm.toResString())
|
||||
VHelper.showVspaceDialog(context)
|
||||
},
|
||||
{
|
||||
NewFlatLogUtils.logCloudArchiveVSpaceDownloadDialogClick(R.string.cancel.toResString())
|
||||
},
|
||||
extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true)
|
||||
)
|
||||
}
|
||||
|
||||
private fun showDownloadTipDialog(context: Context) {
|
||||
NewFlatLogUtils.logCloudArchiveGameDownloadDialogShow()
|
||||
DialogHelper.showDialog(
|
||||
context,
|
||||
R.string.archive_dialog_title.toResString(),
|
||||
R.string.archive_download_dialog_content.toResString(),
|
||||
R.string.archive_download_dialog_confirm.toResString(),
|
||||
R.string.cancel.toResString(),
|
||||
{
|
||||
NewFlatLogUtils.logCloudArchiveGameDownloadDialogClick(R.string.archive_download_dialog_confirm.toResString())
|
||||
VHelper.disableLaunchGameAfterInstallation()
|
||||
EventBus.getDefault().post(EBReuse("download"))
|
||||
},
|
||||
{
|
||||
NewFlatLogUtils.logCloudArchiveGameDownloadDialogClick(R.string.cancel.toResString())
|
||||
},
|
||||
extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true)
|
||||
)
|
||||
}
|
||||
|
||||
private fun applyArchive(
|
||||
context: Context,
|
||||
entrance: String,
|
||||
packageName: String,
|
||||
archiveEntity: ArchiveEntity
|
||||
) {
|
||||
VArchiveHelper.getArchiveFile(archiveEntity.md5)?.run {
|
||||
|
||||
RetrofitManager.getInstance().newApi
|
||||
.postArchiveUsage(archiveEntity.gameId, archiveEntity.id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe()
|
||||
|
||||
VArchiveHelper.applyGameArchive(context, packageName, this) { packageName, isSuccess ->
|
||||
runOnUiThread {
|
||||
if (isSuccess) {
|
||||
VHelper.launch(context, packageName)
|
||||
} else {
|
||||
ToastUtils.toast(R.string.archive_apply_fail.toResString())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NewFlatLogUtils.logCloudArchiveDownloadOrApply(archiveEntity.name, entrance)
|
||||
}
|
||||
|
||||
private fun downloadArchive(
|
||||
context: Context,
|
||||
entrance: String,
|
||||
fragment: Fragment,
|
||||
packageName: String,
|
||||
archiveEntity: ArchiveEntity,
|
||||
downloadBtn: TextView,
|
||||
downloadCompletedListener: (() -> Unit)? = null
|
||||
) {
|
||||
// 执行下载
|
||||
VArchiveHelper.downloadArchive(archiveEntity)
|
||||
|
||||
// 下载进度弹窗
|
||||
val archiveLoadingDialog = Dialog(context, R.style.DialogWindowTransparent)
|
||||
val archiveLoadingBinding = DialogArchiveLoadingBinding.inflate(context.layoutInflater)
|
||||
showArchiveLoadingDialog(archiveLoadingDialog, archiveLoadingBinding.root)
|
||||
|
||||
// 下载进度监听
|
||||
AutoUnregisteredSimpleDownloadListener(archiveEntity.id, fragment, object : DownloadListener {
|
||||
override fun onError(error: DownloadError) {
|
||||
dismissArchiveLoadingDialog(archiveLoadingDialog)
|
||||
ToastUtils.toast(R.string.archive_download_fail.toResString())
|
||||
}
|
||||
|
||||
override fun onProgress(progress: Float) {
|
||||
archiveLoadingBinding.run {
|
||||
progressTv.text = "${progress.roundTo(1)}%"
|
||||
progressBar.progress = progress.toInt()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSizeReceived(fileSize: Long) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
override fun onStatusChanged(status: DownloadStatus) {
|
||||
when (status) {
|
||||
DownloadStatus.COMPLETED -> {
|
||||
dismissArchiveLoadingDialog(archiveLoadingDialog)
|
||||
downloadBtn.text = R.string.archive_apply.toResString()
|
||||
showApplyArchiveTipDialog(context, entrance, packageName, archiveEntity)
|
||||
downloadCompletedListener?.invoke()
|
||||
}
|
||||
else -> {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSpeedChanged(speed: Float) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
NewFlatLogUtils.logCloudArchiveDownloadOrApply(archiveEntity.name, entrance)
|
||||
}
|
||||
|
||||
private fun showArchiveLoadingDialog(
|
||||
archiveLoadingDialog: Dialog,
|
||||
contentView: View
|
||||
) {
|
||||
archiveLoadingDialog.run {
|
||||
setCancelable(false)
|
||||
setCanceledOnTouchOutside(false)
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||
setContentView(contentView)
|
||||
show()
|
||||
}
|
||||
archiveLoadingDialog.window?.attributes?.apply {
|
||||
width = DisplayUtils.getScreenWidth() - 120F.dip2px()
|
||||
archiveLoadingDialog.window?.attributes = this
|
||||
}
|
||||
}
|
||||
|
||||
private fun showApplyArchiveTipDialog(
|
||||
context: Context,
|
||||
entrance: String,
|
||||
packageName: String,
|
||||
archiveEntity: ArchiveEntity
|
||||
) {
|
||||
DialogHelper.showDialog(
|
||||
context,
|
||||
R.string.archive_dialog_title.toResString(),
|
||||
R.string.archive_apply_dialog_content.toResString(),
|
||||
R.string.archive_apply.toResString(),
|
||||
R.string.cancel.toResString(),
|
||||
{
|
||||
applyArchive(context, entrance, packageName, archiveEntity)
|
||||
NewFlatLogUtils.logCloudArchiveApplyDialogRelated("cloud_save_overwrite_dialog_click", "使用")
|
||||
},
|
||||
{ NewFlatLogUtils.logCloudArchiveApplyDialogRelated("cloud_save_overwrite_dialog_click", "取消") },
|
||||
extraConfig = DialogHelper.Config(centerTitle = true)
|
||||
)
|
||||
|
||||
NewFlatLogUtils.logCloudArchiveApplyDialogRelated("cloud_save_overwrite_dialog_show")
|
||||
}
|
||||
|
||||
private fun dismissArchiveLoadingDialog(archiveLoadingDialog: Dialog) {
|
||||
if (archiveLoadingDialog.isShowing) {
|
||||
archiveLoadingDialog.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -9,19 +9,19 @@ import android.view.View
|
||||
import android.view.Window
|
||||
import androidx.core.widget.doOnTextChanged
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.adapter.ReportReasonAdapter
|
||||
import com.gh.gamecenter.common.constant.CommonConsts
|
||||
import com.gh.gamecenter.core.utils.CurrentActivityHolder
|
||||
import com.gh.gamecenter.common.json.json
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse
|
||||
import com.gh.gamecenter.common.view.VerticalItemDecoration
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.SuggestionActivity
|
||||
import com.gh.gamecenter.adapter.ReportReasonAdapter
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.common.utils.toColor
|
||||
import com.gh.gamecenter.common.utils.toObject
|
||||
import com.gh.gamecenter.common.utils.toRequestBody
|
||||
import com.gh.gamecenter.common.view.VerticalItemDecoration
|
||||
import com.gh.gamecenter.core.utils.CurrentActivityHolder
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.databinding.DialogReportReasonBinding
|
||||
import com.gh.gamecenter.feature.entity.SettingsEntity
|
||||
import com.gh.gamecenter.entity.SettingsEntity
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
@ -35,7 +35,7 @@ object BbsReportHelper {
|
||||
fun showReportDialog(contentId: String) {
|
||||
val sp = PreferenceManager.getDefaultSharedPreferences(HaloApp.getInstance())
|
||||
val suggestion: SettingsEntity.Suggestion? =
|
||||
sp.getString(CommonConsts.SUGGESTION_HINT_TYPE, null)?.toObject()
|
||||
sp.getString(SuggestionActivity.SUGGESTION_HINT_TYPE, null)?.toObject()
|
||||
val reportList = suggestion?.report ?: return
|
||||
|
||||
CurrentActivityHolder.getCurrentActivity()?.apply {
|
||||
|
||||
131
app/src/main/java/com/gh/common/util/BbsStayTimeHelper.kt
Normal file
131
app/src/main/java/com/gh/common/util/BbsStayTimeHelper.kt
Normal file
@ -0,0 +1,131 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.app.Application
|
||||
import android.os.Bundle
|
||||
import com.gh.gamecenter.core.utils.CurrentActivityHolder
|
||||
import com.gh.gamecenter.core.GHThreadFactory
|
||||
import com.gh.gamecenter.MainActivity
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.common.utils.isPublishEnv
|
||||
import com.gh.gamecenter.common.utils.tryWithDefaultCatch
|
||||
import com.gh.gamecenter.forum.detail.ForumDetailActivity
|
||||
import com.gh.gamecenter.qa.article.detail.ArticleDetailActivity
|
||||
import com.gh.gamecenter.qa.comment.CommentActivity
|
||||
import com.gh.gamecenter.qa.questions.newdetail.NewQuestionDetailActivity
|
||||
import com.gh.gamecenter.qa.video.detail.ForumVideoDetailActivity
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.ResponseBody
|
||||
import java.util.concurrent.ExecutorService
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
object BbsStayTimeHelper {
|
||||
|
||||
private var mStayTimeCount = 0
|
||||
private var mIsStayTimeCountEnabled = false // 论坛停留时间统计是否开启
|
||||
private var mStayTimeTimeout = 30
|
||||
private var mIsStayTimeCountValid = false // 论坛停留时间统计是否有效
|
||||
|
||||
const val IS_BBS_CONTENT_VISIBLE = "is_bbs_content_visible"
|
||||
|
||||
private val mThreadService: ExecutorService by lazy {
|
||||
Executors.newSingleThreadExecutor(GHThreadFactory("STAY_TIME_THREAD"))
|
||||
}
|
||||
|
||||
private val mActivityLifecycleCallbacks by lazy {
|
||||
object : Application.ActivityLifecycleCallbacks {
|
||||
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {}
|
||||
override fun onActivityStopped(activity: Activity) {}
|
||||
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {}
|
||||
override fun onActivityDestroyed(activity: Activity) {}
|
||||
override fun onActivityStarted(activity: Activity) {}
|
||||
|
||||
override fun onActivityResumed(activity: Activity) {
|
||||
if (isTopActivityBbsRelated(activity) && mIsStayTimeCountEnabled) {
|
||||
resumeTimeCount()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityPaused(activity: Activity) {
|
||||
if (isTopActivityBbsRelated(activity) && mIsStayTimeCountEnabled) {
|
||||
pauseTimeCount()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun enableStayTimeCount(timeout: Int) {
|
||||
mIsStayTimeCountEnabled = true
|
||||
mStayTimeTimeout = timeout
|
||||
|
||||
resumeTimeCount()
|
||||
|
||||
HaloApp.getInstance().registerActivityLifecycleCallbacks(mActivityLifecycleCallbacks)
|
||||
}
|
||||
|
||||
fun disableStayTimeCount() {
|
||||
mIsStayTimeCountEnabled = false
|
||||
mStayTimeCount = 0
|
||||
|
||||
HaloApp.getInstance().unregisterActivityLifecycleCallbacks(mActivityLifecycleCallbacks)
|
||||
}
|
||||
|
||||
fun resumeTimeCount() {
|
||||
if (!mIsStayTimeCountEnabled) return
|
||||
|
||||
mIsStayTimeCountValid = true
|
||||
|
||||
mThreadService.execute {
|
||||
while (mIsStayTimeCountEnabled && mIsStayTimeCountValid) {
|
||||
val topActivity = CurrentActivityHolder.getCurrentActivity() ?: continue
|
||||
if (isTopActivityBbsRelated(topActivity)) {
|
||||
tryWithDefaultCatch {
|
||||
mStayTimeCount++
|
||||
if (mStayTimeCount >= mStayTimeTimeout) {
|
||||
postExploreFinish()
|
||||
}
|
||||
}
|
||||
}
|
||||
Thread.sleep(1000)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun pauseTimeCount() {
|
||||
if (!mIsStayTimeCountEnabled) return
|
||||
|
||||
mIsStayTimeCountValid = false
|
||||
}
|
||||
|
||||
private fun isTopActivityBbsRelated(activity: Activity): Boolean {
|
||||
return (activity is MainActivity && activity.intent.extras?.getBoolean(IS_BBS_CONTENT_VISIBLE) == true)
|
||||
|| activity is ForumDetailActivity
|
||||
|| activity is ArticleDetailActivity
|
||||
|| activity is ForumVideoDetailActivity
|
||||
|| activity is CommentActivity
|
||||
|| activity is NewQuestionDetailActivity
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private fun postExploreFinish() {
|
||||
RetrofitManager.getInstance()
|
||||
.api
|
||||
.postExplorerFinish()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
if (!isPublishEnv()) {
|
||||
ToastUtils.toast("完成了论坛停留任务(仅测试环境有这个 toast 不要慌)")
|
||||
}
|
||||
disableStayTimeCount()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,9 +1,11 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.content.Context
|
||||
import com.gh.gamecenter.eventbus.EBCollectionChanged
|
||||
import com.gh.gamecenter.login.user.UserManager
|
||||
import com.gh.gamecenter.common.retrofit.Response
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.ResponseBody
|
||||
@ -17,16 +19,18 @@ import retrofit2.HttpException
|
||||
object CollectionUtils {
|
||||
|
||||
enum class CollectionType {
|
||||
TOOLKIT, ARTICLE, ANSWER, COMMUNITY_ARTICLE
|
||||
toolkit, article, answer, communityArticle
|
||||
}
|
||||
|
||||
fun postCollection(content: String, type: CollectionType, listener: OnCollectionListener) {
|
||||
val api = RetrofitManager.getInstance().api
|
||||
fun postCollection(context: Context, content: String, type: CollectionType, listener: OnCollectionListener) {
|
||||
|
||||
val postCollection = when (type) {
|
||||
CollectionType.ARTICLE -> api.postCollectionArticle(UserManager.getInstance().userId, content)
|
||||
CollectionType.TOOLKIT -> api.postCollectionTools(UserManager.getInstance().userId, content)
|
||||
CollectionType.ANSWER -> api.postCollectionAnswer(UserManager.getInstance().userId, content)
|
||||
CollectionType.article -> RetrofitManager.getInstance().getApi()
|
||||
.postCollectionArticle(UserManager.getInstance().userId, content)
|
||||
CollectionType.toolkit -> RetrofitManager.getInstance().getApi()
|
||||
.postCollectionTools(UserManager.getInstance().userId, content)
|
||||
CollectionType.answer -> RetrofitManager.getInstance().getApi()
|
||||
.postCollectionAnswer(UserManager.getInstance().userId, content)
|
||||
else -> return
|
||||
}
|
||||
postCollection
|
||||
@ -43,7 +47,7 @@ object CollectionUtils {
|
||||
super.onFailure(e)
|
||||
if (e != null) {
|
||||
try {
|
||||
val string = e.response()?.errorBody()?.string() ?: ""
|
||||
val string = e.response()?.errorBody()?.string()
|
||||
val errorBody = JSONObject(string)
|
||||
if (errorBody.getInt("code") == 403009) {
|
||||
listener.onSuccess()
|
||||
@ -58,13 +62,16 @@ object CollectionUtils {
|
||||
})
|
||||
}
|
||||
|
||||
fun deleteCollection(id: String, type: CollectionType, listener: OnCollectionListener) {
|
||||
val api = RetrofitManager.getInstance().api
|
||||
fun deleteCollection(context: Context, id: String, type: CollectionType, listener: OnCollectionListener) {
|
||||
|
||||
val postCollection = when (type) {
|
||||
CollectionType.ARTICLE -> api.deletaCollectionArticle(UserManager.getInstance().userId, id)
|
||||
CollectionType.TOOLKIT -> api.deleteCollectionTools(UserManager.getInstance().userId, id)
|
||||
CollectionType.ANSWER -> api.deleteCollectionAnswer(UserManager.getInstance().userId, id)
|
||||
val postCollection: Observable<ResponseBody>
|
||||
when (type) {
|
||||
CollectionType.article -> postCollection =
|
||||
RetrofitManager.getInstance().getApi().deletaCollectionArticle(UserManager.getInstance().userId, id)
|
||||
CollectionType.toolkit -> postCollection =
|
||||
RetrofitManager.getInstance().getApi().deleteCollectionTools(UserManager.getInstance().userId, id)
|
||||
CollectionType.answer -> postCollection =
|
||||
RetrofitManager.getInstance().getApi().deleteCollectionAnswer(UserManager.getInstance().userId, id)
|
||||
else -> return
|
||||
}
|
||||
postCollection
|
||||
|
||||
@ -10,15 +10,22 @@ import com.gh.gamecenter.CommentDetailActivity
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.json.json
|
||||
import com.gh.gamecenter.common.retrofit.Response
|
||||
import com.gh.gamecenter.common.utils.DialogHelper
|
||||
import com.gh.gamecenter.common.utils.ifLogin
|
||||
import com.gh.gamecenter.common.utils.showAutoOrientation
|
||||
import com.gh.gamecenter.common.view.BugFixedPopupWindow
|
||||
import com.gh.gamecenter.entity.CommentEntity
|
||||
import com.gh.gamecenter.feature.entity.Permissions
|
||||
import com.gh.gamecenter.entity.MeEntity
|
||||
import com.gh.gamecenter.entity.Permissions
|
||||
import com.gh.gamecenter.login.user.UserManager
|
||||
import com.gh.gamecenter.qa.comment.OnCommentOptionClickListener
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Utils
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.ResponseBody
|
||||
import org.json.JSONObject
|
||||
import retrofit2.HttpException
|
||||
|
||||
@ -309,6 +316,200 @@ object CommentHelper {
|
||||
popupWindow.showAutoOrientation(view)
|
||||
}
|
||||
|
||||
private fun showControlDialog(
|
||||
context: Context,
|
||||
answerId: String? = null,
|
||||
articleId: String? = null,
|
||||
communityId: String? = null,
|
||||
comment: CommentEntity,
|
||||
me: MeEntity
|
||||
) {
|
||||
val dialogOptions = arrayListOf<String>()
|
||||
val highlight = "置顶评论"
|
||||
val hide = "隐藏评论"
|
||||
|
||||
var canHighlightCommentDirectly = false
|
||||
var canHideCommentDirectly = false
|
||||
|
||||
if (me.isModerator || me.moderatorPermissions.topAnswerComment > Permissions.GUEST
|
||||
|| me.moderatorPermissions.topCommunityArticleComment > Permissions.GUEST
|
||||
) {
|
||||
dialogOptions.add(highlight)
|
||||
if (me.moderatorPermissions.topAnswerComment > Permissions.REPORTER
|
||||
|| me.moderatorPermissions.topCommunityArticleComment > Permissions.REPORTER
|
||||
) {
|
||||
canHighlightCommentDirectly = true
|
||||
}
|
||||
}
|
||||
|
||||
if (me.isModerator || me.moderatorPermissions.hideAnswerComment > Permissions.GUEST
|
||||
|| me.moderatorPermissions.hideCommunityArticleComment > Permissions.GUEST
|
||||
) {
|
||||
dialogOptions.add(hide)
|
||||
if (me.moderatorPermissions.hideAnswerComment > Permissions.REPORTER
|
||||
|| me.moderatorPermissions.hideCommunityArticleComment > Permissions.REPORTER
|
||||
) {
|
||||
canHideCommentDirectly = true
|
||||
}
|
||||
}
|
||||
|
||||
val highlightDialogHintContent = if (canHighlightCommentDirectly) {
|
||||
"你的操作将立即生效,确定提交吗?(你的管理权限为:高级)"
|
||||
} else {
|
||||
"你的操作将提交给小编审核,确定提交吗?"
|
||||
}
|
||||
|
||||
val hideDialogHintContent = if (canHideCommentDirectly) {
|
||||
"你的操作将立即生效,确定提交吗?(你的管理权限为:高级)"
|
||||
} else {
|
||||
"你的操作将提交给小编审核,确定提交吗?"
|
||||
}
|
||||
|
||||
val disabledOptions = arrayListOf<String>()
|
||||
|
||||
if (comment.priority != 0) {
|
||||
disabledOptions.add(highlight)
|
||||
}
|
||||
|
||||
comment.me?.let {
|
||||
if (it.isCommentOwner) {
|
||||
disabledOptions.add(highlight)
|
||||
}
|
||||
}
|
||||
|
||||
DialogUtils.showListDialog(context, dialogOptions, disabledOptions) {
|
||||
when (it) {
|
||||
highlight -> {
|
||||
if (comment.priority != 0) {
|
||||
Utils.toast(context, "评论已经置顶")
|
||||
return@showListDialog
|
||||
}
|
||||
|
||||
comment.me?.let { me ->
|
||||
if (me.isCommentOwner) {
|
||||
Utils.toast(context, "不能置顶自己的评论")
|
||||
return@showListDialog
|
||||
}
|
||||
}
|
||||
|
||||
val highlightObserver = object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
if (canHighlightCommentDirectly) {
|
||||
Utils.toast(context, "置顶成功,请刷新列表")
|
||||
} else {
|
||||
Utils.toast(context, "提交成功")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailure(e: HttpException?) {
|
||||
super.onFailure(e)
|
||||
e?.let { httpException ->
|
||||
if (httpException.code() == 403) {
|
||||
val string = e.response().errorBody()?.string()
|
||||
val errorJson = JSONObject(string)
|
||||
val errorCode = errorJson.getInt("code")
|
||||
if (errorCode == 403059) {
|
||||
Utils.toast(
|
||||
HaloApp.getInstance().application,
|
||||
"权限错误,请刷新后重试"
|
||||
)
|
||||
return
|
||||
} else {
|
||||
Utils.toast(HaloApp.getInstance().application, e.message())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (answerId != null) {
|
||||
DialogHelper.showDialog(
|
||||
context, highlight, highlightDialogHintContent,
|
||||
"确定", "取消", {
|
||||
RetrofitManager.getInstance().api
|
||||
.highlightAnswerComment(answerId, comment.id)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(highlightObserver)
|
||||
},
|
||||
extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true)
|
||||
)
|
||||
} else {
|
||||
DialogHelper.showDialog(
|
||||
context, highlight, highlightDialogHintContent,
|
||||
"确定", "取消", {
|
||||
RetrofitManager.getInstance().api
|
||||
.highlightCommunityArticleComment(comment.id)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(highlightObserver)
|
||||
},
|
||||
extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
hide -> {
|
||||
val hideObserver = object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
if (canHideCommentDirectly) {
|
||||
Utils.toast(context, "隐藏成功,请刷新列表")
|
||||
} else {
|
||||
Utils.toast(context, "提交成功")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailure(e: HttpException?) {
|
||||
super.onFailure(e)
|
||||
e?.let { httpException ->
|
||||
if (httpException.code() == 403) {
|
||||
val string = e.response().errorBody()?.string()
|
||||
val errorJson = JSONObject(string)
|
||||
val errorCode = errorJson.getInt("code")
|
||||
if (errorCode == 403059) {
|
||||
Utils.toast(
|
||||
HaloApp.getInstance().application,
|
||||
"权限错误,请刷新后重试"
|
||||
)
|
||||
return
|
||||
} else {
|
||||
Utils.toast(HaloApp.getInstance().application, e.message())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (answerId != null) {
|
||||
DialogHelper.showDialog(
|
||||
context, hide, hideDialogHintContent,
|
||||
"确定", "取消", {
|
||||
RetrofitManager.getInstance().api
|
||||
.hideAnswerComment(answerId, comment.id)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(hideObserver)
|
||||
},
|
||||
extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true)
|
||||
)
|
||||
} else {
|
||||
DialogHelper.showDialog(
|
||||
context, hide, hideDialogHintContent,
|
||||
"确定", "取消", {
|
||||
RetrofitManager.getInstance().api
|
||||
.hideCommunityArticleComment(comment.id)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(hideObserver)
|
||||
},
|
||||
extraConfig = DialogHelper.Config(centerTitle = true, centerContent = true)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showReportTypeDialog(
|
||||
context: Context,
|
||||
reportCallback: (reportType: String) -> Unit
|
||||
|
||||
@ -3,6 +3,7 @@ package com.gh.common.util;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
@ -25,7 +26,7 @@ import com.gh.gamecenter.core.utils.DisplayUtils;
|
||||
import com.gh.gamecenter.core.utils.NumberUtils;
|
||||
import com.gh.gamecenter.core.utils.ToastUtils;
|
||||
import com.gh.gamecenter.entity.CommentEntity;
|
||||
import com.gh.gamecenter.feature.entity.MeEntity;
|
||||
import com.gh.gamecenter.entity.MeEntity;
|
||||
import com.gh.gamecenter.login.entity.UserInfoEntity;
|
||||
import com.gh.gamecenter.login.user.UserManager;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.content.Context
|
||||
import android.text.TextUtils
|
||||
import com.gh.gamecenter.eventbus.EBConcernChanged
|
||||
import com.gh.gamecenter.login.user.UserManager
|
||||
@ -7,8 +8,11 @@ import com.gh.gamecenter.common.retrofit.Response
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.ResponseBody
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.json.JSONArray
|
||||
import retrofit2.HttpException
|
||||
|
||||
/**
|
||||
@ -21,8 +25,9 @@ object ConcernUtils {
|
||||
* autoConcern:是否自动关注'关联关注'
|
||||
*/
|
||||
fun postConcernGameId(
|
||||
context: Context,
|
||||
gameId: String,
|
||||
listener: OnConcernListener?,
|
||||
listener: onConcernListener?,
|
||||
autoConcern: Boolean = false
|
||||
) {
|
||||
val mode = if (autoConcern) "auto" else "manual"
|
||||
@ -48,7 +53,7 @@ object ConcernUtils {
|
||||
})
|
||||
}
|
||||
|
||||
fun deleteConcernData(gameId: String, listener: OnConcernListener?) {
|
||||
fun deleteConcernData(context: Context, gameId: String, listener: onConcernListener?) {
|
||||
RetrofitManager.getInstance().api
|
||||
.deleteConcern(UserManager.getInstance().userId, gameId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
@ -67,7 +72,73 @@ object ConcernUtils {
|
||||
})
|
||||
}
|
||||
|
||||
interface OnConcernListener {
|
||||
fun updateConcernData(context: Context, data: JSONArray) {
|
||||
val body = RequestBody.create(
|
||||
MediaType.parse("application/json"),
|
||||
data.toString()
|
||||
)
|
||||
RetrofitManager.getInstance().api
|
||||
.putConcern(UserManager.getInstance().userId, body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
EventBus.getDefault().post(EBConcernChanged())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun deleteConcernQuestions(context: Context, questionsId: String, listener: onConcernListener?) {
|
||||
RetrofitManager.getInstance().api
|
||||
.deleteConcernQuestions(UserManager.getInstance().userId, questionsId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
super.onResponse(response)
|
||||
listener?.onSuccess()
|
||||
}
|
||||
|
||||
override fun onFailure(e: HttpException?) {
|
||||
super.onFailure(e)
|
||||
listener?.onError()
|
||||
var errorString: String? = null
|
||||
try {
|
||||
errorString = e?.response()?.errorBody()?.string()
|
||||
} catch (e1: Exception) {
|
||||
e1.printStackTrace()
|
||||
}
|
||||
ErrorHelper.handleError(context, errorString, false)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun postConcernQuestions(context: Context, questionsId: String, listener: onConcernListener?) {
|
||||
RetrofitManager.getInstance().api
|
||||
.postConcernQuestions(UserManager.getInstance().userId, questionsId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
super.onResponse(response)
|
||||
listener?.onSuccess()
|
||||
}
|
||||
|
||||
override fun onFailure(e: HttpException?) {
|
||||
super.onFailure(e)
|
||||
listener?.onError()
|
||||
var errorString: String? = null
|
||||
try {
|
||||
errorString = e?.response()?.errorBody()?.string()
|
||||
} catch (e1: Exception) {
|
||||
e1.printStackTrace()
|
||||
}
|
||||
ErrorHelper.handleError(context, errorString, false)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
interface onConcernListener {
|
||||
fun onSuccess()
|
||||
fun onError()
|
||||
}
|
||||
|
||||
@ -6,9 +6,8 @@ import android.os.Build;
|
||||
import com.gh.gamecenter.common.constant.Constants;
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts;
|
||||
import com.gh.gamecenter.common.utils.NetworkUtils;
|
||||
import com.gh.gamecenter.feature.entity.GameEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.entity.NewsDetailEntity;
|
||||
import com.gh.gamecenter.feature.utils.PlatformUtils;
|
||||
import com.gh.gamecenter.manager.DataCollectionManager;
|
||||
import com.gh.gamecenter.manager.PackagesManager;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
@ -72,6 +71,16 @@ public class DataCollectionUtils {
|
||||
DataCollectionManager.onEvent(context, "click-item", map);
|
||||
}
|
||||
|
||||
// 上传游戏数据
|
||||
public static void uploadGame(Context context, GameEntity gameEntity, int seconds, String from) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("game", gameEntity.getName());
|
||||
map.put("game_id", gameEntity.getId());
|
||||
map.put("time", seconds);
|
||||
map.put("from", from);
|
||||
DataCollectionManager.onEvent(context, "game", map);
|
||||
}
|
||||
|
||||
// 上传新闻数据
|
||||
public static void uploadNews(Context context, NewsDetailEntity newsDetailEntity,
|
||||
GameEntity gameEntity, int seconds, String from) {
|
||||
@ -107,6 +116,15 @@ public class DataCollectionUtils {
|
||||
DataCollectionManager.onEvent(context, "hijack", map);
|
||||
}
|
||||
|
||||
// 上传用户数据
|
||||
public static void uploadUser(Context context) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("type", Build.MODEL);
|
||||
map.put("system", Build.VERSION.SDK_INT + "=" + Build.VERSION.RELEASE);
|
||||
map.put("install", PackagesManager.INSTANCE.getInstalledList());
|
||||
DataCollectionManager.upsert(context, "user", map);
|
||||
}
|
||||
|
||||
// 上传搜索数据
|
||||
public static void uploadSearch(Context context, String... args) {
|
||||
if (args.length != 5) {
|
||||
|
||||
@ -2,14 +2,17 @@ package com.gh.common.util;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Application;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.gh.base.GlobalActivityManager;
|
||||
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.common.base.activity.BaseActivity;
|
||||
import com.gh.gamecenter.common.constant.Constants;
|
||||
@ -123,16 +126,6 @@ public class DataUtils {
|
||||
|
||||
// 避免初始化顺序问题导致 MetaUtil 一直持有空的 gid
|
||||
MetaUtil.INSTANCE.refreshMeta();
|
||||
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(GhContentProvider.KEY_GID, gid);
|
||||
values.put(GhContentProvider.KEY_ANDROID_ID, MetaUtil.getBase64EncodedAndroidId());
|
||||
try {
|
||||
HaloApp.getInstance().getContentResolver().insert(Uri.parse("content://com.gh.gamecenter.provider/device"), values);
|
||||
} catch (Exception exception) {
|
||||
SentryHelper.INSTANCE.onEvent("DEVICE_INSERT_ERROR", "exception_digest", exception.getLocalizedMessage());
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -8,21 +8,19 @@ import com.gh.common.filter.RegionSetting;
|
||||
import com.gh.common.filter.RegionSettingHelper;
|
||||
import com.gh.common.repository.ReservationRepository;
|
||||
import com.gh.common.simulator.SimulatorGameManager;
|
||||
import com.gh.gamecenter.feature.view.DownloadButton;
|
||||
import com.gh.common.view.DownloadButton;
|
||||
import com.gh.common.xapk.XapkInstaller;
|
||||
import com.gh.common.xapk.XapkUnzipStatus;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.DetailViewHolder;
|
||||
import com.gh.gamecenter.common.constant.Constants;
|
||||
import com.gh.gamecenter.common.entity.LinkEntity;
|
||||
import com.gh.gamecenter.common.utils.ExtensionsKt;
|
||||
import com.gh.gamecenter.core.utils.SPUtils;
|
||||
import com.gh.gamecenter.feature.entity.PluginLocation;
|
||||
import com.gh.gamecenter.common.entity.LinkEntity;
|
||||
import com.gh.gamecenter.entity.PluginLocation;
|
||||
import com.gh.gamecenter.manager.PackagesManager;
|
||||
import com.gh.vspace.VHelper;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
import com.lightgame.download.DownloadStatus;
|
||||
|
||||
/**
|
||||
* Created by khy on 27/06/17.
|
||||
@ -38,10 +36,6 @@ public class DetailDownloadUtils {
|
||||
viewHolder.getOverlayTv().setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (viewHolder.mMultiVersionDownloadTv != null) {
|
||||
viewHolder.mMultiVersionDownloadTv.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (viewHolder.gameEntity != null
|
||||
&& Config.isShowDownload(viewHolder.gameEntity.getId())
|
||||
&& !"光环助手".equals(viewHolder.gameEntity.getName())) {
|
||||
@ -177,34 +171,8 @@ public class DetailDownloadUtils {
|
||||
}
|
||||
viewHolder.mDownloadPb.setText(downloadText);
|
||||
} else {
|
||||
viewHolder.mMultiVersionDownloadTv.setText("选择下载你的版本" + (TextUtils.isEmpty(downloadAddWord) ? "" : "-" + downloadAddWord));
|
||||
viewHolder.mMultiVersionDownloadTv.setVisibility(View.VISIBLE);
|
||||
viewHolder.mDownloadPb.setText("");
|
||||
viewHolder.mDownloadPb.setText("选择下载你的版本" + (TextUtils.isEmpty(downloadAddWord) ? "" : "-" + downloadAddWord) + " >");
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.NORMAL);
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(viewHolder.gameEntity);
|
||||
if (downloadEntity != null) {
|
||||
switch (downloadEntity.getStatus()) {
|
||||
case downloading:
|
||||
viewHolder.mDownloadTips.setVisibility(View.VISIBLE);
|
||||
ExtensionsKt.setDownloadTipsAnimation(viewHolder.mDownloadTips, true);
|
||||
break;
|
||||
case done:
|
||||
case pause:
|
||||
case waiting:
|
||||
case timeout:
|
||||
case subscribe:
|
||||
case neterror:
|
||||
case overflow:
|
||||
viewHolder.mDownloadTips.setVisibility(View.VISIBLE);
|
||||
ExtensionsKt.setDownloadTipsAnimation(viewHolder.mDownloadTips, false);
|
||||
break;
|
||||
default:
|
||||
viewHolder.mDownloadTips.setVisibility(View.GONE);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
viewHolder.mDownloadTips.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
if (isCheck && viewHolder.gameEntity.getApk().size() == 1) {
|
||||
@ -235,14 +203,10 @@ public class DetailDownloadUtils {
|
||||
|
||||
if (XapkUnzipStatus.UNZIPPING.name().equals(xapkStatus)) {
|
||||
String percent = downloadEntity.getMeta().get(XapkInstaller.XAPK_UNZIP_PERCENT);
|
||||
viewHolder.mDownloadPb.setText("游戏解压中 " + percent + "%");
|
||||
viewHolder.mDownloadPb.setText("解压中(" + percent + "%)");
|
||||
viewHolder.mDownloadPb.setProgress((int) (Float.valueOf(percent) * 10));
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.XAPK_UNZIPPING);
|
||||
return;
|
||||
} else if (XapkUnzipStatus.FAILURE.name().equals(xapkStatus)) {
|
||||
viewHolder.mDownloadPb.setText(R.string.install);
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.XAPK_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
viewHolder.mDownloadPb.setProgress((int) (viewHolder.downloadEntity.getPercent() * 10));
|
||||
@ -256,25 +220,30 @@ public class DetailDownloadUtils {
|
||||
}
|
||||
|
||||
switch (downloadEntity.getStatus()) {
|
||||
case timeout:
|
||||
case neterror:
|
||||
case subscribe:
|
||||
case downloading:
|
||||
case redirected:
|
||||
case pause:
|
||||
case overflow:
|
||||
String downloadingText = "游戏加载中 " + downloadEntity.getPercent() + "%";
|
||||
String resumeText = "继续加载 " + downloadEntity.getPercent() + "%";
|
||||
viewHolder.mDownloadPb.setText((downloadEntity.getStatus() == DownloadStatus.downloading || downloadEntity.getStatus() == DownloadStatus.redirected) ? downloadingText : resumeText);
|
||||
if (SPUtils.getBoolean(Constants.SP_USE_BROWSER_TO_INSTALL)) {
|
||||
viewHolder.mDownloadPb.setText(R.string.browser_install_downloading);
|
||||
} else {
|
||||
viewHolder.mDownloadPb.setText(R.string.downloading);
|
||||
}
|
||||
if (downloadEntity.isPluggable() && PackagesManager.INSTANCE.isInstalled(downloadEntity.getPackageName())) {
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_PLUGIN);
|
||||
} else {
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_NORMAL);
|
||||
}
|
||||
break;
|
||||
case timeout:
|
||||
case neterror:
|
||||
case waiting:
|
||||
case subscribe:
|
||||
viewHolder.mDownloadPb.setText(R.string.waiting);
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.WAITING);
|
||||
if (downloadEntity.isPluggable() && PackagesManager.INSTANCE.isInstalled(downloadEntity.getPackageName())) {
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_PLUGIN);
|
||||
} else {
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_NORMAL);
|
||||
}
|
||||
break;
|
||||
case done:
|
||||
if (SimulatorGameManager.isSimulatorGame(viewHolder.gameEntity)) {
|
||||
@ -335,19 +304,18 @@ public class DetailDownloadUtils {
|
||||
|
||||
private static void updateVStyleButton(DetailViewHolder viewHolder) {
|
||||
switch (viewHolder.downloadEntity.getStatus()) {
|
||||
case redirected:
|
||||
case downloading:
|
||||
case overflow:
|
||||
viewHolder.mDownloadPb.setText("游戏加载中 " + viewHolder.downloadEntity.getPercent() + "%");
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_NORMAL);
|
||||
break;
|
||||
case timeout:
|
||||
case neterror:
|
||||
case waiting:
|
||||
case subscribe:
|
||||
viewHolder.mDownloadPb.setText(R.string.waiting);
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_NORMAL);
|
||||
break;
|
||||
case overflow:
|
||||
case timeout:
|
||||
case neterror:
|
||||
case subscribe:
|
||||
case pause:
|
||||
viewHolder.mDownloadPb.setText("继续加载 " + viewHolder.downloadEntity.getPercent() + "%");
|
||||
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_NORMAL);
|
||||
|
||||
@ -4,9 +4,11 @@ import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.CountDownTimer;
|
||||
import android.provider.Settings;
|
||||
@ -20,6 +22,7 @@ import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.ClickableSpan;
|
||||
import android.text.style.URLSpan;
|
||||
import android.text.style.UnderlineSpan;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -28,11 +31,15 @@ import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
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.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
@ -43,6 +50,7 @@ import com.gh.common.constant.Config;
|
||||
import com.gh.common.filter.RegionSetting;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.ShellActivity;
|
||||
import com.gh.gamecenter.SuggestionActivity;
|
||||
import com.gh.gamecenter.adapter.ReportReasonAdapter;
|
||||
import com.gh.gamecenter.adapter.viewholder.PrivacyPolicyItemViewHolder;
|
||||
import com.gh.gamecenter.common.base.TrackableDialog;
|
||||
@ -50,9 +58,6 @@ import com.gh.gamecenter.common.callback.CancelListener;
|
||||
import com.gh.gamecenter.common.callback.ConfirmListener;
|
||||
import com.gh.gamecenter.common.callback.SimpleCallback;
|
||||
import com.gh.gamecenter.common.databinding.DialogAlertDefaultBinding;
|
||||
import com.gh.gamecenter.common.entity.SimpleGameEntity;
|
||||
import com.gh.gamecenter.common.entity.SuggestType;
|
||||
import com.gh.gamecenter.common.utils.DialogHelper;
|
||||
import com.gh.gamecenter.common.utils.ExtensionsKt;
|
||||
import com.gh.gamecenter.common.utils.ImageUtils;
|
||||
import com.gh.gamecenter.common.utils.NetworkUtils;
|
||||
@ -68,32 +73,40 @@ import com.gh.gamecenter.core.utils.EmptyCallback;
|
||||
import com.gh.gamecenter.core.utils.MtaHelper;
|
||||
import com.gh.gamecenter.core.utils.SPUtils;
|
||||
import com.gh.gamecenter.core.utils.SpanBuilder;
|
||||
import com.gh.gamecenter.core.utils.StringUtils;
|
||||
import com.gh.gamecenter.core.utils.ToastUtils;
|
||||
import com.gh.gamecenter.databinding.DialogBindPhoneBinding;
|
||||
import com.gh.gamecenter.databinding.DialogOverseaConfirmationBinding;
|
||||
import com.gh.gamecenter.databinding.DialogPackageParseErrorBinding;
|
||||
import com.gh.gamecenter.databinding.DialogReceiveLibaoSuccessBinding;
|
||||
import com.gh.gamecenter.databinding.DialogRelievePhoneBinding;
|
||||
import com.gh.gamecenter.databinding.DialogReportReasonBinding;
|
||||
import com.gh.gamecenter.databinding.DialogWechatReserveSuccessBinding;
|
||||
import com.gh.gamecenter.databinding.ImprintContentItemBinding;
|
||||
import com.gh.gamecenter.databinding.PrivacyItemBinding;
|
||||
import com.gh.gamecenter.entity.ApkEntity;
|
||||
import com.gh.gamecenter.entity.BadgeEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.entity.PermissionsEntity;
|
||||
import com.gh.gamecenter.entity.PrivacyPolicyEntity;
|
||||
import com.gh.gamecenter.entity.SettingsEntity;
|
||||
import com.gh.gamecenter.entity.SimpleGameEntity;
|
||||
import com.gh.gamecenter.entity.TrackableEntity;
|
||||
import com.gh.gamecenter.feature.entity.ApkEntity;
|
||||
import com.gh.gamecenter.feature.entity.Badge;
|
||||
import com.gh.gamecenter.feature.entity.GameEntity;
|
||||
import com.gh.gamecenter.feature.entity.SettingsEntity;
|
||||
import com.gh.gamecenter.help.HelpAndFeedbackBridge;
|
||||
import com.gh.gamecenter.setting.SettingBridge;
|
||||
import com.gh.gamecenter.login.entity.Badge;
|
||||
import com.gh.gamecenter.setting.compose.activity.ComposeBindPhoneActivity;
|
||||
import com.gh.gamecenter.setting.compose.activity.ComposeGameDownloadSettingActivity;
|
||||
import com.gh.gamecenter.suggest.SuggestType;
|
||||
import com.lightgame.adapter.BaseRecyclerAdapter;
|
||||
import com.lightgame.download.DownloadEntity;
|
||||
import com.lightgame.utils.AppManager;
|
||||
import com.lightgame.utils.Util_System_Keyboard;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import kotlin.Unit;
|
||||
@ -119,15 +132,91 @@ public class DialogUtils {
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public static void showInstallHintDialog(Context context, final ConfirmListener cmListener) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context);
|
||||
|
||||
View view = View.inflate(context, R.layout.dialog_install_hint, null);
|
||||
|
||||
// 标题
|
||||
TextView alertdialog_title = view.findViewById(R.id.installhint_title);
|
||||
alertdialog_title.setText("重要提示");
|
||||
Spanned content = Html.fromHtml("如果您使用的是" + "<font color=\"#ff0000\">华为</font>" + "或" +
|
||||
"<font color=\"#ff0000\">OPPO</font>" + "手机,安装游戏时请选择“" +
|
||||
"<font color=\"#ff0000\">继续安装</font>" +
|
||||
"”(记住不要选择“官方推荐”或“软件商店安装”)");
|
||||
// 内容
|
||||
TextView alertdialog_content = view.findViewById(R.id.installhint_content);
|
||||
alertdialog_content.setText(content);
|
||||
|
||||
// 确定按钮
|
||||
TextView installhint_confirm = view.findViewById(R.id.installhint_confirm);
|
||||
installhint_confirm.setText("知道了");
|
||||
|
||||
final ImageView installhint_unselect = view.findViewById(R.id.installhint_unselect);
|
||||
final ImageView installhint_select = view.findViewById(R.id.installhint_select);
|
||||
|
||||
LinearLayout installhint_unselect_ll = view.findViewById(R.id.installhint_unselect_ll);
|
||||
|
||||
installhint_unselect_ll.setOnClickListener(v -> {
|
||||
if (installhint_unselect.getVisibility() == View.GONE) {
|
||||
installhint_unselect.setVisibility(View.VISIBLE);
|
||||
installhint_select.setVisibility(View.GONE);
|
||||
} else {
|
||||
installhint_unselect.setVisibility(View.GONE);
|
||||
installhint_select.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
installhint_confirm.setOnClickListener(v -> {
|
||||
dialog.dismiss();
|
||||
if (installhint_select.getVisibility() == View.VISIBLE) {
|
||||
if (cmListener != null) {
|
||||
cmListener.onConfirm();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public static void showHintDialog(Context context, String title, CharSequence msg, String confirm) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context);
|
||||
|
||||
View view = View.inflate(context, R.layout.common_hintdialog, null);
|
||||
|
||||
TextView hintdialog_title = view.findViewById(R.id.tv_dialog_hint_title);
|
||||
hintdialog_title.setText(title);
|
||||
|
||||
// 内容
|
||||
TextView hintdialog_content = view.findViewById(R.id.tv_dialog_hint_content);
|
||||
hintdialog_content.setText(msg);
|
||||
|
||||
TextView hintdialog_confirm = view.findViewById(R.id.tv_dialog_hint_confirm);
|
||||
|
||||
hintdialog_confirm.setText(confirm);
|
||||
|
||||
hintdialog_confirm.setOnClickListener(v -> dialog.cancel());
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
|
||||
public static void checkDownload(Context context, String size, CheckDownloadCallBack callBack) {
|
||||
if (!NetworkUtils.isNetworkConnected(context)) {
|
||||
showNoConnectionDownloadDialog(context, () -> {
|
||||
},
|
||||
showNoConnectionDownloadDialog(context, null,
|
||||
() -> callBack.onResponse(true));
|
||||
} else if (NetworkUtils.isWifiConnected(context)
|
||||
|| filter4GorSize(context, size)) {
|
||||
callBack.onResponse(false);
|
||||
} else if (!SPUtils.getBoolean(getTrafficDownloadHintKey(), true)) {
|
||||
} else if (!SPUtils.getBoolean(ComposeGameDownloadSettingActivity.getTrafficDownloadHintKey(), true)) {
|
||||
AppExecutor.getUiExecutor().executeWithDelay(() -> Utils.toast(context, "当前使用移动网络下载,请注意流量消耗"), 500);
|
||||
callBack.onResponse(false);
|
||||
} else {
|
||||
@ -138,10 +227,6 @@ public class DialogUtils {
|
||||
}
|
||||
}
|
||||
|
||||
private static String getTrafficDownloadHintKey() {
|
||||
return PackageUtils.getGhVersionName() + "traffic_download_hint";
|
||||
}
|
||||
|
||||
private static boolean filter4GorSize(Context context, String size) {
|
||||
try {
|
||||
if (TextUtils.isEmpty(size)) {
|
||||
@ -159,8 +244,23 @@ public class DialogUtils {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void checkResumeDownload(Context context, CheckDownloadCallBack callBack) {
|
||||
if (!NetworkUtils.isNetworkConnected(context)) {
|
||||
showNoConnectionDownloadDialog(context, null, () -> callBack.onResponse(true));
|
||||
} else if (NetworkUtils.isWifiConnected(context)) {
|
||||
callBack.onResponse(false);
|
||||
} else {
|
||||
showResumeDownloadDialog(context, () -> {
|
||||
callBack.onResponse(false);
|
||||
}, () -> {
|
||||
callBack.onResponse(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static void showNoConnectionDownloadDialog(Context context, ConfirmListener listener, CancelListener cancelListener) {
|
||||
DialogHelper.showDialog(context, "下载提示", "网络异常,请检查手机网络状态", "知道了", "WiFi自动下载", listener::onConfirm, cancelListener::onCancel, false, "", "");
|
||||
com.gh.gamecenter.common.utils.DialogUtils.showWarningDialog(context, "下载提示", "网络异常,请检查手机网络状态", "连上WiFi后自动下载", "关闭", listener, cancelListener);
|
||||
}
|
||||
|
||||
public static void showDownloadDialog(Context context, ConfirmListener listener, CancelListener cancelListener) {
|
||||
@ -188,7 +288,7 @@ public class DialogUtils {
|
||||
// MtaHelper.onEvent("移动网络下载", NetworkUtils.getMobileNetworkType(finalContext), "连上WiFi后自动下载");
|
||||
});
|
||||
allowAlways.setOnClickListener(v -> {
|
||||
SPUtils.setBoolean(getTrafficDownloadHintKey(), false);
|
||||
SPUtils.setBoolean(ComposeGameDownloadSettingActivity.getTrafficDownloadHintKey(), false);
|
||||
AppExecutor.getUiExecutor().executeWithDelay(() -> {
|
||||
// 显示了弹窗以后,即便下面这个 toast 放在 listener.onConfirm 后调用也是显示 listener.onConfirm 里的 toast
|
||||
// 喷了,延时包治疑难杂症
|
||||
@ -201,10 +301,363 @@ public class DialogUtils {
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(contentView);
|
||||
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public static void showResumeDownloadDialog(Context context, ConfirmListener listener, CancelListener cancelListener) {
|
||||
com.gh.gamecenter.common.utils.DialogUtils.showWarningDialog(context, "下载提示", "当前正在使用移动网络,继续下载会消耗手机流量", "连上WiFi后自动下载", "继续下载", listener, cancelListener);
|
||||
}
|
||||
|
||||
public static void showDownloadDialog(Context context, ConfirmListener listener) {
|
||||
com.gh.gamecenter.common.utils.DialogUtils.showWarningDialog(context, "下载提示", "您当前使用的网络为2G/3G/4G,开始下载将会消耗移动流量,确定下载?", listener);
|
||||
}
|
||||
|
||||
public static void showCancelDialog(Context context, final ConfirmListener listener, CancelListener cancelListener) {
|
||||
Spanned content = Html.fromHtml(context.getString(R.string.cancel_concern_dialog));
|
||||
showCancelListenerDialog(context, "取消关注", content, "确定取消", "暂不取消", listener, cancelListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* ios 风格弹窗
|
||||
*
|
||||
* @param context
|
||||
* @param title 标题
|
||||
* @param message 内容
|
||||
* @param negative 取消按钮文本
|
||||
* @param positive 确认按钮文本
|
||||
* @param clListener 取消按钮监听
|
||||
* @param cmListener 确认按钮监听
|
||||
*/
|
||||
public static Dialog showNewAlertDialog(Context context, String title, CharSequence message
|
||||
, String negative, String positive, TrackableEntity trackableEntity, int gravity, boolean shouldShowCloseBtn, final CancelListener clListener, final ConfirmListener cmListener) {
|
||||
context = checkDialogContext(context);
|
||||
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);
|
||||
|
||||
TextView titleTv = contentView.findViewById(R.id.title);
|
||||
TextView contentTv = contentView.findViewById(R.id.content);
|
||||
TextView cancelBtn = contentView.findViewById(R.id.cancel);
|
||||
TextView confirmBtn = contentView.findViewById(R.id.confirm);
|
||||
View middleLine = contentView.findViewById(R.id.middle_line);
|
||||
View closeIv = contentView.findViewById(R.id.closeIv);
|
||||
titleTv.setGravity(gravity);
|
||||
contentTv.setGravity(gravity);
|
||||
|
||||
titleTv.setText(title);
|
||||
contentTv.setText(message);
|
||||
cancelBtn.setText(negative);
|
||||
confirmBtn.setText(positive);
|
||||
if (negative.isEmpty()) {
|
||||
cancelBtn.setVisibility(View.GONE);
|
||||
middleLine.setVisibility(View.GONE);
|
||||
confirmBtn.setTextColor(ContextCompat.getColor(context, R.color.text_title));
|
||||
}
|
||||
if (positive.isEmpty()) {
|
||||
confirmBtn.setVisibility(View.GONE);
|
||||
middleLine.setVisibility(View.GONE);
|
||||
}
|
||||
closeIv.setVisibility(shouldShowCloseBtn ? View.VISIBLE : View.GONE);
|
||||
closeIv.setOnClickListener(v -> dialog.dismiss());
|
||||
|
||||
cancelBtn.setOnClickListener(v -> {
|
||||
if (clListener != null) clListener.onCancel();
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
confirmBtn.setOnClickListener(v -> {
|
||||
if (cmListener != null) cmListener.onConfirm();
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
Window window = dialog.getWindow();
|
||||
if (window != null) {
|
||||
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
}
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(contentView);
|
||||
dialog.show();
|
||||
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, false, clListener, cmListener);
|
||||
}
|
||||
|
||||
public static Dialog showNewAlertDialog(Context context, String title, CharSequence message
|
||||
, String negative, String positive, int gravity, boolean shouldShowCloseBtn, final CancelListener clListener, final ConfirmListener cmListener) {
|
||||
return showNewAlertDialog(context, title, message, negative, positive, null, gravity, shouldShowCloseBtn, clListener, cmListener);
|
||||
}
|
||||
|
||||
|
||||
public static Dialog showDialogWithHtmlContent(Context context, String title, String content
|
||||
, String positive, String negative, final ConfirmListener cmListener, final CancelListener clListener) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.GhAlertDialog);
|
||||
|
||||
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_alert, null);
|
||||
TextView contentTv = contentView.findViewById(R.id.dialog_content);
|
||||
TextView titleTv = contentView.findViewById(R.id.dialog_title);
|
||||
TextView negativeTv = contentView.findViewById(R.id.dialog_negative);
|
||||
TextView positiveTv = contentView.findViewById(R.id.dialog_positive);
|
||||
contentTv.setText(Html.fromHtml(content));
|
||||
titleTv.setText(title);
|
||||
negativeTv.setText(negative);
|
||||
positiveTv.setText(positive);
|
||||
|
||||
negativeTv.setOnClickListener(view -> {
|
||||
if (clListener != null) {
|
||||
clListener.onCancel();
|
||||
}
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
positiveTv.setOnClickListener(view -> {
|
||||
if (cmListener != null) {
|
||||
cmListener.onConfirm();
|
||||
}
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(contentView);
|
||||
dialog.show();
|
||||
return dialog;
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消按钮灰色
|
||||
*
|
||||
* @param context
|
||||
* @param title
|
||||
* @param message
|
||||
* @param positive
|
||||
* @param negative
|
||||
* @param cmListener
|
||||
*/
|
||||
|
||||
public static void showCancelAlertDialog(Context context, String title, CharSequence message
|
||||
, String positive, String negative, final ConfirmListener cmListener, final CancelListener clListener) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.GhAlertDialog);
|
||||
|
||||
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_alert, null);
|
||||
TextView contentTv = contentView.findViewById(R.id.dialog_content);
|
||||
TextView titleTv = contentView.findViewById(R.id.dialog_title);
|
||||
TextView negativeTv = contentView.findViewById(R.id.dialog_negative);
|
||||
TextView positiveTv = contentView.findViewById(R.id.dialog_positive);
|
||||
|
||||
contentTv.setText(message);
|
||||
titleTv.setText(title);
|
||||
negativeTv.setText(negative);
|
||||
negativeTv.setTextColor(ContextCompat.getColor(context, R.color.hint));
|
||||
positiveTv.setText(positive);
|
||||
|
||||
negativeTv.setOnClickListener(view -> {
|
||||
if (clListener != null) {
|
||||
clListener.onCancel();
|
||||
}
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
positiveTv.setOnClickListener(view -> {
|
||||
if (cmListener != null) {
|
||||
cmListener.onConfirm();
|
||||
}
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(contentView);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击外部退出和取消监听绑定
|
||||
*/
|
||||
public static void showCancelListenerDialog(Context context, String title, CharSequence message
|
||||
, String positive, String negative, final ConfirmListener cmListener, final CancelListener clListener) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.GhAlertDialog);
|
||||
|
||||
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_alert, null);
|
||||
TextView contentTv = contentView.findViewById(R.id.dialog_content);
|
||||
TextView titleTv = contentView.findViewById(R.id.dialog_title);
|
||||
TextView negativeTv = contentView.findViewById(R.id.dialog_negative);
|
||||
TextView positiveTv = contentView.findViewById(R.id.dialog_positive);
|
||||
|
||||
contentTv.setText(message);
|
||||
titleTv.setText(title);
|
||||
negativeTv.setText(negative);
|
||||
//negativeTv.setTextColor(ContextCompat.getColor(context, R.color.hint));
|
||||
positiveTv.setText(positive);
|
||||
|
||||
negativeTv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (clListener != null) {
|
||||
clListener.onCancel();
|
||||
}
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
positiveTv.setOnClickListener(view -> {
|
||||
if (cmListener != null) {
|
||||
cmListener.onConfirm();
|
||||
}
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(contentView);
|
||||
dialog.setOnCancelListener(dialogInterface -> {
|
||||
if (clListener != null)
|
||||
clListener.onCancel();
|
||||
});
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 权限弹窗
|
||||
* 只能在弹窗内取消
|
||||
*/
|
||||
public static void showPermissionDialog(Context context, String title, CharSequence message
|
||||
, String positive, String negative, final ConfirmListener cmListener, final CancelListener clListener) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.GhAlertDialog);
|
||||
|
||||
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_alert, null);
|
||||
TextView contentTv = contentView.findViewById(R.id.dialog_content);
|
||||
TextView titleTv = contentView.findViewById(R.id.dialog_title);
|
||||
TextView negativeTv = contentView.findViewById(R.id.dialog_negative);
|
||||
TextView positiveTv = contentView.findViewById(R.id.dialog_positive);
|
||||
|
||||
contentTv.setText(message);
|
||||
titleTv.setText(title);
|
||||
negativeTv.setText(negative);
|
||||
negativeTv.setTextColor(ContextCompat.getColor(context, R.color.hint));
|
||||
positiveTv.setText(positive);
|
||||
|
||||
negativeTv.setOnClickListener(view -> {
|
||||
if (clListener != null) {
|
||||
clListener.onCancel();
|
||||
}
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
positiveTv.setOnClickListener(view -> {
|
||||
if (cmListener != null) {
|
||||
cmListener.onConfirm();
|
||||
}
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(contentView);
|
||||
dialog.setCancelable(false);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* 只能在弹窗内取消
|
||||
*/
|
||||
public static void showForceDialog(Context context, String title, CharSequence message
|
||||
, String positive, String negative, final ConfirmListener cmListener, final CancelListener clListener) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.GhAlertDialog);
|
||||
|
||||
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_alert, null);
|
||||
TextView contentTv = contentView.findViewById(R.id.dialog_content);
|
||||
TextView titleTv = contentView.findViewById(R.id.dialog_title);
|
||||
TextView negativeTv = contentView.findViewById(R.id.dialog_negative);
|
||||
TextView positiveTv = contentView.findViewById(R.id.dialog_positive);
|
||||
|
||||
contentTv.setText(message);
|
||||
titleTv.setText(title);
|
||||
negativeTv.setText(negative);
|
||||
positiveTv.setText(positive);
|
||||
|
||||
negativeTv.setOnClickListener(view -> {
|
||||
if (clListener != null) {
|
||||
clListener.onCancel();
|
||||
}
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
positiveTv.setOnClickListener(view -> {
|
||||
if (cmListener != null) {
|
||||
cmListener.onConfirm();
|
||||
}
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(contentView);
|
||||
dialog.setCancelable(false);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* 特殊:验证手机号码
|
||||
*/
|
||||
|
||||
public static void checkPhoneNumDialog(Context context, CharSequence message, final ConfirmListener cmListener) {
|
||||
String s = message.toString();
|
||||
String sub1 = s.substring(0, 3);
|
||||
String sub2 = s.substring(3, 7);
|
||||
String sub3 = s.substring(7, 11);
|
||||
String phoneNum = StringUtils.buildString(sub1, " - ", sub2, " - ", sub3);
|
||||
|
||||
AlertDialog alertDialog = new AlertDialog.Builder(context, R.style.GhAlertDialog)
|
||||
.setTitle("请确定手机号:")
|
||||
.setMessage(phoneNum)
|
||||
.setPositiveButton("确认", (dialog, which) -> {
|
||||
if (cmListener != null) {
|
||||
cmListener.onConfirm();
|
||||
}
|
||||
})
|
||||
.setNegativeButton("取消", null)
|
||||
.create();
|
||||
alertDialog.show();
|
||||
|
||||
TextView mesage = (TextView) alertDialog.findViewById(android.R.id.message);
|
||||
Button positiveBtn = alertDialog.getButton(android.app.AlertDialog.BUTTON_POSITIVE);
|
||||
Button negativeBtn = alertDialog.getButton(android.app.AlertDialog.BUTTON_NEGATIVE);
|
||||
|
||||
positiveBtn.setTextSize(13);
|
||||
positiveBtn.setTextColor(ContextCompat.getColor(context, R.color.theme_font));
|
||||
negativeBtn.setTextSize(13);
|
||||
negativeBtn.setTextColor(ContextCompat.getColor(context, R.color.theme_font));
|
||||
if (mesage != null) {
|
||||
mesage.setGravity(Gravity.CENTER);
|
||||
mesage.setTextSize(24);
|
||||
mesage.setTextColor(ContextCompat.getColor(context, R.color.title));
|
||||
TextPaint tp = mesage.getPaint();
|
||||
tp.setFakeBoldText(true);
|
||||
}
|
||||
}
|
||||
|
||||
public static void showSignDialog(Context context, String title, CharSequence message, CharSequence message2
|
||||
, String positive, final ConfirmListener cmListener) {
|
||||
context = checkDialogContext(context);
|
||||
@ -220,7 +673,7 @@ public class DialogUtils {
|
||||
|
||||
contentTv.setText(Html.fromHtml(message.toString()));
|
||||
content2Tv.setText(Html.fromHtml(message2.toString()));
|
||||
titleTv.setText(Html.fromHtml(title));
|
||||
titleTv.setText(title);
|
||||
positiveTv.setText(positive);
|
||||
|
||||
negativeTv.setOnClickListener(view -> dialog.dismiss());
|
||||
@ -234,10 +687,92 @@ public class DialogUtils {
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(contentView);
|
||||
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
|
||||
public static void showLowSystemVersionDialog(Context context) {
|
||||
final Context activityContext = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(activityContext, R.style.GhAlertDialog);
|
||||
|
||||
View contentView = LayoutInflater.from(activityContext).inflate(R.layout.dialog_alert, null);
|
||||
TextView contentTv = contentView.findViewById(R.id.dialog_content);
|
||||
TextView titleTv = contentView.findViewById(R.id.dialog_title);
|
||||
TextView positiveTv = contentView.findViewById(R.id.dialog_positive);
|
||||
|
||||
titleTv.setText("提示");
|
||||
contentTv.setText("抱歉,您当前系统版本过低,暂不支持视频功能");
|
||||
positiveTv.setText("我知道了");
|
||||
|
||||
positiveTv.setOnClickListener(view -> {
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(contentView);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public static void showListDialog(Context context,
|
||||
List<String> selectionList,
|
||||
DialogInterface.OnClickListener onClickListener) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
|
||||
String[] selectionArray = new String[selectionList.size()];
|
||||
selectionArray = selectionList.toArray(selectionArray);
|
||||
builder.setItems(selectionArray, onClickListener);
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param options 供以显示的选项
|
||||
* @param disabledOptions 显示为灰色的选项(是 options 的子集)
|
||||
*/
|
||||
public static void showListDialog(Context context,
|
||||
List<String> options,
|
||||
List<String> disabledOptions,
|
||||
OptionCallback callback) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
Dialog dialog = new Dialog(context);
|
||||
|
||||
LinearLayout container = new LinearLayout(context);
|
||||
container.setOrientation(LinearLayout.VERTICAL);
|
||||
container.setBackgroundColor(ContextCompat.getColor(context, R.color.background_white));
|
||||
container.setPadding(0, DisplayUtils.dip2px(context, 12f), 0, DisplayUtils.dip2px(context, 12f));
|
||||
|
||||
for (String option : options) {
|
||||
TextView reportTv = new TextView(context);
|
||||
reportTv.setText(option);
|
||||
reportTv.setTextSize(17f);
|
||||
if (disabledOptions != null && disabledOptions.contains(option)) {
|
||||
reportTv.setTextColor(ContextCompat.getColor(context, R.color.btn_gray));
|
||||
} else {
|
||||
reportTv.setTextColor(ContextCompat.getColor(context, R.color.title));
|
||||
reportTv.setBackgroundResource(R.drawable.textview_white_style);
|
||||
}
|
||||
int widthPixels = context.getResources().getDisplayMetrics().widthPixels;
|
||||
reportTv.setLayoutParams(new LinearLayout.LayoutParams(widthPixels * 9 / 10,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT));
|
||||
reportTv.setPadding(DisplayUtils.dip2px(context, 20f), DisplayUtils.dip2px(context, 12f),
|
||||
0, DisplayUtils.dip2px(context, 12f));
|
||||
container.addView(reportTv);
|
||||
|
||||
reportTv.setOnClickListener(v -> {
|
||||
dialog.cancel();
|
||||
callback.onClicked(reportTv.getText().toString());
|
||||
});
|
||||
}
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(container);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 特殊:目前只在提交问题错误返回时弹出
|
||||
*/
|
||||
@ -717,6 +1252,38 @@ public class DialogUtils {
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public static void showVersionNumberDialog(Context context, GameEntity gameEntity, @NonNull ConfirmListener listener) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
if (!gameEntity.isShowVersionNumber()) {
|
||||
listener.onConfirm();
|
||||
} else {
|
||||
final Dialog dialog = new Dialog(context, R.style.GhAlertDialog);
|
||||
|
||||
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_version_number, null);
|
||||
|
||||
TextView contentTv = contentView.findViewById(R.id.contentTv);
|
||||
TextView cancelTv = contentView.findViewById(R.id.cancelTv);
|
||||
TextView continueTv = contentView.findViewById(R.id.continueTv);
|
||||
|
||||
contentTv.setText(gameEntity.getVersionNumberString());
|
||||
cancelTv.setOnClickListener(v -> dialog.dismiss());
|
||||
continueTv.setOnClickListener(v -> {
|
||||
listener.onConfirm();
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
Window window = dialog.getWindow();
|
||||
if (window != null) {
|
||||
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
}
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(contentView);
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
|
||||
// 海外下载地址弹窗
|
||||
public static void showOverseaDownloadDialog(Context context, GameEntity gameEntity, @NonNull ConfirmListener listener) {
|
||||
context = checkDialogContext(context);
|
||||
@ -902,9 +1469,30 @@ public class DialogUtils {
|
||||
}
|
||||
|
||||
public static void showPluggableNeverRemindDialog(Context context, String nameAndPlatform, @NonNull ConfirmListener listener) {
|
||||
String content = "助手首页将不再提示《" + nameAndPlatform + "》的所有插件化消息,确定吗?";
|
||||
DialogHelper.showDialog(context, "温馨提醒", content, "确定", "取消", listener::onConfirm, () -> {
|
||||
}, false, "", "");
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.GhAlertDialog);
|
||||
|
||||
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_pluggable_never_remind, null);
|
||||
|
||||
View cancelBtn = contentView.findViewById(R.id.cancel);
|
||||
View confirmBtn = contentView.findViewById(R.id.confirm);
|
||||
TextView contentTv = contentView.findViewById(R.id.content);
|
||||
|
||||
contentTv.setText(("助手首页将不再提示《" + nameAndPlatform + "》的所有插件化消息,确定吗?"));
|
||||
|
||||
cancelBtn.setOnClickListener(v -> {
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
confirmBtn.setOnClickListener(v -> {
|
||||
listener.onConfirm();
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(contentView);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public static void showRegulationTestDialog(Context context, @NonNull ConfirmListener confirmListener, @NonNull CancelListener cancelListener) {
|
||||
@ -979,7 +1567,7 @@ public class DialogUtils {
|
||||
confirmBtn.setOnClickListener(v -> {
|
||||
dialog.dismiss();
|
||||
String hint = "《" + downloadEntity.getName() + "》游戏安装包解压失败,问题反馈:";
|
||||
HelpAndFeedbackBridge.startSuggestionActivity(activityContext, SuggestType.normal, null, hint);
|
||||
SuggestionActivity.startSuggestionActivity(activityContext, SuggestType.normal, null, hint);
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
@ -1014,6 +1602,102 @@ public class DialogUtils {
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public static void showVideoComplaintDialog(Context context,
|
||||
List<String> options,
|
||||
List<String> disabledOptions,
|
||||
OptionCallback callback) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
Dialog dialog = new Dialog(context);
|
||||
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.dialog_video_complaint, null, false);
|
||||
LinearLayout complaintContainer = view.findViewById(R.id.complaintContainer);
|
||||
ConstraintLayout otherComplaintContainer = view.findViewById(R.id.otherComplaintContainer);
|
||||
EditText complaintCommentEt = view.findViewById(R.id.complaintCommentEt);
|
||||
TextView backTv = view.findViewById(R.id.backTv);
|
||||
TextView commitTv = view.findViewById(R.id.commitTv);
|
||||
Context finalContext = context;
|
||||
//添加透明阴影,实现类似 clipPadding=false 效果
|
||||
complaintCommentEt.setShadowLayer(complaintCommentEt.getExtendedPaddingBottom(), 0f, 0f, Color.TRANSPARENT);
|
||||
|
||||
ExtensionsKt.setTextChangedListener(complaintCommentEt, (s, start, before, count) -> {
|
||||
commitTv.setTextColor(ContextCompat.getColor(finalContext, s.toString().trim().isEmpty() ? R.color.text_subtitleDesc : R.color.theme_font));
|
||||
return null;
|
||||
});
|
||||
|
||||
for (String option : options) {
|
||||
TextView reportTv = new TextView(context);
|
||||
reportTv.setText(option);
|
||||
reportTv.setTextSize(16f);
|
||||
if (disabledOptions != null && disabledOptions.contains(option)) {
|
||||
reportTv.setTextColor(ContextCompat.getColor(context, R.color.btn_gray));
|
||||
} else {
|
||||
reportTv.setTextColor(ContextCompat.getColor(context, R.color.title));
|
||||
reportTv.setBackgroundResource(R.drawable.textview_white_style);
|
||||
}
|
||||
reportTv.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT));
|
||||
reportTv.setPadding(DisplayUtils.dip2px(context, 20f), DisplayUtils.dip2px(context, 17f),
|
||||
DisplayUtils.dip2px(context, 20f), DisplayUtils.dip2px(context, 17f));
|
||||
if (option.equals("其它")) {
|
||||
Drawable drawable = ContextCompat.getDrawable(context, R.drawable.ic_complaint_arrow_right);
|
||||
drawable.setBounds(0, 0, DisplayUtils.dip2px(6f), DisplayUtils.dip2px(10f));
|
||||
reportTv.setCompoundDrawables(null, null, drawable, null);
|
||||
}
|
||||
complaintContainer.addView(reportTv);
|
||||
|
||||
reportTv.setOnClickListener(v -> {
|
||||
if (option.equals("其它")) {
|
||||
complaintContainer.setVisibility(View.GONE);
|
||||
otherComplaintContainer.setVisibility(View.VISIBLE);
|
||||
complaintCommentEt.requestFocus();
|
||||
Util_System_Keyboard.showSoftKeyboard(finalContext, complaintCommentEt);
|
||||
} else {
|
||||
dialog.cancel();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
try {
|
||||
jsonObject.put("reason", reportTv.getText().toString());
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
callback.onClicked(jsonObject.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
backTv.setOnClickListener(v -> {
|
||||
Util_System_Keyboard.hideSoftKeyboard(finalContext, complaintCommentEt);
|
||||
complaintContainer.setVisibility(View.VISIBLE);
|
||||
otherComplaintContainer.setVisibility(View.GONE);
|
||||
});
|
||||
commitTv.setOnClickListener(v -> {
|
||||
if (complaintCommentEt.getText().toString().isEmpty()) {
|
||||
ToastUtils.INSTANCE.showToast("请先输入说明~");
|
||||
return;
|
||||
}
|
||||
dialog.cancel();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
try {
|
||||
jsonObject.put("reason", "其它");
|
||||
jsonObject.put("description", complaintCommentEt.getText().toString());
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
callback.onClicked(jsonObject.toString());
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
Window window = dialog.getWindow();
|
||||
if (window != null) {
|
||||
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
WindowManager.LayoutParams params = window.getAttributes();
|
||||
params.width = context.getResources().getDisplayMetrics().widthPixels - DisplayUtils.dip2px(40f);
|
||||
window.setAttributes(params);
|
||||
}
|
||||
}
|
||||
|
||||
public static void showViewBadgeDialog(Context context, Badge badge, ConfirmListener listener) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
@ -1193,7 +1877,7 @@ public class DialogUtils {
|
||||
@Override
|
||||
public Unit invoke() {
|
||||
SimpleGameEntity entity = new SimpleGameEntity(gameId, gameName, "");
|
||||
HelpAndFeedbackBridge.startSuggestionActivity(finalContext, SuggestType.gameQuestion, "notfound", "模拟器安装包解析错误", entity, "-");
|
||||
SuggestionActivity.startSuggestionActivity(finalContext, SuggestType.gameQuestion, "notfound", "模拟器安装包解析错误", entity, "-");
|
||||
dialog.dismiss();
|
||||
return null;
|
||||
}
|
||||
@ -1302,6 +1986,36 @@ public class DialogUtils {
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public static void showReceiveLibaoSuccessDialog(Context context, String title, String des, String libaoCode, ConfirmListener listener) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.DialogWindowTransparent);
|
||||
DialogReceiveLibaoSuccessBinding binding = DialogReceiveLibaoSuccessBinding.inflate(LayoutInflater.from(context));
|
||||
binding.title.setText(title);
|
||||
binding.libaoCodeTv.setText(libaoCode);
|
||||
binding.desTv.setText(des);
|
||||
|
||||
binding.confirm.setOnClickListener(v -> {
|
||||
dialog.dismiss();
|
||||
listener.onConfirm();
|
||||
});
|
||||
|
||||
binding.cancel.setOnClickListener(v -> {
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(binding.getRoot());
|
||||
dialog.show();
|
||||
Window window = dialog.getWindow();
|
||||
if (window != null) {
|
||||
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
WindowManager.LayoutParams params = window.getAttributes();
|
||||
params.width = context.getResources().getDisplayMetrics().widthPixels - DisplayUtils.dip2px(60f);
|
||||
window.setAttributes(params);
|
||||
}
|
||||
}
|
||||
|
||||
public static void showReserveSuccess2WechatBindDialog(Context context, ConfirmListener confirmListener, CancelListener cancelListener) {
|
||||
context = checkDialogContext(context);
|
||||
|
||||
@ -1337,7 +2051,7 @@ public class DialogUtils {
|
||||
binding.confirmTv.setText("我知道了");
|
||||
binding.centerDivider.setVisibility(View.GONE);
|
||||
binding.cancelTv.setVisibility(View.GONE);
|
||||
ExtensionsKt.setDrawableStart(binding.titleTv, R.drawable.ic_reserve_success, null, null);
|
||||
binding.titleTv.setCompoundDrawablesWithIntrinsicBounds(ExtensionsKt.toDrawable(R.drawable.ic_reserve_success), null, null, null);
|
||||
binding.confirmTv.setOnClickListener(v -> dialog.dismiss());
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(binding.getRoot());
|
||||
@ -1366,7 +2080,7 @@ public class DialogUtils {
|
||||
|
||||
binding.bindPhoneBtn.setOnClickListener(v -> {
|
||||
dialog.dismiss();
|
||||
Intent intent = SettingBridge.INSTANCE.getBindPhoneNormalIntent(finalContext, false);
|
||||
Intent intent = ComposeBindPhoneActivity.getNormalIntent(finalContext, false);
|
||||
finalContext.startActivity(intent);
|
||||
});
|
||||
|
||||
|
||||
@ -10,8 +10,11 @@ import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.common.exposure.ExposureEvent
|
||||
import com.gh.common.exposure.ExposureEvent.Companion.createEvent
|
||||
import com.gh.common.exposure.ExposureManager.log
|
||||
import com.gh.common.exposure.ExposureTraceUtils.appendTrace
|
||||
import com.gh.common.exposure.ExposureType
|
||||
import com.gh.common.util.EntranceUtils.jumpActivity
|
||||
import com.gh.gamecenter.*
|
||||
import com.gh.gamecenter.amway.AmwayActivity
|
||||
@ -22,25 +25,20 @@ import com.gh.gamecenter.common.base.activity.BaseActivity
|
||||
import com.gh.gamecenter.common.base.activity.BaseActivity_TabLayout
|
||||
import com.gh.gamecenter.common.base.activity.ToolBarActivity
|
||||
import com.gh.gamecenter.common.base.fragment.BaseFragment_TabLayout
|
||||
import com.gh.gamecenter.common.constant.CommonConsts
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts.*
|
||||
import com.gh.gamecenter.common.constant.RouteConsts
|
||||
import com.gh.gamecenter.common.entity.*
|
||||
import com.gh.gamecenter.common.entity.CommunityEntity
|
||||
import com.gh.gamecenter.common.entity.Display
|
||||
import com.gh.gamecenter.common.entity.LinkEntity
|
||||
import com.gh.gamecenter.common.retrofit.Response
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.runOnIoThread
|
||||
import com.gh.gamecenter.core.AppExecutor
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.discovery.DiscoveryActivity
|
||||
import com.gh.gamecenter.download.DownloadFragment.Companion.INDEX_UPDATE
|
||||
import com.gh.gamecenter.entity.*
|
||||
import com.gh.gamecenter.eventbus.EBSkip
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.entity.MeEntity
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent.Companion.createEvent
|
||||
import com.gh.gamecenter.feature.exposure.ExposureType
|
||||
import com.gh.gamecenter.forum.detail.ForumDetailActivity
|
||||
import com.gh.gamecenter.forum.home.CommunityHomeFragment
|
||||
import com.gh.gamecenter.fragment.MainWrapperFragment
|
||||
@ -53,8 +51,8 @@ import com.gh.gamecenter.gamedetail.GameDetailFragment
|
||||
import com.gh.gamecenter.gamedetail.fuli.kaifu.ServersCalendarActivity
|
||||
import com.gh.gamecenter.gamedetail.history.HistoryApkListActivity
|
||||
import com.gh.gamecenter.gamedetail.rating.RatingReplyActivity
|
||||
import com.gh.gamecenter.help.HelpAndFeedbackBridge
|
||||
import com.gh.gamecenter.login.user.UserManager
|
||||
import com.gh.gamecenter.mygame.PlayedGameActivity
|
||||
import com.gh.gamecenter.personalhome.UserHomeActivity
|
||||
import com.gh.gamecenter.personalhome.background.PersonalityBackgroundActivity
|
||||
import com.gh.gamecenter.personalhome.border.AvatarBorderActivity
|
||||
@ -67,8 +65,10 @@ import com.gh.gamecenter.qa.video.detail.ForumVideoDetailActivity
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.gh.gamecenter.servers.GameServerTestActivity
|
||||
import com.gh.gamecenter.servers.GameServersActivity
|
||||
import com.gh.gamecenter.setting.SettingBridge
|
||||
import com.gh.gamecenter.setting.compose.activity.ComposeBindPhoneActivity
|
||||
import com.gh.gamecenter.setting.compose.activity.ComposeSettingActivity
|
||||
import com.gh.gamecenter.subject.SubjectActivity
|
||||
import com.gh.gamecenter.suggest.SuggestType
|
||||
import com.gh.gamecenter.tag.TagsActivity
|
||||
import com.gh.gamecenter.toolbox.ToolBoxBlockActivity
|
||||
import com.gh.gamecenter.video.data.VideoDataActivity
|
||||
@ -145,7 +145,6 @@ object DirectUtils {
|
||||
directToLinkPage(context, linkEntity, entrance, path, null)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun directToLinkPage(
|
||||
context: Context,
|
||||
linkEntity: LinkEntity,
|
||||
@ -252,6 +251,11 @@ object DirectUtils {
|
||||
path
|
||||
)
|
||||
|
||||
"community_special_column" -> directAskColumnDetail(
|
||||
context, linkEntity.link
|
||||
?: "", linkEntity.community!!, entrance, path
|
||||
)
|
||||
|
||||
"web", "inurl", "web链接" -> {
|
||||
when {
|
||||
linkEntity.link!!.contains("v.douyin") && PackageHelper.localPackageNameSet.contains("com.ss.android.ugc.aweme") -> {
|
||||
@ -282,6 +286,11 @@ object DirectUtils {
|
||||
)
|
||||
)
|
||||
|
||||
"all_community_article" -> directSimpleArticleList(
|
||||
context, linkEntity.link
|
||||
?: "", entrance, path
|
||||
)
|
||||
|
||||
"category", "分类" -> directCategoryDirectory(context, linkEntity.link!!, linkEntity.text!!)
|
||||
|
||||
"catalog" -> directCatalog(context, linkEntity.link!!, linkEntity.text!!, entrance, path)
|
||||
@ -349,7 +358,7 @@ object DirectUtils {
|
||||
|
||||
"mobile_bind" -> {
|
||||
CheckLoginUtils.checkLogin(context, entrance) {
|
||||
context.startActivity(SettingBridge.getBindPhoneNormalIntent(context, false))
|
||||
context.startActivity(ComposeBindPhoneActivity.getNormalIntent(context, false))
|
||||
}
|
||||
}
|
||||
|
||||
@ -379,7 +388,7 @@ object DirectUtils {
|
||||
|
||||
"etiquette_exam" -> directToRegulationTestPage(context)
|
||||
|
||||
"setting" -> context.startActivity(SettingBridge.getSettingIntent(context, false, entrance))
|
||||
"setting" -> context.startActivity(ComposeSettingActivity.getIntent(context, false, entrance))
|
||||
|
||||
"index_page" -> directToHomeTab(context)
|
||||
|
||||
@ -449,9 +458,8 @@ object DirectUtils {
|
||||
@JvmStatic
|
||||
fun directToQa(context: Context, text: String? = "", id: String) {
|
||||
if (id.isEmpty()) return
|
||||
val destination = RouteConsts.activity.qaActivity.toDestinationClass()
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_TO, destination?.name ?: "")
|
||||
bundle.putString(KEY_TO, QaActivity::class.java.simpleName)
|
||||
bundle.putString(KEY_NAVIGATION_TITLE, text)
|
||||
bundle.putString(KEY_QA_ID, id)
|
||||
jumpActivity(context, bundle)
|
||||
@ -463,9 +471,8 @@ object DirectUtils {
|
||||
@JvmStatic
|
||||
fun directToQaCollection(context: Context, text: String, id: String) {
|
||||
if (id.isEmpty()) return
|
||||
val destination = RouteConsts.activity.qaActivity.toDestinationClass()
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_TO, destination?.name ?: "")
|
||||
bundle.putString(KEY_TO, QaActivity::class.java.simpleName)
|
||||
bundle.putString(KEY_NAVIGATION_TITLE, text)
|
||||
bundle.putString(KEY_QA_COLLECTION_ID, id)
|
||||
jumpActivity(context, bundle)
|
||||
@ -583,21 +590,19 @@ object DirectUtils {
|
||||
entrance: String? = null,
|
||||
path: String? = null
|
||||
) {
|
||||
directToHomeActivity(context, userId, "", "", position, entrance, path)
|
||||
directToHomeActivity(context, userId, "", position, entrance, path)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转至个人主页
|
||||
* @param position 定位到某个tab 0游戏 1发布
|
||||
* @param type 类型 (发布)
|
||||
* @param gameType 类型 (游戏)
|
||||
* @param type 类型
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToHomeActivity(
|
||||
context: Context,
|
||||
userId: String? = "",
|
||||
type: String? = "",
|
||||
gameType: String? = "",
|
||||
position: Int? = 0,
|
||||
entrance: String? = null,
|
||||
path: String? = null
|
||||
@ -610,7 +615,6 @@ object DirectUtils {
|
||||
bundle.putString(KEY_ENTRANCE, BaseActivity.mergeEntranceAndPath(entrance, path))
|
||||
bundle.putString(KEY_PATH, path)
|
||||
bundle.putString(KEY_TYPE, UserHistoryViewModel.TYPE.fromValue(type).value)
|
||||
bundle.putString(KEY_GAME, gameType)
|
||||
bundle.putInt(KEY_POSITION, position ?: 0)
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
@ -705,6 +709,11 @@ object DirectUtils {
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
|
||||
// 跳转至用户玩过的游戏
|
||||
fun directToPlayedGame(context: Context, userId: String, entrance: String = "", path: String = "") {
|
||||
context.startActivity(PlayedGameActivity.getIntent(context, userId, entrance, path))
|
||||
}
|
||||
|
||||
// 专栏
|
||||
@JvmStatic
|
||||
fun directToSubject(
|
||||
@ -744,8 +753,7 @@ object DirectUtils {
|
||||
) {
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
val destination = RouteConsts.activity.suggestionActivity.toDestinationClass()
|
||||
bundle.putString(KEY_TO, destination?.name ?: "")
|
||||
bundle.putString(KEY_TO, SuggestionActivity::class.java.simpleName)
|
||||
if (isQaFeedback) {
|
||||
bundle.putBoolean(KEY_IS_QA_FEEDBACK, true)
|
||||
bundle.putString(KEY_QA_CONTENT_ID, qaContentId)
|
||||
@ -764,37 +772,6 @@ object DirectUtils {
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun directToFeedbackCompat(
|
||||
context: Context,
|
||||
content: String? = null,
|
||||
hintType: String? = null,
|
||||
isQaFeedback: Boolean = false,
|
||||
qaContentId: String? = "",
|
||||
entrance: String? = null
|
||||
) {
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
val destination = RouteConsts.activity.suggestionActivity.toDestinationClass()
|
||||
bundle.putString(KEY_TO, destination?.name ?: "")
|
||||
if (isQaFeedback) {
|
||||
bundle.putBoolean(KEY_IS_QA_FEEDBACK, true)
|
||||
bundle.putString(KEY_QA_CONTENT_ID, qaContentId)
|
||||
bundle.putSerializable(KEY_SUGGESTTYPE, SuggestType.normal)
|
||||
} else {
|
||||
bundle.putString(KEY_CONTENT, content)
|
||||
if (TextUtils.isEmpty(hintType)) {
|
||||
bundle.putSerializable(KEY_SUGGESTTYPE, SuggestType.gameQuestion)
|
||||
bundle.putString(KEY_SUGGEST_HINT_TYPE, KEY_PLUGIN)
|
||||
} else {
|
||||
bundle.putSerializable(KEY_SUGGESTTYPE, SuggestType.normal)
|
||||
bundle.putString(KEY_SUGGEST_HINT_TYPE, hintType)
|
||||
}
|
||||
}
|
||||
|
||||
EntranceUtils.jumpActivityCompat(context, bundle)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun directToDownloadManager(context: Context, entrance: String? = null) {
|
||||
val bundle = Bundle()
|
||||
@ -889,6 +866,15 @@ object DirectUtils {
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
|
||||
// 个人-系统消息
|
||||
@JvmStatic
|
||||
fun directToOfficialNotification(context: Context, entrance: String? = null) {
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
bundle.putString(KEY_TO, MessageKeFuActivity::class.java.simpleName)
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun directToExternalBrowser(context: Context, url: String) {
|
||||
try {
|
||||
@ -1076,7 +1062,7 @@ object DirectUtils {
|
||||
bundle.putString(KEY_PATH, path)
|
||||
jumpActivity(context, bundle)
|
||||
} else {
|
||||
DialogHelper.showVideoUnsupportedDialog(context)
|
||||
DialogUtils.showLowSystemVersionDialog(context)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1118,7 +1104,7 @@ object DirectUtils {
|
||||
bundle.putString(KEY_SECTION_NAME, sectionName)
|
||||
jumpActivity(context, bundle)
|
||||
} else {
|
||||
DialogHelper.showVideoUnsupportedDialog(context)
|
||||
DialogUtils.showLowSystemVersionDialog(context)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1265,6 +1251,30 @@ object DirectUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转梦工厂小游戏
|
||||
*/
|
||||
/*@JvmStatic
|
||||
fun directLetoGameCenter(context: Context) {
|
||||
if (UserManager.getInstance().isLoggedIn) {
|
||||
UserManager.getInstance().userInfoEntity?.run {
|
||||
MgcAccountManager.syncAccount(context, if (idCard != null) idCard!!.name else name, mobile, name, icon, true,
|
||||
object : SyncUserInfoListener {
|
||||
override fun onSuccess(data: LoginResultBean?) {}
|
||||
|
||||
override fun onFail(code: String?, message: String?) {}
|
||||
})
|
||||
}
|
||||
} else {
|
||||
MgcAccountManager.exitAccount(context, object : SyncUserInfoListener {
|
||||
override fun onSuccess(data: LoginResultBean?) {}
|
||||
|
||||
override fun onFail(code: String?, message: String?) {}
|
||||
})
|
||||
}
|
||||
Leto.getInstance().startGameCenter(context)
|
||||
}*/
|
||||
|
||||
/**
|
||||
* 跳转分类
|
||||
*/
|
||||
@ -1331,6 +1341,47 @@ object DirectUtils {
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到问题标签详情
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directAskColumnLabelDetail(
|
||||
context: Context,
|
||||
tag: String,
|
||||
community: CommunityEntity,
|
||||
entrance: String? = null,
|
||||
path: String? = ""
|
||||
) {
|
||||
// val bundle = Bundle()
|
||||
// bundle.putString(KEY_TO, AskColumnDetailActivity::class.java.name)
|
||||
// bundle.putString(KEY_ASK_TAG, tag)
|
||||
// bundle.putParcelable(KEY_COMMUNITY_DATA, community)
|
||||
// bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
// bundle.putString(KEY_PATH, path)
|
||||
// jumpActivity(context, bundle)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到专栏详情
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directAskColumnDetail(
|
||||
context: Context,
|
||||
columnId: String,
|
||||
community: CommunityEntity,
|
||||
entrance: String? = null,
|
||||
path: String? = ""
|
||||
) {
|
||||
// if (columnId.isEmpty()) return
|
||||
// val bundle = Bundle()
|
||||
// bundle.putString(KEY_TO, AskColumnDetailActivity::class.java.name)
|
||||
// bundle.putString(KEY_COLUMN_ID, columnId)
|
||||
// bundle.putParcelable(KEY_COMMUNITY_DATA, community)
|
||||
// bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
// bundle.putString(KEY_PATH, path)
|
||||
// jumpActivity(context, bundle)
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到板块
|
||||
*/
|
||||
@ -1366,6 +1417,20 @@ object DirectUtils {
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
|
||||
/**
|
||||
* 社区文章
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directSimpleArticleList(context: Context, sortType: String, entrance: String? = null, path: String? = "") {
|
||||
// if (sortType.isEmpty()) return
|
||||
// val bundle = Bundle()
|
||||
// bundle.putString(KEY_TO, SimpleArticleListActivity::class.java.name)
|
||||
// bundle.putString(KEY_TYPE, sortType)
|
||||
// bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
// bundle.putString(KEY_PATH, path)
|
||||
// jumpActivity(context, bundle)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun directGameZone(context: Context, gameId: String, url: String, entrance: String? = null) {
|
||||
RetrofitManager.getInstance()
|
||||
@ -1422,7 +1487,7 @@ object DirectUtils {
|
||||
context.startActivity(intent)
|
||||
|
||||
// 这里换个线程操作是为了做一点延时
|
||||
runOnIoThread {
|
||||
AppExecutor.ioExecutor.execute {
|
||||
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_HOME))
|
||||
}
|
||||
} else {
|
||||
@ -1443,7 +1508,7 @@ object DirectUtils {
|
||||
context.startActivity(intent)
|
||||
|
||||
// 这里换个线程操作是为了做一点延时
|
||||
runOnIoThread {
|
||||
AppExecutor.ioExecutor.execute {
|
||||
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_BBS))
|
||||
EventBus.getDefault().post(EBSkip(CommunityHomeFragment.EB_TAB, position))
|
||||
}
|
||||
@ -1466,7 +1531,7 @@ object DirectUtils {
|
||||
context.startActivity(intent)
|
||||
|
||||
// 这里换个线程操作是为了做一点延时
|
||||
runOnIoThread {
|
||||
AppExecutor.ioExecutor.execute {
|
||||
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_VIDEO))
|
||||
}
|
||||
} else {
|
||||
@ -1485,7 +1550,7 @@ object DirectUtils {
|
||||
context.startActivity(intent)
|
||||
|
||||
// 这里换个线程操作是为了做一点延时
|
||||
runOnIoThread {
|
||||
AppExecutor.ioExecutor.execute {
|
||||
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_PERSONAL))
|
||||
}
|
||||
} else {
|
||||
@ -1495,13 +1560,12 @@ object DirectUtils {
|
||||
|
||||
/**
|
||||
* 跳转至使用帮助与反馈,请不要随意修改方法名
|
||||
* @param position 使用帮助:[CommonConsts.TAB_MAIN],意见反馈:[CommonConsts.TAB_SUB]
|
||||
* @param position 使用帮助:[HelpAndFeedbackActivity.HELP_ITEM],意见反馈:[HelpAndFeedbackActivity.SUGGESTION_ITEM]
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToHelpAndFeedback(context: Context, position: Int = CommonConsts.TAB_MAIN) {
|
||||
val destination = RouteConsts.activity.helpAndFeedbackActivity.toDestinationClass()
|
||||
fun directToHelpAndFeedback(context: Context, position: Int = HelpAndFeedbackActivity.HELP_ITEM) {
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_TO, destination?.name ?: "")
|
||||
bundle.putString(KEY_TO, HelpAndFeedbackActivity::class.java.name)
|
||||
bundle.putInt(BaseActivity_TabLayout.PAGE_INDEX, position)
|
||||
jumpActivity(context, bundle)
|
||||
}
|
||||
@ -1857,7 +1921,7 @@ object DirectUtils {
|
||||
diagnosis: String = "",
|
||||
requestCode: Int? = null
|
||||
) {
|
||||
val intent = HelpAndFeedbackBridge.getIntent(
|
||||
val intent = SuggestionActivity.getIntent(
|
||||
context,
|
||||
type,
|
||||
hiddenHint,
|
||||
|
||||
@ -4,8 +4,8 @@ import android.content.Context
|
||||
import android.os.Build
|
||||
import com.gh.gamecenter.common.utils.DialogHelper
|
||||
import com.gh.gamecenter.core.utils.EmptyCallback
|
||||
import com.gh.gamecenter.feature.entity.ApkEntity
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.ApkEntity
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
|
||||
object DownloadDialogHelper {
|
||||
|
||||
|
||||
@ -3,9 +3,8 @@ package com.gh.common.util
|
||||
import com.gh.common.filter.RegionSettingHelper
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.common.retrofit.Response
|
||||
import com.gh.gamecenter.feature.utils.ApkActiveUtils
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
||||
@ -10,34 +10,35 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.common.chain.*
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.common.dialog.DeviceRemindDialog
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.gh.common.exposure.ExposureEvent
|
||||
import com.gh.common.filter.RegionSettingHelper
|
||||
import com.gh.common.history.HistoryHelper
|
||||
import com.gh.common.repository.ReservationRepository
|
||||
import com.gh.common.simulator.NewSimulatorGameManager
|
||||
import com.gh.common.simulator.SimulatorDownloadManager
|
||||
import com.gh.common.simulator.SimulatorGameManager
|
||||
import com.gh.gamecenter.feature.view.DownloadButton
|
||||
import com.gh.common.view.DownloadButton
|
||||
import com.gh.common.xapk.XapkInstaller
|
||||
import com.gh.common.xapk.XapkInstaller.cancelUnzipTask
|
||||
import com.gh.common.xapk.XapkUnzipStatus
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.download.dialog.DownloadDialog
|
||||
import com.gh.gamecenter.DownloadManagerActivity
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.WebActivity
|
||||
import com.gh.gamecenter.adapter.viewholder.GameViewHolder
|
||||
import com.gh.gamecenter.common.callback.CancelListener
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.constant.EntranceConsts
|
||||
import com.gh.gamecenter.common.entity.LinkEntity
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.utils.*
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.common.entity.LinkEntity
|
||||
import com.gh.gamecenter.energy.EnergyBridge
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.entity.PluginLocation
|
||||
import com.gh.gamecenter.entity.PluginLocation
|
||||
import com.gh.gamecenter.gamedetail.dialog.GamePermissionDialogFragment
|
||||
import com.gh.gamecenter.manager.PackagesManager
|
||||
import com.gh.gamecenter.teenagermode.TeenagerModeActivity
|
||||
import com.gh.vspace.VDownloadManagerActivity
|
||||
import com.gh.vspace.VHelper
|
||||
import com.lightgame.download.DownloadConfig
|
||||
import com.lightgame.download.DownloadEntity
|
||||
@ -119,13 +120,13 @@ object DownloadItemUtils {
|
||||
fun updateItemWithReserveStatus(holder: GameViewHolder, gameEntity: GameEntity) {
|
||||
if ("download" == gameEntity.reserveStatus) {
|
||||
// 已上线
|
||||
updateItem(holder.gameDownloadBtn.context, gameEntity, holder, false)
|
||||
updateItem(holder.gameDes.context, gameEntity, holder, false)
|
||||
} else if ("appointment" == gameEntity.reserveStatus) {
|
||||
// 已预约
|
||||
holder.gameDownloadBtn.text = "已预约"
|
||||
holder.gameDownloadBtn.visibility = View.VISIBLE
|
||||
holder.gameDownloadBtn.buttonStyle = DownloadButton.ButtonStyle.RESERVED
|
||||
updateItemViewStatus(holder, null, null)
|
||||
updateItemViewStatus(holder, false, null, null)
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,8 +166,7 @@ object DownloadItemUtils {
|
||||
) {
|
||||
// 显示预约
|
||||
if (gameEntity.isReservable) {
|
||||
holder.multiVersionDownloadTv?.visibility = View.GONE
|
||||
updateItemViewStatus(holder, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
|
||||
updateItemViewStatus(holder, false, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
|
||||
updateDownloadButton(
|
||||
context,
|
||||
holder.gameDownloadBtn,
|
||||
@ -177,16 +177,11 @@ object DownloadItemUtils {
|
||||
return
|
||||
}
|
||||
if (gameEntity.getApk().isEmpty() || gameEntity.downloadOffStatus != null) {
|
||||
holder.multiVersionDownloadTv?.visibility = View.GONE
|
||||
holder.gameDownloadTips?.visibility = View.GONE
|
||||
updateItemViewStatus(holder, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
|
||||
updateItemViewStatus(holder, false, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
|
||||
} else if (gameEntity.getApk().size == 1) {
|
||||
holder.multiVersionDownloadTv?.visibility = View.GONE
|
||||
holder.gameDownloadTips?.visibility = View.GONE
|
||||
updateNormalItem(context, holder, gameEntity, briefStyle, isShowRecommendStar)
|
||||
updateNormalItem(context, holder, gameEntity, isShowPlatform, briefStyle, isShowRecommendStar)
|
||||
} else {
|
||||
holder.multiVersionDownloadTv?.visibility = View.VISIBLE
|
||||
updatePluginItem(context, holder, gameEntity, briefStyle, isShowRecommendStar)
|
||||
updatePluginItem(context, holder, gameEntity, isShowPlatform, briefStyle, isShowRecommendStar)
|
||||
}
|
||||
updateDownloadButton(
|
||||
context,
|
||||
@ -267,58 +262,42 @@ object DownloadItemUtils {
|
||||
downloadEntity = VHelper.getDownloadEntitySnapshot(gameEntity.id, gameEntity.getUniquePackageName())
|
||||
}
|
||||
|
||||
if (downloadEntity == null) {
|
||||
val entryMap: ArrayMap<String, DownloadEntity> = gameEntity.getEntryMap()
|
||||
val apkEntity = gameEntity.getApk()[0]
|
||||
if (entryMap.isNotEmpty()) {
|
||||
downloadEntity = entryMap[apkEntity.getPlatform()]
|
||||
}
|
||||
}
|
||||
|
||||
if (downloadEntity != null) {
|
||||
downloadBtn.apply {
|
||||
when (downloadEntity.status) {
|
||||
DownloadStatus.done -> {
|
||||
if (downloadEntity.isSimulatorGame() && gameEntity.simulator != null) {
|
||||
GameUtils.setDownloadBtnStatus(context, gameEntity, downloadBtn, pluginLocation)
|
||||
} else if (downloadEntity.isVGame()) {
|
||||
buttonStyle =
|
||||
if (PackagesManager.isCanUpdate(
|
||||
downloadEntity.gameId,
|
||||
downloadEntity.packageName
|
||||
)
|
||||
) {
|
||||
setText(R.string.update)
|
||||
DownloadButton.ButtonStyle.NORMAL
|
||||
} else {
|
||||
setText(R.string.launch)
|
||||
DownloadButton.ButtonStyle.LAUNCH_OR_OPEN
|
||||
}
|
||||
} else {
|
||||
buttonStyle = DownloadButton.ButtonStyle.INSTALL_NORMAL
|
||||
setText(R.string.install)
|
||||
}
|
||||
buttonStyle =
|
||||
if (downloadEntity.isPluggable && PackagesManager.isInstalled(downloadEntity.packageName)) {
|
||||
DownloadButton.ButtonStyle.PLUGIN
|
||||
} else {
|
||||
DownloadButton.ButtonStyle.NORMAL
|
||||
}
|
||||
}
|
||||
DownloadStatus.pause,
|
||||
DownloadStatus.timeout,
|
||||
DownloadStatus.neterror,
|
||||
DownloadStatus.subscribe,
|
||||
DownloadStatus.overflow -> {
|
||||
val status = downloadEntity.status
|
||||
if (status == DownloadStatus.downloading) {
|
||||
setText(R.string.downloading)
|
||||
buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_NORMAL
|
||||
} else if (status == DownloadStatus.waiting) {
|
||||
setText(R.string.waiting)
|
||||
buttonStyle = DownloadButton.ButtonStyle.WAITING
|
||||
} else if (status == DownloadStatus.pause || status == DownloadStatus.timeout || status == DownloadStatus.neterror || status == DownloadStatus.subscribe || status == DownloadStatus.overflow) {
|
||||
setText(R.string.downloading)
|
||||
buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_NORMAL
|
||||
} else if (status == DownloadStatus.done) {
|
||||
val xapkStatus = downloadEntity.meta[XapkInstaller.XAPK_UNZIP_STATUS]
|
||||
if (XapkUnzipStatus.UNZIPPING.name == xapkStatus) {
|
||||
setText(R.string.unzipping)
|
||||
buttonStyle = DownloadButton.ButtonStyle.NORMAL
|
||||
setText(R.string.resume)
|
||||
return
|
||||
}
|
||||
DownloadStatus.cancel -> {
|
||||
if (downloadEntity.isSimulatorGame() && gameEntity.simulator != null) {
|
||||
GameUtils.setDownloadBtnStatus(context, gameEntity, downloadBtn, pluginLocation)
|
||||
} else if (downloadEntity.isVGame()) {
|
||||
if (PackagesManager.isCanUpdate(downloadEntity.gameId, downloadEntity.packageName)) {
|
||||
setText(R.string.update)
|
||||
} else {
|
||||
setText(R.string.launch)
|
||||
}
|
||||
} else {
|
||||
setText(R.string.install)
|
||||
}
|
||||
else -> {
|
||||
// do nothing
|
||||
}
|
||||
buttonStyle =
|
||||
if (downloadEntity.isPluggable && PackagesManager.isInstalled(downloadEntity.packageName)) {
|
||||
DownloadButton.ButtonStyle.PLUGIN
|
||||
} else {
|
||||
DownloadButton.ButtonStyle.NORMAL
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -331,184 +310,192 @@ object DownloadItemUtils {
|
||||
|
||||
// 更新正常的条目,只有一个apk包
|
||||
private fun updateNormalItem(
|
||||
context: Context,
|
||||
holder: GameViewHolder,
|
||||
gameEntity: GameEntity,
|
||||
briefStyle: String?,
|
||||
context: Context, holder: GameViewHolder, gameEntity: GameEntity,
|
||||
isShowPlatform: Boolean, briefStyle: String?,
|
||||
isShowRecommendStar: Boolean = false
|
||||
) {
|
||||
val entryMap: ArrayMap<String, DownloadEntity> = gameEntity.getEntryMap()
|
||||
val apkEntity = gameEntity.getApk()[0]
|
||||
var downloadEntity: DownloadEntity? = null
|
||||
if (entryMap.isNotEmpty()) {
|
||||
downloadEntity = entryMap[apkEntity.getPlatform()]
|
||||
}
|
||||
if (downloadEntity == null) {
|
||||
downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity)
|
||||
}
|
||||
if (downloadEntity != null) {
|
||||
if (downloadEntity.isSimulatorGame()) {
|
||||
if (downloadEntity.status != DownloadStatus.done) {
|
||||
val downloadEntity = entryMap[apkEntity.getPlatform()]
|
||||
if (downloadEntity != null) {
|
||||
if (downloadEntity.isSimulatorGame()) {
|
||||
if (downloadEntity.status != DownloadStatus.done) {
|
||||
// 更改进度条和提示文本的状态
|
||||
changeStatus(context, holder, downloadEntity, isShowPlatform, true)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
// 更改进度条和提示文本的状态
|
||||
changeStatus(context, holder, downloadEntity)
|
||||
changeStatus(context, holder, downloadEntity, isShowPlatform, true, isShowRecommendStar)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
// 更改进度条和提示文本的状态
|
||||
changeStatus(context, holder, downloadEntity)
|
||||
return
|
||||
}
|
||||
}
|
||||
updateItemViewStatus(holder, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
|
||||
updateItemViewStatus(holder, false, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
|
||||
}
|
||||
|
||||
// 更新插件的条目,有多个apk包
|
||||
private fun updatePluginItem(
|
||||
context: Context,
|
||||
holder: GameViewHolder,
|
||||
gameEntity: GameEntity,
|
||||
briefStyle: String?,
|
||||
context: Context, holder: GameViewHolder, gameEntity: GameEntity,
|
||||
isShowPlatform: Boolean, briefStyle: String?,
|
||||
isShowRecommendStar: Boolean = false
|
||||
) {
|
||||
val entryMap = gameEntity.getEntryMap()
|
||||
var downloadEntity: DownloadEntity? = null
|
||||
if (entryMap.isNotEmpty()) {
|
||||
val queue = DownloadManager.getInstance().getQueue(gameEntity.name)
|
||||
downloadEntity = if (queue != null && !queue.isEmpty()) {
|
||||
val downloadEntity = if (queue != null && !queue.isEmpty()) {
|
||||
entryMap[queue.peek()]
|
||||
} else {
|
||||
entryMap[entryMap.keyAt(0)]
|
||||
}
|
||||
if (downloadEntity != null) {
|
||||
// 更改进度条和提示文本的状态
|
||||
changeStatus(context, holder, downloadEntity, isShowPlatform, false, isShowRecommendStar)
|
||||
return
|
||||
}
|
||||
}
|
||||
if (downloadEntity == null) {
|
||||
downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity)
|
||||
}
|
||||
if (downloadEntity != null) {
|
||||
// 更改进度条和提示文本的状态
|
||||
changeStatus(context, holder, downloadEntity, gameEntity.getApk().size > 1)
|
||||
return
|
||||
}
|
||||
updateItemViewStatus(holder, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
|
||||
updateItemViewStatus(holder, false, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
|
||||
}
|
||||
|
||||
// 更改进度条和提示文本的状态
|
||||
fun changeStatus(
|
||||
context: Context,
|
||||
holder: GameViewHolder,
|
||||
downloadEntity: DownloadEntity,
|
||||
isMultiVersion: Boolean = false
|
||||
context: Context, holder: GameViewHolder, downloadEntity: DownloadEntity,
|
||||
isShowPlatform: Boolean, isNormal: Boolean, isShowRecommendStar: Boolean = false
|
||||
) {
|
||||
when (downloadEntity.status) {
|
||||
DownloadStatus.redirected,
|
||||
DownloadStatus.downloading -> {
|
||||
if (isMultiVersion) {
|
||||
holder.gameDownloadBtn.buttonStyle = DownloadButton.ButtonStyle.NORMAL
|
||||
val darkMode = (holder.gameDownloadTips?.getTag(R.string.is_dark_mode_on_id) as? Boolean) ?: false
|
||||
val isDarkModeChanged = DarkModeUtils.isDarkModeOn(context) != darkMode
|
||||
if (holder.gameDownloadTips?.visibility == View.GONE || holder.gameDownloadTips?.isAnimating == false || isDarkModeChanged) {
|
||||
holder.gameDownloadTips?.visibility = View.VISIBLE
|
||||
holder.gameDownloadTips?.setDownloadTipsAnimation(true)
|
||||
}
|
||||
holder.gameDownloadTips?.setTag(R.string.is_dark_mode_on_id, DarkModeUtils.isDarkModeOn(context))
|
||||
val status = downloadEntity.status
|
||||
// 畅玩游戏下载完成时不再需要显示进度条
|
||||
val shouldShowDownload = !(downloadEntity.isVGame() && status == DownloadStatus.done)
|
||||
val platform = PlatformUtils.getInstance(context).getPlatformName(downloadEntity.platform)
|
||||
|
||||
updateItemViewStatus(holder, shouldShowDownload, null, null, isShowRecommendStar)
|
||||
holder.gameProgressbar.progressDrawable = R.drawable.progressbar_bg_style.toDrawable()
|
||||
|
||||
if (status == DownloadStatus.downloading) {
|
||||
if (DownloadStatus.pause != DownloadManager.getInstance().getStatus(downloadEntity.url)) {
|
||||
holder.gameProgressbar.progress = (downloadEntity.percent * 10).toInt()
|
||||
if (isShowPlatform && platform != null) {
|
||||
holder.gameDownloadSpeed.text = String.format(
|
||||
"%s - %s(剩%s)", platform,
|
||||
SpeedUtils.getSpeed(downloadEntity.speed),
|
||||
SpeedUtils.getRemainTime(
|
||||
downloadEntity.size,
|
||||
downloadEntity.progress,
|
||||
downloadEntity.speed * 1024
|
||||
)
|
||||
)
|
||||
} else {
|
||||
holder.gameDownloadTips?.visibility = View.GONE
|
||||
holder.gameDownloadBtn.buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_NORMAL
|
||||
holder.gameDownloadBtn.progress = (downloadEntity.percent * 10).toInt()
|
||||
holder.gameDownloadBtn.text = downloadEntity.percent.toString() + "%"
|
||||
holder.gameDownloadSpeed.text = String.format(
|
||||
"%s(剩%s)", SpeedUtils.getSpeed(downloadEntity.speed),
|
||||
SpeedUtils.getRemainTime(
|
||||
downloadEntity.size,
|
||||
downloadEntity.progress,
|
||||
downloadEntity.speed * 1024
|
||||
)
|
||||
)
|
||||
}
|
||||
holder.gameDownloadPercentage.text = downloadEntity.percent.toString() + "%"
|
||||
}
|
||||
DownloadStatus.waiting -> {
|
||||
if (isMultiVersion) {
|
||||
holder.gameDownloadTips?.visibility = View.VISIBLE
|
||||
holder.gameDownloadTips?.setDownloadTipsAnimation(false)
|
||||
}
|
||||
holder.gameDownloadBtn.buttonStyle = DownloadButton.ButtonStyle.WAITING
|
||||
holder.gameDownloadBtn.text = context.getString(R.string.waiting)
|
||||
} else if (status == DownloadStatus.waiting) {
|
||||
holder.gameProgressbar.progress = (downloadEntity.percent * 10).toInt()
|
||||
if (isShowPlatform && platform != null) {
|
||||
holder.gameDownloadSpeed.text = String.format("%s - 等待", platform)
|
||||
} else {
|
||||
holder.gameDownloadSpeed.text = "等待"
|
||||
}
|
||||
DownloadStatus.pause,
|
||||
DownloadStatus.timeout,
|
||||
DownloadStatus.neterror,
|
||||
DownloadStatus.subscribe,
|
||||
DownloadStatus.overflow -> {
|
||||
if (isMultiVersion) {
|
||||
holder.gameDownloadTips?.visibility = View.VISIBLE
|
||||
holder.gameDownloadTips?.setDownloadTipsAnimation(false)
|
||||
}
|
||||
holder.gameDownloadBtn.buttonStyle = DownloadButton.ButtonStyle.NORMAL
|
||||
holder.gameDownloadBtn.text = context.getString(R.string.resume)
|
||||
holder.gameDownloadPercentage.text = downloadEntity.percent.toString() + "%"
|
||||
} else if (status == DownloadStatus.pause || status == DownloadStatus.timeout || status == DownloadStatus.neterror || status == DownloadStatus.subscribe || status == DownloadStatus.overflow) {
|
||||
holder.gameProgressbar.progress = (downloadEntity.percent * 10).toInt()
|
||||
if (isShowPlatform && platform != null) {
|
||||
holder.gameDownloadSpeed.text = String.format("%s - 暂停", platform)
|
||||
} else {
|
||||
holder.gameDownloadSpeed.text = "暂停"
|
||||
}
|
||||
DownloadStatus.done -> {
|
||||
if (isMultiVersion) {
|
||||
holder.gameDownloadTips?.visibility = View.VISIBLE
|
||||
holder.gameDownloadTips?.setDownloadTipsAnimation(false)
|
||||
}
|
||||
val xapkStatus = downloadEntity.meta[XapkInstaller.XAPK_UNZIP_STATUS]
|
||||
if (XapkUnzipStatus.UNZIPPING.name == xapkStatus) {
|
||||
val percent = downloadEntity.meta[XapkInstaller.XAPK_UNZIP_PERCENT]
|
||||
holder.gameDownloadBtn.progress = (java.lang.Float.valueOf(percent) * 10).toInt()
|
||||
holder.gameDownloadBtn.text = "$percent%"
|
||||
return
|
||||
} else if (XapkUnzipStatus.FAILURE.name == xapkStatus) {
|
||||
holder.gameDownloadBtn.setText(R.string.install)
|
||||
holder.gameDownloadBtn.buttonStyle = DownloadButton.ButtonStyle.INSTALL_NORMAL
|
||||
return
|
||||
}
|
||||
holder.gameDownloadBtn.progress = 1000
|
||||
holder.gameDownloadBtn.setText(R.string.hundred_percent)
|
||||
holder.gameDownloadPercentage.text = downloadEntity.percent.toString() + "%"
|
||||
} else if (status == DownloadStatus.done) {
|
||||
val xapkStatus = downloadEntity.meta[XapkInstaller.XAPK_UNZIP_STATUS]
|
||||
if (XapkUnzipStatus.UNZIPPING.name == xapkStatus) {
|
||||
val percent = downloadEntity.meta[XapkInstaller.XAPK_UNZIP_PERCENT]
|
||||
holder.gameProgressbar.progressDrawable =
|
||||
context.resources.getDrawable(R.drawable.progressbar_xapk_style)
|
||||
holder.gameDownloadSpeed.setText(R.string.unzipping)
|
||||
holder.gameProgressbar.progress = (java.lang.Float.valueOf(percent) * 10).toInt()
|
||||
holder.gameDownloadPercentage.text = "$percent%"
|
||||
return
|
||||
}
|
||||
else -> {
|
||||
holder.gameDownloadTips?.visibility = View.GONE
|
||||
holder.gameProgressbar.progress = 1000
|
||||
if (isShowPlatform && platform != null) {
|
||||
holder.gameDownloadSpeed.text = String.format("%s - 下载完成", platform)
|
||||
} else {
|
||||
holder.gameDownloadSpeed.text = "下载完成"
|
||||
}
|
||||
holder.gameDownloadPercentage.setText(R.string.hundred_percent)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateItemViewStatus(
|
||||
holder: GameViewHolder,
|
||||
showDownload: Boolean,
|
||||
briefStyle: String?,
|
||||
recommendStyle: LinkEntity?,
|
||||
isShowRecommendStar: Boolean = false
|
||||
) {
|
||||
holder.gameDownloadTips?.visibility = View.GONE
|
||||
// 推荐指数优先,现暂时为游戏单详情列表游戏使用
|
||||
if (isShowRecommendStar && holder.recommendStarInfo != null) {
|
||||
holder.recommendStarInfo!!.visibility = View.VISIBLE
|
||||
if (showDownload) {
|
||||
if (holder.gameRating != null) holder.gameRating!!.visibility = View.GONE
|
||||
holder.gameDes?.visibility = View.GONE
|
||||
return
|
||||
}
|
||||
|
||||
// 推荐优先,有推荐内容时不执行下面的 star 和 brief 代码块
|
||||
if (briefStyle != null && recommendStyle != null && briefStyle.contains("recommend")) {
|
||||
if (holder.recommendContainer != null) {
|
||||
holder.recommendContainer!!.visibility = View.VISIBLE
|
||||
}
|
||||
if (holder.gameRating != null) holder.gameRating!!.visibility = View.GONE
|
||||
holder.gameDes?.visibility = View.GONE
|
||||
holder.recommendTv?.text = recommendStyle.text
|
||||
if (TextUtils.isEmpty(recommendStyle.icon)) {
|
||||
holder.recommendIv?.visibility = View.GONE
|
||||
holder.recommendContainer?.setPadding(6F.dip2px(), 0, 8F.dip2px(), 0)
|
||||
} else {
|
||||
holder.recommendIv?.visibility = View.VISIBLE
|
||||
ImageUtils.display(holder.recommendIv, recommendStyle.icon)
|
||||
}
|
||||
return
|
||||
} else {
|
||||
holder.gameDes.visibility = View.GONE
|
||||
holder.gameProgressbar.visibility = View.VISIBLE
|
||||
holder.gameInfo.visibility = View.VISIBLE
|
||||
if (holder.recommendContainer != null) {
|
||||
holder.recommendContainer!!.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
if (briefStyle != null && briefStyle.contains("star")) {
|
||||
if (holder.gameRating != null) holder.gameRating!!.visibility = View.VISIBLE
|
||||
if (holder.recommendStarInfo != null) {
|
||||
holder.recommendStarInfo!!.visibility = View.GONE
|
||||
}
|
||||
} else {
|
||||
if (holder.gameRating != null) holder.gameRating!!.visibility = View.GONE
|
||||
}
|
||||
holder.gameProgressbar.visibility = View.GONE
|
||||
holder.gameInfo.visibility = View.GONE
|
||||
|
||||
// 缺省情况下回落到游戏简介
|
||||
if (TextUtils.isEmpty(briefStyle) || briefStyle!!.contains("brief") || briefStyle.contains("recommend")) {
|
||||
holder.gameDes?.visibility = View.VISIBLE
|
||||
} else {
|
||||
holder.gameDes?.visibility = View.GONE
|
||||
// 推荐指数优先,现暂时为游戏单详情列表游戏使用
|
||||
if (isShowRecommendStar && holder.recommendStarInfo != null) {
|
||||
holder.recommendStarInfo!!.visibility = View.VISIBLE
|
||||
if (holder.gameRating != null) holder.gameRating!!.visibility = View.GONE
|
||||
holder.gameDes.visibility = View.GONE
|
||||
return
|
||||
}
|
||||
|
||||
// 推荐优先,有推荐内容时不执行下面的 star 和 brief 代码块
|
||||
if (briefStyle != null && recommendStyle != null && briefStyle.contains("recommend")) {
|
||||
if (holder.recommendContainer != null) {
|
||||
holder.recommendContainer!!.visibility = View.VISIBLE
|
||||
}
|
||||
if (holder.gameRating != null) holder.gameRating!!.visibility = View.GONE
|
||||
holder.gameDes.visibility = View.GONE
|
||||
holder.recommendTv.text = recommendStyle.text
|
||||
if (TextUtils.isEmpty(recommendStyle.icon)) {
|
||||
holder.recommendIv.visibility = View.GONE
|
||||
holder.recommendContainer?.setPadding(6F.dip2px(), 0, 8F.dip2px(), 0)
|
||||
} else {
|
||||
holder.recommendIv.visibility = View.VISIBLE
|
||||
ImageUtils.display(holder.recommendIv, recommendStyle.icon)
|
||||
}
|
||||
return
|
||||
} else {
|
||||
if (holder.recommendContainer != null) {
|
||||
holder.recommendContainer!!.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
if (briefStyle != null && briefStyle.contains("star")) {
|
||||
if (holder.gameRating != null) holder.gameRating!!.visibility = View.VISIBLE
|
||||
} else {
|
||||
if (holder.gameRating != null) holder.gameRating!!.visibility = View.GONE
|
||||
}
|
||||
|
||||
// 缺省情况下回落到游戏简介
|
||||
if (TextUtils.isEmpty(briefStyle) || briefStyle!!.contains("brief") || briefStyle.contains("recommend")) {
|
||||
holder.gameDes.visibility = View.VISIBLE
|
||||
} else {
|
||||
holder.gameDes.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -575,7 +562,7 @@ object DownloadItemUtils {
|
||||
@JvmStatic
|
||||
fun setOnClickListener(
|
||||
context: Context,
|
||||
downloadBtn: View,
|
||||
downloadBtn: DownloadButton,
|
||||
gameEntity: GameEntity,
|
||||
position: Int,
|
||||
adapter: RecyclerView.Adapter<out RecyclerView.ViewHolder?>?,
|
||||
@ -655,22 +642,30 @@ object DownloadItemUtils {
|
||||
allStateClickCallback?.onCallback()
|
||||
clickCallback?.onCallback()
|
||||
if ("download" == gameEntity.reserveStatus) {
|
||||
ReservationHelper.showDeleteReservationDialog(context) {
|
||||
ReservationHelper.deleteReservation(gameEntity) {
|
||||
adapter?.notifyItemChanged(position)
|
||||
refreshCallback?.onCallback()
|
||||
ReservationHelper.showDeleteReservationDialog(context, object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
ReservationHelper.deleteReservation(gameEntity, object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
adapter?.notifyItemChanged(position)
|
||||
refreshCallback?.onCallback()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
ReservationHelper.showCancelReservationDialog(context, {
|
||||
NewFlatLogUtils.logMyGameCancelReserveDialogClick(
|
||||
"确定取消",
|
||||
gameEntity.id,
|
||||
gameEntity.name ?: ""
|
||||
)
|
||||
ReservationHelper.cancelReservation(gameEntity) {
|
||||
adapter?.notifyItemChanged(position)
|
||||
refreshCallback?.onCallback()
|
||||
ReservationHelper.showCancelReservationDialog(context, object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
NewFlatLogUtils.logMyGameCancelReserveDialogClick(
|
||||
"确定取消",
|
||||
gameEntity.id,
|
||||
gameEntity.name ?: ""
|
||||
)
|
||||
ReservationHelper.cancelReservation(gameEntity, object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
adapter?.notifyItemChanged(position)
|
||||
refreshCallback?.onCallback()
|
||||
}
|
||||
})
|
||||
}
|
||||
}, object : CancelListener {
|
||||
override fun onCancel() {
|
||||
@ -713,24 +708,26 @@ object DownloadItemUtils {
|
||||
}
|
||||
} else if (gameEntity.getApk().size == 1) {
|
||||
downloadBtn.setOnClickListener {
|
||||
val clickRunnable = EmptyCallback {
|
||||
allStateClickCallback?.onCallback()
|
||||
clickCallback?.onCallback()
|
||||
onNormalClick(
|
||||
context,
|
||||
downloadBtn,
|
||||
gameEntity,
|
||||
position,
|
||||
adapter,
|
||||
entrance,
|
||||
location,
|
||||
traceEvent,
|
||||
refreshCallback
|
||||
)
|
||||
val clickRunnable = object : EmptyCallback {
|
||||
override fun onCallback() {
|
||||
allStateClickCallback?.onCallback()
|
||||
clickCallback?.onCallback()
|
||||
onNormalClick(
|
||||
context,
|
||||
downloadBtn,
|
||||
gameEntity,
|
||||
position,
|
||||
adapter,
|
||||
entrance,
|
||||
location,
|
||||
traceEvent,
|
||||
refreshCallback
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// 启动不需要请求存储权限
|
||||
if (downloadBtn is DownloadButton && downloadBtn.text == context.getString(R.string.launch)) {
|
||||
if (downloadBtn.text.toString() == context.getString(R.string.launch)) {
|
||||
clickRunnable.onCallback()
|
||||
} else {
|
||||
PermissionHelper.checkStoragePermissionBeforeAction(context, clickRunnable)
|
||||
@ -759,7 +756,7 @@ object DownloadItemUtils {
|
||||
@JvmOverloads
|
||||
fun onNormalClick(
|
||||
context: Context,
|
||||
downloadBtn: View?,
|
||||
downloadBtn: DownloadButton,
|
||||
gameEntity: GameEntity,
|
||||
position: Int,
|
||||
adapter: RecyclerView.Adapter<out RecyclerView.ViewHolder?>?,
|
||||
@ -768,7 +765,7 @@ object DownloadItemUtils {
|
||||
traceEvent: ExposureEvent? = null,
|
||||
refreshCallback: EmptyCallback? = null
|
||||
) {
|
||||
val str = if (downloadBtn is DownloadButton) downloadBtn.text else context.getString(R.string.download)
|
||||
val str = downloadBtn.text.toString()
|
||||
if (gameEntity.getApk().isEmpty()) return
|
||||
val apk = gameEntity.getApk().safelyGetInRelease(0) ?: return
|
||||
if (str == context.getString(R.string.download)) {
|
||||
@ -790,7 +787,6 @@ object DownloadItemUtils {
|
||||
DataLogUtils.uploadGameLog(context, gameEntity.id, gameEntity.name, entrance)
|
||||
} else if (str == context.getString(R.string.attempt)) {
|
||||
ChainBuilder().apply {
|
||||
addHandler(UpdateNewSimulatorHandler())
|
||||
addHandler(GamePermissionHandler())
|
||||
addHandler(BrowserInstallHandler())
|
||||
addHandler(PackageCheckHandler())
|
||||
@ -848,9 +844,8 @@ object DownloadItemUtils {
|
||||
val isInstalledNewSimulator = SimulatorGameManager.isNewSimulatorInstalled(context)
|
||||
val isInstalledOldSimulator = SimulatorGameManager.isOldSimulatorInstalled(context)
|
||||
var simulator = gameEntity.simulator
|
||||
val newSimulator = Config.getNewSimulatorEntitySetting()
|
||||
if (!isInstalledOldSimulator && newSimulator != null && newSimulator.active) {//在没有安装旧的模拟器且有配置新版模拟器 才使用新版模拟器 否则还是用以前旧的
|
||||
simulator = newSimulator
|
||||
if (!isInstalledOldSimulator) {
|
||||
simulator = Config.getNewSimulatorEntitySetting()
|
||||
}
|
||||
if (downloadEntity != null && SimulatorGameManager.isSimulatorGame(gameEntity) && !isInstalled && !isInstalledNewSimulator) {
|
||||
SimulatorDownloadManager.getInstance().showDownloadDialog(
|
||||
@ -912,31 +907,15 @@ object DownloadItemUtils {
|
||||
}
|
||||
})
|
||||
} else {
|
||||
var downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity)
|
||||
if (downloadEntity == null && gameEntity.getApk().size == 1) {
|
||||
val entryMap: ArrayMap<String, DownloadEntity> = gameEntity.getEntryMap()
|
||||
val apkEntity = gameEntity.getApk()[0]
|
||||
if (entryMap.isNotEmpty()) {
|
||||
downloadEntity = entryMap[apkEntity.getPlatform()]
|
||||
}
|
||||
}
|
||||
if (downloadEntity != null) {
|
||||
val xapkStatus = downloadEntity.meta[XapkInstaller.XAPK_UNZIP_STATUS]
|
||||
if (XapkUnzipStatus.UNZIPPING.name == xapkStatus) {
|
||||
cancelUnzipTask(downloadEntity)
|
||||
return
|
||||
}
|
||||
when (str) {
|
||||
context.getString(R.string.resume) -> {
|
||||
DownloadManager.getInstance().resume(downloadEntity, true)
|
||||
}
|
||||
context.getString(R.string.waiting) -> {
|
||||
Utils.toast(context, "最多只能同时下载三个任务,请稍等")
|
||||
}
|
||||
else -> {
|
||||
DownloadManager.getInstance().pause(downloadEntity.url)
|
||||
}
|
||||
}
|
||||
if (gameEntity.isVGame()) {
|
||||
context.startActivity(VDownloadManagerActivity.getIntent(context, true))
|
||||
} else {
|
||||
context.startActivity(
|
||||
DownloadManagerActivity.getDownloadMangerIntent(
|
||||
context,
|
||||
apk.url, entrance + "+(" + location.split(":").toTypedArray()[0] + ")"
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -945,7 +924,7 @@ object DownloadItemUtils {
|
||||
private fun download(
|
||||
context: Context,
|
||||
gameEntity: GameEntity,
|
||||
downloadBtn: View?,
|
||||
downloadBtn: DownloadButton,
|
||||
entrance: String,
|
||||
location: String,
|
||||
isSubscribe: Boolean,
|
||||
@ -965,10 +944,8 @@ object DownloadItemUtils {
|
||||
traceEvent
|
||||
)
|
||||
Utils.toast(context, gameEntity.name + "已加入下载队列")
|
||||
if (downloadBtn is DownloadButton) {
|
||||
downloadBtn.text = "0%"
|
||||
downloadBtn.buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_NORMAL
|
||||
}
|
||||
downloadBtn.setText(R.string.downloading)
|
||||
downloadBtn.buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_NORMAL
|
||||
DeviceRemindDialog.showDeviceRemindDialog(context, gameEntity)
|
||||
} else {
|
||||
Utils.toast(context, msg)
|
||||
@ -977,22 +954,15 @@ object DownloadItemUtils {
|
||||
|
||||
//插件化
|
||||
private fun plugin(
|
||||
context: Context,
|
||||
gameEntity: GameEntity,
|
||||
downloadBtn: View?,
|
||||
entrance: String,
|
||||
location: String,
|
||||
isSubscribe: Boolean,
|
||||
traceEvent: ExposureEvent?
|
||||
context: Context, gameEntity: GameEntity, downloadBtn: DownloadButton, entrance: String,
|
||||
location: String, isSubscribe: Boolean, traceEvent: ExposureEvent?
|
||||
) {
|
||||
val msg = FileUtils.isCanDownload(context, gameEntity.getApk()[0].size)
|
||||
if (TextUtils.isEmpty(msg)) {
|
||||
DownloadManager.createDownload(context, gameEntity, "插件化", entrance, location, isSubscribe, traceEvent)
|
||||
Utils.toast(context, gameEntity.name + "已加入下载队列")
|
||||
if (downloadBtn is DownloadButton) {
|
||||
downloadBtn.setText(R.string.downloading)
|
||||
downloadBtn.buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_PLUGIN
|
||||
}
|
||||
downloadBtn.setText(R.string.downloading)
|
||||
downloadBtn.buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_PLUGIN
|
||||
} else {
|
||||
Utils.toast(context, msg)
|
||||
}
|
||||
@ -1000,11 +970,8 @@ object DownloadItemUtils {
|
||||
|
||||
//安装
|
||||
private fun install(
|
||||
context: Context,
|
||||
gameEntity: GameEntity,
|
||||
position: Int,
|
||||
adapter: RecyclerView.Adapter<out RecyclerView.ViewHolder?>?,
|
||||
refreshCallback: EmptyCallback?
|
||||
context: Context, gameEntity: GameEntity, position: Int,
|
||||
adapter: RecyclerView.Adapter<out RecyclerView.ViewHolder?>?, refreshCallback: EmptyCallback?
|
||||
) {
|
||||
val apkEntity = gameEntity.getApk()[0]
|
||||
val downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity)
|
||||
|
||||
@ -35,7 +35,7 @@ object DownloadNotificationHelper {
|
||||
const val ACTION_DOWNLOAD = "com.gh.gamecenter.DOWNLOAD"
|
||||
const val ACTION_VDOWNLOAD = "com.gh.gamecenter.VDOWNLOAD"
|
||||
|
||||
private val mNotifyMap: MutableMap<String, Long> by lazy { mutableMapOf() }
|
||||
private val mNotifyMap: MutableMap<String, Long> = mutableMapOf()
|
||||
|
||||
private fun getNotificationManager(): NotificationManager {
|
||||
return HaloApp.getInstance().application.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
@ -196,6 +196,13 @@ object DownloadNotificationHelper {
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun initDownloadNotification(downloadTasks: MutableList<DownloadEntity>) {
|
||||
for (downloadTask in downloadTasks) {
|
||||
addOrUpdateDownloadNotification(downloadTask)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getNotificationIcon(): Int {
|
||||
return R.mipmap.logo
|
||||
}
|
||||
|
||||
@ -8,25 +8,28 @@ import com.gh.common.xapk.XapkInstaller
|
||||
import com.gh.download.DownloadDataHelper
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.SuggestionActivity
|
||||
import com.gh.gamecenter.common.base.activity.BaseActivity
|
||||
import com.gh.gamecenter.common.callback.ConfirmListener
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.common.entity.SimpleGameEntity
|
||||
import com.gh.gamecenter.common.entity.SuggestType
|
||||
import com.gh.gamecenter.common.eventbus.EBShowDialog
|
||||
import com.gh.gamecenter.common.retrofit.Response
|
||||
import com.gh.gamecenter.common.utils.*
|
||||
import com.gh.gamecenter.core.utils.*
|
||||
import com.gh.gamecenter.energy.EnergyBridge
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.SimpleGameEntity
|
||||
import com.gh.gamecenter.entity.SimulatorEntity
|
||||
import com.gh.gamecenter.eventbus.EBDownloadStatus
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.entity.SimulatorEntity
|
||||
import com.gh.gamecenter.feature.utils.PlatformUtils
|
||||
import com.gh.gamecenter.help.HelpAndFeedbackBridge
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.gh.gamecenter.setting.compose.activity.ComposeGameDownloadSettingActivity
|
||||
import com.gh.gamecenter.suggest.SuggestType
|
||||
import com.gh.vspace.VHelper
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.download.*
|
||||
import com.lightgame.download.DataWatcher
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import com.lightgame.download.DownloadStatus
|
||||
import com.lightgame.download.FileUtils
|
||||
import com.lightgame.utils.AppManager
|
||||
import com.lightgame.utils.Utils
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
@ -44,8 +47,6 @@ object DownloadObserver {
|
||||
// TODO 修复因为更改内存对象造成的双重下载完成事件问题,具体触发代码见 DownloadDao.updateSnapshotList
|
||||
private var mDoneDebouncePair: Pair<String, Long>? = null
|
||||
|
||||
private const val TEA_EVENT_DOWNLOAD_COMPLETE = "game_addiction"
|
||||
|
||||
// 如果在WIFI状态下,下载自动暂停,则再重试一遍
|
||||
@JvmStatic
|
||||
fun initObserver() {
|
||||
@ -76,7 +77,7 @@ object DownloadObserver {
|
||||
val currentActivity = AppManager.getInstance().currentActivity() ?: return
|
||||
|
||||
DialogHelper.showDialog(currentActivity, "下载失败", "下载链接已失效,建议提交反馈", "立即反馈", "取消", {
|
||||
HelpAndFeedbackBridge.startSuggestionActivity(
|
||||
SuggestionActivity.startSuggestionActivity(
|
||||
currentActivity,
|
||||
SuggestType.gameQuestion, "notfound",
|
||||
StringUtils.buildString(downloadEntity.name, ",问题反馈:下载链接失效"),
|
||||
@ -199,11 +200,6 @@ object DownloadObserver {
|
||||
} else {
|
||||
statDoneEvent(downloadEntity)
|
||||
|
||||
if (!SPUtils.getBoolean(TEA_EVENT_DOWNLOAD_COMPLETE)) {
|
||||
HaloApp.getInstance().flavorProvider.logEvent(TEA_EVENT_DOWNLOAD_COMPLETE)
|
||||
SPUtils.setBoolean(TEA_EVENT_DOWNLOAD_COMPLETE, true)
|
||||
}
|
||||
|
||||
GameActivityDownloadHelper.clear()
|
||||
|
||||
EnergyBridge.postEnergyTask("download_game", downloadEntity.gameId, downloadEntity.packageName)
|
||||
@ -244,20 +240,16 @@ object DownloadObserver {
|
||||
val gameName = downloadEntity.getMetaExtra(Constants.GAME_NAME)
|
||||
if (simulatorJson.isEmpty()) return
|
||||
var simulator = GsonUtils.fromJson(simulatorJson, SimulatorEntity::class.java)
|
||||
val isInstalled = PackageUtils.isInstalledFromAllPackage(
|
||||
HaloApp.getInstance().application,
|
||||
simulator.apk?.packageName
|
||||
)
|
||||
val isInstalledNewSimulator =
|
||||
SimulatorGameManager.isNewSimulatorInstalled(HaloApp.getInstance().application)
|
||||
val isInstalledOldSimulator =
|
||||
SimulatorGameManager.isOldSimulatorInstalled(HaloApp.getInstance().application)
|
||||
val isInstalled = PackageUtils.isInstalledFromAllPackage(HaloApp.getInstance().application, simulator.apk?.packageName)
|
||||
val isInstalledNewSimulator = SimulatorGameManager.isNewSimulatorInstalled(HaloApp.getInstance().application)
|
||||
val isInstalledOldSimulator = SimulatorGameManager.isOldSimulatorInstalled(HaloApp.getInstance().application)
|
||||
// if (!isInstalled && !isInstalledNewSimulator) {
|
||||
val currentActivity = AppManager.getInstance().currentActivity()
|
||||
?: return
|
||||
val newSimulator = Config.getNewSimulatorEntitySetting()
|
||||
if ((!isInstalledOldSimulator && newSimulator != null && newSimulator.active) || isInstalledNewSimulator) { //如果没有安装任一旧的模拟器 或者下载了新模拟器 则使用新版本模拟器
|
||||
simulator = newSimulator ?: simulator
|
||||
if (!isInstalledOldSimulator || isInstalledNewSimulator) { //如果没有安装任一旧的模拟器 或者下载了新模拟器 则使用新版本模拟器
|
||||
Config.getNewSimulatorEntitySetting().let {
|
||||
simulator = it!!
|
||||
}
|
||||
}
|
||||
SimulatorDownloadManager.getInstance().showDownloadDialog(
|
||||
currentActivity, simulator,
|
||||
@ -269,7 +261,7 @@ object DownloadObserver {
|
||||
} else {
|
||||
val downloadType = downloadEntity.getMetaExtra(Constants.EXTRA_DOWNLOAD_TYPE)
|
||||
// 是否是自动安装
|
||||
val isAutoInstall = SPUtils.getBoolean(Constants.SP_AUTO_INSTALL, true)
|
||||
val isAutoInstall = SPUtils.getBoolean(ComposeGameDownloadSettingActivity.AUTO_INSTALL_SP_KEY, true)
|
||||
if (downloadType == Constants.SIMULATOR_DOWNLOAD || isAutoInstall) {
|
||||
if (FileUtils.isEmptyFile(downloadEntity.path)) {
|
||||
Utils.toast(mApplication, R.string.install_failure_hint)
|
||||
@ -370,22 +362,6 @@ object DownloadObserver {
|
||||
if (downloadEntity.isPluggable) {
|
||||
type = ExposureUtils.DownloadType.PLUGIN_DOWNLOAD
|
||||
}
|
||||
|
||||
var downloadSpeed = 0L
|
||||
val elapsedTimeString = downloadEntity.meta[DownloadConfig.KEY_DOWNLOAD_ELAPSED_TIME]
|
||||
if (elapsedTimeString != null) {
|
||||
var elapsedTime = elapsedTimeString.toLong()
|
||||
if (elapsedTime == 0L) {
|
||||
elapsedTime = 1L
|
||||
SentryHelper.onEvent(
|
||||
"DOWNLOAD_ELAPSED_TIME",
|
||||
"elapsedTime is zero",
|
||||
downloadEntity.gameId + ":" + downloadEntity.size
|
||||
)
|
||||
}
|
||||
downloadSpeed = downloadEntity.size / elapsedTime
|
||||
}
|
||||
|
||||
val isPlatformRecommend =
|
||||
java.lang.Boolean.parseBoolean(downloadEntity.getMetaExtra(Constants.IS_PLATFORM_RECOMMEND))
|
||||
ExposureUtils.logADownloadCompleteExposureEvent(
|
||||
@ -397,7 +373,6 @@ object DownloadObserver {
|
||||
),
|
||||
downloadEntity.platform,
|
||||
downloadEntity.exposureTrace,
|
||||
downloadSpeed,
|
||||
downloadEntity.meta[DownloadEntity.DOWNLOAD_HOST_KEY] ?: "unknown",
|
||||
downloadEntity.meta[DownloadEntity.DOWNLOAD_PATH_KEY] ?: "unknown",
|
||||
type
|
||||
|
||||
@ -37,32 +37,6 @@ import java.util.Set;
|
||||
|
||||
public class EntranceUtils {
|
||||
|
||||
public static void jumpActivityCompat(Context context, Bundle bundle) {
|
||||
bundle.putBoolean(KEY_REQUIRE_REDIRECT, true);
|
||||
|
||||
if (HaloApp.getInstance().isRunningForeground || HaloApp.getInstance().isAlreadyUpAndRunning) {
|
||||
// 应用正在运行,前台或后台
|
||||
String to = bundle.getString(KEY_TO);
|
||||
Class<?> clazz = ClassUtils.forName(to);
|
||||
if (clazz == null) clazz = MainActivity.class;
|
||||
if (ToolbarFragment.class.isAssignableFrom(clazz)) { // 兼容ToolbarFragment
|
||||
ToolBarActivity.startFragmentNewTask(context, (Class<? extends ToolbarFragment>) clazz, bundle);
|
||||
} else {
|
||||
Intent intent1 = new Intent(context, clazz);
|
||||
intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
// 如果 activity 名称有 singleton 的就添加 reorder_to_front 标签 (有点粗暴有点蠢,但暂时就先这样吧 :C )
|
||||
if (clazz.getSimpleName().toLowerCase().contains("singleton")) {
|
||||
intent1.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
}
|
||||
intent1.putExtras(bundle);
|
||||
context.startActivity(intent1);
|
||||
}
|
||||
} else {
|
||||
// 应用未在运行
|
||||
context.startActivity(SplashScreenActivity.getSplashScreenIntent(context, bundle));
|
||||
}
|
||||
}
|
||||
|
||||
public static void jumpActivity(Context context, Bundle bundle) {
|
||||
bundle.putBoolean(KEY_REQUIRE_REDIRECT, true);
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ import com.gh.gamecenter.common.utils.DialogHelper
|
||||
import com.gh.gamecenter.common.utils.dip2px
|
||||
import com.gh.gamecenter.common.utils.toColor
|
||||
import com.gh.gamecenter.common.utils.toObject
|
||||
import com.gh.gamecenter.common.entity.ErrorEntity
|
||||
import com.gh.gamecenter.entity.ErrorEntity
|
||||
import com.halo.assistant.fragment.user.UserInfoEditFragment
|
||||
import com.halo.assistant.fragment.user.VerifyPhoneFragment
|
||||
import com.lightgame.utils.AppManager
|
||||
@ -183,11 +183,6 @@ object ErrorHelper {
|
||||
|
||||
403210 -> handleVerifyPhoneError(context, errorEntity, realNameConfirmListener, entrance)
|
||||
|
||||
// 禁言(发布内容)
|
||||
403402 -> Utils.toast(context, "您的账号存在违规,不允许发布内容")
|
||||
// 禁言(点赞)
|
||||
403403 -> Utils.toast(context, "您的账号存在违规,不允许点赞")
|
||||
|
||||
else -> Utils.toast(context, R.string.post_failure_hint)
|
||||
}
|
||||
}
|
||||
@ -408,16 +403,15 @@ object ErrorHelper {
|
||||
val errorEntity: ErrorEntity? =
|
||||
httpException?.response()?.errorBody()?.string()?.toObject()
|
||||
when {
|
||||
errorEntity?.code == 403099 -> Utils.toast(context, "当前账号正在注销,禁止登录")
|
||||
|
||||
// 用户禁止登录
|
||||
errorEntity?.code == 403401 -> Utils.toast(context, "您的账号存在违规,不允许登录")
|
||||
|
||||
// 设备禁止登录
|
||||
errorEntity?.code == 403404 -> Utils.toast(context, "您的设备存在违规,不允许登录")
|
||||
|
||||
errorEntity?.toast?.isNotEmpty() == true -> Utils.toast(context, errorEntity.toast)
|
||||
|
||||
errorEntity?.code == 403099 -> {
|
||||
Utils.toast(context, "当前账号正在注销,禁止登录")
|
||||
}
|
||||
errorEntity?.code == 403401 -> {//禁止登录
|
||||
Utils.toast(context, "网络异常")
|
||||
}
|
||||
errorEntity?.toast?.isNotEmpty() == true -> {
|
||||
Utils.toast(context, errorEntity.toast)
|
||||
}
|
||||
else -> Utils.toast(context, R.string.login_failure)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
|
||||
@ -3,10 +3,10 @@ package com.gh.common.util
|
||||
import android.app.Activity
|
||||
import android.os.Build
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.utils.dip2px
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils
|
||||
import com.gh.gamecenter.energy.EnergyBridge
|
||||
import com.lightgame.utils.Util_System_Keyboard
|
||||
import com.lzf.easyfloat.EasyFloat
|
||||
@ -67,14 +67,23 @@ object FloatingBackViewManager {
|
||||
}
|
||||
|
||||
dragEnd { view ->
|
||||
// 记录停止拖动的最后位置
|
||||
view.findViewById<View>(R.id.titleTv)?.apply {
|
||||
val outLocation = IntArray(2)
|
||||
getLocationOnScreen(outLocation)
|
||||
val yOffset = outLocation[1]
|
||||
val statusBarHeight = DisplayUtils.getStatusBarHeight(activity.resources)
|
||||
|
||||
mLastPositionY = yOffset
|
||||
// 记录停止拖动的最后位置
|
||||
val outLocation = IntArray(2)
|
||||
view.getLocationInWindow(outLocation)
|
||||
val yOffset = outLocation[1]
|
||||
|
||||
if (yOffset <= statusBarHeight) {
|
||||
// 判断状态栏是否被消费
|
||||
if (yOffset == view.y.toInt()) {
|
||||
view.y = statusBarHeight.toFloat()
|
||||
} else {
|
||||
view.y = 0F
|
||||
}
|
||||
}
|
||||
|
||||
mLastPositionY = yOffset
|
||||
}
|
||||
}
|
||||
.show()
|
||||
@ -104,6 +113,8 @@ object FloatingBackViewManager {
|
||||
|
||||
/**
|
||||
* 停用返回小浮窗
|
||||
* @param type 类型
|
||||
* @param activityUrl 类型为活动的时候用的地址
|
||||
*/
|
||||
@JvmStatic
|
||||
fun disableBackView() {
|
||||
|
||||
@ -5,14 +5,13 @@ import android.content.Context
|
||||
import android.text.TextUtils
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.gh.common.DefaultJsApi
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.common.dialog.CertificationDialog
|
||||
import com.gh.common.exposure.ExposureEvent
|
||||
import com.gh.common.exposure.ExposureManager
|
||||
import com.gh.common.exposure.ExposureSource
|
||||
import com.gh.common.exposure.ExposureType
|
||||
import com.gh.common.history.HistoryHelper
|
||||
import com.gh.common.repository.ReservationRepository
|
||||
import com.gh.common.simulator.NewSimulatorGameManager
|
||||
import com.gh.common.simulator.SimulatorDownloadManager
|
||||
import com.gh.common.simulator.SimulatorGameManager
|
||||
import com.gh.download.DownloadManager
|
||||
import com.gh.download.dialog.DownloadDialog
|
||||
import com.gh.gamecenter.R
|
||||
@ -28,26 +27,17 @@ import com.gh.gamecenter.common.utils.singleToMain
|
||||
import com.gh.gamecenter.common.view.dsbridge.CompletionHandler
|
||||
import com.gh.gamecenter.core.runOnUiThread
|
||||
import com.gh.gamecenter.core.utils.EmptyCallback
|
||||
import com.gh.gamecenter.core.utils.MtaHelper
|
||||
import com.gh.gamecenter.core.utils.SPUtils
|
||||
import com.gh.gamecenter.core.utils.ToastUtils
|
||||
import com.gh.gamecenter.energy.EnergyBridge
|
||||
import com.gh.gamecenter.feature.entity.ApkEntity
|
||||
import com.gh.gamecenter.feature.entity.GameEntity
|
||||
import com.gh.gamecenter.feature.entity.PluginLocation
|
||||
import com.gh.gamecenter.feature.exposure.ExposureEvent
|
||||
import com.gh.gamecenter.feature.exposure.ExposureSource
|
||||
import com.gh.gamecenter.feature.exposure.ExposureType
|
||||
import com.gh.gamecenter.feature.utils.ApkActiveUtils
|
||||
import com.gh.gamecenter.entity.ApkEntity
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.PluginLocation
|
||||
import com.gh.gamecenter.gamedetail.dialog.GamePermissionDialogFragment
|
||||
import com.gh.gamecenter.login.user.UserManager
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.gh.gamecenter.teenagermode.TeenagerModeActivity
|
||||
import com.gh.vspace.VHelper
|
||||
import com.lightgame.download.DownloadEntity
|
||||
import com.lightgame.download.FileUtils
|
||||
import com.lightgame.utils.Utils
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* 游戏活动下载辅助类
|
||||
@ -103,7 +93,7 @@ object GameActivityDownloadHelper {
|
||||
// 开始玩
|
||||
gameEntity.getApk().size == 0 && gameEntity.h5Link != null -> play(context, gameEntity)
|
||||
// 下载
|
||||
else -> handleDownloadStatus(context, event, gameEntity, entrance, location, this)
|
||||
else -> handleDownload(context, event, gameEntity, entrance, location, this)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -167,8 +157,8 @@ object GameActivityDownloadHelper {
|
||||
context.startActivity(i)
|
||||
}
|
||||
|
||||
// 处理下载的各种状态
|
||||
private fun handleDownloadStatus(
|
||||
// 下载
|
||||
private fun handleDownload(
|
||||
context: Context,
|
||||
event: DefaultJsApi.GameActivityEvent,
|
||||
gameEntity: GameEntity,
|
||||
@ -178,190 +168,49 @@ object GameActivityDownloadHelper {
|
||||
) {
|
||||
val apk = getApk(gameEntity, event, true) ?: return
|
||||
val downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity)
|
||||
val str = GameUtils.getDownloadBtnText(context, gameEntity, PluginLocation.only_game)
|
||||
if (downloadEntity != null &&
|
||||
str != context.getString(R.string.install) &&
|
||||
str != context.getString(R.string.launch)
|
||||
) {
|
||||
if (downloadEntity != null) {
|
||||
ToastUtils.toast("${gameEntity.name}已加入下载队列")
|
||||
} else {
|
||||
when {
|
||||
str == context.getString(R.string.download) || str == context.getString(R.string.attempt) -> {
|
||||
handleDownloadStatus(context, gameEntity, apk, entrance, location, traceEvent)
|
||||
}
|
||||
str == context.getString(R.string.smooth) -> {
|
||||
handleSmoothStatus(context, gameEntity, apk, entrance, location, traceEvent)
|
||||
}
|
||||
str.contains("化") -> {
|
||||
handlePluginStatus(context, gameEntity, apk, entrance, location, traceEvent)
|
||||
}
|
||||
str == context.getString(R.string.install) -> {
|
||||
handleInstallStatus(context, gameEntity, apk, downloadEntity)
|
||||
}
|
||||
str == context.getString(R.string.launch) -> {
|
||||
handleLaunchStatus(context, gameEntity, apk, entrance, location, traceEvent)
|
||||
}
|
||||
str == context.getString(R.string.update) -> {
|
||||
handleUpdateStatus(context, gameEntity, apk, entrance, location, traceEvent)
|
||||
}
|
||||
else -> {
|
||||
ToastUtils.toast("${gameEntity.name}已加入下载队列")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理下载状态
|
||||
private fun handleDownloadStatus(
|
||||
context: Context,
|
||||
gameEntity: GameEntity,
|
||||
apk: ApkEntity,
|
||||
entrance: String,
|
||||
location: String,
|
||||
traceEvent: ExposureEvent
|
||||
) {
|
||||
GamePermissionDialogFragment.show((context as AppCompatActivity), gameEntity, gameEntity.info) {
|
||||
CertificationDialog.showCertificationDialog(context, gameEntity) {
|
||||
DialogUtils.checkDownload(context, apk.size) { isSubscribe: Boolean ->
|
||||
download(context, gameEntity, apk, isSubscribe, entrance, location, traceEvent)
|
||||
}
|
||||
}
|
||||
}
|
||||
DataLogUtils.uploadGameLog(context, gameEntity.id, gameEntity.name, entrance)
|
||||
}
|
||||
|
||||
// 处理畅玩状态
|
||||
private fun handleSmoothStatus(
|
||||
context: Context,
|
||||
gameEntity: GameEntity,
|
||||
apk: ApkEntity,
|
||||
entrance: String,
|
||||
location: String,
|
||||
traceEvent: ExposureEvent
|
||||
) {
|
||||
VHelper.validateVSpaceBeforeAction(context, gameEntity) {
|
||||
GamePermissionDialogFragment.show((context as AppCompatActivity), gameEntity, gameEntity.info) {
|
||||
CertificationDialog.showCertificationDialog(context, gameEntity) {
|
||||
DialogUtils.checkDownload(context, apk.size) { isSubscribe: Boolean ->
|
||||
download(context, gameEntity, apk, isSubscribe, entrance, location, traceEvent)
|
||||
val str = GameUtils.getDownloadBtnText(context, gameEntity, PluginLocation.only_game)
|
||||
if (str == context.getString(R.string.download) || str == context.getString(R.string.attempt)) {
|
||||
GamePermissionDialogFragment.show((context as AppCompatActivity), gameEntity, gameEntity.info) {
|
||||
CertificationDialog.showCertificationDialog(context, gameEntity) {
|
||||
DialogUtils.checkDownload(context, apk.size) { isSubscribe: Boolean ->
|
||||
download(context, gameEntity, apk, isSubscribe, entrance, location, traceEvent)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理插件化状态
|
||||
private fun handlePluginStatus(
|
||||
context: Context,
|
||||
gameEntity: GameEntity,
|
||||
apk: ApkEntity,
|
||||
entrance: String,
|
||||
location: String,
|
||||
traceEvent: ExposureEvent
|
||||
) {
|
||||
if (gameEntity.pluggableCollection != null) {
|
||||
DownloadDialog.showDownloadDialog(context, gameEntity, traceEvent, entrance, location)
|
||||
} else {
|
||||
CertificationDialog.showCertificationDialog(context, gameEntity) {
|
||||
DataLogUtils.uploadGameLog(context, gameEntity.id, gameEntity.name, entrance)
|
||||
} else if (str == context.getString(R.string.smooth)) {
|
||||
VHelper.validateVSpaceBeforeAction(context, gameEntity, true) {
|
||||
GamePermissionDialogFragment.show((context as AppCompatActivity), gameEntity, gameEntity.info) {
|
||||
CertificationDialog.showCertificationDialog(context, gameEntity) {
|
||||
DialogUtils.checkDownload(context, apk.size) { isSubscribe: Boolean ->
|
||||
download(context, gameEntity, apk, isSubscribe, entrance, location, traceEvent)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (str.contains("化")) {
|
||||
if (gameEntity.pluggableCollection != null) {
|
||||
DownloadDialog.showDownloadDialog(context, gameEntity, traceEvent, entrance, location)
|
||||
} else {
|
||||
CertificationDialog.showCertificationDialog(context, gameEntity) {
|
||||
DialogUtils.checkDownload(context, apk.size) { isSubscribe: Boolean ->
|
||||
plugin(context, gameEntity, apk, entrance, location, isSubscribe, traceEvent)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (str == context.getString(R.string.install) || str == context.getString(R.string.launch)) {
|
||||
ToastUtils.toast("${gameEntity.name}已加入下载队列")
|
||||
} else if (str == context.getString(R.string.update)) {
|
||||
DialogUtils.checkDownload(context, apk.size) { isSubscribe: Boolean ->
|
||||
plugin(context, gameEntity, apk, entrance, location, isSubscribe, traceEvent)
|
||||
update(context, gameEntity, apk, entrance, location, isSubscribe, traceEvent)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理安装状态
|
||||
private fun handleInstallStatus(
|
||||
context: Context,
|
||||
gameEntity: GameEntity,
|
||||
apk: ApkEntity,
|
||||
downloadEntity: DownloadEntity?
|
||||
) {
|
||||
val simulatorDownloadEntity = SimulatorGameManager.findDownloadEntityByUrl(apk.url)
|
||||
if (gameEntity.simulator != null) {
|
||||
val isInstalled =
|
||||
PackageUtils.isInstalledFromAllPackage(context, gameEntity.simulator!!.apk!!.packageName)
|
||||
val isInstalledNewSimulator = SimulatorGameManager.isNewSimulatorInstalled(context)
|
||||
val isInstalledOldSimulator = SimulatorGameManager.isOldSimulatorInstalled(context)
|
||||
var simulator = gameEntity.simulator
|
||||
val newSimulator = Config.getNewSimulatorEntitySetting()
|
||||
// 在没有安装旧的模拟器且有配置新版模拟器 才使用新版模拟器 否则还是用以前旧的
|
||||
if (!isInstalledOldSimulator && newSimulator != null && newSimulator.active) {
|
||||
simulator = newSimulator
|
||||
}
|
||||
if (simulatorDownloadEntity != null && SimulatorGameManager.isSimulatorGame(gameEntity) && !isInstalled && !isInstalledNewSimulator) {
|
||||
SimulatorDownloadManager.getInstance().showDownloadDialog(
|
||||
context, simulator,
|
||||
SimulatorDownloadManager.SimulatorLocation.LAUNCH, gameEntity.id, gameEntity.name!!, null
|
||||
)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (gameEntity.isVGame()) {
|
||||
VHelper.installOrLaunch((context as AppCompatActivity), gameEntity.getUniquePackageName() ?: "")
|
||||
} else {
|
||||
downloadEntity?.run {
|
||||
install(context, gameEntity, apk, this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理启动状态
|
||||
private fun handleLaunchStatus(
|
||||
context: Context,
|
||||
gameEntity: GameEntity,
|
||||
apk: ApkEntity,
|
||||
entrance: String,
|
||||
location: String,
|
||||
traceEvent: ExposureEvent
|
||||
) {
|
||||
EnergyBridge.postEnergyTask("play_game", gameEntity.id, gameEntity.getApk()[0].packageName)
|
||||
//启动模拟器游戏
|
||||
if (SimulatorGameManager.isSimulatorGame(gameEntity)) {
|
||||
if (NewSimulatorGameManager.shouldShowUpdateNewSimulatorAlert(context)) {
|
||||
NewSimulatorGameManager.showUpdateNewsSimulator(context, null)
|
||||
return
|
||||
}
|
||||
val simulatorDownloadEntity =
|
||||
SimulatorGameManager.findDownloadEntityByUrl(gameEntity.getApk()[0].url)
|
||||
if (simulatorDownloadEntity != null) {
|
||||
val file = File(simulatorDownloadEntity.path)
|
||||
if (!file.exists()) {
|
||||
download(context, gameEntity, apk, false, entrance, location, traceEvent)
|
||||
return
|
||||
}
|
||||
NewFlatLogUtils.logSimulatorGameCardClick("启动")
|
||||
SimulatorGameManager.launchSimulatorGame(simulatorDownloadEntity, gameEntity)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (gameEntity.isVGame()) {
|
||||
VHelper.installOrLaunch((context as AppCompatActivity), gameEntity.getUniquePackageName() ?: "")
|
||||
return
|
||||
}
|
||||
|
||||
if (entrance.contains("我的游戏")) {
|
||||
MtaHelper.onEvent("我的游戏_启动", "启动", gameEntity.name)
|
||||
}
|
||||
PackageUtils.launchApplicationByPackageName(context, gameEntity.getApk()[0].packageName)
|
||||
}
|
||||
|
||||
// 处理更新状态
|
||||
private fun handleUpdateStatus(
|
||||
context: Context,
|
||||
gameEntity: GameEntity,
|
||||
apk: ApkEntity,
|
||||
entrance: String,
|
||||
location: String,
|
||||
traceEvent: ExposureEvent
|
||||
) {
|
||||
DialogUtils.checkDownload(context, apk.size) { isSubscribe: Boolean ->
|
||||
update(context, gameEntity, apk, entrance, location, isSubscribe, traceEvent)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getApk(
|
||||
gameEntity: GameEntity,
|
||||
event: DefaultJsApi.GameActivityEvent,
|
||||
@ -445,29 +294,6 @@ object GameActivityDownloadHelper {
|
||||
}
|
||||
}
|
||||
|
||||
// 安装
|
||||
private fun install(
|
||||
context: Context,
|
||||
gameEntity: GameEntity,
|
||||
apkEntity: ApkEntity,
|
||||
downloadEntity: DownloadEntity
|
||||
) {
|
||||
val path = downloadEntity.path
|
||||
when {
|
||||
FileUtils.isEmptyFile(path) -> {
|
||||
Utils.toast(context, R.string.install_failure_hint)
|
||||
DownloadManager.getInstance().cancel(downloadEntity.url)
|
||||
gameEntity.getEntryMap().remove(apkEntity.getPlatform())
|
||||
}
|
||||
PackageUtils.isCanPluggable(apkEntity) -> {
|
||||
DialogHelper.showPluginDialog(context) { PackageInstaller.uninstall(context, path) }
|
||||
}
|
||||
else -> {
|
||||
PackageInstaller.install(context, downloadEntity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 更新
|
||||
private fun update(
|
||||
context: Context,
|
||||
|
||||
@ -0,0 +1,254 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.app.Application
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.ProgressBar
|
||||
import com.gh.gamecenter.common.base.activity.ToolBarActivity
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.common.retrofit.BiResponse
|
||||
import com.gh.gamecenter.common.utils.singleToMain
|
||||
import com.gh.gamecenter.common.utils.tryWithDefaultCatch
|
||||
import com.gh.gamecenter.core.GHThreadFactory
|
||||
import com.gh.gamecenter.core.runOnUiThread
|
||||
import com.gh.gamecenter.core.utils.CurrentActivityHolder
|
||||
import com.gh.gamecenter.gamecollection.detail.GameCollectionDetailActivity
|
||||
import com.gh.gamecenter.gamecollection.square.GameCollectionSquareActivity
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lzf.easyfloat.EasyFloat
|
||||
import com.lzf.easyfloat.enums.ShowPattern
|
||||
import com.lzf.easyfloat.enums.SidePattern
|
||||
import okhttp3.ResponseBody
|
||||
import java.util.concurrent.ExecutorService
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
/**
|
||||
* 浏览游戏单广场任务辅助类
|
||||
*/
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
object GameCollectionSquareBrowseTaskHelper {
|
||||
|
||||
const val KEY_IS_FORM_BROWSE_TASK = "is_from_browse_task"
|
||||
private const val FLOATING_SQUARE_BROWSE_TASK_VIEW = "floating_square_browse_task_view"
|
||||
|
||||
private var mBrowseTimeCount = 0
|
||||
private var mIsBrowseTimeCountEnabled = false // 游戏单广场浏览时间统计是否开启
|
||||
private var mBrowseTimeTimeout = 15
|
||||
private var mIsBrowseTimeCountValid = false // 游戏单广场浏览时间统计是否有效
|
||||
private var mBrowsePro: ProgressBar? = null
|
||||
private var mIsFinished = false
|
||||
private var mNeedShowFloatView = false
|
||||
private var mIsFirstEnterSquare = true
|
||||
|
||||
private val mThreadService: ExecutorService by lazy {
|
||||
Executors.newSingleThreadExecutor(GHThreadFactory("BROWSE_SQUARE_THREAD"))
|
||||
}
|
||||
|
||||
private val mActivityLifecycleCallbacks by lazy {
|
||||
object : Application.ActivityLifecycleCallbacks {
|
||||
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {}
|
||||
override fun onActivityStopped(activity: Activity) {}
|
||||
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {}
|
||||
override fun onActivityStarted(activity: Activity) {}
|
||||
|
||||
override fun onActivityResumed(activity: Activity) {
|
||||
if (isTopActivityGameCollectionRelated(activity) && mIsBrowseTimeCountEnabled) {
|
||||
resumeTimeCount()
|
||||
} else if (isGameCollectionSquare(activity) && mNeedShowFloatView) {
|
||||
showOrUpdateFloatView(activity, mBrowseTimeTimeout)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityPaused(activity: Activity) {
|
||||
if (isTopActivityGameCollectionRelated(activity) && mIsBrowseTimeCountEnabled) {
|
||||
pauseTimeCount()
|
||||
}
|
||||
if (isGameCollectionSquare(activity)) {
|
||||
dismissFloatView()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityDestroyed(activity: Activity) {
|
||||
if (isGameCollectionSquare(activity) && mIsBrowseTimeCountEnabled) {
|
||||
disableBrowseTimeCount()
|
||||
unregisterActivityLifecycleCallbacks()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun enableBrowseTimeCount(timeout: Int, isFinished: Boolean) {
|
||||
mIsBrowseTimeCountEnabled = true
|
||||
mBrowseTimeTimeout = timeout
|
||||
mIsFinished = isFinished
|
||||
mNeedShowFloatView = true
|
||||
mIsFirstEnterSquare = true
|
||||
|
||||
resumeTimeCount()
|
||||
|
||||
HaloApp.getInstance().registerActivityLifecycleCallbacks(mActivityLifecycleCallbacks)
|
||||
}
|
||||
|
||||
fun disableBrowseTimeCount() {
|
||||
mBrowseTimeCount = 0
|
||||
mIsBrowseTimeCountEnabled = false
|
||||
mBrowsePro = null
|
||||
mIsFinished = false
|
||||
mIsFirstEnterSquare = true
|
||||
}
|
||||
|
||||
fun unregisterActivityLifecycleCallbacks() {
|
||||
mNeedShowFloatView = false
|
||||
HaloApp.getInstance().unregisterActivityLifecycleCallbacks(mActivityLifecycleCallbacks)
|
||||
}
|
||||
|
||||
private fun resumeTimeCount() {
|
||||
if (!mIsBrowseTimeCountEnabled) return
|
||||
|
||||
mIsBrowseTimeCountValid = true
|
||||
|
||||
mThreadService.execute {
|
||||
while (mIsBrowseTimeCountEnabled && mIsBrowseTimeCountValid) {
|
||||
val topActivity = CurrentActivityHolder.getCurrentActivity() ?: continue
|
||||
checkFirstEnterSquare(topActivity)
|
||||
runBrowseTask(topActivity)
|
||||
Thread.sleep(1000)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkFirstEnterSquare(topActivity: Activity) {
|
||||
if (isGameCollectionSquare(topActivity, false) && mIsFirstEnterSquare) {
|
||||
mIsFirstEnterSquare = false
|
||||
topActivity.intent.putExtra(KEY_IS_FORM_BROWSE_TASK, true)
|
||||
}
|
||||
}
|
||||
|
||||
private fun runBrowseTask(topActivity: Activity) {
|
||||
if (isTopActivityGameCollectionRelated(topActivity)) {
|
||||
tryWithDefaultCatch {
|
||||
showOrUpdateFloatView(topActivity, if (mIsFinished) mBrowseTimeTimeout else mBrowseTimeCount)
|
||||
if (mIsFinished) {
|
||||
disableBrowseTimeCount()
|
||||
} else {
|
||||
countBrowseTimeout(topActivity)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun countBrowseTimeout(topActivity: Activity) {
|
||||
mBrowseTimeCount++
|
||||
if (mBrowseTimeCount >= mBrowseTimeTimeout) {
|
||||
showOrUpdateFloatView(topActivity, mBrowseTimeTimeout)
|
||||
postBrowseFinish()
|
||||
}
|
||||
}
|
||||
|
||||
private fun pauseTimeCount() {
|
||||
if (!mIsBrowseTimeCountEnabled) return
|
||||
|
||||
mIsBrowseTimeCountValid = false
|
||||
}
|
||||
|
||||
// 从任务跳转的游戏单广场/此游戏单广场进入的游戏单详情都计时
|
||||
private fun isTopActivityGameCollectionRelated(activity: Activity): Boolean {
|
||||
return isGameCollectionSquare(activity)
|
||||
|| (activity is GameCollectionDetailActivity
|
||||
&& activity.intent.getBundleExtra(ToolBarActivity.NORMAL_FRAGMENT_BUNDLE)
|
||||
?.getBoolean(KEY_IS_FORM_BROWSE_TASK) == true)
|
||||
}
|
||||
|
||||
private fun isGameCollectionSquare(activity: Activity, checkIsFromTask: Boolean = true): Boolean {
|
||||
return activity is GameCollectionSquareActivity
|
||||
&& (!checkIsFromTask || activity.intent.getBooleanExtra(KEY_IS_FORM_BROWSE_TASK, false))
|
||||
}
|
||||
|
||||
private fun showOrUpdateFloatView(activity: Activity, time: Int) {
|
||||
// 不支持 Android 4.1 的设备
|
||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN) return
|
||||
|
||||
// 游戏单广场才显示FloatView
|
||||
if (!isGameCollectionSquare(activity)) return
|
||||
|
||||
runOnUiThread {
|
||||
val isFinished = time == mBrowseTimeTimeout
|
||||
val floatView = EasyFloat.getFloatView(FLOATING_SQUARE_BROWSE_TASK_VIEW)
|
||||
if (floatView != null) {
|
||||
updateFloatView(floatView, isFinished, time)
|
||||
} else {
|
||||
showFloatView(activity, isFinished)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showFloatView(activity: Activity, isFinished: Boolean) {
|
||||
EasyFloat.with(activity)
|
||||
.setLayout(R.layout.layout_square_browse_task_float)
|
||||
.setTag(FLOATING_SQUARE_BROWSE_TASK_VIEW)
|
||||
.setAnimator(null)
|
||||
.setGravity(Gravity.END.or(Gravity.CENTER_VERTICAL), 0, 0)
|
||||
.setSidePattern(SidePattern.RIGHT)
|
||||
.setShowPattern(ShowPattern.CURRENT_ACTIVITY)
|
||||
.setDragEnable(false)
|
||||
.registerCallback {
|
||||
createResult { _, _, view ->
|
||||
initFloatView(view, isFinished)
|
||||
}
|
||||
}
|
||||
.show()
|
||||
}
|
||||
|
||||
private fun initFloatView(view: View?, isFinished: Boolean) {
|
||||
if (isFinished) {
|
||||
view?.findViewById<ProgressBar>(R.id.browsePro)?.run {
|
||||
max = mBrowseTimeTimeout
|
||||
progress = mBrowseTimeTimeout
|
||||
}
|
||||
view?.findViewById<ImageView>(R.id.browsePic)
|
||||
?.setImageResource(R.drawable.pic_browse_square_finish)
|
||||
} else {
|
||||
view?.findViewById<ProgressBar>(R.id.browsePro)?.run {
|
||||
mBrowsePro = this
|
||||
max = mBrowseTimeTimeout
|
||||
progress = 0
|
||||
}
|
||||
view?.findViewById<ImageView>(R.id.browsePic)
|
||||
?.setImageResource(R.drawable.pic_browse_square)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateFloatView(floatView: View, isFinished: Boolean, time: Int) {
|
||||
if (mBrowsePro == null) {
|
||||
mBrowsePro = floatView.findViewById(R.id.browsePro)
|
||||
}
|
||||
mBrowsePro?.progress = time
|
||||
if (isFinished) {
|
||||
floatView.findViewById<ImageView>(R.id.browsePic)
|
||||
.setImageResource(R.drawable.pic_browse_square_finish)
|
||||
}
|
||||
}
|
||||
|
||||
private fun dismissFloatView() {
|
||||
EasyFloat.dismiss(FLOATING_SQUARE_BROWSE_TASK_VIEW)
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private fun postBrowseFinish() {
|
||||
RetrofitManager.getInstance()
|
||||
.newApi
|
||||
.postGameCollectionTask("browse_game_list_square", "0")
|
||||
.compose(singleToMain())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
disableBrowseTimeCount()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user