Compare commits

...

46 Commits

Author SHA1 Message Date
141734e8e6 fix: 安利墙页适配底部tab 2024-01-25 17:48:07 +08:00
d6ae3ee1e9 fix: 论坛详情页适配底部tab 2024-01-25 17:29:45 +08:00
9f94e29193 refactor: 帮助与反馈页面改为懒加载 2024-01-25 17:27:16 +08:00
ac2eda9aee refactor: 视频贴页面改为懒加载 2024-01-25 17:27:16 +08:00
3c4a4eb6e4 fix: 修改通用跳转命名 2024-01-25 17:27:16 +08:00
9722051371 refactor: 游戏详情页改为懒加载 2024-01-25 17:11:49 +08:00
212494ea20 Merge branch 'feat/GHZS-3956' of git.shanqu.cc:halo/android/assistant-android into feat/GHZS-3956 2024-01-25 11:05:09 +08:00
b5b61a69ec fix:长列表式,点击换一批crash 2024-01-25 11:05:02 +08:00
b93a49a9e5 feat: APP内容配置重构-埋点—客户端2(补充曝光数据1) https://jira.shanqu.cc/browse/GHZS-4559 2024-01-25 09:56:54 +08:00
48d59502f2 fix:参数缺失 2024-01-25 09:31:38 +08:00
55437238f6 Merge branch 'chen/202401/fix-GHZS-4653-2' into 'feat/GHZS-3956'
fix:APP内容配置重构-客户端-组件:专题合集-轮播图-01/24测试-客户端...

See merge request halo/android/assistant-android!1521
2024-01-24 18:02:54 +08:00
c436ceb72c fix:APP内容配置重构-客户端-组件:专题合集-轮播图-01/24测试-客户端 https://jira.shanqu.cc/projects/GHZS/issues/GHZS-4653?filter=myopenissues 2024-01-24 17:56:58 +08:00
fb28a834a5 fix: APP内容配置重构-刷新轮换—客户端(修复刷新轮换游戏全部被屏蔽时显示错误页数的问题) https://jira.shanqu.cc/browse/GHZS-4257 2024-01-24 17:21:59 +08:00
2639a39de3 feat: APP内容配置重构-埋点—客户端2 https://jira.shanqu.cc/browse/GHZS-4559 2024-01-24 16:11:31 +08:00
228d7ff634 Merge branch 'chen/202401/fix-GHZS-4608' into 'feat/GHZS-3956'
fix:APP内容配置重构-客户端-组件:游戏专题-光环游戏-0120测试—客户端...

See merge request halo/android/assistant-android!1515
2024-01-24 14:38:51 +08:00
c02f4df423 fix:APP内容配置重构-客户端-组件:游戏专题-光环游戏-0120测试—客户端 https://jira.shanqu.cc/projects/GHZS/issues/GHZS-4608?filter=myopenissues 2024-01-24 14:36:54 +08:00
b84e1291e7 fix: 修复首页闪退问题 https://jira.shanqu.cc/browse/GHZS-3956 2024-01-24 11:23:58 +08:00
f663a076f8 feat: APP内容配置重构-附属需求:弹窗顺序 https://jira.shanqu.cc/browse/GHZS-4086 2024-01-23 16:36:54 +08:00
da4df9fcf6 feat: APP内容配置重构-附属需求:首次启动跳转 https://jira.shanqu.cc/browse/GHZS-4085 2024-01-23 16:36:54 +08:00
03734c1075 feat: APP内容配置重构-附属需求:弹窗顺序 https://jira.shanqu.cc/browse/GHZS-4086 2024-01-23 16:36:54 +08:00
6588392aa7 fix:APP内容配置重构-客户端-组件:游戏专题-QQ小游戏-0120测试-客户端 https://jira.shanqu.cc/browse/GHZS-4607 2024-01-23 16:36:54 +08:00
016d8a2bd4 fix: APP内容配置重构-换一批—客户端(修复点击换一批后功能失效的问题) https://jira.shanqu.cc/browse/GHZS-4256 2024-01-23 16:36:54 +08:00
ee1a17d221 feat:自定义页面曝光埋点:https://jira.shanqu.cc/projects/GHZS/issues/GHZS-4397?filter=myopenissues 2024-01-23 16:36:54 +08:00
472bef5880 feat: APP内容配置重构-自定义页面下载按钮—客户端 https://jira.shanqu.cc/browse/GHZS-4255 2024-01-23 16:36:54 +08:00
b9b13413d5 fix: 补充自定义页面轮播发现页卡片获取游戏逻辑 https://jira.shanqu.cc/browse/GHZS-4596 2024-01-23 16:36:54 +08:00
11fccb2086 fix: 0119测试-客户端(2) https://jira.shanqu.cc/browse/GHZS-4596 2024-01-23 16:36:54 +08:00
3bbaa93503 feat:APP内容配置重构-客户端-页面:自定义页面-01/19测试-客户端 https://jira.shanqu.cc/browse/GHZS-4601 2024-01-23 16:36:54 +08:00
ae4758e7d1 feat: APP内容配置重构-附属需求:弹窗顺序 https://jira.shanqu.cc/browse/GHZS-4086 2024-01-23 16:36:54 +08:00
7a758e0efa fix: APP内容配置重构-其他组件:搜索栏—客户端(修复点击搜索栏无法跳转的问题) https://jira.shanqu.cc/browse/GHZS-4073 2024-01-23 16:36:53 +08:00
0c8925711a fix: APP内容配置重构-其他组件:下拉推送—客户端 (修复下拉推送UI显示问题) https://jira.shanqu.cc/browse/GHZS-4070 2024-01-23 16:36:53 +08:00
d94dd0329d fix:修复折叠滑动大图,图标矩阵crash https://jira.shanqu.cc/browse/GHZS-4076 2024-01-23 16:36:53 +08:00
cb2ea46eb9 fix:光环APP】APP内容配置重构-客户端-页面:自定义页面:修复crash https://jira.shanqu.cc/browse/GHZS-4076 2024-01-23 16:36:53 +08:00
7c649a80b0 fix: 修复懒加载问题 2024-01-23 16:36:53 +08:00
795a850d12 fix: APP内容配置重构-底部tab—客户端(关闭ViewPager2离屏加载,设置缓存数量) https://jira.shanqu.cc/browse/GHZS-4025 2024-01-23 16:36:53 +08:00
97c69ed5b4 fix: APP内容配置重构-底部tab—客户端(修复视频Tab显示问题) https://jira.shanqu.cc/browse/GHZS-4025 2024-01-23 16:36:53 +08:00
e7785a586d fix: APP内容配置重构-其他组件:下拉推送—客户端(修复首页为自定义页面时下拉推送搜索栏没有更新背景的问题) https://jira.shanqu.cc/browse/GHZS-4070 2024-01-23 16:36:53 +08:00
179e0936be feat:【光环APP】APP内容配置重构-客户端-页面:自定义页面 https://jira.shanqu.cc/browse/GHZS-4076 2024-01-23 16:36:53 +08:00
3ab8514a0d feat:APP内容配置重构-页面:自定义页面—客户端 https://jira.shanqu.cc/projects/GHZS/issues/GHZS-4077?filter=myopenissues 2024-01-23 16:36:53 +08:00
4af0abaf83 ci 2024-01-23 16:36:53 +08:00
455b93328b feat: APP内容配置重构-换一批—客户端 https://jira.shanqu.cc/browse/GHZS-4256
feat: APP内容配置重构-刷新轮换—客户端 https://jira.shanqu.cc/browse/GHZS-4257
feat: APP内容配置重构-其他组件:搜索栏—客户端 https://jira.shanqu.cc/browse/GHZS-4073
feat: APP内容配置重构-页面:多tab导航页—客户端 https://jira.shanqu.cc/browse/GHZS-4080
feat: APP内容配置重构-其他组件:下拉推送—客户端 https://jira.shanqu.cc/browse/GHZS-4070
feat: APP内容配置重构-页面:多tab导航页—客户端 https://jira.shanqu.cc/browse/GHZS-4080
feat: APP内容配置重构-底部tab—客户端 https://jira.shanqu.cc/browse/GHZS-4025
2024-01-23 16:36:53 +08:00
76beb0188b 对接通用内容合集数据
处理折叠滑动大图气泡动画
2024-01-23 16:36:53 +08:00
b03f7433f8 feat:APP内容配置重构-页面:自定义页面—客户端... 2024-01-23 16:36:53 +08:00
38dc8d2f86 feat: APP内容配置重构-附属需求:弹窗顺序 https://jira.shanqu.cc/browse/GHZS-4086 2024-01-23 16:36:53 +08:00
a9be547587 fix: 处理代码冲突 2024-01-23 16:36:52 +08:00
1e58bc9064 feat: 移除无用的游戏名后缀字段
Signed-off-by: chenjuntao <chenjuntao@ghzhushou.com>
2024-01-23 16:36:52 +08:00
6f3018d4aa feat: 移除 GameEntity 无用的字段和方法,移除 Config 的一键修复相关功能 https://jira.shanqu.cc/browse/GHZS-4274 2024-01-23 16:36:52 +08:00
406 changed files with 27735 additions and 4721 deletions

View File

@ -72,6 +72,7 @@ android_build:
only:
- dev
- dev-5.33.0
- feat/GHZS-3956
# 代码检查
sonarqube_analysis:
@ -103,6 +104,7 @@ sonarqube_analysis:
only:
- dev
- dev-5.33.0
- feat/GHZS-3956
## 发送简易检测结果报告
send_sonar_report:
@ -121,6 +123,7 @@ send_sonar_report:
only:
- dev
- dev-5.33.0
- feat/GHZS-3956
oss-upload&send-email:
tags:
@ -152,4 +155,5 @@ oss-upload&send-email:
- /usr/local/bin/python /ci-android-mail-jira-comment.py
only:
- dev
- dev-5.33.0
- dev-5.33.0
- feat/GHZS-3956

View File

@ -193,7 +193,7 @@
android:screenOrientation="portrait" />
<activity
android:name="com.gh.gamecenter.NewsDetailActivity"
android:name="com.gh.gamecenter.newsdetail.NewsDetailActivity"
android:screenOrientation="portrait" />
<activity
@ -248,7 +248,7 @@
android:windowSoftInputMode="stateHidden" />
<activity
android:name="com.gh.gamecenter.LibaoDetailActivity"
android:name="com.gh.gamecenter.libao.LibaoDetailActivity"
android:screenOrientation="portrait" />
<activity
@ -701,7 +701,7 @@
android:screenOrientation="portrait" />
<activity
android:name="com.gh.gamecenter.toolbox.ToolBoxBlockActivity"
android:name="com.gh.gamecenter.toolbox.ToolBoxActivity"
android:screenOrientation="portrait" />
<activity
@ -778,6 +778,10 @@
android:name="com.gh.gamecenter.SplashAdActivity"
android:screenOrientation="portrait" />
<activity
android:name="com.gh.gamecenter.wrapper.ToolbarWrapperActivity"
android:screenOrientation="portrait" />
<!-- <activity-->
<!-- android:name="${applicationId}.douyinapi.DouYinEntryActivity"-->

View File

@ -0,0 +1 @@
{"v":"5.12.2","fr":60,"ip":0,"op":40,"w":66,"h":66,"nm":"icon_tab_my","ddd":0,"assets":[{"id":"comp_0","nm":"icon","fr":60,"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"highlight","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[33.134,34.5,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":1,"k":[{"i":{"x":0.667,"y":0.733},"o":{"x":0.333,"y":0},"t":0,"s":[{"i":[[0,-0.004],[0.493,0],[0,0.004],[-0.493,0]],"o":[[0,0.004],[-0.493,0],[0,-0.004],[0.493,0]],"v":[[0.893,1.488],[0,1.496],[-0.893,1.488],[0,1.483]],"c":true}]},{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0.267},"t":10,"s":[{"i":[[0,-1.018],[1.793,0],[0,1.018],[-1.793,0]],"o":[[0,1.018],[-1.793,0],[0,-1.018],[1.793,0]],"v":[[2.914,-0.344],[0,1.5],[-2.914,-0.344],[0,-1.5]],"c":true}]},{"i":{"x":0.333,"y":1},"o":{"x":0.667,"y":0},"t":18,"s":[{"i":[[0,-1.181],[1.407,0],[0,1.181],[-1.407,0]],"o":[[0,1.181],[-1.407,0],[0,-1.181],[1.407,0]],"v":[[2.226,-0.341],[0,1.74],[-2.211,-0.341],[0,-1.74]],"c":true}]},{"i":{"x":0.333,"y":1},"o":{"x":0.667,"y":0},"t":26,"s":[{"i":[[0,-0.905],[1.381,0],[0,0.905],[-1.381,0]],"o":[[0,0.905],[-1.381,0],[0,-0.905],[1.381,0]],"v":[[2.5,-0.306],[0,1.333],[-2.5,-0.306],[0,-1.333]],"c":true}]},{"t":32,"s":[{"i":[[0,-1.018],[1.381,0],[0,1.018],[-1.381,0]],"o":[[0,1.018],[-1.381,0],[0,-1.018],[1.381,0]],"v":[[2.5,-0.344],[0,1.5],[-2.5,-0.344],[0,-1.5]],"c":true}]}],"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"color","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[300,300],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"椭圆形","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":60,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"body","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[33,34.204,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-3.866,0],[0,3.866],[3.866,0],[0,-3.866]],"o":[[3.866,0],[0,-3.866],[-3.866,0],[0,3.866]],"v":[[0,4.599],[7,-2.401],[0,-9.401],[-7,-2.401]],"c":true},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ind":1,"ty":"sh","ix":2,"ks":{"a":0,"k":{"i":[[0.207,0.359],[2.438,0],[1.189,-2.104],[-0.361,-0.204],[-0.204,0.361],[-1.915,0],[-0.932,-1.613],[-0.359,0.207]],"o":[[-1.198,-2.072],[-2.462,0],[-0.204,0.361],[0.361,0.204],[0.925,-1.638],[1.897,0],[0.207,0.359],[0.359,-0.207]],"v":[[5.848,8.225],[0,4.849],[-5.88,8.282],[-5.596,9.304],[-4.574,9.02],[0,6.349],[4.549,8.976],[5.574,9.25]],"c":true},"ix":2},"nm":"路径 2","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"mm","mm":1,"nm":"合并路径 1","mn":"ADBE Vector Filter - Merge","hd":false},{"ty":"gf","o":{"a":0,"k":100,"ix":10},"r":1,"bm":0,"g":{"p":3,"k":{"a":0,"k":[0,0.267,0.639,1,0.5,0.241,0.596,1,1,0.216,0.553,1],"ix":9}},"s":{"a":0,"k":[-3.812,-4.384],"ix":5},"e":{"a":0,"k":[6.345,8.129],"ix":6},"t":1,"nm":"color","mn":"ADBE Vector Graphic - G-Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[300,300],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"Union","np":4,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":60,"st":0,"ct":1,"bm":0}]}],"layers":[{"ddd":0,"ind":1,"ty":0,"nm":"icon","refId":"comp_0","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[33,33,0],"ix":2,"l":2},"a":{"a":0,"k":[33,33,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":0,"s":[100,100,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":8,"s":[70,70,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":18,"s":[110,110,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":26,"s":[90,90,100]},{"t":32,"s":[100,100,100]}],"ix":6,"l":2}},"ao":0,"w":66,"h":66,"ip":0,"op":60,"st":0,"bm":0}],"markers":[],"props":{}}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

View File

@ -15,9 +15,7 @@ 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.LibaoDetailActivity
import com.gh.gamecenter.MainActivity
import com.gh.gamecenter.NewsDetailActivity
import com.gh.gamecenter.WebActivity
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.constant.EntranceConsts
@ -38,12 +36,14 @@ import com.gh.gamecenter.eventbus.EBSkip
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.utils.PlatformUtils
import com.gh.gamecenter.fragment.MainWrapperFragment
import com.gh.gamecenter.gamecollection.publish.GameCollectionEditActivity
import com.gh.gamecenter.libao.LibaoDetailActivity
import com.gh.gamecenter.newsdetail.NewsDetailActivity
import com.gh.gamecenter.qa.BbsType
import com.gh.gamecenter.qa.video.publish.VideoPublishActivity
import com.gh.gamecenter.subject.SubjectActivity
import com.gh.gamecenter.video.detail.VideoDetailContainerViewModel
import com.gh.gamecenter.wrapper.MainWrapperFragment
import com.lightgame.utils.Utils
import org.greenrobot.eventbus.EventBus
import java.nio.charset.Charset
@ -503,13 +503,13 @@ object DefaultUrlHandler {
EntranceConsts.HOST_GAME_LIBRARY -> {
DirectUtils.directToMainActivity(context)
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_GAME))
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.TYPE_GAME_LIBRARY))
}
EntranceConsts.HOST_HOME_GAME_COLLECTION_SQUARE -> {
DirectUtils.directToMainActivity(context)
EventBus.getDefault()
.post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_HOME))
.post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.TYPE_HOME))
EventBus.getDefault().post(EBReuse(host))
}

View File

@ -1,18 +0,0 @@
package com.gh.common.chain
import android.content.Context
import com.gh.common.dialog.CertificationDialog
import com.gh.gamecenter.feature.entity.GameEntity
class CertificationHandler : DownloadChainHandler() {
override fun handleRequest(context: Context, gameEntity: GameEntity, asVGame: Boolean) {
CertificationDialog.showCertificationDialog(context, gameEntity) {
if (hasNext()) {
getNext()?.handleRequest(context, gameEntity, asVGame)
} else {
processEndCallback?.invoke(asVGame, null)
}
}
}
}

View File

@ -8,7 +8,6 @@ import android.text.TextUtils;
import androidx.annotation.Nullable;
import com.gh.common.util.AdHelper;
import com.gh.common.util.PackageHelper;
import com.gh.common.util.PackageUtils;
import com.gh.gamecenter.BuildConfig;
@ -26,21 +25,18 @@ import com.gh.gamecenter.entity.GameGuidePopupEntity;
import com.gh.gamecenter.entity.NewApiSettingsEntity;
import com.gh.gamecenter.entity.NewSettingsEntity;
import com.gh.gamecenter.entity.VSetting;
import com.gh.gamecenter.feature.entity.NewsEntity;
import com.gh.gamecenter.feature.entity.SettingsEntity;
import com.gh.gamecenter.feature.entity.SimulatorEntity;
import com.gh.gamecenter.feature.utils.ContentBlockedHelper;
import com.gh.gamecenter.retrofit.RetrofitManager;
import com.gh.vspace.VHelper;
import com.halo.assistant.HaloApp;
import com.lightgame.utils.Utils;
import org.greenrobot.eventbus.EventBus;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.util.List;
import java.util.Locale;
import io.reactivex.android.schedulers.AndroidSchedulers;
@ -76,51 +72,10 @@ public class Config {
private static GameGuidePopupEntity mGameGuidePopupEntity;
private static SharedPreferences mDefaultSharedPreferences;
public static final String FIX_DOWNLOAD_KEY = "isFixDownload";
public static final String FIX_PLUGIN_KEY = "isFixPlugin";
public static final int VIDEO_PAGE_SIZE = 21; // 视频列表大多都是一行3个
public static boolean isShow() {
if (SPUtils.getBoolean(Constants.SP_TEENAGER_MODE)) return false;
if (getPreferences().getBoolean(FIX_DOWNLOAD_KEY, false)) return true;
if (!isExistDownloadFilter()) return false;
for (SettingsEntity.Download entity : getSettings().getDownload()) {
if ("all".equals(entity.getGame())) {
if (entity.getPluginfy() && "normal".equals(entity.getPolicy()) && filterTime(entity.getTime())) {
return true;
}
}
}
return false;
}
public static boolean isShowDownload(String gameId) {
if (getPreferences().getBoolean(FIX_DOWNLOAD_KEY, false)) return true;
if (TextUtils.isEmpty(gameId) || !isExistDownloadFilter())
return false;
for (SettingsEntity.Download entity : getSettings().getDownload()) {
if (gameId.equals(entity.getGame())) {
if ("normal".equals(entity.getPolicy()) && filterTime(entity.getTime())) {
return true;
} else {
return false;
}
} else if ("all".equals(entity.getGame())) {
if ("normal".equals(entity.getPolicy()) && filterTime(entity.getTime())) {
return true;
}
}
}
return false;
return !SPUtils.getBoolean(Constants.SP_TEENAGER_MODE);
}
/**
@ -136,74 +91,10 @@ public class Config {
return mNewApiSettingsEntity.getInstall().getVpnRequired().getShouldShowVpnOption();
}
public static boolean isShowPlugin(String gameId) {
SharedPreferences preferences = getPreferences();
boolean isFixPlugin = preferences.getBoolean(FIX_PLUGIN_KEY, false);
if (isFixPlugin) return true;
if (TextUtils.isEmpty(gameId) || !isExistDownloadFilter())
return false;
for (SettingsEntity.Download entity : getSettings().getDownload()) {
if (gameId.equals(entity.getGame())) {
if (entity.getPluginfy() && filterTime(entity.getTime())) {
return true;
} else {
return false;
}
}
if ("all".equals(entity.getGame())) {
if (entity.getPluginfy() && filterTime(entity.getTime())) {
preferences.edit().putBoolean(FIX_PLUGIN_KEY, true).apply();
return true;
}
}
}
return false;
}
public static boolean isShowPlugin() {
SharedPreferences preferences = getPreferences();
boolean isFixPlugin = preferences.getBoolean(FIX_PLUGIN_KEY, false);
if (isFixPlugin) return true;
if (!isExistDownloadFilter())
return false;
for (SettingsEntity.Download entity : getSettings().getDownload()) {
if ("all".equals(entity.getGame())) {
if (entity.getPluginfy() && filterTime(entity.getTime())) {
preferences.edit().putBoolean(FIX_PLUGIN_KEY, true).apply();
return true;
}
}
}
return false;
}
private static boolean filterTime(SettingsEntity.Download.TimeEntity timeEntity) {
long end = timeEntity.getEnd();
long start = timeEntity.getStart();
long curTime = Utils.getTime(HaloApp.getInstance().getApplication());
if ((start == 0 || curTime >= start) && (end == 0 || curTime <= end)) {
return true;
}
return false;
}
public static void setSettings(SettingsEntity settingsEntity) {
getPreferences().edit().putString(SETTINGS_KEY, GsonUtils.toJson(settingsEntity)).apply();
mSettingsEntity = settingsEntity;
// 更新设置状态
mSettingsEntity.showArticleEntrance();
mSettingsEntity.showCommunityEntrance();
// 加载完设置后刷新下
PackageHelper.initList();
}
@ -331,27 +222,6 @@ public class Config {
return mGameGuidePopupEntity;
}
private static boolean isExistDownloadFilter() {
if (getSettings() == null || getSettings().getDownload() == null || getSettings().getDownload().size() == 0) {
return false;
} else {
return true;
}
}
public static void filterPluginArticle(List<NewsEntity> list) {
if (isShowPlugin() || list == null) return;
for (int i = 0; i < list.size(); i++) {
NewsEntity newsEntity = list.get(i);
String title = newsEntity.getTitle();
if (!TextUtils.isEmpty(title) && title.contains("插件")) {
list.remove(i);
i--;
}
}
}
public static SharedPreferences getPreferences() {
if (mDefaultSharedPreferences == null) {
mDefaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(HaloApp.getInstance().getApplication());
@ -382,9 +252,6 @@ public class Config {
GsonUtils.toJson(response.getSuggestion()));
edit.apply();
if (!getPreferences().getBoolean(Config.FIX_DOWNLOAD_KEY, false) && Config.isShow()) {
getPreferences().edit().putBoolean(Config.FIX_DOWNLOAD_KEY, true).apply();
}
if (!SPUtils.getBoolean(Constants.SP_TEENAGER_MODE)) {
EventBus.getDefault().post(new EBReuse("Refresh"));
}

View File

@ -15,7 +15,6 @@ import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.gh.common.chain.BrowserInstallHandler;
import com.gh.common.chain.CertificationHandler;
import com.gh.common.chain.DownloadChainBuilder;
import com.gh.common.chain.DownloadChainHandler;
import com.gh.common.chain.CheckDownloadHandler;
@ -109,7 +108,6 @@ public class BindingAdapters {
// 判断是否显示按钮
if (gameEntity != null
&& Config.isShowDownload(gameEntity.getId())
&& !"光环助手".equals(gameEntity.getName())) {
progressBar.setVisibility(View.VISIBLE);
} else {
@ -156,7 +154,6 @@ public class BindingAdapters {
builder.addHandler(new BrowserInstallHandler());
builder.addHandler(new PackageCheckHandler());
builder.addHandler(new DownloadDialogHelperHandler());
builder.addHandler(new CertificationHandler());
builder.addHandler(new VersionNumberHandler());
builder.addHandler(new LandPageAddressHandler());
builder.addHandler(new OverseaDownloadHandler());
@ -185,7 +182,6 @@ public class BindingAdapters {
DownloadChainBuilder builder = new DownloadChainBuilder();
builder.addHandler(new UnsupportedFeatureHandler());
builder.addHandler(new GamePermissionHandler());
builder.addHandler(new CertificationHandler());
builder.addHandler(new VersionNumberHandler());
builder.setProcessEndCallback((asVGame, isSubscribe) -> {
@ -540,11 +536,10 @@ public class BindingAdapters {
}
}
public static void setGameName(TextView view, GameEntity game, boolean isShowPlatform, @Nullable Boolean isShowSuffix) {
if (isShowSuffix == null) isShowSuffix = true; // 默认显示
public static void setGameName(TextView view, GameEntity game, boolean isShowPlatform) {
String gameName;
if (isShowPlatform && game.getApk().size() > 0) {
gameName = String.format("%s - %s", !isShowSuffix ? game.getNameWithoutSuffix() : game.getName(),
gameName = String.format("%s - %s", game.getName(),
PlatformUtils.getInstance(view.getContext()).getPlatformName(
game.getApk().get(0).getPlatform()));
if (!gameName.equals((String) view.getTag(R.string.tag_game_name_id))) {
@ -552,7 +547,7 @@ public class BindingAdapters {
view.setTag(R.string.tag_game_name_id, gameName);
}
} else {
gameName = !isShowSuffix ? game.getNameWithoutSuffix() : game.getName();
gameName = game.getName();
if (gameName != null && !gameName.equals((String) view.getTag(R.string.tag_game_name_id))) {
view.setText(gameName);
view.setTag(R.string.tag_game_name_id, gameName);

View File

@ -1,221 +0,0 @@
package com.gh.common.dialog
import android.annotation.SuppressLint
import android.app.Activity
import android.app.Dialog
import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.graphics.Paint
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.widget.CheckBox
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import com.gh.gamecenter.common.avoidcallback.AvoidOnResultManager
import com.gh.gamecenter.common.avoidcallback.Callback
import com.gh.gamecenter.common.constant.Constants
import com.gh.common.util.*
import com.gh.gamecenter.R
import com.gh.gamecenter.ShellActivity
import com.gh.gamecenter.common.callback.ConfirmListener
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.utils.SensorsBridge
import com.gh.gamecenter.core.utils.GsonUtils
import com.gh.gamecenter.core.utils.SPUtils
import com.gh.gamecenter.feature.entity.AuthDialogEntity
import com.gh.gamecenter.feature.entity.AuthDialogLevel
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.login.user.UserManager
import com.google.gson.reflect.TypeToken
import com.halo.assistant.fragment.user.UserInfoEditFragment
import com.lightgame.utils.AppManager
class CertificationDialog(
context: Context,
private val authDialogEntity: AuthDialogEntity,
val gameEntity: GameEntity,
val listener: ConfirmListener
) :
Dialog(context, R.style.GhAlertDialog) {
private lateinit var view: View
private lateinit var detailedDesTv: TextView
private lateinit var noRemindAgainCb: CheckBox
private lateinit var actionLeftTv: TextView
private lateinit var actionRightTv: TextView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
view = LayoutInflater.from(context).inflate(R.layout.dialog_sertification, null)
setContentView(view)
detailedDesTv = view.findViewById(R.id.detailedDesTv)
noRemindAgainCb = view.findViewById(R.id.noRemindAgainCb)
actionLeftTv = view.findViewById(R.id.actionLeftTv)
actionRightTv = view.findViewById(R.id.actionRightTv)
detailedDesTv.paint.flags = Paint.UNDERLINE_TEXT_FLAG
detailedDesTv.paint.isAntiAlias = true
detailedDesTv.setOnClickListener {
DirectUtils.directToWebView(context, authDialogEntity.link)
}
when (authDialogEntity.level) {
AuthDialogLevel.MUST_PASS.value -> {
actionLeftTv.text = "暂不下载"
actionRightTv.text = "去实名认证"
noRemindAgainCb.visibility = View.GONE
actionLeftTv.setOnClickListener {
SensorsBridge.trackEvent("VerificationPopupClick", "button_name", actionLeftTv.text.toString())
dismiss()
}
actionRightTv.setOnClickListener {
SensorsBridge.trackEvent("VerificationPopupClick", "button_name", actionRightTv.text.toString())
if (UserManager.getInstance().isLoggedIn) {
gotoAuthPage()
} else {
gotoLoginPage()
}
}
}
AuthDialogLevel.ALWAYS_HINT.value -> {
actionLeftTv.text = "去实名认证"
actionRightTv.text = "继续下载"
noRemindAgainCb.visibility = View.GONE
actionLeftTv.setOnClickListener {
SensorsBridge.trackEvent("VerificationPopupClick", "button_name", actionLeftTv.text.toString())
if (UserManager.getInstance().isLoggedIn) {
gotoAuthPage()
} else {
gotoLoginPage()
}
}
actionRightTv.setOnClickListener {
SensorsBridge.trackEvent("VerificationPopupClick", "button_name", actionRightTv.text.toString())
listener.onConfirm()
dismiss()
}
}
AuthDialogLevel.OPTIONAL_HINT.value -> {
actionLeftTv.text = "去实名认证"
actionRightTv.text = "继续下载"
noRemindAgainCb.visibility = View.VISIBLE
actionLeftTv.setOnClickListener {
SensorsBridge.trackEvent("VerificationPopupClick", "button_name", actionLeftTv.text.toString())
if (noRemindAgainCb.isChecked) {
SPUtils.setBoolean(gameEntity.id, true)
}
if (UserManager.getInstance().isLoggedIn) {
gotoAuthPage()
} else {
gotoLoginPage()
}
}
actionRightTv.setOnClickListener {
SensorsBridge.trackEvent("VerificationPopupClick", "button_name", actionRightTv.text.toString())
if (noRemindAgainCb.isChecked) {
SPUtils.getBoolean(gameEntity.id, true)
}
listener.onConfirm()
dismiss()
}
}
}
SensorsBridge.trackEvent(
"VerificationDialogShow",
"game_id",
gameEntity.id,
"game_name",
gameEntity.name ?: "",
"game_type",
gameEntity.categoryChinese
)
}
//跳转登录页面
private fun gotoLoginPage() {
val currentActivity = AppManager.getInstance().currentActivity() ?: return
CheckLoginUtils.checkLogin(
currentActivity as AppCompatActivity,
null, true, "实名认证弹窗"
) {
if (UserManager.getInstance().isAuth) {
listener.onConfirm()
dismiss()
}
}
}
//跳转实名认证页面
private fun gotoAuthPage() {
val currentActivity = AppManager.getInstance().currentActivity() ?: return
AvoidOnResultManager.getInstance(currentActivity as AppCompatActivity)
.startForResult(
ShellActivity.getIntent(
context,
ShellActivity.Type.REAL_NAME_INFO,
).apply {
putExtra(EntranceConsts.KEY_GAME_ID, gameEntity.id)
}, object : Callback {
override fun onActivityResult(resultCode: Int, data: Intent?) {
if (resultCode == Activity.RESULT_OK && data != null) {
val isAuthSuccess =
data.getBooleanExtra(UserInfoEditFragment.AUTH_SUCCESS, false)
if (isAuthSuccess) {
listener.onConfirm()
dismiss()
}
}
}
})
}
companion object {
@JvmStatic
fun showCertificationDialog(context: Context, game: GameEntity, listener: ConfirmListener) {
//1.先判断是否登录 是执行2 否执行3
//2.判断是否实名认证 是终止 否执行3
//3.判断是否需要弹出认证弹窗接口
if (UserManager.getInstance().isLoggedIn) {
if (UserManager.getInstance().isAuth) {//已实名认证
listener.onConfirm()
} else {
authDialog(context, game, listener)
}
} else {
authDialog(context, game, listener)
}
}
@SuppressLint("CheckResult")
private fun authDialog(context: Context, game: GameEntity, listener: ConfirmListener) {
var authDialog: AuthDialogEntity? = null
if (game.authDialog != null) {
authDialog = game.authDialog
}
if (authDialog == null) {
val datas = SPUtils.getString(Constants.SP_AUTH_DIALOG)
val type = object : TypeToken<List<AuthDialogEntity>>() {}.type
val authDialogs = GsonUtils.gson.fromJson<List<AuthDialogEntity>>(datas, type)
if (!authDialogs.isNullOrEmpty()) {
authDialog = authDialogs.find { it.gameCategory == game.category }
}
}
val isCloseAuthDialog = SPUtils.getBoolean(game.id, false)
if (authDialog != null && (authDialog.level != AuthDialogLevel.OPTIONAL_HINT.value || !isCloseAuthDialog)) {
val dialog = CertificationDialog(context, authDialog, game, listener)
dialog.show()
} else {
listener.onConfirm()
}
}
}
}

View File

@ -29,6 +29,15 @@ class PrivacyPolicyDialogFragment : BaseDialogFragment() {
private var mCallBack: ((isSuccess: Boolean) -> Unit)? = null
private val mBinding by lazy { DialogPrivacyProtocolBinding.inflate(layoutInflater) }
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (savedInstanceState != null) {
dismiss()
return
}
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,

View File

@ -24,6 +24,15 @@ class ReserveDialog : BaseDialogFragment() {
private lateinit var mReserveList: List<SimpleGameEntity>
private var mDismissListener: (() -> Unit)? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (savedInstanceState != null) {
dismiss()
return
}
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
val binding: DialogReserveBinding = DialogReserveBinding.inflate(layoutInflater, null, false)

View File

@ -75,7 +75,6 @@ object HistoryHelper {
historyGame.iconFloat = gameEntity.iconFloat
historyGame.name = gameEntity.name
historyGame.tagStyle = gameEntity.tagStyle
historyGame.tag = gameEntity.getTag()
historyGame.subtitle = gameEntity.subtitle
historyGame.subtitleStyle = gameEntity.subtitleStyle
return historyGame

View File

@ -0,0 +1,11 @@
package com.gh.common.iinterface
import com.gh.gamecenter.entity.PullDownPush
interface ISmartRefresh {
fun setSmartRefreshEnabled(isEnable: Boolean)
fun finishTwoLevel(action: String)
fun finishRefresh()
fun popupPullDownPush(finishCallback: () -> Unit)
fun setPullDownPush(pullDownPush: PullDownPush?)
}

View File

@ -0,0 +1,21 @@
package com.gh.common.iinterface
import android.view.View
interface ISmartRefreshContent {
/**
* 启用/关闭 页面滑动
* @param isScrollEnabled 是否启用
*/
fun setScrollEnabled(isScrollEnabled: Boolean)
fun onRefresh()
/**
* 启用/关闭 SwipeRefreshLayout 的下拉刷新
* @param isSwipeRefreshEnabled 是否启用
*/
fun setSwipeRefreshEnabled(isSwipeRefreshEnabled: Boolean)
fun provideSlideBackgroundView(): View?
}

