Compare commits

..

88 Commits

Author SHA1 Message Date
681e2cd4ee build: 添加 3.7.0 版本的 sentry plugin 缓存
Signed-off-by: chenjuntao <chenjuntao@ghzhushou.com>
2024-10-24 10:15:39 +08:00
883dad8f06 build: 添加 3.7.0 版本的 sentry plugin 缓存
Signed-off-by: chenjuntao <chenjuntao@ghzhushou.com>
2024-10-23 15:51:23 +08:00
0d650d2d00 build: 添加 3.7.0 版本的 sentry plugin 缓存
Signed-off-by: chenjuntao <chenjuntao@ghzhushou.com>
2024-10-23 15:50:47 +08:00
8f8ac99dae chore: 版本更新至 5.38.2
Signed-off-by: chenjuntao <chenjuntao@ghzhushou.com>
2024-10-23 12:37:29 +08:00
0be7db94ad Merge branch 'hotfix/v5.38.1-1111/crashes' into 'release'
修复 5.38.1 的部分闪退问题

See merge request halo/android/assistant-android!1947
2024-10-23 11:52:09 +08:00
ae80359b48 Merge branch 'fix/catch_view_lifecycle_owner_crash' into 'release'
fix: 捕获加载图片时获取ViewLifecycleOwner出现的闪退问题

See merge request halo/android/assistant-android!1946
2024-10-23 11:47:53 +08:00
81281855a1 fix: 修复继续下载 VA 插件异常时的闪退问题(遇到异常尝试重下) https://sentry.shanqu.cc/organizations/lightgame/issues/416793
Signed-off-by: chenjuntao <chenjuntao@ghzhushou.com>
2024-10-23 11:28:58 +08:00
a5174c6931 fix: 捕获加载图片时获取ViewLifecycleOwner出现的闪退问题 2024-10-23 11:16:36 +08:00
a3cc74afb3 fix: 修复部分位置在处理图片选择回调时处理不合理造成的闪退问题 https://sentry.shanqu.cc/organizations/lightgame/issues/416811
Signed-off-by: chenjuntao <chenjuntao@ghzhushou.com>
2024-10-23 10:13:39 +08:00
84e78de6fc fix: 当 PackageName 为空时的闪退问题 https://sentry.shanqu.cc/organizations/lightgame/issues/416770
Signed-off-by: chenjuntao <chenjuntao@ghzhushou.com>
2024-10-23 09:54:50 +08:00
9bf4c73250 chore: 版本更新至 5.38.1
Signed-off-by: chenjuntao <chenjuntao@ghzhushou.com>
2024-10-22 15:13:34 +08:00
57a222b87a Merge branch 'hotfix/v5.38.0-1110/get_install_list_anr' into 'release'
fix: 修复错误使用全量已安装应用列表进行应用是否已安装判断依据的问题

See merge request halo/android/assistant-android!1945
2024-10-22 10:42:53 +08:00
3e125b90a2 fix: 修复错误使用全量已安装应用列表进行应用是否已安装判断依据的问题
Signed-off-by: chenjuntao <chenjuntao@ghzhushou.com>
2024-10-22 10:32:33 +08:00
1809265d4f Merge branch 'fix/sentry-415534' into 'release'
fixed: Sentry415534 VA启动游戏弹窗报“Can not perform this action after onSaveInstanceState”的异常问题

See merge request halo/android/assistant-android!1944
2024-10-22 10:10:36 +08:00
3b3774596d fixed: Sentry415534 VA启动游戏弹窗报“Can not perform this action after onSaveInstanceState”的异常问题 2024-10-22 09:58:40 +08:00
bded49c366 Merge branch 'hotfix/v5.38.0-1110/remove_duplicated_sentry_log' into 'release'
fix: 移除部分 Sentry 日志上报,避免数据量过大

See merge request halo/android/assistant-android!1943
2024-10-21 18:04:47 +08:00
841711b5f1 fix: 移除部分 Sentry 日志上报,避免数据量过大
Signed-off-by: chenjuntao <chenjuntao@ghzhushou.com>
2024-10-21 18:02:17 +08:00
7a080115a7 Merge branch 'hotfix/v5.38.0-1110/remove_duplicated_sentry_log' into 'release'
fix: 移除 AndroidException 类型的 Sentry 日志上报,避免数据量过大

See merge request halo/android/assistant-android!1942
2024-10-21 17:31:24 +08:00
337c4724a7 fix: 移除 AndroidException 类型的 Sentry 日志上报,避免数据量过大
Signed-off-by: chenjuntao <chenjuntao@ghzhushou.com>
2024-10-21 17:28:44 +08:00
2119691bf6 Merge branch 'fix/GHZSCY-6799' into 'release'
fix: 【光环助手】V5.38版本群测汇总(1) https://jira.shanqu.cc/browse/GHZSCY-6799

See merge request halo/android/assistant-android!1941
2024-10-18 16:12:03 +08:00
caf50055c9 fix: 【光环助手】V5.38版本群测汇总(1) https://jira.shanqu.cc/browse/GHZSCY-6799 2024-10-18 16:11:13 +08:00
3ee3c2453f Merge branch 'fix/GHZSCY-6799' into 'release'
fix: 【光环助手】V5.38版本群测汇总(3) https://jira.shanqu.cc/browse/GHZSCY-6799

See merge request halo/android/assistant-android!1940
2024-10-18 15:27:05 +08:00
5e431e8a61 fix: 【光环助手】V5.38版本群测汇总(3) https://jira.shanqu.cc/browse/GHZSCY-6799 2024-10-18 15:14:18 +08:00
ff72c7cac8 Merge branch 'fix/navigation_bar_view_issue' into 'release'
fix: 修复 navigationBarView 的高度占位问题 https://jira.shanqu.cc/browse/GHZSCY-6799

See merge request halo/android/assistant-android!1939
2024-10-18 14:54:48 +08:00
047325e9bc fix: 修复 navigationBarView 的高度占位问题
Signed-off-by: chenjuntao <chenjuntao@ghzhushou.com>
2024-10-18 11:27:31 +08:00
afbb758740 Merge branch 'refactor/sync-va' into 'dev'
feat: 更新插件1.0.3 正式版本 url

See merge request halo/android/assistant-android!1938
2024-10-17 15:43:21 +08:00
5de629cfdd feat: 更新插件1.0.3 正式版本 url 2024-10-17 15:42:59 +08:00
f026623600 Merge branch 'refactor/sync-va' into 'dev'
chore: va组件升级到2.0.6

See merge request halo/android/assistant-android!1937
2024-10-17 11:24:35 +08:00
2f5ee0eb91 chore: va组件升级到2.0.6
refactor: update commit id
2024-10-17 11:24:12 +08:00
e7651e8092 Merge branch 'feat/GHZSCY-6708-patch' into 'dev'
feat: CPM微信小游戏API接入兼容OkHttp 4.x

See merge request halo/android/assistant-android!1936
2024-10-17 11:23:47 +08:00
82d51d6375 feat: CPM微信小游戏API接入兼容OkHttp 4.x 2024-10-17 11:23:24 +08:00
6080edfd8a Merge branch 'feat/GHZSCY-6708' into 'dev'
feat: CPM微信小游戏API接入工作—客户端 https://jira.shanqu.cc/browse/GHZSCY-6708

See merge request halo/android/assistant-android!1911
2024-10-17 10:17:19 +08:00
d9713571c9 feat: CPM微信小游戏API接入工作—客户端 https://jira.shanqu.cc/browse/GHZSCY-6708 2024-10-17 10:17:19 +08:00
b466525e8b Merge branch 'feat/GHZSCY-6790' into 'dev'
feat: 更新 OkHttp 至 4.X 最新版本并启用 brotli 压缩 https://jira.shanqu.cc/browse/GHZSCY-6790

See merge request halo/android/assistant-android!1935
2024-10-16 16:56:07 +08:00
2a25675dce feat: 更新 OkHttp 至 4.X 最新版本并启用 brotli 压缩 https://jira.shanqu.cc/browse/GHZSCY-6790 2024-10-16 16:56:06 +08:00
5486ad8818 Merge branch 'fix/home_appbar_style' into 'dev'
fix: 修复多tab导航页在无Tab样式下AppBar变色异常的问题

See merge request halo/android/assistant-android!1934
2024-10-16 13:47:17 +08:00
5552fcf7bc Merge branch 'fix/stop_banner_play_on_pause' into 'dev'
fix: 修复部分轮播图没有在页面暂停时停止播放的问题

See merge request halo/android/assistant-android!1933
2024-10-16 13:47:10 +08:00
782a0af13c fix: 修复多tab导航页在无Tab样式下AppBar变色异常的问题 2024-10-16 11:44:44 +08:00
c6c2d9cd12 fix: 修复部分轮播图没有在页面暂停时停止播放的问题 2024-10-16 10:09:51 +08:00
f929a08e46 Merge branch 'fix/GHZSCY-6685' into 'dev'
fix: 修复 Fresco 不能根据 ViewPager/ViewPager2 页面可见性变更动图播放状态的问题 https://jira.shanqu.cc/browse/GHZSCY-6685

See merge request halo/android/assistant-android!1930
2024-10-15 18:16:41 +08:00
e48f96d7d7 fix: 修复 Fresco 不能根据 ViewPager/ViewPager2 页面可见性变更动图播放状态的问题 https://jira.shanqu.cc/browse/GHZSCY-6685 2024-10-15 18:16:41 +08:00
3cc95dbc08 Merge branch 'fix/system-properties-sensitive' into 'dev'
fix: 修复xcrash敏感行为【读取系统属性】

See merge request halo/android/assistant-android!1929
2024-10-15 15:08:29 +08:00
f75396d7ae fix: 修复xcrash敏感行为【读取系统属性】 2024-10-15 15:07:57 +08:00
72c3df7fa6 Merge branch 'fix/GHZSCY-6773' into 'dev'
fix:【光环助手】游戏专题-右上角显示问题 https://jira.shanqu.cc/browse/GHZSCY-6773

See merge request halo/android/assistant-android!1928
2024-10-15 09:35:38 +08:00
2d4920cfb0 fix:【光环助手】游戏专题-右上角显示问题 https://jira.shanqu.cc/browse/GHZSCY-6773 2024-10-15 09:31:13 +08:00
2d30b97cca Merge branch 'fix/hiddenapibypass-bug' into 'dev'
fix: 更新hiddenapibypass库,观察native crash的hiddenapi相关问题是否解决。

See merge request halo/android/assistant-android!1927
2024-10-14 17:09:30 +08:00
40346e3c9a fix: 更新hiddenapibypass库,观察native crash的hiddenapi相关问题是否解决。 2024-10-14 17:08:20 +08:00
7f601c856a Merge branch 'fix/illegal_state_exception' into 'dev'
fix: 尝试修复游戏专题合集详情页闪退问题 https://sentry.shanqu.cc/organizations/lightgame/issues/388936

See merge request halo/android/assistant-android!1924
2024-10-12 11:36:49 +08:00
6e56f2e3a0 fix: 尝试修复游戏专题合集详情页闪退问题 https://sentry.shanqu.cc/organizations/lightgame/issues/388936 2024-10-12 10:40:26 +08:00
e2fbda1e4c Merge branch 'fix/GHZSCY-6778' into 'dev'
fix: 分类页面展示异常 https://jira.shanqu.cc/browse/GHZSCY-6778

See merge request halo/android/assistant-android!1921
2024-10-11 16:45:57 +08:00
1e88ba8539 fix: 分类页面展示异常 https://jira.shanqu.cc/browse/GHZSCY-6778 2024-10-11 15:40:03 +08:00
0f43b5610d Merge branch 'feat/GHZSCY-6474' into 'dev'
feat: 【光环助手】搜索榜单的神策埋点问题 https://jira.shanqu.cc/browse/GHZSCY-6747

See merge request halo/android/assistant-android!1920
2024-10-11 15:10:51 +08:00
04dcfbab2e feat: 【光环助手】搜索榜单的神策埋点问题 https://jira.shanqu.cc/browse/GHZSCY-6747 2024-10-11 15:10:51 +08:00
8dd33cb599 Merge branch 'fix/GHZSCY-6777' into 'dev'
fix: 【光环助手】进入QA详情页埋点上报问题 https://jira.shanqu.cc/browse/GHZSCY-6777

See merge request halo/android/assistant-android!1917
2024-10-11 15:02:10 +08:00
af5826962b fix: 【光环助手】进入QA详情页埋点上报问题 https://jira.shanqu.cc/browse/GHZSCY-6777 2024-10-11 15:02:10 +08:00
9883f8d5c0 Merge branch 'fix/GHZSCY-6772' into 'dev'
fix: 分流器-验收问题-客户端 https://jira.shanqu.cc/browse/GHZSCY-6772

See merge request halo/android/assistant-android!1918
2024-10-11 15:01:59 +08:00
848207784e fix: 分流器-验收问题-客户端 https://jira.shanqu.cc/browse/GHZSCY-6772 2024-10-11 15:01:59 +08:00
fc294f9e7b Merge branch 'revert/GHZSCY-5572' into 'dev'
Revert: 搜索业务-新增搜索发现取代热门标签—客户端 https://jira.shanqu.cc/browse/GHZSCY-5572

See merge request halo/android/assistant-android!1916
2024-10-09 17:00:42 +08:00
96cd53a2c9 Revert: 搜索业务-新增搜索发现取代热门标签—客户端 https://jira.shanqu.cc/browse/GHZSCY-5572 2024-10-09 17:00:42 +08:00
5458c93475 fix: 处理合并冲突
Signed-off-by: chenjuntao <chenjuntao@ghzhushou.com>
2024-10-09 15:53:40 +08:00
675d63c1d6 Merge remote-tracking branch 'origin/release' into dev
# Conflicts:
#	.gitlab-ci.yml
#	app/src/main/java/com/gh/gamecenter/download/DownloadFragment.kt
#	dependencies.gradle
#	vasdk
2024-10-09 15:34:08 +08:00
1040f5ff4d Merge branch 'sentry/407275' into 'release'
fix: Sentry 407275 修复Z10机型报BadTokenException的异常

See merge request halo/android/assistant-android!1915
2024-10-09 14:56:18 +08:00
97be320529 fix: Sentry 407275 修复Z10机型报BadTokenException的异常 2024-10-09 14:56:18 +08:00
0e086c9452 Merge branch 'fix/va-some-npe' into 'dev'
fix: 修复sentry捕获异常。

See merge request halo/android/assistant-android!1914
2024-10-09 14:13:09 +08:00
dc677d1b9f fix: 修复sentry捕获异常。
1.https://sentry.shanqu.cc/organizations/lightgame/issues/396947/?project=22
2.https://sentry.shanqu.cc/organizations/lightgame/issues/398572/events/0d99a320eee243efa7089b59cb10219c/?project=22
3.https://sentry.shanqu.cc/organizations/lightgame/issues/382462/events/30a62c7d5e0a40df80f36ff25b325728/?project=22
4.https://sentry.shanqu.cc/organizations/lightgame/issues/407819/?project=22
5.https://sentry.shanqu.cc/organizations/lightgame/issues/397248/?project=22
2024-10-09 14:10:54 +08:00
fa50c6e417 Merge branch 'fix/crashes' into 'dev'
修复Sentry闪退问题

See merge request halo/android/assistant-android!1913
2024-10-09 14:04:48 +08:00
dc96f2274f fix: 修复启动时QQ小游戏获取WebView的默认UserAgent导致的闪退问题 https://sentry.shanqu.cc/organizations/lightgame/issues/352547/?project=22 2024-10-09 11:32:36 +08:00
ad5f5048a6 Merge branch 'fix/auto-login-crash' into 'dev'
fix:自动登录页面闪退

See merge request halo/android/assistant-android!1912
2024-10-09 11:20:24 +08:00
e5491fb297 fix:自动登录页面闪退 2024-10-09 11:20:24 +08:00
ff96eaafee fix: 修复获取统计数据时出现的空指针闪退问题 https://sentry.shanqu.cc/organizations/lightgame/issues/387745/?project=22 2024-10-08 17:33:43 +08:00
da0ace0aa6 Merge branch 'fix/get_packagename_culprit' into 'dev'
fix: 修复多线程同时请求已安装包名列表的问题

See merge request halo/android/assistant-android!1909
2024-09-27 14:14:41 +08:00
11a2d7aa53 fix: 修复因为获取已安装包名延迟造成的下载按钮状态更新问题
Signed-off-by: chenjuntao <chenjuntao@ghzhushou.com>
2024-09-27 10:04:09 +08:00
d3444918dd fix: 修复多线程同时请求已安装包名列表的问题
Signed-off-by: chenjuntao <chenjuntao@ghzhushou.com>
2024-09-27 10:04:09 +08:00
59cde4e2bf Merge branch 'hotfix/v5.37.5-1095/privacy-policy' into 'release'
feat: 优化获取进程名的方式 https://jira.shanqu.cc/browse/GHZSCY-6690

See merge request halo/android/assistant-android!1898
2024-09-20 10:56:40 +08:00
cc0c7c7fae feat: 优化获取进程名的方式 https://jira.shanqu.cc/browse/GHZSCY-6690 2024-09-20 10:32:29 +08:00
9e9ce6a84f Merge branch 'hotfix/v5.37.5-1095/download_ad_crash' into 'release'
fix: 修复下载管理展示第三方广告失败回落展示自有广告时出现的闪退问题...

See merge request halo/android/assistant-android!1895
2024-09-14 17:23:26 +08:00
7d0b500ff9 fix: 修复下载管理展示第三方广告失败回落展示自有广告时出现的闪退问题 https://sentry.shanqu.cc/organizations/lightgame/issues/409586/?project=22 2024-09-14 17:13:23 +08:00
425456b263 Merge branch 'feat/v5.37.5-1095/va-2.0.5' into 'release'
Feat/v5.37.5 1095/va 2.0.5

See merge request halo/android/assistant-android!1890
2024-09-11 17:08:07 +08:00
f6abab9a2d Revert "chore: 组件升级 2.0.5-debug" 2024-09-11 17:05:56 +08:00
d194f969e4 chore: va组件2.0.5-debug 2024-09-10 16:43:57 +08:00
95f66344fb chore: va组件2.0.5 2024-09-10 13:46:15 +08:00
570e2fa9bc Revert "feat:同步商业版代码至:dbc3b8ecaca3e774b1e63f41e70b651f4acfaee1"
This reverts commit 811d42457c.
2024-09-05 15:22:32 +08:00
9e07080043 feat: 调整依赖源顺序 2024-09-04 17:03:37 +08:00
e10a329159 chore: 版本更新至 5.37.5 2024-09-04 16:00:00 +08:00
b3bc7b43f7 Merge branch 'feat/v5.37.5-1095/update-va' into 'release'
feat:同步商业版代码至:dbc3b8ecaca3e774b1e63f41e70b651f4acfaee1

See merge request halo/android/assistant-android!1875
2024-09-04 15:54:34 +08:00
811d42457c feat:同步商业版代码至:dbc3b8ecaca3e774b1e63f41e70b651f4acfaee1 2024-09-04 15:52:46 +08:00
ac0b819ea9 Merge branch 'feat/GHZSCY-6644' into 'release'
feat: 【光环助手】安装相关优化功能埋点事件的属性字段英文错误的问题 https://jira.shanqu.cc/browse/GHZSCY-6644

See merge request halo/android/assistant-android!1874
2024-09-04 15:43:47 +08:00
d931fb5940 feat: 【光环助手】安装相关优化功能埋点事件的属性字段英文错误的问题 https://jira.shanqu.cc/browse/GHZSCY-6644 2024-09-04 14:42:17 +08:00
212 changed files with 2335 additions and 1333 deletions

View File

@ -72,6 +72,7 @@ android_build:
only:
- dev
- release
- pack/update_sentry_plugin_cache
# 代码检查
sonarqube_analysis:
@ -157,3 +158,4 @@ oss-upload&send-email:
only:
- dev
- release
- pack/update_sentry_plugin_cache

View File