View File

@ -0,0 +1,9 @@
package com.gh.common.iinterface
import com.gh.common.prioritychain.PriorityChain
interface ISuperiorChain {
fun registerInferiorChain(chain: PriorityChain)
fun unregisterInferiorChain(chain: PriorityChain)
}

View File

@ -14,7 +14,7 @@ import com.gh.gamecenter.core.utils.DisplayUtils
import com.gh.gamecenter.core.utils.SPUtils
import com.gh.gamecenter.databinding.PopupAccelerateNotificationBinding
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.fragment.MainWrapperViewModel
import com.gh.gamecenter.wrapper.MainWrapperViewModel
class AccelerateNotificationHandler(priority: Int) : PriorityChainHandler(priority) {
@ -42,7 +42,7 @@ class AccelerateNotificationHandler(priority: Int) : PriorityChainHandler(priori
processNext()
} else {
updateStatus(STATUS_VALID)
onProcess()
process()
}
} else {
if (gameEntityList == null) {
@ -53,7 +53,7 @@ class AccelerateNotificationHandler(priority: Int) : PriorityChainHandler(priori
}
}
override fun onProcess() {
override fun onProcess() : Boolean {
when (getStatus()) {
STATUS_VALID -> {
val accelerateSet =
@ -64,6 +64,7 @@ class AccelerateNotificationHandler(priority: Int) : PriorityChainHandler(priori
}
accelerateSet.add(mGameList!![0].messageId)
SPUtils.setStringSet(Constants.SP_ACCELERATE_NOTIFICATION_POP_UP_SET, accelerateSet)
return true
} else {
processNext()
}
@ -73,6 +74,8 @@ class AccelerateNotificationHandler(priority: Int) : PriorityChainHandler(priori
processNext()
}
}
return false
}
companion object {

View File

@ -0,0 +1,82 @@
package com.gh.common.prioritychain
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.gh.gamecenter.floatingwindow.FloatingWindowEntity
import com.gh.gamecenter.livedata.Event
class CustomFloatingWindowHandler(priority: Int) : PriorityChainHandler(priority) {
private val data = arrayListOf<FloatingWindowEntity>()
private val _showFloatingAction = MutableLiveData<Event<ArrayList<FloatingWindowEntity>>>()
val showFloatingAction: LiveData<Event<ArrayList<FloatingWindowEntity>>> = _showFloatingAction
fun setData(newData: List<FloatingWindowEntity>) {
data.clear()
data.addAll(newData)
doPreProcess()
}
private fun doPreProcess() {
// debugOnly {
// data.clear()
// data.add(
// FloatingWindowEntity(
// id = "audire",
// image = "https://jira.shanqu.cc/secure/attachment/57822/57822_image-2023-12-01-17-53-04-492.png",
// link = WelcomeDialogEntity(
// id = null,
// time = null,
// packages = null,
// floatingWindowId = null,
// shouldShowExitAnimation = false
// ),
// pushType = "maiorum",
// expandable = false,
// expandedImage = "fermentum",
// bigPopupNotice = "dignissim"
// )
// )
// }
if (getStatus() == STATUS_PENDING) {
if (data.isNotEmpty()) {
updateStatus(STATUS_VALID)
process()
} else {
processNext()
}
} else {
if (data.isNotEmpty()) {
updateStatus(STATUS_VALID)
} else {
updateStatus(STATUS_INVALID)
}
}
}
override fun onProcess(): Boolean {
when (getStatus()) {
STATUS_VALID -> {
_showFloatingAction.value = Event(data)
processNext()
// floatingWindowProvider.showFloatingWindowOnly(
// mFragment!!,
// mRecyclerView!!,
// mWindowList!!,
// ) {
// val welcomeDialog = WelcomeDialogFragment.getInstance(it, true, mFragment)
// welcomeDialog.show(mFragment!!.childFragmentManager, "WelcomeDialog")
// }
}
STATUS_INVALID -> {
processNext()
}
}
return false
}
}

View File

@ -42,7 +42,7 @@ class FloatingWindowHandler(priority: Int) : PriorityChainHandler(priority) {
if (getStatus() == STATUS_PENDING) {
if (!mWindowList.isNullOrEmpty()) {
updateStatus(STATUS_VALID)
onProcess()
process()
} else {
processNext()
}
@ -55,7 +55,7 @@ class FloatingWindowHandler(priority: Int) : PriorityChainHandler(priority) {
}
}
override fun onProcess() {
override fun onProcess(): Boolean {
when (getStatus()) {
STATUS_VALID -> {
val floatingWindowProvider =
@ -65,7 +65,7 @@ class FloatingWindowHandler(priority: Int) : PriorityChainHandler(priority) {
// 强校验所有条件均通过才能显示
if (floatingWindowProvider == null || mFragment == null || mFragment?.isAdded == false || mRecyclerView == null) {
processNext()
return
return false
}
floatingWindowProvider.showFloatingWindowOnly(
@ -82,6 +82,8 @@ class FloatingWindowHandler(priority: Int) : PriorityChainHandler(priority) {
processNext()
}
}
return false
}
}

View File

@ -0,0 +1,244 @@
package com.gh.common.prioritychain
import android.annotation.SuppressLint
import android.app.Activity
import android.app.Application.ActivityLifecycleCallbacks
import android.os.Bundle
import android.preference.PreferenceManager
import androidx.fragment.app.FragmentActivity
import com.gh.common.iinterface.ISuperiorChain
import com.gh.common.util.CheckLoginUtils
import com.gh.common.util.PackageUtils
import com.gh.gamecenter.SplashScreenActivity
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.entity.SimpleGameEntity
import com.gh.gamecenter.common.retrofit.BiResponse
import com.gh.gamecenter.common.utils.debugOnly
import com.gh.gamecenter.core.utils.SPUtils
import com.gh.gamecenter.entity.DialogEntity
import com.gh.gamecenter.feature.entity.WelcomeDialogEntity
import com.gh.gamecenter.login.user.UserManager
import com.gh.gamecenter.retrofit.RetrofitManager
import com.halo.assistant.HaloApp
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
/**
* 全局的 APP 优先级弹窗链管理器
*
* 弹窗的优先级为
* 启动跳转(-101) > 更新弹窗(-100) > 隐私政策弹窗(-99) > 消息通知权限弹窗(0) > 预约弹窗(1) > 启动弹窗(2)
*/
object GlobalPriorityChainHelper : ISuperiorChain {
private val api = RetrofitManager.getInstance().api
private var inferiorChain: PriorityChain? = null
private val mainChain: PriorityChain by lazy { PriorityChain { inferiorChain?.start() } }
/**
* 当前 activity 是否使用于应用全局弹窗的弹出
* 排除启动页和其它非 FragmentActivity
*/
fun isThisActivityValid(activity: Activity?): Boolean {
return activity is FragmentActivity
&& !activity.isFinishing
&& activity !is SplashScreenActivity
}
/**
* 预启动所有的优先级弹窗管理链
*/
fun preStart() {
val launchRedirectHandler = LaunchRedirectHandler(-101)
val updateDialogHandler = UpdateDialogHandler(-100)
val privacyPolicyDialogHandler = PrivacyPolicyDialogHandler(-99)
val notificationPermissionDialogHandler = NotificationPermissionDialogHandler(0)
val reserveDialogHandler = ReserveDialogHandler(1)
val welcomeDialogHandler = WelcomeDialogHandler(2)
mainChain.addHandler(launchRedirectHandler)
mainChain.addHandler(updateDialogHandler)
mainChain.addHandler(privacyPolicyDialogHandler)
mainChain.addHandler(welcomeDialogHandler)
mainChain.addHandler(reserveDialogHandler)
mainChain.addHandler(notificationPermissionDialogHandler)
launchRedirectHandler.doPreProcess()
updateDialogHandler.doPreProcess()
requestOpeningDialogData(welcomeDialogHandler, privacyPolicyDialogHandler)
requestReserveDialogData(reserveDialogHandler)
}
/**
* 启动优先级弹窗管理链的执行
*/
fun start() {
if (mainChain.isHandlerQueueEmpty()) return
mainChain.start()
observeLifecycle()
}
private fun observeLifecycle() {
HaloApp.getInstance().registerActivityLifecycleCallbacks(object : ActivityLifecycleCallbacks {
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
// do nothing
}
override fun onActivityStarted(activity: Activity) {
// do nothing
}
override fun onActivityResumed(activity: Activity) {
// 优先级弹窗管理链为空时取消注册,避免无用调用
if (mainChain.isHandlerQueueEmpty()) {
HaloApp.getInstance().unregisterActivityLifecycleCallbacks(this)
} else {
resume()
}
}
override fun onActivityPaused(activity: Activity) {
// do nothing
}
override fun onActivityStopped(activity: Activity) {
// do nothing
}
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {
// do nothing
}
override fun onActivityDestroyed(activity: Activity) {
// do nothing
}
})
}
/**
* 恢复链的处理
*/
fun resume() {
mainChain.resume()
}
/**
* 请求首页启动弹窗相关的数据并执行相关 handler 的 preProcess
*/
@SuppressLint("CheckResult")
private fun requestOpeningDialogData(
welcomeDialogHandler: WelcomeDialogHandler,
privacyPolicyDialogHandler: PrivacyPolicyDialogHandler
) {
val sp = PreferenceManager.getDefaultSharedPreferences(HaloApp.getInstance())
val lastId = SPUtils.getString(sp, Constants.SP_LAST_OPENING_ID, "")
val lastTime = SPUtils.getLong(sp, Constants.SP_LAST_OPENING_TIME, 0)
val openType = if (HaloApp.getInstance().isNewForThisVersion) "first" else "not_first_time"
api.getOpeningDialog(HaloApp.getInstance().channel, lastId, lastTime, openType)
.subscribeOn(Schedulers.io())
.subscribe(object : BiResponse<DialogEntity>() {
override fun onSuccess(data: DialogEntity) {
var welcomeDialogEntity: WelcomeDialogEntity? = null
var privacyPolicyDialogEntity: DialogEntity.PrivacyPolicyEntity? = null
// 全新安装忽略隐私弹窗
if (data.privacyPolicyDialog != null) {
val id = data.privacyPolicyDialog.id
val lastAcceptedId = SPUtils.getString(Constants.SP_LAST_ACCEPTED_PRIVACY_DIALOG_ID, "")
if (HaloApp.getInstance().isBrandNewInstall) {
SPUtils.setString(Constants.SP_LAST_ACCEPTED_PRIVACY_DIALOG_ID, id)
} else {
if (id != lastAcceptedId) {
privacyPolicyDialogEntity = data.privacyPolicyDialog
}
}
}
// debugOnly {
// privacyPolicyDialogEntity = DialogEntity.PrivacyPolicyEntity(
// "5f6f5f3d9d9b4e0001c3b3a5",
// "privacy_policy",
// "ONCE",
// "INFORM",
// "隐私政策",
// 1601116800000)
// }
privacyPolicyDialogHandler.doPreProcess(privacyPolicyDialogEntity)
// 类型为游戏时判断是否本地已安装该游戏,已安装不弹弹窗
if (data.welcomeDialog != null) {
welcomeDialogEntity = data.welcomeDialog
if (data.welcomeDialog.type == "game") {
if (data.welcomeDialog.packages != null) {
for (packageName in data.welcomeDialog.packages!!) {
if (PackageUtils.isInstalled(HaloApp.getInstance(), packageName)) {
welcomeDialogEntity = null
break
}
}
}
}
}
welcomeDialogHandler.doPreProcess(welcomeDialogEntity)
}
override fun onFailure(exception: Exception) {
privacyPolicyDialogHandler.doPreProcess(null)
}
})
}
/**
* 请求预约弹窗相关的数据
*/
@SuppressLint("CheckResult")
private fun requestReserveDialogData(reserveDialogHandler: ReserveDialogHandler) {
// debugOnly {
// reserveDialogHandler.doPreProcess(arrayListOf(SimpleGameEntity(
// "5f6f5f3d9d9b4e0001c3b3a5",
// "5f6f5f3d9d9b4e0001c3b3a5",
// "https://and-static.ghzs.com/image/game/icon/2022/11/18/63772b0d398daaa7c5067298.png",
// "5f6f5f3d9d9b4e0001c3b3a5",
// )))
// return
// }
if (CheckLoginUtils.isLogin()) {
api.getReserveDialog(UserManager.getInstance().userId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : BiResponse<List<SimpleGameEntity>>() {
override fun onSuccess(data: List<SimpleGameEntity>) {
reserveDialogHandler.doPreProcess(data)
}
override fun onFailure(exception: Exception) {
reserveDialogHandler.doPreProcess(null)
}
})
} else {
reserveDialogHandler.doPreProcess(null)
}
}
override fun registerInferiorChain(chain: PriorityChain) {
inferiorChain = chain
if (mainChain.isHandlerQueueEmpty()) {
inferiorChain?.resume()
}
}
override fun unregisterInferiorChain(chain: PriorityChain) {
if (inferiorChain == chain) {
inferiorChain = null
}
}
}

View File

@ -1,26 +1,26 @@
package com.gh.common.prioritychain
import com.gh.gamecenter.fragment.HomeSearchToolWrapperFragment
import com.gh.common.iinterface.ISmartRefresh
class HomePushHandler(priority: Int): PriorityChainHandler(priority) {
private var mHomeFragment: HomeSearchToolWrapperFragment? = null
private var mSmartRefreshFragment: ISmartRefresh? = null
/**
* 提前预处理显示弹窗的内容
*/
fun doPreProcess(homeFragment: HomeSearchToolWrapperFragment?, shouldShow: Boolean) {
mHomeFragment = homeFragment
fun doPreProcess(smartRefreshFragment: ISmartRefresh?, shouldShow: Boolean) {
mSmartRefreshFragment = smartRefreshFragment
if (getStatus() == STATUS_PENDING) {
if (shouldShow && homeFragment != null) {
if (shouldShow && smartRefreshFragment != null) {
updateStatus(STATUS_VALID)
onProcess()
process()
} else {
processNext()
}
} else {
if (shouldShow && homeFragment != null) {
if (shouldShow && smartRefreshFragment != null) {
updateStatus(STATUS_VALID)
} else {
updateStatus(STATUS_INVALID)
@ -28,18 +28,21 @@ class HomePushHandler(priority: Int): PriorityChainHandler(priority) {
}
}
override fun onProcess() {
override fun onProcess(): Boolean {
when (getStatus()) {
STATUS_VALID -> {
// 目前首页下拉二楼是首页最后一个弹窗类的东西,还没实现回调,如果有其它要在它后面弹出的,需要自行在它的实现结果后添加回调
mHomeFragment?.popUpHomePushIfNeeded {
mSmartRefreshFragment?.popupPullDownPush {
processNext()
}
return true
}
STATUS_INVALID -> {
processNext()
}
}
return false
}
}

View File

@ -0,0 +1,86 @@
package com.gh.common.prioritychain
import android.annotation.SuppressLint
import com.gh.common.util.DirectUtils
import com.gh.gamecenter.BuildConfig
import com.gh.gamecenter.common.entity.LaunchRedirect
import com.gh.gamecenter.common.entity.LaunchRedirectWrapper
import com.gh.gamecenter.common.retrofit.BiResponse
import com.gh.gamecenter.common.utils.singleToMain
import com.gh.gamecenter.core.AppExecutor
import com.gh.gamecenter.core.utils.CurrentActivityHolder
import com.gh.gamecenter.retrofit.RetrofitManager
import com.gh.gamecenter.wrapper.MainWrapperRepository
import com.halo.assistant.HaloApp
/**
* 初次启动跳转
*/
class LaunchRedirectHandler(priority: Int) : PriorityChainHandler(priority) {
private var launchData: LaunchRedirect? = null
@SuppressLint("CheckResult")
fun doPreProcess() {
// if (true) {
if (HaloApp.getInstance().isBrandNewInstall) {
RetrofitManager.getInstance().newApi
.getLaunchRedirect(BuildConfig.VERSION_NAME, HaloApp.getInstance().channel)
.compose(singleToMain())
.subscribe(object : BiResponse<LaunchRedirectWrapper>() {
override fun onSuccess(data: LaunchRedirectWrapper) {
launchData = data.launchRedirect
if (launchData == null) {
updateStatus(STATUS_INVALID)
processNext()
return
}
// 尝试提前设置 tab default 避免首页数据加载完成tab 选中会闪烁
if (launchData?.type == "bottom_tab") {
MainWrapperRepository.getInstance().sendMainSelectTabEvent(launchData!!)
}
if (getStatus() == STATUS_PENDING) {
updateStatus(STATUS_VALID)
process()
} else {
updateStatus(STATUS_VALID)
}
}
override fun onFailure(exception: Exception) {
super.onFailure(exception)
updateStatus(STATUS_INVALID)
processNext()
}
})
} else {
updateStatus(STATUS_INVALID)
processNext()
}
}
override fun onProcess(): Boolean {
val currentActivity = CurrentActivityHolder.getCurrentActivity()
if (GlobalPriorityChainHelper.isThisActivityValid(currentActivity)) {
if (getStatus() == STATUS_VALID) {
// 当 type 为 "bottom_tab" 时上面 doPreProcess 中已经处理过了,但再选中一次好像也没有什么问题,先不特殊处理这个 case 了
DirectUtils.directToLinkPage(currentActivity!!, launchData!!, "首次启动跳转", "")
// 跳转页面不管回调,延迟 500ms 后执行下一个 handler
AppExecutor.uiExecutor.executeWithDelay({
processNext()
}, 500L)
return true
} else if (getStatus() == STATUS_INVALID) {
processNext()
}
}
return false
}
}

View File

@ -6,15 +6,18 @@ import com.gh.gamecenter.login.user.UserManager
class NotificationPermissionDialogHandler(priority: Int) : PriorityChainHandler(priority) {
override fun onProcess() {
override fun onProcess(): Boolean {
// 仅登录后再启动光环时请求一次权限
if (UserManager.getInstance().isLoggedIn) {
NotificationHelper.showNotificationHintDialog(NotificationUgc.LOGIN) {
processNext()
}
return true
} else {
processNext()
}
return false
}
}

View File

@ -1,22 +1,54 @@
package com.gh.common.prioritychain
import com.lightgame.utils.Utils
import java.util.*
import java.util.concurrent.PriorityBlockingQueue
class PriorityChain {
class PriorityChain(private val completeCallback: (() -> Unit)? = null) {
private val mHandlerQueue: Queue<PriorityChainHandler> = PriorityBlockingQueue()
private val handlerQueue: Queue<PriorityChainHandler> = PriorityBlockingQueue()
/**
* 添加 handler 到队列中
*/
fun addHandler(handler: PriorityChainHandler) {
mHandlerQueue.add(handler.also {
handlerQueue.add(handler.also {
it.setPriorityChain(this)
})
}
/**
* 启动队列中的 handler
*/
fun start() {
mHandlerQueue.poll()?.process(mHandlerQueue)
handlerQueue.peek()?.let {
it.injectQueue(handlerQueue)
it.process()
}
}
fun isHandlerQueueEmpty() = mHandlerQueue.isEmpty()
/**
* 恢复队列中的 handler
*/
fun resume() {
val handler = handlerQueue.peek()
if (handler?.getStatus() == PriorityChainHandler.STATUS_HANDLING) {
Utils.log(PriorityChainHandler.TAG, "${handler.javaClass.simpleName} 处于执行中状态,不用恢复")
} else {
handler?.injectQueue(handlerQueue)
handler?.process()
}
}
/**
* 队列是否为空
*/
fun isHandlerQueueEmpty() = handlerQueue.isEmpty()
fun onHandleComplete() {
completeCallback?.invoke()
}
}

View File

@ -5,54 +5,76 @@ import java.util.*
abstract class PriorityChainHandler(private val mPriority: Int) : Comparable<PriorityChainHandler> {
private var mStatus = STATUS_UNKNOWN
private var mQueue: Queue<PriorityChainHandler>? = null
private var status = STATUS_UNKNOWN
private var queue: Queue<PriorityChainHandler>? = null
private var mPriorityChain: PriorityChain? = null
private var priorityChain: PriorityChain? = null
/**
* 获取当前 handler 的状态
* - 等待结果返回 STATUS_PENDING
* - 无需执行 STATUS_INVALID
* - 可执行 STATUS_VALID
* - 执行中 STATUS_HANDLING
* - 未知 STATUS_UNKNOWN
*/
fun getStatus(): Int = mStatus
fun getStatus(): Int = status
fun updateStatus(status: Int) {
Utils.log(TAG, "${javaClass.simpleName} updateStatus $status")
Utils.log(TAG, "${javaClass.simpleName} updateStatus ${this.status} $status")
mStatus = status
this.status = status
}
fun setPriorityChain(priorityChain: PriorityChain) {
mPriorityChain = priorityChain
this.priorityChain = priorityChain
}
fun process(queue: Queue<PriorityChainHandler>) {
Utils.log(TAG, "${javaClass.simpleName} process $mStatus")
fun injectQueue(queue: Queue<PriorityChainHandler>) {
this.queue = queue
}
fun process() {
Utils.log(TAG, "${javaClass.simpleName} process $status")
mQueue = queue
// 若当前 handler 未经处理,将其状态改为 pending
if (mStatus == STATUS_UNKNOWN) {
if (status == STATUS_UNKNOWN) {
updateStatus(STATUS_PENDING)
}
onProcess()
if (status == STATUS_HANDLING) {
Utils.log(TAG, "${javaClass.simpleName} 已经处于执行中状态,不用再次执行")
return
}
val isHandling = onProcess()
if (isHandling) {
updateStatus(STATUS_HANDLING)
}
}
/**
* 执行相关功能的地方
* @return 是否满足执行条件并处于执行中状态
*/
abstract fun onProcess()
abstract fun onProcess(): Boolean
/**
* 分发给下一个 handler 处理
*/
fun processNext() {
Utils.log(TAG, "${javaClass.simpleName} processNext $mStatus")
Utils.log(TAG, "${javaClass.simpleName} processNext $status")
mQueue?.poll()?.process(mQueue!!)
queue?.remove(this)
if (queue?.isEmpty() == true) {
priorityChain?.onHandleComplete()
} else {
queue?.peek()?.let {
it.injectQueue(queue!!)
it.process()
}
}
}
override fun compareTo(other: PriorityChainHandler): Int {
@ -64,6 +86,7 @@ abstract class PriorityChainHandler(private val mPriority: Int) : Comparable<Pri
internal const val STATUS_INVALID = 1
internal const val STATUS_VALID = 2
internal const val STATUS_UNKNOWN = 3
internal const val STATUS_HANDLING = 4
const val TAG = "PriorityChainHandler"
}

View File

@ -2,18 +2,17 @@ package com.gh.common.prioritychain
import androidx.fragment.app.FragmentActivity
import com.gh.common.dialog.PrivacyPolicyDialogFragment
import com.gh.gamecenter.core.utils.CurrentActivityHolder
import com.gh.gamecenter.entity.DialogEntity
class PrivacyPolicyDialogHandler(priority: Int) : PriorityChainHandler(priority) {
private var mActivity: FragmentActivity? = null
private var mPrivacyPolicyEntity: DialogEntity.PrivacyPolicyEntity? = null
/**
* 提前预处理显示弹窗的内容
*/
fun doPreProcess(fragmentActivity: FragmentActivity, privacyPolicyEntity: DialogEntity.PrivacyPolicyEntity?) {
mActivity = fragmentActivity
fun doPreProcess(privacyPolicyEntity: DialogEntity.PrivacyPolicyEntity?) {
mPrivacyPolicyEntity = privacyPolicyEntity
if (getStatus() == STATUS_PENDING) {
@ -21,7 +20,7 @@ class PrivacyPolicyDialogHandler(priority: Int) : PriorityChainHandler(priority)
processNext()
} else {
updateStatus(STATUS_VALID)
onProcess()
process()
}
} else {
if (privacyPolicyEntity == null) {
@ -32,17 +31,26 @@ class PrivacyPolicyDialogHandler(priority: Int) : PriorityChainHandler(priority)
}
}
override fun onProcess() {
when(getStatus()) {
STATUS_VALID -> {
PrivacyPolicyDialogFragment.show(mActivity!!, mPrivacyPolicyEntity) { _: Boolean? ->
override fun onProcess(): Boolean {
val currentActivity = CurrentActivityHolder.getCurrentActivity()
if (GlobalPriorityChainHelper.isThisActivityValid(currentActivity)) {
when (getStatus()) {
STATUS_VALID -> {
PrivacyPolicyDialogFragment.show(currentActivity as FragmentActivity, mPrivacyPolicyEntity) { _: Boolean? ->
processNext()
}
return true
}
STATUS_INVALID -> {
processNext()
}
}
STATUS_INVALID -> {
processNext()
}
}
return false
}
}

View File

@ -1,20 +1,18 @@
package com.gh.common.prioritychain
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import com.gh.common.dialog.ReserveDialog
import com.gh.gamecenter.common.entity.SimpleGameEntity
import com.gh.gamecenter.message.MessageUnreadRepository
import com.gh.gamecenter.core.utils.CurrentActivityHolder
class ReserveDialogHandler(priority: Int) : PriorityChainHandler(priority) {
private var mFragment: Fragment? = null
private var mReserveData: List<SimpleGameEntity>? = null
/**
* 提前预处理显示弹窗的内容
*/
fun doPreProcess(fragment: Fragment, reserveData: List<SimpleGameEntity>?) {
mFragment = fragment
fun doPreProcess(reserveData: List<SimpleGameEntity>?) {
mReserveData = reserveData
if (getStatus() == STATUS_PENDING) {
@ -22,7 +20,7 @@ class ReserveDialogHandler(priority: Int) : PriorityChainHandler(priority) {
processNext()
} else {
updateStatus(STATUS_VALID)
onProcess()
process()
}
} else {
if (reserveData.isNullOrEmpty()) {
@ -33,21 +31,28 @@ class ReserveDialogHandler(priority: Int) : PriorityChainHandler(priority) {
}
}
override fun onProcess() {
when (getStatus()) {
STATUS_VALID -> {
val reserveDialog = ReserveDialog.getInstance(mReserveData!!)
reserveDialog.setOnDismissListener {
MessageUnreadRepository.loadMessageUnreadData()
override fun onProcess(): Boolean {
val currentActivity = CurrentActivityHolder.getCurrentActivity()
if (GlobalPriorityChainHelper.isThisActivityValid(currentActivity)) {
when (getStatus()) {
STATUS_VALID -> {
val reserveDialog = ReserveDialog.getInstance(mReserveData!!)
reserveDialog.setOnDismissListener {
processNext()
}
reserveDialog.show((currentActivity as FragmentActivity).supportFragmentManager, "reserveDialog")
return true
}
STATUS_INVALID -> {
processNext()
}
reserveDialog.show(mFragment!!.childFragmentManager, "reserveDialog")
}
STATUS_INVALID -> {
processNext()
}
}
return false
}
}

View File

@ -1,17 +1,47 @@
package com.gh.common.prioritychain
import android.content.Context
import com.gh.gamecenter.manager.UpdateManager
import androidx.fragment.app.FragmentActivity
import com.gh.gamecenter.core.utils.CurrentActivityHolder
import com.gh.gamecenter.update.UpdateHelper
class UpdateDialogHandler(context: Context, priority: Int) : PriorityChainHandler(priority) {
class UpdateDialogHandler(priority: Int) : PriorityChainHandler(priority) {
private val mUpdateManager = UpdateManager.getInstance(context)
override fun onProcess() {
mUpdateManager.checkUpdate(true, null)
mUpdateManager.setDismissCallback {
processNext()
fun doPreProcess() {
UpdateHelper.getUpdate(false) {
if (getStatus() == STATUS_PENDING) {
if (UpdateHelper.isUpdateValid(false)) {
updateStatus(STATUS_VALID)
process()
} else {
updateStatus(STATUS_INVALID)
processNext()
}
} else {
if (UpdateHelper.isUpdateValid(false)) {
updateStatus(STATUS_VALID)
} else {
updateStatus(STATUS_INVALID)
}
}
}
}
override fun onProcess(): Boolean {
val currentActivity = CurrentActivityHolder.getCurrentActivity()
if (GlobalPriorityChainHelper.isThisActivityValid(currentActivity)) {
if (getStatus() == STATUS_VALID) {
UpdateHelper.showUpdateDialog(currentActivity as FragmentActivity) {
processNext()
}
return true
} else if (getStatus() == STATUS_INVALID) {
processNext()
}
}
return false
}
}

View File

@ -1,32 +1,31 @@
package com.gh.common.prioritychain
import android.graphics.Bitmap
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import com.gh.gamecenter.common.callback.BiCallback
import com.gh.gamecenter.common.utils.ImageUtils
import com.gh.gamecenter.core.utils.CurrentActivityHolder
import com.gh.gamecenter.feature.entity.WelcomeDialogEntity
import com.gh.gamecenter.fragment.MainWrapperViewModel
import com.gh.gamecenter.fragment.WelcomeDialogFragment
import com.gh.gamecenter.wrapper.MainWrapperViewModel
import com.halo.assistant.HaloApp
class WelcomeDialogHandler(priority: Int): PriorityChainHandler(priority) {
class WelcomeDialogHandler(priority: Int) : PriorityChainHandler(priority) {
private var mFragment: Fragment? = null
private var mWelcomeDialogEntity: WelcomeDialogEntity? = null
private var welcomeDialogEntity: WelcomeDialogEntity? = null
fun doPreProcess(fragment: Fragment, welcomeDialogEntity: WelcomeDialogEntity?) {
mFragment = fragment
mWelcomeDialogEntity = welcomeDialogEntity
fun doPreProcess(welcomeDialogEntity: WelcomeDialogEntity?) {
this.welcomeDialogEntity = welcomeDialogEntity
val preLoadClosure = {
// 判断启动本次应用是否已经弹窗,不是的话弹启动弹窗
if (HaloApp.get(MainWrapperViewModel.SHOULD_SHOW_OPENING_DIALOG, false) == null) {
HaloApp.put(MainWrapperViewModel.SHOULD_SHOW_OPENING_DIALOG, false)
ImageUtils.getBitmap(mWelcomeDialogEntity!!.icon, object : BiCallback<Bitmap, Boolean> {
ImageUtils.getBitmap(this.welcomeDialogEntity!!.icon, object : BiCallback<Bitmap, Boolean> {
override fun onFirst(first: Bitmap) {
if (getStatus() == STATUS_PENDING) {
updateStatus(STATUS_VALID)
onProcess()
process()
} else {
updateStatus(STATUS_VALID)
}
@ -56,24 +55,28 @@ class WelcomeDialogHandler(priority: Int): PriorityChainHandler(priority) {
}
}
override fun onProcess() {
when (getStatus()) {
STATUS_VALID -> {
if (mFragment == null || !mFragment!!.isAdded) {
updateStatus(STATUS_INVALID)
processNext()
} else {
val welcomeDialog = WelcomeDialogFragment.getInstance(mWelcomeDialogEntity)
override fun onProcess(): Boolean {
val currentActivity = CurrentActivityHolder.getCurrentActivity()
if (GlobalPriorityChainHelper.isThisActivityValid(currentActivity)) {
when (getStatus()) {
STATUS_VALID -> {
val welcomeDialog = WelcomeDialogFragment.getInstance(welcomeDialogEntity)
welcomeDialog.setOnDismissListener {
processNext()
}
welcomeDialog.show(mFragment!!.childFragmentManager, "WelcomeDialog")
welcomeDialog.show((currentActivity as FragmentActivity).supportFragmentManager, "WelcomeDialog")
return true
}
STATUS_INVALID -> {
processNext()
}
}
STATUS_INVALID -> {
processNext()
}
}
return false
}
}

View File

@ -16,9 +16,8 @@ class BindingAdaptersProviderImpl : IBindingAdaptersProvider {
view: TextView,
game: GameEntity,
isShowPlatform: Boolean,
isShowSuffix: Boolean
) {
BindingAdapters.setGameName(view, game, isShowPlatform, isShowSuffix)
BindingAdapters.setGameName(view, game, isShowPlatform)
}
override fun setGameTags(layout: LinearLayout, gameEntity: GameEntity) {

View File

@ -100,10 +100,6 @@ class ConfigProviderImpl : IConfigProvider {
return Config.getNightModeSetting()?.setting ?: false
}
override fun isShowPlugin(gameId: String): Boolean {
return Config.isShowPlugin(gameId)
}
override fun init(context: Context?) {
// Do nothing
}

View File

@ -8,8 +8,8 @@ import com.gh.gamecenter.core.provider.IMainProvider
@Route(path = RouteConsts.provider.mainActivity, name = "MainActivity暴露服务")
class MainProviderImpl : IMainProvider {
override fun skipToMainActivity(context: Context, position: Int) {
MainActivity.skipToMainActivity(context, position)
override fun skipToMainActivity(context: Context, type: String) {
MainActivity.skipToMainActivity(context, type)
}
override fun init(context: Context?) {

View File

@ -1,16 +1,30 @@
package com.gh.common.provider
import android.content.Context
import android.os.Handler
import androidx.fragment.app.FragmentActivity
import com.alibaba.android.arouter.facade.annotation.Route
import com.gh.common.util.DialogUtils
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.core.provider.IUpdateManagerProvider
import com.gh.gamecenter.manager.UpdateManager
import com.gh.gamecenter.core.utils.ToastUtils
import com.gh.gamecenter.update.UpdateHelper
@Route(path = RouteConsts.provider.updateManager, name = "UpdateManager暴露服务")
class UpdateManagerProviderImpl: IUpdateManagerProvider {
override fun checkUpdate(context: Context, isAutoCheck: Boolean, handler: Handler?) {
UpdateManager.getInstance(context).checkUpdate(isAutoCheck, handler)
override fun checkUpdate(activity: FragmentActivity, ignoreSuppressOption: Boolean) {
val dialog = DialogUtils.showWaitDialog(activity, "检查更新中...")
UpdateHelper.getUpdate(ignoreSuppressOption) {
dialog.dismiss()
if (UpdateHelper.isUpdateValid(ignoreSuppressOption)) {
UpdateHelper.showUpdateDialog(activity) {
// Do nothing
}
} else {
ToastUtils.toast("您的光环助手已是最新版本")
}
}
}
override fun init(context: Context?) {

View File

@ -367,8 +367,7 @@ public class DetailDownloadUtils {
String downloadAddWord = gameEntity.getDownloadAddWord();
// 不满足条件的部分游戏隐藏下载按钮
if (Config.isShowDownload(gameEntity.getId())
&& !"光环助手".equals(gameEntity.getName())) {
if (!"光环助手".equals(gameEntity.getName())) {
viewHolder.getDownloadBottom().setVisibility(View.VISIBLE);
} else {
viewHolder.getDownloadBottom().setVisibility(View.GONE);

View File

@ -37,10 +37,7 @@ import com.gh.gamecenter.core.runOnIoThread
import com.gh.gamecenter.core.utils.ToastUtils
import com.gh.gamecenter.discovery.DiscoveryActivity
import com.gh.gamecenter.download.DownloadFragment.Companion.INDEX_UPDATE
import com.gh.gamecenter.entity.GameCollectionListEntity
import com.gh.gamecenter.entity.SubjectData
import com.gh.gamecenter.entity.SubjectRecommendEntity
import com.gh.gamecenter.entity.VideoLinkEntity
import com.gh.gamecenter.entity.*
import com.gh.gamecenter.eventbus.EBSkip
import com.gh.gamecenter.feature.entity.GameDetailServer
import com.gh.gamecenter.feature.entity.GameEntity
@ -53,7 +50,6 @@ import com.gh.gamecenter.feature.provider.IConcernInfoProvider
import com.gh.gamecenter.forum.detail.ForumDetailActivity
import com.gh.gamecenter.forum.home.CommunityHomeFragment
import com.gh.gamecenter.forum.search.ForumOrUserSearchActivity
import com.gh.gamecenter.fragment.MainWrapperFragment
import com.gh.gamecenter.game.columncollection.detail.ColumnCollectionDetailActivity
import com.gh.gamecenter.game.commoncollection.detail.CommonCollectionDetailActivity
import com.gh.gamecenter.game.upload.GameSubmissionActivity
@ -68,7 +64,9 @@ import com.gh.gamecenter.gamedetail.fuli.kaifu.ServersSubscribedGameListActivity
import com.gh.gamecenter.gamedetail.history.HistoryApkListActivity
import com.gh.gamecenter.gamedetail.rating.RatingReplyActivity
import com.gh.gamecenter.help.HelpAndFeedbackBridge
import com.gh.gamecenter.libao.LibaoDetailActivity
import com.gh.gamecenter.login.user.UserManager
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
@ -88,12 +86,15 @@ import com.gh.gamecenter.servers.gametest2.GameServerTestV2Activity
import com.gh.gamecenter.setting.SettingBridge
import com.gh.gamecenter.subject.SubjectActivity
import com.gh.gamecenter.tag.TagsActivity
import com.gh.gamecenter.toolbox.ToolBoxBlockActivity
import com.gh.gamecenter.toolbox.ToolBoxActivity
import com.gh.gamecenter.video.data.VideoDataActivity
import com.gh.gamecenter.video.detail.VideoDetailActivity
import com.gh.gamecenter.video.detail.VideoDetailContainerViewModel
import com.gh.gamecenter.video.game.GameVideoActivity
import com.gh.gamecenter.video.videomanager.VideoManagerActivity
import com.gh.gamecenter.wrapper.MainWrapperFragment
import com.gh.gamecenter.wrapper.MainWrapperRepository
import com.gh.gamecenter.wrapper.ToolbarWrapperActivity
import com.gh.vspace.VDownloadManagerActivity
import com.halo.assistant.HaloApp
import com.halo.assistant.fragment.WebFragment
@ -159,7 +160,9 @@ object DirectUtils {
"explore_column",
"game_explore",
"column_test_v2",
"game_list_collection"
"game_list_collection",
"multi_tab_nav",
"custom_page"
)
fun directToLinkPage(
@ -296,6 +299,7 @@ object DirectUtils {
"",
linkEntity.blockId,
linkEntity.blockName,
"",
exposureEvent
)
@ -393,7 +397,7 @@ object DirectUtils {
"video_tab" -> directToVideoTab(context)
"toolkit" -> context.startActivity(ToolBoxBlockActivity.getIntent(context, entrance))
"toolkit" -> context.startActivity(ToolBoxActivity.getIntent(context, entrance))
"column_test" -> context.startActivity(
GameServerTestActivity.getIntent(
@ -461,6 +465,22 @@ object DirectUtils {
entrance
)
"multi_tab_nav" -> context.startActivity(ToolbarWrapperActivity.getMultiTabNavIntent(context, linkEntity.link ?: "", linkEntity.text ?: ""))
"custom_page" -> context.startActivity(ToolbarWrapperActivity.getCustomPageIntent(context, linkEntity.link ?: "", linkEntity.text ?: ""))
// 选中首页底部 tab
"bottom_tab" -> {
val intent = Intent(context, MainActivity::class.java).apply {
flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
}
context.startActivity(intent)
if (linkEntity is LaunchRedirect) {
MainWrapperRepository.getInstance().sendMainSelectTabEvent(linkEntity)
}
}
"" -> {
// do nothing
}
@ -515,7 +535,9 @@ object DirectUtils {
columnName: String = "",
blockId: String = "",
blockName: String = "",
exposureEvent: ExposureEvent? = null
style: String = "",
exposureEvent: ExposureEvent? = null,
showSubjectTab: Boolean = false
) {
if (id.isEmpty()) return
val bundle = Bundle()
@ -525,7 +547,9 @@ object DirectUtils {
bundle.putString(KEY_COLUMNNAME, columnName)
bundle.putString(KEY_BLOCK_ID, blockId)
bundle.putString(KEY_BLOCK_NAME, blockName)
bundle.putString(KEY_COLUMN_COLLECTION_STYLE, style)
bundle.putInt(KEY_POSITION, position)
bundle.putBoolean(KEY_SHOW_SUBJECT_TAB, showSubjectTab)
if (exposureEvent != null) {
bundle.putParcelableArrayList(EntranceConsts.KEY_EXPOSURE_SOURCE_LIST, ArrayList(exposureEvent.source))
}
@ -848,6 +872,27 @@ object DirectUtils {
jumpActivity(context, bundle)
}
@JvmStatic
fun directToDownloadManager(
context: Context,
entrance: String = "",
bottomTab: String = "",
gameColumnId: String = "",
gameColumnName: String = "",
customPageId: String = "",
customPageName: String = ""
) {
val bundle = Bundle()
bundle.putString(KEY_ENTRANCE, entrance)
bundle.putString(KEY_TO, DownloadManagerActivity.TAG)
bundle.putString(KEY_BOTTOM_TAB_NAME, bottomTab)
bundle.putString(KEY_GAME_COLUMN_ID, gameColumnId)
bundle.putString(KEY_GAME_COLUMN_NAME, gameColumnName)
bundle.putString(KEY_CUSTOM_PAGE_ID, customPageId)
bundle.putString(KEY_CUSTOM_PAGE_NAME, customPageName)
jumpActivity(context, bundle)
}
@JvmStatic
fun directToDownloadManagerAndStartUpdate(
context: Context,
@ -868,7 +913,7 @@ object DirectUtils {
fun directToToolbox(context: Context, gameId: String, toolboxUrl: String, entrance: String = ENTRANCE_BROWSER) {
val bundle = Bundle()
bundle.putString(KEY_ENTRANCE, entrance)
bundle.putString(KEY_TO, ToolBoxBlockActivity::class.java.name)
bundle.putString(KEY_TO, ToolBoxActivity::class.java.name)
bundle.putString(KEY_GAMEID, gameId)
bundle.putString(KEY_URL, toolboxUrl)
jumpActivity(context, bundle)
@ -1013,21 +1058,7 @@ object DirectUtils {
*/
@JvmStatic
fun directToCommunity(context: Context, community: CommunityEntity?) {
// if (MainActivity::class.java.name != RunningUtils.getTopActivity(context)) {
// val intent = Intent(context, MainActivity::class.java)
// intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
// context.startActivity(intent)
//
// UserManager.getInstance().setCommunityData(community)
//
// // 这里换个线程操作是为了做一点延时
// AppExecutor.ioExecutor.execute {
// EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_BBS))
// EventBus.getDefault().post(EBReuse(CommunityFragment.EB_RETRY_PAGE))
// }
// } else {
directForumDetail(context, community?.id)
// }
}
@JvmStatic
@ -1471,10 +1502,10 @@ object DirectUtils {
// 这里换个线程操作是为了做一点延时
runOnIoThread {
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_HOME))
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.TYPE_HOME))
}
} else {
jumpActivity(context, Bundle().apply { putInt(KEY_POSITION, MainWrapperFragment.INDEX_HOME) })
jumpActivity(context, Bundle().apply { putString(KEY_TYPE, MainWrapperFragment.TYPE_HOME) })
}
}
@ -1492,12 +1523,12 @@ object DirectUtils {
// 这里换个线程操作是为了做一点延时
runOnIoThread {
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_BBS))
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.TYPE_COMMUNITY_HOME))
EventBus.getDefault().post(EBSkip(CommunityHomeFragment.EB_TAB, position))
}
} else {
jumpActivity(context, Bundle().apply {
putInt(KEY_POSITION, MainWrapperFragment.INDEX_BBS)
putString(KEY_TYPE, MainWrapperFragment.TYPE_COMMUNITY_HOME)
putInt(KEY_SUB_POSITION, position)
})
}
@ -1515,10 +1546,10 @@ object DirectUtils {
// 这里换个线程操作是为了做一点延时
runOnIoThread {
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_VIDEO))
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.TYPE_VIDEO_STREAM))
}
} else {
jumpActivity(context, Bundle().apply { putInt(KEY_POSITION, MainWrapperFragment.INDEX_VIDEO) })
jumpActivity(context, Bundle().apply { putString(KEY_TYPE, MainWrapperFragment.TYPE_VIDEO_STREAM) })
}
}
@ -1534,10 +1565,10 @@ object DirectUtils {
// 这里换个线程操作是为了做一点延时
runOnIoThread {
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_PERSONAL))
EventBus.getDefault().post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.TYPE_MY_HALO))
}
} else {
jumpActivity(context, Bundle().apply { putInt(KEY_POSITION, MainWrapperFragment.INDEX_PERSONAL) })
jumpActivity(context, Bundle().apply { putString(KEY_TYPE, MainWrapperFragment.TYPE_MY_HALO) })
}
}
@ -1975,9 +2006,29 @@ object DirectUtils {
bbsId: String,
entrance: String,
sourceEntrance: String,
forumName: String
forumName: String,
bottomTab: String = "",
multiTabId: String = "",
multiTabName: String = "",
customPageId: String = "",
customPageName: String = "",
searchBoxPattern: String = ""
) {
context.startActivity(ForumOrUserSearchActivity.getIntent(context, bbsId, entrance, sourceEntrance, forumName))
context.startActivity(
ForumOrUserSearchActivity.getIntent(
context,
bbsId,
entrance,
sourceEntrance,
forumName,
bottomTab,
multiTabId,
multiTabName,
customPageId,
customPageName,
searchBoxPattern
)
)
}
@JvmStatic
@ -2051,9 +2102,27 @@ object DirectUtils {
fun directToQGameSearch(
context: Context,
hint: String,
sourceEntrance: String
sourceEntrance: String,
bottomTab: String = "",
multiTabId: String = "",
multiTabName: String = "",
customPageId: String = "",
customPageName: String = "",
searchBoxPattern: String = ""
) {
context.startActivity(QGameSearchActivity.getIntent(context, hint, sourceEntrance))
context.startActivity(
QGameSearchActivity.getIntent(
context,
hint,
sourceEntrance,
bottomTab,
multiTabId,
multiTabName,
customPageId,
customPageName,
searchBoxPattern
)
)
}
@SuppressLint("CheckResult")
@ -2146,4 +2215,60 @@ object DirectUtils {
context.startActivity(ServersCalendarManagementActivity.getIntent(context))
}
}
fun directToSearch(
context: Context,
searchType: String,
searchHint: String,
entrance: String,
sourceEntrance: String,
bottomTab: String = "",
multiTabId: String = "",
multiTabName: String = "",
customPageId: String = "",
customPageName: String = "",
searchBoxPattern: String = ""
) {
when (searchType) {
"halo_game" -> context.startActivity(
SearchActivity.getIntent(
context,
false,
searchHint,
entrance,
sourceEntrance,
bottomTab,
multiTabId,
multiTabName,
customPageId,
customPageName,
searchBoxPattern
)
)
"qq_mini_game" -> directToQGameSearch(
context,
searchHint,
sourceEntrance,
bottomTab,
multiTabId,
multiTabName,
customPageId,
customPageName,
searchBoxPattern
)
"bbs" -> directToForumOrUserSearch(
context,
"",
entrance,
sourceEntrance,
"",
bottomTab,
multiTabId,
multiTabName,
customPageId,
customPageName,
searchBoxPattern
)
}
}
}

View File

@ -219,7 +219,7 @@ object DownloadItemUtils {
pluginLocation: PluginLocation? = PluginLocation.only_game
) {
// 控制是否显示下载按钮
downloadBtn.goneIf(!Config.isShowDownload(gameEntity.id) || context.getString(R.string.app_name) == gameEntity.name)
downloadBtn.goneIf(context.getString(R.string.app_name) == gameEntity.name)
// 青少年模式或者需要特殊处理显示查看
if (SPUtils.getBoolean(Constants.SP_TEENAGER_MODE) || gameEntity.isSpecialDownload()) {
downloadBtn.text = "查看"
@ -903,7 +903,6 @@ object DownloadItemUtils {
DownloadChainBuilder().apply {
addHandler(GamePermissionHandler())
addHandler(CheckStoragePermissionHandler())
addHandler(CertificationHandler())
addHandler(VersionNumberHandler())
}
.setProcessEndCallback { _, _ ->
@ -945,7 +944,6 @@ object DownloadItemUtils {
addHandler(BrowserInstallHandler())
addHandler(PackageCheckHandler())
addHandler(DownloadDialogHelperHandler())
addHandler(CertificationHandler())
addHandler(OverseaDownloadHandler())
addHandler(LandPageAddressHandler())
addHandler(CheckDownloadHandler())
@ -964,7 +962,6 @@ object DownloadItemUtils {
addHandler(BrowserInstallHandler())
addHandler(PackageCheckHandler())
addHandler(DownloadDialogHelperHandler())
addHandler(CertificationHandler())
addHandler(VersionNumberHandler())
addHandler(LandPageAddressHandler())
addHandler(OverseaDownloadHandler())
@ -982,7 +979,6 @@ object DownloadItemUtils {
addHandler(GamePermissionHandler())
addHandler(PackageCheckHandler())
addHandler(DownloadDialogHelperHandler())
addHandler(CertificationHandler())
addHandler(VersionNumberHandler())
addHandler(LandPageAddressHandler())
addHandler(OverseaDownloadHandler())
@ -1001,7 +997,6 @@ object DownloadItemUtils {
} else {
DownloadChainBuilder().apply {
addHandler(DownloadDialogHelperHandler())
addHandler(CertificationHandler())
addHandler(CheckDownloadHandler())
}
.setProcessEndCallback { _, isSubscribe ->

View File

@ -6,7 +6,6 @@ import android.text.TextUtils
import androidx.appcompat.app.AppCompatActivity
import com.gh.common.DefaultJsApi
import com.gh.common.constant.Config
import com.gh.common.dialog.CertificationDialog
import com.gh.common.exposure.ExposureManager
import com.gh.common.history.HistoryHelper
import com.gh.common.repository.ReservationRepository
@ -264,10 +263,14 @@ object GameActivityDownloadHelper {
traceEvent: ExposureEvent
) {
GamePermissionDialogFragment.show((context as AppCompatActivity), gameEntity, gameEntity.info) {
CertificationDialog.showCertificationDialog(context, gameEntity) {
DialogUtils.checkDownload(context, apk.size, gameEntity.id, gameEntity.name, gameEntity.categoryChinese) { isSubscribe: Boolean ->
download(context, gameEntity, apk, false, isSubscribe, entrance, location, traceEvent)
}
DialogUtils.checkDownload(
context,
apk.size,
gameEntity.id,
gameEntity.name,
gameEntity.categoryChinese
) { isSubscribe: Boolean ->
download(context, gameEntity, apk, false, isSubscribe, entrance, location, traceEvent)
}
}
DataLogUtils.uploadGameLog(context, gameEntity.id, gameEntity.name, entrance)
@ -284,16 +287,14 @@ object GameActivityDownloadHelper {
) {
VHelper.validateVSpaceBeforeAction(context, gameEntity) {
GamePermissionDialogFragment.show((context as AppCompatActivity), gameEntity, gameEntity.info) {
CertificationDialog.showCertificationDialog(context, gameEntity) {
DialogUtils.checkDownload(
context,
apk.size,
gameEntity.id,
gameEntity.name,
gameEntity.categoryChinese
) { isSubscribe: Boolean ->
download(context, gameEntity, apk, true, isSubscribe, entrance, location, traceEvent)
}
DialogUtils.checkDownload(
context,
apk.size,
gameEntity.id,
gameEntity.name,
gameEntity.categoryChinese
) { isSubscribe: Boolean ->
download(context, gameEntity, apk, true, isSubscribe, entrance, location, traceEvent)
}
}
}
@ -311,10 +312,14 @@ object GameActivityDownloadHelper {
if (gameEntity.pluggableCollection != null) {
DownloadDialog.showDownloadDialog(context, gameEntity, traceEvent, entrance, location)
} else {
CertificationDialog.showCertificationDialog(context, gameEntity) {
DialogUtils.checkDownload(context, apk.size, gameEntity.id, gameEntity.name, gameEntity.categoryChinese) { isSubscribe: Boolean ->
plugin(context, gameEntity, apk, entrance, location, isSubscribe, traceEvent)
}
DialogUtils.checkDownload(
context,
apk.size,
gameEntity.id,
gameEntity.name,
gameEntity.categoryChinese
) { isSubscribe: Boolean ->
plugin(context, gameEntity, apk, entrance, location, isSubscribe, traceEvent)
}
}
}

View File

@ -1,15 +1,19 @@
package com.gh.common.util
import com.gh.gamecenter.R
import com.gh.gamecenter.common.entity.Display
import com.gh.gamecenter.common.entity.LinkEntity
import com.gh.gamecenter.common.utils.toJson
import com.gh.gamecenter.core.utils.GsonUtils
import com.gh.gamecenter.core.utils.SPUtils
import com.gh.gamecenter.entity.BottomTab
import com.gh.gamecenter.entity.SubjectRecommendEntity
import com.google.gson.reflect.TypeToken
import com.halo.assistant.HaloApp
object HomeBottomBarHelper {
private const val GAME_BAR_KEY = "game_bar_key"
private const val VIDEO_BAR_KEY = "video_bar_key"
private const val KEY_HOME_BOTTOM_TAB = "home_bottom_tab"
@JvmStatic
fun getDefaultGameBarData(): SubjectRecommendEntity {
@ -39,41 +43,37 @@ object HomeBottomBarHelper {
}
@JvmStatic
fun getDefaultVideoData(): SubjectRecommendEntity {
fun getDefaultBottomTabHomeEntity(): BottomTab {
val animationCode = HaloApp.getInstance().application.assets
.open("lottie/tab_home.json")
.bufferedReader().use { it.readText() }
return BottomTab(name = "首页", jsCode = animationCode, iconSelector = R.drawable.selector_ic_home, default = true)
}
@JvmStatic
fun getDefaultBottomTabMineEntity(): BottomTab {
val animationCode = HaloApp.getInstance().application.assets
.open("lottie/tab_mine.json")
.bufferedReader().use { it.readText() }
return BottomTab(name = "我的光环", jsCode = animationCode, iconSelector = R.drawable.selector_ic_user, link = LinkEntity(type = "my_halo"))
}
@JvmStatic
fun getDefaultHomeBottomTabData(): List<BottomTab> {
try {
val json = SPUtils.getString(VIDEO_BAR_KEY)
val json = SPUtils.getString(KEY_HOME_BOTTOM_TAB)
if (json.isNotEmpty()) {
return GsonUtils.fromJson(json, SubjectRecommendEntity::class.java)
val type = object : TypeToken<List<BottomTab>>() {}.type
return GsonUtils.gson.fromJson(json, type)
}
} catch (ignore: Exception) {
}
return getDefaultVideoEntity()
return listOf(getDefaultBottomTabHomeEntity(), getDefaultBottomTabMineEntity())
}
@JvmStatic
fun getDefaultVideoEntity(): SubjectRecommendEntity {
val animationCode = HaloApp.getInstance().application.assets
.open("lottie/tab_video.json")
.bufferedReader().use { it.readText() }
return SubjectRecommendEntity(
type = "video_stream",
text = "视频",
name = "视频",
position = 4,
animationCode = animationCode,
default = false,
display = Display()
)
}
@JvmStatic
fun updateDefaultGameBarData(data: SubjectRecommendEntity) {
SPUtils.setString(GAME_BAR_KEY, data.toJson())
}
@JvmStatic
fun updateDefaultVideoBarData(data: SubjectRecommendEntity) {
SPUtils.setString(VIDEO_BAR_KEY, data.toJson())
fun updateDefaultHomeBottomTabData(data: List<BottomTab>) {
SPUtils.setString(KEY_HOME_BOTTOM_TAB, data.toJson())
}
}

View File

@ -151,14 +151,8 @@ public class PackageUtils {
}
}
// 镜像游戏,使用镜像 Apk 替换掉原来的 ApkNormal
if (RegionSettingHelper.shouldThisGameDisplayMirrorInfo(gameEntity.getId())) {
gameEntity.setApkNormal(gameEntity.getApk());
}
// 非插件游戏更新
for (ApkEntity apkEntity : gameEntity.getApkNormal()) {
for (ApkEntity apkEntity : gameEntity.getApk()) {
// ghVersion 不存在即是非插件游戏
if (TextUtils.isEmpty(apkEntity.getGhVersion())) {
int versionCodeFromRequest = apkEntity.getVersionCode();

View File

@ -0,0 +1,216 @@
package com.gh.common.util
import android.os.Bundle
import androidx.fragment.app.Fragment
import com.gh.gamecenter.amway.AmwayFragment
import com.gh.gamecenter.category2.CategoryV2Fragment
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.entity.LinkEntity
import com.gh.gamecenter.discovery.DiscoveryFragment
import com.gh.gamecenter.entity.SubjectData
import com.gh.gamecenter.feedback.view.help.HelpAndFeedbackFragment
import com.gh.gamecenter.feedback.view.qa.HelpContainerFragment
import com.gh.gamecenter.forum.detail.ForumDetailFragment
import com.gh.gamecenter.forum.home.CommunityHomeFragment
import com.gh.gamecenter.fragment.ReloadFragment
import com.gh.gamecenter.game.columncollection.detail.ColumnCollectionDetailFragment
import com.gh.gamecenter.game.commoncollection.detail.CommonCollectionDetailFragment
import com.gh.gamecenter.gamecollection.hotlist.GameCollectionHotListWrapperFragment
import com.gh.gamecenter.gamecollection.square.GameCollectionSquareFragment
import com.gh.gamecenter.gamedetail.GameDetailFragment
import com.gh.gamecenter.info.InfoWrapperFragment
import com.gh.gamecenter.libao.LibaoDetailFragment
import com.gh.gamecenter.libao.LibaoFragment
import com.gh.gamecenter.newsdetail.NewsDetailFragment
import com.gh.gamecenter.personal.HaloPersonalFragment
import com.gh.gamecenter.qa.article.detail.ArticleDetailFragment
import com.gh.gamecenter.qa.questions.newdetail.NewQuestionDetailFragment
import com.gh.gamecenter.qa.subject.AskSubjectFragment
import com.gh.gamecenter.qa.video.detail.ForumVideoDetailFragment
import com.gh.gamecenter.servers.GameServersPublishFragment
import com.gh.gamecenter.servers.gametest2.GameServerTestV2Fragment
import com.gh.gamecenter.subject.SubjectFragment
import com.gh.gamecenter.tag.TagsListFragment
import com.gh.gamecenter.toolbox.ToolboxFragment
import com.gh.gamecenter.video.detail.HomeVideoFragment
import com.gh.gamecenter.wrapper.ToolbarWrapperFragment
import com.halo.assistant.fragment.WebFragment
/**
* 通用跳转Fragment方法
* @see <a href="https://wiki.shanqu.cc/pages/viewpage.action?pageId=102828538">WIKI</a>
*/
object ViewPagerFragmentHelper {
const val WRAPPER_FRAGMENT_NAME = "WrapperFragmentName"
fun createFragment(bundle: Bundle, linkEntity: LinkEntity, isTabWrapper: Boolean): Fragment {
return when (linkEntity.type) {
// 游戏详情页
"game" -> {
bundle.putString(EntranceConsts.KEY_GAMEID, linkEntity.link)
GameDetailFragment().with(bundle)
}
// 我的光环
"my_halo" -> HaloPersonalFragment().with(bundle)
// 社区首页
"community_home" -> CommunityHomeFragment().with(bundle)
// 视频信息流
"video_stream" -> {
bundle.putBoolean(EntranceConsts.KEY_IS_HOME_VIDEO, true)
HomeVideoFragment().with(bundle)
}
// 安利墙
"top_game_comment" -> {
AmwayFragment().with(bundle)
}
// 论坛
"community" -> {
bundle.putString(EntranceConsts.KEY_BBS_ID, linkEntity.link)
ForumDetailFragment().with(bundle)
}
// 论坛子版块
"bbs_section" -> {
bundle.putString(EntranceConsts.KEY_BBS_ID, linkEntity.community?.id)
bundle.putString(EntranceConsts.KEY_BBS_SECTION_ID, linkEntity.link)
ForumDetailFragment().with(bundle)
}
// 游戏单热搜榜
"game_hot_list" -> {
GameCollectionHotListWrapperFragment().with(bundle)
}
// 视频贴
"video" -> {
bundle.putString(EntranceConsts.KEY_VIDEO_ID, linkEntity.link)
ForumVideoDetailFragment().with(bundle)
}
// 帮助与反馈
"feedback" -> {
HelpAndFeedbackFragment().with(bundle)
}
// 其他原来带Toolbar的Fragment
else -> createToolbarWrapperFragment(bundle, linkEntity, isTabWrapper)
}
}
private fun createToolbarWrapperFragment(bundle: Bundle, entity: LinkEntity, isTabWrapper: Boolean): Fragment {
var className = ReloadFragment::class.java.name
when (entity.type) {
// 游戏单广场
"game_list" -> {
className = GameCollectionSquareFragment::class.java.name
}
// 游戏专题详情页/QQ游戏专题详情页
"column", "qq_mini_game_column_detail" -> {
className = SubjectFragment::class.java.name
bundle.putParcelable(
EntranceConsts.KEY_SUBJECT_DATA,
SubjectData(entity.link, entity.text, false, isQQMiniGame = entity.type == "qq_mini_game_column_detail")
)
bundle.putBoolean(EntranceConsts.KEY_SHOW_DOWNLOAD_MENU, !isTabWrapper)
}
// 专题合集详情页
"column_collection" -> {
className = ColumnCollectionDetailFragment::class.java.name
bundle.putString(EntranceConsts.KEY_COLLECTION_ID, entity.link)
bundle.putInt(EntranceConsts.KEY_POSITION, 0)
bundle.putString(EntranceConsts.KEY_COLUMNNAME, entity.text)
bundle.putBoolean(EntranceConsts.KEY_IS_COLUMN_COLLECTION, true)
}
// 开服表
"server" -> {
className = GameServersPublishFragment::class.java.name
bundle.putBoolean(EntranceConsts.KEY_SHOW_DOWNLOAD_MENU, !isTabWrapper)
}
// 新游开测
"column_test_v2" -> {
className = GameServerTestV2Fragment::class.java.name
}
// 分类2.0
"category_v2" -> {
className = CategoryV2Fragment::class.java.name
bundle.putString(EntranceConsts.KEY_CATEGORY_ID, entity.link)
bundle.putString(EntranceConsts.KEY_CATEGORY_TITLE, entity.text)
bundle.putBoolean(EntranceConsts.KEY_SHOW_DOWNLOAD_MENU, !isTabWrapper)
}
// 通用内容合集详情页
"common_collection" -> {
className = CommonCollectionDetailFragment::class.java.name
bundle.putString(EntranceConsts.KEY_COLLECTION_ID, entity.link)
bundle.putString(EntranceConsts.KEY_COLUMNNAME, entity.text)
}
// web链接
"web" -> {
className = WebFragment::class.java.name
bundle.putString(EntranceConsts.KEY_URL, entity.link)
bundle.putBoolean(WebFragment.KEY_OPEN_NATIVE_PAGE, false)
bundle.putBoolean(WebFragment.KEY_ENABLE_HORIZONTAL_SCROLL_DISPATCH, true)
if (entity.link != null && entity.link!!.contains("leave_web_page_handle_back_pressed=true")) {
bundle.putBoolean(WebFragment.KEY_LEAVE_WEB_PAGE_TO_HANDLE_BACK_PRESSED, true)
}
}
// 发现页
"game_explore" -> {
className = DiscoveryFragment::class.java.name
}
// 礼包详情页
"libao" -> {
className = LibaoDetailFragment::class.java.name
bundle.putString(EntranceConsts.KEY_ID, entity.link)
}
// 游戏标签详情
"tag" -> {
className = TagsListFragment::class.java.name
bundle.putBoolean(EntranceConsts.KEY_SHOW_DOWNLOAD_MENU, !isTabWrapper)
}
// 文章
"article" -> {
className = NewsDetailFragment::class.java.name
bundle.putString(EntranceConsts.KEY_NEWSID, entity.link)
}
// 提问
"question" -> {
className = NewQuestionDetailFragment::class.java.name
bundle.putString(EntranceConsts.KEY_QUESTIONS_ID, entity.link)
}
// 帖子
"community_article" -> {
className = ArticleDetailFragment::class.java.name
bundle.putString(EntranceConsts.KEY_COMMUNITY_ARTICLE_ID, entity.link)
bundle.putParcelable(EntranceConsts.KEY_COMMUNITY_DATA, entity.community)
}
// 社区专题
"community_column" -> {
className = AskSubjectFragment::class.java.name
bundle.putString(EntranceConsts.KEY_COLUMN_ID, entity.link)
bundle.putParcelable(EntranceConsts.KEY_COMMUNITY_DATA, entity.community)
}
// QA
"qa" -> {
className = HelpContainerFragment::class.java.name
bundle.putString(EntranceConsts.KEY_QA_ID, entity.link)
bundle.putString(EntranceConsts.KEY_NAVIGATION_TITLE, entity.text)
}
// 资讯中心
"article_center" -> {
className = InfoWrapperFragment::class.java.name
}
// 礼包中心
"libao_center" -> {
className = LibaoFragment::class.java.name
}
// 工具箱
"toolkit" -> {
className = ToolboxFragment::class.java.name
}
}
return if (isTabWrapper) {
// 多Tab导航页不需要Toolbar
(Class.forName(className).getDeclaredConstructor().newInstance() as Fragment).apply { arguments = bundle }
} else {
bundle.putString(WRAPPER_FRAGMENT_NAME, className)
ToolbarWrapperFragment().with(bundle)
}
}
}

View File

@ -6,13 +6,13 @@ import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.gh.common.util.DirectUtils
import com.gh.gamecenter.NewsDetailActivity
import com.gh.gamecenter.R
import com.gh.gamecenter.common.callback.OnViewClickListener
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.databinding.*
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.newsdetail.NewsDetailActivity
import com.lightgame.adapter.BaseRecyclerAdapter
class DownloadDialogAdapter(

View File

@ -7,7 +7,6 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import com.gh.common.constant.Config
import com.gh.common.dialog.CertificationDialog
import com.gh.common.dialog.DeviceRemindDialog
import com.gh.common.dialog.PackageCheckDialogFragment
import com.gh.common.util.*
@ -343,33 +342,28 @@ class DownloadDialogItemViewHolder(val binding: DownloadDialogItemBinding) : Bas
context as AppCompatActivity,
gameEntity
) {
CertificationDialog.showCertificationDialog(
DialogUtils.checkDownload(
context,
gameEntity
) {
DialogUtils.checkDownload(
apkEntity.size,
gameEntity.id,
gameEntity.name,
gameEntity.categoryChinese
) { isSubscribe ->
DownloadManager.createDownload(
context,
apkEntity.size,
gameEntity.id,
gameEntity.name,
gameEntity.categoryChinese
) { isSubscribe ->
DownloadManager.createDownload(
context,
apkEntity,
gameEntity,
false,
false,
entrance,
location,
isSubscribe, traceEvent
)
apkEntity,
gameEntity,
false,
false,
entrance,
location,
isSubscribe, traceEvent
)
DeviceRemindDialog.showDeviceRemindDialog(
context,
gameEntity
)
}
DeviceRemindDialog.showDeviceRemindDialog(
context,
gameEntity
)
}
}
}

View File

@ -48,6 +48,7 @@ import com.gh.common.constant.Config;
import com.gh.common.filter.RegionSettingHelper;
import com.gh.common.history.HistoryDatabase;
import com.gh.common.history.HistoryHelper;
import com.gh.common.prioritychain.GlobalPriorityChainHelper;
import com.gh.common.repository.ReservationRepository;
import com.gh.common.simulator.SimulatorGameManager;
import com.gh.common.util.ActivationHelper;
@ -82,13 +83,11 @@ import com.gh.gamecenter.common.retrofit.Response;
import com.gh.gamecenter.common.utils.DialogHelper;
import com.gh.gamecenter.common.utils.ExtensionsKt;
import com.gh.gamecenter.common.utils.NewFlatLogUtils;
import com.gh.gamecenter.common.utils.PermissionHelper;
import com.gh.gamecenter.common.utils.SensorsBridge;
import com.gh.gamecenter.common.utils.ShareUtils;
import com.gh.gamecenter.core.AppExecutor;
import com.gh.gamecenter.core.utils.ClassUtils;
import com.gh.gamecenter.core.utils.DisplayUtils;
import com.gh.gamecenter.core.utils.EmptyCallback;
import com.gh.gamecenter.core.utils.GsonUtils;
import com.gh.gamecenter.core.utils.MtaHelper;
import com.gh.gamecenter.core.utils.SPUtils;
@ -99,8 +98,7 @@ import com.gh.gamecenter.entity.StartupAdEntity;
import com.gh.gamecenter.eventbus.EBSkip;
import com.gh.gamecenter.feature.entity.GameEntity;
import com.gh.gamecenter.feature.utils.PlatformUtils;
import com.gh.gamecenter.fragment.MainWrapperFragment;
import com.gh.gamecenter.fragment.MainWrapperViewModel;
import com.gh.gamecenter.home.custom.model.CustomPageShareRepository;
import com.gh.gamecenter.home.skip.PackageSkipActivity;
import com.gh.gamecenter.login.user.UserManager;
import com.gh.gamecenter.login.utils.QuickLoginHelper;
@ -109,6 +107,8 @@ import com.gh.gamecenter.packagehelper.PackageViewModel;
import com.gh.gamecenter.retrofit.RetrofitManager;
import com.gh.gamecenter.room.AppDatabase;
import com.gh.gamecenter.room.dao.SimulatorGameDao;
import com.gh.gamecenter.wrapper.MainWrapperFragment;
import com.gh.gamecenter.wrapper.MainWrapperViewModel;
import com.gh.vspace.VHelper;
import com.google.android.exoplayer2.upstream.cache.Cache;
import com.google.gson.JsonSyntaxException;
@ -275,7 +275,7 @@ public class MainActivity extends BaseActivity {
ReservationRepository.refreshReservations();
if (getIntent().getBooleanExtra(SWITCH_TO_VIDEO, false)) {
handler.postDelayed(() -> mMainWrapperFragment.setCurrentItem(2), 800);
handler.postDelayed(() -> mMainWrapperFragment.setCurrentItem(MainWrapperFragment.TYPE_VIDEO_STREAM), 800);
}
// 跳转至其它页面
@ -431,9 +431,6 @@ public class MainActivity extends BaseActivity {
int currentPageIndex = savedInstanceState.getInt(CURRENT_PAGE, -1);
if (currentPageIndex >= 0) {
EventBus.getDefault().post(new EBSkip(MainActivity.EB_SKIP_MAIN, currentPageIndex));
if (currentPageIndex == MainWrapperFragment.INDEX_VIDEO) {
DisplayUtils.setLightStatusBar(this, false);
}
}
}
}
@ -464,6 +461,7 @@ public class MainActivity extends BaseActivity {
protected void onDestroy() {
super.onDestroy();
CustomPageShareRepository.Companion.getInstance().onClear();
AdDelegateHelper.INSTANCE.cancelSplashAd(this);
handler.removeCallbacksAndMessages(null);
@ -601,10 +599,12 @@ public class MainActivity extends BaseActivity {
ExtensionsKt.removeFromParent(startSdkAdIcpContainer, true);
}
// 通知优先级高的弹窗可以显示了
AppExecutor.getUiExecutor().execute(() -> {
mMainWrapperFragment.showDialog();
});
onSplashHidden();
}
private void onSplashHidden() {
// 通知全局弹窗可以进行显示
AppExecutor.getUiExecutor().execute(GlobalPriorityChainHelper.INSTANCE::start);
}
/**
@ -753,8 +753,8 @@ public class MainActivity extends BaseActivity {
}
Utils.log(bundle);
if (bundle.getInt(EntranceConsts.KEY_POSITION) != -1) {
EventBus.getDefault().post(new EBSkip(MainActivity.EB_SKIP_MAIN, bundle.getInt(EntranceConsts.KEY_POSITION)));
if (!TextUtils.isEmpty(bundle.getString(EntranceConsts.KEY_TYPE, ""))) {
EventBus.getDefault().post(new EBSkip(MainActivity.EB_SKIP_MAIN, bundle.getString(EntranceConsts.KEY_TYPE)));
}
}
}, 500);
@ -797,7 +797,7 @@ public class MainActivity extends BaseActivity {
toast("抱歉,暂未找到相关内容");
}
LogUtils.uploadPackageSkip("external_jump", "进入游戏库", "", "");
EventBus.getDefault().post(new EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_GAME));
EventBus.getDefault().post(new EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.TYPE_GAME_LIBRARY));
return true;
}
return false;
@ -925,7 +925,7 @@ public class MainActivity extends BaseActivity {
}
if (getIntent().getBooleanExtra(SWITCH_TO_VIDEO, false)) {
mMainWrapperFragment.setCurrentItem(2);
mMainWrapperFragment.setCurrentItem(MainWrapperFragment.TYPE_VIDEO_STREAM);
}
}
@ -957,17 +957,17 @@ public class MainActivity extends BaseActivity {
return "游戏首页";
}
public static void skipToMainActivity(Context context, int position) {
public static void skipToMainActivity(Context context, String type) {
Activity activity = AppManager.getInstance().findActivity(MainActivity.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1
&& activity != null && !activity.isDestroyed()) {
EventBus.getDefault().post(new EBSkip(MainActivity.EB_SKIP_MAIN, position));
EventBus.getDefault().post(new EBSkip(MainActivity.EB_SKIP_MAIN, type));
} else {
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
EventBus.getDefault().post(new EBSkip(MainActivity.EB_SKIP_MAIN, position));
EventBus.getDefault().post(new EBSkip(MainActivity.EB_SKIP_MAIN, type));
}
}, 300);
}

View File

@ -113,10 +113,23 @@ open class SearchActivity : BaseActivity() {
}
protected open fun trackSearchPageShow(){
val bottomTab = intent.getStringExtra(EntranceConsts.KEY_BOTTOM_TAB_NAME) ?: ""
val multiTabId = intent.getStringExtra(EntranceConsts.KEY_MULTI_TAB_NAV_ID) ?: ""
val multiTabName = intent.getStringExtra(EntranceConsts.KEY_MULTI_TAB_NAV_NAME) ?: ""
val customPageId = intent.getStringExtra(EntranceConsts.KEY_CUSTOM_PAGE_ID) ?: ""
val customPageName = intent.getStringExtra(EntranceConsts.KEY_CUSTOM_PAGE_NAME) ?: ""
val searchBoxPattern = intent.getStringExtra(EntranceConsts.KEY_SEARCH_BOX_PATTERN) ?: ""
SensorsBridge.trackSearchPageShow(
GlobalActivityManager.getCurrentPageEntity().pageId,
GlobalActivityManager.getCurrentPageEntity().pageName,
intent.getStringExtra(EntranceConsts.KEY_SOURCE_ENTRANCE) ?: ""
intent.getStringExtra(EntranceConsts.KEY_SOURCE_ENTRANCE) ?: "",
bottomTab,
multiTabId,
multiTabName,
customPageId,
customPageName,
searchBoxPattern
)
}
@ -364,12 +377,33 @@ open class SearchActivity : BaseActivity() {
hint: String,
entrance: String,
sourceEntrance: String
): Intent = getIntent(context, searchImmediately, hint, entrance, sourceEntrance)
@JvmStatic
fun getIntent(
context: Context,
searchImmediately: Boolean,
hint: String,
entrance: String,
sourceEntrance: String,
bottomTab: String = "",
multiTabId: String = "",
multiTabName: String = "",
customPageId: String = "",
customPageName: String = "",
searchBoxPattern: String = ""
): Intent {
val intent = Intent(context, SearchActivity::class.java)
intent.putExtra(KEY_SEARCH_IMMEDIATELY, searchImmediately)
intent.putExtra(EntranceConsts.KEY_HINT, hint)
intent.putExtra(EntranceConsts.KEY_ENTRANCE, entrance)
intent.putExtra(EntranceConsts.KEY_SOURCE_ENTRANCE, sourceEntrance)
intent.putExtra(EntranceConsts.KEY_BOTTOM_TAB_NAME, bottomTab)
intent.putExtra(EntranceConsts.KEY_MULTI_TAB_NAV_ID, multiTabId)
intent.putExtra(EntranceConsts.KEY_MULTI_TAB_NAV_NAME, multiTabName)
intent.putExtra(EntranceConsts.KEY_CUSTOM_PAGE_ID, customPageId)
intent.putExtra(EntranceConsts.KEY_CUSTOM_PAGE_NAME, customPageName)
intent.putExtra(EntranceConsts.KEY_SEARCH_BOX_PATTERN, searchBoxPattern)
return intent
}
}

View File

@ -324,7 +324,7 @@ public class SkipActivity extends BaseActivity {
DirectUtils.directCategoryDirectory(this, path, title, ENTRANCE_BROWSER, "浏览器");
break;
case HOST_COLUMN_COLLECTION:
DirectUtils.directToColumnCollection(this, path, -1, ENTRANCE_BROWSER, "", "", "", null);
DirectUtils.directToColumnCollection(this, path, -1, ENTRANCE_BROWSER, "", "", "", "", null,false);
break;
case EntranceConsts.HOST_BLOCK:
name = uri.getQueryParameter("name");
@ -419,7 +419,8 @@ public class SkipActivity extends BaseActivity {
JSONObject extJsonObject = new JSONObject(extJson);
String qqGameId = extJsonObject.optString("aid");
DirectUtils.directToQGameById(this, qqGameId);
} catch (JSONException ignored) {}
} catch (JSONException ignored) {
}
break;
default:
EntranceUtils.jumpActivity(this, new Bundle()); // 跳转至首页

View File

@ -263,7 +263,6 @@ class SplashScreenActivity : BaseActivity() {
runOnIoThread {
mViewModel?.deviceDialogSetting()
mViewModel?.filterDetailTags()
mViewModel?.authDialog()
mViewModel?.postMark(mIsNewForThisVersion)
mViewModel?.regulationTestStatus()
checkAndPostUsageStats()

View File

@ -13,7 +13,6 @@ import com.gh.gamecenter.common.retrofit.Response
import com.gh.gamecenter.common.utils.toRequestBody
import com.gh.gamecenter.core.utils.GsonUtils
import com.gh.gamecenter.core.utils.SPUtils
import com.gh.gamecenter.feature.entity.AuthDialogEntity
import com.gh.gamecenter.entity.DeviceDialogEntity
import com.gh.gamecenter.retrofit.RetrofitManager
import com.halo.assistant.HaloApp
@ -77,18 +76,6 @@ class SplashScreenViewModel(application: Application) : AndroidViewModel(applica
})
}
/**
* 获取游戏实名认证弹窗
*/
fun authDialog() {
mApi.authDialog()
.subscribe(object : Response<List<AuthDialogEntity?>?>() {
override fun onResponse(response: List<AuthDialogEntity?>?) {
super.onResponse(response)
SPUtils.setString(Constants.SP_AUTH_DIALOG, GsonUtils.toJson(response))
}
})
}
/**
* 判断新老用户

View File

@ -1,283 +0,0 @@
//package com.gh.gamecenter;
//
//import android.content.Context;
//import android.content.Intent;
//import android.os.Bundle;
//import android.text.TextUtils;
//import android.view.View;
//import android.view.inputmethod.EditorInfo;
//import android.widget.EditText;
//import android.widget.LinearLayout;
//import android.widget.TextView;
//
//import com.gh.gamecenter.common.callback.OnRequestCallBackListener;
//import com.gh.gamecenter.common.base.activity.ToolBarActivity;
//import com.gh.common.util.EntranceUtils;
//import com.gh.gamecenter.core.utils.MtaHelper;
//import com.gh.gamecenter.common.utils.TextHelper;
//import com.gh.gamecenter.core.utils.UrlFilterUtils;
//import com.gh.gamecenter.common.view.VerticalItemDecoration;
//import com.gh.gamecenter.adapter.ToolBoxRvAdapter;
//import com.gh.gamecenter.common.entity.ToolBoxEntity;
//import com.gh.gamecenter.retrofit.Response;
//import com.gh.gamecenter.retrofit.RetrofitManager;
//import com.gh.gamecenter.common.entity.SuggestType;
//import com.google.android.material.appbar.AppBarLayout;
//import com.lightgame.utils.Util_System_Keyboard;
//import com.lightgame.utils.Utils;
//
//import java.util.List;
//
//import androidx.annotation.NonNull;
//import androidx.annotation.Nullable;
//import androidx.recyclerview.widget.LinearLayoutManager;
//import androidx.recyclerview.widget.RecyclerView;
//import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
//import butterknife.BindView;
//import butterknife.OnClick;
//import io.reactivex.android.schedulers.AndroidSchedulers;
//import io.reactivex.schedulers.Schedulers;
//
///**
// * Created by khy on 24/05/17.
// */
//
//public class ToolBoxActivity extends ToolBarActivity implements SwipeRefreshLayout.OnRefreshListener, OnRequestCallBackListener {
//
// @BindView(R.id.et_search)
// public EditText searchEt;
// @BindView(R.id.tv_search)
// public TextView searchTv;
// @BindView(R.id.tv_back)
// public View backTv;
// @BindView(R.id.toolbox_appbar)
// AppBarLayout mAppBar;
// @BindView(R.id.toolbox_rv)
// RecyclerView mToolboxRv;
// @BindView(R.id.reuse_none_data)
// LinearLayout mNoneData;
// @BindView(R.id.reuse_tv_none_data)
// TextView mNoneDataTv;
// @BindView(R.id.reuse_no_connection)
// LinearLayout mNoConnection;
// @BindView(R.id.toolbox_refresh)
// SwipeRefreshLayout mRefresh;
// @BindView(R.id.reuse_ll_loading)
// View mLoading;
//
// private LinearLayoutManager mLayoutManager;
// private ToolBoxRvAdapter mRvAdapter;
// private ToolBoxRvAdapter mNormalRvAdapter;
//
// private boolean mIsSearch; // 记录页面状态 搜索页面/普通页面
// private String mSearchKey; // 记录搜索关键字
//
// Runnable runnable = () -> changeAdapter(true);
//
// @NonNull
// public static Intent getIntent(Context context, String entrance) {
// Intent intent = new Intent(context, ToolBoxActivity.class);
// intent.putExtra(EntranceUtils.KEY_ENTRANCE, entrance);
// return intent;
// }
//
// @Override
// protected int getLayoutId() {
// return R.layout.activity_toolbox;
// }
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setNavigationTitle("光环工具箱");
//
// mRefresh.setColorSchemeResources(R.color.theme);
// mRefresh.setOnRefreshListener(this);
//
// // 跳转到工具箱 https://gitlab.ghzs.com/pm/halo-app-issues/issues/636
// String gameId = getIntent().getStringExtra(EntranceUtils.KEY_GAMEID);
// String targetUrl = getIntent().getStringExtra(EntranceUtils.KEY_URL);
// if (!TextUtils.isEmpty(targetUrl) && !TextUtils.isEmpty(gameId)) {
// findGameAndOpenItsToolboxWebview(gameId, targetUrl);
// }
//
// mLayoutManager = new LinearLayoutManager(this);
// mToolboxRv.setLayoutManager(mLayoutManager);
// mRvAdapter = new ToolBoxRvAdapter(this, this, mIsSearch, mSearchKey);
// mToolboxRv.addItemDecoration(new VerticalItemDecoration(this, 8, false));
// mToolboxRv.setAdapter(mRvAdapter);
//
// mNormalRvAdapter = mRvAdapter;
//
// mToolboxRv.addOnScrollListener(new RecyclerView.OnScrollListener() {
// @Override
// public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
// super.onScrollStateChanged(recyclerView, newState);
// if (newState == RecyclerView.SCROLL_STATE_IDLE && mLayoutManager.findLastVisibleItemPosition() + 1 == mRvAdapter
// .getItemCount()) {
// if (!mRvAdapter.isOver() && !mRvAdapter.isLoading() && !mRvAdapter.isNetworkError()) {
// mRvAdapter.loadData();
// }
// }
// }
// });
//
// mAppBar.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> {
// if (verticalOffset == 0) {
// mRefresh.setEnabled(true);
// } else {
// mRefresh.setEnabled(false);
// }
// int totalScrollRange = appBarLayout.getTotalScrollRange();
// if (totalScrollRange == -verticalOffset) {
// Util_System_Keyboard.hideSoftKeyboard(this);
// }
// });
//
// initSearch();
// }
//
// private void findGameAndOpenItsToolboxWebview(String gameId, String url) {
// RetrofitManager.getInstance()
// .getApi()
// .getGameToolBoxData(1, UrlFilterUtils.getFilterQuery("game_id", gameId))
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new Response<List<ToolBoxEntity>>() {
// @Override
// public void onResponse(@Nullable List<ToolBoxEntity> response) {
// if (response == null) return;
//
// for (ToolBoxEntity toolbox : response) {
// if (url.equals(toolbox.getUrl())) {
// Intent intent = WebActivity.getWebByCollectionTools(ToolBoxActivity.this, toolbox, false);
// startActivity(intent);
// }
// }
// }
// });
// }
//
// private void initSearch() {
// backTv.setOnClickListener(v -> search(false, ""));
//
// TextHelper.limitTheLengthOfEditText(searchEt, 20, () -> {
// Utils.toast(this, "最多输入20字");
// });
//
// searchTv.setOnClickListener(v -> {
// MtaHelper.onEvent("我的光环_新", "工具箱", "点击搜索");
// if (TextUtils.isEmpty(searchEt.getText().toString())) {
// Utils.toast(this, R.string.search_hint);
// return;
// }
// Util_System_Keyboard.hideSoftKeyboard(this,searchEt);
// search(true, searchEt.getText().toString());
// });
//
// searchEt.setOnFocusChangeListener((v, hasFocus) -> {
// if (!hasFocus) {
// Util_System_Keyboard.hideSoftKeyboard(this, searchEt);
// }
// });
//
// searchEt.setOnEditorActionListener((v, actionId, event) -> {
// if (actionId == EditorInfo.IME_ACTION_SEARCH) {
// searchTv.performClick();
// }
// return false;
// });
// }
//
//
// @OnClick({R.id.reuse_no_connection, R.id.reuse_none_data})
// public void onClick(View view) {
// if (view.getId() == R.id.reuse_no_connection) {
// mLoading.setVisibility(View.VISIBLE);
// mNoConnection.setVisibility(View.GONE);
// mLoading.postDelayed(runnable, 1000);
// } else if (view.getId() == R.id.reuse_none_data) {
// if (mIsSearch) {
// // TODO反馈
// MtaHelper.onEvent("我的光环_新", "工具箱", "点击反馈");
// SuggestionActivity.startSuggestionActivity(this, SuggestType.functionSuggest, null, null);
// }
// }
// }
//
// @Override
// public void loadDone() {
// mRefresh.setRefreshing(false);
// mNoneData.setVisibility(View.GONE);
// mNoConnection.setVisibility(View.GONE);
// mLoading.setVisibility(View.GONE);
// }
//
// @Override
// public void loadDone(Object obj) {
//
// }
//
// @Override
// public void loadEmpty() {
// mRefresh.setRefreshing(false);
// mNoneData.setVisibility(View.VISIBLE);
// mNoConnection.setVisibility(View.GONE);
// mLoading.setVisibility(View.GONE);
// if (mIsSearch) {
// mNoneDataTv.setText("未找到结果,点我反馈");
// } else {
// mNoneDataTv.setText(getResources().getString(R.string.game_empty));
// }
// }
//
// @Override
// public void loadError() {
// mRefresh.setRefreshing(false);
// mNoneData.setVisibility(View.GONE);
// mNoConnection.setVisibility(View.VISIBLE);
// mLoading.setVisibility(View.GONE);
// }
//
// @Override
// public void onRefresh() {
// mRefresh.postDelayed(runnable, 1000);
// }
//
// public void search(boolean isSearch, String searchKey) {
// if (mNoneData.getVisibility() == View.VISIBLE) {
// mNoneData.setVisibility(View.GONE);
// }
// if (isSearch) {
// mLoading.setVisibility(View.VISIBLE);
// }
// mIsSearch = isSearch;
// mSearchKey = searchKey;
// changeAdapter(false);
// }
//
// private void changeAdapter(boolean isRefresh) {
// if (mIsSearch) {
// mRvAdapter = new ToolBoxRvAdapter(this, this, mIsSearch, mSearchKey);
// } else {
// if (mNormalRvAdapter != null && !isRefresh) {
// mRvAdapter = mNormalRvAdapter;
// } else {
// mRvAdapter = new ToolBoxRvAdapter(this, this, mIsSearch, null);
// mNormalRvAdapter = mRvAdapter;
// }
// }
// mToolboxRv.setAdapter(mRvAdapter);
//
// if (mSearchKey != null) {
// searchEt.setText(mSearchKey);
// searchEt.setSelection(searchEt.getText().length());
// }
//
// if (mIsSearch) {
// backTv.setVisibility(View.VISIBLE);
// } else {
// backTv.setVisibility(View.GONE);
// }
// }
//}

View File

@ -12,25 +12,24 @@ import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.ViewHolder;
import com.gh.common.constant.Config;
import com.gh.common.util.DataCollectionUtils;
import com.gh.gamecenter.core.utils.DisplayUtils;
import com.gh.common.util.NewsUtils;
import com.gh.gamecenter.core.utils.StringUtils;
import com.gh.gamecenter.common.utils.TextHelper;
import com.gh.gamecenter.core.utils.UrlFilterUtils;
import com.gh.gamecenter.NewsDetailActivity;
import com.gh.gamecenter.NewsSearchActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.common.viewholder.FooterViewHolder;
import com.gh.gamecenter.adapter.viewholder.GameNewsSearchViewHolder;
import com.gh.gamecenter.adapter.viewholder.GameNewsTypeListViewHolder;
import com.gh.gamecenter.adapter.viewholder.NewsTextViewHolder;
import com.gh.gamecenter.common.retrofit.Response;
import com.gh.gamecenter.common.utils.TextHelper;
import com.gh.gamecenter.common.viewholder.FooterViewHolder;
import com.gh.gamecenter.core.utils.DisplayUtils;
import com.gh.gamecenter.core.utils.StringUtils;
import com.gh.gamecenter.core.utils.UrlFilterUtils;
import com.gh.gamecenter.databinding.GameNewsSearchItemBinding;
import com.gh.gamecenter.databinding.GameNewsTypeItemBinding;
import com.gh.gamecenter.databinding.NewsTextItemBinding;
import com.gh.gamecenter.feature.entity.NewsEntity;
import com.gh.gamecenter.common.retrofit.Response;
import com.gh.gamecenter.newsdetail.NewsDetailActivity;
import com.gh.gamecenter.retrofit.RetrofitManager;
import com.lightgame.adapter.BaseRecyclerAdapter;
import com.lightgame.utils.Utils;
@ -110,7 +109,6 @@ public class GameNewsAdapter extends BaseRecyclerAdapter<ViewHolder> {
@Override
public List<NewsEntity> apply(List<NewsEntity> list) {
// 去除重复数据
Config.filterPluginArticle(list);
return NewsUtils.removeDuplicateData(mNewsList, list);
}
})

View File

@ -18,35 +18,35 @@ import com.gh.common.util.ConcernContentUtils;
import com.gh.common.util.DataCollectionUtils;
import com.gh.common.util.DialogUtils;
import com.gh.common.util.DirectUtils;
import com.gh.gamecenter.common.utils.ExtensionsKt;
import com.gh.gamecenter.core.utils.DisplayUtils;
import com.gh.gamecenter.common.constant.EntranceConsts;
import com.gh.gamecenter.common.utils.ImageUtils;
import com.gh.gamecenter.core.utils.MtaHelper;
import com.gh.common.util.NewsUtils;
import com.gh.gamecenter.core.utils.NumberUtils;
import com.gh.gamecenter.core.utils.StringUtils;
import com.gh.gamecenter.common.utils.TextHelper;
import com.gh.gamecenter.common.utils.TimestampUtils;
import com.gh.gamecenter.NewsDetailActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.ShareCardActivity;
import com.gh.gamecenter.ShareCardPicActivity;
import com.gh.gamecenter.WebActivity;
import com.gh.gamecenter.adapter.viewholder.CommentHeadViewHolder;
import com.gh.gamecenter.adapter.viewholder.CommentViewHolder;
import com.gh.gamecenter.common.constant.EntranceConsts;
import com.gh.gamecenter.common.retrofit.JSONObjectResponse;
import com.gh.gamecenter.common.retrofit.OkHttpCache;
import com.gh.gamecenter.common.retrofit.Response;
import com.gh.gamecenter.common.utils.ExtensionsKt;
import com.gh.gamecenter.common.utils.ImageUtils;
import com.gh.gamecenter.common.utils.TextHelper;
import com.gh.gamecenter.common.utils.TimestampUtils;
import com.gh.gamecenter.common.viewholder.FooterViewHolder;
import com.gh.gamecenter.feature.databinding.NewsDigestItemBinding;
import com.gh.gamecenter.feature.viewholder.NewsDigestViewHolder;
import com.gh.gamecenter.core.utils.DisplayUtils;
import com.gh.gamecenter.core.utils.MtaHelper;
import com.gh.gamecenter.core.utils.NumberUtils;
import com.gh.gamecenter.core.utils.StringUtils;
import com.gh.gamecenter.databinding.CommentHeadItemBinding;
import com.gh.gamecenter.feature.databinding.NewsDigestItemBinding;
import com.gh.gamecenter.feature.entity.ArticleCommentParent;
import com.gh.gamecenter.feature.entity.CommentEntity;
import com.gh.gamecenter.feature.entity.ConcernEntity;
import com.gh.gamecenter.feature.eventbus.EBDeleteComment;
import com.gh.gamecenter.feature.viewholder.NewsDigestViewHolder;
import com.gh.gamecenter.manager.VisitManager;
import com.gh.gamecenter.common.retrofit.JSONObjectResponse;
import com.gh.gamecenter.common.retrofit.OkHttpCache;
import com.gh.gamecenter.common.retrofit.Response;
import com.gh.gamecenter.newsdetail.NewsDetailActivity;
import com.gh.gamecenter.retrofit.RetrofitManager;
import com.lightgame.adapter.BaseRecyclerAdapter;
import com.lightgame.utils.Utils;

View File

@ -608,7 +608,6 @@ class DetailViewHolder(
builder.addHandler(BrowserInstallHandler())
builder.addHandler(PackageCheckHandler())
builder.addHandler(DownloadDialogHelperHandler())
builder.addHandler(CertificationHandler())
builder.addHandler(VersionNumberHandler())
builder.addHandler(LandPageAddressHandler())
builder.addHandler(OverseaDownloadHandler())
@ -617,7 +616,6 @@ class DetailViewHolder(
download(asVGame, isSubscribe as Boolean)
}
} else {
builder.addHandler(CertificationHandler())
builder.addHandler(VersionNumberHandler())
builder.setProcessEndCallback { _: Boolean?, _: Any? ->
DownloadDialog.showDownloadDialog(

View File

@ -37,6 +37,7 @@ import com.gh.gamecenter.eventbus.EBDownloadStatus
import com.gh.gamecenter.eventbus.EBPackage
import com.gh.gamecenter.fragment.HomeSearchToolWrapperFragment
import com.gh.gamecenter.gamedetail.rating.RatingFragment
import com.gh.gamecenter.wrapper.SearchToolbarTabWrapperFragment
import com.lightgame.download.DataWatcher
import com.lightgame.download.DownloadEntity
import org.greenrobot.eventbus.Subscribe
@ -331,12 +332,12 @@ class AmwayFragment : LazyListFragment<AmwayListItemData, AmwayViewModel>() {
}
fun onScrollChanged() {
if (parentFragment is HomeSearchToolWrapperFragment) {
if (parentFragment is SearchToolbarTabWrapperFragment) {
val scrollY = mAlternativeBinding?.listRv?.computeVerticalScrollOffset()
if (scrollY != null) {
mAlternativeBinding?.headerContainer?.translationY = -scrollY.toFloat()
if (parentFragment is HomeSearchToolWrapperFragment && isSupportVisible) {
(parentFragment as HomeSearchToolWrapperFragment).onScrollChanged(
if (isSupportVisible) {
(parentFragment as SearchToolbarTabWrapperFragment).onScrollChanged(
mAlternativeBinding?.headerContainer?.measuredHeight ?: 0,
scrollY
)
@ -362,7 +363,7 @@ class AmwayFragment : LazyListFragment<AmwayListItemData, AmwayViewModel>() {
mDefaultBinding?.collapsingToolbar?.setContentScrimColor(R.color.ui_surface.toColor(requireContext()))
mDefaultBinding?.listRefresh?.setBackgroundColor(R.color.ui_background.toColor(requireContext()))
}
if (mIsFromMainWrapper) {
if (mIsFromMainWrapper && isSupportVisible) {
DisplayUtils.setLightStatusBar(requireActivity(), !mIsDarkModeOn && mIsCollapsed)
}
}

View File

@ -24,13 +24,13 @@ import com.gh.gamecenter.core.utils.SPUtils
import com.gh.gamecenter.databinding.FragmentCategoryBinding
import com.gh.gamecenter.entity.CategoryEntity
import com.gh.gamecenter.entity.SidebarsEntity
import com.gh.gamecenter.fragment.HomeSearchToolWrapperViewModel
import com.gh.gamecenter.wrapper.SearchToolbarTabWrapperViewModel
class CategoryV2Fragment : LazyFragment() {
private var mBinding: FragmentCategoryBinding? = null
private var mViewModel: CategoryV2ViewModel? = null
private var mHomeViewModel: HomeSearchToolWrapperViewModel? = null
private var mHomeViewModel: SearchToolbarTabWrapperViewModel? = null
private var mEntity: SidebarsEntity? = null
private var mSpecialCatalogFragment: SpecialCatalogFragment? = null
private var mCategoryV2ListFragment: CategoryV2ListFragment? = null
@ -68,8 +68,10 @@ class CategoryV2Fragment : LazyFragment() {
// 除了这里以外,下面还有一个判断是否为首页 tab 栏的赋值
mViewModel?.entrance = if (mEntrance.contains("首页")) "首页" else "板块"
if (arguments?.getBoolean(EntranceConsts.KEY_IS_HOME) == true) {
mHomeViewModel = viewModelProviderFromParent()
val multiTabNavId = arguments?.getString(EntranceConsts.KEY_MULTI_TAB_NAV_ID, "") ?: ""
if (arguments?.getBoolean(EntranceConsts.KEY_IS_HOME) == true && multiTabNavId.isNotEmpty()) {
mHomeViewModel = viewModelProviderFromParent(SearchToolbarTabWrapperViewModel.Factory(multiTabNavId, ""), multiTabNavId)
mViewModel?.entrance = "首页Tab栏"
}
mViewModel?.logAppearance()

View File

@ -242,7 +242,7 @@ class CategoryV2ListAdapter(
binding.run {
gameIconView.displayGameIcon(gameEntity)
gameRating.textSize = if (gameEntity.commentCount > 3) 12F else 10F
BindingAdapters.setGameName(gameName, gameEntity, false, null)
BindingAdapters.setGameName(gameName, gameEntity, false)
BindingAdapters.setGameTags(labelList, gameEntity)
gameRating.setDrawableStart(if (gameEntity.commentCount > 3) R.drawable.game_horizontal_rating.toDrawable() else null)
gameRating.text = if (gameEntity.commentCount > 3) {

View File

@ -10,18 +10,18 @@ import androidx.recyclerview.widget.RecyclerView;
import com.gh.common.util.CollectionUtils;
import com.gh.common.util.DataCollectionUtils;
import com.gh.gamecenter.common.utils.DialogHelper;
import com.gh.gamecenter.common.constant.EntranceConsts;
import com.gh.gamecenter.common.view.CustomDividerItemDecoration;
import com.gh.gamecenter.NewsDetailActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.common.baselist.ListAdapter;
import com.gh.gamecenter.common.baselist.ListFragment;
import com.gh.gamecenter.common.baselist.LoadType;
import com.gh.gamecenter.feature.entity.NewsEntity;
import com.gh.gamecenter.common.constant.EntranceConsts;
import com.gh.gamecenter.common.utils.DialogHelper;
import com.gh.gamecenter.common.view.CustomDividerItemDecoration;
import com.gh.gamecenter.eventbus.EBCollectionChanged;
import com.gh.gamecenter.feature.entity.NewsEntity;
import com.gh.gamecenter.history.IBatchDelete;
import com.gh.gamecenter.history.ManageOption;
import com.gh.gamecenter.newsdetail.NewsDetailActivity;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

View File

@ -11,8 +11,6 @@ import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import com.gh.common.util.CollectionUtils;
import com.gh.gamecenter.common.view.CustomDividerItemDecoration;
import com.gh.gamecenter.NewsDetailActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.WebActivity;
import com.gh.gamecenter.common.baselist.ListAdapter;
@ -20,8 +18,10 @@ import com.gh.gamecenter.common.baselist.ListFragment;
import com.gh.gamecenter.common.baselist.LoadType;
import com.gh.gamecenter.common.baselist.NormalListViewModel;
import com.gh.gamecenter.common.entity.ToolBoxEntity;
import com.gh.gamecenter.common.view.CustomDividerItemDecoration;
import com.gh.gamecenter.eventbus.EBCollectionChanged;
import com.gh.gamecenter.login.user.UserManager;
import com.gh.gamecenter.newsdetail.NewsDetailActivity;
import com.gh.gamecenter.retrofit.RetrofitManager;
import org.greenrobot.eventbus.Subscribe;

View File

@ -14,7 +14,6 @@ import com.gh.common.util.HomeBottomBarHelper
import com.gh.common.util.NewFlatLogUtils
import com.gh.gamecenter.BlockActivity
import com.gh.gamecenter.GameDetailActivity
import com.gh.gamecenter.MainActivity
import com.gh.gamecenter.R
import com.gh.gamecenter.adapter.viewholder.GameViewHolder
import com.gh.gamecenter.common.base.BaseRecyclerViewHolder
@ -33,15 +32,11 @@ import com.gh.gamecenter.discovery.DiscoveryFragment.Companion.INTERESTED_GAME_R
import com.gh.gamecenter.discovery.interestedgame.InterestedGameActivity
import com.gh.gamecenter.entity.DiscoveryGameCardLabel
import com.gh.gamecenter.eventbus.EBDownloadStatus
import com.gh.gamecenter.eventbus.EBSkip
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.feature.exposure.ExposureType
import com.gh.gamecenter.feature.game.GameItemViewHolder
import com.gh.gamecenter.fragment.MainWrapperFragment
import com.gh.gamecenter.fragment.MainWrapperRepository
import com.lightgame.download.DownloadEntity
import org.greenrobot.eventbus.EventBus
class DiscoveryAdapter(
context: Context,
@ -220,14 +215,8 @@ class DiscoveryAdapter(
}
}
recommendIv.setOnClickListener {
val navBar = MainWrapperRepository.getInstance().getGameNavBarLiveData().value
if (navBar == null || mContext is DiscoveryActivity) {
val blockData = HomeBottomBarHelper.getDefaultGameBarData()
mContext.startActivity(BlockActivity.getIntent(mContext, blockData, mBaseExposureSource, mEntrance))
} else {
EventBus.getDefault()
.post(EBSkip(MainActivity.EB_SKIP_MAIN, MainWrapperFragment.INDEX_GAME))
}
val blockData = HomeBottomBarHelper.getDefaultGameBarData()
mContext.startActivity(BlockActivity.getIntent(mContext, blockData, mBaseExposureSource, mEntrance))
NewFlatLogUtils.logDiscoverPageJumpGamesLibraries()
}
}
@ -319,7 +308,7 @@ class DiscoveryAdapter(
gameIconView.displayGameIcon(gameEntity)
gameRating.textSize = if (gameEntity.commentCount > 3) 12F else 10F
BindingAdapters.setGameName(gameName, gameEntity, false, null)
BindingAdapters.setGameName(gameName, gameEntity, false)
gameRating.setDrawableStart(if (gameEntity.commentCount > 3) R.drawable.game_horizontal_rating.toDrawable() else null)
gameRating.text = if (gameEntity.commentCount > 3) {
if (gameEntity.star == 10.0F) "10" else gameEntity.star.toString()

View File

@ -27,6 +27,7 @@ import com.gh.gamecenter.DownloadManagerActivity
import com.gh.gamecenter.R
import com.gh.gamecenter.common.base.fragment.BaseFragment_TabLayout
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.eventbus.EBMiPush
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.core.utils.DisplayUtils
@ -87,7 +88,14 @@ class DownloadFragment : BaseFragment_TabLayout() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
SensorsBridge.trackDownloadManagerEnter()
SensorsBridge.trackDownloadManagerEnter(
mEntrance,
arguments?.getString(EntranceConsts.KEY_BOTTOM_TAB_NAME, "") ?: "",
arguments?.getString(EntranceConsts.KEY_GAME_COLUMN_ID, "") ?: "",
arguments?.getString(EntranceConsts.KEY_GAME_COLUMN_NAME, "") ?: "",
arguments?.getString(EntranceConsts.KEY_CUSTOM_PAGE_ID, "") ?: "",
arguments?.getString(EntranceConsts.KEY_CUSTOM_PAGE_NAME, "") ?: ""
)
mPermanentInactivePluggableApkList = HomePluggableHelper.getPermanentInactivePluggablePackage()
}

View File

@ -15,24 +15,24 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.gh.common.xapk.XapkDialogHelper;
import com.gh.gamecenter.common.base.fragment.BaseFragment;
import com.gh.gamecenter.common.utils.DialogHelper;
import com.gh.gamecenter.common.constant.EntranceConsts;
import com.gh.gamecenter.common.utils.NetworkUtils;
import com.gh.common.xapk.XapkInstaller;
import com.gh.common.xapk.XapkUnzipStatus;
import com.gh.download.DownloadManager;
import com.gh.gamecenter.DownloadManagerActivity;
import com.gh.gamecenter.MainActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.common.base.fragment.BaseFragment;
import com.gh.gamecenter.common.constant.EntranceConsts;
import com.gh.gamecenter.common.eventbus.EBMiPush;
import com.gh.gamecenter.common.utils.DialogHelper;
import com.gh.gamecenter.common.utils.ExtensionsKt;
import com.gh.gamecenter.common.utils.NetworkUtils;
import com.gh.gamecenter.core.utils.DisplayUtils;
import com.gh.gamecenter.databinding.DownloadmanagerBinding;
import com.gh.gamecenter.eventbus.EBDownloadChanged;
import com.gh.gamecenter.common.eventbus.EBMiPush;
import com.gh.gamecenter.eventbus.EBPackage;
import com.gh.gamecenter.eventbus.EBUISwitch;
import com.gh.gamecenter.fragment.MainWrapperFragment;
import com.gh.gamecenter.wrapper.MainWrapperFragment;
import com.lightgame.download.DataWatcher;
import com.lightgame.download.DownloadConfig;
import com.lightgame.download.DownloadEntity;
@ -238,7 +238,7 @@ public class GameDownloadFragment extends BaseFragment implements View.OnClickLi
mBinding.reuseNoneData.reuseNoneDataDescTv.setText(getString(R.string.game_no_data_desc));
mBinding.reuseNoneData.reuseResetLoadTv.setText("去首页看看");
mBinding.reuseNoneData.reuseResetLoadTv.setVisibility(View.VISIBLE);
mBinding.reuseNoneData.reuseResetLoadTv.setOnClickListener(v -> MainActivity.skipToMainActivity(getActivity(), MainWrapperFragment.INDEX_HOME));
mBinding.reuseNoneData.reuseResetLoadTv.setOnClickListener(v -> MainActivity.skipToMainActivity(getActivity(), MainWrapperFragment.TYPE_HOME));
mBinding.downloadingHintContainer.setOnClickListener(v -> mBinding.downloadmanagerRvShow.scrollToPosition(adapter.getItemCount() - 1));
mBinding.downloadmanagerRvShow.setHasFixedSize(true);

View File

@ -120,7 +120,6 @@ class InstalledGameViewModel(application: Application) : AndroidViewModel(applic
for (entity in gameList) {
if (entity.id == id) {
val newEntity = entity.copy()
newEntity.isLibaoExists = entity.isLibaoExists
// 下载管理不显示镜像游戏,不然会有奇怪的问题
if (entity.shouldUseMirrorInfo()) {

View File

@ -20,16 +20,15 @@ import com.gh.gamecenter.common.utils.toColor
import com.gh.gamecenter.common.view.FixLinearLayoutManager
import com.gh.gamecenter.common.view.VerticalItemDecoration
import com.gh.gamecenter.core.utils.DisplayUtils
import com.gh.gamecenter.core.utils.EmptyCallback
import com.gh.gamecenter.databinding.FragmentMyGameBinding
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.entity.GameInstall
import com.gh.gamecenter.eventbus.EBDownloadStatus
import com.gh.gamecenter.eventbus.EBPackage
import com.gh.gamecenter.fragment.MainWrapperFragment
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.entity.GameInstall
import com.gh.gamecenter.manager.PackagesManager
import com.gh.gamecenter.packagehelper.PackageRepository
import com.gh.gamecenter.packagehelper.PackageViewModel
import com.gh.gamecenter.wrapper.MainWrapperFragment
import com.lightgame.download.DataWatcher
import com.lightgame.download.DownloadEntity
import com.lightgame.download.DownloadStatus
@ -143,7 +142,7 @@ class NewInstalledGameFragment : ToolbarFragment() {
mBinding.reuseNoneData.reuseNoneDataDescTv.text = getString(R.string.game_no_data_desc)
mBinding.reuseNoneData.reuseResetLoadTv.text = "去首页看看"
mBinding.reuseNoneData.reuseResetLoadTv.setOnClickListener {
MainActivity.skipToMainActivity(requireContext(), MainWrapperFragment.INDEX_HOME)
MainActivity.skipToMainActivity(requireContext(), MainWrapperFragment.TYPE_HOME)
}
mBinding.run {
@ -163,7 +162,7 @@ class NewInstalledGameFragment : ToolbarFragment() {
reuseNoneData.reuseNoneDataTv.text = getString(R.string.game_no_data)
reuseNoneData.reuseNoneDataDescTv.text = getString(R.string.game_no_data_desc)
reuseNoneData.reuseResetLoadTv.setOnClickListener {
MainActivity.skipToMainActivity(activity, MainWrapperFragment.INDEX_HOME)
MainActivity.skipToMainActivity(activity, MainWrapperFragment.TYPE_HOME)
}
}
}

View File

@ -14,9 +14,9 @@ import com.gh.gamecenter.core.utils.DisplayUtils
import com.gh.gamecenter.core.utils.EmptyCallback
import com.gh.gamecenter.databinding.FragmentGameUpdatableBinding
import com.gh.gamecenter.eventbus.EBDownloadStatus
import com.gh.gamecenter.fragment.MainWrapperFragment
import com.gh.gamecenter.packagehelper.PackageRepository
import com.gh.gamecenter.packagehelper.PackageViewModel
import com.gh.gamecenter.wrapper.MainWrapperFragment
import com.lightgame.download.DataWatcher
import com.lightgame.download.DownloadEntity
import org.greenrobot.eventbus.Subscribe
@ -119,7 +119,7 @@ class UpdatableGameFragment : LazyFragment() {
noDataContainer.reuseNoneDataDescTv.text = getString(R.string.game_no_data_desc)
noDataContainer.reuseResetLoadTv.text = "去首页看看"
noDataContainer.reuseResetLoadTv.setOnClickListener {
MainActivity.skipToMainActivity(activity, MainWrapperFragment.INDEX_HOME)
MainActivity.skipToMainActivity(activity, MainWrapperFragment.TYPE_HOME)
}
}
}

View File

@ -28,8 +28,6 @@ data class AmwayCommentEntity(
var iconSubscript: String? = "",
@SerializedName("name")
private var mName: String,
@SerializedName("name_suffix")
var nameSuffix: String? = "",
@SerializedName(value = "new_tag_style")
var tag: List<TagStyleEntity>? = arrayListOf(),
@SerializedName("new_star")
@ -48,7 +46,7 @@ data class AmwayCommentEntity(
@IgnoredOnParcel
val name: String?
get() = mName.removeSuffix(".") + (nameSuffix ?: "")
get() = mName.removeSuffix(".")
fun toGameEntity(): GameEntity {
val gameEntity = GameEntity()

View File

@ -0,0 +1,36 @@
package com.gh.gamecenter.entity
import android.os.Parcelable
import androidx.annotation.DrawableRes
import com.gh.gamecenter.common.entity.LinkEntity
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize
@Parcelize
data class BottomTab(
@SerializedName("_id")
val id: String = "",
val name: String = "",
@SerializedName("icon_select")
val iconSelect: String = "", // 选中图片
@SerializedName("icon_unselect")
val iconUnselect: String = "", // 未选中图片
@DrawableRes
val iconSelector: Int = 0, // 本地字段
@SerializedName("js_code")
val jsCode: String = "", // js代码
val link: LinkEntity? = null, // 通用链接
@SerializedName("search_style")
val searchStyle: SearchStyle = SearchStyle(), // 搜索样式
@SerializedName("is_default_page")
var default: Boolean = false, // 是否为默认显示页
var isTransparentStyle: Boolean = false // 本地字段透明底部Tab
): Parcelable {
@Parcelize
data class SearchStyle(
@SerializedName("style_type")
val styleType: String = "two_lines", // 样式类型two_lines搜索栏与顶部tab分为两行、apposition搜索栏与顶部tab同一行
@SerializedName("search_type")
var searchType: String = "halo_game", // 搜索类型halo_game光环游戏、qq_mini_gameQQ小游戏、bbs论坛
): Parcelable
}

View File

@ -0,0 +1,13 @@
package com.gh.gamecenter.entity
import com.gh.gamecenter.home.custom.model.CustomPageData
import com.google.gson.annotations.SerializedName
data class DataUnionEntity(
@SerializedName("bottom_tab")
val bottomTab: List<BottomTab> = listOf(), // 底部tab
@SerializedName("multi_tab_nav")
val multiTabNav: MultiTabNav? = null, // 多tab导航页当默认页为【多tab导航数据】时才有此字段数据
@SerializedName("custom_page")
val customPage: CustomPageData? = null, // 自定义页面相关信息(当默认页为【自定义页面】时才有此字段数据】)
)

View File

@ -9,8 +9,6 @@ class GameVideoInfo(
val gameName: String = "",
@SerializedName("game_icon")
val gameIcon: String = "",
@SerializedName("name_suffix")
var nameSuffix: String? = null,
@SerializedName("video_count")
val videoCount: Int = 0,
@SerializedName("vote_count")

View File

@ -43,8 +43,6 @@ data class HistoryGameEntity(
gameEntity.subtitleStyle = subtitleStyle
gameEntity.name = name
gameEntity.tagStyle = tagStyle
gameEntity.isLibaoExists = isLibaoExist
gameEntity.setTag(tag)
return gameEntity
}
}

View File

@ -16,5 +16,5 @@ class HomeDataEntity(
@SerializedName("home_sub_slide")
val homeSubSlide: ArrayList<HomeSubSlide> = arrayListOf(),
@SerializedName("home_push")
var homePush: HomePush? = null
var homePush: PullDownPush? = null
)

View File

@ -28,7 +28,9 @@ data class HomeSubSlide(
val cardData: CardData = CardData(),
val image: String = "",
val title: String = "",
var sequence: Int = -1 // 本地字段
// 本地字段
var sequence: Int = -1,
var repeatCount: Int = -1
) {
fun toLinkEntity(): LinkEntity {
return if (linkType.isNotEmpty()) {

View File

@ -0,0 +1,40 @@
package com.gh.gamecenter.entity
import android.graphics.Color
import com.gh.gamecenter.common.entity.LinkEntity
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.google.gson.annotations.SerializedName
data class MultiTabNav(
@SerializedName("_id")
val id: String = "",
val title: String = "",
@SerializedName("link_multi_tab_nav")
val linkMultiTabNav: List<LinkMultiTabNav> = ArrayList()
) {
data class LinkMultiTabNav(
@SerializedName("_id")
val id: String = "",
val name: String = "",
val img: String = "",
@SerializedName("tab_show_img")
var showImgOnSelected: Boolean? = false, // 选中时是否显示图片
@SerializedName("is_default_page")
var default: Boolean = false, // 是否为默认显示页
val link: LinkEntity? = null, // 通用链接
// 本地字段
var style: TabStyle = TabStyle(),
var showPullDownPush: Boolean = false,
var exposureEvent: ExposureEvent? = null, // 绑定的曝光实体
) {
data class TabStyle(
var useLightStyle: Boolean = false,
var primaryColor: Int = Color.WHITE,
var offsetRatio: Float = 0F,
var currentSelectColor: Int = 0,
var isSlideBackgroundColorEnable: Boolean = false, // 是否启用首页轮播图背景颜色
var isSlideBackgroundColorShow: Boolean = false, // 是否正在显示首页轮播图背景颜色
)
}
}

View File

@ -121,8 +121,6 @@ data class PersonalHistoryEntity(
val id: String = "",
@SerializedName("name")
private var mName: String = "",
@SerializedName("name_suffix")
val nameSuffix: String = "",
val icon: String = "",
@SerializedName(value = "new_tag_style")

View File

@ -3,7 +3,7 @@ package com.gh.gamecenter.entity
import com.gh.gamecenter.feature.entity.GameEntity
import com.google.gson.annotations.SerializedName
data class HomePush(
data class PullDownPush(
@SerializedName("_id")
val id: String = "",
@SerializedName("pop_switch")
@ -13,6 +13,7 @@ data class HomePush(
val imgUrl: String = "",
val video: Video? = null,
val game: GameEntity? = null,
var isSlideBackgroundColorEnable: Boolean = false // 本地字段,是否启用首页轮播图背景颜色
)
data class Video(

View File

@ -15,7 +15,6 @@ class SubjectData(
var filter: String = "", // Filter: 类型(分类)
var tagType: String? = "", // 游戏Item 标签类型
var briefStyle: String = "",
var showSuffix: Boolean = true,
var isQQMiniGame: Boolean = false,
var requireUpdateSetting: Boolean = false, // 多专题页面需要专题页面自行获取专题配置
@ -34,7 +33,6 @@ class SubjectData(
name = subjectName,
isOrder = isOrder ?: false,
briefStyle = briefStyle,
isShowSuffix = showSuffix,
tag = tagType
)
}

View File

@ -9,6 +9,8 @@ import com.gh.gamecenter.feature.entity.GameEntity
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.IgnoredOnParcel
import kotlinx.parcelize.Parcelize
import kotlin.math.max
import kotlin.math.min
/**
* Created by LGT on 2016/7/1.
@ -32,7 +34,8 @@ data class SubjectEntity(
@SerializedName("relation_column_id")
var relatedColumnId: String? = null,
var style: String? = "", // 值为 "top" 时表示此专题(合集)为排行榜 https://gitlab.ghzs.com/pm/halo-app-issues/issues/699
val list: Int = 0,
@SerializedName("list")
private val _list: Int? = null,
@SerializedName("common_collection_content")
var commonCollectionList: MutableList<CommonCollectionContentEntity>? = null,
@SerializedName("home_page_style")
@ -48,8 +51,6 @@ data class SubjectEntity(
@SerializedName("show_name")
var showName: Boolean = true, // 是否显示“专题名字”true、false
@SerializedName("show_suffix")
var showSuffix: Boolean = true, // 是否显示”游戏后缀“true、false
@SerializedName("type_style")
var typeStyle: String = "", // 横屏样式不显示default、评分star、备注remark
@SerializedName("brief_style")
@ -101,7 +102,10 @@ data class SubjectEntity(
@SerializedName("is_qq_column")
var isQQColumn: Boolean = false,
var explain: String = "" // 游戏单合集说明
var explain: String = "", // 游戏单合集说明
@SerializedName("show_star")
private val _showStar: Boolean? = null
) : Parcelable {
@IgnoredOnParcel
@ -111,10 +115,13 @@ data class SubjectEntity(
mData = value
}
val showStar: Boolean
get() = _showStar ?: false
fun getFilterName(): String {
if (!TextUtils.isEmpty(name) && !Config.isShowPlugin()) {
name = name?.replace("插件", "游戏")
}
return if (name == null) "" else name!!
}
val list: Int
get() = max(min(_list ?: 0, data?.size ?: 0), 1)
}

View File

@ -16,8 +16,6 @@ class SubjectSettingEntity(
var filter: String = "", // rows: off/on
var order: Boolean = false, // 是否显示序号
@SerializedName("show_suffix")
var showSuffix: Boolean = true,
@SerializedName("brief_style")
var briefStyle: String = "",

View File

@ -25,8 +25,6 @@ open class VideoEntity(
val gameId: String = "",
@SerializedName("game_name")
private var mGameName: String = "",
@SerializedName("name_suffix")
var nameSuffix: String? = null,
@SerializedName("game_icon")
val gameIcon: String = "",
@SerializedName("category_id")
@ -73,7 +71,7 @@ open class VideoEntity(
@IgnoredOnParcel
val gameName: String
get() = mGameName.removeSuffix(".") + (nameSuffix ?: "")
get() = mGameName.removeSuffix(".")
fun getThumb(): String {
val configProvider = ARouter.getInstance().build(RouteConsts.provider.config).navigation() as? IConfigProvider

View File

@ -7,12 +7,18 @@ public class EBSkip {
private String type;
private int currentItem;
private String linkType;
public EBSkip(String type, int currentItem) {
this.type = type;
this.currentItem = currentItem;
}
public EBSkip(String type, String linkType) {
this.type = type;
this.linkType = linkType;
}
public String getType() {
return type;
}
@ -21,4 +27,8 @@ public class EBSkip {
return currentItem;
}
public String getLinkType() {
return linkType;
}
}

View File

@ -4,12 +4,18 @@ public class EBUISwitch {
private String from;
private int position;
private String linkType;
public EBUISwitch(String from, int position) {
this.position = position;
this.from = from;
}
public EBUISwitch(String from, String linkType) {
this.linkType = linkType;
this.from = from;
}
public int getPosition() {
return position;
}
@ -26,4 +32,11 @@ public class EBUISwitch {
this.from = from;
}
public String getLinkType() {
return linkType;
}
public void setLinkType(String linkType) {
this.linkType = linkType;
}
}

View File

@ -41,7 +41,6 @@ import com.gh.common.util.LogUtils
import com.gh.common.util.NewFlatLogUtils
import com.gh.common.util.NewLogUtils
import com.gh.gamecenter.GameDetailActivity
import com.gh.gamecenter.NewsDetailActivity
import com.gh.gamecenter.R
import com.gh.gamecenter.common.base.TrackableDialog
import com.gh.gamecenter.common.base.adapter.FragmentStateAdapter
@ -77,6 +76,7 @@ import com.gh.gamecenter.gamedetail.fuli.FuLiFragment
import com.gh.gamecenter.login.entity.UserInfoEntity
import com.gh.gamecenter.login.user.UserManager
import com.gh.gamecenter.login.user.UserRepository
import com.gh.gamecenter.newsdetail.NewsDetailActivity
import com.gh.gamecenter.qa.article.edit.ArticleEditActivity
import com.gh.gamecenter.qa.draft.CommunityDraftWrapperActivity
import com.gh.gamecenter.qa.questions.edit.QuestionEditActivity
@ -286,9 +286,13 @@ class ForumDetailFragment : BaseLazyTabFragment(), IScrollable {
insertDataToAllTab(it)
}
ViewCompat.setOnApplyWindowInsetsListener(mBinding.forumAppbar) { _, insets ->
(mBinding.toolbar.layoutParams as ViewGroup.MarginLayoutParams).topMargin = insets.systemWindowInsetTop
insets.consumeSystemWindowInsets()
if (requireActivity() is ForumDetailActivity) {
ViewCompat.setOnApplyWindowInsetsListener(mBinding.forumAppbar) { _, insets ->
(mBinding.toolbar.layoutParams as MarginLayoutParams).topMargin = insets.systemWindowInsetTop
insets.consumeSystemWindowInsets()
}
} else if (arguments?.getBoolean(EntranceConsts.KEY_IS_FROM_MAIN_WRAPPER) == true) {
(mBinding.toolbar.layoutParams as MarginLayoutParams).topMargin = DisplayUtils.getStatusBarHeight(requireContext().resources)
}
mBinding.toolbar.setNavigationOnClickListener {
@ -707,7 +711,7 @@ class ForumDetailFragment : BaseLazyTabFragment(), IScrollable {
val location = IntArray(2)
moderatorTv.getLocationOnScreen(location)
moderatorGuideContainer.layoutParams =
(moderatorGuideContainer.layoutParams as ViewGroup.MarginLayoutParams).apply {
(moderatorGuideContainer.layoutParams as MarginLayoutParams).apply {
leftMargin = location[0] - 16F.dip2px()
}
moderatorGuideContainer.alpha = 0F
@ -747,7 +751,7 @@ class ForumDetailFragment : BaseLazyTabFragment(), IScrollable {
ForumOrUserSearchActivity.getIntent(
requireContext(),
mBbsId,
"论坛详情",
ENTRANCE,
SOURCE_ENTRANCE,
mForumDetail?.name ?: ""
)
@ -925,12 +929,15 @@ class ForumDetailFragment : BaseLazyTabFragment(), IScrollable {
if (isToolbarWhite) R.color.white else R.color.transparent
)
)
DisplayUtils.setStatusBarColor(
requireActivity(),
if (isToolbarWhite) R.color.white else R.color.transparent
)
if (arguments?.getString(EntranceConsts.KEY_MULTI_TAB_NAV_ID, "").isNullOrEmpty() && isSupportVisible) {
DisplayUtils.setStatusBarColor(
requireActivity(),
if (isToolbarWhite) R.color.white else R.color.transparent
)
DisplayUtils.setLightStatusBar(requireActivity(), isToolbarWhite)
}
if (isToolbarWhite) {
DisplayUtils.setLightStatusBar(requireActivity(), true)
if (!mIsFromMainWrapper) mBinding.toolbar.setNavigationIcon(R.drawable.ic_bar_back)
mBinding.searchIv.setImageDrawable(
ContextCompat.getDrawable(
@ -939,7 +946,6 @@ class ForumDetailFragment : BaseLazyTabFragment(), IScrollable {
)
)
} else {
DisplayUtils.setLightStatusBar(requireActivity(), false)
if (!mIsFromMainWrapper) mBinding.toolbar.setNavigationIcon(R.drawable.ic_bar_back_light)
mBinding.searchIv.setImageDrawable(
ContextCompat.getDrawable(
@ -1319,5 +1325,6 @@ class ForumDetailFragment : BaseLazyTabFragment(), IScrollable {
var TOP_CONTENT_TOP_MARGIN = 8F.dip2px()
const val SOURCE_ENTRANCE = "论坛"
const val ENTRANCE = "论坛详情"
}
}

View File

@ -41,8 +41,6 @@ import com.gh.gamecenter.eventbus.EBUISwitch
import com.gh.gamecenter.feature.entity.ArticleEntity
import com.gh.gamecenter.feature.entity.ForumVideoEntity
import com.gh.gamecenter.forum.search.ForumOrUserSearchActivity
import com.gh.gamecenter.fragment.MainWrapperFragment
import com.gh.gamecenter.fragment.MainWrapperViewModel
import com.gh.gamecenter.login.entity.UserInfoEntity
import com.gh.gamecenter.login.user.UserRepository
import com.gh.gamecenter.qa.article.detail.ArticleDetailWebCacheManager
@ -51,6 +49,9 @@ import com.gh.gamecenter.qa.draft.CommunityDraftWrapperActivity
import com.gh.gamecenter.qa.questions.edit.QuestionEditActivity
import com.gh.gamecenter.qa.video.publish.VideoPublishActivity
import com.gh.gamecenter.video.detail.VideoDetailContainerViewModel
import com.gh.gamecenter.wrapper.MainWrapperFragment
import com.gh.gamecenter.wrapper.MainWrapperRepository
import com.gh.gamecenter.wrapper.MainWrapperViewModel
import com.google.android.material.tabs.TabLayout
import com.halo.assistant.HaloApp
import org.greenrobot.eventbus.Subscribe
@ -98,8 +99,8 @@ class CommunityHomeFragment : LazyFragment() {
insertDataToRecommendTab(it)
}
mMainWrapperViewModel?.videoNavBar?.observe(this) {
mShowVideo = it?.type != "video_stream"
mMainWrapperViewModel?.bottomTabListLiveData?.observe(this) { tabList ->
mShowVideo = tabList.find { it.link?.type == MainWrapperRepository.TYPE_TAB_VIDEO } != null
mBinding?.searchContainer?.goneIf(mShowVideo)
mBinding?.videoAndSearchContainer?.goneIf(!mShowVideo) {
val decorView = requireActivity().window.decorView as? FrameLayout
@ -614,7 +615,7 @@ class CommunityHomeFragment : LazyFragment() {
@Subscribe(threadMode = ThreadMode.MAIN)
fun onEventMainThread(busNine: EBUISwitch) {
if (busNine.position == MainWrapperFragment.INDEX_BBS) {
if (MainWrapperFragment.EB_MAIN_SCROLL_TOP == busNine.from && busNine.linkType == MainWrapperFragment.TYPE_COMMUNITY_HOME) {
if (mFragmentList.isEmpty()) return
(mFragmentList[0] as ForumArticleListFragment).scrollToTop()
setPutQuestionButtonStatus(View.VISIBLE)

View File

@ -2,14 +2,14 @@ package com.gh.gamecenter.forum.home
import android.content.Context
import android.view.ViewGroup
import com.gh.gamecenter.common.base.BaseRecyclerViewHolder
import com.gh.common.util.CheckLoginUtils
import com.gh.common.util.DirectUtils
import com.gh.common.util.NewLogUtils
import com.gh.gamecenter.common.utils.toBinding
import com.gh.gamecenter.InfoActivity
import com.gh.gamecenter.common.base.BaseRecyclerViewHolder
import com.gh.gamecenter.common.utils.toBinding
import com.gh.gamecenter.databinding.ForumWelfareItemBinding
import com.gh.gamecenter.toolbox.ToolBoxBlockActivity
import com.gh.gamecenter.toolbox.ToolBoxActivity
import com.lightgame.adapter.BaseRecyclerAdapter
class WelfaresAdapter(
@ -35,7 +35,7 @@ class WelfaresAdapter(
when (entity.second) {
"游戏工具箱" -> {
NewLogUtils.logForumPageEvent("click_forum_toolbox")
mContext.startActivity(ToolBoxBlockActivity.getIntent(mContext, "(社区-论坛:工具箱)"))
mContext.startActivity(ToolBoxActivity.getIntent(mContext, "(社区-论坛:工具箱)"))
}
"礼包中心" -> {

View File

@ -4,20 +4,20 @@ import android.os.Bundle
import android.view.View
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import com.gh.gamecenter.common.constant.Constants
import com.gh.common.util.*
import com.gh.gamecenter.NewsDetailActivity
import com.gh.common.util.NewLogUtils
import com.gh.gamecenter.R
import com.gh.gamecenter.common.base.fragment.ToolbarFragment
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.utils.ifLogin
import com.gh.gamecenter.common.utils.toColor
import com.gh.gamecenter.common.utils.toDrawable
import com.gh.gamecenter.common.utils.viewModelProvider
import com.gh.gamecenter.core.utils.*
import com.gh.gamecenter.core.utils.ToastUtils
import com.gh.gamecenter.databinding.FragmentModeratorListBinding
import com.gh.gamecenter.entity.ApplyModeratorStatusEntity
import com.gh.gamecenter.eventbus.EBUserFollow
import com.gh.gamecenter.common.base.fragment.ToolbarFragment
import com.gh.gamecenter.newsdetail.NewsDetailActivity
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode

View File

@ -5,7 +5,8 @@ import android.content.Intent
import android.os.Bundle
import android.text.TextUtils
import android.view.View
import com.gh.common.util.*
import com.gh.common.util.NewFlatLogUtils
import com.gh.common.util.NewLogUtils
import com.gh.gamecenter.DisplayType
import com.gh.gamecenter.R
import com.gh.gamecenter.SearchActivity
@ -13,6 +14,7 @@ import com.gh.gamecenter.SearchType
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.utils.showKeyBoard
import com.gh.gamecenter.common.utils.toColor
import com.gh.gamecenter.forum.detail.ForumDetailFragment
import com.gh.gamecenter.search.SearchDefaultFragment
import com.lightgame.utils.Util_System_Keyboard
@ -26,7 +28,7 @@ class ForumOrUserSearchActivity : SearchActivity() {
super.onCreate(savedInstanceState)
mBbsId = intent.getStringExtra(EntranceConsts.KEY_BBS_ID) ?: ""
mLocation = intent.getStringExtra(EntranceConsts.KEY_LOCATION) ?: ""
searchEt.hint = if (mEntrance == "论坛首页") {
searchEt.hint = if (mEntrance != ForumDetailFragment.ENTRANCE) {
"搜索论坛内容、用户"
} else {
"搜索此论坛中的内容"
@ -35,7 +37,7 @@ class ForumOrUserSearchActivity : SearchActivity() {
searchBtn.setTextColor(R.color.text_theme.toColor(this))
searchBtn.setOnClickListener {
val key = searchEt.text.toString().trim { it <= ' ' }
NewLogUtils.logForumSearchClick(key, if (mEntrance == "论坛首页") "社区搜索" else "论坛详情页搜索")
NewLogUtils.logForumSearchClick(key, if (mEntrance != ForumDetailFragment.ENTRANCE) "社区搜索" else "论坛详情页搜索")
Util_System_Keyboard.hideSoftKeyboard(this)
search(SearchType.MANUAL, null)
}
@ -45,7 +47,7 @@ class ForumOrUserSearchActivity : SearchActivity() {
super.initSearchBar()
backBtn.setOnClickListener {
val key = searchEt.text.toString().trim { it <= ' ' }
if (mEntrance == "论坛首页") {
if (mEntrance != ForumDetailFragment.ENTRANCE) {
NewFlatLogUtils.logClickSearchReturn(key)
} else {
NewFlatLogUtils.logClickBbsSearchReturn(key, mBbsId)
@ -106,7 +108,7 @@ class ForumOrUserSearchActivity : SearchActivity() {
val key = searchEt.text.toString().trim { it <= ' ' }
if (key.isNotEmpty()) {
val stayTime = (System.currentTimeMillis() - startPageTime) / 1000
if (mEntrance == "论坛首页") {
if (mEntrance != ForumDetailFragment.ENTRANCE) {
NewFlatLogUtils.logViewSearchList(stayTime, key)
} else {
NewFlatLogUtils.logViewBbsSearchList(stayTime, key, mBbsId)
@ -115,7 +117,7 @@ class ForumOrUserSearchActivity : SearchActivity() {
}
else -> {
if (mEntrance == "论坛首页") {
if (mEntrance != ForumDetailFragment.ENTRANCE) {
val fragment =
supportFragmentManager.findFragmentByTag(ForumOrUserSearchFragment::class.java.name) as? ForumOrUserSearchFragment
?: ForumOrUserSearchFragment()
@ -149,13 +151,25 @@ class ForumOrUserSearchActivity : SearchActivity() {
bbsId: String,
mEntrance: String,
sourceEntrance: String,
location: String
location: String,
bottomTab: String = "",
multiTabId: String = "",
multiTabName: String = "",
customPageId: String = "",
customPageName: String = "",
searchBoxPattern: String = ""
): Intent {
val intent = Intent(context, ForumOrUserSearchActivity::class.java)
intent.putExtra(EntranceConsts.KEY_BBS_ID, bbsId)
intent.putExtra(EntranceConsts.KEY_ENTRANCE, mEntrance)
intent.putExtra(EntranceConsts.KEY_SOURCE_ENTRANCE, sourceEntrance)
intent.putExtra(EntranceConsts.KEY_LOCATION, location)
intent.putExtra(EntranceConsts.KEY_BOTTOM_TAB_NAME, bottomTab)
intent.putExtra(EntranceConsts.KEY_MULTI_TAB_NAV_ID, multiTabId)
intent.putExtra(EntranceConsts.KEY_MULTI_TAB_NAV_NAME, multiTabName)
intent.putExtra(EntranceConsts.KEY_CUSTOM_PAGE_ID, customPageId)
intent.putExtra(EntranceConsts.KEY_CUSTOM_PAGE_NAME, customPageName)
intent.putExtra(EntranceConsts.KEY_SEARCH_BOX_PATTERN, searchBoxPattern)
return intent
}
}

View File

@ -28,7 +28,7 @@ import com.gh.gamecenter.core.utils.MD5Utils
import com.gh.gamecenter.core.utils.SPUtils
import com.gh.gamecenter.core.utils.TimeElapsedHelper
import com.gh.gamecenter.databinding.FragmentMainHomeWrapperBinding
import com.gh.gamecenter.entity.HomePush
import com.gh.gamecenter.entity.PullDownPush
import com.gh.gamecenter.entity.SubjectRecommendEntity
import com.gh.gamecenter.eventbus.EBDownloadStatus
import com.gh.gamecenter.eventbus.EBPackage
@ -38,6 +38,8 @@ import com.gh.gamecenter.feature.game.GameItemViewHolder
import com.gh.gamecenter.gamecollection.square.GameCollectionSquareFragment
import com.gh.gamecenter.home.HomeFragment
import com.gh.gamecenter.home.video.ScrollCalculatorHelper
import com.gh.gamecenter.wrapper.MainWrapperFragment
import com.gh.gamecenter.wrapper.MainWrapperViewModel
import com.google.android.material.appbar.AppBarLayout
import com.halo.assistant.HaloApp
import com.lightgame.download.DataWatcher
@ -75,7 +77,7 @@ class HomeSearchToolWrapperFragment : HomeTabWrapperFragment() {
private var mTwoLevelOpenOffset = 0
private var mTwoLevelOpenCount = 0
private var mShowTwoLevelStartOffset = 0
private var mHomePush: HomePush? = null
private var mHomePush: PullDownPush? = null
private var mExposureEvent: ExposureEvent? = null
private var mGameViewHolder: GameViewHolder? = null
@ -155,25 +157,6 @@ class HomeSearchToolWrapperFragment : HomeTabWrapperFragment() {
setHomePush()
}
}
mMainWrapperViewModel?.accelerateNotificationPopup?.observeNonNull(viewLifecycleOwner) {
if (parentFragment is MainWrapperFragment && isSupportVisible) {
val isHandlerQueueEmpty = (parentFragment as MainWrapperFragment).isPriorityChainHandlerQueueEmpty()
val accelerateSet =
HashSet(SPUtils.getStringSet(Constants.SP_ACCELERATE_NOTIFICATION_POP_UP_SET))
if (isHandlerQueueEmpty && it.isNotEmpty() && !accelerateSet.contains(it[0].messageId)) {
AccelerateNotificationHandler.showAccelerateNotificationPopupWindow(
requireActivity(),
mMainWrapperViewModel,
mBaseHandler as BaseHandler,
it[0],
null
)
accelerateSet.add(it[0].messageId)
SPUtils.setStringSet(Constants.SP_ACCELERATE_NOTIFICATION_POP_UP_SET, accelerateSet)
}
}
}
}
private fun initSmartRefresh() {
@ -995,7 +978,7 @@ class HomeSearchToolWrapperFragment : HomeTabWrapperFragment() {
}
}
}
if (reuse.type == Constants.FINISH_HOME_PUSH) {
if (reuse.type == Constants.FINISH_PULL_DOWN_PUSH) {
if (!mHomePushClick) {
mBaseHandler.postDelayed({
finishTwoLevel("跳转收起")

View File

@ -5,7 +5,6 @@ import android.app.Application
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.MutableLiveData
import com.gh.common.filter.RegionSettingHelper
import com.gh.common.prioritychain.FloatingWindowHandler
import com.gh.gamecenter.BuildConfig
import com.gh.gamecenter.R
import com.gh.gamecenter.common.retrofit.BiResponse
@ -29,7 +28,6 @@ class HomeSearchToolWrapperViewModel(application: Application) : AndroidViewMode
private var mHomeTabPosition: Int = -1
private var mHomeTab: SubjectRecommendEntity? = null
private var mFloatingWindowHandler: FloatingWindowHandler? = null
var appBarOffset = 0
@ -116,12 +114,4 @@ class HomeSearchToolWrapperViewModel(application: Application) : AndroidViewMode
})
}
fun setFloatingWindowHandler(handler: FloatingWindowHandler) {
mFloatingWindowHandler = handler
}
fun getFloatingWindowHandler(): FloatingWindowHandler? {
return mFloatingWindowHandler
}
}

View File

@ -14,6 +14,7 @@ import androidx.appcompat.widget.Toolbar
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.fragment.app.Fragment
import com.facebook.drawee.view.SimpleDraweeView
import com.gh.common.util.ViewPagerFragmentHelper
import com.gh.download.DownloadManager
import com.gh.gamecenter.DownloadManagerActivity
import com.gh.gamecenter.R
@ -79,7 +80,7 @@ class HomeToolbarWrapperFragment: LazyFragment(), ToolbarController {
try {
if (arguments != null) {
val className = requireArguments().getString(MainWrapperFragment.WRAPPER_FRAGMENT_NAME)
val className = requireArguments().getString(ViewPagerFragmentHelper.WRAPPER_FRAGMENT_NAME)
mContentFragment = childFragmentManager.findFragmentById(R.id.wrapper_main_content) ?: Class.forName(className).newInstance() as Fragment
mContentFragment!!.arguments = requireArguments().clone() as Bundle
}
@ -164,7 +165,7 @@ class HomeToolbarWrapperFragment: LazyFragment(), ToolbarController {
}
// 设置标题居中
private fun setTitleCenter() {
override fun setTitleCenter() {
if (mActionMenuView != null && mTitleContainer != null && mBackContainer != null) {
mActionMenuView!!.post {
val params =

View File

@ -1,868 +0,0 @@
package com.gh.gamecenter.fragment
import android.graphics.PorterDuff
import android.graphics.drawable.Animatable
import android.net.Uri
import android.os.Bundle
import android.text.TextUtils
import android.view.View
import android.widget.CheckedTextView
import android.widget.ImageView
import androidx.annotation.ColorRes
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
import androidx.viewpager.widget.PagerAdapter
import com.airbnb.lottie.LottieAnimationView
import com.facebook.drawee.backends.pipeline.Fresco
import com.facebook.drawee.controller.BaseControllerListener
import com.facebook.drawee.interfaces.DraweeController
import com.facebook.drawee.view.SimpleDraweeView
import com.facebook.fresco.animation.drawable.AnimatedDrawable2
import com.facebook.fresco.animation.drawable.BaseAnimationListener
import com.facebook.imagepipeline.image.ImageInfo
import com.gh.common.constant.Config
import com.gh.common.prioritychain.*
import com.gh.common.util.*
import com.gh.common.util.LogUtils
import com.gh.common.util.NewLogUtils
import com.gh.gamecenter.MainActivity
import com.gh.gamecenter.R
import com.gh.gamecenter.ShellActivity
import com.gh.gamecenter.adapter.MainFragmentPagerAdapter
import com.gh.gamecenter.amway.AmwayFragment
import com.gh.gamecenter.catalog.CatalogFragment
import com.gh.gamecenter.category.CategoryDirectoryFragment
import com.gh.gamecenter.category2.CategoryV2Fragment
import com.gh.gamecenter.common.base.fragment.BaseFragment_ViewPager_Checkable
import com.gh.gamecenter.common.base.fragment.ToolbarFragment
import com.gh.gamecenter.common.callback.OnDoubleTapListener
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.eventbus.EBReuse
import com.gh.gamecenter.common.exposure.ExposureSource
import com.gh.gamecenter.common.syncpage.SyncPageRepository
import com.gh.gamecenter.common.tracker.TrackerLogger
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.core.utils.SPUtils
import com.gh.gamecenter.core.utils.SentryHelper
import com.gh.gamecenter.databinding.FragmentMainBinding
import com.gh.gamecenter.discovery.DiscoveryFragment
import com.gh.gamecenter.entity.HomeDataEntity
import com.gh.gamecenter.entity.SubjectData
import com.gh.gamecenter.entity.SubjectRecommendEntity
import com.gh.gamecenter.eventbus.EBSkip
import com.gh.gamecenter.eventbus.EBUISwitch
import com.gh.gamecenter.forum.detail.ForumDetailFragment
import com.gh.gamecenter.forum.home.CommunityHomeFragment
import com.gh.gamecenter.game.GameFragment
import com.gh.gamecenter.game.columncollection.detail.ColumnCollectionDetailFragment
import com.gh.gamecenter.game.commoncollection.detail.CommonCollectionDetailFragment
import com.gh.gamecenter.gamecollection.square.GameCollectionSquareFragment
import com.gh.gamecenter.login.entity.UserInfoEntity
import com.gh.gamecenter.message.MessageUnreadRepository
import com.gh.gamecenter.message.MessageUnreadViewModel
import com.gh.gamecenter.personal.HaloPersonalFragment
import com.gh.gamecenter.pkg.PkgHelper
import com.gh.gamecenter.servers.GameServersPublishFragment
import com.gh.gamecenter.servers.GameServersTestFragment
import com.gh.gamecenter.subject.SubjectFragment
import com.gh.gamecenter.video.detail.HomeVideoFragment
import com.halo.assistant.HaloApp
import com.halo.assistant.fragment.WebFragment
import com.lightgame.listeners.OnBackPressedListener
import com.lightgame.view.CheckableLinearLayout
import com.lightgame.view.NoScrollableViewPager
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
import org.json.JSONObject
class MainWrapperFragment : BaseFragment_ViewPager_Checkable(), OnBackPressedListener {
private val mBinding by lazy { FragmentMainBinding.inflate(layoutInflater) }
private var mViewModel: MainWrapperViewModel? = null
private var mGameWrapperFragment: SearchToolWrapperFragment? = null
private var mHomeFragment: HomeSearchToolWrapperFragment? = null
private var mFourthFragment: ToolbarFragment? = null
private var mCommunityHomeFragment: CommunityHomeFragment? = null
private val mResAssets = arrayOf(
"lottie/tab_home.json",
"lottie/tab_game.json",
"lottie/tab_forum.json",
"lottie/tab_video.json",
"tab_mine.gif"
)
private var mPopUpHomePush = false
private val mPriorityChain by lazy { PriorityChain() }
private var mVideoNavBarEntity: SubjectRecommendEntity? = null
override fun getLayoutId(): Int = 0
override fun getInflatedLayout() = mBinding.root
override fun getCheckableGroupId(): Int = R.id.lightgame_tab_container
override fun getViewPagerId(): Int = R.id.lightgame_tab_viewpager
override fun getCurrentItem() = mViewPager.currentItem
override fun getChildCount(): Int = 5
override fun provideAdapter(): PagerAdapter = MainFragmentPagerAdapter(requireContext(), childFragmentManager, mFragmentsList as ArrayList<Fragment>)
override fun initFragmentList(fragments: MutableList<Fragment>) {
mHomeFragment = HomeSearchToolWrapperFragment()
fragments.add(mHomeFragment!!)
initGameWrapperFragment()
fragments.add(mGameWrapperFragment!!)
mCommunityHomeFragment = CommunityHomeFragment()
mCommunityHomeFragment!!.arguments = arguments
fragments.add(mCommunityHomeFragment!!)
initFourthFragment(fragments)
if (mViewModel!!.shouldHideVideoTab()) {
mBinding.mainTabVideo.visibility = View.GONE
}
fragments.add(HaloPersonalFragment())
}
private fun initGameWrapperFragment() {
mGameWrapperFragment = SearchToolWrapperFragment()
val homeArgs = Bundle()
var entity = mViewModel!!.gameNavBar.value
if (entity == null) {
entity = HomeBottomBarHelper.getDefaultGameBarData()
}
putFragmentBundle(entity, homeArgs, true)
if ("block" != entity.type) {
homeArgs.putParcelable(
EntranceConsts.KEY_EXPOSURE_SOURCE,
ExposureSource("游戏库", "")
)
}
mGameWrapperFragment!!.arguments = homeArgs
}
private fun initFourthFragment(fragments: MutableList<Fragment>) {
var entity = mViewModel!!.videoNavBar.value
if (entity == null) {
entity = HomeBottomBarHelper.getDefaultVideoData()
}
val fourthFragment: Fragment? = when (entity.type) {
"video_stream" -> {
if (mFourthFragment !is HomeVideoFragment) {
val videoArgs = Bundle()
videoArgs.putBoolean(EntranceConsts.KEY_IS_HOME_VIDEO, true)
mFourthFragment = HomeVideoFragment()
mFourthFragment!!.arguments = videoArgs
mFourthFragment
} else {
null
}
}
"top_game_comment" -> {
if (mFourthFragment !is AmwayFragment) {
val amwayArgs = Bundle()
amwayArgs.putBoolean(EntranceConsts.KEY_IS_FROM_MAIN_WRAPPER, true)
mFourthFragment = AmwayFragment()
mFourthFragment!!.arguments = amwayArgs
mFourthFragment
} else {
null
}
}
"community" -> {
if (mFourthFragment !is ForumDetailFragment) {
val forumArgs = Bundle()
forumArgs.putString(EntranceConsts.KEY_BBS_ID, entity.link)
forumArgs.putBoolean(EntranceConsts.KEY_IS_FROM_MAIN_WRAPPER, true)
mFourthFragment = ForumDetailFragment()
mFourthFragment!!.arguments = forumArgs
mFourthFragment
} else {
null
}
}
else -> {
// 新页面与旧页面类型不同或链接不同时才进行替换
if (mFourthFragment !is HomeToolbarWrapperFragment || mVideoNavBarEntity?.type != entity.type || mVideoNavBarEntity?.link != entity.link) {
val homeArgs = Bundle()
putFragmentBundle(entity, homeArgs, false)
mFourthFragment = HomeToolbarWrapperFragment()
mFourthFragment!!.arguments = homeArgs
mFourthFragment
} else {
null
}
}
}
if (fourthFragment != null) {
if (mFragmentsList.size > 3) {
// 替换第4个Fragment
try {
(mAdapter as MainFragmentPagerAdapter).replaceFragment(3, fourthFragment)
} catch (e: Exception) {
SentryHelper.onEvent(
"REPLACE_FRAGMENT_CRASH",
"new_fragment_type",
entity.type,
"old_fragment_type",
mVideoNavBarEntity?.type,
"new_link",
entity.link,
"old_link",
mVideoNavBarEntity?.link
)
}
} else {
fragments.add(fourthFragment)
}
mVideoNavBarEntity = entity
}
}
private fun putFragmentBundle(entity: SubjectRecommendEntity, homeArgs: Bundle, isGameTab: Boolean) {
var className = HomeGameWrapperFragment::class.java.name
val entrance = if (isGameTab) "游戏库" else entity.linkTypeChinese
when (entity.type) {
"block" -> {
className = if (isGameTab) HomeGameWrapperFragment::class.java.name else GameFragment::class.java.name
if (isGameTab) {
homeArgs.putBoolean(EntranceConsts.KEY_SHOW_SEARCH_TOOLBAR, false)
} else {
homeArgs.putBoolean(EntranceConsts.KEY_SHOW_DOWNLOAD_MENU, true)
homeArgs.putBoolean(EntranceConsts.KEY_IS_FROM_HOME_TOOLBAR_WRAPPER, true)
}
homeArgs.putParcelable(EntranceConsts.KEY_BLOCK_DATA, entity)
}
"column" -> {
className = SubjectFragment::class.java.name
homeArgs.putString(EntranceConsts.KEY_ENTRANCE, entrance)
homeArgs.putParcelable(
EntranceConsts.KEY_SUBJECT_DATA,
SubjectData(entity.link, entity.text, false, "", "", "", "", true, false, false)
)
if (!isGameTab) {
homeArgs.putBoolean(EntranceConsts.KEY_SHOW_DOWNLOAD_MENU, true)
}
}
"column_collection" -> {
className = ColumnCollectionDetailFragment::class.java.name
homeArgs.putString(EntranceConsts.KEY_ENTRANCE, entrance)
homeArgs.putString(EntranceConsts.KEY_COLLECTION_ID, entity.link)
homeArgs.putInt(EntranceConsts.KEY_POSITION, 0)
homeArgs.putString(EntranceConsts.KEY_COLUMNNAME, entity.text)
homeArgs.putBoolean(EntranceConsts.KEY_IS_COLUMN_COLLECTION, true)
}
"server" -> {
className = GameServersPublishFragment::class.java.name
homeArgs.putString(EntranceConsts.KEY_ENTRANCE, entrance)
if (!isGameTab) {
homeArgs.putBoolean(EntranceConsts.KEY_SHOW_DOWNLOAD_MENU, true)
}
}
"column_test" -> {
className = GameServersTestFragment::class.java.name
homeArgs.putString(GameServersTestFragment.TEST_COLUMN_ID, entity.link)
if (!isGameTab) {
homeArgs.putBoolean(EntranceConsts.KEY_SHOW_DOWNLOAD_MENU, true)
}
}
"catalog" -> {
className = CatalogFragment::class.java.name
homeArgs.putString(EntranceConsts.KEY_CATALOG_ID, entity.link)
homeArgs.putString(EntranceConsts.KEY_CATALOG_TITLE, entity.text)
}
"category" -> {
className = CategoryDirectoryFragment::class.java.name
homeArgs.putString(EntranceConsts.KEY_CATEGORY_ID, entity.link)
homeArgs.putString(EntranceConsts.KEY_CATEGORY_TITLE, entity.text)
}
"category_v2" -> {
className = CategoryV2Fragment::class.java.name
homeArgs.putString(EntranceConsts.KEY_CATEGORY_ID, entity.link)
homeArgs.putString(EntranceConsts.KEY_CATEGORY_TITLE, entity.text)
if (!isGameTab) {
homeArgs.putBoolean(EntranceConsts.KEY_SHOW_DOWNLOAD_MENU, true)
}
}
"common_collection" -> {
className = CommonCollectionDetailFragment::class.java.name
homeArgs.putString(EntranceConsts.KEY_ENTRANCE, entrance)
homeArgs.putString(EntranceConsts.KEY_COLLECTION_ID, entity.link)
homeArgs.putString(EntranceConsts.KEY_COLUMNNAME, entity.text)
}
"game_list" -> {
className = GameCollectionSquareFragment::class.java.name
homeArgs.putString(EntranceConsts.KEY_ENTRANCE, entrance)
homeArgs.putInt(EntranceConsts.KEY_TAB_INDEX, 0)
homeArgs.putString(EntranceConsts.KEY_NAME, entity.name)
homeArgs.putBoolean(EntranceConsts.KEY_IS_FROM_HOME_TOOLBAR_WRAPPER, true)
}
"web" -> {
className = WebFragment::class.java.name
homeArgs.putString(EntranceConsts.KEY_URL, entity.link)
homeArgs.putBoolean(WebFragment.KEY_OPEN_NATIVE_PAGE, false)
homeArgs.putBoolean(WebFragment.KEY_ENABLE_HORIZONTAL_SCROLL_DISPATCH, true)
if (entity.link != null && entity.link!!.contains("leave_web_page_handle_back_pressed=true")) {
homeArgs.putBoolean(WebFragment.KEY_LEAVE_WEB_PAGE_TO_HANDLE_BACK_PRESSED, true)
}
}
"explore_column" -> {
className = DiscoveryFragment::class.java.name
homeArgs.putString(EntranceConsts.KEY_ENTRANCE, entrance)
}
}
homeArgs.putString(EntranceConsts.KEY_LOCATION, entrance)
homeArgs.putString(WRAPPER_FRAGMENT_NAME, className)
homeArgs.putBoolean(EntranceConsts.KEY_IS_HOME, true)
}
override fun restoreFragments(): ArrayList<Fragment> = ArrayList()
override fun onCreate(savedInstanceState: Bundle?) {
mViewModel = viewModelProviderFromParent(MainWrapperViewModel.Factory(HaloApp.getInstance()))
super.onCreate(savedInstanceState)
buildPriorityChain()
mViewModel?.gameNavBar?.observe(this) { updateGameBarContent(it) }
mViewModel?.videoNavBar?.observe(this) { updateVideoBarContent(it) }
mBinding.viewShadow.visibility = if (mIsDarkModeOn) View.GONE else View.VISIBLE
ViewModelProvider(this)[MessageUnreadViewModel::class.java]
.unreadMessageTotalLiveData.observe(this) { isShow: Boolean? ->
mBinding.mainIvMessageHint.goneIf(!isShow!!)
}
}
/**
* 构建 PriorityChain使用优先队列来决定当前需要显示哪一个弹窗
* 正常弹窗顺序(不含首页自动下拉二楼),更新弹窗、隐私政策弹窗、消息通知权限弹窗、预约弹窗、插件化通知 popup、启动弹窗、右下悬浮窗
* 特殊弹窗顺序(含首页自动下拉二楼,无需请求显示启动弹窗),更新弹窗、隐私政策弹窗、消息通知权限弹窗、预约弹窗、插件化通知 popup、首页自动下拉二楼、右下悬浮窗
* 可以根据上述的顺序为弹窗预设优先级
* 更新弹窗 (-100)
* 隐私政策弹窗 (-99)
* 消息通知权限弹窗 (0)
* 预约弹窗 (1)
* 插件化通知 popup (2)
* 首页自动下拉二楼 (3)
* 启动弹窗 (4)
* 首页右下悬浮窗 (5)
*/
private fun buildPriorityChain() {
val homeSearchToolWrapperViewModel: HomeSearchToolWrapperViewModel = viewModelProviderFromParent()
val updateDialogHandler = UpdateDialogHandler(requireContext(), -100)
val privacyPolicyDialogHandler = PrivacyPolicyDialogHandler(-99)
val notificationPermissionDialogHandler = NotificationPermissionDialogHandler(0)
val reserveDialogHandler = ReserveDialogHandler(1)
val accelerateNotificationHandler = AccelerateNotificationHandler(2)
val homePushHandler = HomePushHandler(3)
val welcomeDialogHandler = WelcomeDialogHandler(4)
val floatingWindowHandler = FloatingWindowHandler(5)
homeSearchToolWrapperViewModel.setFloatingWindowHandler(floatingWindowHandler)
mPriorityChain.addHandler(updateDialogHandler)
mPriorityChain.addHandler(privacyPolicyDialogHandler)
mPriorityChain.addHandler(welcomeDialogHandler)
mPriorityChain.addHandler(reserveDialogHandler)
mPriorityChain.addHandler(notificationPermissionDialogHandler)
mPriorityChain.addHandler(accelerateNotificationHandler)
mPriorityChain.addHandler(homePushHandler)
mPriorityChain.addHandler(floatingWindowHandler)
mViewModel?.privacyPolicyDialog?.observe(this) {
privacyPolicyDialogHandler.doPreProcess(requireActivity(), it)
}
mViewModel?.reserveDialog?.observe(this) {
reserveDialogHandler.doPreProcess(this, it)
MessageUnreadRepository.loadMessageUnreadData()
}
mViewModel?.accelerateNotificationPopup?.observe(this) {
accelerateNotificationHandler.doPreProcess(
requireActivity(),
mBaseHandler!! as BaseHandler,
it,
mViewModel!!
)
}
mViewModel?.floatingWindow?.observe(this) { windowEntityList ->
floatingWindowHandler.setData(windowEntityList ?: arrayListOf())
}
homeSearchToolWrapperViewModel.homeDataLiveData.observe(this) { homeDataEntity: HomeDataEntity? ->
val homePushSet =
SPUtils.getStringSet(Constants.SP_HOME_PUSH_POP_UP_SET)
mPopUpHomePush = homeDataEntity?.homePush != null
&& "on" == homeDataEntity.homePush?.popSwitch
&& !homePushSet.contains(homeDataEntity.homePush?.id)
if (mPopUpHomePush) {
welcomeDialogHandler.doPreProcess(this, null)
} else {
welcomeDialogHandler.doPreProcess(this, mViewModel!!.welcomeDialog.value)
}
homePushHandler.doPreProcess(mHomeFragment!!, mPopUpHomePush)
}
}
fun showDialog() {
mPriorityChain.start()
}
fun isPriorityChainHandlerQueueEmpty() = mPriorityChain.isHandlerQueueEmpty()
private fun applyPkgConfig() {
val pkgLinkEntity = PkgHelper.getPkgConfig()
if (pkgLinkEntity != null) {
val bottomTab = pkgLinkEntity.homeBottomTab
if (!pkgLinkEntity.shouldStayAtMainActivity) {
// 不停留在首页,执行跳转,标记已用
PkgHelper.markConfigUsed()
DirectUtils.directToLinkPage(requireContext(), pkgLinkEntity, "推广包配置", "首页")
} else if ("home" != bottomTab) {
// 停留首页,但选中底部 tab 不是首页的,执行选中,标记已用
PkgHelper.markConfigUsed()
// TODO 根据具体 tab 来作为跳转的具体位置,避免硬编码
var targetIndex = INDEX_HOME
when (bottomTab) {
"game_lib" -> targetIndex = INDEX_GAME
"community" -> targetIndex = INDEX_BBS
"video" -> targetIndex = INDEX_VIDEO
"gh" -> targetIndex = INDEX_PERSONAL
}
mViewPager.currentItem = targetIndex
onPageChanged(targetIndex)
changeColor(targetIndex)
}
}
}
private fun updateGameBarContent(navBarEntity: SubjectRecommendEntity?) {
if (navBarEntity != null) {
mBinding.mainTabGame.visibility = View.VISIBLE
mBinding.mainTabGameName.text = navBarEntity.name
ImageUtils.picasso
.load(Uri.parse(navBarEntity.iconUnselect)) //.placeholder(R.drawable.ic_game_unselect)
.into(mBinding.mainTabGameIcon)
if (navBarEntity.default) currentItem = INDEX_GAME
} else {
mBinding.mainTabGame.visibility = View.GONE
}
}
private fun updateVideoBarContent(navBarEntity: SubjectRecommendEntity?) {
mBinding.mainTabVideo.visibility = View.VISIBLE
if (navBarEntity != null) {
mBinding.mainTabVideoName.text = navBarEntity.name
ImageUtils.picasso
.load(Uri.parse(navBarEntity.iconUnselect))
.placeholder(R.drawable.ic_video_unselect)
.into(mBinding.mainTabVideoIcon)
if (navBarEntity.default) currentItem = INDEX_VIDEO
initFourthFragment(mFragmentsList)
} else {
mBinding.mainTabVideo.visibility = View.GONE
}
}
override fun onPause() {
super.onPause()
SyncPageRepository.clearSyncData()
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
if (mViewPager is NoScrollableViewPager) {
(mViewPager as NoScrollableViewPager).setScrollable(false)
}
// 启动时即当选中第一个 tab
onPageChanged(INDEX_HOME)
changeColor(INDEX_HOME)
for (i in 0 until mCheckableGroup.childCount) {
val child = mCheckableGroup.getChildAt(i)
child.setOnTouchListener(object : OnDoubleTapListener(context) {
override fun onDoubleTap() {
EventBus.getDefault().post(EBUISwitch(EB_MAIN_SCROLL_TOP, i))
}
})
}
applyPkgConfig()
}
override fun handleOnClick(view: View): Boolean {
val toCheck = mCheckableGroup.indexOfChild(view)
playTabAnimation(toCheck)
changeColor(toCheck)
mHomeFragment?.finishTwoLevel("跳转收起")
val trackEvent = JSONObject()
tryWithDefaultCatch {
trackEvent.put("position", toCheck)
trackEvent.put("tab_content", getTabName(toCheck))
}
SensorsBridge.trackEvent("HomeBottomTabSelect", trackEvent)
return super.handleOnClick(view)
}
private fun getTabName(index: Int): String {
return when (index) {
0 -> "首页"
1 -> mBinding.mainTabGameName.text.toString()
2 -> "社区"
3 -> "视频"
4 -> "我的光环"
else -> ""
}
}
private fun changeColor(toCheck: Int) {
if (mFourthFragment is HomeVideoFragment && toCheck == INDEX_VIDEO) {
mBinding.viewShadow.visibility = View.GONE
mCheckableGroup.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.transparent))
changeTabImageColor(R.color.text_A1A5B7, PorterDuff.Mode.SRC_ATOP, toCheck)
} else {
mBinding.viewShadow.visibility = if (mIsDarkModeOn) View.GONE else View.VISIBLE
mCheckableGroup.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.ui_surface))
changeTabImageColor(
if (mIsDarkModeOn) R.color.text_A1A5B7 else R.color.text_50556B,
if (mIsDarkModeOn) PorterDuff.Mode.SRC_ATOP else PorterDuff.Mode.DST,
toCheck
)
}
changeTabTextColor(toCheck)
}
private fun playTabAnimation(toCheck: Int) {
when (toCheck) {
INDEX_HOME -> {
stopAnimation(mBinding.lottieGame, INDEX_GAME)
stopAnimation(mBinding.lottieVideo, INDEX_VIDEO)
stopAnimation(mBinding.lottieCommunity, INDEX_BBS)
stopAnimation(mBinding.lottieMine, INDEX_PERSONAL)
playAnimation(mBinding.lottieHome, toCheck)
}
INDEX_GAME -> {
val value = mViewModel!!.gameNavBar.value
if (value != null && !TextUtils.isEmpty(value.animationCode)) {
stopAnimation(mBinding.lottieHome, INDEX_HOME)
stopAnimation(mBinding.lottieVideo, INDEX_VIDEO)
stopAnimation(mBinding.lottieCommunity, INDEX_BBS)
stopAnimation(mBinding.lottieMine, INDEX_PERSONAL)
playGameAnimation(value, toCheck)
}
}
INDEX_BBS -> {
stopAnimation(mBinding.lottieHome, INDEX_HOME)
stopAnimation(mBinding.lottieGame, INDEX_GAME)
stopAnimation(mBinding.lottieVideo, INDEX_VIDEO)
stopAnimation(mBinding.lottieMine, INDEX_PERSONAL)
playAnimation(mBinding.lottieCommunity, toCheck)
}
INDEX_VIDEO -> {
val value = mViewModel!!.videoNavBar.value
if (value != null && !TextUtils.isEmpty(value.animationCode)) {
stopAnimation(mBinding.lottieHome, INDEX_HOME)
stopAnimation(mBinding.lottieGame, INDEX_GAME)
stopAnimation(mBinding.lottieCommunity, INDEX_BBS)
stopAnimation(mBinding.lottieMine, INDEX_PERSONAL)
playVideoAnimation(value, toCheck)
}
}
INDEX_PERSONAL -> {
stopAnimation(mBinding.lottieHome, INDEX_HOME)
stopAnimation(mBinding.lottieGame, INDEX_GAME)
stopAnimation(mBinding.lottieVideo, INDEX_VIDEO)
stopAnimation(mBinding.lottieCommunity, INDEX_BBS)
playAnimation(mBinding.lottieMine, toCheck)
}
else -> {}
}
}
private fun changeTabImageColor(@ColorRes colorRes: Int, mode: PorterDuff.Mode, toCheck: Int) {
for (i in 0 until mCheckableGroup.childCount) {
val checkableGroupChild = mCheckableGroup.getChildAt(i) as CheckableLinearLayout
val checkableView = checkableGroupChild.findCheckableImageView(checkableGroupChild) as? ImageView
if (checkableView != null) {
if (i != toCheck) {
checkableView.setColorFilter(ContextCompat.getColor(requireContext(), colorRes), mode)
} else {
checkableView.colorFilter = null
}
}
}
}
private fun changeTabTextColor(toCheck: Int) {
for (i in 0 until mCheckableGroup.childCount) {
val checkableGroupChild = mCheckableGroup.getChildAt(i) as? CheckableLinearLayout
val checkableView = checkableGroupChild?.findCheckableTextView(checkableGroupChild) as? CheckedTextView
val isChecked = i == toCheck
if (checkableView != null) {
val unselectColor: Int = if (mFourthFragment is HomeVideoFragment && toCheck == INDEX_VIDEO) R.color.text_A1A5B7 else R.color.tab_text_unselect
checkableView.setTextColor(
ContextCompat.getColor(requireContext(), if (isChecked) R.color.text_theme else unselectColor)
)
}
}
}
private fun playGameAnimation(entity: SubjectRecommendEntity, position: Int) {
val checkableGroupChild = mCheckableGroup.getChildAt(position) as? CheckableLinearLayout
val checkableView = checkableGroupChild?.findCheckableImageView(checkableGroupChild)
if (checkableView != null) checkableView.visibility = View.INVISIBLE
mBinding.lottieGame.visibility = View.VISIBLE
mBinding.lottieGame.setAnimationFromJson(entity.animationCode, entity.iconSelect)
mBinding.lottieGame.playAnimation()
mBinding.lottieGame.doOnAnimationEnd {
mBinding.lottieGame.visibility = View.GONE
if (checkableView != null) checkableView.visibility = View.VISIBLE
}
}
private fun playVideoAnimation(entity: SubjectRecommendEntity, position: Int) {
val checkableGroupChild = mCheckableGroup.getChildAt(position) as? CheckableLinearLayout
val checkableView = checkableGroupChild?.findCheckableImageView(checkableGroupChild)
if (checkableView != null) checkableView.visibility = View.INVISIBLE
mBinding.lottieVideo.visibility = View.VISIBLE
mBinding.lottieVideo.setAnimationFromJson(entity.animationCode, entity.iconSelect)
mBinding.lottieVideo.playAnimation()
mBinding.lottieVideo.doOnAnimationEnd {
mBinding.lottieVideo.visibility = View.GONE
if (checkableView != null) checkableView.visibility = View.VISIBLE
}
}
private fun playAnimation(view: View, position: Int) {
val checkableGroupChild = mCheckableGroup.getChildAt(position) as CheckableLinearLayout
val checkableView = checkableGroupChild.findCheckableImageView(checkableGroupChild)
if (checkableView != null) checkableView.visibility = View.INVISIBLE
view.visibility = View.VISIBLE
if (view is LottieAnimationView) {
view.setAnimation(mResAssets[position])
view.playAnimation()
view.doOnAnimationEnd {
view.visibility = View.GONE
checkableView?.visibility = View.VISIBLE
}
} else {
val lottieView = view as SimpleDraweeView
val uri = Uri.parse("asset:///" + mResAssets[position])
val controller: DraweeController = Fresco.newDraweeControllerBuilder()
.setUri(uri)
.setAutoPlayAnimations(true)
.setControllerListener(object : BaseControllerListener<ImageInfo?>() {
override fun onFinalImageSet(id: String, imageInfo: ImageInfo?, animatable: Animatable?) {
super.onFinalImageSet(id, imageInfo, animatable)
if (animatable != null) {
val animatedDrawable = animatable as AnimatedDrawable2
animatedDrawable.setAnimationListener(object : BaseAnimationListener() {
override fun onAnimationStop(drawable: AnimatedDrawable2) {
super.onAnimationStop(drawable)
lottieView.visibility = View.GONE
checkableView?.visibility = View.VISIBLE
}
})
}
}
}).build()
lottieView.controller = controller
}
}
private fun stopAnimation(lottieView: View, position: Int) {
val checkableGroupChild = mCheckableGroup.getChildAt(position) as CheckableLinearLayout
val checkableView = checkableGroupChild.findCheckableImageView(checkableGroupChild)
checkableView?.visibility = View.VISIBLE
lottieView.visibility = View.GONE
}
override fun onPageChanged(index: Int) {
super.onPageChanged(index)
var tabText = ""
when (index) {
INDEX_HOME -> {
tabText = "首页"
NewLogUtils.logBottomNavigationClick("首页", "", "", "", index)
}
INDEX_GAME -> {
tabText = "游戏库"
var entity = mViewModel!!.gameNavBar.value
if (entity == null) {
entity = HomeBottomBarHelper.getDefaultGameBarData()
}
NewLogUtils.logBottomNavigationClick(
"游戏库",
(if (entity.type != null) entity.type else "")!!,
(if (entity.text != null) entity.text else "")!!, (if (entity.link != null) entity.link else "")!!,
index
)
}
INDEX_BBS -> {
tabText = "论坛"
LogUtils.uploadAccessBbsTab()
NewLogUtils.logBottomNavigationClick("社区", "", "", "", index)
}
INDEX_VIDEO -> {
tabText = "视频"
var entity = mViewModel!!.videoNavBar.value
if (entity == null) {
entity = HomeBottomBarHelper.getDefaultVideoData()
}
NewLogUtils.logCommunityHomeEvent("click_button_video_tab")
NewLogUtils.logBottomNavigationClick(entity.linkTypeChinese, entity.type ?: "", entity.text ?: "", entity.link ?: "", index)
}
INDEX_PERSONAL -> {
tabText = "我的光环"
IntegralLogHelper.log("view_me", "我的光环")
NewLogUtils.logBottomNavigationClick("我的光环", "", "", "", index)
}
}
TrackerLogger.logHomeTabSelected(index, tabText)
val gameNavBarEntity = mViewModel!!.gameNavBar.value
if (gameNavBarEntity != null) {
if (index == INDEX_GAME) {
ImageUtils.picasso
.load(Uri.parse(gameNavBarEntity.iconSelect)) //.placeholder(R.drawable.ic_game_select)
.into(mBinding.mainTabGameIcon)
} else {
ImageUtils.picasso
.load(Uri.parse(gameNavBarEntity.iconUnselect)) //.placeholder(R.drawable.ic_game_unselect)
.into(mBinding.mainTabGameIcon)
}
}
val videoNavBarEntity = mViewModel!!.videoNavBar.value
if (videoNavBarEntity != null) {
if (index == INDEX_VIDEO) {
ImageUtils.picasso
.load(Uri.parse(videoNavBarEntity.iconSelect))
.placeholder(R.drawable.ic_video_select)
.into(mBinding.mainTabVideoIcon)
} else {
ImageUtils.picasso
.load(Uri.parse(videoNavBarEntity.iconUnselect))
.placeholder(R.drawable.ic_video_unselect)
.into(mBinding.mainTabVideoIcon)
}
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
fun onEventMainThread(skip: EBSkip) {
if (MainActivity.EB_SKIP_MAIN == skip.type) {
checkIndex(skip.currentItem)
changeColor(skip.currentItem)
mViewPager.setCurrentItem(skip.currentItem, false)
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
fun onEventMainThread(reuse: EBReuse) {
if ("Refresh" == reuse.type) {
val settings = Config.getSettings()
if (settings != null && !settings.showCommunityEntrance()) {
mBinding.mainTabCommunity.visibility = View.GONE
} else {
mBinding.mainTabCommunity.visibility = View.VISIBLE
}
} else if (Constants.EB_REALNAME_RESULT == reuse.type) {
updateRealNameErrorContainer()
}
}
private fun updateRealNameErrorContainer() {
val deviceCertificationInfoString =
SPUtils.getString(Constants.SP_DEVICE_CERTIFICATION_PREFIX + HaloApp.getInstance().gid)
// 未点过关闭按钮并且处于实名认证失败状态的,显示提示 view
if (!SPUtils.getBoolean(Constants.SP_REALNAME_ERROR_HINT_IGNORED)
&& !TextUtils.isEmpty(deviceCertificationInfoString)
) {
val entity: UserInfoEntity? = deviceCertificationInfoString.toObject()
if (entity?.idCard != null && entity.idCard!!.status == 2) {
mBinding.realNameErrorContainer.visibility = View.VISIBLE
mBinding.realNameErrorCloseIv.enlargeTouchArea(100)
mBinding.realNameErrorCloseIv.setOnClickListener {
SPUtils.setBoolean(Constants.SP_REALNAME_ERROR_HINT_IGNORED, true)
mBinding.realNameErrorContainer.visibility = View.GONE
}
mBinding.realNameErrorContainer.setOnClickListener {
startActivity(ShellActivity.getIntent(requireActivity(), ShellActivity.Type.REAL_NAME_INFO, null))
}
} else {
mBinding.realNameErrorContainer.visibility = View.GONE
}
}
}
fun setCurrentItem(page: Int) {
mViewPager.setCurrentItem(page, false)
changeColor(page)
}
override fun onHandleBackPressed(): Boolean {
if (mFourthFragment is HomeVideoFragment && (mFourthFragment as HomeVideoFragment).getCurrentFragment() != null) {
return (mFourthFragment!! as HomeVideoFragment).getCurrentFragment()!!.onHandleBackPressed()
}
if (mViewPager.currentItem == INDEX_VIDEO) {
return mFourthFragment!!.onBackPressed()
}
if (mViewPager.currentItem == INDEX_HOME) {
return mHomeFragment!!.onBackPressed()
}
if (mViewPager.currentItem == INDEX_GAME) {
return mGameWrapperFragment!!.onBackPressed()
}
return if (mViewPager.currentItem == INDEX_BBS) {
mCommunityHomeFragment!!.onBackPressed()
} else false
}
override fun onDarkModeChanged() {
super.onDarkModeChanged()
changeColor(mViewPager.currentItem)
}
companion object {
const val INDEX_HOME = 0
const val INDEX_GAME = 1
const val INDEX_BBS = 2
const val INDEX_VIDEO = 3
const val INDEX_PERSONAL = 4
const val EB_MAIN_SCROLL_TOP = "main_scroll_top"
const val WRAPPER_FRAGMENT_NAME = "WrapperFragmentName"
}
}

View File

@ -1,73 +0,0 @@
package com.gh.gamecenter.fragment
import android.annotation.SuppressLint
import androidx.lifecycle.MutableLiveData
import com.gh.common.util.HomeBottomBarHelper
import com.gh.gamecenter.BuildConfig
import com.gh.gamecenter.common.retrofit.BiResponse
import com.gh.gamecenter.core.utils.SingletonHolder
import com.gh.gamecenter.entity.SubjectRecommendEntity
import com.gh.gamecenter.retrofit.RetrofitManager
import com.halo.assistant.HaloApp
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import retrofit2.HttpException
class MainWrapperRepository {
private val mSensitiveApi = RetrofitManager.getInstance().api
private val mGameNavBar = MutableLiveData<SubjectRecommendEntity?>()
private val mVideoNavBar = MutableLiveData<SubjectRecommendEntity?>()
fun getGameNavBarLiveData() = mGameNavBar
fun getVideoNavBarLiveData() = mVideoNavBar
@SuppressLint("CheckResult")
fun getHomeNavBar() {
mSensitiveApi.getHomeNavBarV2s(HaloApp.getInstance().channel, BuildConfig.VERSION_NAME)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : BiResponse<List<SubjectRecommendEntity>>() {
override fun onSuccess(data: List<SubjectRecommendEntity>) {
var isVideoConfigurated = false
data.forEach {
if (it.position == TAB_GAME_POSITION) {
HomeBottomBarHelper.updateDefaultGameBarData(it)
mGameNavBar.postValue(it)
} else if (it.position == TAB_VIDEO_POSITION) {
isVideoConfigurated = true
HomeBottomBarHelper.updateDefaultVideoBarData(it)
mVideoNavBar.postValue(it)
}
}
// 没有配置底部tab第4位时默认展示视频tab
if (!isVideoConfigurated) {
val defaultVideoEntity = HomeBottomBarHelper.getDefaultVideoEntity()
HomeBottomBarHelper.updateDefaultVideoBarData(defaultVideoEntity)
mVideoNavBar.postValue(defaultVideoEntity)
}
}
override fun onFailure(exception: Exception) {
if (exception is HttpException && exception.code() == 404) {
mGameNavBar.postValue(null)
HomeBottomBarHelper.updateDefaultGameBarData(SubjectRecommendEntity())
val defaultVideoEntity = HomeBottomBarHelper.getDefaultVideoEntity()
mVideoNavBar.postValue(defaultVideoEntity)
HomeBottomBarHelper.updateDefaultVideoBarData(defaultVideoEntity)
} else {
mGameNavBar.postValue(HomeBottomBarHelper.getDefaultGameBarData())
mVideoNavBar.postValue(HomeBottomBarHelper.getDefaultVideoData())
}
}
})
}
companion object : SingletonHolder<MainWrapperRepository>({ MainWrapperRepository() }) {
const val TAB_GAME_POSITION = 2
const val TAB_VIDEO_POSITION = 4
}
}

View File

@ -1,228 +0,0 @@
package com.gh.gamecenter.fragment
import android.annotation.SuppressLint
import android.app.Application
import android.preference.PreferenceManager
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.alibaba.android.arouter.launcher.ARouter
import com.gh.common.util.CheckLoginUtils
import com.gh.common.util.PackageUtils
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.constant.RouteConsts
import com.gh.gamecenter.common.entity.SimpleGameEntity
import com.gh.gamecenter.common.retrofit.BiResponse
import com.gh.gamecenter.common.retrofit.Response
import com.gh.gamecenter.core.provider.IFloatingWindowProvider
import com.gh.gamecenter.core.utils.SPUtils
import com.gh.gamecenter.entity.DialogEntity
import com.gh.gamecenter.entity.SubjectRecommendEntity
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.entity.WelcomeDialogEntity
import com.gh.gamecenter.floatingwindow.FloatingWindowEntity
import com.gh.gamecenter.login.user.UserManager
import com.gh.gamecenter.retrofit.RetrofitManager
import com.halo.assistant.HaloApp
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import okhttp3.MediaType
import okhttp3.RequestBody
import okhttp3.ResponseBody
import org.json.JSONObject
import retrofit2.HttpException
class MainWrapperViewModel(application: Application, repository: MainWrapperRepository) :
AndroidViewModel(application) {
private val mApi = RetrofitManager.getInstance().api
private val mSensitiveApi = RetrofitManager.getInstance().api
val gameNavBar: MutableLiveData<SubjectRecommendEntity?> = repository.getGameNavBarLiveData()
val videoNavBar: MutableLiveData<SubjectRecommendEntity?> = repository.getVideoNavBarLiveData()
val welcomeDialog = MutableLiveData<WelcomeDialogEntity?>()
val reserveDialog = MutableLiveData<List<SimpleGameEntity>?>()
val privacyPolicyDialog = MutableLiveData<DialogEntity.PrivacyPolicyEntity?>()
val accelerateNotificationPopup = MutableLiveData<List<GameEntity>?>()
val floatingWindow = MutableLiveData<ArrayList<FloatingWindowEntity>?>()
/**
* 请求各种弹窗的数据
*/
fun requestAllDialogData() {
requestOpeningData()
requestReserveDialog()
requestAccelerateNotificationPopup()
requestFloatingWindowList()
}
/**
* 获取弹窗
*/
@SuppressLint("CheckResult")
private fun requestOpeningData() {
val sp = PreferenceManager.getDefaultSharedPreferences(getApplication())
val lastId = SPUtils.getString(sp, Constants.SP_LAST_OPENING_ID, "")
val lastTime = SPUtils.getLong(sp, Constants.SP_LAST_OPENING_TIME, 0)
val openType = if (HaloApp.getInstance().isNewForThisVersion) "first" else "not_first_time"
mSensitiveApi.getOpeningDialog(HaloApp.getInstance().channel, lastId, lastTime, openType)
.subscribeOn(Schedulers.io())
.subscribe(object : BiResponse<DialogEntity>() {
override fun onSuccess(data: DialogEntity) {
val welcomeDialogEntity = data.welcomeDialog
val privacyPolicyDialogEntity = data.privacyPolicyDialog
// 类型为游戏时判断是否本地已安装该游戏,已安装不弹弹窗
if (welcomeDialogEntity != null) {
updateWelcomeDialogData(null, welcomeDialogEntity)
if (welcomeDialogEntity.type == "game") {
if (welcomeDialogEntity.packages == null) {
welcomeDialog.postValue(data.welcomeDialog)
} else {
for (packageName in data.welcomeDialog.packages!!) {
if (PackageUtils.isInstalled(getApplication(), packageName)) {
welcomeDialog.postValue(null)
return
}
}
welcomeDialog.postValue(data.welcomeDialog)
}
} else {
welcomeDialog.postValue(data.welcomeDialog)
}
}
// 全新安装忽略隐私弹窗
if (privacyPolicyDialogEntity != null) {
val id = privacyPolicyDialogEntity.id
val lastAcceptedId = SPUtils.getString(Constants.SP_LAST_ACCEPTED_PRIVACY_DIALOG_ID, "")
if (HaloApp.getInstance().isBrandNewInstall) {
SPUtils.setString(Constants.SP_LAST_ACCEPTED_PRIVACY_DIALOG_ID, id)
privacyPolicyDialog.postValue(null)
} else {
if (id != lastAcceptedId) {
privacyPolicyDialog.postValue(privacyPolicyDialogEntity)
} else {
privacyPolicyDialog.postValue(null)
}
}
} else {
privacyPolicyDialog.postValue(null)
}
}
override fun onFailure(exception: Exception) {
privacyPolicyDialog.postValue(null)
}
})
}
@SuppressLint("CheckResult")
private fun requestReserveDialog() {
if (CheckLoginUtils.isLogin()) {
mApi.getReserveDialog(UserManager.getInstance().userId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : BiResponse<List<SimpleGameEntity>>() {
override fun onSuccess(data: List<SimpleGameEntity>) {
reserveDialog.postValue(data)
}
override fun onFailure(exception: Exception) {
reserveDialog.postValue(null)
}
})
} else {
reserveDialog.postValue(null)
}
}
fun requestAccelerateNotificationPopup() {
if (CheckLoginUtils.isLogin()) {
mApi.getAccelerateNotificationPopup(UserManager.getInstance().userId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Response<List<GameEntity>>() {
override fun onResponse(response: List<GameEntity>?) {
super.onResponse(response)
accelerateNotificationPopup.postValue(response)
}
override fun onFailure(e: HttpException?) {
super.onFailure(e)
accelerateNotificationPopup.postValue(null)
}
})
} else {
accelerateNotificationPopup.postValue(null)
}
}
private fun requestFloatingWindowList() {
val floatingWindowProvider =
ARouter.getInstance().build(RouteConsts.provider.floatingwindow)
.navigation() as? IFloatingWindowProvider<WelcomeDialogEntity>
floatingWindowProvider?.getFloatingWindowOnly { anies, throwable ->
if (anies != null) {
updateWelcomeDialogData(anies as ArrayList<FloatingWindowEntity>, null)
floatingWindow.postValue(anies)
} else if (throwable != null) {
floatingWindow.postValue(arrayListOf())
}
}
}
/**
* 更新启动弹窗是否需要显示消失动画的标记
* 当启动弹窗绑定的 windowId 与右下角悬浮窗的第一个 window 的 id 一样时才显示消失动画
*/
private fun updateWelcomeDialogData(
floatingWindowList: ArrayList<FloatingWindowEntity>?,
welcomeDialogEntity: WelcomeDialogEntity?
) {
val finalFloatingWindowList = floatingWindowList ?: floatingWindow.value
val finalWelcomeDialogEntity = welcomeDialogEntity ?: welcomeDialog.value
if (finalFloatingWindowList != null && finalWelcomeDialogEntity != null) {
if (finalFloatingWindowList.firstOrNull()?.id == finalWelcomeDialogEntity.floatingWindowId) {
finalWelcomeDialogEntity.shouldShowExitAnimation = true
}
}
}
fun postMessageRead(messageId: String) {
val jsonObject = JSONObject()
jsonObject.put("type", "system_message")
val body = RequestBody.create(MediaType.parse("application/json"), jsonObject.toString())
RetrofitManager.getInstance().api.postMessageRead(UserManager.getInstance().userId, messageId, body)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Response<ResponseBody>() {
})
}
/**
* 特殊渠道隐藏视频 tab
*/
fun shouldHideVideoTab(): Boolean {
val channelInInteger = HaloApp.getInstance().channel.toIntOrNull()
return if (channelInInteger == null) false else channelInInteger in 1001..1050
}
class Factory(
private val mApplication: Application,
) : ViewModelProvider.NewInstanceFactory() {
override fun <T : ViewModel> create(modelClass: Class<T>): T {
return MainWrapperViewModel(mApplication, MainWrapperRepository.getInstance()) as T
}
}
companion object {
const val SHOULD_SHOW_OPENING_DIALOG = "show_opening_dialog"
}
}

View File

@ -0,0 +1,43 @@
package com.gh.gamecenter.fragment
import android.os.Bundle
import android.view.View
import com.gh.gamecenter.common.base.fragment.BaseLazyFragment
import com.gh.gamecenter.common.utils.observeNonNull
import com.gh.gamecenter.common.utils.viewModelProviderFromParent
import com.gh.gamecenter.core.utils.DisplayUtils
import com.gh.gamecenter.databinding.FragmentReloadBinding
import com.gh.gamecenter.wrapper.MainWrapperRepository
import com.gh.gamecenter.wrapper.MainWrapperViewModel
import com.halo.assistant.HaloApp
class ReloadFragment: BaseLazyFragment() {
private val mBinding by lazy { FragmentReloadBinding.inflate(layoutInflater) }
private val mViewModel: MainWrapperViewModel by lazy { viewModelProviderFromParent(MainWrapperViewModel.Factory(HaloApp.getInstance())) }
override fun getLayoutId(): Int = 0
override fun getInflatedLayout(): View = mBinding.root
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
DisplayUtils.setLightStatusBar(requireActivity(), !mIsDarkModeOn)
mBinding.reuseNoConnection.connectionReloadTv.setOnClickListener {
MainWrapperRepository.getInstance().getDataUnion()
mBinding.reuseNoConnection.root.visibility = View.GONE
mBinding.reuseLoading.root.visibility = View.VISIBLE
}
mViewModel.errorLiveData.observeNonNull(this) {
mBinding.reuseNoConnection.root.visibility = View.VISIBLE
mBinding.reuseLoading.root.visibility = View.GONE
}
}
override fun onDarkModeChanged() {
super.onDarkModeChanged()
if (isSupportVisible) {
DisplayUtils.setLightStatusBar(requireActivity(), !mIsDarkModeOn)
}
}
}

View File

@ -8,6 +8,7 @@ import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import com.gh.common.constant.Config;
import com.gh.common.util.ViewPagerFragmentHelper;
import com.gh.gamecenter.R;
import com.gh.gamecenter.common.base.fragment.LazyFragment;
import com.gh.gamecenter.common.base.fragment.ToolbarFragment;
@ -53,7 +54,7 @@ public class SearchToolWrapperFragment extends LazyFragment {
try {
Bundle arguments = getArguments();
if (arguments != null) {
String className = Objects.requireNonNull(arguments.getString(MainWrapperFragment.WRAPPER_FRAGMENT_NAME));
String className = Objects.requireNonNull(arguments.getString(ViewPagerFragmentHelper.WRAPPER_FRAGMENT_NAME));
mContentFragment = contentFragment != null ? contentFragment : (Fragment) Class.forName(className).newInstance();
Bundle bundle = new Bundle();

View File

@ -0,0 +1,318 @@
package com.gh.gamecenter.fragment
import android.annotation.SuppressLint
import android.app.Dialog
import android.content.Context
import android.content.DialogInterface
import android.os.Bundle
import android.text.Html
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.constraintlayout.widget.ConstraintLayout
import com.gh.common.util.DirectUtils
import com.gh.common.util.PackageInstaller
import com.gh.download.DownloadManager
import com.gh.gamecenter.R
import com.gh.gamecenter.common.base.fragment.BaseDialogFragment
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.common.view.CustomLinkMovementMethod
import com.gh.gamecenter.core.AppExecutor
import com.gh.gamecenter.core.utils.*
import com.gh.gamecenter.databinding.AppUpdateHintDialogBinding
import com.gh.gamecenter.databinding.AppUpdatingDialogBinding
import com.gh.gamecenter.databinding.DialogUpdateBinding
import com.gh.gamecenter.entity.AppEntity
import com.gh.gamecenter.update.UpdateHelper
import com.lightgame.download.DataWatcher
import com.lightgame.download.DownloadEntity
import com.lightgame.download.DownloadStatus
import java.text.DecimalFormat
import java.util.concurrent.atomic.AtomicBoolean
import kotlin.math.roundToInt
/**
* 更新弹窗 DialogFragment
*/
class UpdateDialogFragment : BaseDialogFragment() {
private var mUpdateEntity: AppEntity? = null
private var mDismissCallback: EmptyCallback? = null
private val mIsDismissByTouchInside = AtomicBoolean(false)
private val mBinding by lazy { DialogUpdateBinding.inflate(layoutInflater) }
private var mIsDisplayingDownloadingStyle = false // 是否正在显示更新中样式
private val mDataWatcher = object : DataWatcher() {
override fun onDataChanged(downloadEntity: DownloadEntity) {
if (downloadEntity.name.contains("光环助手")) {
if (mIsDisplayingDownloadingStyle) {
updateDownloadingView(
mBinding.updatingContainerView,
downloadEntity,
mUpdateEntity!!
)
} else {
if (DownloadStatus.done == downloadEntity.status) {
updateUpdateHintView(
mBinding.updateHintContainerView,
mUpdateEntity!!,
UpdateHelper.isUpdateFileDownloaded(mUpdateEntity!!)
)
}
}
}
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (savedInstanceState != null) {
dismiss()
return
}
DownloadManager.getInstance().addObserver(mDataWatcher)
mUpdateEntity = arguments?.getParcelable(UPDATE_ENTITY)
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
showUpdateHintStyle(requireContext(), mUpdateEntity!!)
return mBinding.root
}
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
return super.onCreateDialog(savedInstanceState).apply {
val cancelable = !mUpdateEntity!!.isForce
setCancelable(cancelable)
setCanceledOnTouchOutside(cancelable)
this@UpdateDialogFragment.isCancelable = cancelable
}
}
override fun onDismiss(dialog: DialogInterface) {
super.onDismiss(dialog)
if (!mIsDismissByTouchInside.get()) {
SensorsBridge.trackVersionUpdateDialogClick("关闭弹窗")
}
mDismissCallback?.onCallback()
}
override fun onDestroyView() {
super.onDestroyView()
DownloadManager.getInstance().removeObserver(mDataWatcher)
}
/**
* 显示更新弹窗(提示样式)
* @param context 上下文
* @param updateEntity 更新实体
*/
private fun showUpdateHintStyle(context: Context, updateEntity: AppEntity) {
mIsDisplayingDownloadingStyle = false
val updateHintBinding = mBinding.updateHintContainerView
val updatingBinding = mBinding.updatingContainerView
updatingBinding.root.visibility = View.GONE
updateHintBinding.root.visibility = View.VISIBLE
val cancelUpdateTextView = updateHintBinding.cancel
val confirmTextView = updateHintBinding.confirm
if (!TextUtils.isEmpty(updateEntity.spareLink)) {
val defaultText = "部分设备若无法更新安装,请前往官网进行下载安装:"
val externalTextTv = updateHintBinding.externalTextTv
val builder = SpanBuilder(defaultText + updateEntity.spareLink)
.click(
context,
defaultText.length,
defaultText.length + updateEntity.spareLink!!.length,
R.color.text_theme,
false
) {
DirectUtils.directToExternalBrowser(context, updateEntity.spareLink!!)
}
.build()
externalTextTv.text = builder
externalTextTv.movementMethod = CustomLinkMovementMethod.getInstance()
externalTextTv.visibility = View.VISIBLE
}
val updateFileIsDownloaded = UpdateHelper.isUpdateFileDownloaded(updateEntity)
if (NetworkUtils.isWifiConnected(context)) {
if (!updateFileIsDownloaded) {
updateUpdateHintView(updateHintBinding, updateEntity, false)
UpdateHelper.createUpdate(updateEntity, true)
} else {
updateUpdateHintView(updateHintBinding, updateEntity, true)
}
} else {
updateUpdateHintView(updateHintBinding, updateEntity, updateFileIsDownloaded)
}
updateHintBinding.desc.text = Html.fromHtml(updateEntity.content)
updateHintBinding.version.text = java.lang.String.format("版本%s更新日志", updateEntity.version)
updateHintBinding.size.text = java.lang.String.format("大小 %s", updateEntity.size)
cancelUpdateTextView.setOnClickListener {
if (updateEntity.isForce) {
UpdateHelper.exitApp()
} else {
dismiss()
}
mIsDismissByTouchInside.set(true)
val cancelText: String = cancelUpdateTextView.text.toString()
SensorsBridge.trackVersionUpdateDialogClick(cancelText)
}
confirmTextView.setOnClickListener {
// 产品不接受显示下载完成文案从立即更新变为立即安装,所以文案为立即更新时一律不执行安装
if (UpdateHelper.isUpdateFileDownloaded(updateEntity) && confirmTextView.text != "立即更新") {
DataLogUtils.uploadUpgradeLog(context, "install") //上传更新安装数据
PackageInstaller.install(context, false, UpdateHelper.getUpdateDownloadPath(updateEntity), null)
} else {
showDownloadingStyle(updateEntity)
}
val buttonName: String = confirmTextView.text.toString()
SensorsBridge.trackVersionUpdateDialogClick(buttonName)
}
SensorsBridge.trackVersionUpdateDialogShow()
DataLogUtils.uploadUpgradeLog(context, "notice") //上传更新通知弹窗数据
}
/**
* 更新更新提示的文案
*/
private fun updateUpdateHintView(
binding: AppUpdateHintDialogBinding,
updateEntity: AppEntity,
isUpdateDownloaded: Boolean
) {
val confirmText = if (isUpdateDownloaded) "立即安装" else "立即更新"
val cancelText = if (isUpdateDownloaded) {
if (updateEntity.isForce) "暂不安装,退出光环" else "暂不安装"
} else {
if (updateEntity.isForce) "暂不更新,退出光环" else "暂不更新"
}
binding.confirm.text = confirmText
binding.downloadedHint.visibility = if (isUpdateDownloaded) View.VISIBLE else View.GONE
binding.cancel.text = cancelText
}
/**
* 显示更新下载中弹窗
*/
private fun showDownloadingStyle(updateEntity: AppEntity) {
mIsDisplayingDownloadingStyle = true
val updatingBinding = mBinding.updatingContainerView
val updateHintBinding = mBinding.updateHintContainerView
updatingBinding.root.visibility = View.VISIBLE
updateHintBinding.root.visibility = View.GONE
updatingBinding.appTvCancel.setOnClickListener {
DownloadManager.getInstance().cancel(updateEntity.url)
if (updateEntity.isForce) {
UpdateHelper.exitApp()
} else {
dismiss()
}
}
if (NetworkUtils.isMobileConnected(context)) {
ToastUtils.toast("当前使用移动数据进行下载")
}
UpdateHelper.createUpdate(updateEntity, false)
}
@SuppressLint("SetTextI18n")
private fun updateDownloadingView(
dialogBinding: AppUpdatingDialogBinding,
downloadEntity: DownloadEntity,
updateEntity: AppEntity
) {
// 被取消任务的状态不用来更新页面
if (DownloadStatus.cancel != downloadEntity.status) {
val size = (downloadEntity.progress / 1024) / 1024F
val df = DecimalFormat("0.00")
dialogBinding.size.text = (df.format(size) + "MB")
dialogBinding.remain.text = String.format(
"剩余%s",
SpeedUtils.getRemainSecondTime(
downloadEntity.size,
downloadEntity.progress,
downloadEntity.speed * 1024
)
)
dialogBinding.progress.progress = (downloadEntity.percent * 10).roundToInt()
val width = dialogBinding.progress.width
val marLeft = (downloadEntity.percent / 100 * width)
val anchorLp = dialogBinding.progressAnchor.layoutParams
if (anchorLp is ConstraintLayout.LayoutParams) {
anchorLp.leftMargin = marLeft.roundToInt()
dialogBinding.progressAnchor.layoutParams = anchorLp
}
val fillingLp = dialogBinding.progressFilling.layoutParams
fillingLp.width = (marLeft + DisplayUtils.dip2px(5F)).toInt()
dialogBinding.progressFilling.layoutParams = fillingLp
dialogBinding.percent.text = "${downloadEntity.percent} %"
}
if (DownloadStatus.done == downloadEntity.status) {
DownloadManager.getInstance().cancel(downloadEntity.url, false, true, false)
try {
dismiss()
} catch (ignored: IllegalArgumentException) {
// do nothing
}
if (updateEntity.isForce) {
AppExecutor.uiExecutor.executeWithDelay({ UpdateHelper.exitApp() }, 1000L)
}
} else if (DownloadStatus.neterror == downloadEntity.status) {
ToastUtils.toast("网络错误,请稍后重试")
} else if (DownloadStatus.diskisfull == downloadEntity.status) {
ToastUtils.toast("磁盘已满,请清理后重试")
} else if (DownloadStatus.diskioerror == downloadEntity.status) {
ToastUtils.toast("磁盘 IO 异常,请稍后重试")
} else if (DownloadStatus.timeout == downloadEntity.status) {
ToastUtils.toast("请求超时,请稍后重试")
} else if (DownloadStatus.notfound == downloadEntity.status) {
ToastUtils.toast("下载链接异常,请稍后重试")
} else if (DownloadStatus.hijack == downloadEntity.status) {
ToastUtils.toast("网络劫持,请稍后重试")
}
}
companion object {
const val UPDATE_ENTITY = "update_entity"
fun newInstance(updateEntity: AppEntity, dismissCallback: EmptyCallback): UpdateDialogFragment {
val fragment = UpdateDialogFragment()
val bundle = Bundle()
bundle.putParcelable(UPDATE_ENTITY, updateEntity)
fragment.arguments = bundle
fragment.mDismissCallback = dismissCallback
return fragment
}
}
}

View File

@ -4,7 +4,6 @@ import android.app.Application
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.MediatorLiveData
import androidx.lifecycle.MutableLiveData
import com.gh.common.util.GameSubstituteRepositoryHelper
import com.gh.download.DownloadManager
import com.gh.gamecenter.common.baselist.LoadStatus
import com.gh.gamecenter.common.entity.ExposureEntity

View File

@ -1,7 +1,6 @@
package com.gh.gamecenter.game
import android.graphics.Color
import android.os.Bundle
import android.view.View
import androidx.core.content.ContextCompat
import androidx.lifecycle.Observer
@ -32,13 +31,13 @@ import com.gh.gamecenter.eventbus.EBDiscoverChanged
import com.gh.gamecenter.eventbus.EBDownloadStatus
import com.gh.gamecenter.eventbus.EBPackage
import com.gh.gamecenter.eventbus.EBUISwitch
import com.gh.gamecenter.fragment.MainWrapperFragment
import com.gh.gamecenter.game.data.GameItemData
import com.gh.gamecenter.home.test_v2.HomeGameTestV2ViewModel
import com.gh.gamecenter.home.test_v2.HomeItemGameTestV2ViewHolder
import com.gh.gamecenter.home.test_v2.HomeItemGameTestV2ViewHolderWatcher
import com.gh.gamecenter.home.test_v2.addViewHolderWatcher
import com.gh.gamecenter.home.video.ScrollCalculatorHelper
import com.gh.gamecenter.wrapper.MainWrapperFragment
import com.halo.assistant.HaloApp
import com.lightgame.download.DataWatcher
import com.lightgame.download.DownloadEntity
@ -58,8 +57,6 @@ open class GameFragment : LazyFragment() {
private lateinit var mExposureListener: ExposureListener
private lateinit var mScrollCalculatorHelper: ScrollCalculatorHelper
private var mIsFromHomeToolbarWrapper = false
private val dataWatcher = object : DataWatcher() {
override fun onDataChanged(downloadEntity: DownloadEntity) {
mListAdapter.notifyItemByDownload(downloadEntity)
@ -76,11 +73,6 @@ open class GameFragment : LazyFragment() {
override fun getRealLayoutId() = R.layout.fragment_game
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
mIsFromHomeToolbarWrapper = arguments?.getBoolean(EntranceConsts.KEY_IS_FROM_HOME_TOOLBAR_WRAPPER, false) ?: false
}
override fun onFragmentFirstVisible() {
mViewModel = provideViewModel()
mViewModel.entrance = mEntrance
@ -92,10 +84,6 @@ open class GameFragment : LazyFragment() {
super.onFragmentFirstVisible()
if (mIsFromHomeToolbarWrapper) {
initMenu(R.menu.menu_download)
}
mViewModel.loadStatus.observe(this) {
if (it != null) {
mBinding.gameRefresh.isRefreshing = false
@ -333,18 +321,10 @@ open class GameFragment : LazyFragment() {
if (::mListAdapter.isInitialized && "Refresh" == reuse.type) {
mListAdapter.notifyDataSetChanged()
}
(mViewModel as GameViewModel).refreshRecentVGameIfNeeded()
}
@Subscribe(threadMode = ThreadMode.MAIN)
fun onEventMainThread(busNine: EBUISwitch) {
if (::mLayoutManager.isInitialized &&
MainWrapperFragment.EB_MAIN_SCROLL_TOP == busNine.from &&
MainWrapperFragment.INDEX_GAME == busNine.position
) {
mBinding.gameList.stopScroll()
mLayoutManager.scrollToPosition(0)
if(::mViewModel.isInitialized){
(mViewModel as GameViewModel).refreshRecentVGameIfNeeded()
}
}
@Subscribe(threadMode = ThreadMode.MAIN)

View File

@ -11,7 +11,6 @@ import androidx.lifecycle.LifecycleOwner
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.ViewHolder
import com.gh.common.constant.Config
import com.gh.common.databind.BindingAdapters
import com.gh.common.exposure.IExposable
import com.gh.common.util.*
@ -930,7 +929,7 @@ class GameFragmentAdapter(
SensorsBridge.trackEvent("RecommendedLocationClick", json {
"position" to clickedPosition
"Recommended_location_name" to if (Config.isShowPlugin()) entity.name else entity.nameNormal
"Recommended_location_name" to entity.name
"location" to "版块"
"block_name" to blockData?.text
"block_id" to blockData?.link
@ -951,6 +950,7 @@ class GameFragmentAdapter(
"",
mViewModel.blockData?.link ?: "",
mViewModel.blockData?.text ?: "",
"",
exposureEvent
)
@ -1071,12 +1071,12 @@ class GameFragmentAdapter(
source = listOf(
ExposureSource(
"推荐入口",
if (Config.isShowPlugin()) entity.name ?: "" else entity.nameNormal ?: ""
entity.name ?: ""
)
)
)
event.payload.controlType = "推荐入口"
event.payload.controlName = if (Config.isShowPlugin()) entity.name else entity.nameNormal
event.payload.controlName = entity.name
event.payload.controlLinkType = entity.type
event.payload.controlLinkName = entity.text
entity.exposureEvent = event
@ -1124,19 +1124,19 @@ class GameFragmentAdapter(
ImageUtils.display(entranceIcon4, if (subjectDigestList.size > 3) subjectDigestList[3].icon else "")
ImageUtils.display(entranceIcon5, if (subjectDigestList.size > 4) subjectDigestList[4].icon else "")
entranceName1.text = if (subjectDigestList.isNotEmpty()) {
if (Config.isShowPlugin()) subjectDigestList[0].name else subjectDigestList[0].nameNormal
subjectDigestList[0].name
} else "推荐入口"
entranceName2.text = if (subjectDigestList.size > 1) {
if (Config.isShowPlugin()) subjectDigestList[1].name else subjectDigestList[1].nameNormal
subjectDigestList[1].name
} else "推荐入口"
entranceName3.text = if (subjectDigestList.size > 2) {
if (Config.isShowPlugin()) subjectDigestList[2].name else subjectDigestList[2].nameNormal
subjectDigestList[2].name
} else "推荐入口"
entranceName4.text = if (subjectDigestList.size > 3) {
if (Config.isShowPlugin()) subjectDigestList[3].name else subjectDigestList[3].nameNormal
subjectDigestList[3].name
} else "推荐入口"
entranceName5.text = if (subjectDigestList.size > 4) {
if (Config.isShowPlugin()) subjectDigestList[4].name else subjectDigestList[4].nameNormal
subjectDigestList[4].name
} else "推荐入口"
}
@ -1279,7 +1279,7 @@ class GameFragmentAdapter(
)
}
holder.bindGameItem(gameEntity, subjectData.isShowSuffix, subjectData.briefStyle)
holder.bindGameItem(gameEntity, subjectData.briefStyle)
holder.initServerType(gameEntity)
runOnIoThread(true) {
@ -2067,4 +2067,4 @@ class GameFragmentAdapter(
}
class GameAndPosition(val entity: GameEntity?, val position: Int, val index: Int = 0)
data class GameAndPosition(val entity: GameEntity?, val position: Int, val index: Int = 0)

View File

@ -73,10 +73,10 @@ class GameViewModel(application: Application, override var blockData: SubjectRec
private var mSubjectGameIdList = hashSetOf<String>()
init {
if (blockData == null) {
// 读取默认板块
blockData = HomeBottomBarHelper.getDefaultGameBarData()
}
// if (blockData == null) {
// // 读取默认板块
// blockData = HomeBottomBarHelper.getDefaultGameBarData()
// }
if (!blockData?.link.isNullOrEmpty()) {
initData()
@ -725,8 +725,6 @@ class GameViewModel(application: Application, override var blockData: SubjectRec
if (!data.isNullOrEmpty()) {
for (game in data) {
mSubjectGameIdList.add(game.id)
// 应用专题是否显示游戏名后缀的配置
game.shouldShowNameSuffix = subjectEntity.showSuffix
}
}
@ -848,7 +846,6 @@ class GameViewModel(application: Application, override var blockData: SubjectRec
position = i + if (data[0].image.isNullOrEmpty()) 1 else 0,
isOrder = subjectEntity.isOrder,
briefStyle = subjectEntity.briefStyle,
isShowSuffix = subjectEntity.showSuffix
)
addGamePositionAndPackage(game)
@ -880,8 +877,7 @@ class GameViewModel(application: Application, override var blockData: SubjectRec
tag = subjectEntity.tag,
position = i + if (data[0].image.isNullOrEmpty()) 1 else 0,
isOrder = subjectEntity.isOrder,
briefStyle = subjectEntity.briefStyle,
isShowSuffix = subjectEntity.showSuffix
briefStyle = subjectEntity.briefStyle
)
game.outerSequence = index
game.sequence = i
@ -912,7 +908,6 @@ class GameViewModel(application: Application, override var blockData: SubjectRec
position = i + if (data[0].image.isNullOrEmpty()) 1 else 0,
isOrder = subjectEntity.isOrder,
briefStyle = subjectEntity.briefStyle,
isShowSuffix = subjectEntity.showSuffix
)
game.outerSequence = index
game.sequence = i
@ -1068,7 +1063,6 @@ class GameViewModel(application: Application, override var blockData: SubjectRec
position = i + if (data[0].image.isNullOrEmpty()) 1 else 0,
isOrder = subjectEntity.isOrder,
briefStyle = subjectEntity.briefStyle,
isShowSuffix = subjectEntity.showSuffix
)
val itemDataGame = GameItemData()
itemDataGame.game = game

View File

@ -7,21 +7,21 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.StaggeredGridLayoutManager
import com.gh.common.exposure.IExposable
import com.gh.gamecenter.common.constant.ItemViewType
import com.gh.common.util.DirectUtils
import com.gh.common.util.NewLogUtils
import com.gh.gamecenter.common.utils.ImageUtils
import com.gh.gamecenter.core.utils.MtaHelper
import com.gh.gamecenter.core.utils.PageSwitchDataHelper
import com.gh.gamecenter.R
import com.gh.gamecenter.common.viewholder.FooterViewHolder
import com.gh.gamecenter.adapter.viewholder.GameColumnCollectionItemViewHolder
import com.gh.gamecenter.common.baselist.ListAdapter
import com.gh.gamecenter.databinding.GameColumnCollectionItemBinding
import com.gh.gamecenter.common.constant.ItemViewType
import com.gh.gamecenter.common.entity.LinkEntity
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.gamecenter.common.exposure.ExposureSource
import com.gh.gamecenter.common.utils.ImageUtils
import com.gh.gamecenter.common.utils.SensorsBridge
import com.gh.gamecenter.common.viewholder.FooterViewHolder
import com.gh.gamecenter.core.utils.MtaHelper
import com.gh.gamecenter.core.utils.PageSwitchDataHelper
import com.gh.gamecenter.databinding.GameColumnCollectionItemBinding
import com.gh.gamecenter.feature.exposure.ExposureEvent
class ColumnCollectionDetailAdapter(
context: Context,
@ -31,7 +31,8 @@ class ColumnCollectionDetailAdapter(
private val mEntrance: String,
private val mBlockId: String,
private val mBlockName: String,
private val mLocation: String
private val mLocation: String,
private val mStyle: String
) : ListAdapter<LinkEntity>(context), IExposable {
private var mExposureSparseArray = SparseArray<ExposureEvent>()
@ -98,7 +99,7 @@ class ColumnCollectionDetailAdapter(
val exposureEvent = ExposureEvent.createEventWithSourceConcat(
null,
mBasicExposureSourceList ?: arrayListOf(),
arrayListOf(ExposureSource("游戏专题合集", "${mViewModel.getGameColumnCollectionName()}+${mViewModel.collectionId}"))
arrayListOf(ExposureSource("合集详情", ""), ExposureSource("专题", "${data.name}+${mStyle}+${data.link}"))
).apply {
payload.outerSequence = mTabIndex
payload.sequence = position

View File

@ -6,18 +6,19 @@ import androidx.lifecycle.ViewModelProviders
import androidx.recyclerview.widget.StaggeredGridLayoutManager
import com.ethanhua.skeleton.Skeleton
import com.gh.common.exposure.ExposureListener
import com.gh.gamecenter.R
import com.gh.gamecenter.common.baselist.LazyListFragment
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.constant.EntranceConsts.KEY_SHOW_SUBJECT_TAB
import com.gh.gamecenter.common.entity.LinkEntity
import com.gh.gamecenter.common.exposure.ExposureSource
import com.gh.gamecenter.common.utils.dip2px
import com.gh.gamecenter.common.utils.observeNonNull
import com.gh.gamecenter.common.utils.toColor
import com.gh.gamecenter.common.view.GridSpacingItemDecoration
import com.gh.gamecenter.R
import com.gh.gamecenter.common.baselist.LazyListFragment
import com.gh.gamecenter.databinding.FragmentColumnCollectionDetailBinding
import com.gh.gamecenter.common.entity.LinkEntity
import com.gh.gamecenter.entity.SubjectData
import com.gh.gamecenter.common.exposure.ExposureSource
import com.gh.gamecenter.subject.tab.SubjectTabFragment
class ColumnCollectionDetailFragment : LazyListFragment<LinkEntity, ColumnCollectionDetailViewModel>() {
@ -34,6 +35,8 @@ class ColumnCollectionDetailFragment : LazyListFragment<LinkEntity, ColumnCollec
private var mBlockId = ""
private var mBlockName = ""
private var showSubjectTab = false
override fun getItemDecoration() = null
override fun getRealLayoutId() = R.layout.fragment_column_collection_detail
@ -51,6 +54,7 @@ class ColumnCollectionDetailFragment : LazyListFragment<LinkEntity, ColumnCollec
mBlockId = requireArguments().getString(EntranceConsts.KEY_BLOCK_ID, "")
mBlockName = requireArguments().getString(EntranceConsts.KEY_BLOCK_NAME, "")
mBasicExposureSourceList = arguments?.getParcelableArrayList(EntranceConsts.KEY_EXPOSURE_SOURCE_LIST)
showSubjectTab = arguments?.getBoolean(KEY_SHOW_SUBJECT_TAB, false) ?: false
}
override fun onFragmentFirstVisible() {
@ -87,17 +91,29 @@ class ColumnCollectionDetailFragment : LazyListFragment<LinkEntity, ColumnCollec
mListRv?.addOnScrollListener(mExposureListener!!)
if (mListViewModel.rowCount() == 1) {
mListRv?.setPadding(16F.dip2px(), 0, 16F.dip2px(), 0)
mListRv?.addItemDecoration(GridSpacingItemDecoration(mListViewModel.rowCount(), 16F.dip2px(), false))
mListRv?.addItemDecoration(
GridSpacingItemDecoration(
mListViewModel.rowCount(),
16F.dip2px(),
false
)
)
} else {
mListRv?.setPadding(16F.dip2px(), 8F.dip2px(), 16F.dip2px(), 0)
mListRv?.addItemDecoration(GridSpacingItemDecoration(mListViewModel.rowCount(), 12F.dip2px(), false))
mListRv?.addItemDecoration(
GridSpacingItemDecoration(
mListViewModel.rowCount(),
12F.dip2px(),
false
)
)
}
}
}
}
override fun onChanged(list: MutableList<LinkEntity>?) {
if (mListViewModel.columnCollection.value?.style != "top") {
if (mListViewModel.columnCollection.value?.style != "top" && !showSubjectTab) {
super.onChanged(list)
} else {
if (list != null && list.isNotEmpty()) {
@ -147,7 +163,8 @@ class ColumnCollectionDetailFragment : LazyListFragment<LinkEntity, ColumnCollec
mEntrance,
mBlockId,
mBlockName,
mLocation
mLocation,
arguments?.getString(EntranceConsts.KEY_COLUMN_COLLECTION_STYLE, "") ?: ""
)
}
return mAdapter!!

View File

@ -3,9 +3,10 @@ package com.gh.gamecenter.game.commoncollection.detail
import android.content.Context
import android.content.Intent
import android.os.Bundle
import com.gh.gamecenter.common.base.activity.ToolBarActivity
import com.gh.gamecenter.R
import com.gh.gamecenter.common.base.activity.ToolBarActivity
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.exposure.ExposureSource
import com.gh.gamecenter.common.utils.updateStatusBarColor
class CommonCollectionDetailActivity : ToolBarActivity() {
@ -45,7 +46,8 @@ class CommonCollectionDetailActivity : ToolBarActivity() {
collectionId: String,
blockId: String = "",
blockName: String = "",
entrance: String = ""
entrance: String = "",
exposureSourceList: ArrayList<ExposureSource>? = null
): Intent {
val bundle = Bundle()
bundle.putString(EntranceConsts.KEY_ENTRANCE, entrance)
@ -53,6 +55,7 @@ class CommonCollectionDetailActivity : ToolBarActivity() {
bundle.putString(EntranceConsts.KEY_BLOCK_NAME, blockName)
bundle.putString(EntranceConsts.KEY_COLLECTION_ID, collectionId)
bundle.putString(EntranceConsts.KEY_LOCATION, "合集详情")
bundle.putParcelableArrayList(EntranceConsts.KEY_EXPOSURE_SOURCE_LIST, exposureSourceList)
return getTargetIntent(
context,
CommonCollectionDetailActivity::class.java,

View File

@ -5,9 +5,9 @@ import android.util.SparseArray
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.gh.common.exposure.IExposable
import com.gh.common.util.*
import com.gh.common.util.DirectUtils
import com.gh.common.util.NewLogUtils
import com.gh.gamecenter.R
import com.gh.gamecenter.adapter.viewholder.CommonCollectionDetailOneItemViewHolder
import com.gh.gamecenter.adapter.viewholder.CommonCollectionDetailTwoItemViewHolder
@ -15,13 +15,14 @@ import com.gh.gamecenter.adapter.viewholder.CommonCollectionImageTextItemViewHol
import com.gh.gamecenter.common.baselist.ListAdapter
import com.gh.gamecenter.common.constant.ItemViewType
import com.gh.gamecenter.common.exposure.ExposureSource
import com.gh.gamecenter.common.utils.goneIf
import com.gh.gamecenter.common.utils.toBinding
import com.gh.gamecenter.common.utils.ImageUtils
import com.gh.gamecenter.common.utils.SensorsBridge
import com.gh.gamecenter.common.utils.goneIf
import com.gh.gamecenter.common.utils.toBinding
import com.gh.gamecenter.common.viewholder.FooterViewHolder
import com.gh.gamecenter.entity.CommonCollectionContentEntity
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.exposure.ExposureEvent
class CommonCollectionDetailAdapter(
context: Context,
@ -128,13 +129,7 @@ class CommonCollectionDetailAdapter(
it.sequence = position
},
basicSource = mBasicExposureSource ?: listOf(),
listOf(
ExposureSource(
"内容合集",
"${mViewModel.commonCollectionLiveData.value?.name}+${mViewModel.commonCollectionLiveData.value?.id}"
),
ExposureSource("合集详情")
),
listOf(ExposureSource("合集详情")),
).apply {
this.payload.outerSequence = mTabIndex
}

View File

@ -11,10 +11,6 @@ import com.gh.gamecenter.R
import com.gh.gamecenter.adapter.viewholder.GameViewHolder
import com.gh.gamecenter.common.base.GlobalActivityManager
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.common.utils.dip2px
import com.gh.gamecenter.common.utils.goneIf
import com.gh.gamecenter.common.utils.toBinding
import com.gh.gamecenter.common.utils.toPx
import com.gh.gamecenter.core.utils.StringUtils
import com.gh.gamecenter.entity.SubjectEntity
import com.gh.gamecenter.feature.entity.GameEntity
@ -127,6 +123,16 @@ class GameHorizontalAdapter(
clickGameName = gameEntity.name ?: "",
clickGameId = gameEntity.id
)
if (!gameEntity.isQQMiniGame()) {
SensorsBridge.trackColumnClick(
location = "游戏详情",
gameName = gameName,
gameId = gameId,
gameColumnName = mSubjectEntity.name ?: "",
gameColumnId = mSubjectEntity.id ?: "",
text = "游戏"
)
}
}
if (gameEntity.isQQMiniGame()) {

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