@ -2,7 +2,6 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android' // kotlin
apply plugin: 'kotlin-parcelize'
apply plugin: 'com.google.devtools.ksp'
apply plugin: 'kotlin-kapt'
import groovy.xml.XmlUtil
@ -102,6 +101,8 @@ android {
buildConfigField "String", "NEW_API_HOST", "\"${NEW_API_HOST}\""
buildConfigField "String", "LOG_HUB_PROJECT", "\"${LOG_HUB_PROJECT}\""
buildConfigField "String", "VAPI_HOST", "\"${VAPI_HOST}\""
buildConfigField "String", "WGAME_CPM_BUSIAPPID", "\"${WGAME_CPM_BUSIAPPID}\""
buildConfigField "String", "WGAME_CPM_API_HOST", "\"${WGAME_CPM_API_HOST}\""
buildConfigField "String", "WECHAT_APPID", "\"${WECHAT_APPID}\""
buildConfigField "String", "WECHAT_SECRET", "\"${WECHAT_SECRET}\""
buildConfigField "String", "TENCENT_APPID", "\"${TENCENT_APPID}\""
@ -122,9 +123,10 @@ android {
}
}
ksp {
arg("AROUTER_MODULE_NAME", project.getName())
arg("AROUTER_GENERATE_DOC", "enable")
kapt {
arguments {
arg("AROUTER_MODULE_NAME", project.name)
}
}
packagingOptions {
@ -376,7 +378,7 @@ dependencies {
implementation "androidx.annotation:annotation:${annotation}"
implementation "androidx.viewpager2:viewpager2:${viewpager2}"
ksp("androidx.room:room-compiler:${room}")
kapt "androidx.room:room-compiler:${room}"
implementation "com.tencent.vasdolly:helper:${apkChannelPackage}"
implementation "com.tencent.vasdolly:writer:${apkChannelPackage}"
@ -426,8 +428,7 @@ dependencies {
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:${desugarJdkLibs}"
kapt "com.google.auto.service:auto-service:${autoServiceVersion}"
ksp("com.github.JailedBird:ArouterKspCompiler:${arouterKspCompilerVersion}")
kapt "com.alibaba:arouter-compiler:$arouterVersion"
implementation project(':ndownload')
implementation project(':vspace-bridge:vspace')

View File

@ -638,7 +638,7 @@
<!-- android:theme="@android:style/Theme.Translucent" />-->
<activity
android:name="com.gh.gamecenter.SkipCompatActivity"
android:name="com.gh.gamecenter.SkipActivity"
android:exported="true"
android:theme="@style/Theme.AppCompat.Light.Fullscreen.Transparent">
<intent-filter>

View File

@ -588,7 +588,7 @@ document.addEventListener("selectionchange", function(e) {
});
document.addEventListener("selectionchange", function(e) {
RE.enabledEditingItems(e)
setTimeout(() => RE.enabledEditingItems(e), 10)
});
RE.recursion = function(dom) {

View File

@ -256,7 +256,7 @@ class DefaultJsApi(
@JavascriptInterface
fun isInstalled(event: Any): String {
val localInstalledPackageList = PackageUtils.getAllPackageName(HaloApp.getInstance().application)
val localInstalledPackageList = PackageHelper.getInstalledPackageNameList(HaloApp.getInstance().application, 0)
val packageNameList: ArrayList<String> = event.toString().toObject() ?: ArrayList()
for (packageName in packageNameList) {
@ -555,7 +555,7 @@ class DefaultJsApi(
@JavascriptInterface
fun getInstallStatus(event: Any): String {
val localInstalledPackageList = PackageUtils.getAllPackageName(HaloApp.getInstance().application)
val localInstalledPackageList = PackageHelper.getInstalledPackageNameList(HaloApp.getInstance().application, 0)
val packageNameList: ArrayList<String> = event.toString().toObject() ?: ArrayList()
val installStatusMap: HashMap<String, Boolean> = hashMapOf()

View File

@ -15,7 +15,6 @@ import com.gh.common.util.DirectUtils.directToLegacyVideoDetail
import com.gh.common.util.DirectUtils.directToLinkPage
import com.gh.common.util.DirectUtils.directToQa
import com.gh.common.util.PackageUtils
import com.gh.gamecenter.SkipCompatActivity
import com.gh.gamecenter.WebActivity
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.constant.EntranceConsts
@ -67,10 +66,6 @@ object DefaultUrlHandler {
bringAppToFront: Boolean = false,
sourceEntrance: String = ""): Boolean {
val uri = Uri.parse(url)
// 优先交给新的路由拦截处理
if (SkipCompatActivity.handleSkip(context, uri)) return true
if ("ghzhushou" == uri.scheme) {
Utils.log("url = $url")
Utils.log("url = " + uri.scheme!!)
@ -379,7 +374,7 @@ object DefaultUrlHandler {
val iconSubscript = uri.getQueryParameter("game_icon_subscript") ?: ""
val gameEntity =
if (forumType == BbsType.OFFICIAL_BBS.value && gameId.isNotEmpty() && gameName.isNotEmpty() && icon.isNotEmpty()) {
GameEntity(id = gameId, mName = gameName, mIcon = icon, mIconSubscript = iconSubscript)
GameEntity(_id = gameId, mName = gameName, mIcon = icon, mIconSubscript = iconSubscript)
} else null
val activityLabelEntity = if (activityId.isNotEmpty() && activityName.isNotEmpty()) {
ActivityLabelEntity(

View File

@ -63,6 +63,9 @@ public class Config {
public static final String NEW_API_HOST = EnvHelper.getNewHost();
public static final String VAPI_HOST = EnvHelper.getVHost();
public static final String WGAME_CPM_BUSIAPPID = BuildConfig.WGAME_CPM_BUSIAPPID;
public static final String WGAME_CPM_API_HOST = EnvHelper.getWGameCPMHost();
// Third-Party confs
public static final String WECHAT_APPID = BuildConfig.WECHAT_APPID;
public static final String WECHAT_SECRET = BuildConfig.WECHAT_SECRET;

View File

@ -6,6 +6,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.LayoutManager
import androidx.recyclerview.widget.StaggeredGridLayoutManager
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.feature.exposure.ExposureEvent
import io.reactivex.functions.Consumer
@ -16,8 +17,9 @@ class ExposureListener(var fragment: Fragment, var exposable: IExposable) : Recy
val throttleBus: ExposureThrottleBus by lazy {
ExposureThrottleBus(
Consumer { commitExposure(it) },
Consumer(Throwable::printStackTrace)
{ commitExposure(it) },
Consumer(Throwable::printStackTrace),
{ commitWXCPMExposure(it) }
)
}
var layoutManager: LayoutManager? = null
@ -93,4 +95,32 @@ class ExposureListener(var fragment: Fragment, var exposable: IExposable) : Recy
ExposureManager.log(eventList)
}
/**
* 微信小游戏CPM曝光事件接口上报由于普通曝光事件的上报通道存在节流特性不符合CPM接口对于数据上报的实时性和准确性的要求所以使用额外的通道进行上报
*/
private fun commitWXCPMExposure(visibleState: ExposureThrottleBus.VisibleState) {
val eventList = arrayListOf<ExposureEvent>()
for (pos in visibleState.firstVisiblePosition..visibleState.lastVisiblePosition) {
try {
exposable.getEventByPosition(pos)?.let {
if (it.payload.miniGameType == Constants.WECHAT_MINI_GAME_CPM) {
eventList.add(it)
}
}
exposable.getEventListByPosition(pos)?.let { list ->
list.forEach {
if (it.payload.miniGameType == Constants.WECHAT_MINI_GAME_CPM) {
eventList.add(it)
}
}
}
} catch (ignore: Exception) {
// Just ignore the error.
}
}
ExposureManager.logCPM(eventList)
}
}

View File

@ -1,11 +1,13 @@
package com.gh.common.exposure
import com.gh.gamecenter.BuildConfig
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.loghub.TLogHubHelper
import com.gh.gamecenter.common.utils.FixedSizeLinkedHashSet
import com.gh.gamecenter.common.utils.toJson
import com.gh.gamecenter.core.AppExecutor
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.minigame.wechat.WGameSubjectCPMListReportHelper
import com.lightgame.utils.Utils
import com.volcengine.model.tls.LogItem
@ -32,6 +34,9 @@ object ExposureManager {
*/
fun log(event: ExposureEvent) {
AppExecutor.logExecutor.execute {
if (event.payload.miniGameType == Constants.WECHAT_MINI_GAME_CPM) {
WGameSubjectCPMListReportHelper.reportExposure(event)
}
if (!exposureCache.contains(event.id)) {
exposureSet.add(event)
exposureCache.add(event.id)
@ -58,6 +63,17 @@ object ExposureManager {
}
}
/**
* Log a wechat mini game cpm collection of exposure event.
*/
fun logCPM(eventList: List<ExposureEvent>) {
AppExecutor.logExecutor.execute {
if (eventList.isNotEmpty()) {
WGameSubjectCPMListReportHelper.reportExposure(eventList.toSet())
}
}
}
/**
* @param forcedUpload Ignore all restrictions.
*/

View File

@ -3,16 +3,20 @@ package com.gh.common.exposure
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.functions.Consumer
import io.reactivex.schedulers.Schedulers
import io.reactivex.subjects.PublishSubject
import io.reactivex.subjects.BehaviorSubject
import java.util.concurrent.TimeUnit
class ExposureThrottleBus(var onSuccess: Consumer<VisibleState>, var onError: Consumer<Throwable>) {
class ExposureThrottleBus(
var onSuccess: Consumer<VisibleState>,
var onError: Consumer<Throwable>,
onPreSuccess: Consumer<VisibleState>
) {
companion object {
private const val THRESHOLD_TIME = 300L
}
private val mPublishSubject: PublishSubject<VisibleState> = PublishSubject.create()
private val mPublishSubject: BehaviorSubject<VisibleState> = BehaviorSubject.create()
private val mCompositeDisposable: CompositeDisposable = CompositeDisposable()
init {
@ -24,6 +28,7 @@ class ExposureThrottleBus(var onSuccess: Consumer<VisibleState>, var onError: Co
*/
val disposable = mPublishSubject
.distinctUntilChanged()
.doOnNext(onPreSuccess)
.throttleWithTimeout(THRESHOLD_TIME, TimeUnit.MILLISECONDS)
.subscribeOn(Schedulers.io())
.subscribe(onSuccess, onError)

View File

@ -103,6 +103,7 @@ class AccelerateNotificationHandler(priority: Int) : PriorityChainHandler(priori
context = activity,
gameId = gameEntity.id,
entrance = "首页插件上架弹窗",
defaultTab = -1,
isSkipGameComment = false,
scrollToLibao = false,
openVideoStreaming = false,

View File

@ -33,5 +33,9 @@ class BuildConfigImpl : IBuildConfigProvider {
override fun getVDevApiHost(): String = BuildConfig.DEV_VAPI_HOST
override fun getWGameCPMApiHost(): String = BuildConfig.WGAME_CPM_API_HOST
override fun getWGameCPMBusiAppId(): String = BuildConfig.WGAME_CPM_BUSIAPPID
override fun getLogProducerProject(): String = BuildConfig.LOG_HUB_PROJECT
}

View File

@ -62,7 +62,13 @@ class DirectProviderImpl : IDirectProvider {
DirectUtils.directToCommunityArticle(context, articleId, communityId, entrance, path, sourceEntrance)
}
override fun directToVideoDetail(context: Context, videoId: String, entrance: String?, path: String?, sourceEntrance: String) {
override fun directToVideoDetail(
context: Context,
videoId: String,
entrance: String?,
path: String?,
sourceEntrance: String
) {
DirectUtils.directToVideoDetail(context, videoId, entrance, path, sourceEntrance)
}
@ -78,8 +84,13 @@ class DirectProviderImpl : IDirectProvider {
DirectUtils.directToQQGameById(activity, qqAppId)
}
override fun directToWechatGameById(activity: Activity, qqAppId: String) {
DirectUtils.directToWechatGameById(activity, qqAppId)
override fun directToWechatGameById(
activity: Activity,
wechatAppId: String,
wechatAppPath: String,
wechatAppExtData: String
) {
DirectUtils.directToWechatGameById(activity, wechatAppId, wechatAppPath, wechatAppExtData)
}
override fun directToExternalBrowser(context: Context, url: String) {

View File

@ -54,6 +54,7 @@ class GameDetailProviderImpl : IGameDetailProvider {
context: Context,
gameId: String,
entrance: String?,
defaultTab: Int,
isSkipGameComment: Boolean,
scrollToLibao: Boolean,
openVideoStreaming: Boolean,
@ -64,6 +65,7 @@ class GameDetailProviderImpl : IGameDetailProvider {
context,
gameId,
entrance,
defaultTab,
isSkipGameComment,
scrollToLibao,
openVideoStreaming,

View File

@ -9,7 +9,7 @@ import com.gh.gamecenter.core.provider.IPackageHelperProvider
@Route(path = RouteConsts.provider.packageHelper, name = "PackageHelper暴露服务")
class PackageHelperProviderImpl : IPackageHelperProvider {
override fun getLocalPackageNameSet(): HashSet<String> {
override fun getLocalPackageNameSet(): Set<String> {
return PackageHelper.localPackageNameSet
}

View File

@ -56,6 +56,7 @@ import com.gh.gamecenter.gamecollection.detail.GameCollectionDetailActivity
import com.gh.gamecenter.gamecollection.hotlist.GameCollectionHotListActivity
import com.gh.gamecenter.gamecollection.hotlist.GameCollectionListDetailActivity
import com.gh.gamecenter.gamecollection.square.GameCollectionSquareActivity
import com.gh.gamecenter.gamedetail.GameDetailFragment
import com.gh.gamecenter.gamedetail.fuli.kaifu.ServersCalendarActivity
import com.gh.gamecenter.gamedetail.fuli.kaifu.ServersCalendarManagementActivity
import com.gh.gamecenter.gamedetail.fuli.kaifu.ServersSubscribedGameListActivity
@ -68,6 +69,7 @@ import com.gh.gamecenter.minigame.MiniGameRecentlyPlayUseCase
import com.gh.gamecenter.minigame.MiniGameSearchActivity
import com.gh.gamecenter.minigame.qq.QGameHomeWrapperActivity
import com.gh.gamecenter.newsdetail.NewsDetailActivity
import com.gh.gamecenter.personalhome.UserHomeActivity
import com.gh.gamecenter.personalhome.background.PersonalityBackgroundActivity
import com.gh.gamecenter.personalhome.border.AvatarBorderActivity
import com.gh.gamecenter.personalhome.home.UserHistoryViewModel
@ -483,11 +485,13 @@ object DirectUtils {
ColumnCollectionDetailFragment.TYPE_QQ_MINI_GAME_COLUMN -> directToQGameHome(context)
// QQ游戏专题详情页
ViewPagerFragmentHelper.TYPE_QQ_MINI_GAME_COLUMN, ViewPagerFragmentHelper.TYPE_WECHAT_GAME_COLUMN -> {
val subjectType = if (linkEntity.type == ViewPagerFragmentHelper.TYPE_QQ_MINI_GAME_COLUMN) {
SubjectData.SubjectType.QQ_GAME
} else {
SubjectData.SubjectType.WECHAT_GAME
ViewPagerFragmentHelper.TYPE_QQ_MINI_GAME_COLUMN,
ViewPagerFragmentHelper.TYPE_WECHAT_GAME_COLUMN,
ViewPagerFragmentHelper.TYPE_WECHAT_GAME_CPM_COLUMN -> {
val subjectType = when (linkEntity.type) {
ViewPagerFragmentHelper.TYPE_QQ_MINI_GAME_COLUMN -> SubjectData.SubjectType.QQ_GAME
ViewPagerFragmentHelper.TYPE_WECHAT_GAME_CPM_COLUMN -> SubjectData.SubjectType.WECHAT_GAME_CPM
else -> SubjectData.SubjectType.WECHAT_GAME
}
directToSubject(
context = context,
@ -716,7 +720,7 @@ object DirectUtils {
*/
@JvmStatic
fun directToHomeActivity(context: Context, userId: String?, entrance: String? = null, path: String? = null) {
directToHomeActivity(context, userId, entrance, path, 0)
context.startActivity(UserHomeActivity.getIntent(context, userId ?: "", entrance, path))
}
@JvmStatic
@ -755,20 +759,17 @@ object DirectUtils {
entrance: String? = null,
path: String? = null
) {
IntegralLogHelper.log("view_homepage", "个人主页")
val uri = Uri.Builder()
.path(RouteConsts.activity.userHomeActivity)
.appendQueryParameter(KEY_USER_ID, userId)
.appendQueryParameter(KEY_TAB_INDEX, position.toString())
.appendQueryParameter(KEY_PATH, BaseActivity.mergeEntranceAndPath(entrance, path))
.appendQueryParameter(KEY_COMMUNITY_TYPE, UserHistoryViewModel.TYPE.fromValue(type).value)
.appendQueryParameter(KEY_GAME_TYPE, gameType)
.build()
ARouter.getInstance()
.build(uri)
.navigation(context)
val bundle = Bundle()
bundle.putString(KEY_USER_ID, userId)
bundle.putString(KEY_TO, UserHomeActivity::class.java.name)
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)
}
@ -800,10 +801,10 @@ object DirectUtils {
bundle.putString(KEY_GAMEID, id)
if (!TextUtils.isEmpty(tab)) {
when (tab) {
"comment" -> bundle.putString(KEY_TARGET, EntranceConsts.TAB_TYPE_RATING)
"desc" -> bundle.putString(KEY_TARGET, EntranceConsts.TAB_TYPE_DESC)
"forum" -> bundle.putString(KEY_TARGET, EntranceConsts.TAB_TYPE_BBS)
"zone" -> bundle.putString(KEY_TARGET, EntranceConsts.TAB_TYPE_TRENDS)
"comment" -> bundle.putString(KEY_TARGET, GameDetailFragment.TAB_RATING)
"desc" -> bundle.putString(KEY_TARGET, GameDetailFragment.TAB_DESC)
"forum" -> bundle.putString(KEY_TARGET, GameDetailFragment.TAB_BBS)
"zone" -> bundle.putString(KEY_TARGET, GameDetailFragment.TAB_TRENDS)
}
}
if (traceEvent != null) {
@ -848,7 +849,7 @@ object DirectUtils {
bundle.putString(KEY_ENTRANCE, entrance)
bundle.putString(KEY_GAMEID, id)
bundle.putBoolean(KEY_OPEN_VIDEO_STREAMING, true)
bundle.putString(KEY_TARGET, EntranceConsts.TAB_TYPE_DESC)
bundle.putString(KEY_TARGET, GameDetailFragment.TAB_DESC)
jumpActivity(context, bundle)
}
@ -856,7 +857,7 @@ object DirectUtils {
fun directToGameDetail(
context: Context,
id: String,
defaultTab: String = EntranceConsts.TAB_TYPE_DESC,
defaultTab: String = GameDetailFragment.TAB_DESC,
entrance: String? = null
) {
val bundle = Bundle()
@ -1514,7 +1515,7 @@ object DirectUtils {
response?.apply {
if (zone.status == "on") {
if (zone.style == "link") {
directToGameDetail(context, gameId, EntranceConsts.TAB_TYPE_TRENDS, entrance)
directToGameDetail(context, gameId, GameDetailFragment.TAB_TRENDS, entrance)
} else {
directToWebView(context, url, entrance)
}
@ -2010,6 +2011,8 @@ object DirectUtils {
fun directToWechatGameById(
activity: Activity,
wechatAppId: String,
wechatAppPath: String = "",
wechatAppExtData: String = ""
) {
val wxApiProxy = WXAPIFactory.createWXAPI(
@ -2024,8 +2027,9 @@ object DirectUtils {
wxApiProxy.sendReq(
WXLaunchMiniProgram.Req().apply {
userName = wechatAppId
path = Constants.WECHAT_MINI_GAME_PCS
miniprogramType = WXLaunchMiniProgram.Req.MINIPTOGRAM_TYPE_RELEASE;
path = wechatAppPath.ifEmpty { Constants.WECHAT_MINI_GAME_PCS }
extData = wechatAppExtData
miniprogramType = WXLaunchMiniProgram.Req.MINIPTOGRAM_TYPE_RELEASE
}
)
@ -2033,14 +2037,8 @@ object DirectUtils {
}
@JvmStatic
fun directToMessageCenter(defaultTabIndex: Int, source: String) {
val uri = Uri.Builder()
.path(RouteConsts.activity.messageWrapperActivity)
.appendQueryParameter(RouteConsts.QueryParams.REQUIRE_LOGIN, "true")
.appendQueryParameter(RouteConsts.QueryParams.SOURCE, source)
.build()
ARouter.getInstance().build(uri)
fun directToMessageCenter(defaultTabIndex: Int) {
ARouter.getInstance().build(RouteConsts.activity.messageWrapperActivity)
.withInt(BaseActivity_TabLayout.PAGE_INDEX, defaultTabIndex)
.navigation()
}

View File

@ -880,7 +880,7 @@ object DownloadItemUtils {
}
if (gameEntity.isMiniGame()) {
downloadBtn.setOnClickListener {
MiniGameItemHelper.launchMiniGame(gameEntity.miniGameAppId, gameEntity.miniGameType)
MiniGameItemHelper.launchMiniGame(gameEntity)
clickCallback?.onCallback()
allStateClickCallback?.onCallback()
}

View File

@ -494,7 +494,7 @@ object DownloadObserver {
java.lang.Boolean.parseBoolean(downloadEntity.getMetaExtra(Constants.IS_PLATFORM_RECOMMEND))
val exposureEvent = ExposureUtils.logADownloadCompleteExposureEvent(
GameEntity(
id = downloadEntity.gameId,
_id = downloadEntity.gameId,
mName = downloadEntity.name.removeSuffix(Constants.GAME_NAME_DECORATOR),
gameVersion = downloadEntity.versionName ?: "",
isPlatformRecommend = isPlatformRecommend,

View File

@ -1,9 +1,6 @@
package com.gh.common.util;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Handler;
import android.os.Message;
@ -19,10 +16,8 @@ import org.greenrobot.eventbus.EventBus;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 下载完成跳安装,
*/
@ -49,15 +44,15 @@ public class InstallUtils {
@Override
public void handleMessage(Message msg) {
if (msg.what == INSTALL_WHAT && packageManager != null) {
List<String> packageNameList = PackageHelper.INSTANCE.getInstalledPackageNameList(context, 0);
ArrayList<String> list = new ArrayList<>(packageNameList);
if (installMap != null && installMap.size() != 0) {
ArrayList<String> keys = new ArrayList<>();
for (String packageName : installMap.keySet()) {
if (TextUtils.isEmpty(packageName)) continue;
long time = installMap.get(packageName);
if (System.currentTimeMillis() - time >= MAX_TIME) {
keys.add(packageName);
} else if (list.contains(packageName)) {
} else if (PackageUtils.isInstalled(context, packageName)) {
keys.add(packageName);
DownloadEntity downloadEntity = DownloadManager.getInstance().getDownloadEntityByPackageName(packageName);
@ -65,7 +60,7 @@ public class InstallUtils {
if (!TextUtils.isEmpty(installVersion) && downloadEntity != null &&
installVersion.equals(downloadEntity.getVersionName())) {
if (!downloadEntity.isPluggable() || PackageUtils.isSignedByGh(context, packageName)) {
EventBus.getDefault().post(new EBPackage(EBPackage.TYPE_INSTALLED, packageName, installVersion));
EventBus.getDefault().post(new EBPackage(EBPackage.TYPE_INSTALLED, packageName, installVersion, false));
}
}
}
@ -80,9 +75,9 @@ public class InstallUtils {
long time = uninstallMap.get(packageName);
if (System.currentTimeMillis() - time >= MAX_TIME) {
keys.add(packageName);
} else if (!list.contains(packageName)) {
} else if (!PackageUtils.isInstalled(context, packageName)) {
keys.add(packageName);
EventBus.getDefault().post(new EBPackage("卸载", packageName, ""));
EventBus.getDefault().post(new EBPackage("卸载", packageName, "", false));
}
}
for (String key : keys) {
@ -105,6 +100,8 @@ public class InstallUtils {
}
public void addInstall(String packageName) {
if (TextUtils.isEmpty(packageName)) return;
if (installMap == null) {
installMap = Collections.synchronizedMap(new HashMap<String, Long>());
}

View File

@ -105,14 +105,9 @@ object PackageHelper {
get() = _installedPackageApiSwitchStatusLiveData
// 本地已安装包的列表
var localPackageNameSet = hashSetOf<String>()
var localPackageNameSet = setOf<String>()
get() {
return if (field.isEmpty()) {
field = getAllPackageName(HaloApp.getInstance().application)
field
} else {
field
}
return HashSet(cachedInstalledPackageNameList)
}
/**
@ -461,9 +456,10 @@ object PackageHelper {
* 进行包名初始化相关的操作
*/
fun initPackageRelatedData() {
PackageRepository.initData()
refreshLocalPackageList()
refreshPackageNameList()
PackageRepository.initData {
refreshLocalPackageList()
refreshPackageNameList()
}
}
/**
@ -818,7 +814,7 @@ object PackageHelper {
uploadUIDGapLog = false
val uidGap = (android.os.Process.LAST_APPLICATION_UID - lastValidUid) / 100 * 100
SentryHelper.onEvent("UID_GAP", "gap", uidGap.toString())
// SentryHelper.onEvent("UID_GAP", "gap", uidGap.toString())
}
return packageList

View File

@ -225,17 +225,6 @@ public class PackageUtils {
}
} catch (Exception e) {
e.printStackTrace();
if (e instanceof AndroidException) {
// 有些设备会出现 DeadSystemException
SentryHelper.INSTANCE.onEvent(
"GET_META_DATA_ERROR",
"packageName",
packageName,
"exception_digest",
e.getLocalizedMessage()
);
}
}
return null;
}
@ -497,7 +486,6 @@ public class PackageUtils {
}
} catch (Exception e) {
e.printStackTrace();
SentryHelper.INSTANCE.onEvent("GET_PACKAGE_INFO_ERROR", "path", path);
}
return null;
@ -577,8 +565,7 @@ public class PackageUtils {
}
return true;
} catch (Exception e) {
ArrayList<String> allPackageName = getAllPackageName(context);
boolean isInstalled = allPackageName.contains(packageName);
boolean isInstalled = PackageHelper.INSTANCE.getLocalPackageNameSet().contains(packageName);
if (isInstalled) {
// 能进这里说明上面的 try {} 结果有问题,记录一下
@ -641,17 +628,6 @@ public class PackageUtils {
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT).versionName;
} catch (Exception e) {
e.printStackTrace();
if (e instanceof AndroidException) {
// 有些设备会出现 DeadSystemException
SentryHelper.INSTANCE.onEvent(
"GET_VERSION_NAME_ERROR",
"packageName",
packageName,
"exception_digest",
e.getLocalizedMessage()
);
}
}
return null;
}
@ -665,16 +641,6 @@ public class PackageUtils {
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT).versionCode;
} catch (Exception e) {
e.printStackTrace();
if (e instanceof AndroidException) {
// 有些设备会出现 DeadSystemException
SentryHelper.INSTANCE.onEvent(
"GET_VERSION_CODE_ERROR",
"packageName",
packageName,
"exception_digest",
e.getLocalizedMessage()
);
}
}
return 0;
}
@ -689,39 +655,10 @@ public class PackageUtils {
return packageManager.getApplicationIcon(packageName);
} catch (Exception e) {
e.printStackTrace();
if (e instanceof AndroidException) {
// 有些设备会出现 DeadSystemException
SentryHelper.INSTANCE.onEvent(
"GET_ICON_ERROR",
"packageName",
packageName,
"exception_digest",
e.getLocalizedMessage()
);
}
}
return null;
}
/*
* 获取所有已安装的软件的包名(包括系统应用)
*/
public static ArrayList<String> getAllPackageName(Context context) {
ArrayList<String> list = new ArrayList<>();
List<String> packageNameList = PackageHelper.INSTANCE.getInstalledPackageNameList(context, 0);
for (String packageName : packageNameList) {
if (!context.getPackageName().equals(packageName)) {
list.add(packageName);
}
}
return list;
}
public static ArrayList<String> getAllPackageNameIncludeGh(Context context) {
List<String> packageNameList = PackageHelper.INSTANCE.getInstalledPackageNameList(context, 0);
return new ArrayList<>(packageNameList);
}
public static JSONArray getAppList(Context context) {
JSONArray jsonArray = new JSONArray();
try {
@ -751,17 +688,6 @@ public class PackageUtils {
return jsonObject;
} catch (Exception e) {
e.printStackTrace();
if (e instanceof AndroidException) {
// 有些设备会出现 DeadSystemException
SentryHelper.INSTANCE.onEvent(
"GET_APP_BASIC_INFO_BY_PACKAGE_NAME",
"packageName",
packageName,
"exception_digest",
e.getLocalizedMessage()
);
}
return jsonObject;
}
}

View File

@ -46,7 +46,7 @@ object RecommendPopupHelper {
//判断是否符合包名限制
val nameRule = entity.recommendPackage.nameRule
val packages = entity.recommendPackage.details
val installedPackages = PackageUtils.getAllPackageNameIncludeGh(HaloApp.getInstance())
val installedPackages = PackageHelper.getInstalledPackageNameList(HaloApp.getInstance(), 0)
var isMatchSuccess = true
val checkInstalled: (splitPackages: List<String>) -> Boolean = {
var isInstalled = false

View File

@ -27,7 +27,9 @@ import com.gh.gamecenter.retrofit.RetrofitManager
import com.halo.assistant.HaloApp
import com.lightgame.utils.Utils
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.ResponseBody
import org.json.JSONArray
import org.json.JSONObject
@ -124,11 +126,12 @@ object UsageStatsHelper {
&& curEvent.className == nextEvent.className
) {
val diff = nextEvent.timeStamp - curEvent.timeStamp
val packageName = curEvent.packageName ?: continue
if (pakAndTime[curEvent.packageName] == null) {
pakAndTime[curEvent.packageName] = diff
if (pakAndTime[packageName] == null) {
pakAndTime[packageName] = diff
} else {
pakAndTime[curEvent.packageName] = pakAndTime[curEvent.packageName]!! + diff
pakAndTime[packageName] = pakAndTime[packageName]!! + diff
}
}
}
@ -175,7 +178,7 @@ object UsageStatsHelper {
return
}
val body = RequestBody.create(MediaType.parse("application/json"), postBody.toString())
val body = postBody.toString().toRequestBody("application/json".toMediaTypeOrNull())
mApi.postUsageStatus(body, UserManager.getInstance().userId)
.subscribe(object : BiResponse<ResponseBody>() {
override fun onSuccess(data: ResponseBody) {

View File

@ -65,6 +65,7 @@ object ViewPagerFragmentHelper {
const val TYPE_COLUMN = "column" // 游戏专题详情页
const val TYPE_QQ_MINI_GAME_COLUMN = "qq_mini_game_column_detail" // QQ小游戏专题详情页
const val TYPE_WECHAT_GAME_COLUMN = "wechat_game_column_detail" // 微信小游戏专题详情页
const val TYPE_WECHAT_GAME_CPM_COLUMN = "wechat_game_cpm_column_detail" // 微信小游戏CPM专题详情页
const val TYPE_COLUMN_COLLECTION = "column_collection" // 专题合集详情页
const val TYPE_SERVER = "server" // 开服表
const val TYPE_COLUMN_TEST = "column_test_v2" // 新游开测
@ -163,10 +164,11 @@ object ViewPagerFragmentHelper {
className = GameCollectionSquareFragment::class.java.name
}
// 游戏专题详情页/QQ游戏专题详情页
TYPE_COLUMN, TYPE_QQ_MINI_GAME_COLUMN, TYPE_WECHAT_GAME_COLUMN -> {
TYPE_COLUMN, TYPE_QQ_MINI_GAME_COLUMN, TYPE_WECHAT_GAME_COLUMN, TYPE_WECHAT_GAME_CPM_COLUMN -> {
val subjectType = when(entity.type) {
TYPE_QQ_MINI_GAME_COLUMN -> SubjectData.SubjectType.QQ_GAME
TYPE_WECHAT_GAME_COLUMN -> SubjectData.SubjectType.WECHAT_GAME
TYPE_WECHAT_GAME_CPM_COLUMN -> SubjectData.SubjectType.WECHAT_GAME_CPM
else -> SubjectData.SubjectType.NORMAL
}
className = SubjectFragment::class.java.name

View File

@ -34,7 +34,9 @@ import com.lightgame.utils.Utils
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody
import org.json.JSONException
import org.json.JSONObject
import java.util.*
@ -216,7 +218,7 @@ object PackageObserver {
try {
jsonObject.put("game_id", gameId)
jsonObject.put("package", packageName)
val rBody = RequestBody.create(MediaType.parse("application/json"), jsonObject.toString())
val rBody = jsonObject.toString().toRequestBody("application/json".toMediaTypeOrNull())
RetrofitManager.getInstance().api
.postPlayedGame(UserManager.getInstance().userId, rBody)
.subscribeOn(Schedulers.io())

View File

@ -94,8 +94,8 @@ object ExoCacheManager {
response =
OkHttpClient.Builder().connectTimeout(5, TimeUnit.SECONDS).readTimeout(5, TimeUnit.SECONDS).build()
.newCall(request).execute()
if (response!!.isSuccessful && response.body() != null) {
val length = response.body()!!.contentLength()
if (response!!.isSuccessful && response.body != null) {
val length = response.body!!.contentLength()
contentLength = if (length == 0L) -1L else length
}
} catch (e: Exception) {

View File

@ -3,6 +3,7 @@ package com.gh.download.dialog
import android.app.Application
import androidx.lifecycle.*
import com.gh.common.constant.Config
import com.gh.common.util.PackageHelper
import com.gh.common.util.PackageUtils
import com.gh.download.DownloadManager
import com.gh.gamecenter.feature.entity.ApkEntity
@ -34,7 +35,7 @@ class DownloadViewModel(application: Application, val gameEntity: GameEntity) :
private var mAllApkList: MutableList<ApkEntity> = ArrayList()
private var mInstalledApkList: MutableList<ApkEntity> = ArrayList()
private var mOtherApkList: MutableList<ApkEntity> = ArrayList()
private var allPackageName: ArrayList<String>? = null
private var allPackageName: List<String>? = null
var otherSectionPosition = -1
init {
@ -47,7 +48,7 @@ class DownloadViewModel(application: Application, val gameEntity: GameEntity) :
}
fun getAllPackageName() {
allPackageName = PackageUtils.getAllPackageName(HaloApp.getInstance())
allPackageName = PackageHelper.getInstalledPackageNameList(HaloApp.getInstance(), 0)
}
fun initListData() {

View File

@ -6,7 +6,7 @@ import android.util.Base64
import com.gh.common.constant.Config
import com.gh.common.util.DirectUtils
import com.gh.common.util.LogUtils
import com.gh.common.util.PackageUtils
import com.gh.common.util.PackageHelper
import com.gh.gamecenter.ShellActivity
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.entity.ExposureEntity
@ -28,7 +28,6 @@ import org.json.JSONObject
import java.io.File
import java.net.URLEncoder
import java.util.*
import kotlin.collections.ArrayList
object BrowserInstallHelper {
@ -40,7 +39,7 @@ object BrowserInstallHelper {
private val mContext by lazy { HaloApp.getInstance().application }
private var mUseReservePort = false
private var mValidInstalledPackageList: ArrayList<String> = arrayListOf()
private var mValidInstalledPackageList: List<String> = listOf()
private var mValidConditionMatchedCache: Boolean? = null
private fun getServer(port: Int): DownloadServer {
@ -54,14 +53,14 @@ object BrowserInstallHelper {
return server
}
private fun getAllInstalledPackageList(): ArrayList<String> {
private fun getAllInstalledPackageList(): List<String> {
when {
mValidInstalledPackageList.isNotEmpty() -> {
return mValidInstalledPackageList
}
else -> {
val allInstalledPackageList = PackageUtils.getAllPackageName(mContext)
val allInstalledPackageList = PackageHelper.getInstalledPackageNameList(mContext, 0)
if (allInstalledPackageList.isNotEmpty()) {
mValidInstalledPackageList = allInstalledPackageList

View File

@ -27,12 +27,24 @@ object SimpleDownloadManager {
val downloadStatus = mDownloadQueue.getStatus(config.uniqueId)
if (downloadStatus != DownloadStatus.PAUSED) {
ExecutorProvider.getInstance().backgroundExecutor.execute {
DownloadMessageHandler.insertDownloadToDatabase(getDownloadEntity(config))
mDownloadQueue.submitNewTask(config)
}
createNewTaskAndDownload(config)
} else {
resume(config.uniqueId)
try {
resume(config.uniqueId)
} catch (e: IllegalArgumentException) {
createNewTaskAndDownload(config)
}
}
}
/**
* 创建新任务并下载
*/
private fun createNewTaskAndDownload(config: DownloadConfig) {
ExecutorProvider.getInstance().backgroundExecutor.execute {
mDownloadQueue.cancel(config.uniqueId)
DownloadMessageHandler.insertDownloadToDatabase(getDownloadEntity(config))
mDownloadQueue.submitNewTask(config)
}
}

View File

@ -5,17 +5,12 @@ import android.content.ContextWrapper
import android.content.Intent
import android.os.Bundle
import android.view.View
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.gh.base.DownloadToolbarActivity
import com.gh.common.exposure.ExposureManager
import com.gh.common.exposure.ExposureManager.log
import com.gh.common.exposure.ExposureTraceUtils.appendTrace
import com.gh.gamecenter.common.base.GlobalActivityManager
import com.gh.gamecenter.common.base.activity.ToolBarActivity.NORMAL_FRAGMENT_BUNDLE
import com.gh.gamecenter.common.base.activity.ToolBarActivity.NORMAL_FRAGMENT_NAME
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.common.utils.toArrayList
import com.gh.gamecenter.core.utils.DisplayUtils
import com.gh.gamecenter.entity.GamePlatform
@ -25,54 +20,15 @@ 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.gamedetail.GameDetailFragment
import com.halo.assistant.HaloApp
@Route(
path = RouteConsts.activity.gameDetailActivity,
name = "游戏详情页"
)
/**
* Created by khy on 2017/3/24.
* 游戏详情页
*/
class GameDetailActivity : DownloadToolbarActivity() {
@JvmField
@Autowired(name = EntranceConsts.KEY_GAME_ID, desc = "游戏 id", required = true)
var gameId: String? = null
@JvmField
@Autowired(name = EntranceConsts.KEY_GAME_ENTITY, desc = "游戏摘要实体,如果你不懂这个是什么,那么不要用它,直接传入游戏 id 即可")
var gameEntity: GameEntity? = null
@JvmField
@Autowired(name = EntranceConsts.KEY_ENTRANCE, desc = "入口埋点字段(开发内部使用)")
var entrance: String? = ""
@JvmField
@Autowired(name = EntranceConsts.KEY_DEFAULT_TAB, desc = "默认选中 tab 的类型(目前可选的有五个类型 `详情`, `专区``云存档``评价``论坛`),首次进入匹配并切换至对应 tab")
var defaultTab: String = ""
@JvmField
@Autowired(name = EntranceConsts.KEY_COMMENT_AS_DEFAULT_TAB, desc = "跳转到评论 tab首次进入直接跳转到评论 tab")
var commentAsDefaultTab: Boolean = false
@JvmField
@Autowired(name = EntranceConsts.KEY_SCROLL_TO_LIBAO, desc = "滚动到礼包区域,首次进入滚动到礼包区域")
var scrollToLibao: Boolean = false
@JvmField
@Autowired(name = EntranceConsts.KEY_SCROLL_TO_SERVER, desc = "滚动到开服表区域,首次进入滚动到开服表区域")
var scrollToServer: Boolean = false
@JvmField
@Autowired(name = EntranceConsts.KEY_OPEN_VIDEO_STREAMING, desc = "打开视频流,首次进入打开视频流")
var openVideoStreaming: Boolean = false
@JvmField
@Autowired(name = EntranceConsts.KEY_OPEN_PLATFORM_WINDOW, desc = "打开多版本窗口,首次进入打开多版本窗口")
var openPlatformWindow: Boolean = false
override fun onCreate(savedInstanceState: Bundle?) {
ARouter.getInstance().inject(this)
generateDataFromRoute()
super.onCreate(savedInstanceState)
DisplayUtils.transparentStatusBar(this)
}
@ -81,21 +37,37 @@ class GameDetailActivity : DownloadToolbarActivity() {
return getTargetIntent(this, GameDetailActivity::class.java, GameDetailFragment::class.java)
}
override fun getLayoutId() = R.layout.activity_game_detail
override fun getLayoutId(): Int {
return R.layout.activity_game_detail
}
override fun showToolbarAtLeft() = true
override fun showDownloadMenu() = true
override fun showToolbarAtLeft(): Boolean {
return true
}
override fun getActivityNameInChinese() = "游戏详情"
override fun showDownloadMenu(): Boolean {
return true
}
override fun onDestroy() {
super.onDestroy()
HaloApp.remove(Constants.GAME_DETAIL_COME_IN)
}
override fun getActivityNameInChinese(): String {
return "游戏详情"
}
override fun getBusinessId(): Pair<String, String> {
return if (!gameId.isNullOrEmpty()) {
Pair(gameId ?: "", "")
val fragment = targetFragment as? GameDetailFragment?
return if (fragment?.arguments != null) {
Pair(fragment.requireArguments().getString(EntranceConsts.KEY_GAMEID) ?: "", "")
} else {
super.getBusinessId()
}
}
override fun attachBaseContext(newBase: Context) {
super.attachBaseContext(object : ContextWrapper(newBase) {
override fun getSystemService(name: String): Any? {
@ -124,13 +96,6 @@ class GameDetailActivity : DownloadToolbarActivity() {
)
}
private fun generateDataFromRoute() {
val bundle = intent.extras
intent?.putExtra(NORMAL_FRAGMENT_NAME, GameDetailFragment::class.java.canonicalName)
intent?.putExtra(NORMAL_FRAGMENT_BUNDLE, bundle)
}
companion object {
@JvmStatic
@ -166,10 +131,9 @@ class GameDetailActivity : DownloadToolbarActivity() {
if (traceEvent != null) {
val clickEvent = createEvent(gameEntity, traceEvent.source, appendTrace(traceEvent), ExposureType.CLICK)
ExposureManager.log(clickEvent)
log(clickEvent)
bundle.putParcelable(EntranceConsts.KEY_TRACE_EVENT, clickEvent)
}
if (gameEntity != null && traceEvent != null && gameEntity.id != traceEvent.payload.gameId) {
// 当游戏 ID 跟曝光 traceEvent 的游戏ID 不一样的时候更新 traceEvent 的游戏ID
val (payload) = createEvent(
@ -180,33 +144,31 @@ class GameDetailActivity : DownloadToolbarActivity() {
)
traceEvent.payload = payload
}
if (defaultTab.isNotEmpty()) {
bundle.putString(EntranceConsts.KEY_TARGET, defaultTab)
}
if (isSkipGameComment) {
bundle.putBoolean(EntranceConsts.KEY_COMMENT_AS_DEFAULT_TAB, true)
bundle.putBoolean(EntranceConsts.KEY_SKIP_GAME_COMMENT, true)
}
if (scrollToLibao) {
bundle.putString(EntranceConsts.KEY_TARGET, EntranceConsts.TAB_TYPE_DESC)
bundle.putString(EntranceConsts.KEY_TARGET, GameDetailFragment.TAB_DESC)
bundle.putBoolean(EntranceConsts.KEY_SCROLL_TO_LIBAO, true)
}
if (scrollToServer) {
bundle.putString(EntranceConsts.KEY_TARGET, EntranceConsts.TAB_TYPE_DESC)
bundle.putString(EntranceConsts.KEY_TARGET, GameDetailFragment.TAB_DESC)
bundle.putBoolean(EntranceConsts.KEY_SCROLL_TO_SERVER, true)
}
bundle.putString(EntranceConsts.KEY_GAME_ID, gameEntity?.id)
bundle.putString(EntranceConsts.KEY_GAMEID, gameEntity?.id)
bundle.putString(EntranceConsts.KEY_ENTRANCE, entrance)
bundle.putParcelable(EntranceConsts.KEY_GAME_ENTITY, gameEntity)
ARouter.getInstance()
.build(RouteConsts.activity.gameDetailActivity)
.with(bundle)
.navigation(context)
bundle.putParcelable(GameEntity.TAG, gameEntity)
context.startActivity(
getTargetIntent(
context,
GameDetailActivity::class.java,
GameDetailFragment::class.java,
bundle
)
)
}
@JvmStatic
@ -216,7 +178,7 @@ class GameDetailActivity : DownloadToolbarActivity() {
entrance: String?,
traceEvent: ExposureEvent?
) {
startGameDetailActivity(context, gameId, entrance, isSkipGameComment = false, traceEvent = traceEvent)
startGameDetailActivity(context, gameId, entrance, -1, traceEvent = traceEvent)
}
@JvmStatic
@ -224,6 +186,7 @@ class GameDetailActivity : DownloadToolbarActivity() {
context: Context,
gameId: String,
entrance: String?,
defaultTab: Int = -1,
isSkipGameComment: Boolean = false,
scrollToLibao: Boolean = false,
openVideoStreaming: Boolean = false,
@ -234,6 +197,7 @@ class GameDetailActivity : DownloadToolbarActivity() {
context,
gameId,
entrance,
defaultTab,
isSkipGameComment,
scrollToLibao,
openVideoStreaming,
@ -247,6 +211,7 @@ class GameDetailActivity : DownloadToolbarActivity() {
/**
* @param gameId 游戏Id
* @param defaultTab 默认定位到哪个tab
* @param isSkipGameComment 是否跳转到评论tab
* @param scrollToLibao 滚动到礼包区域
* @param openVideoStreaming 是否打开视频流
@ -260,6 +225,7 @@ class GameDetailActivity : DownloadToolbarActivity() {
context: Context,
gameId: String,
entrance: String?,
defaultTab: Int = -1,
isSkipGameComment: Boolean = false,
scrollToLibao: Boolean = false,
openVideoStreaming: Boolean = false,
@ -282,7 +248,7 @@ class GameDetailActivity : DownloadToolbarActivity() {
appendTrace(traceEvent),
ExposureType.CLICK
)
ExposureManager.log(clickEvent)
log(clickEvent)
bundle.putParcelable(EntranceConsts.KEY_TRACE_EVENT, clickEvent)
}
if (traceEvent != null && gameId != traceEvent.payload.gameId) {
@ -295,12 +261,15 @@ class GameDetailActivity : DownloadToolbarActivity() {
)
traceEvent.payload = payload
}
if (defaultTab != -1) {
bundle.putInt(EntranceConsts.KEY_TARGET, defaultTab)
}
if (isSkipGameComment) {
bundle.putBoolean(EntranceConsts.KEY_COMMENT_AS_DEFAULT_TAB, true)
bundle.putBoolean(EntranceConsts.KEY_SKIP_GAME_COMMENT, true)
}
if (openVideoStreaming) {
bundle.putBoolean(EntranceConsts.KEY_OPEN_VIDEO_STREAMING, true)
bundle.putString(EntranceConsts.KEY_TARGET, EntranceConsts.TAB_TYPE_DESC)
bundle.putString(EntranceConsts.KEY_TARGET, GameDetailFragment.TAB_DESC)
}
if (openPlatformWindow) {
bundle.putBoolean(EntranceConsts.KEY_OPEN_PLATFORM_WINDOW, true)
@ -314,10 +283,10 @@ class GameDetailActivity : DownloadToolbarActivity() {
}
}
if (scrollToLibao) {
bundle.putString(EntranceConsts.KEY_TARGET, EntranceConsts.TAB_TYPE_DESC)
bundle.putString(EntranceConsts.KEY_TARGET, GameDetailFragment.TAB_DESC)
bundle.putBoolean(EntranceConsts.KEY_SCROLL_TO_LIBAO, true)
}
bundle.putString(EntranceConsts.KEY_GAME_ID, gameId)
bundle.putString(EntranceConsts.KEY_GAMEID, gameId)
bundle.putString(EntranceConsts.KEY_ENTRANCE, entrance)
bundle.putParcelable(EntranceConsts.KEY_CUSTOM_PAGE_TRACK_DATA, customPageTrackData)
bundle.putString(EntranceConsts.KEY_LAST_PAGE_ID, GlobalActivityManager.getLastPageEntity().pageId)
@ -326,11 +295,14 @@ class GameDetailActivity : DownloadToolbarActivity() {
EntranceConsts.KEY_LAST_PAGE_BUSINESS_ID,
GlobalActivityManager.getLastPageEntity().pageBusinessId
)
ARouter.getInstance()
.build(RouteConsts.activity.gameDetailActivity)
.with(bundle)
.navigation(context)
context.startActivity(
getTargetIntent(
context,
GameDetailActivity::class.java,
GameDetailFragment::class.java,
bundle
)
)
}
}

View File

@ -238,7 +238,7 @@ open class SearchActivity : BaseActivity() {
GlobalActivityManager.getCurrentPageEntity().pageId,
GlobalActivityManager.getCurrentPageEntity().pageName,
key ?: "",
TRACK_SEARCH_TYPE_DEFAULT,
TRACK_SEARCH_TYPE_RANK,
mSourceEntrance
)
}
@ -433,12 +433,14 @@ open class SearchActivity : BaseActivity() {
const val TRACK_SEARCH_TYPE_INPUT = "输入搜索"
const val TRACK_SEARCH_TYPE_DEFAULT = "默认搜索"
const val TRACK_SEARCH_TYPE_HISTORY = "历史搜索"
const val TRACK_SEARCH_TYPE_RANK = "榜单搜索"
@JvmStatic
fun toTrackSearchType(type: String) = when (type) {
SearchType.AUTO.value -> TRACK_SEARCH_TYPE_AUTO
SearchType.MANUAL.value -> TRACK_SEARCH_TYPE_INPUT
SearchType.HISTORY.value -> TRACK_SEARCH_TYPE_HISTORY
SearchType.RANK.value -> TRACK_SEARCH_TYPE_RANK
else -> TRACK_SEARCH_TYPE_DEFAULT
}

View File

@ -408,7 +408,7 @@ public class SkipActivity extends BaseActivity {
try {
JSONObject extJsonObject = new JSONObject(extJson);
String qqGameId = extJsonObject.optString("aid");
MiniGameItemHelper.INSTANCE.launchMiniGame(qqGameId, Constants.QQ_MINI_GAME);
MiniGameItemHelper.INSTANCE.launchMiniGame(qqGameId, Constants.QQ_MINI_GAME, "", "");
} catch (JSONException ignored) {
}
break;
@ -445,6 +445,24 @@ public class SkipActivity extends BaseActivity {
break;
}
}
} else if ("market".equals(uri.getScheme())) {
String host = uri.getHost();
String id = "";
try {
id = uri.getQueryParameter("id");
} catch (UnsupportedOperationException e) {
e.printStackTrace();
}
if (host != null) {
if ("details".equals(host)) {
bundle = new Bundle();
bundle.putString(KEY_TO, EntranceConsts.KEY_MARKET_DETAILS);
bundle.putString(KEY_DATA, id);
EntranceUtils.jumpActivity(this, bundle);
} else {
EntranceUtils.jumpActivity(this, new Bundle()); // 跳转至首页
}
}
}
}

View File

@ -1,105 +0,0 @@
package com.gh.gamecenter
import android.content.Context
import android.net.Uri
import android.os.Bundle
import com.alibaba.android.arouter.facade.Postcard
import com.alibaba.android.arouter.facade.callback.NavigationCallback
import com.alibaba.android.arouter.launcher.ARouter
import com.gh.common.util.EntranceUtils
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.utils.DialogHelper
import com.halo.assistant.HaloApp
import com.lightgame.utils.Utils
class SkipCompatActivity : SkipActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
val uri = intent.data
if (handleSkip(this, uri)) {
intent.setData(null)
}
super.onCreate(savedInstanceState)
finish()
}
companion object {
const val TAG = "SkipCompat"
const val HOST = "app"
const val SCHEME = "ghzhushou"
const val MARKET = "market"
fun handleSkip(context: Context, uri: Uri?): Boolean {
if (uri == null) return false
// Handle skip
if (uri.scheme == SCHEME) {
Utils.log(TAG, "handleSkip: $uri")
val host = uri.host
if (host == HOST) {
ARouter.getInstance()
.build(uri)
.navigation(context, object : NavigationCallback {
override fun onFound(postcard: Postcard?) {
Utils.log(TAG, "navigate to postcard ${postcard?.uri} onFound" )
}
override fun onLost(postcard: Postcard?) {
Utils.log(TAG, "navigate to postcard ${postcard?.uri} onLost" )
if (HaloApp.getInstance().isAlreadyUpAndRunning) {
// 在光环应用内时,显示不支持弹窗
// 显示不支持弹窗
DialogHelper.showUpgradeDialog(context)
} else {
// 在光环应用外跳转时,重定向至首页
EntranceUtils.jumpActivity(context, Bundle())
}
}
override fun onArrival(postcard: Postcard?) {
Utils.log(TAG, "navigate to postcard ${postcard?.uri} onArrival" )
}
override fun onInterrupt(postcard: Postcard?) {
Utils.log(TAG, "navigate to postcard ${postcard?.uri} onInterrupt" )
}
})
return true
}
} else if (uri.scheme == MARKET) {
val host = uri.host
var id = ""
try {
id = uri.getQueryParameter("id") ?: ""
} catch (e: Exception) {
e.printStackTrace()
}
if (host != null) {
if ("details" == host) {
val bundle = Bundle()
bundle.putString(
EntranceConsts.KEY_TO,
EntranceConsts.KEY_MARKET_DETAILS
)
bundle.putString(EntranceConsts.KEY_DATA, id)
EntranceUtils.jumpActivity(context, bundle)
} else {
EntranceUtils.jumpActivity(context, Bundle()) // 跳转至首页
}
return true
}
}
return false
}
}
}

View File

@ -32,7 +32,7 @@ class AmwaySearchDefaultFragment : SearchDefaultFragment() {
mViewModel.playedGames.observeNonNull(viewLifecycleOwner) {
defaultViewModel?.isExistHotSearch = it.isNotEmpty()
updateView()
mBinding.searchDiscoveryList.run {
mBinding.hotList.run {
layoutManager = LinearLayoutManager(context)
adapter = AmwaySearchAdapter(context, mViewModel, "安利墙搜索-最近玩过").apply { setData(it) }
}
@ -43,7 +43,7 @@ class AmwaySearchDefaultFragment : SearchDefaultFragment() {
override fun initView() {
mBinding = mAmwayBinding.searchContent
mBinding.searchDiscoveryHeadContainer.headTitle.text = "最近玩过"
mBinding.hotHeadContainer.headTitle.text = "最近玩过"
mBinding.historyFlexContainer.setLimitHeight(mFlexMaxHeight)
updateHistorySearchView(null)

View File

@ -309,7 +309,8 @@ class CategoryV2ListFragment : ListFragment<GameEntity, CategoryV2ListViewModel>
// 安装/卸载 事件
@Subscribe(threadMode = ThreadMode.MAIN)
fun onEventMainThread(busFour: EBPackage) {
if (busFour.isInstalledOrUninstalled()) {
// 忽略首次初始化触发的事件
if (!busFour.fromInit && busFour.isInstalledOrUninstalled()) {
mAdapter?.notifyDataSetChanged()
}
}

View File

@ -27,7 +27,7 @@ open class BaseCloudArchiveViewModel(application: Application, private val mConf
)
.enqueue(object : Callback {
override fun onResponse(call: Call, response: Response) {
mArchiveConfigStr = response.body()?.string() ?: ""
mArchiveConfigStr = response.body?.string() ?: ""
callback?.invoke(mArchiveConfigStr)
}

View File

@ -93,7 +93,7 @@ class AdGameBannerAdapter(
it.name ?: ""
)
if (it.isMiniGame()) {
MiniGameItemHelper.launchMiniGame(it.miniGameAppId, it.miniGameType)
MiniGameItemHelper.launchMiniGame(it)
} else {
GameDetailActivity.startGameDetailActivity(
mContext,

View File

@ -161,6 +161,7 @@ class DownloadFragment : BaseFragment_TabLayout() {
val showOnFailed = downloadManagerAd?.displayRule?.onFailedAction == "show"
if ((showThirdPartyAd && thirdPartyAd != null) || (!showThirdPartyAd && thirdPartyAd != null && ownerAd == null)) {
initThirdPartyAd(downloadManagerAd, thirdPartyAd) { isSuccess ->
if (!isAdded) return@initThirdPartyAd
mBinding.maskView.goneIf(!isSuccess)
if (!isSuccess && ownerAd != null && showOnFailed) {
mSlideInterval = ownerAd.adSource?.sliderInterval ?: -1
@ -215,7 +216,7 @@ class DownloadFragment : BaseFragment_TabLayout() {
}
private fun initOwnerAd(adConfig: AdConfig) {
if (adConfig.id.isEmpty()) return
if (!isAdded || adConfig.id.isEmpty()) return
mAdGameViewModel = viewModelProvider(AdGameViewModel.Factory(adConfig))
initAdGameBanner(adConfig)
mBinding.closeAdIv.setOnClickListener {
@ -249,6 +250,7 @@ class DownloadFragment : BaseFragment_TabLayout() {
adConfig.displayRule.onFailedAction == "show" && adConfig.thirdPartyAd != null) {
// 自有广告游戏为空时,显示第三方广告
initThirdPartyAd(adConfig, adConfig.thirdPartyAd) { isSuccess ->
if (!isAdded) return@initThirdPartyAd
mBinding.maskView.goneIf(!isSuccess)
if (isSuccess) {
SPUtils.setLong(Constants.SP_LAST_DOWNLOAD_MANAGER_AD_SHOW_TIME, System.currentTimeMillis())

View File

@ -220,7 +220,7 @@ class NewInstalledGameFragment : ToolbarFragment() {
@Subscribe(threadMode = ThreadMode.MAIN)
fun onEventMainThread(packageEb: EBPackage) {
if (packageEb.isInstalledOrUninstalled()) {
if (!packageEb.fromInit && packageEb.isInstalledOrUninstalled()) {
mInstallGameViewModel.initData(
PackagesManager.filterSameApk(
PackagesManager.filterDownloadBlackPackage(mPackageViewModel?.getGameInstalledLiveData()?.value as MutableList<GameInstall>?)

View File

@ -9,14 +9,16 @@ import kotlinx.parcelize.Parcelize
@Parcelize
data class SearchSubjectEntity(
val name: String = "",
val games: List<GameEntity> = listOf(),
var games: List<GameEntity> = listOf(),
val location: Int = 0,
@SerializedName("column_id")
val columnId: String = "",
val adId: String = "", // 广告ID(本地字段),不为空时为广告专题
val codeId: String = "", // 广告CODE_ID(本地字段),不为空时为广告专题
@SerializedName("ad_icon_active")
val adIconActive: Boolean = false
val adIconActive: Boolean = false,
// 本地字段标记是否为微信小游戏CPM专题
var isWGameSubjectCPM: Boolean = false
) : Parcelable {
fun getFilterGame() = RegionSettingHelper.filterGame(games)
}

View File

@ -63,6 +63,11 @@ class SubjectData(
/**
* 微信小游戏专题
*/
WECHAT_GAME
WECHAT_GAME,
/**
* 微信小游戏CPM专题
*/
WECHAT_GAME_CPM,
}
}

View File

@ -104,6 +104,8 @@ data class SubjectEntity(
@SerializedName("is_wechat_column")
var isWechatColumn: Boolean = false,
var isWechatColumnCPM: Boolean = false,
var explain: String = "", // 游戏单合集说明
@SerializedName("show_star")
@ -130,6 +132,7 @@ data class SubjectEntity(
val subjectType: SubjectData.SubjectType get() = when {
isQQColumn -> SubjectData.SubjectType.QQ_GAME
isWechatColumnCPM -> SubjectData.SubjectType.WECHAT_GAME_CPM
isWechatColumn -> SubjectData.SubjectType.WECHAT_GAME
else -> SubjectData.SubjectType.NORMAL
}

View File

@ -1,6 +1,12 @@
package com.gh.gamecenter.eventbus
class EBPackage(var type: String, var packageName: String, var versionName: String?) {
/**
* @param fromInit 实体生成是否来自于初始化
*/
class EBPackage(var type: String,
var packageName: String,
var versionName: String?,
val fromInit: Boolean = false) {
var gameId: String? = null
var isVGame: Boolean = false // 是否是畅玩游戏

View File

@ -709,7 +709,7 @@ class ForumDetailFragment : BaseLazyTabFragment(), IScrollable {
} else {
val fuliFragment = childFragmentManager.findFragmentByTag("${tag}$INDEX_TRENDS") ?: FuLiFragment()
fuliFragment.arguments = bundleOf(
EntranceConsts.KEY_GAME_ENTITY to game.toGameEntity(),
GameEntity.TAG to game.toGameEntity(),
EntranceConsts.KEY_ENTRANCE to mEntrance,
EntranceConsts.KEY_PATH to TAB_TRENDS
)

View File

@ -280,6 +280,7 @@ class FollowHomeFragment : LazyFragment(), IScrollable {
requireContext(),
it.id,
"",
-1,
traceEvent = it.exposureEvent
)
})

View File

@ -39,14 +39,14 @@ class ForumOrUserSearchDefaultFragment : SearchDefaultFragment() {
override fun initView() {
mBinding = FragmentSearchDefaultBinding.bind(mCachedView)
mBinding.searchDiscoveryTagHeadContainer.root.visibility = View.GONE
mBinding.searchDiscoveryTagFlexContainer.visibility = View.GONE
mBinding.hotTagHeadContainer.root.visibility = View.GONE
mBinding.hotTagFlexContainer.visibility = View.GONE
if (mEntrance == "论坛首页" || mEntrance == "搜索栏") {
mBinding.searchDiscoveryHeadContainer.headTitle.text = "热门论坛"
mBinding.hotHeadContainer.headTitle.text = "热门论坛"
mViewModel.getForumSearchHotContent()
} else {
mBinding.searchDiscoveryHeadContainer.root.visibility = View.GONE
mBinding.searchDiscoveryList.visibility = View.GONE
mBinding.hotHeadContainer.root.visibility = View.GONE
mBinding.hotList.visibility = View.GONE
}
val params = mBinding.historyHeadContainer.root.layoutParams as ConstraintLayout.LayoutParams
params.topMargin = 0.5f.dip2px()

View File

@ -611,7 +611,7 @@ class GameFragmentAdapter(
val subjectData = gameEntity.subjectData
DataCollectionUtils.uploadClick(mContext, subjectData?.name + "-列表", "游戏-专题", gameEntity.name)
if (gameEntity.isMiniGame()) {
MiniGameItemHelper.launchMiniGame(gameEntity.miniGameAppId, gameEntity.miniGameType)
MiniGameItemHelper.launchMiniGame(gameEntity)
} else {
GameDetailActivity.startGameDetailActivity(
mContext, gameEntity,
@ -1322,7 +1322,7 @@ class GameFragmentAdapter(
DataCollectionUtils.uploadClick(mContext, subjectData.name + "-列表", "游戏-专题", gameEntity.name)
if (gameEntity.isMiniGame()) {
MiniGameItemHelper.launchMiniGame(gameEntity.miniGameAppId, gameEntity.miniGameType)
MiniGameItemHelper.launchMiniGame(gameEntity)
} else if (gameEntity.isPluggable) {
GameDetailActivity.startGameDetailActivity(
mContext,

View File

@ -67,6 +67,8 @@ class ColumnCollectionDetailFragment : LazyListFragment<LinkEntity, ColumnCollec
}
private fun showSubjectTab(linkEntityList: MutableList<LinkEntity>) {
if (!isVisible) return
val subjectDataList = arrayListOf<SubjectData>()
for (link in linkEntityList) {

View File

@ -135,7 +135,7 @@ class GameGallerySlideViewHolder(val binding: GameGallerySlideItemBinding) : Bas
binding.iconIv.displayGameIcon(gameEntity)
binding.iconIv.setOnClickListener {
if (gameEntity.isMiniGame()) {
MiniGameItemHelper.launchMiniGame(gameEntity.miniGameAppId, gameEntity.miniGameType)
MiniGameItemHelper.launchMiniGame(gameEntity)
} else {
GameDetailActivity.startGameDetailActivity(
binding.root.context,

View File

@ -55,7 +55,7 @@ class GameGalleryViewHolder(val cell: GameGalleryItemCell) :
if (subjectEntity.isMiniGame) {
gameIcon.setOnClickListener {
MiniGameItemHelper.launchMiniGame(gameEntity.miniGameAppId, gameEntity.miniGameType)
MiniGameItemHelper.launchMiniGame(gameEntity)
}
} else {
gameIcon.setOnClickListener(null)

View File

@ -140,7 +140,7 @@ class GameHorizontalAdapter(
}
if (gameEntity.isMiniGame()) {
MiniGameItemHelper.launchMiniGame(gameEntity.miniGameAppId, gameEntity.miniGameType)
MiniGameItemHelper.launchMiniGame(gameEntity)
} else {
GameDetailActivity.startGameDetailActivity(
mContext,

View File

@ -68,7 +68,7 @@ class GameHorizontalSlideAdapter(
holder.bindGameHorizontalItem(gameEntity, mSubjectEntity)
holder.itemView.setOnClickListener {
if (gameEntity.isMiniGame()) {
MiniGameItemHelper.launchMiniGame(gameEntity.miniGameAppId, gameEntity.miniGameType)
MiniGameItemHelper.launchMiniGame(gameEntity)
} else {
val exposureEvent = exposureEventList?.safelyGetInRelease(position)
if (exposureEvent != null) {

View File

@ -45,7 +45,9 @@ import com.zhihu.matisse.Matisse
import com.zhihu.matisse.internal.utils.PathUtils
import io.reactivex.disposables.Disposable
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody
import java.io.File
import kotlin.collections.component1
import kotlin.collections.component2
@ -420,10 +422,8 @@ class GameUploadFragment : ToolbarFragment() {
requestMap["type"] = mGameType
}
val body = RequestBody.create(
MediaType.parse("application/json"),
GsonUtils.toJson(requestMap)
)
val body = GsonUtils.toJson(requestMap)
.toRequestBody("application/json".toMediaTypeOrNull())
mViewModel.uploadGames(body)
}

View File

@ -968,7 +968,7 @@ class GameCollectionDetailFragment :
// 安装/卸载 事件
@Subscribe(threadMode = ThreadMode.MAIN)
fun onEventMainThread(busFour: EBPackage) {
if (busFour.isInstalledOrUninstalled()) {
if (!busFour.fromInit && busFour.isInstalledOrUninstalled()) {
if (EBPackage.TYPE_INSTALLED == busFour.type
&& UserManager.getInstance().isLoggedIn
&& (mEntity?.count?.playedGame ?: 0) < (mEntity?.count?.game ?: 0)

View File

@ -7,6 +7,9 @@ import android.os.Handler
import android.os.Looper
import android.os.Message
import android.view.animation.AccelerateDecelerateInterpolator
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.recyclerview.widget.RecyclerView
import androidx.viewpager2.widget.ViewPager2
import com.gh.common.util.DirectUtils
@ -21,6 +24,17 @@ class GameCollectionAmwayViewHolder(var binding: GameCollectionSquareAmwayItemBi
private val mAdapter = GameCollectionAmwayAdapter(binding.root.context)
private val mLooperHandle = LooperHandle(this)
private val mSlideLooperKey = 333
private val mLifecycleObserver = object : DefaultLifecycleObserver {
override fun onResume(owner: LifecycleOwner) {
super.onResume(owner)
startAutoPlay()
}
override fun onPause(owner: LifecycleOwner) {
super.onPause(owner)
stopAutoPlay()
}
}
fun bindAmway(amwayList: List<AmwayCommentEntity>, viewModel: GameCollectionSquareViewModel) {
mAdapter.setAmwayList(amwayList)
@ -54,6 +68,14 @@ class GameCollectionAmwayViewHolder(var binding: GameCollectionSquareAmwayItemBi
mLooperHandle.removeMessages(mSlideLooperKey)
}
fun onViewAttach(lifecycle: Lifecycle) {
lifecycle.addObserver(mLifecycleObserver)
}
fun onViewDetach(lifecycle: Lifecycle) {
lifecycle.removeObserver(mLifecycleObserver)
}
fun ViewPager2.setCurrentItem(
item: Int,
duration: Long,

View File

@ -2,6 +2,7 @@ package com.gh.gamecenter.gamecollection.square
import android.content.Context
import android.view.ViewGroup
import androidx.lifecycle.LifecycleOwner
import androidx.recyclerview.widget.RecyclerView
import com.gh.common.exposure.ExposureManager
import com.gh.common.util.DirectUtils
@ -23,6 +24,7 @@ import com.lightgame.adapter.BaseRecyclerAdapter
class GameCollectionBannerAdapter(
context: Context,
private val mLifecycleOwner: LifecycleOwner,
private val mViewModel: GameCollectionSquareViewModel,
var mBannerList: List<CarouselEntity> = emptyList(),
private var mAmwayListItem: List<AmwayCommentEntity>? = null,
@ -78,6 +80,20 @@ class GameCollectionBannerAdapter(
return index
}
override fun onViewAttachedToWindow(holder: RecyclerView.ViewHolder) {
super.onViewAttachedToWindow(holder)
if (holder is GameCollectionAmwayViewHolder) {
holder.onViewAttach(mLifecycleOwner.lifecycle)
}
}
override fun onViewDetachedFromWindow(holder: RecyclerView.ViewHolder) {
super.onViewDetachedFromWindow(holder)
if (holder is GameCollectionAmwayViewHolder) {
holder.onViewDetach(mLifecycleOwner.lifecycle)
}
}
companion object {
const val ITEM_AMWAY = 100
const val ITEM_BANNER = 101

View File

@ -12,6 +12,9 @@ import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.PagerSnapHelper
import androidx.recyclerview.widget.RecyclerView
@ -47,6 +50,7 @@ import java.lang.ref.WeakReference
class GameCollectionSquareAdapter(
context: Context,
private val mLifecycleOwner: LifecycleOwner,
private val mIsHome: Boolean = false,
private val mFragment: GameCollectionSquareFragment,
private val mViewModel: GameCollectionSquareViewModel,
@ -157,7 +161,7 @@ class GameCollectionSquareAdapter(
when (holder) {
is GameCollectionHeaderItemViewHolder -> {
val itemData = mEntityList[position]
holder.bindHeader(itemData, mBasicExposureSource, mViewModel)
holder.bindHeader(mLifecycleOwner, itemData, mBasicExposureSource, mViewModel)
}
is GameCollectionFilterItemViewHolder -> holder.bindFilter(mFragment, mViewModel, mRefreshCallback)
@ -211,6 +215,20 @@ class GameCollectionSquareAdapter(
override fun getItemCount() =
if (mEntityList.isNullOrEmpty()) 0 else if (mIsHome && mEntityList.size == 2) mEntityList.size else mEntityList.size + 1
override fun onViewAttachedToWindow(holder: RecyclerView.ViewHolder) {
super.onViewAttachedToWindow(holder)
if (holder is GameCollectionHeaderItemViewHolder) {
holder.onViewAttach(mLifecycleOwner.lifecycle)
}
}
override fun onViewDetachedFromWindow(holder: RecyclerView.ViewHolder) {
super.onViewDetachedFromWindow(holder)
if (holder is GameCollectionHeaderItemViewHolder) {
holder.onViewDetach(mLifecycleOwner.lifecycle)
}
}
class GameCollectionHeaderItemViewHolder(val binding: ItemGameCollectionHeaderBinding) :
RecyclerView.ViewHolder(binding.root) {
private lateinit var mBannerAdapter: GameCollectionBannerAdapter
@ -218,8 +236,20 @@ class GameCollectionSquareAdapter(
private lateinit var mBannerLayoutManager: LinearLayoutManager
private val mLooperHandle = LooperHandle(this)
private val mSlideLooperKey = 111
private val mLifecycleObserver = object : DefaultLifecycleObserver {
override fun onResume(owner: LifecycleOwner) {
super.onResume(owner)
startAutoPlay()
}
override fun onPause(owner: LifecycleOwner) {
super.onPause(owner)
stopAutoPlay()
}
}
fun bindHeader(
lifecycleOwner: LifecycleOwner,
itemData: GameCollectionListItemData,
mBasicExposureSource: List<ExposureSource>,
viewModel: GameCollectionSquareViewModel
@ -249,6 +279,7 @@ class GameCollectionSquareAdapter(
mBannerLayoutManager = LinearLayoutManager(context, RecyclerView.HORIZONTAL, false)
mBannerAdapter = GameCollectionBannerAdapter(
context,
lifecycleOwner,
viewModel,
bannerList,
amwayListItem,
@ -345,6 +376,14 @@ class GameCollectionSquareAdapter(
mLooperHandle.removeMessages(mSlideLooperKey)
}
fun onViewAttach(lifecycle: Lifecycle) {
lifecycle.addObserver(mLifecycleObserver)
}
fun onViewDetach(lifecycle: Lifecycle) {
lifecycle.removeObserver(mLifecycleObserver)
}
class LooperHandle(viewHolder: GameCollectionHeaderItemViewHolder) : Handler(Looper.getMainLooper()) {
private val mWeakReference: WeakReference<GameCollectionHeaderItemViewHolder> = WeakReference(viewHolder)

View File

@ -138,6 +138,7 @@ class GameCollectionSquareFragment : LazyListFragment<GamesCollectionEntity, Gam
mGuideContainer?.visibility = View.GONE
} else {
if (mExposureEventList.isNotEmpty()) ExposureManager.log(mExposureEventList)
stopAutoPlay()
}
val stayTime = (System.currentTimeMillis() - startPageTime) / 1000
NewFlatLogUtils.logGameCollectSquareStayTime(stayTime, if (mUseAlternativeLayout) "首页tab栏" else "游戏单广场")
@ -175,6 +176,8 @@ class GameCollectionSquareFragment : LazyListFragment<GamesCollectionEntity, Gam
)
)
}
} else {
startAutoPlay()
}
mElapsedHelper.resetCounting()
mElapsedHelper.resumeCounting()
@ -270,6 +273,7 @@ class GameCollectionSquareFragment : LazyListFragment<GamesCollectionEntity, Gam
mAdapter =
GameCollectionSquareAdapter(
requireContext(),
viewLifecycleOwner,
mUseAlternativeLayout,
this,
mViewModel,
@ -382,6 +386,7 @@ class GameCollectionSquareFragment : LazyListFragment<GamesCollectionEntity, Gam
val bannerAdapter = GameCollectionBannerAdapter(
requireContext(),
viewLifecycleOwner,
mViewModel,
mEntrance = "游戏单广场",
mBasicExposureSource = mBasicExposureSourceList
@ -515,7 +520,8 @@ class GameCollectionSquareFragment : LazyListFragment<GamesCollectionEntity, Gam
}
private fun startAutoPlay() {
if ((mDefaultBinding.headerContainer.bannerRv.adapter as GameCollectionBannerAdapter).getActualSize() <= 1) return
val bannerAdapter = mDefaultBinding.headerContainer.bannerRv.adapter as? GameCollectionBannerAdapter
if (bannerAdapter == null || bannerAdapter.getActualSize() <= 1) return
stopAutoPlay()
mLooperHandle.sendEmptyMessageDelayed(mSlideLooperKey, BANNER_LOOP_TIME)
}

View File

@ -438,7 +438,7 @@ class GameDetailFragment : BaseLazyFragment(), IScrollable {
val args = arguments ?: Bundle()
mAutoDownload = args.getBoolean(EntranceConsts.KEY_AUTO_DOWNLOAD)
mTraceEvent = args.getParcelable(EntranceConsts.KEY_TRACE_EVENT)
mSkipGameComment = args.getBoolean(EntranceConsts.KEY_COMMENT_AS_DEFAULT_TAB)
mSkipGameComment = args.getBoolean(EntranceConsts.KEY_SKIP_GAME_COMMENT)
mIsOpenPlatformWindow = args.getBoolean(EntranceConsts.KEY_OPEN_PLATFORM_WINDOW)
mSkeleton = Skeleton.bind(mBinding.listSkeleton)
@ -451,11 +451,11 @@ class GameDetailFragment : BaseLazyFragment(), IScrollable {
.load(R.layout.fragment_gamedetail_skeleton)
.show()
val gameId = args.getString(EntranceConsts.KEY_GAME_ID) ?: ""
val gameId = args.getString(EntranceConsts.KEY_GAMEID) ?: ""
val factory = GameDetailViewModel.Factory(
HaloApp.getInstance().application,
gameId,
args.getParcelable(EntranceConsts.KEY_GAME_ENTITY)
args.getParcelable(GameEntity.TAG)
)
mViewModel = viewModelProviderFromParent(factory, gameId)
mPackageViewModel = viewModelProvider(PackageViewModel.Factory())
@ -464,8 +464,8 @@ class GameDetailFragment : BaseLazyFragment(), IScrollable {
mBodyBinding.gamedetailVp.doOnPageSelected { position ->
if (!isAdded) return@doOnPageSelected
val bbsPosition = getTabPositionFromTabType(EntranceConsts.TAB_TYPE_BBS)
val trendsPosition = getTabPositionFromTabType(EntranceConsts.TAB_TYPE_TRENDS)
val bbsPosition = getTabPositionFromTabType(TAB_BBS)
val trendsPosition = getTabPositionFromTabType(TAB_TRENDS)
if (mNewGameDetailEntity?.bbsTab != null && position == bbsPosition) {
DirectUtils.directToLinkPage(
@ -482,7 +482,7 @@ class GameDetailFragment : BaseLazyFragment(), IScrollable {
}, 200)
} else if (mNewGameDetailEntity?.zone != null && mNewGameDetailEntity?.zone?.style != "default" && position == trendsPosition && mNewGameDetailEntity?.bbsTab != null) {
// 跳转论坛-专区
val entrance = if (mDestinationTab == getTabPositionFromTabType(EntranceConsts.TAB_TYPE_TRENDS)) {
val entrance = if (mDestinationTab == getTabPositionFromTabType(TAB_TRENDS)) {
if (mEntrance.contains("搜索")) "搜索页面" else "其他"
} else "游戏详情页"
mNewGameDetailEntity?.bbsTab?.link?.let {
@ -839,7 +839,7 @@ class GameDetailFragment : BaseLazyFragment(), IScrollable {
DetailDownloadUtils.updateViewHolder(viewHolder)
mDestinationTab =
getTabPositionFromTabType(arguments?.getString(EntranceConsts.KEY_TARGET, EntranceConsts.TAB_TYPE_DESC) ?: EntranceConsts.TAB_TYPE_DESC)
getTabPositionFromTabType(arguments?.getString(EntranceConsts.KEY_TARGET, TAB_DESC) ?: TAB_DESC)
// destinationTab 的优先级最高,关注和关联关注在它的后面
if (mDestinationTab != -1) {
@ -1015,7 +1015,7 @@ class GameDetailFragment : BaseLazyFragment(), IScrollable {
}
val bundle = Bundle()
bundle.putParcelable(EntranceConsts.KEY_GAME_ENTITY, mGameEntity)
bundle.putParcelable(GameEntity.TAG, mGameEntity)
bundle.putString(EntranceConsts.KEY_ENTRANCE, mEntrance)
bundle.putBoolean(EntranceConsts.KEY_SCROLL_TO_LIBAO, scrollToLibao)
bundle.putBoolean(EntranceConsts.KEY_SCROLL_TO_SERVER, scrollToServer)
@ -1031,21 +1031,21 @@ class GameDetailFragment : BaseLazyFragment(), IScrollable {
mTabTitleList.clear()
val tag = "android:switcher:${mBodyBinding.gamedetailVp.id}:"
val descFragment = childFragmentManager.findFragmentByTag("${tag}${EntranceConsts.TAB_TYPE_DESC}") ?: DescFragment()
val descFragment = childFragmentManager.findFragmentByTag("${tag}$TAB_DESC") ?: DescFragment()
descFragment.arguments = bundle
mFragmentsList.add(descFragment)
mTabTitleList.add(getString(R.string.game_detail_desc))
mTabTypeList.add(EntranceConsts.TAB_TYPE_DESC)
mTabTypeList.add(TAB_DESC)
if (data.showArchive) {
val cloudArchiveFragment =
childFragmentManager.findFragmentByTag("${tag}${EntranceConsts.TAB_TYPE_ARCHIVE}") ?: CloudArchiveFragment()
childFragmentManager.findFragmentByTag("${tag}${TAB_ARCHIVE}") ?: CloudArchiveFragment()
bundle.putParcelable(EntranceConsts.KEY_GAME, mGameEntity ?: GameEntity())
bundle.putString(EntranceConsts.KEY_ARCHIVE_CONFIG_URL, data.archiveTab.configUrl)
cloudArchiveFragment.arguments = bundle
mFragmentsList.add(cloudArchiveFragment)
mTabTitleList.add(getString(R.string.game_detail_cloud_archive))
mTabTypeList.add(EntranceConsts.TAB_TYPE_ARCHIVE)
mTabTypeList.add(TAB_ARCHIVE)
NewFlatLogUtils.logCloudArchiveGameDetailTabRelated(
"cloud_save_tab_show",
@ -1055,13 +1055,13 @@ class GameDetailFragment : BaseLazyFragment(), IScrollable {
}
if (data.showComment) {
val ratingFragment = childFragmentManager.findFragmentByTag("${tag}${EntranceConsts.TAB_TYPE_RATING}") ?: RatingFragment()
bundle.putBoolean(EntranceConsts.KEY_COMMENT_AS_DEFAULT_TAB, mSkipGameComment)
val ratingFragment = childFragmentManager.findFragmentByTag("${tag}${TAB_RATING}") ?: RatingFragment()
bundle.putBoolean(EntranceConsts.KEY_SKIP_GAME_COMMENT, mSkipGameComment)
bundle.putBoolean(EntranceConsts.KEY_DIRECT_COMMENT, data.directComment)
ratingFragment.arguments = bundle
mFragmentsList.add(ratingFragment)
mTabTitleList.add(getString(R.string.game_detail_comment))
mTabTypeList.add(EntranceConsts.TAB_TYPE_RATING)
mTabTypeList.add(TAB_RATING)
}
data.zone?.let {
@ -1072,7 +1072,7 @@ class GameDetailFragment : BaseLazyFragment(), IScrollable {
mFragmentsList.add(Fragment())
} else if (it.style == "link") {
//显示web页面
val webFragment = childFragmentManager.findFragmentByTag("${tag}${EntranceConsts.TAB_TYPE_TRENDS}") ?: WebFragment()
val webFragment = childFragmentManager.findFragmentByTag("${tag}${TAB_TRENDS}") ?: WebFragment()
val webBundle = Bundle()
webBundle.putString(EntranceConsts.KEY_ENTRANCE, "游戏专区")
webBundle.putString(EntranceConsts.KEY_URL, it.link)
@ -1080,7 +1080,7 @@ class GameDetailFragment : BaseLazyFragment(), IScrollable {
webFragment.arguments = webBundle
mFragmentsList.add(webFragment)
} else {
val fuliFragment = childFragmentManager.findFragmentByTag("${tag}${EntranceConsts.TAB_TYPE_TRENDS}") ?: FuLiFragment()
val fuliFragment = childFragmentManager.findFragmentByTag("${tag}${TAB_TRENDS}") ?: FuLiFragment()
fuliFragment.arguments = bundle
mFragmentsList.add(fuliFragment)
}
@ -1089,7 +1089,7 @@ class GameDetailFragment : BaseLazyFragment(), IScrollable {
} else {
mTabTitleList.add(getString(R.string.game_detail_dongtai))
}
mTabTypeList.add(EntranceConsts.TAB_TYPE_TRENDS)
mTabTypeList.add(TAB_TRENDS)
}
var isShowBbs = true
@ -1103,7 +1103,7 @@ class GameDetailFragment : BaseLazyFragment(), IScrollable {
if (isShowBbs && mGameEntity?.shouldUseMirrorInfo() == false) {
mFragmentsList.add(Fragment())
mTabTitleList.add(getString(R.string.game_detail_bbs))
mTabTypeList.add(EntranceConsts.TAB_TYPE_BBS)
mTabTypeList.add(TAB_BBS)
}
}
@ -1116,7 +1116,7 @@ class GameDetailFragment : BaseLazyFragment(), IScrollable {
gamedetailVp.doOnPageSelected {
logTabClick(it)
}
gamedetailVp.currentItem = getTabPositionFromTabType(EntranceConsts.TAB_TYPE_DESC)
gamedetailVp.currentItem = getTabPositionFromTabType(TAB_DESC)
mBodyBinding.tabLayout.setupWithViewPager(gamedetailVp)
mBodyBinding.tabIndicator.setupWithTabLayout(mBodyBinding.tabLayout)
@ -1125,7 +1125,7 @@ class GameDetailFragment : BaseLazyFragment(), IScrollable {
for (i in 0 until mBodyBinding.tabLayout.tabCount) {
val tab = mBodyBinding.tabLayout.getTabAt(i) ?: continue
val tabTitle = if (tab.text != null) tab.text.toString() else ""
if (data.showArchive && i == getTabPositionFromTabType(EntranceConsts.TAB_TYPE_ARCHIVE)) {
if (data.showArchive && i == getTabPositionFromTabType(TAB_ARCHIVE)) {
tab.customView = getArchiveTabView(tabTitle)
tab.view.run {
clipChildren = false
@ -1258,7 +1258,7 @@ class GameDetailFragment : BaseLazyFragment(), IScrollable {
if (mNewGameDetailEntity!!.showComment) {
if (mSkipGameComment) {
tabPerformClick(getTabPositionFromTabType(EntranceConsts.TAB_TYPE_RATING))
tabPerformClick(getTabPositionFromTabType(TAB_RATING))
mBodyBinding.gamedetailAppbar.setExpanded(false)
mSkipGameComment = false
}
@ -1759,13 +1759,13 @@ class GameDetailFragment : BaseLazyFragment(), IScrollable {
@Subscribe(threadMode = ThreadMode.MAIN)
fun onEventMainThread(reuse: EBReuse) {
if (SKIP_DESC == reuse.type) {
tabPerformClick(getTabPositionFromTabType(EntranceConsts.TAB_TYPE_DESC))
tabPerformClick(getTabPositionFromTabType(TAB_DESC))
} else if (OPEN_APPBAR == reuse.type && !mIsTouchScreen) {
mBodyBinding.gamedetailAppbar.setExpanded(true, true)
} else if (SKIP_FULI == reuse.type) {
tabPerformClick(getTabPositionFromTabType(EntranceConsts.TAB_TYPE_TRENDS))
tabPerformClick(getTabPositionFromTabType(TAB_TRENDS))
} else if (SKIP_RATING == reuse.type) {
tabPerformClick(getTabPositionFromTabType(EntranceConsts.TAB_TYPE_RATING))
tabPerformClick(getTabPositionFromTabType(TAB_RATING))
} else if (CLOSE_APPBAR == reuse.type && !mIsTouchScreen) {
mBodyBinding.gamedetailAppbar.setExpanded(false, true)
} else if ("download" == reuse.type) {
@ -2012,8 +2012,8 @@ class GameDetailFragment : BaseLazyFragment(), IScrollable {
}
private fun tabPerformClick(position: Int) {
val trendsTabPosition = getTabPositionFromTabType(EntranceConsts.TAB_TYPE_TRENDS)
val bbsTabPosition = getTabPositionFromTabType(EntranceConsts.TAB_TYPE_BBS)
val trendsTabPosition = getTabPositionFromTabType(TAB_TRENDS)
val bbsTabPosition = getTabPositionFromTabType(TAB_BBS)
when (position) {
trendsTabPosition -> {
@ -2023,7 +2023,7 @@ class GameDetailFragment : BaseLazyFragment(), IScrollable {
) {
performJumpContentCard("func_zone", position)
} else {
mBodyBinding.gamedetailVp.currentItem = getTabPositionFromTabType(EntranceConsts.TAB_TYPE_TRENDS)
mBodyBinding.gamedetailVp.currentItem = getTabPositionFromTabType(TAB_TRENDS)
}
}
@ -2031,7 +2031,7 @@ class GameDetailFragment : BaseLazyFragment(), IScrollable {
if (!mTabTitleList.contains(getString(R.string.game_detail_bbs))) {
performJumpContentCard("func_bbs", position)
} else {
mBodyBinding.gamedetailVp.currentItem = getTabPositionFromTabType(EntranceConsts.TAB_TYPE_BBS)
mBodyBinding.gamedetailVp.currentItem = getTabPositionFromTabType(TAB_BBS)
}
}
@ -2072,11 +2072,11 @@ class GameDetailFragment : BaseLazyFragment(), IScrollable {
val entrance = if (mEntrance.contains("论坛详情")) "论坛" else "游戏"
mGameEntity?.run {
when (mTabTypeList[position]) {
EntranceConsts.TAB_TYPE_DESC -> {
TAB_DESC -> {
NewLogUtils.logGameDetailTabClick(name ?: "", id, "详情")
}
EntranceConsts.TAB_TYPE_TRENDS -> {
TAB_TRENDS -> {
NewLogUtils.logGameDetailTabClick(
"view_game_detail_special_area_tab",
entrance,
@ -2087,7 +2087,7 @@ class GameDetailFragment : BaseLazyFragment(), IScrollable {
NewLogUtils.logGameDetailTabClick(name ?: "", id, "专区")
}
EntranceConsts.TAB_TYPE_ARCHIVE -> {
TAB_ARCHIVE -> {
NewFlatLogUtils.logCloudArchiveGameDetailTabRelated(
"cloud_save_tab_click",
mGameEntity?.id ?: "",
@ -2106,12 +2106,12 @@ class GameDetailFragment : BaseLazyFragment(), IScrollable {
)
}
EntranceConsts.TAB_TYPE_RATING -> {
TAB_RATING -> {
NewLogUtils.logGameDetailTabClick("view_game_detail_comment_tab", entrance, id, gameType, bbsId)
NewLogUtils.logGameDetailTabClick(name ?: "", id, "评论")
}
EntranceConsts.TAB_TYPE_BBS -> {
TAB_BBS -> {
NewLogUtils.logGameDetailTabClick(name ?: "", id, "论坛")
}
}
@ -2367,7 +2367,7 @@ class GameDetailFragment : BaseLazyFragment(), IScrollable {
private fun updateArchiveTabUI() {
mBodyBinding.tabLayout.run {
val archivePosition = getTabPositionFromTabType(EntranceConsts.TAB_TYPE_ARCHIVE)
val archivePosition = getTabPositionFromTabType(TAB_ARCHIVE)
getTabAt(archivePosition)?.customView?.findViewById<ImageView>(R.id.newIv)?.visibility = View.VISIBLE
}
}
@ -2384,7 +2384,7 @@ class GameDetailFragment : BaseLazyFragment(), IScrollable {
override fun onBackPressed(): Boolean {
mOrientationUtils?.backToProtVideo()
val trendsTabPosition = getTabPositionFromTabType(EntranceConsts.TAB_TYPE_TRENDS)
val trendsTabPosition = getTabPositionFromTabType(TAB_TRENDS)
if (mBodyBinding.gamedetailVp.currentItem == trendsTabPosition
&& mFragmentsList[trendsTabPosition] is WebFragment
@ -2647,6 +2647,12 @@ class GameDetailFragment : BaseLazyFragment(), IScrollable {
}
companion object {
const val TAB_DESC = "详情"
const val TAB_TRENDS = "专区"
const val TAB_ARCHIVE = "云存档"
const val TAB_RATING = "评价"
const val TAB_BBS = "论坛"
const val SKIP_DESC = "skipDesc"
const val SKIP_FULI = "skipFuli"
const val SKIP_RATING = "skipRatting"

View File

@ -116,7 +116,7 @@ class DescFragment: LazyFragment(), IScrollable {
}
override fun onFragmentFirstVisible() {
mGameEntity = arguments?.getParcelable(EntranceConsts.KEY_GAME_ENTITY)
mGameEntity = arguments?.getParcelable(GameEntity.TAG)
openVideoStreaming = arguments?.getBoolean(EntranceConsts.KEY_OPEN_VIDEO_STREAMING, false) ?: false
mScrollToLibao = arguments?.getBoolean(EntranceConsts.KEY_SCROLL_TO_LIBAO, false) ?: false
mScrollToServer = arguments?.getBoolean(EntranceConsts.KEY_SCROLL_TO_SERVER, false) ?: false

View File

@ -394,7 +394,7 @@ class SpecialDownloadDialogFragment : BaseDraggableDialogFragment() {
SensorsBridge.trackDownloadComponentsContentClick(
gameId = gameEntity.id,
gameName = gameEntity.name ?: "unknown",
gameSchemeType = gameEntity.gameBitChinese,
gameSchemaType = gameEntity.gameBitChinese,
downloadStatus = gameEntity.downloadStatusChinese,
gameType = gameEntity.categoryChinese,
downloadType = if (asVGame) "畅玩下载" else "本地下载",
@ -405,7 +405,7 @@ class SpecialDownloadDialogFragment : BaseDraggableDialogFragment() {
SensorsBridge.trackDownloadComponentsShow(
gameId = gameEntity.id,
gameName = gameEntity.name ?: "unknown",
gameSchemeType = gameEntity.gameBitChinese,
gameSchemaType = gameEntity.gameBitChinese,
downloadStatus = gameEntity.downloadStatusChinese,
gameType = gameEntity.categoryChinese,
downloadType = if (asVGame) "畅玩下载" else "本地下载",

View File

@ -59,7 +59,7 @@ class FuLiFragment : LazyFragment(), IScrollable {
}
override fun onFragmentFirstVisible() {
val gameEntity = arguments?.getParcelable(EntranceConsts.KEY_GAME_ENTITY) as? GameEntity
val gameEntity = arguments?.getParcelable(GameEntity.TAG) as? GameEntity
val gameDetailFactory =
GameDetailViewModel.Factory(HaloApp.getInstance().application, gameEntity?.id, gameEntity)
shouldScroolToLibao = arguments?.getBoolean(EntranceConsts.KEY_SCROLL_TO_LIBAO) ?: false

View File

@ -52,6 +52,7 @@ class GameDetailAnswerAdapter(
val path = "游戏详情-动态"
holder.bindAnswerItem(entity, mEntrance, path)
holder.binding.title.setOnClickListener {
HaloApp.put(Constants.GAME_DETAIL_COME_IN, true)
MtaHelper.onEvent("进入问答", "游戏详情", mViewModel.gameCommunity?.name + "+" + mViewModel.game?.name)
if ("community_article" == entity.type) {
MtaHelper.onEvent("游戏详情_新", "点击社区文章", mViewModel.game?.name + "+" + entity.questions.title)
@ -80,6 +81,7 @@ class GameDetailAnswerAdapter(
}
holder.itemView.setOnClickListener {
HaloApp.put(Constants.GAME_DETAIL_COME_IN, true)
MtaHelper.onEvent("进入问答", "游戏详情", mViewModel.gameCommunity?.name + "+" + mViewModel.game?.name)
if ("community_article" == entity.type) {
MtaHelper.onEvent("游戏详情_新", "点击社区文章", mViewModel.game?.name + "+" + entity.questions.title)

View File

@ -18,7 +18,7 @@ class RatingFoldActivity : ToolBarActivity() {
@JvmStatic
fun getIntent(context: Context, game: GameEntity, entrance: String, path: String): Intent {
val bundle = Bundle()
bundle.putParcelable(EntranceConsts.KEY_GAME_ENTITY, game)
bundle.putParcelable(GameEntity.TAG, game)
bundle.putString(EntranceConsts.KEY_ENTRANCE, mergeEntranceAndPath(entrance, path))
bundle.putSerializable(EntranceConsts.KEY_LOCATION, RatingViewModel.RatingType.FOLD_RATING)
return getTargetIntent(context, RatingFoldActivity::class.java, RatingFragment::class.java, bundle)

View File

@ -91,7 +91,7 @@ class RatingFragment : LazyListFragment<RatingComment, RatingViewModel>(), IScro
override fun provideListViewModel(): RatingViewModel {
val factory = RatingViewModel.Factory(
HaloApp.getInstance().application,
arguments?.getParcelable(EntranceConsts.KEY_GAME_ENTITY)!!, mRatingType!!
arguments?.getParcelable(GameEntity.TAG)!!, mRatingType!!
)
return ViewModelProviders.of(this, factory).get(RatingViewModel::class.java)
}
@ -109,7 +109,7 @@ class RatingFragment : LazyListFragment<RatingComment, RatingViewModel>(), IScro
override fun onFragmentPause() {
super.onFragmentPause()
val game = arguments?.getParcelable<GameEntity>(EntranceConsts.KEY_GAME_ENTITY)
val game = arguments?.getParcelable<GameEntity>(GameEntity.TAG)
val stayTime = (System.currentTimeMillis() - startPageTime) / 1000
NewLogUtils.logGameDetailTabOrCommentDetailPause(
"jump_game_detail_comment_tab",
@ -128,7 +128,7 @@ class RatingFragment : LazyListFragment<RatingComment, RatingViewModel>(), IScro
super.onFragmentFirstVisible()
val horizontalPadding = com.gh.gamecenter.common.R.dimen.game_detail_item_horizontal_padding.toPx()
mSkipGameComment = arguments?.getBoolean(EntranceConsts.KEY_COMMENT_AS_DEFAULT_TAB)
mSkipGameComment = arguments?.getBoolean(EntranceConsts.KEY_SKIP_GAME_COMMENT)
mListRv?.setPadding(horizontalPadding, 0, horizontalPadding, 0)
mListRefresh?.setBackgroundColor(ContextCompat.getColor(requireContext(), com.gh.gamecenter.common.R.color.transparent))
mListRefresh?.isEnabled = mRatingType != RatingViewModel.RatingType.RATING

View File

@ -45,7 +45,9 @@ import com.gh.gamecenter.login.user.UserManager
import com.halo.assistant.HaloApp
import com.lightgame.utils.Utils
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody
import org.json.JSONObject
import retrofit2.HttpException
@ -131,7 +133,7 @@ class RatingEditActivity : ToolBarActivity(), KeyboardHeightObserver {
return
}
setToolbarMenu(R.menu.menu_game_comment)
mGame = intent.getParcelableExtra(EntranceConsts.KEY_GAME_ENTITY) ?: GameEntity(id = "")
mGame = intent.getParcelableExtra(GameEntity.TAG) ?: GameEntity(id = "")
mFromAmway = intent.getBooleanExtra(EntranceConsts.KEY_AMWAY, false)
mIsSkipSuccessPage = intent.getBooleanExtra(EntranceConsts.KEY_SKIP_SUCCESS_PAGE, false)
mComment = intent.getParcelableExtra(RatingComment::class.java.simpleName)
@ -541,7 +543,7 @@ class RatingEditActivity : ToolBarActivity(), KeyboardHeightObserver {
jsonObject.put("rom", MetaUtil.getRom().name + " " + MetaUtil.getRom().versionName)
jsonObject.put("again", again)
val body = RequestBody.create(MediaType.parse("application/json"), jsonObject.toString())
val body = jsonObject.toString().toRequestBody("application/json".toMediaTypeOrNull())
CheckLoginUtils.checkLogin(this, mEntrance) {
mViewModel.postGameComment(mComment?.id ?: "", body)
@ -659,7 +661,7 @@ class RatingEditActivity : ToolBarActivity(), KeyboardHeightObserver {
isSkipSuccessPage: Boolean = true
): Intent {
val intent = Intent(context, RatingEditActivity::class.java)
intent.putExtra(EntranceConsts.KEY_GAME_ENTITY, game)
intent.putExtra(GameEntity.TAG, game)
intent.putExtra(EntranceConsts.KEY_RATING_STAR_COUNT, starCount)
intent.putExtra(EntranceConsts.KEY_AMWAY, fromAmway)
intent.putExtra(EntranceConsts.KEY_SKIP_SUCCESS_PAGE, isSkipSuccessPage)
@ -670,7 +672,7 @@ class RatingEditActivity : ToolBarActivity(), KeyboardHeightObserver {
fun getPatchIntent(context: Context, game: GameEntity, comment: RatingComment): Intent {
val intent = Intent(context, RatingEditActivity::class.java)
intent.putExtra(EntranceConsts.KEY_GAME_ENTITY, game)
intent.putExtra(GameEntity.TAG, game)
intent.putExtra(RatingComment::class.java.simpleName, comment)
return intent
}

View File

@ -97,7 +97,7 @@ class HomeGameItemViewHolder(val binding: HomeGameItemBinding) : BaseRecyclerVie
}
holder.itemView.setOnClickListener {
if (game.isMiniGame()) {
MiniGameItemHelper.launchMiniGame(game.miniGameAppId, game.miniGameType)
MiniGameItemHelper.launchMiniGame(game)
} else {
GameDetailActivity.startGameDetailActivity(
binding.root.context,

View File

@ -140,7 +140,7 @@ class CustomPageFragment : LazyFragment(), ISmartRefreshContent, IScrollable {
searchToolbarTabWrapperViewModel =
viewModelProviderFromParent(
SearchToolbarTabWrapperViewModel.Factory(multiTabNavId, noTabLinkId),
multiTabNavId
multiTabNavId + noTabLinkId
)
}
if (bottomTabId.isNotEmpty()) {
@ -292,13 +292,14 @@ class CustomPageFragment : LazyFragment(), ISmartRefreshContent, IScrollable {
gameDetailDestination.observe(viewLifecycleOwner, EventObserver { (entrance, game) ->
if (game.isMiniGame()) {
MiniGameItemHelper.launchMiniGame(game.miniGameAppId, game.miniGameType)
MiniGameItemHelper.launchMiniGame(game)
} else {
GameDetailActivity.startGameDetailActivity(
requireContext(),
game.id,
entrance,
traceEvent = game.exposureEvent,
-1,
traceEvent = game.exposureEvent
)
}
@ -401,7 +402,8 @@ class CustomPageFragment : LazyFragment(), ISmartRefreshContent, IScrollable {
requireContext(),
gameId = gameId,
entrance = "自定义页面",
traceEvent = exposureEvent,
defaultTab = -1,
traceEvent = exposureEvent
)
})

View File

@ -78,6 +78,7 @@ class CustomPageViewModel(
addSource(repository.customDiscoverItemLiveData, ::notifyItemChanged)
addSource(repository.recentGamesItemLiveData, ::notifyItemChanged)
addSource(repository.customPluginItemLiveData, ::notifyItemChanged)
addSource(repository.wechatMiniGameCPMItemLiveData, ::notifyWechatMiniGameCPMSubjectItemChanged)
}
val dataList: LiveData<List<CustomPageItem>> = _dataList
@ -357,11 +358,11 @@ class CustomPageViewModel(
}
}
override fun onChangeABatch(subjectEntity: SubjectEntity, position: Int) {
override fun onChangeABatch(subjectEntity: SubjectEntity) {
val subjectId = subjectEntity.id ?: return
val gameList = subjectChangedMap[subjectId]
if (gameList != null) {
changeSubjectCustomPageItem(position, getRandomGameList(subjectEntity.data, ArrayList(gameList)))
changeSubjectCustomPageItem(subjectId, getRandomGameList(subjectEntity.data, ArrayList(gameList)))
} else {
repository.loadChangeSubjectGame(subjectEntity)
.subscribeOn(Schedulers.io())
@ -370,7 +371,7 @@ class CustomPageViewModel(
override fun onResponse(response: List<GameEntity>?) {
if (response != null) {
subjectChangedMap[subjectId] = response
onChangeABatch(subjectEntity, position)
onChangeABatch(subjectEntity)
}
}
@ -396,21 +397,32 @@ class CustomPageViewModel(
return resultGameList
}
private fun changeSubjectCustomPageItem(position: Int, newGameList: MutableList<GameEntity>) {
private fun changeSubjectCustomPageItem(id: String, newGameList: MutableList<GameEntity>) {
val oldData = _dataList.value as? MutableList<CustomPageItem>
if (!oldData.isNullOrEmpty() && newGameList.isNotEmpty()) {
val newData = oldData?.toMutableList()
if (!newData.isNullOrEmpty() && newGameList.isNotEmpty()) {
// 替换当前专题游戏数据
val customPageItem = oldData.getOrNull(position)
val position = newData.indexOfFirst {
when(it) {
is CustomSubjectItem -> it.data.id == id
is CustomSplitSubjectItem -> it.data.id == id
else -> false
}
}
if (position == -1) return
val customPageItem = newData[position]
if (customPageItem is CustomSubjectItem) {
val newCustomPageItem = customPageItem.copy(data = customPageItem.data.copy(mData = newGameList))
oldData[position] = newCustomPageItem
val newCustomPageItem =
customPageItem.copy(data = customPageItem.data.copy(mData = newGameList), _position = position)
newData[position] = newCustomPageItem
gamePositionAndPackageHelper.putAll(getPositionAndPackageMap(newCustomPageItem, newGameList))
}
if (customPageItem is CustomSplitSubjectItem) {
// 移除所有旧数据
oldData.removeAll {
newData.removeAll {
it.componentPosition == customPageItem.componentPosition
}
@ -433,21 +445,15 @@ class CustomPageViewModel(
)
// 将新的 items 添加到列表集合
if (position >= oldData.size) {
oldData.addAll(newItems)
} else {
oldData.addAll(position, newItems)
}
newData.addAll(position, newItems)
// 修正集合中 item 的position 取值
oldData.forEachIndexed { index, item ->
newData.forEachIndexed { index, item ->
item.position = index
}
}
// 通知更新
_dataList.value = oldData
_dataList.value = newData
}
}
@ -467,6 +473,40 @@ class CustomPageViewModel(
}
}
/**
* 通过CPM接口异步请求获取的微信小游戏数据插入
*/
private fun notifyWechatMiniGameCPMSubjectItemChanged(result: Pair<String, List<GameEntity>>) {
val oldData = _dataList.value ?: return
val index = oldData.indexOfFirst {
it is CustomWeChatMiniGamesCPMSubjectItem && it.data.id == result.first
}
if (index == -1) return
val subjectItem = (oldData[index] as CustomWeChatMiniGamesCPMSubjectItem).apply {
data.data = result.second.toMutableList()
data.isWechatColumnCPM = true
}
val position = subjectItem.position
val componentPosition = subjectItem.componentPosition
val newData = oldData.toMutableList()
val customPageItemList = repository.convertColumnDetailSubjectItems(
position,
componentPosition,
subjectItem.link,
subjectItem.data
)
if (customPageItemList.isEmpty()) return
newData[index] = customPageItemList[0]
newData.addAll(index + 1, customPageItemList.subList(1, customPageItemList.size))
newData.forEachIndexed { pos, customPageItem ->
customPageItem.position = pos
}
repository.notifyPositionChanged(newData.size)
gamePositionAndPackageHelper.clear()
gamePositionAndPackageHelper.putAll(getPositionAndPackageMap(newData))
_dataList.value = newData
}
private fun notifyItemRemoved(removeItem: CustomPageItem) {
val oldData = _dataList.value ?: return
val newData = oldData.toMutableList()
@ -476,7 +516,7 @@ class CustomPageViewModel(
for (i in removeItem.position until newData.size) {
newData[i].position--
}
repository.notifyPositionChanged(-1)
repository.notifyPositionAdded(-1)
gamePositionAndPackageHelper.clear()
gamePositionAndPackageHelper.putAll(getPositionAndPackageMap(newData))
_dataList.value = newData

View File

@ -134,7 +134,7 @@ class CustomGameHorizontalAdapter(
}
if (gameEntity.isMiniGame()) {
MiniGameItemHelper.launchMiniGame(gameEntity.miniGameAppId, gameEntity.miniGameType)
MiniGameItemHelper.launchMiniGame(gameEntity)
} else {
GameDetailActivity.startGameDetailActivity(
context,

View File

@ -29,7 +29,7 @@ interface OnCustomPageEventListener {
/**
* 换一批
*/
fun onChangeABatch(subjectEntity: SubjectEntity, position: Int)
fun onChangeABatch(subjectEntity: SubjectEntity)
fun onChangeAppBarColor(color: Int)

View File

@ -39,7 +39,7 @@ class SubjectEventHelper(viewModel: CustomPageViewModel) : CustomPageItemChildEv
fun onChangeABatch(subject: SubjectEntity) {
tracker.trackColumnClick(_item, null, "右上角", "换一批")
viewModel.onChangeABatch(subject, _item.position)
viewModel.onChangeABatch(subject)
}
fun onMoreClick(link: LinkEntity) {

View File

@ -73,6 +73,8 @@ class CustomPageData(
val qqMiniGameColumn: SubjectEntity? = null,
@SerializedName("link_wechat_game_column_detail")
val wechatMiniGameColumn: SubjectEntity? = null,
@SerializedName("link_wechat_game_cpm_column_detail")
val wechatMiniGameCPMColumn: SubjectEntity? = null,
@SerializedName("link_common_collection")
val linkCommonCollection: CommonContentCollection? = null,
@SerializedName("link_qq_game_recently_played")
@ -83,6 +85,7 @@ class CustomPageData(
get() = when (link.type) {
CustomPageItem.CUSTOM_LINK_TYPE_QQ_MINI_GAME_COLUMN_DETAIL -> qqMiniGameColumn
CustomPageItem.CUSTOM_LINK_TYPE_WECHAT_MINI_GAME_COLUMN_DETAIL -> wechatMiniGameColumn
CustomPageItem.CUSTOM_LINK_TYPE_WECHAT_WECHAT_GAME_CPM_COLUMN_DETAIL -> wechatMiniGameCPMColumn
else -> linkColumn
}
@ -672,7 +675,7 @@ class CustomPageData(
@SerializedName("home")
private val _home: String? = null,
@SerializedName("more_link")
val moreLink: LinkEntity? = null
val moreLink: LinkEntity? = null
) {
val home: String

View File

@ -4,10 +4,7 @@ import com.gh.common.util.ViewPagerFragmentHelper
import com.gh.gamecenter.common.entity.LinkEntity
import com.gh.gamecenter.common.exposure.ExposureSource
import com.gh.gamecenter.core.utils.TimeUtils
import com.gh.gamecenter.entity.AmwayCommentEntity
import com.gh.gamecenter.entity.DiscoveryCardEntity
import com.gh.gamecenter.entity.HomeItemTestV2Entity
import com.gh.gamecenter.entity.SubjectEntity
import com.gh.gamecenter.entity.*
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.vspace.VGameItemData
@ -84,6 +81,7 @@ abstract class CustomPageItem(
const val CUSTOM_LINK_TYPE_WECHAT_GAME_RECENTLY_PLAYED = "wechat_game_recently_played"
const val CUSTOM_LINK_TYPE_QQ_MINI_GAME_COLUMN_DETAIL = ViewPagerFragmentHelper.TYPE_QQ_MINI_GAME_COLUMN
const val CUSTOM_LINK_TYPE_WECHAT_MINI_GAME_COLUMN_DETAIL = ViewPagerFragmentHelper.TYPE_WECHAT_GAME_COLUMN
const val CUSTOM_LINK_TYPE_WECHAT_WECHAT_GAME_CPM_COLUMN_DETAIL = ViewPagerFragmentHelper.TYPE_WECHAT_GAME_CPM_COLUMN
const val CUSTOM_LINK_TYPE_HALO_RECOMMEND = "halo_recommend"
const val CUSTOM_LINK_TYPE_COLUMN_COLLECTION = "column_collection" // 专题合集
const val CUSTOM_LINK_TYPE_GAME_LIST_COLLECTION = "game_list_collection"
@ -300,6 +298,7 @@ abstract class CustomPageItem(
CUSTOM_LINK_TYPE_WECHAT_GAME_RECENTLY_PLAYED to "最近在玩",
CUSTOM_LINK_TYPE_QQ_MINI_GAME_COLUMN_DETAIL to "QQ小游戏专题",
CUSTOM_LINK_TYPE_WECHAT_MINI_GAME_COLUMN_DETAIL to "微信小游戏专题",
CUSTOM_LINK_TYPE_WECHAT_WECHAT_GAME_CPM_COLUMN_DETAIL to "微信小游戏专题",
CUSTOM_LINK_TYPE_HALO_RECOMMEND to "光环推荐",
CUSTOM_LINK_TYPE_COLUMN_COLLECTION to "专题合集",
CUSTOM_LINK_TYPE_GAME_LIST_COLLECTION to "游戏单合集",
@ -623,6 +622,25 @@ data class CustomRecentWeChatMiniGamesItem(
}
}
// 微信小游戏CPM专题组件
data class CustomWeChatMiniGamesCPMSubjectItem(
private val _link: LinkEntity,
val data: SubjectEntity,
private val _position: Int,
private val _componentPosition: Int
) : CustomPageItem(_link, _position, _componentPosition) {
override val itemType: Int
get() = CUSTOM_PAGE_ITEM_TYPE_MINI_GAME_RECENT_PLAY
override fun doAreContentsTheSames(other: CustomPageItem): Boolean {
return other is CustomWeChatMiniGamesCPMSubjectItem
&& data == other.data
&& position == other.position
&& componentPosition == other.componentPosition
}
}
// qq小游戏-最近在玩
data class CustomRecentQqMiniGamesItem(
private val _link: LinkEntity,

View File

@ -3,12 +3,12 @@ package com.gh.gamecenter.home.custom.model
import android.graphics.Paint
import androidx.lifecycle.LiveData
import androidx.lifecycle.MediatorLiveData
import androidx.lifecycle.Observer
import com.gh.common.filter.RegionSettingHelper
import com.gh.common.util.GameSubstituteRepositoryHelper
import com.gh.common.util.HomePluggableHelper
import com.gh.download.DownloadManager
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.entity.LinkEntity
import com.gh.gamecenter.common.utils.TextHelper
import com.gh.gamecenter.common.utils.dip2px
import com.gh.gamecenter.common.utils.sp2px
@ -18,11 +18,11 @@ import com.gh.gamecenter.entity.DiscoveryCardEntity
import com.gh.gamecenter.entity.GameUpdateEntity
import com.gh.gamecenter.entity.PullDownPush
import com.gh.gamecenter.entity.SubjectEntity
import com.gh.gamecenter.feature.entity.FloatingWindowEntity
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.entity.PluginLocation
import com.gh.gamecenter.feature.entity.TagStyleEntity
import com.gh.gamecenter.feature.utils.ApkActiveUtils
import com.gh.gamecenter.feature.entity.FloatingWindowEntity
import com.gh.gamecenter.gamedetail.rating.edit.RatingEditActivity
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.COMMON_CONTENT_COLLECTION_LAYOUT_BANNER
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.COMMON_CONTENT_COLLECTION_LAYOUT_DOUBLE_ROW_BANNER
@ -47,7 +47,6 @@ import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.COMPONENTS_S
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.COMPONENTS_SUBJECT_TYPE_GAME_HORIZONTAL_SLIDE
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.COMPONENTS_SUBJECT_TYPE_GAME_TIMELINE_HORIZONTAL_SLIDE
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.COMPONENTS_SUBJECT_TYPE_GAME_VERTICAL_SLIDE
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.COMPONENTS_SUBJECT_TYPE_SINGLE_GAME_CARD
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.CUSTOM_LINK_TYPE_COLUMN
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.CUSTOM_LINK_TYPE_GAME
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.CUSTOM_LINK_TYPE_HALO_RECOMMEND
@ -55,7 +54,11 @@ import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.CUSTOM_LINK_
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.CUSTOM_LINK_TYPE_QQ_MINI_GAME_COLUMN_DETAIL
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.CUSTOM_LINK_TYPE_WECHAT_GAME_RECENTLY_PLAYED
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.CUSTOM_LINK_TYPE_WECHAT_MINI_GAME_COLUMN_DETAIL
import com.gh.gamecenter.home.custom.model.CustomPageItem.Companion.CUSTOM_LINK_TYPE_WECHAT_WECHAT_GAME_CPM_COLUMN_DETAIL
import com.gh.gamecenter.minigame.MiniGameRecentlyPlayUseCase
import com.gh.gamecenter.minigame.wechat.WGameSubjectCPMListRepository
import com.gh.gamecenter.minigame.wechat.WGameSubjectCPMListUseCase
import com.gh.gamecenter.minigame.wechat.WGameSubjectCPMRemoteDataSource
import com.gh.gamecenter.packagehelper.PackageRepository
import com.gh.gamecenter.retrofit.RetrofitManager
import com.gh.gamecenter.wrapper.MainWrapperRepository
@ -63,12 +66,14 @@ import com.gh.vspace.VHelper
import io.reactivex.Observable
import io.reactivex.Single
import io.reactivex.disposables.CompositeDisposable
import java.util.concurrent.atomic.AtomicInteger
import java.util.regex.Pattern
class CustomPageRepository private constructor(
private val remoteDataSource: CustomPageRemoteDataSource,
private val localDataSource: CustomPageLocalDataSource
private val localDataSource: CustomPageLocalDataSource,
private val wGameSubjectCPMRemoteDataSource: WGameSubjectCPMRemoteDataSource
) {
private val pageInfo = PageInfo()
@ -77,6 +82,10 @@ class CustomPageRepository private constructor(
private val shareRepository = CustomPageShareRepository.instance
private val wGameSubjectCPMListUseCase = WGameSubjectCPMListUseCase(
WGameSubjectCPMListRepository(wGameSubjectCPMRemoteDataSource)
)
private var recentItem: CustomRecentGamesItem? = null
private var recentQQItem: CustomRecentQqMiniGamesItem? = null
@ -91,14 +100,13 @@ class CustomPageRepository private constructor(
private var displayingGameIdSet = hashSetOf<String>() // 当前正在显示的游戏 id 列表
private val _customPluginItemLiveData = MediatorLiveData<CustomPluginItem>().apply {
val customPluginItemLiveData: LiveData<CustomPluginItem> = MediatorLiveData<CustomPluginItem>().apply {
addSource(PackageRepository.gameUpdateLiveData) {
refreshPluginIfNeed(it)?.let(this::setValue)
}
}
val customPluginItemLiveData: LiveData<CustomPluginItem> = _customPluginItemLiveData
private val _recentGamesItemLiveData = MediatorLiveData<CustomRecentGamesItem>().apply {
val recentGamesItemLiveData: LiveData<CustomRecentGamesItem> = MediatorLiveData<CustomRecentGamesItem>().apply {
addSource(DownloadManager.getInstance().downloadEntityLiveData) {
refreshRecentVGameIfNeed()?.let(this::setValue)
}
@ -106,29 +114,30 @@ class CustomPageRepository private constructor(
refreshRecentVGameIfNeed()?.let(this::setValue)
}
}
val recentGamesItemLiveData: LiveData<CustomRecentGamesItem> = _recentGamesItemLiveData
private val _recentMiniGamesItemLiveData = MediatorLiveData<CustomRecentWeChatMiniGamesItem>().apply {
addSource(MiniGameRecentlyPlayUseCase.wechatRecentGamesItemLiveData) {
refreshRecentWechatMiniGameIfNeed(it)?.let(this::setValue)
val recentMiniGamesItemLiveData: LiveData<CustomRecentWeChatMiniGamesItem> =
MediatorLiveData<CustomRecentWeChatMiniGamesItem>().apply {
addSource(MiniGameRecentlyPlayUseCase.wechatRecentGamesItemLiveData) {
refreshRecentWechatMiniGameIfNeed(it)?.let(this::setValue)
}
}
}
val recentMiniGamesItemLiveData: LiveData<CustomRecentWeChatMiniGamesItem> = _recentMiniGamesItemLiveData
private val _recentQqMiniGamesItemLiveData = MediatorLiveData<CustomRecentQqMiniGamesItem>().apply {
addSource(MiniGameRecentlyPlayUseCase.qqRecentGamesItemLiveData) {
refreshRecentQQMiniGameIfNeed(it)?.let(this::setValue)
val recentQqMiniGamesItemLiveData: LiveData<CustomRecentQqMiniGamesItem> =
MediatorLiveData<CustomRecentQqMiniGamesItem>().apply {
addSource(MiniGameRecentlyPlayUseCase.qqRecentGamesItemLiveData) {
refreshRecentQQMiniGameIfNeed(it)?.let(this::setValue)
}
}
}
val recentQqMiniGamesItemLiveData: LiveData<CustomRecentQqMiniGamesItem> = _recentQqMiniGamesItemLiveData
private val _customDiscoverItemLiveData = MediatorLiveData<CustomDiscoverCardItem>().apply {
addSource(shareRepository.discoverData) {
refreshDiscoverDataIfNeed(it)?.let(this::setValue)
val customDiscoverItemLiveData: LiveData<CustomDiscoverCardItem> =
MediatorLiveData<CustomDiscoverCardItem>().apply {
addSource(shareRepository.discoverData) {
refreshDiscoverDataIfNeed(it)?.let(this::setValue)
}
}
}
val customDiscoverItemLiveData: LiveData<CustomDiscoverCardItem> = _customDiscoverItemLiveData
val wechatMiniGameCPMItemLiveData: LiveData<Pair<String, List<GameEntity>>> =
wGameSubjectCPMListUseCase.wechatMiniGameCPMListLiveData
val hiddenNotifications: LiveData<HashMap<String, MutableSet<String>>>
get() = shareRepository.hiddenNotifications
@ -224,6 +233,7 @@ class CustomPageRepository private constructor(
private fun transformRawDataIntoItemData(data: CustomPageData, reloadDiscoverData: Boolean): List<CustomPageItem> {
val list = arrayListOf<CustomPageItem>()
data.customsComponents
.forEachIndexed { _, item ->
// 如果当前item不是展开大图并且上一个item为展开大图则说明展开大图组件已结束
@ -265,112 +275,24 @@ class CustomPageRepository private constructor(
}
}
item.link.type == CUSTOM_LINK_TYPE_COLUMN || item.link.type == CUSTOM_LINK_TYPE_QQ_MINI_GAME_COLUMN_DETAIL || item.link.type == CUSTOM_LINK_TYPE_WECHAT_MINI_GAME_COLUMN_DETAIL -> {
// 游戏专题
val gameSubject = item.gameSubjectEntity?.also {
if (item.link.type == CUSTOM_LINK_TYPE_COLUMN) {
it.data?.forEach { game ->
game.gameLocation = GameEntity.GameLocation.INDEX
}
}
}
var isAdded = false
if (gameSubject != null && !gameSubject.data.isNullOrEmpty()) {
// 记录已显示的游戏 id
for (game in gameSubject.data!!) {
displayingGameIdSet.add(game.id)
}
// 替换游戏
substituteGameIfNeeded(gameSubject)
if (gameSubject.tag == "update") {
// 优先显示更新标签
gameSubject.data?.forEach {
it.tagStyle.clear()
it.tagStyle.add(
TagStyleEntity(
id = "local_generated",
name = TimeUtils.getFormatTime(it.updateTime, "MM-dd") + " 更新",
color = "1383EB",
background = "E8F3FF",
column = "1383EB"
)
)
}
}
when (gameSubject.type) {
COMPONENTS_GAME_SUBJECT_TYPE_DOUBLE_CARD, COMPONENTS_SUBJECT_TYPE_DOUBLE_GAME_WELFARE_CARD -> {
// 双列卡片 双列福利卡片
val gameCount = gameSubject.data?.size ?: 0
if (gameCount >= COMPONENT_TYPE_COLUMN_LIMIT_TWO_COUNT) {
val subjectItems = convertSplitSubjectItems(item, 2, false)
list.addAll(subjectItems)
isAdded = true
}
}
COMPONENTS_GAME_SUBJECT_TYPE_GAME_VERTICAL -> {
// 长列表式
val subjectItems = convertSplitSubjectItems(item, 1, false)
list.addAll(subjectItems)
isAdded = true
}
COMPONENTS_SUBJECT_TYPE_GAME_HORIZONTAL -> {
// 图标矩阵
val subjectItems = convertSplitSubjectItems(item, 4, true)
list.addAll(subjectItems)
isAdded = true
}
else -> {
if (gameSubject.type == COMPONENTS_GAME_SUBJECT_TYPE_GAME_VIDEO_HORIZONTAL_SLIDE ||
gameSubject.type == COMPONENTS_SUBJECT_TYPE_GAME_FOLD_SLIDE
) {
val gameCount = gameSubject.data?.size ?: 0
if (gameCount >= COMPONENT_TYPE_COLUMN_LIMIT_TWO_COUNT) {
list.add(
CustomSubjectItem(
item.link,
gameSubject,
pageInfo.position,
pageInfo.componentPosition
)
)
pageInfo.positionIncrement()
isAdded = true
}
} else {
val gameCount = gameSubject.data?.size ?: 0
if (gameCount > 0) {
list.add(
CustomSubjectItem(
item.link,
gameSubject,
pageInfo.position,
pageInfo.componentPosition
)
)
pageInfo.positionIncrement()
isAdded = true
}
}
}
}
if (isAdded) {
pageInfo.componentPositionIncrement()
}
item.link.type == CUSTOM_LINK_TYPE_COLUMN
|| item.link.type == CUSTOM_LINK_TYPE_QQ_MINI_GAME_COLUMN_DETAIL
|| item.link.type == CUSTOM_LINK_TYPE_WECHAT_MINI_GAME_COLUMN_DETAIL -> {
val subItems = convertColumnDetailSubjectItems(
pageInfo.position,
pageInfo.componentPosition,
item.link,
item.gameSubjectEntity
)
if (subItems.isNotEmpty()) {
list.addAll(subItems)
pageInfo.positionGetAndAdd(subItems.size)
pageInfo.componentPositionIncrement()
}
}
//QQ小游戏-最近在玩(需要用户登录才显示)
item.link.type == CUSTOM_LINK_TYPE_QQ_GAME_RECENTLY_PLAYED -> {
//QQ小游戏-最近在玩(需要用户登录才显示)
val linkQqGameRecentlyPlayed = item.linkQqGameRecentlyPlayed
if (linkQqGameRecentlyPlayed != null) {
recentQQItem = CustomRecentQqMiniGamesItem(
@ -386,8 +308,8 @@ class CustomPageRepository private constructor(
}
// 微信小游戏-最近在玩
item.link.type == CUSTOM_LINK_TYPE_WECHAT_GAME_RECENTLY_PLAYED -> {
// 微信小游戏-最近在玩
recentWechatItem = CustomRecentWeChatMiniGamesItem(
item.link,
MiniGameRecentlyPlayUseCase.getRecentlyPlayedMiniGameList(Constants.WECHAT_MINI_GAME),
@ -398,6 +320,23 @@ class CustomPageRepository private constructor(
pageInfo.componentPositionIncrement()
}
// 微信小游戏CPM专题
item.link.type == CUSTOM_LINK_TYPE_WECHAT_WECHAT_GAME_CPM_COLUMN_DETAIL -> {
item.gameSubjectEntity?.let { subject ->
list.add(
CustomWeChatMiniGamesCPMSubjectItem(
item.link,
subject,
pageInfo.position,
pageInfo.componentPosition
)
)
wGameSubjectCPMListUseCase.getWechatMiniGameCPMList(subject.id)
pageInfo.positionIncrement()
pageInfo.componentPositionIncrement()
}
}
item.linkColumnCollection != null -> {
// 专题合集
val linkColumnCollection = item.linkColumnCollection
@ -475,7 +414,9 @@ class CustomPageRepository private constructor(
|| layout == COMMON_CONTENT_COLLECTION_LAYOUT_DOUBLE_ROW_VERTICAL_CARD
|| layout == COMMON_CONTENT_COLLECTION_LAYOUT_VERTICAL_IMAGE_TEXT
) {
list.addAll(convertSplitCommonContentCollection(item))
val subItems = convertSplitCommonContentCollection(item)
list.addAll(subItems)
pageInfo.positionGetAndAdd(subItems.size)
pageInfo.componentPositionIncrement()
} else {
var show = true
@ -528,12 +469,16 @@ class CustomPageRepository private constructor(
// 最近在玩
val entities = VHelper.getSortedRecentlyPlayedList()
recentItem =
CustomRecentGamesItem(item.link, entities, pageInfo.position, pageInfo.componentPosition)
.also {
list.add(it)
pageInfo.positionIncrement()
pageInfo.componentPositionIncrement()
}
CustomRecentGamesItem(
item.link,
entities,
pageInfo.position,
pageInfo.componentPosition
).also {
list.add(it)
pageInfo.positionIncrement()
pageInfo.componentPositionIncrement()
}
}
item.link.type == "plugin_area" -> {
@ -666,45 +611,155 @@ class CustomPageRepository private constructor(
}
pageInfo.nextPage()
return list
}
fun convertColumnDetailSubjectItems(
position: Int,
componentPosition: Int,
link: LinkEntity,
subjectEntity: SubjectEntity?,
): List<CustomPageItem> {
var currentPosition = position
val list = mutableListOf<CustomPageItem>()
// 游戏专题
val gameSubject = subjectEntity?.also {
if (link.type == CUSTOM_LINK_TYPE_COLUMN) {
it.data?.forEach { game ->
game.gameLocation = GameEntity.GameLocation.INDEX
}
}
}
if (gameSubject != null && !gameSubject.data.isNullOrEmpty()) {
// 记录已显示的游戏 id
for (game in gameSubject.data!!) {
displayingGameIdSet.add(game.id)
}
// 替换游戏
substituteGameIfNeeded(gameSubject)
if (gameSubject.tag == "update") {
// 优先显示更新标签
gameSubject.data?.forEach {
it.tagStyle.clear()
it.tagStyle.add(
TagStyleEntity(
id = "local_generated",
name = TimeUtils.getFormatTime(it.updateTime, "MM-dd") + " 更新",
color = "1383EB",
background = "E8F3FF",
column = "1383EB"
)
)
}
}
when (gameSubject.type) {
COMPONENTS_GAME_SUBJECT_TYPE_DOUBLE_CARD, COMPONENTS_SUBJECT_TYPE_DOUBLE_GAME_WELFARE_CARD -> {
// 双列卡片 双列福利卡片
val gameCount = gameSubject.data?.size ?: 0
if (gameCount >= COMPONENT_TYPE_COLUMN_LIMIT_TWO_COUNT) {
val subjectItems =
convertSplitSubjectItems(link, subjectEntity, currentPosition, componentPosition, 2, false)
list.addAll(subjectItems)
currentPosition += subjectItems.size
}
}
COMPONENTS_GAME_SUBJECT_TYPE_GAME_VERTICAL -> {
// 长列表式
val subjectItems =
convertSplitSubjectItems(link, subjectEntity, currentPosition, componentPosition, 1, false)
list.addAll(subjectItems)
currentPosition += subjectItems.size
}
COMPONENTS_SUBJECT_TYPE_GAME_HORIZONTAL -> {
// 图标矩阵
val subjectItems =
convertSplitSubjectItems(link, subjectEntity, currentPosition, componentPosition, 4, true)
list.addAll(subjectItems)
currentPosition += subjectItems.size
}
else -> {
if (gameSubject.type == COMPONENTS_GAME_SUBJECT_TYPE_GAME_VIDEO_HORIZONTAL_SLIDE ||
gameSubject.type == COMPONENTS_SUBJECT_TYPE_GAME_FOLD_SLIDE
) {
val gameCount = gameSubject.data?.size ?: 0
if (gameCount >= COMPONENT_TYPE_COLUMN_LIMIT_TWO_COUNT) {
list.add(
CustomSubjectItem(
link,
gameSubject,
currentPosition,
componentPosition
)
)
}
} else {
val gameCount = gameSubject.data?.size ?: 0
if (gameCount > 0) {
list.add(
CustomSubjectItem(
link,
gameSubject,
currentPosition,
componentPosition
)
)
}
}
}
}
}
return list
}
private fun convertSplitSubjectItems(
item: CustomPageData.CustomsComponent,
link: LinkEntity,
subjectEntity: SubjectEntity?,
position: Int,
componentPosition: Int,
stepNum: Int,
isMustFullyCover: Boolean
): List<CustomPageItem> {
val gameSubject = item.gameSubjectEntity ?: return emptyList()
val gameSubject = subjectEntity ?: return emptyList()
val items = arrayListOf<CustomPageItem>()
val games = gameSubject.data ?: emptyList()
var currentPosition = position
(games.indices step stepNum).forEach { start ->
if (isMustFullyCover) {
if (start + stepNum - 1 < games.size) {
items.add(
CustomSplitSubjectItem(
item.link,
link,
gameSubject,
pageInfo.position,
pageInfo.componentPosition,
currentPosition++,
componentPosition,
stepNum,
start
)
)
pageInfo.positionIncrement()
}
} else {
items.add(
CustomSplitSubjectItem(
item.link,
link,
gameSubject,
pageInfo.position,
pageInfo.componentPosition,
currentPosition++,
componentPosition,
stepNum,
start
)
)
pageInfo.positionIncrement()
}
}
items.forEach {
@ -729,7 +784,6 @@ class CustomPageRepository private constructor(
left
)
)
pageInfo.positionIncrement()
}
return items
}
@ -742,12 +796,20 @@ class CustomPageRepository private constructor(
}
}
fun notifyPositionChanged(offset: Int) {
pageInfo.position += offset
fun notifyPositionAdded(offset: Int) {
pageInfo.positionGetAndAdd(offset)
}
fun notifyPositionChanged(value: Int) {
pageInfo.position = value
}
fun loadChangeSubjectGame(subjectEntity: SubjectEntity): Observable<List<GameEntity>> =
remoteDataSource.loadChangeSubjectGame(subjectEntity)
if (subjectEntity.isWechatColumnCPM) {// 微信小游戏CPM专题的“换一批”接口
wGameSubjectCPMRemoteDataSource.getRecommendCPMList(2, 10).toObservable()
} else {
remoteDataSource.loadChangeSubjectGame(subjectEntity)
}
.map(RegionSettingHelper.filterGame)
.map(ApkActiveUtils.filterMapperList)
@ -798,16 +860,16 @@ class CustomPageRepository private constructor(
val page: Int
get() = _page
private var _position: Int = 0
private var _position: AtomicInteger = AtomicInteger(0)
var position: Int
get() = _position
get() = _position.get()
set(value) {
_position = value
_position.set(value)
}
private var _componentPosition = 0
private var _componentPosition: AtomicInteger = AtomicInteger(0)
val componentPosition: Int
get() = _componentPosition
get() = _componentPosition.get()
fun nextPage() {
@ -815,17 +877,25 @@ class CustomPageRepository private constructor(
}
fun positionIncrement() {
_position++
positionGetAndAdd(1)
}
fun componentPositionIncrement() {
_componentPosition++
componentPositionGetAndAdd(1)
}
fun positionGetAndAdd(value: Int) {
_position.getAndAdd(value)
}
fun componentPositionGetAndAdd(value: Int) {
_componentPosition.getAndAdd(value)
}
fun reset() {
_page = 1
_position = 0
_componentPosition = 0
_position.set(0)
_componentPosition.set(0)
}
}
@ -844,7 +914,8 @@ class CustomPageRepository private constructor(
RetrofitManager.getInstance().newApi,
MainWrapperRepository.getInstance()
),
CustomPageLocalDataSource()
CustomPageLocalDataSource(),
WGameSubjectCPMRemoteDataSource()
)
}
}

View File

@ -123,8 +123,12 @@ abstract class BaseCustomViewHolder(
_title.name = subject.name
tvTitle.text = subject.name ?: ""
}
if (_title.rightText != subject.home) {
_title.rightText = subject.home
val home = subject.home ?: ""
val homeText = subject.homeText ?: ""
if (_title.rightHome != home || _title.rightText != homeText) {
_title.rightHome = home
_title.rightText = homeText
fun getHomeText(defaultResId: Int): String =
if (subject.homeText.isNullOrBlank()) {
defaultResId.toResString()
@ -363,6 +367,7 @@ abstract class BaseCustomViewHolder(
data class TitleData(
var name: String? = null,
var rightHome: String? = null,
var rightText: String? = null,
var isRefresh: Boolean = false,
var icon: String? = null,

View File

@ -13,7 +13,7 @@ object HeadUpDisplayLogHelper {
source = source,
downloadType = if (downloadEntity.asVGame()) "畅玩下载" else "本地下载",
downloadStatus = downloadEntity.getMetaExtra(Constants.DOWNLOAD_STATUS_IN_CHINESE),
gameSchemeType = if (downloadEntity.getMetaExtra(Constants.KEY_BIT) == "32") "32位" else "64位",
gameSchemaType = if (downloadEntity.getMetaExtra(Constants.KEY_BIT) == "32") "32位" else "64位",
gameType = downloadEntity.getMetaExtra(Constants.GAME_CATEGORY_IN_CHINESE),
gameId = downloadEntity.gameId,
gameName = downloadEntity.name
@ -25,7 +25,7 @@ object HeadUpDisplayLogHelper {
source = source,
downloadType = if (downloadEntity.asVGame()) "畅玩下载" else "本地下载",
downloadStatus = downloadEntity.getMetaExtra(Constants.DOWNLOAD_STATUS_IN_CHINESE),
gameSchemeType = if (downloadEntity.getMetaExtra(Constants.KEY_BIT) == "32") "32位" else "64位",
gameSchemaType = if (downloadEntity.getMetaExtra(Constants.KEY_BIT) == "32") "32位" else "64位",
gameType = downloadEntity.getMetaExtra(Constants.GAME_CATEGORY_IN_CHINESE),
gameId = downloadEntity.gameId,
gameName = downloadEntity.name
@ -36,7 +36,7 @@ object HeadUpDisplayLogHelper {
SensorsBridge.trackAutomaticInstallationPromptBarShow(
downloadType = if (downloadEntity.asVGame()) "畅玩下载" else "本地下载",
downloadStatus = downloadEntity.getMetaExtra(Constants.DOWNLOAD_STATUS_IN_CHINESE),
gameSchemeType = if (downloadEntity.getMetaExtra(Constants.KEY_BIT) == "32") "32位" else "64位",
gameSchemaType = if (downloadEntity.getMetaExtra(Constants.KEY_BIT) == "32") "32位" else "64位",
gameType = downloadEntity.getMetaExtra(Constants.GAME_CATEGORY_IN_CHINESE),
gameId = downloadEntity.gameId,
gameName = downloadEntity.name
@ -47,7 +47,7 @@ object HeadUpDisplayLogHelper {
SensorsBridge.trackAutomaticInstallationPromptBarClick(
downloadType = if (downloadEntity.asVGame()) "畅玩下载" else "本地下载",
downloadStatus = downloadEntity.getMetaExtra(Constants.DOWNLOAD_STATUS_IN_CHINESE),
gameSchemeType = if (downloadEntity.getMetaExtra(Constants.KEY_BIT) == "32") "32位" else "64位",
gameSchemaType = if (downloadEntity.getMetaExtra(Constants.KEY_BIT) == "32") "32位" else "64位",
gameType = downloadEntity.getMetaExtra(Constants.GAME_CATEGORY_IN_CHINESE),
gameId = downloadEntity.gameId,
gameName = downloadEntity.name

View File

@ -59,7 +59,7 @@ class MiniGameRecentlyPlayListAdapter(
if (onItemClick != null) {
onItemClick.invoke(entity, position)
} else {
MiniGameItemHelper.launchMiniGame(entity.miniGameAppId, entity.miniGameType)
MiniGameItemHelper.launchMiniGame(entity)
}
}
}

View File

@ -56,7 +56,7 @@ class MiniGameSearchDefaultRankAdapter(
// 转成Game实体比较好处理数据
val trackGame = GameEntity(
id = rank.id,
_id = rank.id,
mName = rank.name,
miniGameAppId = rank.link.link ?: "",
miniGameType = Constants.WECHAT_MINI_GAME,

View File

@ -2,14 +2,16 @@ package com.gh.gamecenter.minigame
import com.gh.gamecenter.entity.SearchSubjectEntity
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.minigame.wechat.WGameSubjectCPMRemoteDataSource
import com.gh.gamecenter.retrofit.RetrofitManager
import com.gh.gamecenter.retrofit.service.ApiService
import com.gh.gamecenter.search.ISearchGameResultRepository
import io.reactivex.Observable
import java.net.URLEncoder
import io.reactivex.Single
class MiniGameSearchResultRepository(
private val api: ApiService = RetrofitManager.getInstance().newApi
private val api: ApiService = RetrofitManager.getInstance().newApi,
private val mWGameSubjectCPMDataSource: WGameSubjectCPMRemoteDataSource = WGameSubjectCPMRemoteDataSource()
) : ISearchGameResultRepository {
override fun getSearchGame(
@ -22,4 +24,8 @@ class MiniGameSearchResultRepository(
override fun getSearchSubject(key: String?, page: Int): Observable<List<SearchSubjectEntity>> {
return Observable.just(emptyList())
}
override fun getWGameCPMGameList(): Single<MutableList<GameEntity>> {
return mWGameSubjectCPMDataSource.getRecommendCPMList(1)
}
}

View File

@ -6,7 +6,9 @@ import com.gh.gamecenter.retrofit.service.ApiService
import com.gh.gamecenter.subject.ISubjectRepository
import io.reactivex.Observable
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.ResponseBody
import okhttp3.ResponseBody.Companion.toResponseBody
class QGameSubjectRepository(
private val api: ApiService = RetrofitManager.getInstance().newApi
@ -17,7 +19,7 @@ class QGameSubjectRepository(
}
override fun getSubjectName(column_id: String?): Observable<ResponseBody> {
return Observable.just(ResponseBody.create(MediaType.parse("application/json"), "{\"name\": \"专题\"}"))
return Observable.just("{\"name\": \"专题\"}".toResponseBody("application/json".toMediaTypeOrNull()))
}
}

View File

@ -0,0 +1,21 @@
package com.gh.gamecenter.minigame.wechat
import com.gh.gamecenter.entity.SubjectSettingEntity
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.subject.ISubjectListRepository
import io.reactivex.Observable
import io.reactivex.Single
class WGameSubjectCPMListRepository(
private val dataSource: WGameSubjectCPMRemoteDataSource = WGameSubjectCPMRemoteDataSource()
) : ISubjectListRepository {
override fun getColumn(column_id: String?, page: Int, sort: String?, order: String?): Single<MutableList<GameEntity>> {
return dataSource.getRecommendCPMList(page)
}
override fun getColumnSettings(column_id: String?): Observable<SubjectSettingEntity> {
return Observable.just(SubjectSettingEntity())
}
}

View File

@ -0,0 +1,46 @@
package com.gh.gamecenter.minigame.wechat
import android.annotation.SuppressLint
import androidx.lifecycle.LiveData
import com.gh.gamecenter.common.livedata.NonStickyMutableLiveData
import com.gh.gamecenter.common.retrofit.BiResponse
import com.gh.gamecenter.feature.entity.GameEntity
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
/**
* 微信小游戏CPM-网域层
*/
class WGameSubjectCPMListUseCase(
private val repository: WGameSubjectCPMListRepository = WGameSubjectCPMListRepository()
) {
/**
* 微信专题CPM请求记录用于避免重复请求以专题ID作为Key
*/
private val requestKeyList = mutableListOf<String>()
/**
* 微信小游戏CPM列表这里的LiveData充当类似于EventBus的角色因此使用NonStickyMutableLiveData
*/
private val _wechatMiniGameCPMListLiveData = NonStickyMutableLiveData<Pair<String, List<GameEntity>>>()
val wechatMiniGameCPMListLiveData: LiveData<Pair<String, List<GameEntity>>> = _wechatMiniGameCPMListLiveData
@SuppressLint("CheckResult")
fun getWechatMiniGameCPMList(subjectId: String?) {
if (subjectId.isNullOrEmpty() || requestKeyList.contains(subjectId)) {
return
}
requestKeyList.add(subjectId)
repository.getColumn(null, 1, null, null)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : BiResponse<List<GameEntity>>() {
override fun onSuccess(data: List<GameEntity>) {
requestKeyList.remove(subjectId)
_wechatMiniGameCPMListLiveData.value = subjectId to data
}
})
}
}

View File

@ -0,0 +1,59 @@
package com.gh.gamecenter.minigame.wechat
import com.gh.common.constant.Config
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.exposure.meta.MetaUtil
import com.gh.gamecenter.common.utils.toRequestBody
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.entity.TagStyleEntity
import com.gh.gamecenter.retrofit.RetrofitManager
import com.gh.gamecenter.feature.retrofit.WGameCPMApiService
import io.reactivex.Single
class WGameSubjectCPMRemoteDataSource(
private val api: WGameCPMApiService = RetrofitManager.getInstance().wGameCPMApi
) {
fun getRecommendCPMList(page: Int, pageSize: Int = 10): Single<MutableList<GameEntity>> {
val meta = MetaUtil.getMeta()
val request = mapOf(
"head" to mapOf(
"busiAppid" to Config.WGAME_CPM_BUSIAPPID,
"oaid" to (meta.oaid ?: ""),
"manufacturer" to (meta.manufacturer ?: ""),
"mode" to (meta.model ?: ""),
"androidId" to (MetaUtil.getAndroidId()),
"imei" to (MetaUtil.getIMEI())
),
"body" to mapOf(
"page" to page - 1,
"pageSize" to pageSize,
)
)
return api.getUserRecommendList(request.toRequestBody())
.map {
if (it.ret == 0) {
it.appInfoList.map { info ->
GameEntity(
mName = info.appName,
mIcon = info.logo,
mBrief = info.briefIntro,
miniGameUid = info.appID,
miniGameAppId = info.userName,
miniGameType = Constants.WECHAT_MINI_GAME_CPM,
miniGameAppStatus = 2,
miniGameAppPath = info.wechatAppPath,
miniGameExtData = info.extData,
miniGameRecommendId = info.recommendID,
mTagStyle = arrayListOf(
TagStyleEntity(name = info.categoryName),
TagStyleEntity(name = info.subcategoryName)
)
)
}.toMutableList()
} else {
mutableListOf()
}
}
}
}

View File

@ -0,0 +1,19 @@
package com.gh.gamecenter.minigame.wechat
import com.gh.gamecenter.entity.SubjectSettingEntity
import com.gh.gamecenter.subject.ISubjectRepository
import io.reactivex.Observable
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.ResponseBody
import okhttp3.ResponseBody.Companion.toResponseBody
class WGameSubjectCPMRepository : ISubjectRepository {
override fun getColumnSettings(column_id: String?): Observable<SubjectSettingEntity> {
return Observable.just(SubjectSettingEntity())
}
override fun getSubjectName(column_id: String?): Observable<ResponseBody> {
return Observable.just("{\"name\": \"专题\"}".toResponseBody("application/json".toMediaTypeOrNull()))
}
}

View File

@ -6,7 +6,9 @@ import com.gh.gamecenter.retrofit.service.ApiService
import com.gh.gamecenter.subject.ISubjectRepository
import io.reactivex.Observable
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.ResponseBody
import okhttp3.ResponseBody.Companion.toResponseBody
class WGameSubjectRepository(
private val api: ApiService = RetrofitManager.getInstance().newApi
@ -16,6 +18,6 @@ class WGameSubjectRepository(
}
override fun getSubjectName(column_id: String?): Observable<ResponseBody> {
return Observable.just(ResponseBody.create(MediaType.parse("application/json"), "{\"name\": \"专题\"}"))
return Observable.just("{\"name\": \"专题\"}".toResponseBody("application/json".toMediaTypeOrNull()))
}
}

View File

@ -14,7 +14,6 @@ import com.gh.gamecenter.GameDetailActivity
import com.gh.gamecenter.R
import com.gh.gamecenter.common.baselist.ListAdapter
import com.gh.gamecenter.common.baselist.LoadType
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.constant.ItemViewType
import com.gh.gamecenter.common.exposure.ExposureSource
import com.gh.gamecenter.common.utils.*
@ -281,7 +280,7 @@ class MyFollowedGameViewHolder(var binding: ItemFollowedGameBinding) : RecyclerV
binding.root.context,
gameEntity,
entrance,
defaultTab = EntranceConsts.TAB_TYPE_TRENDS
defaultTab = GameDetailFragment.TAB_TRENDS
)
}
} else {
@ -307,7 +306,7 @@ class MyFollowedGameViewHolder(var binding: ItemFollowedGameBinding) : RecyclerV
binding.root.context,
gameEntity,
entrance,
defaultTab = EntranceConsts.TAB_TYPE_BBS
defaultTab = GameDetailFragment.TAB_BBS
)
}
} else {

View File

@ -26,13 +26,16 @@ class PackageFilterManager {
*/
@SuppressLint("CheckResult")
fun updateFilterPackages(
packageList: MutableList<String>,
packageList: List<String>,
appendOnly: Boolean = true,
callbackClosure: ((list: ArrayList<String>) -> Unit)? = null
) {
val finalPackageList = ArrayList(packageList)
if (appendOnly) {
// 添加因为异常而没能正常更新的包名列表
packageList.addAll(PackageRepository.mPendingPackageNameSet)
finalPackageList.addAll(PackageRepository.mPendingPackageNameSet)
}
RetrofitManager.getInstance()

View File

@ -7,6 +7,7 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.gh.common.filter.RegionSettingHelper
import com.gh.common.util.GameUtils
import com.gh.common.util.PackageHelper
import com.gh.common.util.PackageUtils
import com.gh.gamecenter.R
import com.gh.gamecenter.common.exposure.meta.MetaUtil
@ -91,8 +92,7 @@ object PackageRepository {
/**
* 预留方法,如果想手动初始化可以调用
*/
@JvmStatic
fun initData() {
fun initData(onPackageNameReceivedCallback: (() -> Unit)? = null) {
if (mIsInitialisingData) return
mIsInitialisingData = true
@ -104,17 +104,25 @@ object PackageRepository {
Single.zip<Result<Any?>, Result<Any?>, Result<Any?>>(
Single.create { emitter ->
val list = PackageUtils.getAllPackageName(mApplication)
val list = PackageHelper.getInstalledPackageNameList(mApplication, 0)
uploadAppList()
// 回调包名获取结果
onPackageNameReceivedCallback?.invoke()
initFilterPackage(list) { filteredList ->
emitter.onSuccess(Result.success(null))
mInstalledPkgSet.addAll(filteredList)
notifyInstallPkgData()
loadInstalledGameDigestAndNotifyData(packageFilterManager.packageKey, filteredList)
loadInstalledGameDigestAndNotifyData(
packageKey = packageFilterManager.packageKey,
filteredList = filteredList,
isVGame = false,
updateInstallStatus = true,
fromInit = true
)
}
},
Single.create { emitter ->
// 畅玩游戏更新
@ -156,7 +164,7 @@ object PackageRepository {
* 初始化光环后台收录的安装包
*/
private fun initFilterPackage(
list: MutableList<String>,
list: List<String>,
callbackClosure: ((list: ArrayList<String>) -> Unit)? = null
) {
packageFilterManager.updateFilterPackages(list, false, callbackClosure)
@ -249,13 +257,15 @@ object PackageRepository {
* @param onWorkerThreadOnly 是否在工作线程执行
* @param isVGame 包名列表是否为畅玩游戏
* @param updateInstallStatus 更新安装状态 (通过 EventBus 来进行)
* @param fromInit 是否来自数据首次初始化
*/
@SuppressLint("CheckResult")
private fun loadInstalledGameDigestAndNotifyData(
packageKey: String,
filteredList: ArrayList<String>,
isVGame: Boolean = false,
updateInstallStatus: Boolean = false
updateInstallStatus: Boolean = false,
fromInit: Boolean = false
) {
var isNotifyUpdate = false
val maxPageCount = (filteredList.size / PAGE_SIZE) + 1
@ -284,7 +294,7 @@ object PackageRepository {
for (game in validGames) {
val shouldNotifyChanges =
validateGameAndPostChanges(gh_id, game, pkgName, isVGame, updateInstallStatus)
validateGameAndPostChanges(gh_id, game, pkgName, isVGame, updateInstallStatus, fromInit)
if (!isNotifyUpdate && shouldNotifyChanges) {
isNotifyUpdate = true
}
@ -310,7 +320,8 @@ object PackageRepository {
game: GameEntity,
pkgName: String,
isVGame: Boolean,
updateInstallStatus: Boolean
updateInstallStatus: Boolean,
fromInit: Boolean = false
): Boolean {
if (ghId == null || ghId == game.id) {
gameInstalled.add(GameInstall.transformGameInstall(game, pkgName, isVGame))
@ -321,7 +332,7 @@ object PackageRepository {
if (updateInstallStatus) {
EventBus.getDefault()
.post(EBPackage(EBPackage.TYPE_INSTALLED, pkgName, game.getApk().firstOrNull()?.version))
.post(EBPackage(EBPackage.TYPE_INSTALLED, pkgName, game.getApk().firstOrNull()?.version, fromInit))
}
if (isCanUpdate || isCanPluggable) {

View File

@ -183,11 +183,6 @@ class HaloPersonalFragment : BaseLazyFragment() {
}
}
mStubBinding.personalMsg -> {
// 优先进入有数字提醒的消息tab其次是有红点提醒的游戏动态最后是没有提醒的消息tab
val defaultTabIndex = if ((mUnreadViewModel.messageUnreadCountLiveData.value?.message
?: 0) < 1 && mUnreadViewModel.zixunConcernLiveData.value == true
) 0 else 1
if (CheckLoginUtils.isLogin()) {
NewFlatLogUtils.logHaloSelfClick("右上角", "消息中心")
SensorsBridge.trackHaloSelfClick(
@ -202,11 +197,16 @@ class HaloPersonalFragment : BaseLazyFragment() {
"我的"
)
SensorsBridge.trackMessageCenterClick()
// 优先进入有数字提醒的消息tab其次是有红点提醒的游戏动态最后是没有提醒的消息tab
val defaultTabIndex = if ((mUnreadViewModel.messageUnreadCountLiveData.value?.message
?: 0) < 1 && mUnreadViewModel.zixunConcernLiveData.value == true
) 0 else 1
DirectUtils.directToMessageCenter(defaultTabIndex)
} else {
NewFlatLogUtils.logHaloSelfLogin()
CheckLoginUtils.checkLogin(context, "我的光环-消息") {}
}
DirectUtils.directToMessageCenter(defaultTabIndex, "我的光环-消息")
}
mStubBinding.personalUserIcon,
mStubBinding.personalUserName -> {
@ -374,12 +374,14 @@ class HaloPersonalFragment : BaseLazyFragment() {
}
mSuperiorChain?.registerInferiorChain(mPriorityChain)
startBannerAutoPlay()
}
override fun onFragmentPause() {
super.onFragmentPause()
mSuperiorChain?.unregisterInferiorChain(mPriorityChain)
stopBannerAutoPlay()
}
@SuppressLint("CheckResult", "SetTextI18n")
@ -1011,7 +1013,7 @@ class HaloPersonalFragment : BaseLazyFragment() {
}
private fun startBannerAutoPlay() {
if (mPersonalBannerAdapter.getActualSize() < 2) return
if (!::mPersonalBannerAdapter.isInitialized || mPersonalBannerAdapter.getActualSize() < 2) return
stopBannerAutoPlay()
mLooperHandle.sendEmptyMessageDelayed(mSlideLooperKey, BANNER_LOOP_TIME)
}

View File

@ -20,7 +20,9 @@ import com.gh.gamecenter.retrofit.RetrofitManager
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.ResponseBody
import org.json.JSONArray
import org.json.JSONObject
@ -75,7 +77,7 @@ class InstalledGameDialog(
jsonObject.put("package", game.packageName)
objects.put(jsonObject)
}
val requestBody = RequestBody.create(MediaType.parse("application/json"), objects.toString())
val requestBody = objects.toString().toRequestBody("application/json".toMediaTypeOrNull())
RetrofitManager.getInstance().api
.postPlayedGames(UserManager.getInstance().userId, requestBody)
.subscribeOn(Schedulers.io())

View File

@ -1,56 +1,43 @@
package com.gh.gamecenter.personalhome
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.View
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.gh.gamecenter.common.base.activity.ToolBarActivity
import com.gh.gamecenter.R
import com.gh.gamecenter.common.base.activity.BaseActivity
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.core.utils.DisplayUtils
@Route(
path = RouteConsts.activity.userHomeActivity,
name = "个人主页"
)
/**
* 个人主页
*/
class UserHomeActivity : ToolBarActivity() {
@JvmField
@Autowired(name = EntranceConsts.KEY_USER_ID, desc = "用户 id (长 id 或短 id 均可)", required = true)
var userId: String? = null
@JvmField
@Autowired(name = EntranceConsts.KEY_TAB_INDEX, desc = "默认选中 tab 的序号,可选值 0 游戏1 发布")
var selectedTabIndex: Int = 0
@JvmField
@Autowired(name = EntranceConsts.KEY_COMMUNITY_TYPE, desc = "默认选中的社区内容 tab 类型,可选值 all: 全部, video: 视频, community_article: 帖子, answer: 回答, question: 问题")
var selectedCommunityType: String = ""
@JvmField
@Autowired(name = EntranceConsts.KEY_GAME_TYPE, desc = "默认选中的游戏 tab 类型,可选值 game_collection: 游戏单, played_game: 玩过, comment: 评价")
var selectedGameType: String = ""
@JvmField
@Autowired(name = EntranceConsts.KEY_PATH, desc = "页面路径 (历史代码用到的,传不传都行)")
var path: String = ""
override fun provideNormalIntent(): Intent {
return getTargetIntent(this, UserHomeActivity::class.java, UserHomeFragment::class.java)
}
override fun onCreate(savedInstanceState: Bundle?) {
// 注入 arouter 参数
ARouter.getInstance().inject(this)
// 桥接 arouter 和原有入参
generateDataFromRoute()
super.onCreate(savedInstanceState)
hideToolbar(true)
DisplayUtils.setStatusBarColor(this, com.gh.gamecenter.common.R.color.transparent, false)
}
companion object {
@JvmStatic
fun getIntent(context: Context, userId: String, entrance: String?, path: String?): Intent {
val bundle = Bundle()
bundle.putString(EntranceConsts.KEY_USER_ID, userId)
bundle.putString(EntranceConsts.KEY_ENTRANCE, BaseActivity.mergeEntranceAndPath(entrance, path))
bundle.putString(EntranceConsts.KEY_PATH, path)
return getTargetIntent(context, UserHomeActivity::class.java, UserHomeFragment::class.java, bundle)
}
}
override fun getBusinessId(): Pair<String, String> {
return Pair(userId ?: "", "")
return Pair(targetFragment.arguments?.getString(EntranceConsts.KEY_USER_ID) ?: "", "")
}
override fun isAutoResetViewBackgroundEnabled(): Boolean = true
@ -61,11 +48,4 @@ class UserHomeActivity : ToolBarActivity() {
listOf(R.id.allType, R.id.videoType, R.id.articleType, R.id.questionType, R.id.answerType, R.id.tab_title)
)
}
private fun generateDataFromRoute() {
val bundle = intent.extras
intent?.putExtra(NORMAL_FRAGMENT_NAME, UserHomeFragment::class.java.canonicalName)
intent?.putExtra(NORMAL_FRAGMENT_BUNDLE, bundle)
}
}

View File

@ -93,6 +93,7 @@ class UserHomeFragment : ToolbarFragment() {
}
mHomeBinding?.container?.setZoomView(mHomeBinding?.userBackgroundContainer)
// mHomeBinding?.userBadge?.visibleIf(mUserHomeViewModel.userId == UserManager.getInstance().userId)
mUserHomeViewModel.userInfo.observeNonNull(this) {
// 区分是数据初始化还是数据更新
@ -116,6 +117,7 @@ class UserHomeFragment : ToolbarFragment() {
updateUserInfo(it)
updateTab(it)
trackMtaEvent(it.name)
} else {
updateUserInfo(it)
}
@ -296,9 +298,9 @@ class UserHomeFragment : ToolbarFragment() {
}
private fun updateTab(personalData: PersonalEntity) {
val keyPosition = arguments?.getInt(EntranceConsts.KEY_TAB_INDEX, -1) ?: -1
val type = UserHistoryViewModel.TYPE.fromValue(arguments?.getString(EntranceConsts.KEY_COMMUNITY_TYPE))
val gameType = arguments?.getString(EntranceConsts.KEY_GAME_TYPE) ?: "game_collection"
val keyPosition = arguments?.getInt(EntranceConsts.KEY_POSITION, -1) ?: -1
val type = UserHistoryViewModel.TYPE.fromValue(arguments?.getString(EntranceConsts.KEY_TYPE))
val gameType = arguments?.getString(EntranceConsts.KEY_GAME) ?: "game_collection"
val count = personalData.count
val position = if (keyPosition > -1) {
keyPosition
@ -333,6 +335,7 @@ class UserHomeFragment : ToolbarFragment() {
FragmentAdapter(childFragmentManager, mFragmentList, titleList)
mHomeBinding?.viewpager?.currentItem = position
mHomeBinding?.viewpager?.doOnPageSelected {
MtaHelper.onEvent("个人主页详情", "个人主页详情", titleList[it])
if (it == 1) (mFragmentList[1] as UserHistoryFragment).onScrollStateChanged()
}
mHomeBinding?.tabLayout?.setupWithViewPager(mHomeBinding?.viewpager)
@ -359,6 +362,19 @@ class UserHomeFragment : ToolbarFragment() {
return view
}
private fun trackMtaEvent(name: String? = "") {
MtaHelper.onEvent(
"个人主页",
mPath,
StringUtils.combineTwoString(name, mUserHomeViewModel.userId)
)
MtaHelper.onEvent(
"个人主页",
"不区分位置",
StringUtils.combineTwoString(name, mUserHomeViewModel.userId)
)
}
private fun updateUnreadInfo(messageEntity: MessageUnreadEntity) {
if (mUserHomeViewModel.userId == UserManager.getInstance().userId) {
BindingAdapters.setMessageUnread(mHomeBinding?.userFansCountHint, messageEntity.fans)
@ -541,6 +557,7 @@ class UserHomeFragment : ToolbarFragment() {
log("view_pendant", "头像挂件页")
}
if (mUserHomeViewModel.userId == UserManager.getInstance().userId) {
MtaHelper.onEvent("个人主页详情", "个人主页详情", "头像")
startActivity(AvatarBorderActivity.getIntent(requireContext()))
} else {
startActivity(
@ -558,6 +575,7 @@ class UserHomeFragment : ToolbarFragment() {
userFollowerContainer.setOnClickListener {
IntegralLogHelper.log("click_follow", LOCATION)
MtaHelper.onEvent("个人主页详情", "个人主页详情", "关注数")
startActivity(
FollowersActivity.getIntent(
requireContext(),
@ -569,6 +587,7 @@ class UserHomeFragment : ToolbarFragment() {
}
userFansContainer.setOnClickListener {
IntegralLogHelper.log("click_follower", LOCATION)
MtaHelper.onEvent("个人主页详情", "个人主页详情", "粉丝数")
requireContext().startActivity(
FansActivity.getIntent(
requireContext(),
@ -580,6 +599,7 @@ class UserHomeFragment : ToolbarFragment() {
}
userVoteContainer.setOnClickListener {
IntegralLogHelper.log("click_like", LOCATION)
MtaHelper.onEvent("个人主页详情", "个人主页详情", "赞同数")
Utils.toast(
requireContext(),
"共获得 " + NumberUtils.transSimpleCount(personalData?.count?.vote!!) + " 赞同"
@ -587,6 +607,7 @@ class UserHomeFragment : ToolbarFragment() {
}
userEditBtn.setOnClickListener {
IntegralLogHelper.log("click_edit", LOCATION)
MtaHelper.onEvent("个人主页详情", "个人主页详情", "编辑按钮")
requireContext().startActivity(UserInfoActivity.getIntent(requireContext()))
}
userConcernContainer.setOnClickListener {
@ -596,6 +617,7 @@ class UserHomeFragment : ToolbarFragment() {
buttonName = "关注"
)
ifLogin("个人主页-关注-[关注]") {
MtaHelper.onEvent("个人主页详情", "个人主页详情", "关注按钮")
mUserHomeViewModel.follow()
}
}
@ -607,6 +629,7 @@ class UserHomeFragment : ToolbarFragment() {
buttonName = "已关注"
)
ifLogin("个人主页-关注-[关注]") {
MtaHelper.onEvent("个人主页详情", "个人主页详情", "关注按钮")
DialogHelper.showDialog(
requireContext(),
"取消关注",

View File

@ -30,6 +30,7 @@ import com.gh.gamecenter.common.base.fragment.BaseFragment
import com.gh.gamecenter.common.base.fragment.ToolbarFragment
import com.gh.gamecenter.common.callback.ConfirmListener
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.constant.Constants.GAME_DETAIL_COME_IN
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.entity.NormalShareEntity
import com.gh.gamecenter.common.entity.SuggestType
@ -593,6 +594,7 @@ open class AnswerDetailFragment : ToolbarFragment() {
when (menuItem.itemId) {
R.id.menu_more -> mViewModel.answerDetail?.let { showMoreItemDialog(it) }
R.id.menu_question_and_answer -> {
HaloApp.remove(GAME_DETAIL_COME_IN)
val community = mViewModel.answerDetail?.community
MtaHelper.onEvent(
"进入问答",
@ -1130,6 +1132,8 @@ open class AnswerDetailFragment : ToolbarFragment() {
(requireActivity() as ToolBarActivity).clearMenu()
initMenu(R.menu.menu_answer)
val itemMenu = getItemMenu(R.id.menu_question_and_answer)
itemMenu.isVisible = HaloApp.get(GAME_DETAIL_COME_IN, false) != null
}
}

View File

@ -25,7 +25,9 @@ import com.lightgame.utils.Utils
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.ResponseBody
import org.greenrobot.eventbus.EventBus
import org.json.JSONObject
@ -259,10 +261,8 @@ class AnswerDetailViewModel(application: Application) : AndroidViewModel(applica
fun toggleComment(answerId: String, isCommentable: Boolean) {
val params = HashMap<String, Boolean>()
params["commentable"] = isCommentable
val body = RequestBody.create(
MediaType.parse("application/json"),
JSONObject(params as Map<*, *>).toString()
)
val body = JSONObject(params as Map<*, *>).toString()
.toRequestBody("application/json".toMediaTypeOrNull())
RetrofitManager.getInstance()
.api

View File

@ -26,7 +26,9 @@ import com.lightgame.utils.Utils
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.ResponseBody
import org.greenrobot.eventbus.EventBus
import org.json.JSONArray
@ -144,7 +146,7 @@ class ArticleEditViewModel(application: Application) : BaseRichEditorViewModel(a
if (draftEntity?.id != null) {
articleBody.put("draft_id", draftEntity?.id)
}
val body = RequestBody.create(MediaType.parse("application/json"), articleBody.toString())
val body = articleBody.toString().toRequestBody("application/json".toMediaTypeOrNull())
val observable = if (detailEntity == null) {
mApi.postCommunityArticle(mSelectCommunityData?.id, body)
} else {
@ -226,7 +228,7 @@ class ArticleEditViewModel(application: Application) : BaseRichEditorViewModel(a
if (mSelectCommunityData != null && mSelectCommunityData!!.id.isNotEmpty()) {
articleBody.put("community_id", mSelectCommunityData!!.id)
}
val body = RequestBody.create(MediaType.parse("application/json"), articleBody.toString())
val body = articleBody.toString().toRequestBody("application/json".toMediaTypeOrNull())
val observable = if (draftEntity?.id != null) {
mApi.patchCommunityArticleDrafts(UserManager.getInstance().userId, draftEntity?.id, body)
} else {

View File

@ -40,7 +40,7 @@ class GameDefaultAdapter(
val intent = Intent()
intent.putExtra(
GameEntity::class.java.simpleName,
GameEntity(id = entity.gameId, mIcon = entity.gameIcon, mName = entity.gameName, mCategory = entity.category)
GameEntity(_id = entity.gameId, mIcon = entity.gameIcon, mName = entity.gameName, mCategory = entity.category)
)
(mContext as Activity).setResult(Activity.RESULT_OK, intent)
(mContext as Activity).finish()

View File

@ -28,7 +28,9 @@ import com.lightgame.utils.Utils
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.ResponseBody
import org.greenrobot.eventbus.EventBus
import org.json.JSONArray
@ -266,7 +268,7 @@ class QuestionEditViewModel(application: Application) : BaseRichEditorViewModel(
}
processDialog.postValue(WaitingDialogFragment.WaitingDialogData("提交中...", true))
val body = RequestBody.create(MediaType.parse("application/json"), bodyJson)
val body = bodyJson.toRequestBody("application/json".toMediaTypeOrNull())
mApi.moderatorsPatchQuestion(body, UserManager.getInstance().userId, questionEntity?.id)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())

View File

@ -15,7 +15,9 @@ import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.ResponseBody
import org.json.JSONException
import org.json.JSONObject
@ -59,7 +61,7 @@ class QuestionsInviteViewModel(application: Application, var questionId: String?
e.printStackTrace()
}
val body = RequestBody.create(MediaType.parse("application/json"), jsonObject.toString())
val body = jsonObject.toString().toRequestBody("application/json".toMediaTypeOrNull())
RetrofitManager.getInstance().api
.postInvite(body, questionId)
.subscribeOn(Schedulers.io())

View File

@ -30,7 +30,9 @@ import com.lightgame.utils.Utils
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.ResponseBody
import org.json.JSONObject
import retrofit2.HttpException
@ -114,7 +116,7 @@ class VideoPublishViewModel(application: Application) : AndroidViewModel(applica
when {
isDraft -> {
val draftData = JSONObject(videoEntity.toJson()).put("local_path", videoPath).toString()
val body = RequestBody.create(MediaType.parse("application/json"), draftData)
val body = draftData.toRequestBody("application/json".toMediaTypeOrNull())
postDraft(body)
}
videoPatch != null -> {
@ -150,7 +152,7 @@ class VideoPublishViewModel(application: Application) : AndroidViewModel(applica
private fun patchVideo(jsonObject: JSONObject, videoId: String) {
processDialog.postValue(WaitingDialogFragment.WaitingDialogData("提交中...", true))
val body = RequestBody.create(MediaType.parse("application/json"), jsonObject.toString())
val body = jsonObject.toString().toRequestBody("application/json".toMediaTypeOrNull())
mApi.patchBbsVideo(videoId, body)
.compose(observableToMain())
.subscribe(object : Response<ResponseBody>() {
@ -208,7 +210,7 @@ class VideoPublishViewModel(application: Application) : AndroidViewModel(applica
private fun postVideo(jsonObject: JSONObject) {
processDialog.postValue(WaitingDialogFragment.WaitingDialogData("提交中...", true))
val body = RequestBody.create(MediaType.parse("application/json"), jsonObject.toString())
val body = jsonObject.toString().toRequestBody("application/json".toMediaTypeOrNull())
mApi.postBbsVideo(body)
.compose(observableToMain())
.subscribe(object : Response<JsonObject>() {

Some files were not shown because too many files have changed in this diff Show More