Compare commits

..

721 Commits

Author SHA1 Message Date
4c2a46875d tinker_base-4.0.0 2020-05-15 19:01:45 +08:00
6ce64892e4 处理游戏礼包换行 2020-05-15 18:51:19 +08:00
92e1c55913 优化游戏详情礼包UI 2020-05-15 18:42:34 +08:00
b0a4aa66f6 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-05-15 15:58:17 +08:00
aad92e529e 去掉延迟播放视频逻辑 2020-05-15 15:58:13 +08:00
6e03e75110 修复问答-全部页面无法显示问题 2020-05-15 15:51:44 +08:00
cc53a1f3d6 tinker_base-4.0.0 2020-05-15 14:19:10 +08:00
25cd086298 默认的checkRetryDownload(重试下载)放到initDownloadService(初始化下载)里面 2020-05-15 13:32:01 +08:00
b27ecab969 tinker_base-4.0.0 2020-05-15 12:27:51 +08:00
db1c0d954f 修改获取baseActivity不是本应用包名 2020-05-15 12:15:58 +08:00
03d20aed61 tinker_base-4.0.0 2020-05-15 11:01:14 +08:00
c2fb1a58db 修改礼包剩余百分比 2020-05-14 15:54:40 +08:00
55998c3c4d 礼包详情剩余百分比改为四舍五入 2020-05-14 14:59:32 +08:00
1ef8fa5deb 把初始化下载服务放到主线程执行 2020-05-14 11:05:16 +08:00
d0a2868e5a Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-05-14 10:31:15 +08:00
49c2366a89 修改游戏标签样式 2020-05-14 10:31:08 +08:00
cb7d985195 修复自定义栏目跳转反馈页面的异常 2020-05-14 10:22:23 +08:00
bead0bded1 修复自定义栏目跳转反馈页面的异常 2020-05-13 17:58:46 +08:00
cc92d5f639 修改游戏详情-相关游戏标签样式 2020-05-13 17:34:43 +08:00
84c281122e Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev
# Conflicts:
#	app/src/main/res/layout/item_game_detail_related_version.xml
2020-05-13 17:28:08 +08:00
bb4a35a6a9 调整游戏详情板块之间的边距 2020-05-13 17:25:26 +08:00
71ae36fbf0 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-05-13 16:27:50 +08:00
04864e059c 光环助手V4.0.0补充需求:游戏列表优化(后台尚未完成,标签颜色暂且写死) https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/862 2020-05-13 16:27:41 +08:00
7a47184af3 去掉游戏详情倒数第二个栏目的特殊底边距 2020-05-13 15:22:15 +08:00
48e2831e96 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-05-13 12:29:05 +08:00
c1caa23b10 恢复webview实现NestedScrollingChild接口 2020-05-13 12:29:00 +08:00
443cc6007d Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-05-13 11:18:40 +08:00
7d99923960 整理多平台下载弹窗代码 2020-05-13 11:18:18 +08:00
7342d0706f Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-05-13 11:12:28 +08:00
c15c194feb 再次修改游戏详情礼包UI 2020-05-13 11:12:23 +08:00
3b6a5b5a20 更换引导图 2020-05-13 11:04:39 +08:00
f9028ea8a5 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-05-13 10:56:39 +08:00
8cd06a80ba 多版本下载面板优化20200512测试3 https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/819 2020-05-13 10:56:34 +08:00
6c80266abb 修复多平台面板无法读取链接图标问题 2020-05-13 10:53:44 +08:00
ca3c1fa8c2 修改游戏详情礼包UI 2020-05-12 22:18:53 +08:00
2b7deaef2c 完成4.0测试问题汇总(0511)的0512UI测试 https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/859 2020-05-12 21:10:55 +08:00
42f1898bd1 整理游戏详情页列表间距 2020-05-12 20:38:03 +08:00
0bdff3eac7 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-05-12 19:46:43 +08:00
a00f6660a1 修改徽章中心不显示问题 2020-05-12 19:46:38 +08:00
67d1ad497f 完成4.0.0测试问题汇总(0511)的 2, 3, 4, 8 https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/859 2020-05-12 18:03:58 +08:00
f1bbf4e9fc 专区网页二级页面点击右上角返回按钮直接关闭页面 2020-05-12 17:35:13 +08:00
00ff5e6a94 视频流底部添加渐变背景 2020-05-12 16:05:00 +08:00
7f77a8fd63 详细信息功能标签增加分割线 2020-05-12 15:17:22 +08:00
7c1267148b 光环助手V4.0.0-测试问题汇总(20200511)(5,6,7,9) https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/859 2020-05-12 12:12:33 +08:00
2dbb7b67cb 调整游戏详情板块间距 2020-05-12 11:14:33 +08:00
c41db52b05 网页控制分享新加url参数 2020-05-12 11:13:46 +08:00
72f3a262ca 评论页面评论过少时不展示评分区域 2020-05-11 16:55:48 +08:00
2fbe6a4937 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-05-11 16:44:32 +08:00
c6fb63afe6 专区网页跳转二级页面使用原生页面打开 2020-05-11 16:44:28 +08:00
2e05320ddf 优化详情页公告/自定义栏目的初始化显示样式 2020-05-11 16:40:57 +08:00
a3f86ab604 避免数组越界 2020-05-11 16:38:48 +08:00
5d2efda925 修复历史版本页面下载游戏时文字抖动的问题 2020-05-11 15:14:07 +08:00
4a30ac04b7 修复可展开文字在触摸全部按钮是高度会变更的问题 2020-05-11 15:13:33 +08:00
1097068393 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-05-11 14:05:00 +08:00
df88502c3d 光环助手V4.0-前端测试问题汇总(0509)1 https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/849 2020-05-11 14:04:55 +08:00
b8df485a7e 历史安装包列表没包时隐藏下载按钮 2020-05-11 11:41:50 +08:00
a8a66a7b1e 开服日历开服说明支持换行符 2020-05-11 10:47:29 +08:00
a1548faeda 补充从 APK 中读签名公钥的细节 2020-05-11 10:01:22 +08:00
34f452be6e 调整专区空数据占位图位置 2020-05-10 19:24:46 +08:00
bef04854e3 尝试修复从APK文件中读取公钥耗时过长的问题 2020-05-09 21:29:51 +08:00
757782e43b 尝试修复从APK文件中读取公钥耗时过长的问题 2020-05-09 21:11:13 +08:00
8a69f565a3 修复自定义栏目跳转问题 2020-05-09 21:07:27 +08:00
be20d1fec6 尝试修复从APK文件中读取公钥耗时过长的问题 2020-05-09 20:52:35 +08:00
7a71e457ef 历史版本更新的介绍文字调整为最多三行 2020-05-09 20:49:56 +08:00
3af9fa0a10 修复点击下载闪退问题 2020-05-09 18:45:53 +08:00
ff8b3efde9 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-05-09 17:56:45 +08:00
161f63a664 多平台弹窗增加游戏图标展位符 2020-05-09 17:56:38 +08:00
3206e04639 微调自定栏目UI 2020-05-09 17:47:28 +08:00
f1dea0f200 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-05-09 17:39:51 +08:00
d94a83a7c3 修改插件化显示规则 https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/838 (三) 2020-05-09 17:39:40 +08:00
6bbc7104d9 修复在 MIUI 上首页顶部会出现空白区域的问题 2020-05-09 17:10:59 +08:00
a2180196ee Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-05-09 16:51:51 +08:00
a6dc4c7891 暴力处理顶部视频静音问题 2020-05-09 16:51:30 +08:00
fa7355c5c6 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-05-09 15:28:26 +08:00
0140c10f15 20200508测试(1,2,3,4) https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/819 2020-05-09 15:28:12 +08:00
796da0e673 完成游戏详情自定义栏目的0509测试问题 https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/829 2020-05-09 14:43:07 +08:00
743f78096a 光环助手V4.0.0-游戏评论Tab20200509测试问题:1https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/834 2020-05-09 14:38:30 +08:00
52d726b6f3 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-05-09 12:02:24 +08:00
bed4450900 光环助手V4.0.0-游戏评论Tab20200509测试问题:2 https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/834 2020-05-09 12:01:56 +08:00
c2ab369d0c Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-05-09 11:48:51 +08:00
32a7f37b6a 20200508补充规则(1,2,3)https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/838 2020-05-09 11:48:45 +08:00
b299199579 光环助手V4.0.0-游戏详情Tab202200509测试问题1 https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/827 2020-05-09 11:13:27 +08:00
7091ea179d 游戏详情历史版本入口判断 2020-05-09 09:59:54 +08:00
dceb582bb1 游戏详情视频点赞数 2020-05-09 09:03:23 +08:00
6e2e9f7dcf Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-05-08 20:44:23 +08:00
c27025269e 游戏详情视频添加背景 2020-05-08 20:44:01 +08:00
cf1411b412 完成首页弹窗 0508 测试问题 https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/821 2020-05-08 19:03:02 +08:00
b167f5bb8b 完成光环助手V4.0-前端优化汇总(视频相关)20200508评论 https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/842 2020-05-08 18:32:10 +08:00
87d0fd9edb Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-05-08 18:09:06 +08:00
b59a169e10 完成实名认证弹窗20200505补充 https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/847 2020-05-08 18:08:47 +08:00
941e3985b0 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-05-08 16:59:36 +08:00
127fb76c19 尝试修复某些设备出现的下载红点位置异常问题 https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/824 (3) 2020-05-08 16:59:28 +08:00
5f3028f795 完成游戏详情自定义栏目 20200508 测试问题 https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/829 2020-05-08 16:50:35 +08:00
b596f04dba Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-05-08 16:19:53 +08:00
0bb96ecf12 尝试修复下载通知跳转问题 https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/824 (2) 2020-05-08 16:19:38 +08:00
60f21f6113 光环助手V4.0.0-游戏大事件功能20200508测试问题1,2 https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/828 2020-05-08 15:12:13 +08:00
051000e4a8 光环助手V4.0.0-游戏历史版本功能20200508测试问题2 https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/832 2020-05-08 11:47:43 +08:00
14e8020147 游戏详情新增低权重的自定义栏目样式 https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/829 2020-05-07 18:54:10 +08:00
a99b1499a2 微调使用帮助UI 2020-05-07 18:30:04 +08:00
6a1c01556b 微调使用帮助UI 2020-05-07 18:21:22 +08:00
c41327640b [使用帮助]功能升级为[Q&A管理](0507测试3/4)https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/837 2020-05-07 17:10:44 +08:00
7df5834ebc Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-05-07 15:25:17 +08:00
ebafc2f98f 多版本下载面板优化(20200507测试1)https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/819 2020-05-07 15:24:53 +08:00
92c9d81171 视频预加载大小根据设备内存大小决定 2020-05-07 15:04:59 +08:00
7d34a3972d 修复游戏详情简介不显示的问题 2020-05-07 12:11:04 +08:00
90f1254c6c 完成首页UI调整的0430测试 https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/820 2020-05-07 11:57:16 +08:00
8b71d68749 更换答案/文章详情底部分享按钮 2020-05-07 11:37:23 +08:00
17c0cf52b6 修复游戏历史版本功能的部分测试bug https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/832 2020-05-07 11:06:58 +08:00
045be4ff09 游戏详情自定义栏目内容支持富文本 2020-05-07 10:58:06 +08:00
af7948fcb5 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-05-07 10:26:50 +08:00
e1c12d5007 优化游戏详情触摸事件 2020-05-07 10:26:29 +08:00
8676b20fbb 增加试玩开关判断 2020-05-07 10:24:00 +08:00
54db9fb910 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-05-07 10:16:00 +08:00
0eaee1ae63 修复下载弹窗重复弹出问题 2020-05-07 10:15:46 +08:00
e141dfb6b5 修复部分游戏详情自定义栏目的问题 https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/829 2020-05-06 19:02:49 +08:00
b14b8c9f66 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-05-06 18:26:42 +08:00
b4b589f307 光环助手V4.0.0-游戏详情Tab20200506测试1 https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/827 2020-05-06 18:26:21 +08:00
7a74bc0d04 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-05-06 17:59:47 +08:00
b826c0a9ad 移除旧版多平台弹窗相关代码 2020-05-06 17:59:39 +08:00
a197b59200 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-05-06 17:16:36 +08:00
c25503d7f8 设备弹窗逻辑修改 2020-05-06 17:16:15 +08:00
2c0449dcf6 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-05-06 15:43:18 +08:00
59655daa3b MTA事件ID,Q&A改为QA 2020-05-06 15:43:11 +08:00
1c36d7b923 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-05-06 15:22:45 +08:00
a51175620c 光环助手V4.0.0-游戏详情Tab 20200505测试问题4,5,7 https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/827 2020-05-06 15:22:25 +08:00
7b95c265df Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-05-06 15:12:47 +08:00
a11bb9c210 [使用帮助]功能升级为[Q&A管理](0430测试5/7/8)https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/837 2020-05-06 15:12:30 +08:00
72227a5591 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-05-06 14:17:49 +08:00
f9f2eb4c05 光环助手V4.0.0-游戏大事件功能20200501测试问题 https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/828 2020-05-06 14:17:25 +08:00
e9c57df5fb 视频预加载捕抓 OutOfMemoryError 2020-05-06 11:25:52 +08:00
158c47d94b Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-05-06 11:04:54 +08:00
7616435098 开服日历表开服信息弹窗增加滚动条 2020-05-06 11:04:41 +08:00
69443ff457 光环助手V4.0.0-游戏详情数据统计(MTA)20200505测试 https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/846 2020-05-06 10:22:55 +08:00
6a257c0a9f Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-30 18:29:43 +08:00
eddd56e53a 对接游戏详情视频流接口 2020-04-30 18:29:11 +08:00
de6648867b 调整游戏详情的更新栏目和自定义栏目UI https://gitlab.ghzs.com/pm/halo-app-issues/issues/829 2020-04-30 18:22:05 +08:00
567a6ceda5 设备新增/删除/覆盖已安装的应用,接口和loghub都各发送一份数据
https://gitlab.ghzs.com/stats/stats-issues/issues/135
2020-04-30 16:35:04 +08:00
59330bcd7e Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-04-30 16:27:42 +08:00
36803f24bc 修改游戏详情开服日历表相关UI 2020-04-30 16:27:32 +08:00
46458e2667 Merge remote-tracking branch 'origin/dev' into dev 2020-04-30 15:23:23 +08:00
d0aa6e1fe5 字体大小不随系统设置变更 2020-04-30 15:23:13 +08:00
9bef919123 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-04-30 15:22:12 +08:00
88a0603d50 修改数据统计上传格式
https://gitlab.ghzs.com/stats/stats-issues/-/issues/130#note_45881
2020-04-30 15:21:48 +08:00
106dbb3d8d 修改展开更多不流畅 2020-04-30 15:04:57 +08:00
4214d924a4 游戏详情UI优化 2020-04-30 11:18:08 +08:00
c3b40f9264 光环助手V4.0.0-游戏详细信息内容20200429UI测试 https://gitlab.ghzs.com/pm/halo-app-issues/issues/830 2020-04-29 20:42:11 +08:00
69f00626a2 光环助手V4.0.0-游戏评论Tab0429UI测试 https://gitlab.ghzs.com/pm/halo-app-issues/issues/834 2020-04-29 20:32:44 +08:00
c485b1f7f8 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-29 18:26:12 +08:00
7186c73a64 游戏详情专区UI优化 2020-04-29 18:25:47 +08:00
88f9f65fb6 完成自定义栏目UI调整(20200428UI测试) https://gitlab.ghzs.com/pm/halo-app-issues/issues/829 2020-04-29 18:19:13 +08:00
714573ec6b Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-04-29 17:54:14 +08:00
a979445ffc 多平台下载弹窗安装/卸载后即时刷新数据 2020-04-29 17:54:00 +08:00
3cf38eb3fc Merge remote-tracking branch 'origin/dev' into dev 2020-04-29 17:19:59 +08:00
94ceca35bf 提前 Loghub 初始化避免提交时的异常 2020-04-29 17:19:47 +08:00
2bd4eb2004 修复首页游戏替换的逻辑错误 2020-04-29 17:19:10 +08:00
355e71e620 修改编辑问题的标题显示规则 2020-04-29 17:19:09 +08:00
7d9520d97b 修改游戏详情下载进度条UI 2020-04-29 17:11:24 +08:00
ce0957cea7 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-04-29 16:29:09 +08:00
c93169fe97 游戏详情开服日历表更改数据来源 2020-04-29 16:29:01 +08:00
485dd96e93 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-29 16:01:42 +08:00
9b0f0892ff 光环助手V4.0-前端优化汇总(视频相关)11-13 https://gitlab.ghzs.com/pm/halo-app-issues/issues/842 2020-04-29 16:01:18 +08:00
9a04f3ae38 调整首页间距,修复首页下拉刷新无法替换已安装游戏的问题 2020-04-29 15:53:12 +08:00
968d668afa 处理Loghub数据包裹问题 2020-04-29 15:22:38 +08:00
85d19ed2bd 修复回答数同步异常问题 2020-04-29 15:10:48 +08:00
28e490f8d4 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-29 11:23:08 +08:00
298ae7f657 光环助手V4.0.0-游戏详情Tab0428UI测试 https://gitlab.ghzs.com/pm/halo-app-issues/issues/827 2020-04-29 11:22:46 +08:00
d50f29b3dc 修复游戏详情自定义栏目行数设置为0会闪退的问题 2020-04-29 10:00:40 +08:00
f167eff21c Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-04-28 18:57:58 +08:00
69d4f00807 [使用帮助]功能升级为[Q&A管理] (二)https://gitlab.ghzs.com/pm/halo-app-issues/issues/837 2020-04-28 18:57:37 +08:00
904dc4fe2e 光环助手V4.0.0-游戏详细信息内容20200428测试问题 https://gitlab.ghzs.com/pm/halo-app-issues/issues/830 2020-04-28 17:59:00 +08:00
c870cc683d Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-28 15:00:23 +08:00
deb29fd2e4 去掉首页tab按下时状态 2020-04-28 14:59:50 +08:00
19f1bc947a 前台服务的通知 ID 改为 1 2020-04-28 14:33:20 +08:00
60d1b47c66 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-28 11:41:01 +08:00
d67b845dfd 光环助手V4.0.0-游戏评论Tab0427测试问题:1-4 https://gitlab.ghzs.com/pm/halo-app-issues/issues/834 2020-04-28 11:40:37 +08:00
6f1c7c7ded Merge remote-tracking branch 'origin/dev' into dev 2020-04-27 20:39:19 +08:00
46e9118d73 光环助手V4.0-前端优化汇总(视频相关)10 https://gitlab.ghzs.com/pm/halo-app-issues/issues/842 2020-04-27 20:05:30 +08:00
8aa1557b7a 调整首页分割线粗细 2020-04-27 18:26:08 +08:00
6058c3f8c1 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-27 18:23:51 +08:00
d409e6f2a9 游戏详情ui优化 2020-04-27 18:23:19 +08:00
a4d272c556 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-04-27 18:10:48 +08:00
911d7c04ec 处理Loghub数据包裹问题 2020-04-27 18:10:41 +08:00
afc379d449 完成游戏历史版本功能 https://gitlab.ghzs.com/pm/halo-app-issues/issues/832 2020-04-27 17:05:11 +08:00
18feca49e2 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-04-27 16:45:19 +08:00
792b19d40d 多版本下载面板优化(UI测试问题补充)https://gitlab.ghzs.com/pm/halo-app-issues/issues/819 2020-04-27 16:44:29 +08:00
108d05edea 20200426补充4 https://gitlab.ghzs.com/pm/halo-app-issues/issues/833 2020-04-27 16:06:56 +08:00
d8882da17b 去掉游戏详情横向列表滑动padding 2020-04-27 15:55:22 +08:00
f120dfda15 修复游戏详情文字展开按钮换行时的错位问题 2020-04-27 15:23:03 +08:00
dd60ed7abd Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-27 14:53:13 +08:00
d0b478c743 添加游戏详情展开遮罩 2020-04-27 14:52:50 +08:00
defe69ba18 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-04-27 14:26:34 +08:00
32d748efae 多版本下载面板优化(三)https://gitlab.ghzs.com/pm/halo-app-issues/issues/819 2020-04-27 14:26:12 +08:00
f194dc9bf6 20200426测试问题 https://gitlab.ghzs.com/pm/halo-app-issues/issues/826 2020-04-27 11:53:41 +08:00
075fbd77b2 完成游戏详情的展开按钮遮罩效果 2020-04-27 11:17:17 +08:00
edb3e3713a Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-27 10:45:51 +08:00
c70648e038 更换评论标签样式 2020-04-27 10:45:26 +08:00
966f4ee57d Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-04-26 17:14:13 +08:00
f90ced4c31 下载弹窗扩大手势拖拽关闭区域 2020-04-26 17:14:04 +08:00
6bda4d80bf 自定义栏目MTA数据统计 2020-04-26 16:53:36 +08:00
3ecb6b30c9 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev
# Conflicts:
#	app/src/main/java/com/gh/gamecenter/gamedetail/desc/DescAdapter.kt
2020-04-26 16:39:34 +08:00
3c337b618c 光环助手V4.0.0-游戏详情数据统计(MTA)https://gitlab.ghzs.com/pm/halo-app-issues/issues/846 2020-04-26 16:36:53 +08:00
40a90bbcfa 完成游戏详情自定义栏目的UI https://gitlab.ghzs.com/pm/halo-app-issues/issues/829 2020-04-26 16:09:04 +08:00
e54b124252 完成游戏详情自定义栏目的UI https://gitlab.ghzs.com/pm/halo-app-issues/issues/829 2020-04-26 16:07:05 +08:00
18923efe23 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-04-26 15:39:22 +08:00
5c5ad63cc6 多版本下载面板优化(UI测试问题汇总) https://gitlab.ghzs.com/pm/halo-app-issues/issues/819 2020-04-26 15:39:10 +08:00
d5fd444ae5 优化游戏详情视频UI 2020-04-26 11:09:06 +08:00
4a22f70e30 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-04-26 11:03:20 +08:00
9805bd4caa 修改图片压缩格式(防止部分Webp图片无法缩放) 2020-04-26 11:03:00 +08:00
0690f13bea 处理游戏详情标签显示不全和切换状态栏颜色 2020-04-26 09:43:23 +08:00
da8faea4c8 处理视频流顶部标题小红点显示问题 2020-04-26 09:27:57 +08:00
ff927bab09 调整游戏详情自定义栏目的部分UI https://gitlab.ghzs.com/pm/halo-app-issues/issues/829 2020-04-24 18:28:29 +08:00
e3e5def3b6 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-24 18:00:39 +08:00
ba246585ad 完成游戏大事件(后台无数据还未测试) 2020-04-24 18:00:11 +08:00
f242a6a3bc Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-04-24 17:21:34 +08:00
0c89e76b39 光环前端优化汇总(2020年4月第3周) (3)https://gitlab.ghzs.com/pm/halo-app-issues/issues/845 2020-04-24 17:21:23 +08:00
1fa82e72f1 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-24 16:10:38 +08:00
b4e6b04e47 完成实名认证弹窗 https://gitlab.ghzs.com/pm/halo-app-issues/issues/847 2020-04-24 16:10:21 +08:00
002f824f5c 光环前端优化汇总(2020年4月第1周) (4.5)https://gitlab.ghzs.com/pm/halo-app-issues/issues/824 2020-04-24 15:45:25 +08:00
1aaf7f8de1 修复下载多平台弹窗合集和链接Item内容无法显示问题 2020-04-24 15:14:34 +08:00
82ba19842c Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-04-24 14:20:06 +08:00
32ed1bf622 修改游戏开服日历表反馈跳转 2020-04-24 14:19:50 +08:00
0d4838c536 修改退出登录我的光环未恢复默认页面 2020-04-24 11:18:16 +08:00
11527b46f9 版权说明时间换成服务器时间 2020-04-24 09:58:20 +08:00
20c1957b59 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-23 17:57:45 +08:00
ed2630e016 光环助手V4.0.0-游戏详情数据统计(MTA)2-8 https://gitlab.ghzs.com/pm/halo-app-issues/issues/846 2020-04-23 17:57:21 +08:00
8cc2ac2cad 转换光环用户按照app列表数据的埋点方式 https://gitlab.ghzs.com/stats/stats-issues/issues/135 2020-04-23 17:50:41 +08:00
37745ca548 1.转换下载(旧)及相关数据的埋点方式 https://gitlab.ghzs.com/stats/stats-issues/issues/130
2.移除DataService相关代码
 - 相关接口部分移到ApiService部分用LogHub代替
2020-04-23 17:24:47 +08:00
29edcdca4b Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-04-23 11:25:16 +08:00
92669d6974 光环前端优化汇总(2020年4月第3周)(8.9)https://gitlab.ghzs.com/pm/halo-app-issues/issues/845 2020-04-23 11:24:49 +08:00
351a64f592 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-22 18:55:19 +08:00
a29e56543b 实名认证弹窗(未完) 2020-04-22 18:55:05 +08:00
6db3e8c671 完成部分粗糙的游戏详情自定义栏目UI(暂毫无细节) https://gitlab.ghzs.com/pm/halo-app-issues/issues/829 2020-04-22 18:21:36 +08:00
20c4d24698 正式环境接口切换到 4.0.0 2020-04-22 18:18:45 +08:00
114e185bcb Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-04-22 18:14:57 +08:00
a293bff964 光环助手V4.0.0-游戏开服信息内容(三)https://gitlab.ghzs.com/pm/halo-app-issues/issues/831 2020-04-22 18:14:44 +08:00
98b4d9f95d Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-22 09:37:02 +08:00
8489e87586 光环前端优化汇总(2020年4月第3周)4-6 https://gitlab.ghzs.com/pm/halo-app-issues/issues/845 2020-04-22 09:36:36 +08:00
6f7ee2179d 修复编译失败问题 2020-04-22 09:23:00 +08:00
ea6b442a48 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-04-21 18:35:28 +08:00
12d26edd76 光环助手V4.0.0-游戏开服信息内容(三)https://gitlab.ghzs.com/pm/halo-app-issues/issues/831 2020-04-21 18:35:14 +08:00
27053eecd7 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-21 18:31:50 +08:00
151d5b9c1f 游戏详情评论点赞按钮已点赞显示 2020-04-21 18:31:30 +08:00
d35c558658 完成首页弹窗优化 https://gitlab.ghzs.com/pm/halo-app-issues/issues/821 2020-04-21 18:23:05 +08:00
baa4dc7a23 完成个人主页-玩过的游戏&我的游戏-玩过整体优化 https://gitlab.ghzs.com/pm/halo-app-issues/issues/839 2020-04-21 18:09:00 +08:00
9b565c32d1 修改开服时间显示 2020-04-21 17:25:53 +08:00
243dd26d73 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-21 16:11:36 +08:00
263234fecb 光环助手V4.0.0-游戏评论Tab https://gitlab.ghzs.com/pm/halo-app-issues/issues/834 2020-04-21 16:11:14 +08:00
0ba598ee67 删除无用代码,临时修复下载插件化判断错误问题 2020-04-21 10:25:42 +08:00
29430b9967 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-04-20 18:38:29 +08:00
2038b16dce 修改下载按钮样式 2020-04-20 18:38:12 +08:00
9ea793397b 光环助手V4.0-前端优化汇总(视频相关)1-3,5,6,7 https://gitlab.ghzs.com/pm/halo-app-issues/issues/842 2020-04-20 18:26:41 +08:00
6061938129 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-20 12:35:43 +08:00
62277aa525 光环前端优化汇总(2020年4月第3周)5 https://gitlab.ghzs.com/pm/halo-app-issues/issues/845 2020-04-20 12:35:22 +08:00
1c118b06c9 Merge remote-tracking branch 'origin/dev' into dev 2020-04-20 12:16:15 +08:00
a41c315e36 修复打包异常 2020-04-20 12:11:07 +08:00
40576e0012 光环前端优化汇总(2020年4月第3周)1,4 https://gitlab.ghzs.com/pm/halo-app-issues/issues/845 2020-04-20 11:58:12 +08:00
a582db52f4 游戏详情实体添加@Keep注解 2020-04-20 11:12:18 +08:00
cb2656ad85 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-19 17:59:19 +08:00
da1c686d42 尝试解决长时间处于后台视频流页面控件为空的问题 2020-04-19 17:58:41 +08:00
b613fe2ba0 修复由于延迟问答tab和我的光环tab加载引起的问题 2020-04-19 17:00:52 +08:00
83e29b1cf3 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-17 18:56:04 +08:00
5bbd23bf33 游戏详情游戏详细信息显示问题 2020-04-17 18:55:59 +08:00
9f69b83b51 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev
# Conflicts:
#	app/src/main/java/com/gh/common/util/GameUtils.java
2020-04-17 18:54:13 +08:00
4f77781e24 下载按钮状态优化(三) https://gitlab.ghzs.com/pm/halo-app-issues/issues/838 2020-04-17 18:50:28 +08:00
b23d589a29 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-17 17:49:33 +08:00
7f16a69301 完成游戏详情专区tab https://gitlab.ghzs.com/pm/halo-app-issues/issues/833 2020-04-17 17:49:08 +08:00
006da73737 基本完成游戏历史版本功能(部分UI细节待完善) https://gitlab.ghzs.com/pm/halo-app-issues/issues/832 2020-04-17 17:44:47 +08:00
3f998cdf75 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-17 16:38:13 +08:00
3e94cd9d8c 下载按钮状态优化(一,二) https://gitlab.ghzs.com/pm/halo-app-issues/issues/838 2020-04-17 16:38:06 +08:00
5922f92caf 游戏详情详细信息,版本求更新 https://gitlab.ghzs.com/pm/halo-app-issues/issues/830 2020-04-17 11:11:19 +08:00
f5f5909fde Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-16 19:00:58 +08:00
7e67357887 多版本下载面板UI跳转 2020-04-16 19:00:49 +08:00
d5750c6cb8 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-16 18:59:35 +08:00
b2983d5c96 游戏详情专区支持显示webview页面 2020-04-16 18:59:30 +08:00
5a19e46d26 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-16 18:44:04 +08:00
8456a5a1d6 多版本下载面板增加"其它版本"跳转按钮 2020-04-16 18:43:51 +08:00
b9329a092e 大致完成游戏详情详情tab(除自定义栏目) 2020-04-16 18:20:05 +08:00
6ecad9eebd Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-16 15:45:52 +08:00
f32dd9efee 多版本下载面板优化(添加相关交互动画) https://gitlab.ghzs.com/pm/halo-app-issues/issues/819 2020-04-16 15:45:44 +08:00
48cbaf03b7 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-15 18:57:51 +08:00
7f23cda97a 对接游戏详情数据(未完) 2020-04-15 18:57:46 +08:00
49c1809aa2 多版本下载面板优化(增加链接弹窗) https://gitlab.ghzs.com/pm/halo-app-issues/issues/819 2020-04-15 17:45:57 +08:00
173aa82134 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-15 15:49:01 +08:00
c57e8b2c76 多版本下载面板优化(细节补充) https://gitlab.ghzs.com/pm/halo-app-issues/issues/819 2020-04-15 15:48:35 +08:00
bb741013d4 Merge remote-tracking branch 'origin/dev' into dev 2020-04-15 10:33:21 +08:00
5b014a5a1d 更正版块曝光路径 https://gitlab.ghzs.com/pm/halo-app-issues/issues/843 2020-04-15 10:33:12 +08:00
a85548ac33 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-14 19:15:16 +08:00
77e689fec4 游戏详情UI 2020-04-14 19:15:11 +08:00
fe942dcf73 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
2020-04-14 19:14:49 +08:00
da3b700403 多版本下载面板优化(合计页面基本完成)https://gitlab.ghzs.com/pm/halo-app-issues/issues/819 2020-04-14 19:13:57 +08:00
fcd46cb2ea 延迟加载我的光环 (部分问题后续处理 2020-04-14 12:10:01 +08:00
e918b19e2e 延迟渲染问答tab 2020-04-13 20:48:14 +08:00
afb8badc74 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-13 19:10:12 +08:00
4e22a5c7bb 游戏详情UI 2020-04-13 19:10:08 +08:00
b5d2e02606 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-13 18:57:32 +08:00
28afb4f14c 多版本下载面板优化(一级页面基本完成)https://gitlab.ghzs.com/pm/halo-app-issues/issues/819 2020-04-13 18:57:17 +08:00
165659a664 Merge branch 'optimise-startup' into 'dev'
Optimise startup

See merge request !14
2020-04-13 17:16:26 +08:00
7b3d910b10 优化首页启动速度 https://gitlab.ghzs.com/pm/halo-app-issues/issues/820 2020-04-13 17:12:12 +08:00
1e4a85719a Merge branch '3.7.5-bugfix' into 'dev'
3.7.5 bugfix

See merge request !13
2020-04-13 15:16:49 +08:00
4269cb37d2 Merge branch 'dev' into '3.7.5-bugfix'
# Conflicts:
#   dependencies.gradle
2020-04-13 15:16:32 +08:00
b7ce3e8c20 延迟初始化部分变量 2020-04-13 12:29:54 +08:00
15a0240808 游戏详情(未完) 2020-04-12 16:29:22 +08:00
0aa68ea04b Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-04-10 19:03:44 +08:00
2d9b69fd1e 重新整理检查是否可以更新/插件化的方法 2020-04-10 19:03:37 +08:00
48d6023e0d 游戏下载弹窗:试玩提醒与设备提醒 20200409补充 https://gitlab.ghzs.com/pm/halo-app-issues/issues/818 2020-04-10 17:20:57 +08:00
113ebb36e9 tinker_base-3.7.6 2020-04-10 14:12:30 +08:00
d0c9bd8038 Merge branch '3.7.5-bugfix' of gitlab.ghzhushou.com:halo/assistant-android into 3.7.5-bugfix 2020-04-10 13:50:54 +08:00
104586fb7f 版本号改为 3.7.6 2020-04-10 13:50:24 +08:00
0612582a46 支持应用内/外跳转社区专题 2020-04-10 11:34:05 +08:00
1bc5bb3ef6 tinker_base-3.7.5 2020-04-10 11:26:12 +08:00
a3d0d91dd7 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-09 21:52:06 +08:00
982e8f67bf 游戏详情顶部区域UI 2020-04-09 21:51:41 +08:00
0bb871bff2 完成首页轮播图优化 https://gitlab.ghzs.com/pm/halo-app-issues/issues/820 2020-04-09 17:41:10 +08:00
0eb43d6552 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-04-09 17:24:42 +08:00
b4f29f4856 多版本下载面板优化(Item的数据填充)https://gitlab.ghzs.com/pm/halo-app-issues/issues/819 2020-04-09 17:24:20 +08:00
2719bff65f 修改视频分享统计问题 2020-04-09 14:23:21 +08:00
4fd68565d2 更换游戏详情标题栏icon 2020-04-09 11:12:11 +08:00
b87972143d 修复搜索页可能的闪退问题 2020-04-09 11:01:15 +08:00
8241551438 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-09 10:42:04 +08:00
d7bb45f287 光环前端优化汇总(2020年4月第1周)11 https://gitlab.ghzs.com/pm/halo-app-issues/issues/824 2020-04-09 10:41:28 +08:00
0cdec2a226 捕抓自动安装闪退 2020-04-09 10:25:28 +08:00
dbb3078300 版本号改为 4.0.0 2020-04-09 10:07:35 +08:00
545c235b24 修复游戏详情页因修复 bundle 过大而造成的页面重构闪退 2020-04-08 18:52:03 +08:00
53d3cb320b 提前 downloadService startForeground 操作避免部分设备初始化闪退 2020-04-08 18:50:09 +08:00
38682f01a8 升级 appcompat 依赖避免在5.1设备上webview闪退 2020-04-08 18:49:04 +08:00
a7d141efcc Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-04-08 18:25:06 +08:00
31c404021c 多版本下载面板优化(初步完成UI相关)https://gitlab.ghzs.com/pm/halo-app-issues/issues/819 2020-04-08 18:24:48 +08:00
631cec2fc6 游戏详情顶部区域 2020-04-08 17:51:07 +08:00
13a76e8de7 Merge branch '3.7.5-bugfix' of gitlab.ghzhushou.com:halo/assistant-android into 3.7.5-bugfix 2020-04-08 12:39:57 +08:00
1e98fa98c3 增加应用内 webview 返回应用版本号的方法 2020-04-08 12:39:23 +08:00
be6eab0cae 首页专题支持游戏替换 https://gitlab.ghzs.com/pm/halo-app-issues/issues/820 2020-04-08 11:36:28 +08:00
71ee8bfd29 Merge remote-tracking branch 'origin/dev' into dev 2020-04-07 18:23:32 +08:00
66c9c02dc6 完成游戏大图UI优化 https://gitlab.ghzs.com/pm/halo-app-issues/issues/820 2020-04-07 18:23:21 +08:00
7880ee4aef 游戏详情Tab位置调整 2020-04-07 18:19:16 +08:00
6274d1f778 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-04-07 11:55:37 +08:00
5e98813f92 顶部Tab栏统一样式(补充:开服表)https://gitlab.ghzs.com/pm/halo-app-issues/issues/825 2020-04-07 11:55:21 +08:00
1a30800fb4 光环前端优化汇总(2020年4月第1周)9,10 https://gitlab.ghzs.com/pm/halo-app-issues/issues/824 2020-04-07 10:47:00 +08:00
454e6933f4 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-06 17:51:19 +08:00
e3072071b7 完成游戏设备弹窗 https://gitlab.ghzs.com/pm/halo-app-issues/issues/818 2020-04-06 17:50:57 +08:00
83a88326f0 完成光环前端优化汇总(4月第1周)8 https://gitlab.ghzs.com/pm/halo-app-issues/issues/824 2020-04-06 10:36:19 +08:00
27109a810f Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-06 10:20:26 +08:00
3d5bd424c5 游戏下载弹窗:试玩提醒 https://gitlab.ghzs.com/pm/halo-app-issues/issues/818 2020-04-06 10:20:02 +08:00
c7cd56e7be 完成光环前端优化汇总(4月第1周)的7,8,12 https://gitlab.ghzs.com/pm/halo-app-issues/issues/824 2020-04-06 10:05:17 +08:00
860769c44a 删除无用代码 2020-04-04 18:25:37 +08:00
a83761b88d 顶部Tab栏统一样式(除了开服表,其它的已完成)https://gitlab.ghzs.com/pm/halo-app-issues/issues/825 2020-04-04 18:11:53 +08:00
a79fc9c0b1 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-02 18:33:56 +08:00
877bd63d9d add DownloadDialog 2020-04-02 18:33:48 +08:00
bb9d0582c4 修改游戏试玩弹窗 2020-04-02 17:46:55 +08:00
df7e89e7e4 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-02 16:45:54 +08:00
a12593ea51 游戏试玩弹窗 https://gitlab.ghzs.com/pm/halo-app-issues/issues/818 2020-04-02 16:45:16 +08:00
5ca0af4285 关闭TooLargeTool 2020-04-02 15:55:59 +08:00
20bc38add4 视频流播放错误重试一次 2020-04-02 15:00:07 +08:00
89e72a0fea 下载按钮状态新增“试玩”(未完) 2020-04-02 14:13:02 +08:00
efabaafa38 20200402正式环境测试2 https://gitlab.ghzs.com/pm/halo-app-issues/issues/817 2020-04-02 11:04:10 +08:00
fc25ad7ddb Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-02 10:27:25 +08:00
6b656cf446 add todo 2020-04-02 10:27:06 +08:00
26927661e7 修改视频流banner 2020-04-02 09:40:32 +08:00
15ba945751 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-01 16:44:31 +08:00
8e0527b777 尝试修复SyncPage快速添加/删除时数据无法同步问题 2020-04-01 16:44:21 +08:00
b9dfa0a8a9 视频流静音按钮增加防抖判断 2020-04-01 16:30:32 +08:00
c462973eb6 修复"问答-推荐精选"文章不能点赞问题 2020-04-01 15:29:21 +08:00
b8cefd69c0 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-01 11:56:04 +08:00
1c1537be8a 尝试修改滑动视频不播放问题 2020-04-01 11:55:57 +08:00
1dad632c70 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-01 11:49:24 +08:00
41600c7576 光环助手V3.7.5-前端测试问题汇总(0331)(1.4) https://gitlab.ghzs.com/pm/halo-app-issues/issues/817 2020-04-01 11:45:06 +08:00
5f0074c88d Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-01 10:09:48 +08:00
907f2a2678 修改视频分享按钮动画 2020-04-01 10:09:28 +08:00
4a118bd51c 修复客服页面没授予权限选图片会闪退的问题 2020-04-01 10:08:21 +08:00
4919b46e5d Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-04-01 09:44:52 +08:00
034a6662f9 修复WebFragment JavascriptObject命名空间冲突问题 2020-04-01 09:44:38 +08:00
3fb1c9f315 视频流分享复制链接分享次数也+1 2020-03-31 17:14:42 +08:00
aed4610afd WebFragment分享文案改为Web端控制 2020-03-31 16:48:37 +08:00
345be8035a WebFragment分享文案改为Web端控制 2020-03-31 16:30:03 +08:00
68c7b0ddaf 正式环境改为3.7.5 2020-03-31 10:00:27 +08:00
f39ce00152 20200331测试:1 https://gitlab.ghzs.com/pm/halo-app-issues/issues/801 2020-03-31 09:51:48 +08:00
0b6d1bd6df Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-03-30 16:57:08 +08:00
dca7a44884 修复游戏详情由于Bundle的数据内容过大导致的闪退
引入TooLargeTool库(监控Bundle大小)
2020-03-30 16:56:47 +08:00
d90cdf341e 处理切换tab视频页面闪烁 2020-03-30 11:40:11 +08:00
7828189ea0 update LGLibrary version 2020-03-29 12:49:11 +08:00
e4cd8da65c 修复一下闪退问题 2020-03-29 12:36:39 +08:00
8cebbd3bbe Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-03-27 17:47:39 +08:00
63d9b354d4 update sync page 2020-03-27 17:47:26 +08:00
254944fbfc Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-03-27 16:56:57 +08:00
ec93080190 20200327测试1,2,4 https://gitlab.ghzs.com/pm/halo-app-issues/issues/801 2020-03-27 16:56:36 +08:00
ec638cb231 资讯文章详情播放视频增加MTA事件 2020-03-27 16:45:34 +08:00
7c72623f90 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-03-27 15:52:23 +08:00
2e58404e01 资讯文章详情播放视频由在Web页面改为在App视频详情播放 2020-03-27 15:52:10 +08:00
5eae896330 光环助手V3.7.5-视频详情UI优化2(2) https://gitlab.ghzs.com/pm/halo-app-issues/issues/801 2020-03-27 14:51:37 +08:00
6c2dcc7d37 回退视频流游戏名字颜色值 2020-03-27 11:54:33 +08:00
d40e4e97c1 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-03-27 11:48:03 +08:00
3164ed1b0e 修改SwitchButton样式 2020-03-27 11:47:48 +08:00
b49fae0384 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-03-27 11:43:47 +08:00
80544aff32 0326测试补充2(1),4,6 https://gitlab.ghzs.com/pm/halo-app-issues/issues/801 2020-03-27 11:43:25 +08:00
64235951c2 修复游戏详情回答点赞数量不准确问题 2020-03-27 10:40:33 +08:00
f08fe7d855 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-03-26 22:08:20 +08:00
ff1a9e8694 update sync page 2020-03-26 22:07:59 +08:00
2abf87628a Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-03-26 18:53:18 +08:00
e835482abd 0326测试补充1,3,5,8 https://gitlab.ghzs.com/pm/halo-app-issues/issues/801 2020-03-26 18:52:54 +08:00
e78882e911 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-03-26 18:33:50 +08:00
b021d99f78 RichEditor添加javascript提交Mta事件的接口 2020-03-26 18:33:33 +08:00
084781dc0a jenkins 打包脚本添加错误重试 2020-03-26 18:21:11 +08:00
ce83fed40d Merge branch '3.7.4-bugfix-again' into 'dev'
3.7.4 bugfix again

See merge request !12
2020-03-26 17:49:28 +08:00
24d16a234f Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-03-26 17:29:58 +08:00
536af50a4f 光环助手V3.7.5-视频功能优化(上传视频)0326测试:2 https://gitlab.ghzs.com/pm/halo-app-issues/issues/808 2020-03-26 17:29:42 +08:00
9eccc459d9 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-03-26 17:03:41 +08:00
6e8310e4c9 添加浏览器跳转视频流协议并对接活动视频接口 2020-03-26 17:03:20 +08:00
35e79f938c 微调资讯文章详情UI 2020-03-26 15:53:31 +08:00
10764ac3f4 RichEditor添加显示Dialog/获取数据/存储数据接口 2020-03-26 15:35:27 +08:00
2a6ecfa176 修改获取上传配置的链接参数 2020-03-25 16:31:31 +08:00
5b44c7f856 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-03-25 15:01:11 +08:00
1e5e36a8c7 社区文章/回答列表执行点赞/评论操作后即时刷新列表数据 2020-03-25 15:00:57 +08:00
92dda8e64c 修复应用外跳转只能跳一次的问题 https://gitlab.ghzs.com/pm/halo-app-issues/issues/812 2020-03-25 10:38:18 +08:00
27488e8084 Merge branch 'sync_page_data' 2020-03-24 16:49:39 +08:00
72871e55c6 数据同步模块基本完成 2020-03-24 15:28:19 +08:00
07c05b2191 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-03-24 11:33:24 +08:00
89d2fb98fa 修改问题列表的跳转规则 2020-03-24 11:33:09 +08:00
6d1719b877 处理闪退异常 2020-03-24 10:51:00 +08:00
51599d5bb4 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-03-24 10:46:28 +08:00
aedaee8d3a 光环助手V3.7.5-视频功能优化(上传视频)(2.5) https://gitlab.ghzs.com/pm/halo-app-issues/issues/808 2020-03-24 10:46:02 +08:00
82a859e820 tinker-base-3.7.4-bugfix 2020-03-24 10:40:08 +08:00
c1c655fcb0 完成光环前端优化汇总(3月第3周)的1,2 https://gitlab.ghzs.com/pm/halo-app-issues/issues/812 2020-03-23 18:47:34 +08:00
fabcce9a6c 删除无用代码 2020-03-23 18:14:26 +08:00
16feb963f6 光环前端优化汇总(2020年3月第3周)(3.7.10.12) https://gitlab.ghzs.com/pm/halo-app-issues/issues/812 2020-03-23 18:12:22 +08:00
c7db58f6ea 处理一些闪退异常 2020-03-23 15:18:27 +08:00
79ff887375 修复一些闪退问题 2020-03-23 13:35:46 +08:00
e7ae608986 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-03-23 13:12:21 +08:00
7ec4625d45 RichEditor添加视频库以支持在Web页面直接播放视频 2020-03-23 13:11:50 +08:00
4f68f30576 修复玩过的游戏统计异常 2020-03-23 11:27:37 +08:00
135d717715 光环前端优化汇总(2020年3月第3周)5,6 https://gitlab.ghzs.com/pm/halo-app-issues/issues/812 2020-03-23 10:31:08 +08:00
77c3131a69 Merge branch '3.7.4-bugfix' into 'dev'
3.7.4 bugfix

See merge request !11
2020-03-20 16:35:34 +08:00
7e74cbfbd1 Merge branch 'dev' into '3.7.4-bugfix'
# Conflicts:
#   app/src/main/java/com/gh/gamecenter/help/HelpContentAdapter.kt
2020-03-20 16:35:20 +08:00
a2cd548d1e Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-03-20 15:56:23 +08:00
0a4d6122df 尝试解决exo内核播放完毕不回调问题 2020-03-20 15:56:17 +08:00
23d1435ed2 修复一些闪退问题 2020-03-20 15:31:28 +08:00
dd60900bcb Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-03-20 10:34:13 +08:00
0fbb0aa363 修改AppManager的activity出栈方式,以修复Activity销毁后会自动退出App的问题 2020-03-20 10:33:49 +08:00
23539b9316 视频详情徽章显示问题 2020-03-19 18:23:09 +08:00
a1460b07c6 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-03-19 17:45:03 +08:00
02b6c2733b 修复一些闪退问题 2020-03-19 17:44:47 +08:00
1d29d68aa2 解决进入首页视频流未选中的tab页面播放视频 2020-03-19 15:23:07 +08:00
aa76a20065 完成视频流广告 2020-03-19 10:43:56 +08:00
0683a579c0 tinker_base 3.7.4 2020-03-18 19:21:45 +08:00
f1194d434b 帮助与反馈拼接标题 2020-03-18 18:21:10 +08:00
ec945919ba 广告banner添加indicator 2020-03-18 18:09:08 +08:00
e626e82945 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-03-18 17:26:31 +08:00
6e238379f2 播放界面UI优化 2020-03-18 17:26:26 +08:00
7a4ae83a2b 光环助手V3.7.5-视频功能优化(上传视频)(1) https://gitlab.ghzs.com/pm/halo-app-issues/issues/808 2020-03-18 17:00:21 +08:00
46827b1489 光环前端优化汇总(2020年3月第2周)(11) https://gitlab.ghzs.com/pm/halo-app-issues/issues/805 2020-03-18 15:56:29 +08:00
59e80970ae tinker_base 3.7.4 2020-03-18 14:36:31 +08:00
762897521b 光环助手V3.7.5-视频数据相关 https://gitlab.ghzs.com/pm/halo-app-issues/issues/809 2020-03-18 14:25:09 +08:00
b8d74357b5 显示版本号改为 3.7.5 2020-03-18 10:31:28 +08:00
21c116ea5b 完成前端优化汇总(3月第2周)的第4点 https://gitlab.ghzs.com/pm/halo-app-issues/issues/805 2020-03-18 10:30:49 +08:00
2cf23b9a32 对接最新Tab视频流接口 2020-03-17 17:24:27 +08:00
92a0d77885 光环助手V3.7.4-测试问题汇总(20200311-1900)10 https://gitlab.ghzs.com/pm/halo-app-issues/issues/797 2020-03-17 16:07:35 +08:00
1bc0b0e085 tinker_base 3.7.4 2020-03-17 09:57:08 +08:00
6b03098ac7 Merge branch 'upgrade_dependencies' into dev
# Conflicts:
#	dependencies.gradle
2020-03-17 09:55:41 +08:00
bcd846024e 视频流分享统计 2020-03-17 09:53:49 +08:00
d98edc8f77 光环前端优化汇总(2020年3月第2周)8 https://gitlab.ghzs.com/pm/halo-app-issues/issues/805 2020-03-17 09:20:47 +08:00
a5129c809b 完成复刻工具箱礼包码跳转游戏详情礼包项的需求 https://gitlab.ghzs.com/pm/halo-app-issues/issues/807 2020-03-16 21:12:40 +08:00
3e8e5572d2 修复未登录状态下游戏详情动态 tab 的礼包不显示领取按钮的问题 2020-03-16 21:06:26 +08:00
faef2a5e4d 使用帮助Web页面避免缩放 2020-03-16 18:18:01 +08:00
3d88792d11 视频流广告banner 2020-03-16 16:54:46 +08:00
862b66f8e7 回退启动页更改(在全屏下拉伸比较严重,无奈~) 2020-03-16 15:25:32 +08:00
f7fe7a5153 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-03-15 19:16:05 +08:00
9aeb1624a6 修改视频流详情UI(未完) 2020-03-15 19:15:42 +08:00
15fad5635b 避免原因未知的闪退 2020-03-13 19:04:00 +08:00
ec9c282618 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-03-13 16:59:04 +08:00
7e1da213d5 光环前端优化汇总(2020年3月第2周)(7.9.10)https://gitlab.ghzs.com/pm/halo-app-issues/issues/805 2020-03-13 16:58:47 +08:00
8d9fd482b9 视频流增加最新Tab 2020-03-13 16:28:47 +08:00
bddde8c851 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-03-12 16:28:06 +08:00
b589c38eea 尝试修复启动图适配问题 2020-03-12 16:27:47 +08:00
5c3cdf227e 解决第一次滑动视频闪退 2020-03-12 16:27:29 +08:00
838b775a3e 光环助手V3.7.4-测试问题汇总(20200311-1900)3,4 https://gitlab.ghzs.com/pm/halo-app-issues/issues/797 2020-03-12 15:52:19 +08:00
c87bf1e613 update 2020-03-12 14:19:45 +08:00
81dc17530f update 2020-03-11 17:56:10 +08:00
7af2b7c2d7 api版本改为3.7.4
修改社区问题的点击效果
2020-03-11 17:33:49 +08:00
b53f769a0d update 2020-03-11 17:22:44 +08:00
f78570ce80 答案/文章富文本编辑框添加meta避免缩放 2020-03-11 15:56:27 +08:00
071376267a 修复点击动态页进入问答的闪退问题 2020-03-11 15:55:04 +08:00
51c3d25f3a 调整 Entity 命名 2020-03-11 11:44:20 +08:00
cc6c31027a 修复进入已关注游戏的游戏详情不会自动切换到动态tab的问题 https://gitlab.ghzs.com/pm/halo-app-issues/issues/783 2020-03-11 11:24:54 +08:00
f3b91b63ec 完成游戏详情加载优化(将接口分为用户相关和用户不相关两部分) https://gitlab.ghzs.com/pm/halo-app-issues/issues/783 2020-03-10 21:30:36 +08:00
aadd2071b9 update 2020-03-10 18:16:44 +08:00
fc7566d2c9 整理并更新版本依赖 2020-03-10 17:56:53 +08:00
48b8c0d23e 去掉无用的 ijk so 减小应用体积 2020-03-10 14:23:52 +08:00
c56826b29d Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-03-10 13:53:25 +08:00
28ec3ef5dc 全局拦截参数缺失的非法请求 2020-03-10 13:53:09 +08:00
7f082b7a36 update 2020-03-10 10:27:51 +08:00
c3b8538ac3 修复在部分老旧设备上 webview 标题回调异常的问题 2020-03-09 17:48:00 +08:00
f04b1c4300 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-03-09 16:46:41 +08:00
1d7c8b894f 社区回答/文章编辑,插入回答-收藏回答去除修改红点提示 2020-03-09 16:46:29 +08:00
afd1232cea Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-03-09 15:59:03 +08:00
2b141e79cd 修改会刷到重复视频问题 2020-03-09 15:58:30 +08:00
f6e452237a Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-03-09 15:08:18 +08:00
508dff3bae 尝试修复游戏库闪屏问题 2020-03-09 15:08:03 +08:00
1259199e2c 删除一些无用代码 2020-03-09 15:05:00 +08:00
85fc2dda02 更换首页安利墙和评分字体颜色 2020-03-09 10:36:44 +08:00
d57a6879fb Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-03-07 10:58:18 +08:00
c0f32124ad 回退WebFragment的修改 2020-03-07 10:57:46 +08:00
b3a53f51b0 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-03-06 18:25:55 +08:00
66175c7f20 光环助手V4.0-测试问题汇总(20200304-1900)UI测试补充 https://gitlab.ghzs.com/pm/halo-app-issues/issues/796 2020-03-06 18:25:22 +08:00
dc698ca2cc 微调社区相关UI 2020-03-06 16:40:43 +08:00
6d8c703f33 再次调整视频双击点赞时间间隔 2020-03-06 16:15:22 +08:00
f32e6b60d1 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-03-06 15:12:22 +08:00
f45d1ded17 光环助手V4.0-测试问题汇总(20200304-1900)5,11 https://gitlab.ghzs.com/pm/halo-app-issues/issues/796 2020-03-06 15:12:00 +08:00
da9eac4ecd 修复RichEditor个别机型插入自定义样式无法跳转问题 2020-03-06 15:07:34 +08:00
b58d52709f 光环助手V4.0-视频相关测试汇总(正式环境)19-23 https://gitlab.ghzs.com/pm/halo-app-issues/issues/794 2020-03-06 15:05:46 +08:00
3cde5cc39d 修复游戏搜索多次输入相同关键字时,只有首次触发的问题 2020-03-06 14:28:08 +08:00
50214e7461 修复首页可能出现的无响应问题(改了这个又不能防止抖动了)
社区问答/文章发表评论对接关闭评论和隐藏状态
 修改社区评论/资讯评论可以回复自己的BUG
2020-03-06 12:02:23 +08:00
dc0994d084 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
2020-03-05 19:46:00 +08:00
f79a45e533 光环助手V4.0-测试问题汇总(20200304-1900)(14.16) https://gitlab.ghzs.com/pm/halo-app-issues/issues/796 2020-03-05 19:45:14 +08:00
b704e47322 光环助手V4.0-测试问题汇总(20200304-1900)完成4,7,8,9 https://gitlab.ghzs.com/pm/halo-app-issues/issues/796 2020-03-05 17:47:35 +08:00
bebda2de70 update 2020-03-05 15:59:56 +08:00
dab9f850ba Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-03-05 15:41:58 +08:00
e7073bf010 修改视频流非Wifi弹窗只弹一次 2020-03-05 15:41:35 +08:00
c1ab9617ad Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
2020-03-05 14:54:33 +08:00
c6d9026333 修改问题详情图标 2020-03-05 14:53:14 +08:00
42dae5c993 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-03-05 12:06:26 +08:00
a3af3dcf9b 调整视频双击点赞时间间隔 2020-03-05 12:05:59 +08:00
3e0887b5f9 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into sync_page_data 2020-03-05 11:52:15 +08:00
ba15462981 修复部分列表社区文章无法点赞问题 2020-03-05 11:33:29 +08:00
c29066eb46 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-03-05 11:07:30 +08:00
0464a859d2 尝试修复OnErrorNotImplementedException 2020-03-05 11:07:13 +08:00
962ff89833 避免原因未知的数组越界异常 2020-03-05 11:02:55 +08:00
74a40ebe97 在自动编译安装包的反馈闪退内容中添加编译时间帮助定位问题 2020-03-05 10:57:55 +08:00
686b454abe Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-03-05 10:32:03 +08:00
6d54ddea60 修复资讯文章评论后用户ID错误问题 2020-03-05 10:31:55 +08:00
d005403f65 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-03-04 18:19:27 +08:00
8e907f5221 恢复顶部视频非wifi不自动播放 2020-03-04 18:19:05 +08:00
96bb953d9d 更换部分图标 2020-03-04 18:15:22 +08:00
78b581b376 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-03-04 18:01:59 +08:00
ef7edb4a9e 社区回答/文章列表增加隐藏和关闭评论判断 2020-03-04 18:01:51 +08:00
4bf5ae40e2 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-03-04 16:44:32 +08:00
22ebdc0e87 添加卡顿检测BlockCanary 2020-03-04 16:44:19 +08:00
01bd1628cf 光环助手V4.0-视频相关测试汇总(正式环境)17,18 https://gitlab.ghzs.com/pm/halo-app-issues/issues/794 2020-03-04 16:39:18 +08:00
7de88bc8ad 修复下载流量提醒在某个别设备toast样式不同问题 2020-03-04 14:41:43 +08:00
1a01e2dd4d Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-03-04 11:55:25 +08:00
9e20c7082a 回退关注问题/我的问题UI代码到v3.7.3 2020-03-04 11:55:15 +08:00
74cb2f253b Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-03-04 11:25:08 +08:00
cf41d2e4a7 我的光环分组小红点添加描边 2020-03-04 11:24:44 +08:00
f232adaa98 修复隐私弹窗内容不居中问题 2020-03-04 11:18:21 +08:00
713af4bf12 修复首页横向专题刷新问题 2020-03-04 09:53:46 +08:00
f0f1906ffc Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-03-03 18:21:19 +08:00
3da6444ede 光环助手V4.0-测试问题汇总(UI相关)https://gitlab.ghzs.com/pm/halo-app-issues/issues/795 2020-03-03 18:21:10 +08:00
f149c56617 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-03-03 17:44:02 +08:00
9915a18656 解决视频点赞动画点击边缘变小问题 2020-03-03 17:43:40 +08:00
2173e5a91c 光环助手V4.0-视频相关测试汇总(正式环境)13 https://gitlab.ghzs.com/pm/halo-app-issues/issues/794 2020-03-03 17:43:08 +08:00
4a6866d8fd 完成测试问题汇总(20200228-1930)的1(4) https://gitlab.ghzs.com/pm/halo-app-issues/issues/793 2020-03-03 16:11:10 +08:00
ddc324bcf1 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-03-03 15:42:08 +08:00
daba7e0d12 完成光环助手V4.0-测试问题汇总(20200228-1930)14 https://gitlab.ghzs.com/pm/halo-app-issues/issues/793 2020-03-03 15:41:42 +08:00
6203b80c4e Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-03-03 15:12:38 +08:00
416cbe7e82 光环助手V4.0-测试问题汇总(20200228-1930)(1(2),1(5),1(6),2,3,4,5,6,7,10,11,12) https://gitlab.ghzs.com/pm/halo-app-issues/issues/793 2020-03-03 15:12:30 +08:00
e28ce4d099 完成20200303补充11,12 https://gitlab.ghzs.com/pm/halo-app-issues/issues/794 2020-03-03 10:56:19 +08:00
d1f5ec6c2e Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-03-02 18:31:49 +08:00
166f44bb1d 光环助手V4.0-视频相关测试汇总(正式环境)https://gitlab.ghzs.com/pm/halo-app-issues/issues/794 2020-03-02 18:31:30 +08:00
c8a0420b21 修改隐私弹窗UI 2020-03-02 18:31:09 +08:00
a8894cc464 init sync page data 2020-03-02 17:04:30 +08:00
a3d7d9cb81 处理视频滑动冲突 2020-03-02 15:13:27 +08:00
b6d49c88db Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-03-02 14:45:48 +08:00
8572f8eaf4 修改视频点赞效果 2020-03-02 14:45:07 +08:00
c533cd021f 社区回答/文章列表增加防抖操作 2020-02-28 19:00:40 +08:00
3eb1af7e23 修改社区回答/文章列表混合状态时点赞和评论异常问题 2020-02-28 18:40:24 +08:00
97188a7d9c Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-02-28 17:56:34 +08:00
e29ffa3d13 光环助手V4.0.0-问答社区优化汇总(2200226测试)
https://gitlab.ghzs.com/pm/halo-app-issues/issues/768
2020-02-28 17:56:16 +08:00
5b772a0537 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-02-28 16:52:23 +08:00
82a8888676 修改一些UI问题 2020-02-28 16:52:01 +08:00
bf8630756a 回退视频上传转码中相关代码 2020-02-28 16:24:37 +08:00
35fc381162 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-02-28 15:42:10 +08:00
f72342ac72 社区测试汇总 2020-02-28 15:42:04 +08:00
5a6e528c65 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-02-28 14:46:03 +08:00
4eb52c91a4 设备未安装“抖音”应用,直接打开网页 2020-02-28 14:45:41 +08:00
77bc1594aa 回答和文章列表增加取消点赞操作 2020-02-28 13:26:12 +08:00
23267ec0ee 回退关注问题/我的问题UI代码 2020-02-28 12:44:41 +08:00
1b1bd3264a Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-02-28 12:08:33 +08:00
b954c1f664 修复游戏库刷新替换抖动的问题 2020-02-28 12:08:21 +08:00
707beb9672 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-02-28 11:53:31 +08:00
b2f5a19bde 更换视频点赞动画 2020-02-28 11:52:56 +08:00
e24d7f1045 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-02-28 10:57:47 +08:00
142a64d261 修复上传视频修改封面图闪退问题
回答/文章列表点赞时检查登录状态
2020-02-28 10:57:29 +08:00
2ef98fd050 完成游戏详情加载优化的0228测试 https://gitlab.ghzs.com/pm/halo-app-issues/issues/783 2020-02-28 10:00:04 +08:00
2f3c387c16 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-02-27 18:16:10 +08:00
83b97a9de9 修复评论标签显示问题 2020-02-27 18:15:38 +08:00
97becbea2e 修改字体/色块颜色 2020-02-27 18:13:34 +08:00
8361609c70 merge change_theme_color into dev 2020-02-27 18:07:13 +08:00
eb7d871e70 修复收藏文章提交已读信息闪退问题 2020-02-27 16:24:22 +08:00
d06ab34db1 下载互斥弹窗逻辑修改 2020-02-27 16:18:42 +08:00
d59f604c7e Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-02-27 16:01:37 +08:00
a8d9bb9180 修改隐私弹窗 2020-02-27 16:01:27 +08:00
db90717617 双击点赞toast多次只显示一次 2020-02-27 15:50:03 +08:00
f916c7b8a5 修改游戏库刷新替换规则 2020-02-27 13:56:53 +08:00
4e410e3ea3 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-02-27 12:32:04 +08:00
5a5fb7a5cc 修改评论输入框UI 2020-02-27 12:31:22 +08:00
233a2172f1 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-02-26 18:00:37 +08:00
6376973a61 修复线程池线程数量不够报错,改用newCachedThreadPool 2020-02-26 18:00:04 +08:00
5dd6d73603 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-02-26 17:54:12 +08:00
5918b35793 修改社区专题详情UI 2020-02-26 17:53:52 +08:00
10c3536b2b 修改问答专题徽章显示问题 2020-02-26 17:47:49 +08:00
fffef74480 完成光环前端优化汇总(2020年2月第1周)第2点的0226测试 https://gitlab.ghzs.com/pm/halo-app-issues/issues/771 2020-02-26 17:36:14 +08:00
c5c2938089 修改App桌面图片 2020-02-26 17:24:58 +08:00
32fe28f536 社区文章/回答列表对接点赞数据 2020-02-26 16:43:27 +08:00
fc4a751b2b Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-02-26 16:08:33 +08:00
e364b7d3b0 修改我的收藏-社区文章/回答UI 2020-02-26 16:08:13 +08:00
bc28e08b3f 处理在子线程调用ExoPlayer方法报错和限制预加载视频50M 2020-02-26 15:38:53 +08:00
69b8155dcd Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-02-26 13:30:02 +08:00
16254bb578 社区回答/文章相关列表增加多图显示 2020-02-26 13:29:50 +08:00
acc4a5b2aa 20200226补充:1,2 https://gitlab.ghzs.com/pm/halo-app-issues/issues/769 2020-02-26 12:18:53 +08:00
fddce1ebe3 解决视频双击点赞点三次会触发单击事件 2020-02-26 11:13:25 +08:00
7151cba40e 修改上传配置 2020-02-25 18:36:50 +08:00
6cff45eada Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-02-25 18:10:41 +08:00
a05b4f7b65 全局修改评论相关样式(资讯文章/社区/视频) 2020-02-25 18:10:23 +08:00
e5797a41b7 游戏详情顶部声音问题 2020-02-25 16:51:00 +08:00
9f0191ce0a Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-02-25 16:39:02 +08:00
68a5c472c0 标记我的收藏已读 2020-02-25 16:38:39 +08:00
6c7e6d95ce 删除一些无用资源 2020-02-25 16:31:36 +08:00
ec84bbb4f3 完成游戏详情加载优化 https://gitlab.ghzs.com/pm/halo-app-issues/issues/783 2020-02-25 15:38:02 +08:00
780a8649e3 完成光环前端优化汇总(2020年2月第1周)第2点的0225测试 https://gitlab.ghzs.com/pm/halo-app-issues/issues/771 2020-02-25 15:33:34 +08:00
9aaaf2204a Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-02-25 14:08:39 +08:00
c7f608b9cb 完成0225测试 第6点 https://gitlab.ghzs.com/pm/halo-app-issues/issues/771 2020-02-25 14:08:16 +08:00
591885095b Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-02-25 13:18:00 +08:00
3bcdd37837 修改游戏搜索“找不到想要的游戏”悬浮窗的显示规则 2020-02-25 13:17:50 +08:00
959c5e4cf5 修改评论作者显示错误 2020-02-25 09:33:11 +08:00
7ecc8446ea Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-02-24 18:20:41 +08:00
d3809bb699 修改文案 2020-02-24 18:20:31 +08:00
d5113a52fc Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-02-24 18:15:28 +08:00
e2dd868705 完成20200224测试补充 https://gitlab.ghzs.com/pm/halo-app-issues/issues/779 2020-02-24 18:15:05 +08:00
41ae5b9b6b Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-02-24 18:11:07 +08:00
b0470b3a41 光环助手V4.0.0-插件版本下载互斥弹窗 https://gitlab.ghzs.com/pm/halo-app-issues/issues/788 2020-02-24 18:10:56 +08:00
d371ae9dc5 补充佩戴徽章的显示位置 https://gitlab.ghzs.com/pm/halo-app-issues/issues/778 2020-02-24 17:15:06 +08:00
00124a657d 完成光环前端优化汇总(2020年2月第1周)的第2点 https://gitlab.ghzs.com/pm/halo-app-issues/issues/771 2020-02-24 16:52:53 +08:00
620cec08eb Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-02-24 16:42:54 +08:00
b1205356c8 光环助手V4.0.0-版块(游戏库)优化:新增刷新按钮 https://gitlab.ghzs.com/pm/halo-app-issues/issues/784 2020-02-24 16:42:38 +08:00
e96d6829a4 处理徽章显示异常 2020-02-24 15:08:06 +08:00
0652da2300 完成游戏详情动态 tab 接口的合并 https://gitlab.ghzs.com/pm/halo-app-issues/issues/783 2020-02-22 17:44:08 +08:00
ebe3852132 正式环境接口切换到 4.0.0 2020-02-22 16:58:02 +08:00
1ae73277a9 更换桌面图标 2020-02-21 17:56:55 +08:00
97ec50f8a9 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-02-21 16:38:43 +08:00
1997a8b296 光环前端优化汇总(2020年2月第3周)(1.2.3.5.6) https://gitlab.ghzs.com/pm/halo-app-issues/issues/791 2020-02-21 16:38:25 +08:00
baae0e5bca 预加载视频封面图 2020-02-21 15:51:52 +08:00
4136bfab42 社区文章/回答列表增加点赞动画 2020-02-20 17:17:25 +08:00
3d64d3c90e 社区问题列表支持跳转至回答编辑页面 2020-02-20 15:59:25 +08:00
7d2835bb83 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-02-20 15:32:54 +08:00
9ffaa97d70 撰写回答页面问题标题增加收起功能 2020-02-20 15:32:29 +08:00
363751a970 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-02-20 14:27:42 +08:00
c7218d9c0d 视频点赞取消toast 2020-02-20 14:27:30 +08:00
e9387e29c6 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-02-20 13:33:59 +08:00
33b4d60882 视频管理后台增加压缩功能(6.7.9.10.11)https://gitlab.ghzs.com/pm/halo-app-issues/issues/785 2020-02-20 13:33:40 +08:00
86537b8f1e 光环前端优化汇总(2020年2月第3周)4 https://gitlab.ghzs.com/pm/halo-app-issues/issues/791 2020-02-20 10:01:15 +08:00
c2e64e2a71 双击点赞引导 2020-02-19 18:28:13 +08:00
79af4945e3 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-02-19 16:56:34 +08:00
f83a50d4c5 添加点赞动画 2020-02-19 16:54:49 +08:00
1868488390 社区文章/回答列表增加点赞和评论功能 2020-02-19 15:54:51 +08:00
4dc71d2d76 光环助手V4.0.0-问答社区优化汇总(4) https://gitlab.ghzs.com/pm/halo-app-issues/issues/768 2020-02-19 15:01:29 +08:00
dca5565f45 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-02-18 16:11:41 +08:00
aa6294bfd4 光环前端优化汇总(2020年2月第2周)(1) https://gitlab.ghzs.com/pm/halo-app-issues/issues/786 2020-02-18 16:11:18 +08:00
77a6d3f295 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-02-18 10:47:12 +08:00
10fd6d9aef 光环助手V4.0.0-徽章功能优化汇总4,5 https://gitlab.ghzs.com/pm/halo-app-issues/issues/778 2020-02-18 10:46:46 +08:00
37e6120768 光环助手V4.0.0-视频功能优化(视频详情)1,2 https://gitlab.ghzs.com/pm/halo-app-issues/issues/777 2020-02-18 10:46:18 +08:00
b9defd4a58 光环助手V4.0.0-视频功能优化(上传视频)(3) https://gitlab.ghzs.com/pm/halo-app-issues/issues/776 2020-02-17 17:51:12 +08:00
7f7938fdfa 修改社区搜索样式 2020-02-17 15:30:11 +08:00
7c2f411a48 修改社区文章/回答列表样式 2020-02-17 14:26:37 +08:00
51c152ca5e 使用exo自带缓存策略,重写预加载功能 2020-02-17 11:12:45 +08:00
dc46ee4431 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-02-14 18:53:40 +08:00
da3ba76547 全局修改社区所有列表UI(未完成)(6)
https://gitlab.ghzs.com/pm/halo-app-issues/issues/768
2020-02-14 18:53:24 +08:00
36a31f28f0 完成光环前端优化汇总(2020年2月第2周)的第4点 https://gitlab.ghzs.com/pm/halo-app-issues/issues/786 2020-02-14 11:57:20 +08:00
450a732f2e 修复4.0.0数据后台统计的 6 https://gitlab.ghzs.com/pm/halo-app-issues/issues/789 2020-02-14 11:56:21 +08:00
b8c5dcf4b4 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-02-13 17:39:50 +08:00
8ae5eacffe 游戏搜索(游戏搜索索引和游戏搜索结果)页面重构并且游戏搜索结果页面加上分页操作 2020-02-13 17:39:31 +08:00
bb9f7a33fb 修复游戏评论相关Bug汇总的三(2) https://gitlab.ghzs.com/pm/halo-app-issues/issues/774 2020-02-13 17:36:47 +08:00
06f603e975 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-02-13 16:38:05 +08:00
20c74a1727 光环前端优化汇总(2020年2月第1周)7 https://gitlab.ghzs.com/pm/halo-app-issues/issues/771 2020-02-13 16:37:48 +08:00
5dd3ba43c9 光环前端优化汇总(2020年2月第2周)6 https://gitlab.ghzs.com/pm/halo-app-issues/issues/786 2020-02-12 20:09:30 +08:00
cd749fc1c9 光环前端优化汇总(2020年2月第2周)8,9 https://gitlab.ghzs.com/pm/halo-app-issues/issues/786 2020-02-12 18:08:42 +08:00
6b7610bac8 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-02-12 17:29:47 +08:00
041f48bdb5 光环前端优化汇总(2020年2月第2周)(2)https://gitlab.ghzs.com/pm/halo-app-issues/issues/786 2020-02-12 17:28:58 +08:00
a1adfb336b 修复在低版本系统上自动安装时的闪退问题 2020-02-12 17:24:37 +08:00
35ff5af974 光环助手V4.0.0-版块(游戏库)优化:新增刷新按钮&显示静态图标(二)
https://gitlab.ghzs.com/pm/halo-app-issues/issues/784
2020-02-12 16:21:11 +08:00
638f324cd2 Merge branch 'exo' into dev 2020-02-12 11:36:33 +08:00
62390f88e5 我的光环小红点 2020-02-12 10:57:15 +08:00
9428604613 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-02-11 17:32:47 +08:00
610fc444af 光环助手V4.0.0-问答社区优化汇总(5) https://gitlab.ghzs.com/pm/halo-app-issues/issues/768 2020-02-11 17:32:25 +08:00
e5d7b68a85 版本号升级为4.0.0, 测试环境API亦切换至 4.0.0 2020-02-11 17:24:48 +08:00
9e91a53e94 修复新首页轮播图路径记录问题 https://gitlab.ghzs.com/pm/issues-Inbox/issues/2237 2020-02-11 17:23:46 +08:00
fa553238bb overrideLibrary添加exo,最低版本恢复至16 2020-02-11 10:53:03 +08:00
0a579427f4 顶部视频声音问题 2020-02-11 09:53:37 +08:00
921bc29f73 尝试更换exo内核 2020-02-10 18:26:33 +08:00
2864fa0d91 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-02-10 18:01:05 +08:00
9771fb7f25 光环助手V4.0.0-问答社区优化汇总(2.3) https://gitlab.ghzs.com/pm/halo-app-issues/issues/768 2020-02-10 18:00:45 +08:00
ec5bf05d42 光环助手V4.0.0-视频功能优化(数据与算法)1-3 https://gitlab.ghzs.com/pm/halo-app-issues/issues/781 2020-02-10 15:47:59 +08:00
7257f88993 增加非Wi-Fi环境播放视频提醒 2020-02-10 09:44:28 +08:00
79a5402e83 fix bug 2020-02-07 19:48:07 +08:00
abc899e822 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-02-07 19:37:44 +08:00
4e96f00ae9 Matisse增加单选模式 2020-02-07 19:37:21 +08:00
48106a8577 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-02-07 18:36:14 +08:00
dcdba2a9ad 光环助手V4.0.0-视频功能优化(游戏详情顶部视频)1,2 https://gitlab.ghzs.com/pm/halo-app-issues/issues/779 2020-02-07 18:35:54 +08:00
544c7a065f 优化应用进程重建时的状态异常问题 https://gitlab.ghzs.com/halo/assistant-android/issues/16 2020-02-07 17:04:43 +08:00
cd3ed911d2 视频双击点赞(缺少动画) 2020-02-07 15:33:34 +08:00
e95b2a905c Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-02-07 14:20:32 +08:00
e36209306e 光环助手V4.0.0-我的光环优化汇总 16 https://gitlab.ghzs.com/pm/halo-app-issues/issues/769 2020-02-07 14:20:09 +08:00
af607bc64a 修复由于CDN缓存造成的游戏收录延迟问题 https://gitlab.ghzs.com/pm/halo-app-issues/issues/773 2020-02-07 10:31:40 +08:00
450d81a4e3 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-02-06 19:12:01 +08:00
75c69adc87 修改首页状态栏高度未被消费问题 2020-02-06 19:11:35 +08:00
97b808fa81 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2020-02-06 17:26:38 +08:00
512ae70b94 尝试修复已安装列表闪退问题 2020-02-06 17:26:12 +08:00
322a31fcac 光环助手V4.0.0-我的光环优化汇总 7-9,13-15 https://gitlab.ghzs.com/pm/halo-app-issues/issues/769 2020-02-06 15:45:30 +08:00
20b6c383e1 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-02-06 12:39:12 +08:00
e7ff3ab327 光环前端优化汇总(2020年2月第1周)6 https://gitlab.ghzs.com/pm/halo-app-issues/issues/771 2020-02-06 12:38:47 +08:00
60b55bddab 修复安利内容过长导致标签样式无法显示的问题 2020-02-06 11:57:08 +08:00
1898e594dd 完成前端优化汇总(2月第1周)的 3,4,5 https://gitlab.ghzs.com/pm/halo-app-issues/issues/771 2020-02-06 11:56:09 +08:00
09f0704ad2 更换主题色并区分色块颜色与字体颜色
https://gitlab.ghzs.com/pm/halo-app-issues/issues/767
2020-02-05 17:11:04 +08:00
a6cd047b24 增加回调用于确定 activity 销毁状态 2020-02-05 12:01:40 +08:00
37429a4993 Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-02-04 18:29:15 +08:00
47f2b1e62f 完善登录回落功能 https://gitlab.ghzs.com/halo/assistant-android/issues/17 2020-02-04 18:28:47 +08:00
4e5fe8c32d 修复APP放置于后台过长时间被系统回收后再启动时出现的掉登录的问题 2020-02-04 18:26:31 +08:00
2fdf5421ad 统一管理线程分配,减少资源占用 2020-02-04 16:31:45 +08:00
412e6aa0c5 尝试修复后台执行下载行为时没有将进程转换为前台的问题 2020-02-03 18:02:58 +08:00
1fdafeec4e Merge branch 'dev' of gitlab.ghzs.com:halo/assistant-android into dev 2020-02-03 17:55:28 +08:00
ac819893d4 处理闪退问题 2020-02-03 17:54:40 +08:00
118936845e 处理一些闪退问题 2020-02-03 17:15:44 +08:00
4b1ab3453f 我的光环徽章小红点刷新 2020-02-03 16:13:26 +08:00
53690ff46d Merge branch '3.7.2-bugfix' into 'dev'
3.7.2 bugfix

See merge request !10
2020-02-03 10:09:16 +08:00
e9578bdeec 查看大图兼容 BASE64 编码图片 2020-01-22 11:22:25 +08:00
997 changed files with 28109 additions and 15016 deletions

View File

@ -23,6 +23,10 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
dexOptions {
// jumboMode = true
javaMaxHeapSize "4g"
@ -118,7 +122,6 @@ android {
dimension "nonsense"
buildConfigField "String", "API_HOST", "\"${API_HOST}\""
buildConfigField "String", "COMMENT_HOST", "\"${COMMENT_HOST}\""
buildConfigField "String", "DATA_HOST", "\"${DATA_HOST}\""
buildConfigField "String", "UMENG_APPKEY", "\"${UMENG_APPKEY}\""
buildConfigField "String", "UMENG_MESSAGE_SECRET", "\"${UMENG_MESSAGE_SECRET}\""
@ -136,7 +139,6 @@ android {
buildConfigField "String", "API_HOST", "\"${DEV_API_HOST}\""
buildConfigField "String", "COMMENT_HOST", "\"${DEV_COMMENT_HOST}\""
buildConfigField "String", "DATA_HOST", "\"${DEV_DATA_HOST}\""
buildConfigField "String", "UMENG_APPKEY", "\"${DEBUG_UMENG_APPKEY}\""
buildConfigField "String", "UMENG_MESSAGE_SECRET", "\"${DEBUG_UMENG_MESSAGE_SECRET}\""
@ -183,6 +185,7 @@ dependencies {
debugImplementation "com.facebook.stetho:stetho:${stetho}"
debugImplementation "com.facebook.stetho:stetho-okhttp3:${stetho}"
debugImplementation "com.squareup.okhttp3:logging-interceptor:${okHttp}"
debugImplementation "com.gu.android:toolargetool:${toolargetool}"
implementation "androidx.core:core:${core}"
implementation "androidx.fragment:fragment:${fragment}"
@ -192,14 +195,18 @@ dependencies {
implementation "androidx.annotation:annotation:${annotation}"
implementation "androidx.constraintlayout:constraintlayout:${constraintLayout}"
implementation "androidx.recyclerview:recyclerview:${recyclerView}"
implementation "androidx.lifecycle:lifecycle-runtime:${lifeCycle}"
implementation "androidx.lifecycle:lifecycle-extensions:${lifeCycle}"
kapt "androidx.lifecycle:lifecycle-compiler:${lifeCycle}"
// implementation "androidx.lifecycle:lifecycle-runtime:${lifeCycle}"
// implementation "androidx.lifecycle:lifecycle-extensions:${lifeCycle}"
// kapt "androidx.lifecycle:lifecycle-compiler:${lifeCycle}"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifeCycle"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifeCycle"
implementation "androidx.lifecycle:lifecycle-common-java8:$lifeCycle"
implementation "androidx.room:room-runtime:${room}"
implementation "androidx.room:room-rxjava2:${room}"
implementation "androidx.core:core-ktx:${ktx}"
implementation "androidx.viewpager2:viewpager2:${viewpager2}"
kapt "androidx.room:room-compiler:${room}"
kapt "androidx.databinding:databinding-compiler:${databinding}"
// kapt "androidx.databinding:databinding-compiler:${databinding}"
implementation "com.google.android.material:material:${material}"
@ -241,13 +248,13 @@ dependencies {
// bugly with tinker support
implementation "com.tencent.bugly:crashreport_upgrade:${buglyTinkerSupport}"
implementation 'com.google.android:flexbox:1.1.0'
implementation "com.google.android:flexbox:${flexbox}"
implementation "pub.devrel:easypermissions:${easypermissions}"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.contrarywind:Android-PickerView:4.1.3'
implementation "com.contrarywind:Android-PickerView:${pickerView}"
implementation "com.scwang.smartrefresh:SmartRefreshLayout:${smartRefreshLayout}"
implementation "net.cachapa.expandablelayout:expandablelayout:${expandableLayout}"
@ -263,27 +270,26 @@ dependencies {
implementation ("com.shuyu:gsyVideoPlayer-java:$gsyVideo",{
exclude module: "gsyvideoplayer-androidvideocache"
})
implementation "com.shuyu:gsyVideoPlayer-armv7a:$gsyVideo"
implementation "com.shuyu:gsyVideoPlayer-x86:$gsyVideo"
implementation "com.shuyu:GSYVideoPlayer-exo2:$gsyVideo"
implementation "com.github.wendux:DSBridge-Android:$dsBridge"
implementation "android.arch.work:work-runtime:${workManager}"
implementation "com.llew.huawei:verifier:1.0.6"
implementation "com.llew.huawei:verifier:${verifier}"
implementation "com.github.tbruyelle:rxpermissions:${rxPermissions}"
implementation 'com.ethanhua:skeleton:1.1.1'
implementation 'io.supercharge:shimmerlayout:2.1.0'
implementation "com.tencent.mm.opensdk:wechat-sdk-android-without-mta:5.3.1"
implementation 'com.walkud.rom.checker:RomChecker:1.0.0'
implementation "com.ethanhua:skeleton:${skeleton}"
implementation "io.supercharge:shimmerlayout:${shimmerlayout}"
implementation "com.tencent.mm.opensdk:wechat-sdk-android-without-mta:${mta}"
implementation "com.walkud.rom.checker:RomChecker:${romChecker}"
debugImplementation "com.github.nichbar.chucker:library:$chucker"
releaseImplementation "com.github.nichbar.chucker:library-no-op:$chucker"
implementation "com.bytedance.applog:RangersAppLog-Lite-cn:$bytedanceApplog"
implementation 'com.aliyun.dpa:oss-android-sdk:2.9.2'
implementation "com.aliyun.dpa:oss-android-sdk:${oss}"
implementation "com.airbnb.android:lottie:$lottie"
@ -291,6 +297,9 @@ dependencies {
exclude group: 'com.squareup.okhttp3'
})
debugImplementation "com.github.markzhai:blockcanary-android:$blockcanary"
releaseImplementation "com.github.markzhai:blockcanary-no-op:$blockcanary"
implementation project(':libraries:LGLibrary')
implementation project(':libraries:MTA')
implementation project(':libraries:QQShare')

View File

@ -30,6 +30,8 @@ public class Injection {
// init stetho
Stetho.initializeWithDefaults(application);
// 监控Bundle大小,预防溢出(需要调试的时候再开启吧!)
// TooLargeTool.startLogging(application);
return true;
}

View File

@ -41,6 +41,8 @@
com.shuyu.gsyvideoplayer.armv7a,
com.shuyu.gsyvideoplayer.x86,
com.shuyu.gsy.base,
com.google.android.exoplayer2,
tv.danmaku.ijk.media.exo2,
shuyu.com.androidvideocache,
pl.droidsonroids.gif" />
@ -113,6 +115,10 @@
android:name="com.gh.gamecenter.ShellActivity"
android:screenOrientation="portrait" />
<activity
android:name="com.gh.gamecenter.gamedetail.history.HistoryApkListActivity"
android:screenOrientation="portrait" />
<activity
android:name="com.gh.gamecenter.NewsDetailActivity"
android:screenOrientation="portrait" />
@ -456,8 +462,8 @@
<activity
android:name="com.gh.gamecenter.HelpAndFeedbackActivity"
android:windowSoftInputMode="stateHidden"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden" />
<activity
android:name="com.gh.gamecenter.help.HelpDetailActivity"
@ -478,6 +484,14 @@
android:name=".gamedetail.myrating.MyRatingActivity"
android:screenOrientation="portrait" />
<activity
android:name="com.gh.gamecenter.gamedetail.fuli.kaifu.ServersCalendarActivity"
android:screenOrientation="portrait" />
<activity
android:name="com.gh.gamecenter.QaActivity"
android:screenOrientation="portrait" />
<!-- 使用小米/华为推送弹窗功能提高推送成功率-->
<activity
android:name="com.gh.gamecenter.PushProxyActivity"

View File

@ -2,16 +2,20 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="stylesheet" type="text/css" href="normalize.css">
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" type="text/css" href="video-js.min.css">
<!-- <link rel="stylesheet" href="https://static-web.ghzs.com/website-static/lib/video-js.min.css">--> <!--在web页面播放视频-->
<!--<link rel="stylesheet" type="text/css" href="https://resource.ghzs.com/css/halo_app.css">-->
</head>
<body>
<body style="overflow-x: hidden; word-break: break-all;">
<div id="editor" contenteditable="false"></div>
<script type="text/javascript" src="zepto.min.js"></script>
<script type="text/javascript" src="rich_editor.js"></script>
<script type="text/javascript" src="video.min.js"></script>
<!--<script src="https://static-web.ghzs.com/website-static/lib/video.min.js"></script>--> <!--在web页面播放视频-->
<!--<script type="text/javascript" src="content.js"></script>-->
<!--<script type="text/javascript" src="https://resource.ghzs.com/js/halo_app.js"></script>-->
</body>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
{"v":"5.6.4","fr":25,"ip":0,"op":35,"w":1080,"h":214,"nm":"点赞","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"椭圆形 2","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.588],"y":[0]},"t":17,"s":[15]},{"t":20,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[468.04,73.68,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.659,0.659,0.333],"y":[0,0,0]},"t":10,"s":[50,50,100]},{"t":19,"s":[150,150,100]}],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[24,24],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"椭圆路径 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[300,300],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"椭圆形","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":10,"op":1510,"st":10,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"椭圆形 3","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.588],"y":[0]},"t":27,"s":[15]},{"t":30,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[468.04,73.68,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.659,0.659,0.333],"y":[0,0,0]},"t":20,"s":[50,50,100]},{"t":28,"s":[140,140,100]}],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[24,24],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"椭圆路径 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[300,300],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"椭圆形","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":20,"op":1520,"st":20,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"路径备份 2","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.602],"y":[0]},"t":0,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":5,"s":[100]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.663],"y":[0]},"t":24,"s":[100]},{"t":29,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[531.02,129.675,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.514,0.514,0.333],"y":[0,0,0]},"t":5,"s":[100,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.533,0.533,0.333],"y":[0,0,0]},"t":10,"s":[90,90,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.586,0.586,0.333],"y":[0,0,0]},"t":15,"s":[95,95,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.499,0.499,0.333],"y":[0,0,0]},"t":19,"s":[90,90,100]},{"t":24,"s":[100,100,100]}],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-5.33,-8.3],[3.89,0.27],[-4.4,-1.68],[-4.33,-0.67],[-4.08,9.32],[3.33,5.44],[3.39,4.6],[0.87,-3.7],[3.6,-0.86],[1.03,-0.21],[2.34,-0.53],[0.96,1.15],[4.22,5.48],[-1.18,-4.56]],"o":[[1.11,1.71],[-3.89,-0.27],[6.42,2.5],[4.33,0.66],[1.63,-5.32],[-3.34,-5.45],[-1.68,-2.1],[-0.71,3.14],[-3.43,0.95],[-0.57,0.08],[-3.86,1.12],[-3.23,-3.94],[-1.89,-2.28],[2.42,4.64]],"v":[[-5.387,9.698],[-10.717,8.498],[-12.327,15.628],[5.813,21.748],[23.313,11.778],[20.273,-1.202],[11.563,-13.962],[5.393,-12.362],[1.083,-13.722],[-2.087,-9.742],[-5.707,-11.752],[-8.777,-7.572],[-18.297,-20.542],[-23.827,-17.832]],"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":"填充 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[300,300],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"路径备份 2","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":1500,"st":0,"bm":0}],"markers":[]}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -617,3 +617,25 @@ RE.sendElementNameToNative = function() {
}
}
}
// android function to open link
function customLinkgo(self) {
var datas = self.dataset.datas
// console.log(datas)
window.OnLinkClickListener.onClick(datas)
}
// 在web页面播放视频
//RE.initArticleVideo = function(){
// initArticleVideo()
//}
function showNativeDialog(title, message, positive, negative, callback) {
var jsCallbackCode = "(" + function (v) {
window.onNativeDialogCallback(v);
delete window.onNativeDialogCallback;
}.toString() + ")";
window.onNativeDialogCallback = callback;
window.NativeCallBack.showDialog(title, message, positive, negative, jsCallbackCode);
}

View File

@ -1,6 +1,8 @@
package com.gh.base;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
@ -93,8 +95,8 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EventBus.getDefault().register(this);
ButterKnife.bind(this);
if (useEventBus()) EventBus.getDefault().register(this);
if (useButterKnife()) ButterKnife.bind(this);
mEntrance = getIntent().getStringExtra(KEY_ENTRANCE);
if (TextUtils.isEmpty(mEntrance)) {
mEntrance = Constants.ENTRANCE_UNKNOWN;
@ -107,7 +109,7 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy
@Override
protected void onDestroy() {
EventBus.getDefault().unregister(this);
if (useEventBus()) EventBus.getDefault().unregister(this);
mBaseHandler.removeCallbacksAndMessages(null);
super.onDestroy();
}
@ -178,6 +180,9 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy
@Override
protected void onPause() {
super.onPause();
if (isFinishing()) {
onFinish();
}
}
@Override
@ -185,6 +190,13 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy
super.onResume();
}
/**
* 此回调可用于确认当前 activity 已经执行了 finish() 方法并处于 isFinishing 状态
*/
protected void onFinish() {
}
@Override
public void onRequestPermissionsResult(int requestCode,
@NonNull String[] permissions,
@ -235,4 +247,22 @@ public abstract class BaseActivity extends BaseAppCompatActivity implements Easy
return StringUtils.buildString(entrance, "+(", path, ")");
}
protected boolean useEventBus() {
return true;
}
protected boolean useButterKnife() {
return true;
}
@Override
public Resources getResources() {
Resources resources = super.getResources();
if (resources.getConfiguration().fontScale != 1.0f) {
Configuration configuration = resources.getConfiguration();
configuration.fontScale = 1.0f;
resources.updateConfiguration(configuration, resources.getDisplayMetrics());
}
return resources;
}
}

View File

@ -9,6 +9,7 @@ import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;
import com.gh.base.adapter.FragmentAdapter;
import com.gh.base.fragment.BaseFragment_TabLayout;
import com.gh.common.view.TabIndicatorView;
import com.gh.gamecenter.R;
import com.google.android.material.tabs.TabLayout;
@ -45,7 +46,7 @@ public abstract class BaseActivity_TabLayout extends ToolBarActivity implements
protected abstract void initTabTitleList(List<String> tabTitleList);
protected int provideIndicatorWidth() {
return 65;
return 20;
}
protected View provideTabView(int position, String tabTitle) {
@ -89,11 +90,14 @@ public abstract class BaseActivity_TabLayout extends ToolBarActivity implements
for (int i = 0; i < mTabLayout.getTabCount(); i++) {
TabLayout.Tab tab = mTabLayout.getTabAt(i);
if (tab == null) continue;
View tabView = provideTabView(i, tab.getText() != null ? tab.getText().toString() : "");
if (tabView == null) continue;
String tabTitle = tab.getText() != null ? tab.getText().toString() : "";
View tabView = provideTabView(i, tabTitle);
if (tabView == null)
tabView = BaseFragment_TabLayout.createDefaultTabCustomView(tabTitle);
tab.setCustomView(tabView);
}
BaseFragment_TabLayout.initTabStyle(mTabLayout, mCheckedIndex);
}
@Override

View File

@ -201,7 +201,7 @@ abstract class BaseRichEditorActivity : ToolBarActivity() {
}
R.id.editor_link_game -> {
MtaHelper.onEvent(mtaEventName(), "插入链接", "插入链接-游戏")
startActivityForResult(GameActivity.getIntent(this, "插入游戏"), INSERT_GAME_CODE)
startActivityForResult(GameActivity.getIntent(this, GameActivity.INSERT_GAME_TITLE), INSERT_GAME_CODE)
}
R.id.editor_link_video -> {
MtaHelper.onEvent(mtaEventName(), "插入链接", "插入链接-视频")

View File

@ -65,7 +65,9 @@ public class GHActivityLifecycleCallbacksImpl implements ActivityLifecycleCallba
@Override
public void onActivityDestroyed(Activity activity) {
AppManager.getInstance().finishActivity(activity);
if (activity.isFinishing()) {
AppManager.getInstance().finishActivity(activity);
}
}
}

View File

@ -9,9 +9,20 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import androidx.recyclerview.widget.RecyclerView;
import com.gh.base.OnListClickListener;
import com.gh.base.OnRequestCallBackListener;
import com.gh.common.constant.Constants;
import com.gh.common.syncpage.ISyncAdapterHandler;
import com.gh.common.syncpage.SyncDataEntity;
import com.gh.common.syncpage.SyncPageRepository;
import com.gh.gamecenter.BuildConfig;
import com.gh.gamecenter.eventbus.EBMiPush;
import com.lightgame.OnTitleClickListener;
@ -23,18 +34,14 @@ import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import butterknife.ButterKnife;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import kotlin.Pair;
import static com.gh.common.util.EntranceUtils.KEY_ENTRANCE;
@ -52,7 +59,7 @@ public abstract class BaseFragment<T> extends Fragment implements OnRequestCallB
protected boolean isEverPause;
@NonNull
protected String mEntrance;
protected String mEntrance = "";
protected final Handler mBaseHandler = new BaseFragment.BaseHandler(this);
@ -138,9 +145,55 @@ public abstract class BaseFragment<T> extends Fragment implements OnRequestCallB
} else {
mCachedView = View.inflate(getContext(), getLayoutId(), null);
}
ButterKnife.bind(this, mCachedView);
if (useButterKnife()) {
ButterKnife.bind(this, mCachedView);
}
initView(mCachedView);
if (addSyncPageObserver()) {
initSyncPageObserver();
}
}
private void initSyncPageObserver() {
SyncPageRepository.INSTANCE.getSyncPageLiveData().observe(this, syncDataEntities -> {
try {
Utils.log("SyncPageRepository initSyncPageObserver->" + syncDataEntities);
List<SyncDataEntity> readyRemoveList = new ArrayList<>();
if (syncDataEntities == null || syncDataEntities.isEmpty()) return;
RecyclerView.Adapter adapter = provideSyncAdapter();
if (!(adapter instanceof ISyncAdapterHandler)) return;
for (int i = 0; i < adapter.getItemCount(); i++) {
Pair<String, Object> syncKey = ((ISyncAdapterHandler) adapter).getSyncData(i);
if (syncKey == null) continue;
for (SyncDataEntity syncDataEntity : syncDataEntities) {
if (syncDataEntity.getSyncId().equals(syncKey.getFirst())) {
boolean isSuccess = SyncPageRepository.INSTANCE.handleSyncData(syncKey.getSecond(), syncDataEntity);
if (isSuccess) {
if (BuildConfig.DEBUG) {
Utils.log("SyncPageRepository notify position->" + i);
}
adapter.notifyItemChanged(i);
if (syncDataEntity.getRemove()) {
readyRemoveList.add(syncDataEntity);
}
}
}
}
}
mBaseHandler.postDelayed(() -> SyncPageRepository.removeSyncData(readyRemoveList), 2000);
} catch (Exception e) {
if (BuildConfig.DEBUG) {
throw e;
} else {
e.printStackTrace();
}
}
});
}
// 必须的有subscribe才能register
@ -183,11 +236,7 @@ public abstract class BaseFragment<T> extends Fragment implements OnRequestCallB
}
public void toast(String msg) {
try {
Utils.toast(getContext(), msg);
} catch (Exception ignore) {
}
Utils.toast(getContext(), msg);
}
public void toastLong(@StringRes int msg) {
@ -255,4 +304,16 @@ public abstract class BaseFragment<T> extends Fragment implements OnRequestCallB
return this;
}
@Nullable
protected RecyclerView.Adapter provideSyncAdapter() {
return null;
}
protected boolean addSyncPageObserver() {
return false;
}
protected boolean useButterKnife() {
return true;
}
}

View File

@ -1,18 +1,28 @@
package com.gh.base.fragment;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.material.tabs.TabLayout;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.CheckedTextView;
import android.widget.TextView;
import com.gh.base.adapter.FragmentAdapter;
import com.gh.common.view.TabIndicatorView;
import com.gh.gamecenter.R;
import com.gh.gamecenter.normal.NormalFragment;
import com.halo.assistant.HaloApp;
import com.lightgame.utils.Utils;
import com.lightgame.view.NoScrollableViewPager;
import java.util.ArrayList;
@ -46,7 +56,7 @@ public abstract class BaseFragment_TabLayout extends NormalFragment implements V
protected abstract void initTabTitleList(List<String> tabTitleList);
protected int provideIndicatorWidth() {
return 65;
return 20;
}
protected View provideTabView(int position, String tabTitle) {
@ -94,11 +104,71 @@ public abstract class BaseFragment_TabLayout extends NormalFragment implements V
for (int i = 0; i < mTabLayout.getTabCount(); i++) {
TabLayout.Tab tab = mTabLayout.getTabAt(i);
if (tab == null) continue;
View tabView = provideTabView(i, tab.getText() != null ? tab.getText().toString() : "");
if (tabView == null) continue;
String tabTitle = tab.getText() != null ? tab.getText().toString() : "";
View tabView = provideTabView(i, tabTitle);
if (tabView == null) tabView = createDefaultTabCustomView(tabTitle);
tab.setCustomView(tabView);
}
initTabStyle(mTabLayout, mCheckedIndex);
}
public static void initTabStyle(TabLayout tabLayout, int currentItem) {
// 默认选择addOnTabSelectedListener不会回调
int tabCount = tabLayout.getTabCount();
if (tabCount > 0) {
TabLayout.Tab tab = tabLayout.getTabAt(currentItem);
if (tab != null) updateTabStyle(tab, true);
}
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
updateTabStyle(tab, true);
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
updateTabStyle(tab, false);
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
updateTabStyle(tab, true);
}
});
}
private static void updateTabStyle(TabLayout.Tab tab, boolean isChecked) {
View tabView = tab.getCustomView();
if (tabView == null) {
Utils.log("TabLayout->Tab样式不是通用样式,请检查");
return;
}
TextView tabTitle;
if (tabView instanceof TextView) {
tabTitle = (TextView) tabView;
} else {
tabTitle = tabView.findViewById(R.id.tab_title);
}
if (tabTitle == null) {
Utils.log("TabLayout->Tab样式不是通用样式,请检查");
return;
}
tabTitle.setTypeface(isChecked ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);
}
// 如果不设置View的话无法动态设置字体样式
@NonNull
public static View createDefaultTabCustomView(String title) {
View view = LayoutInflater.from(HaloApp.getInstance().getApplication().getBaseContext()).inflate(R.layout.tab_item, null);
View tabTitle = view.findViewById(R.id.tab_title);
if (tabTitle instanceof CheckedTextView) {
((CheckedTextView) tabTitle).setText(title);
}
return view;
}
@Override

View File

@ -2,6 +2,7 @@ package com.gh.base.fragment
import android.os.Bundle
import com.gh.gamecenter.normal.NormalFragment
import com.lightgame.utils.Utils
/**
* 懒加载(支持多层嵌套)
@ -12,10 +13,10 @@ abstract class BaseLazyFragment : NormalFragment() {
private var isViewCreated = false
private var isSupportVisible = false
protected var isSupportVisible = false
/**
* 用于分发可见时间的时候获取 fragment 是否隐藏
* 用于分发可见时间的时候获取 fragment 是否隐藏
*
* @return true fragment 不可见, false 父 fragment 可见
*/
@ -104,7 +105,7 @@ abstract class BaseLazyFragment : NormalFragment() {
isSupportVisible = visible
if (visible) {
if (mIsFirstVisible) {
if (mIsFirstVisible && view != null) {
mIsFirstVisible = false
onFragmentFirstVisible()
}

View File

@ -0,0 +1,152 @@
package com.gh.base.fragment
import android.content.Intent
import android.graphics.Typeface
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.widget.CheckedTextView
import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.viewpager.widget.ViewPager
import butterknife.BindView
import com.gh.base.adapter.FragmentAdapter
import com.gh.common.view.TabIndicatorView
import com.gh.gamecenter.R
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayout.OnTabSelectedListener
import com.halo.assistant.HaloApp
import com.lightgame.utils.Utils
import com.lightgame.view.NoScrollableViewPager
abstract class BaseLazyTabFragment : BaseLazyFragment(), ViewPager.OnPageChangeListener {
@BindView(R.id.fragment_tab_layout)
lateinit var mTabLayout: TabLayout
@BindView(R.id.fragment_view_pager)
lateinit var mViewPager: NoScrollableViewPager
@BindView(R.id.fragment_tab_indicator)
lateinit var mTabIndicatorView: TabIndicatorView
var mFragmentsList: MutableList<Fragment> = arrayListOf()
var mTabTitleList: MutableList<String> = arrayListOf()
var mCheckedIndex = 0
abstract fun initFragmentList(fragments: MutableList<Fragment>)
abstract fun initTabTitleList(tabTitleList: MutableList<String>)
protected open fun provideIndicatorWidth(): Int {
return 20
}
protected open fun provideTabView(position: Int, tabTitle: String?): View? {
return null
}
override fun getLayoutId(): Int {
return R.layout.fragment_tablayout_viewpager
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
val fragments = childFragmentManager.fragments
if (fragments != null) {
for (fragment in fragments) {
fragment.onActivityResult(requestCode, resultCode, data)
}
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (arguments != null) mCheckedIndex = requireArguments().getInt(PAGE_INDEX, 0)
}
override fun onFragmentFirstVisible() {
super.onFragmentFirstVisible()
initFragmentList(mFragmentsList)
initTabTitleList(mTabTitleList)
mViewPager.offscreenPageLimit = mFragmentsList.size
mViewPager.addOnPageChangeListener(this)
mViewPager.adapter = FragmentAdapter(childFragmentManager, mFragmentsList, mTabTitleList)
mViewPager.currentItem = mCheckedIndex
mTabLayout.setupWithViewPager(mViewPager)
mTabIndicatorView.setupWithTabLayout(mTabLayout)
mTabIndicatorView.setupWithViewPager(mViewPager)
mTabIndicatorView.setIndicatorWidth(provideIndicatorWidth())
for (i in 0 until mTabLayout.tabCount) {
val tab = mTabLayout.getTabAt(i) ?: continue
val tabTitle = if (tab.text != null) tab.text.toString() else ""
var tabView = provideTabView(i, tabTitle)
if (tabView == null) tabView = createDefaultTabCustomView(tabTitle)
tab.customView = tabView
}
initTabStyle(mTabLayout, mCheckedIndex)
}
open fun initTabStyle(tabLayout: TabLayout?, currentItem: Int) { // 默认选择addOnTabSelectedListener不会回调
val tabCount = tabLayout!!.tabCount
if (tabCount > 0) {
val tab = tabLayout.getTabAt(currentItem)
if (tab != null) updateTabStyle(tab, true)
}
tabLayout.addOnTabSelectedListener(object : OnTabSelectedListener {
override fun onTabSelected(tab: TabLayout.Tab) {
updateTabStyle(tab, true)
}
override fun onTabUnselected(tab: TabLayout.Tab) {
updateTabStyle(tab, false)
}
override fun onTabReselected(tab: TabLayout.Tab) {
updateTabStyle(tab, true)
}
})
}
open fun updateTabStyle(tab: TabLayout.Tab, isChecked: Boolean) {
val tabView = tab.customView
if (tabView == null) {
Utils.log("TabLayout->Tab样式不是通用样式,请检查")
return
}
val tabTitle: TextView?
tabTitle = if (tabView is TextView) {
tabView
} else {
tabView.findViewById(R.id.tab_title)
}
if (tabTitle == null) {
Utils.log("TabLayout->Tab样式不是通用样式,请检查")
return
}
tabTitle.typeface = if (isChecked) Typeface.DEFAULT_BOLD else Typeface.DEFAULT
}
// 如果不设置View的话无法动态设置字体样式
open fun createDefaultTabCustomView(title: String?): View {
val view = LayoutInflater.from(HaloApp.getInstance().application.baseContext).inflate(R.layout.tab_item, null)
val tabTitle = view.findViewById<View>(R.id.tab_title)
if (tabTitle is CheckedTextView) {
tabTitle.text = title
}
return view
}
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {}
override fun onPageSelected(position: Int) {}
override fun onPageScrollStateChanged(state: Int) {}
companion object {
const val PAGE_INDEX = "PAGE_INDEX"
}
}

View File

@ -2,14 +2,28 @@ package com.gh.common
import android.os.Handler
import android.os.Looper
import com.gh.common.AppExecutor.ioExecutor
import com.gh.common.AppExecutor.lightWeightIoExecutor
import com.gh.common.AppExecutor.uiExecutor
import java.util.concurrent.Executor
import java.util.concurrent.Executors
/**
* APP 线程池管理类
*
* [ioExecutor] 是一个最大线程数固定的线程池,较为繁重的 IO 任务可以交给它
* [uiExecutor] 是主线程的包裹,需要切换至主线程执行可以用它
* [lightWeightIoExecutor] 是一个单线程的线程池,轻量级且需要保证同一线程的 IO 任务可以交给它
*
*/
object AppExecutor {
@JvmStatic
var ioExecutor = Executors.newSingleThreadExecutor()
val uiExecutor by lazy { MainThreadExecutor() }
@JvmStatic
var uiExecutor = MainThreadExecutor()
val lightWeightIoExecutor by lazy { Executors.newSingleThreadExecutor() }
@JvmStatic
val ioExecutor by lazy { Executors.newCachedThreadPool() }
class MainThreadExecutor : Executor {
private val mainThreadHandler = Handler(Looper.getMainLooper())
@ -24,8 +38,12 @@ object AppExecutor {
}
}
fun runOnIoThread(f: () -> Unit) {
AppExecutor.ioExecutor.execute(f)
fun runOnIoThread(isLightWeightTask: Boolean = false, f: () -> Unit) {
if (isLightWeightTask) {
AppExecutor.lightWeightIoExecutor.execute(f)
} else {
AppExecutor.ioExecutor.execute(f)
}
}
fun runOnUiThread(f: () -> Unit) {

View File

@ -6,9 +6,11 @@ import android.webkit.JavascriptInterface
import androidx.annotation.Keep
import com.gh.base.CurrentActivityHolder
import com.gh.common.util.*
import com.gh.gamecenter.BuildConfig
import com.gh.gamecenter.LoginActivity
import com.gh.gamecenter.ViewImageActivity
import com.gh.gamecenter.entity.Badge
import com.gh.gamecenter.entity.MtaEvent
import com.gh.gamecenter.manager.UserManager
import com.gh.gamecenter.retrofit.BiResponse
import com.gh.gamecenter.retrofit.RetrofitManager
@ -76,6 +78,11 @@ class DefaultJsApi(var context: Context) {
return HaloApp.getInstance().channel
}
@JavascriptInterface
fun getAppVersion(msg: Any): String {
return BuildConfig.VERSION_NAME
}
@JavascriptInterface
fun bindWechat(msg: Any, handler: CompletionHandler<Any>) {
context.ifLogin("浏览器") {
@ -144,9 +151,6 @@ class DefaultJsApi(var context: Context) {
context?.startActivity(ViewImageActivity.getBase64ViewImageIntent(context, true))
}
@Keep
internal data class MtaEvent(var name: String = "", var key: String = "", var value: String = "")
@Keep
internal data class ImageEvent(var imageList: ArrayList<String> = arrayListOf(), var position: Int = 0)

View File

@ -15,7 +15,7 @@ import com.gh.gamecenter.WebActivity
import com.gh.gamecenter.entity.CommunityEntity
import com.gh.gamecenter.entity.VideoLinkEntity
import com.gh.gamecenter.subject.SubjectActivity
import com.halo.assistant.HaloApp
import com.gh.gamecenter.video.detail.VideoDetailContainerViewModel
import com.lightgame.utils.Utils
object DefaultWebViewUrlHandler {
@ -36,7 +36,7 @@ object DefaultWebViewUrlHandler {
when (host) {
"article" -> context.startActivity(NewsDetailActivity.getIntentById(context, id, entrance))
"game" -> GameDetailActivity.startGameDetailActivity(context, id, entrance)
"game" -> GameDetailActivity.startGameDetailActivity(context, id, "libao" == uri.getQueryParameter("to"), entrance)
"column" -> SubjectActivity.startSubjectActivity(context, id, uri.getQueryParameter("name"), false, entrance)
@ -44,7 +44,7 @@ object DefaultWebViewUrlHandler {
"qq" -> try {
DirectUtils.directToQqConversation(context, id)
} catch (e: Exception) {
} catch (e: Throwable) {
Utils.toast(context, "请检查是否已经安装手机QQ")
e.printStackTrace()
}
@ -79,10 +79,18 @@ object DefaultWebViewUrlHandler {
"community" -> {
val community = CommunityEntity()
community.id = id
community.name = uri.getQueryParameter("name")
community.name = uri.getQueryParameter("name") ?: ""
DirectUtils.directToCommunity(context, community)
}
"community_column" -> {
val community = CommunityEntity()
community.id = uri.getQueryParameter("community_id") ?: ""
community.name = uri.getQueryParameter("community_name") ?: ""
val columnId = uri.getQueryParameter("column_id") ?: ""
DirectUtils.directToCommunityColumn(context, community, columnId, entrance, "文章链接")
}
"answer" -> DirectUtils.directToAnswerDetail(context, id, entrance, "文章链接")
"communities" -> {
@ -116,13 +124,26 @@ object DefaultWebViewUrlHandler {
val categoryId = uri.getQueryParameter("category_id") ?: ""
val link = uri.getQueryParameter("link") ?: ""
val linkEntity = VideoLinkEntity(title, categoryId, link)
if (!CheckLoginUtils.isLogin()) {
HaloApp.put(EntranceUtils.HOST_UPLOAD_VIDEO, linkEntity)
}
CheckLoginUtils.checkLogin(context, EntranceUtils.ENTRANCE_BROWSER) {
// if (!CheckLoginUtils.isLogin()) {
// HaloApp.put(EntranceUtils.HOST_UPLOAD_VIDEO, linkEntity)
// }
CheckLoginUtils.checkLogin(context, null, true, EntranceUtils.ENTRANCE_BROWSER) {
DirectUtils.directToVideoManager(context, linkEntity, EntranceUtils.ENTRANCE_BROWSER, "")
}
}
EntranceUtils.HOST_USERHOME -> {
val position = uri.getQueryParameter("position")
DirectUtils.directToHomeActivity(context, id, if (position.isNullOrEmpty()) -1 else position.toInt(), entrance, "")
}
EntranceUtils.HOST_VIDEO_MORE -> {
val referer = uri.getQueryParameter("referer") ?: ""
val type = uri.getQueryParameter("type") ?: ""
val act = uri.getQueryParameter("act") ?: ""
val loaction = if (TextUtils.isEmpty(act)) id else VideoDetailContainerViewModel.Location.VIDEO_ACTIVITY.value
DirectUtils.directToVideoDetail(context, id, loaction, false, "", entrance, "", referer, type, act)
}
else -> DialogUtils.showLowVersionDialog(context)
}
return true

View File

@ -8,6 +8,7 @@ import com.gh.common.exposure.meta.MetaUtil
import com.gh.common.util.edit
import com.gh.common.util.toJson
import com.gh.common.util.toObject
import com.gh.common.util.tryWithDefaultCatch
import com.gh.gamecenter.BuildConfig
import com.gh.gamecenter.entity.AliasEntity
import com.gh.gamecenter.retrofit.RetrofitManager
@ -35,33 +36,34 @@ object PushManager {
@JvmStatic
fun init(channel: String) {
//初始化友盟推送
UMConfigure.init(mApplication,
Config.UMENG_APPKEY, channel,
UMConfigure.DEVICE_TYPE_PHONE,
Config.UMENG_MESSAGE_SECRET)
tryWithDefaultCatch {
//初始化友盟推送
UMConfigure.init(mApplication,
Config.UMENG_APPKEY, channel,
UMConfigure.DEVICE_TYPE_PHONE,
Config.UMENG_MESSAGE_SECRET)
// 注册小米、华为和魅族通道
MiPushRegistar.register(mApplication, Config.MIPUSH_APPID, Config.MIPUSH_APPKEY)
HuaWeiRegister.register(mApplication)
MeizuRegister.register(mApplication, BuildConfig.MEIZUPUSH_APPID, BuildConfig.MEIZUPUSH_APPKEY)
// 注册小米、华为和魅族通道
MiPushRegistar.register(mApplication, Config.MIPUSH_APPID, Config.MIPUSH_APPKEY)
HuaWeiRegister.register(mApplication)
MeizuRegister.register(mApplication, BuildConfig.MEIZUPUSH_APPID, BuildConfig.MEIZUPUSH_APPKEY)
//友盟推送
val pushAgent = PushAgent.getInstance(mApplication)
pushAgent.onAppStart() // 开启App统计
//友盟推送
val pushAgent = PushAgent.getInstance(mApplication)
//注册推送服务每次调用register方法都会回调该接口
registerDevice()
//注册推送服务每次调用register方法都会回调该接口
runOnIoThread { registerDevice() }
val aliasInSp = PreferenceManager.getDefaultSharedPreferences(mApplication).getString(SP_PUSH_ALIAS, "")
mPreviousAlias = aliasInSp?.toObject()
val aliasInSp = PreferenceManager.getDefaultSharedPreferences(mApplication).getString(SP_PUSH_ALIAS, "")
mPreviousAlias = aliasInSp?.toObject()
if (mPreviousAlias == null) {
getAndSetAlias()
if (mPreviousAlias == null) {
getAndSetAlias()
}
// 完全自定义处理(透传)
pushAgent.setPushIntentServiceClass(GHUmengNotificationService::class.java)
}
// 完全自定义处理(透传)
pushAgent.setPushIntentServiceClass(GHUmengNotificationService::class.java)
}
private fun registerDevice() {

View File

@ -6,10 +6,11 @@ import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import com.halo.assistant.HaloApp
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
/**
* 统计用户在当前 Fragment 的停留时间,在 onViewDestroy 或 onDestroy 里获取 elapsedTime 即可,单位为秒
* 统计用户在当前 Fragment/Activity 的停留时间,在 onViewDestroy 或 onDestroy 里获取 elapsedTime 即可,单位为秒
*/
class TimeElapsedHelper(val fragment: Fragment?, val activity: Activity?) {
@ -113,7 +114,7 @@ class TimeElapsedHelper(val fragment: Fragment?, val activity: Activity?) {
}
object TimeElapsedThreadHolder {
val threadService = Executors.newSingleThreadExecutor()
val threadService: ExecutorService by lazy { Executors.newSingleThreadExecutor() }
}
interface TimeoutCallback {

View File

@ -0,0 +1,16 @@
package com.gh.common.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 标记那些不需要检查的同步字段
*
* 同步字段冲突时使用
*/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface SyncIgnore {
}

View File

@ -0,0 +1,12 @@
package com.gh.common.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface SyncPage {
String[] syncNames();
}

View File

@ -0,0 +1,31 @@
package com.gh.common.avoidcallback;
import android.content.Intent;
public class ActivityResultInfo {
private int resultCode;
private Intent data;
public ActivityResultInfo(int resultCode, Intent data) {
this.resultCode = resultCode;
this.data = data;
}
public int getResultCode() {
return resultCode;
}
public void setResultCode(int resultCode) {
this.resultCode = resultCode;
}
public Intent getData() {
return data;
}
public void setData(Intent data) {
this.data = data;
}
}

View File

@ -0,0 +1,48 @@
package com.gh.common.avoidcallback
import android.content.Intent
import android.os.Bundle
import android.util.SparseArray
import androidx.fragment.app.Fragment
import io.reactivex.Observable
import io.reactivex.subjects.PublishSubject
class AvoidOnResultFragment : Fragment() {
private val mSubjects = SparseArray<PublishSubject<ActivityResultInfo>>()
private val mCallbacks = SparseArray<Callback>()
private var requestCode = 1000
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
retainInstance = true
}
fun startForResult(intent: Intent): Observable<ActivityResultInfo> {
val subject = PublishSubject.create<ActivityResultInfo>()
return subject.doOnSubscribe {
mSubjects.put(requestCode, subject)
startActivityForResult(intent, requestCode)
requestCode++
}
}
fun startForResult(intent: Intent, callback: Callback) {
mCallbacks.put(requestCode, callback)
startActivityForResult(intent, requestCode)
requestCode++
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
val subject = mSubjects.get(requestCode)
if (subject != null) {
subject.onNext(ActivityResultInfo(resultCode, data))
subject.onComplete()
}
mSubjects.remove(requestCode)
val callback = mCallbacks.get(requestCode)
callback?.onActivityResult(resultCode, data)
mCallbacks.remove(requestCode)
}
}

View File

@ -0,0 +1,64 @@
package com.gh.common.avoidcallback
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import io.reactivex.Observable
class AvoidOnResultManager {
val TAG = "AvoidOnResultManager"
private var mAvoidOnResultFragment: AvoidOnResultFragment
private constructor(activity: AppCompatActivity) {
mAvoidOnResultFragment = getAvoidOnResultFragment(activity)
}
private constructor(fragment: Fragment) : this(fragment.activity as AppCompatActivity)
companion object {
fun getInstance(activity: AppCompatActivity): AvoidOnResultManager {
return AvoidOnResultManager(activity)
}
fun getInstance(fragment: Fragment): AvoidOnResultManager {
return AvoidOnResultManager(fragment)
}
}
private fun getAvoidOnResultFragment(activity: AppCompatActivity): AvoidOnResultFragment {
var avoidOnResultFragment = findAvoidOnResultFragment(activity)
if (avoidOnResultFragment == null) {
avoidOnResultFragment = AvoidOnResultFragment()
val fragmentManager = activity.supportFragmentManager
fragmentManager
.beginTransaction()
.add(avoidOnResultFragment, TAG)
.commitAllowingStateLoss()
fragmentManager.executePendingTransactions()
}
return avoidOnResultFragment
}
private fun findAvoidOnResultFragment(activity: AppCompatActivity): AvoidOnResultFragment? {
return activity.supportFragmentManager.findFragmentByTag(TAG) as? AvoidOnResultFragment
}
fun startForResult(intent: Intent, callback: Callback) {
mAvoidOnResultFragment.startForResult(intent, callback)
}
fun startForResult(clazz: Class<*>, callback: Callback) {
val intent = Intent(mAvoidOnResultFragment.activity, clazz)
mAvoidOnResultFragment.startForResult(intent, callback)
}
fun startForResult(intent: Intent): Observable<ActivityResultInfo> {
return mAvoidOnResultFragment.startForResult(intent)
}
fun startForResult(clazz: Class<*>): Observable<ActivityResultInfo> {
val intent = Intent(mAvoidOnResultFragment.activity, clazz)
return mAvoidOnResultFragment.startForResult(intent)
}
}

View File

@ -0,0 +1,7 @@
package com.gh.common.avoidcallback
import android.content.Intent
interface Callback {
fun onActivityResult(resultCode: Int, data: Intent?)
}

View File

@ -5,8 +5,6 @@ import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import androidx.annotation.Nullable;
import com.gh.common.util.GsonUtils;
import com.gh.common.util.PackageHelper;
import com.gh.common.util.PackageUtils;
@ -25,6 +23,8 @@ import org.greenrobot.eventbus.EventBus;
import java.util.List;
import androidx.annotation.Nullable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
@ -32,7 +32,6 @@ public class Config {
public static final String API_HOST = BuildConfig.API_HOST;
public static final String COMMENT_HOST = BuildConfig.COMMENT_HOST;
public static final String DATA_HOST = BuildConfig.DATA_HOST;
/**
* 需要配置的请使用{@link PreferenceManager#getDefaultSharedPreferences(Context)}
@ -235,6 +234,10 @@ public class Config {
return false;
}
public static boolean isGameDomeSwitchOpen() {
return getSettings().getGameDomeSwitch().equals("on");
}
public static void fixHideFunction() {
SharedPreferences preferences = PreferenceManager.
getDefaultSharedPreferences(HaloApp.getInstance().getApplication());

View File

@ -29,6 +29,8 @@ public class Constants {
public static final String EB_QUIT_LOGIN = "quit_login";
public static final String GAME_ID_DIVIDER = ":"; // 用于避免历史下载掺和到普通下载状态的 ID 修饰符
// 最近显示的弹窗信息
public static final String SP_LAST_OPENING_ID = "last_opening_dialog_id";
public static final String SP_LAST_OPENING_TIME = "last_opening_dialog_time";
@ -44,12 +46,36 @@ public class Constants {
public static final String SP_SHOWED_NOTIFICATION_NEW_VERSION = "show_notification_new_version";
// 今天是否已经触发了 “通知管理” 引导弹窗
public static final String SP_IS_SHOWED_NOTIFICATION_TODAY = "show_is_notification_today";
// 标记安装的游戏为已玩过弹窗最多取消2次 (https://gitlab.ghzs.com/pm/halo-app-issues/issues/722 调整为版本相关) (不是常量了也放这里好像有点奇怪)
// v4.0.0已废弃,标记安装的游戏为已玩过弹窗最多取消2次 (https://gitlab.ghzs.com/pm/halo-app-issues/issues/722 调整为版本相关) (不是常量了也放这里好像有点奇怪)
public static final String SP_MARK_INSTALLED_GAME = "mark_installed_game" + PackageUtils.getVersionName();
// 标记安装的游戏为已玩过弹窗(个人主页最多弹一次)
public static final String SP_MARK_INSTALLED_GAME_USER_HOME = "mark_installed_game_user_home" + PackageUtils.getVersionName();
// 标记安装的游戏为已玩过弹窗(我的游戏最多弹一次)
public static final String SP_MARK_INSTALLED_GAME_MY_GAME = "mark_installed_game_my_game" + PackageUtils.getVersionName();
//视频详情滑动引导
public static final String SP_SHOW_SLIDE_GUIDE = "show_slide_guide";
//视频详情点击引导
public static final String SP_SHOW_CLICK_GUIDE = "show_click_guide";
//视频详情双击点赞引导
public static final String SP_SHOW_DOUBLE_CLICK_GUIDE = "show_double_click_guide";
//顶部视频声音状态,重启恢复
public static final String SP_TOP_VIDEO_VOICE = "top_video_voice";
//我的光环提醒设置已读
public static final String SP_ADDONS_FUNCS_HAVE_READ = "addons_funcs_have_read";
//视频非wifi提醒只提醒一次重启恢复
public static final String SP_NON_WIFI_TIPS = "non_wifi_tips";
//首页视频最新tab提示
public static final String SP_HOME_NEW_VIDEO_TIPS = "home_new_video";
//游戏设备弹窗提示
public static final String SP_DEVICE_REMIND = "device_remind";
//是否是第一次弹出游戏设备弹窗提示
public static final String SP_FIRST_DEVICE_REMIND = "first_device_remind";
//游戏设备弹窗不再提示
public static final String SP_NO_REMIND_AGAIN = "no_remind_again";
//游戏详情过滤标签数据
public static final String SP_FILTER_TAGS= "filter_tags";
//实名认证弹窗分类数据
public static final String SP_AUTH_DIALOG= "auth_dialog";
//手机号码匹配规则
public static final String REGEX_MOBILE = "^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$";
@ -84,7 +110,9 @@ public class Constants {
public static final int COMMENT_CD = 60 * 1000;
//我的光环功能分组 cd间隔
public static final int ADDONS_CD = 10 * 60 * 1000;
//已收录包名更新 cd间隔
public static final int PACKAGES_CD = 60 * 1000;
public static final String[] REPORT_LIST = new String[]{"垃圾广告营销", "恶意攻击谩骂", "淫秽色情信息", "违法有害信息", "其它"};
public static final String ENTRANCE_UNKNOWN = "(unknown)";

View File

@ -13,9 +13,16 @@ import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import androidx.databinding.BindingAdapter;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.facebook.drawee.view.SimpleDraweeView;
import com.gh.base.OnViewClickListener;
import com.gh.common.constant.Config;
import com.gh.common.dialog.CertificationDialog;
import com.gh.common.dialog.ReserveDialogFragment;
import com.gh.common.exposure.ExposureEvent;
import com.gh.common.exposure.ExposureUtils;
@ -36,10 +43,10 @@ import com.gh.common.util.PackageUtils;
import com.gh.common.util.PermissionHelper;
import com.gh.common.util.PlatformUtils;
import com.gh.common.util.ReservationHelper;
import com.gh.common.view.DownloadDialog;
import com.gh.common.view.DownloadProgressBar;
import com.gh.common.view.DrawableView;
import com.gh.download.DownloadManager;
import com.gh.download.dialog.DownloadDialog;
import com.gh.gamecenter.DownloadManagerActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.WebActivity;
@ -65,12 +72,6 @@ import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Locale;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import androidx.databinding.BindingAdapter;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
/**
* Created by khy on 12/02/18.
*/
@ -198,6 +199,17 @@ public class BindingAdapters {
}
}
@BindingAdapter("textColorFromString")
public static void textColorFromString(TextView tv, String hexString) {
if (TextUtils.isEmpty(hexString)) return;
try {
tv.setTextColor(Color.parseColor(hexString));
} catch (Exception e) {
e.printStackTrace();
}
}
@BindingAdapter("visibleGone")
public static void showHide(View view, Boolean show) {
if (show != null && show) {
@ -207,6 +219,32 @@ public class BindingAdapters {
}
}
@BindingAdapter("goneIf")
public static void goneIf(View view, Boolean gone) {
if (gone != null && gone) {
view.setVisibility(View.GONE);
} else {
view.setVisibility(View.VISIBLE);
}
}
/**
* lazy 的 paddingTop
*/
@BindingAdapter("lazyPaddingTop")
public static void lazyPaddingTop(View view, int paddingTopInDp) {
view.setPadding(view.getPaddingLeft(), DisplayUtils.dip2px(paddingTopInDp), view.getPaddingRight(), view.getPaddingBottom());
}
@BindingAdapter("visibleInvisible")
public static void visibleInvisible(View view, Boolean show) {
if (show != null && show) {
view.setVisibility(View.VISIBLE);
} else {
view.setVisibility(View.INVISIBLE);
}
}
@BindingAdapter("messageUnread")
public static void setMessageUnread(TextView view, int unreadCount) {
if (unreadCount < 100) {
@ -358,17 +396,25 @@ public class BindingAdapters {
case PLUGIN:
if (gameEntity.getApk().size() == 1) {
ApkEntity apk = gameEntity.getApk().get(0);
DownloadDialogHelper.findAvailableDialogAndShow(
v.getContext(),
gameEntity,
apk,
DownloadDialogHelper.findAvailableDialogAndShow(v.getContext(), gameEntity, apk,
() -> {
DialogUtils.checkDownload(v.getContext(), apk.getSize(),
isSubscribe -> download(progressBar, gameEntity, traceEvent, isSubscribe, entrance, location));
CertificationDialog.showCertificationDialog(v.getContext(), gameEntity, () -> {
DialogUtils.showVersionNumberDialog(v.getContext(), gameEntity, () -> {
DialogUtils.checkDownload(v.getContext(), apk.getSize(),
isSubscribe -> download(progressBar, gameEntity, traceEvent, isSubscribe, entrance, location));
});
});
});
} else {
DownloadDialog.getInstance(v.getContext()).showPopupWindow(v, gameEntity,
entrance, location + gameEntity.getName(), traceEvent);
CertificationDialog.showCertificationDialog(v.getContext(), gameEntity, () -> {
DialogUtils.showVersionNumberDialog(v.getContext(), gameEntity, () -> {
DownloadDialog.showDownloadDialog(
v.getContext(),
gameEntity,
entrance,
location + ":" + gameEntity.getName());
});
});
}
break;
case LAUNCH_OR_OPEN:
@ -376,8 +422,11 @@ public class BindingAdapters {
DataUtils.onGameLaunchEvent(v.getContext(), gameEntity.getName(), gameEntity.getApk().get(0).getPlatform(), location);
PackageUtils.launchApplicationByPackageName(v.getContext(), gameEntity.getApk().get(0).getPackageName());
} else {
DownloadDialog.getInstance(v.getContext()).showPopupWindow(v, gameEntity,
entrance, location + gameEntity.getName(), traceEvent);
DownloadDialog.showDownloadDialog(
v.getContext(),
gameEntity,
entrance,
location + ":" + gameEntity.getName());
}
break;
case INSTALL_PLUGIN:
@ -455,7 +504,7 @@ public class BindingAdapters {
}
progressBar.setDownloadType(DownloadProgressBar.DownloadType.NONE);
}
} else {
String status = GameUtils.getDownloadBtnText(progressBar.getContext(), gameEntity, PluginLocation.only_game);
switch (status) {
@ -511,6 +560,23 @@ public class BindingAdapters {
}
}
/*private static void download(DownloadProgressBar progressBar, GameEntity gameEntity, ExposureEvent traceEvent, @Nullable String entrance, @Nullable String location, View v) {
if (gameEntity.getApk().size() == 1) {
ApkEntity apk = gameEntity.getApk().get(0);
DownloadDialogHelper.findAvailableDialogAndShow(
v.getContext(),
gameEntity,
apk,
() -> {
DialogUtils.checkDownload(v.getContext(), apk.getSize(),
isSubscribe -> download(progressBar, gameEntity, traceEvent, isSubscribe, entrance, location));
});
} else {
DownloadDialog.getInstance(v.getContext()).showPopupWindow(v, gameEntity,
entrance, location + gameEntity.getName(), traceEvent);
}
}*/
private static void updateReservation(DownloadProgressBar progressBar, GameEntity gameEntity) {
// 显示预约
@ -546,10 +612,10 @@ public class BindingAdapters {
String msg = FileUtils.isCanDownload(progressBar.getContext(), apkEntity.getSize());
if (TextUtils.isEmpty(msg)) {
DataUtils.onGameDownloadEvent(progressBar.getContext(), gameEntity.getName(), apkEntity.getPlatform(), entrance, "下载开始", method);
ExposureUtils.DownloadType downloadType = ExposureUtils.getDownloadType(apkEntity, method);
ExposureEvent downloadExposureEvent = ExposureUtils.logADownloadExposureEvent(gameEntity, apkEntity.getPlatform(), traceEvent, downloadType);
DownloadManager.createDownload(progressBar.getContext(),
apkEntity,
gameEntity,
@ -567,27 +633,9 @@ public class BindingAdapters {
}
}
@BindingAdapter({"gameLabelList", "subjectTag"})
public static void setGameLabelList(LinearLayout layout, GameEntity gameEntity, String subjectTag) {
if (gameEntity == null) return;
if (gameEntity.getTest() != null) {
layout.removeAllViews();
View testView = LayoutInflater.from(layout.getContext()).inflate(R.layout.game_test_label, null);
TextView testType = testView.findViewById(R.id.test_type);
TextView testTime = testView.findViewById(R.id.test_time);
testType.setText(gameEntity.getTest().getType());
testType.setBackgroundColor(ContextCompat.getColor(layout.getContext(), R.color.tag_yellow));
if (gameEntity.getTest().getStart() == 0) {
testTime.setVisibility(View.GONE);
} else {
testTime.setText(GameViewUtils.getGameTestDate(gameEntity.getTest().getStart()));
}
layout.addView(testView);
} else {
GameViewUtils.setLabelList(layout.getContext(), layout, gameEntity.getTag(), subjectTag, gameEntity.getTagStyle());
}
@BindingAdapter("gameLabelList")
public static void setGameLabelList(LinearLayout layout, List<TagStyleEntity> tagStyle) {
GameViewUtils.setLabelList(layout.getContext(), layout, tagStyle);
}
@BindingAdapter("isRefreshing")

View File

@ -15,6 +15,7 @@ abstract class BaseTrackableDialogFragment : BaseDialogFragment() {
abstract fun getEvent(): String
abstract fun getKey(): String
open fun getValue(): String = ""
// 区分此 dialog 是点击 dialog 外部取消的还是点击返回取消的
private val mIsCanceledByClickOutsideOfDialog = AtomicBoolean(true)
@ -47,6 +48,9 @@ abstract class BaseTrackableDialogFragment : BaseDialogFragment() {
MtaHelper.onEventWithBasicDeviceInfo(getEvent(), getKey(), value)
} else {
MtaHelper.onEvent(getEvent(), getKey(), value)
if (getValue().isNotEmpty()) {
MtaHelper.onEvent(getEvent(), value, getValue())
}
}
}

View File

@ -0,0 +1,196 @@
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.common.avoidcallback.AvoidOnResultManager
import com.gh.common.avoidcallback.Callback
import com.gh.common.constant.Constants
import com.gh.common.util.CheckLoginUtils
import com.gh.common.util.DialogUtils
import com.gh.common.util.GsonUtils
import com.gh.common.util.SPUtils
import com.gh.gamecenter.R
import com.gh.gamecenter.UserInfoEditActivity
import com.gh.gamecenter.WebActivity
import com.gh.gamecenter.entity.AuthDialogEntity
import com.gh.gamecenter.entity.AuthDialogLevel
import com.gh.gamecenter.entity.DeviceDialogEntity
import com.gh.gamecenter.entity.GameEntity
import com.gh.gamecenter.manager.UserManager
import com.gh.gamecenter.retrofit.BiResponse
import com.gh.gamecenter.retrofit.Response
import com.gh.gamecenter.retrofit.RetrofitManager
import com.gh.gamecenter.user.UserViewModel
import com.google.gson.reflect.TypeToken
import com.halo.assistant.fragment.user.UserInfoEditFragment
import com.lightgame.utils.AppManager
import com.tencent.bugly.beta.tinker.TinkerManager.getApplication
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import okhttp3.ResponseBody
import retrofit2.HttpException
class CertificationDialog(context: Context, private val authDialogEntity: AuthDialogEntity, val gameId: String, val listener: DialogUtils.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 {
context.startActivity(WebActivity.getIntentByUrl(context, authDialogEntity.link))
}
when (authDialogEntity.level) {
AuthDialogLevel.MUST_PASS.value -> {
actionLeftTv.text = "暂不下载"
actionRightTv.text = "去实名认证"
noRemindAgainCb.visibility = View.GONE
actionLeftTv.setOnClickListener {
dismiss()
}
actionRightTv.setOnClickListener {
if (UserManager.getInstance().isLoggedIn) {
gotoAuthPage()
} else {
gotoLoginPage()
}
}
}
AuthDialogLevel.ALWAYS_HINT.value -> {
actionLeftTv.text = "去实名认证"
actionRightTv.text = "继续下载"
noRemindAgainCb.visibility = View.GONE
actionLeftTv.setOnClickListener {
if (UserManager.getInstance().isLoggedIn) {
gotoAuthPage()
} else {
gotoLoginPage()
}
}
actionRightTv.setOnClickListener {
listener.onConfirm()
dismiss()
}
}
AuthDialogLevel.OPTIONAL_HINT.value -> {
actionLeftTv.text = "去实名认证"
actionRightTv.text = "继续下载"
noRemindAgainCb.visibility = View.VISIBLE
actionLeftTv.setOnClickListener {
if (noRemindAgainCb.isChecked) {
SPUtils.setBoolean(gameId, true)
}
if (UserManager.getInstance().isLoggedIn) {
gotoAuthPage()
} else {
gotoLoginPage()
}
}
actionRightTv.setOnClickListener {
if (noRemindAgainCb.isChecked) {
SPUtils.getBoolean(gameId, true)
}
listener.onConfirm()
dismiss()
}
}
}
}
//跳转登录页面
private fun gotoLoginPage() {
CheckLoginUtils.checkLogin(AppManager.getInstance().currentActivity() as AppCompatActivity,
null, true, "实名认证弹窗") {
if (UserManager.getInstance().isAuth) {
listener.onConfirm()
dismiss()
}
}
}
//跳转实名认证页面
private fun gotoAuthPage() {
AvoidOnResultManager.getInstance(AppManager.getInstance().currentActivity() as AppCompatActivity)
.startForResult(UserInfoEditActivity.getIntent(context, UserViewModel.TYPE_ID_CARD), object : Callback {
override fun onActivityResult(resultCode: Int, data: Intent?) {
if (resultCode == Activity.RESULT_OK && data != null) {
val isAuthSuccess = data.getBooleanExtra(UserInfoEditFragment.AUTH_SUCCESS, false)
if (isAuthSuccess) {
listener.onConfirm()
dismiss()
}
}
}
})
}
companion object {
@JvmStatic
fun showCertificationDialog(context: Context, game: GameEntity, listener: DialogUtils.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: DialogUtils.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.id, listener)
dialog.show()
} else {
listener.onConfirm()
}
}
}
}

View File

@ -0,0 +1,234 @@
package com.gh.common.dialog
import android.app.Dialog
import android.content.Context
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.os.Build
import android.os.Bundle
import android.os.Handler
import android.os.Message
import android.preference.PreferenceManager
import android.view.LayoutInflater
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.LinearLayout
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import androidx.viewpager2.widget.ViewPager2
import com.facebook.drawee.view.SimpleDraweeView
import com.gh.common.constant.Constants
import com.gh.common.util.*
import com.gh.download.DownloadManager
import com.gh.gamecenter.R
import com.gh.gamecenter.entity.DeviceDialogEntity
import com.gh.gamecenter.entity.GameEntity
import com.google.gson.reflect.TypeToken
import com.halo.assistant.fragment.SettingsFragment.AUTO_INSTALL_SP_KEY
import com.lightgame.download.DataWatcher
import com.lightgame.download.DownloadEntity
import com.lightgame.download.DownloadStatus
import com.lightgame.utils.Utils
import io.reactivex.disposables.Disposable
import kotlinx.android.synthetic.main.dialog_device_remind.view.*
import java.lang.ref.WeakReference
/**
* 设备提醒弹窗
*/
class DeviceRemindDialog(context: Context, val entity: DeviceDialogEntity, val gameEntity: GameEntity) : Dialog(context, R.style.GhAlertDialog) {
private lateinit var view: View
private var currentPage = 0
private var mSlideLooperInterval = 3000L
private lateinit var mLooperHandle: LooperHandle
private lateinit var mAdapter: BannerAdapter
private var mDatas: ArrayList<String> = ArrayList()
private val mSlideLooperKey = 100
private var disposable: Disposable? = null
private val dataWatcher = object : DataWatcher() {
override fun onDataChanged(downloadEntity: DownloadEntity) {
if (downloadEntity.status == DownloadStatus.done && downloadEntity.name == gameEntity.name) {
val sp = PreferenceManager.getDefaultSharedPreferences(getContext())
val autoInstall = sp.getBoolean(AUTO_INSTALL_SP_KEY, true)
if (autoInstall) {
dismiss()
}
}
}
}
companion object {
fun showDeviceRemindDialog(context: Context, gameEntity: GameEntity) {
val datas = SPUtils.getString(Constants.SP_DEVICE_REMIND)
if (datas.isNotEmpty()) {
val type = object : TypeToken<List<DeviceDialogEntity>>() {}.type
val entitys = GsonUtils.gson.fromJson<List<DeviceDialogEntity>>(datas, type)
//1.判断设备是否匹配
val entity = entitys.find { it.manufacturer.toLowerCase().startsWith(Build.MANUFACTURER.toLowerCase()) }
?: return
//2.判断游戏不含剔除标签
gameEntity.tagStyle.forEach {
if (entity.excludeTags.contains(it.name)) {
return
}
}
//3.不再弹出提示判断
val isNoRemindAgain = SPUtils.getBoolean(Constants.SP_NO_REMIND_AGAIN, false)
if (isNoRemindAgain) return
val dialog = DeviceRemindDialog(context, entity, gameEntity)
dialog.show()
}
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
view = LayoutInflater.from(context).inflate(R.layout.dialog_device_remind, null)
setContentView(view)
mDatas.addAll(entity.gallery)
view.titleTv.text = entity.title
view.contentTv.text = entity.content
view.bannerView.apply {
orientation = ViewPager2.ORIENTATION_HORIZONTAL
mAdapter = BannerAdapter()
val recyclerView = getChildAt(0) as RecyclerView
recyclerView.overScrollMode = RecyclerView.OVER_SCROLL_NEVER
registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
override fun onPageSelected(position: Int) {
super.onPageSelected(position)
currentPage = position
slideIndicator(currentPage % mDatas.size)
}
})
recyclerView.addOnItemTouchListener(object : RecyclerView.SimpleOnItemTouchListener() {
override fun onInterceptTouchEvent(rv: RecyclerView, e: MotionEvent): Boolean {
val isStop = e.action == MotionEvent.ACTION_DOWN || e.action == MotionEvent.ACTION_MOVE
if (isStop) mAdapter.stopScroll() else mAdapter.startScroll()
return false
}
})
adapter = mAdapter
mLooperHandle = LooperHandle(mAdapter)
currentPage = (adapter as BannerAdapter).getActualFirstPositionInCenter()
setCurrentItem(currentPage, false)
if (mDatas.size > 1) {
addIndicator()
slideIndicator(currentPage % mDatas.size)
autoPlay()
}
}
val isFirst = SPUtils.getBoolean(Constants.SP_FIRST_DEVICE_REMIND, false)
if (!isFirst) {
view.cancelTv.isEnabled = false
view.cancelTv.background = ContextCompat.getDrawable(context, R.drawable.button_round_f5f5f5)
disposable = countDownTimer(3) { finish, time ->
if (finish) {
view.cancelTv.isEnabled = true
view.cancelTv.background = ContextCompat.getDrawable(context, R.drawable.button_blue_oval)
view.cancelTv.text = "我知道了"
view.cancelTv.setTextColor(ContextCompat.getColor(context, R.color.white))
} else {
view.cancelTv.text = "我知道了(${time}S)"
}
}
SPUtils.setBoolean(Constants.SP_FIRST_DEVICE_REMIND, true)
} else {
view.noRemindAgainCb.visibility = View.VISIBLE
view.cancelTv.text = "我知道了"
view.cancelTv.isEnabled = true
view.cancelTv.setTextColor(ContextCompat.getColor(context, R.color.white))
view.cancelTv.background = ContextCompat.getDrawable(context, R.drawable.button_blue_oval)
}
view.cancelTv.setOnClickListener {
SPUtils.setBoolean(Constants.SP_NO_REMIND_AGAIN, view.noRemindAgainCb.isChecked)
dismiss()
}
DownloadManager.getInstance(context).addObserver(dataWatcher)
}
private fun addIndicator() {
view.indicatorLl.removeAllViews()
mDatas.forEach { _ ->
val indicatorView = ImageView(context).apply {
setImageResource(R.drawable.selector_device_remind_indicator)
val params = LinearLayout.LayoutParams(DisplayUtils.dip2px(8F), LinearLayout.LayoutParams.WRAP_CONTENT)
params.leftMargin = DisplayUtils.dip2px(1F)
params.rightMargin = DisplayUtils.dip2px(1F)
layoutParams = params
}
view.indicatorLl.addView(indicatorView)
}
}
private fun slideIndicator(position: Int) {
for (i in 0 until view.indicatorLl.childCount) {
val childAt = view.indicatorLl.getChildAt(i)
childAt.isSelected = i == position
}
}
private fun autoPlay() {
mAdapter.startScroll()
}
inner class BannerAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
return object : RecyclerView.ViewHolder(LayoutInflater.from(context).inflate(R.layout.item_ad_banner, parent, false)) {}
}
override fun getItemCount(): Int = if (mDatas.size == 1) mDatas.size else Int.MAX_VALUE
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
val data = mDatas[position % mDatas.size]
val view = holder.itemView as SimpleDraweeView
ImageUtils.display(view, data)
}
fun getActualFirstPositionInCenter(): Int {
if (mDatas.size == 1) return 0
var index = itemCount / 2
if (index % mDatas.size != 0) {
index -= (index % mDatas.size)
}
return index
}
fun scrollToNextPage() {
currentPage++
view.bannerView.setCurrentItem(currentPage, true)
}
fun startScroll() {
mLooperHandle.removeMessages(mSlideLooperKey)
mLooperHandle.sendEmptyMessageDelayed(mSlideLooperKey, mSlideLooperInterval)
}
fun stopScroll() {
mLooperHandle.removeMessages(mSlideLooperKey)
}
}
class LooperHandle(val mAdapter: BannerAdapter) : Handler() {
private val mWeakReference: WeakReference<BannerAdapter> = WeakReference(mAdapter)
override fun handleMessage(msg: Message?) {
val adapter = mWeakReference.get()
adapter?.scrollToNextPage()
adapter?.startScroll()
}
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
if (disposable != null && !disposable!!.isDisposed) {
disposable!!.dispose()
disposable = null
}
DownloadManager.getInstance(context).removeObserver(dataWatcher)
}
}

View File

@ -38,7 +38,7 @@ class GameOffServiceDialogFragment : BaseTrackableDialogFragment() {
topMargin = DisplayUtils.dip2px(12f)
}
siteTv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14f)
siteTv.setTextColor(ContextCompat.getColor(requireContext(), R.color.theme))
siteTv.setTextColor(ContextCompat.getColor(requireContext(), R.color.theme_font))
siteTv.text = site.text
siteTv.paintFlags = siteTv.paintFlags or Paint.UNDERLINE_TEXT_FLAG
siteTv.setOnClickListener {

View File

@ -37,7 +37,7 @@ class NotificationHintDialogFragment : BaseTrackableDialogFragment() {
titleTv.text = mNotificationHint?.title
contentContainer.removeAllViews()
for (item in mNotificationHint?.content!!) {
for (item in mNotificationHint?.content ?: arrayListOf()) {
val tv = TextView(context)
tv.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT).apply {

View File

@ -8,12 +8,13 @@ import com.gh.common.util.MtaHelper
import java.util.concurrent.atomic.AtomicBoolean
open class TrackableDialog(context: Context,
themeResId: Int,
private var mEvent: String,
private var mKey: String,
private var mCancelValue: String? = null,
private var mKeyBackValue: String? = null,
private var mLogShowEvent: Boolean = true)
themeResId: Int,
private var mEvent: String,
private var mKey: String,
private var mValue: String? = null,
private var mCancelValue: String? = null,
private var mKeyBackValue: String? = null,
private var mLogShowEvent: Boolean = true)
: Dialog(context, themeResId) {
// 区分此 dialog 是点击 dialog 外部取消的还是点击返回取消的
@ -25,6 +26,9 @@ open class TrackableDialog(context: Context,
setOnCancelListener {
if (mIsCanceledByClickOutsideOfDialog.get()) {
MtaHelper.onEvent(mEvent, mKey, mCancelValue ?: "点击空白")
if (!mValue.isNullOrEmpty()) {
MtaHelper.onEvent(mEvent, "点击空白", mValue)
}
}
}
@ -32,6 +36,9 @@ open class TrackableDialog(context: Context,
if (keyCode == KeyEvent.KEYCODE_BACK && event.action == KeyEvent.ACTION_UP) {
mIsCanceledByClickOutsideOfDialog.set(false)
MtaHelper.onEvent(mEvent, mKey, mKeyBackValue ?: "点击返回")
if (mValue != null) {
MtaHelper.onEvent(mEvent, "点击返回", mValue)
}
}
false
}
@ -41,6 +48,9 @@ open class TrackableDialog(context: Context,
super.show()
if (mLogShowEvent) {
MtaHelper.onEvent(mEvent, mKey, "出现弹窗")
if (!mValue.isNullOrEmpty()) {
MtaHelper.onEvent(mEvent, "出现弹窗", mValue)
}
}
}

View File

@ -31,9 +31,9 @@ object ExposureManager {
private val loghubHelper = LoghubHelper.getInstance()
// exposureCache 用来过滤掉具有相同 id 的曝光事件,避免重复发送事件
private val exposureSet = hashSetOf<ExposureEvent>()
private val exposureExecutor = Executors.newSingleThreadExecutor()
private val exposureCache = FixedSizeLinkedHashSet<String>(300)
private val exposureSet by lazy { hashSetOf<ExposureEvent>() }
private val exposureExecutor by lazy { Executors.newSingleThreadExecutor() }
private val exposureCache by lazy { FixedSizeLinkedHashSet<String>(300) }
private val exposureDao by lazy { ExposureDatabase.buildDatabase(HaloApp.getInstance().application).logHubEventDao() }
@JvmStatic

View File

@ -4,6 +4,7 @@ import android.app.Activity
import android.app.NotificationManager
import android.content.Context
import com.gh.base.CurrentActivityHolder
import com.gh.common.runOnIoThread
import com.gh.common.util.SPUtils
import com.gh.common.util.tryWithDefaultCatch
import com.gh.gamecenter.BuildConfig
@ -128,7 +129,7 @@ object ImManager {
@JvmStatic
fun sendFeedbackMessage(message: String) {
val fromToMessage = IMMessage.createTxtMessage(message)
HaloApp.getInstance().mainExecutor.execute {
runOnIoThread {
tryWithDefaultCatch {
IMChat.getInstance().sendMessage(fromToMessage, object : ChatListener {
override fun onProgress(p0: Int) {}

View File

@ -15,7 +15,7 @@ object LoghubUtils {
private lateinit var mApplication: Application
private val loghubEventSet = hashSetOf<LoghubEvent>()
private val loghubEventSet by lazy { hashSetOf<LoghubEvent>() }
private val loghubEventExecutor by lazy { Executors.newSingleThreadExecutor() }
private val loghubEventDao by lazy { LoghubDatabase.buildDatabase(mApplication).logHubEventDao() }
@ -75,8 +75,16 @@ object LoghubUtils {
}
val log = Log()
log.PutContent("current time ", event.time)
log.PutContent("content", event.content)
// 特殊处理以下logStore不需要用content包裹数据
if (event.logStore == "collection" || event.logStore == "common" || event.logStore == "halo-api-device-installed") {
val contentJson = JSONObject(event.content)
for (key in contentJson.keys()) {
log.PutContent(key, contentJson.get(key).toString())
}
} else {
log.PutContent("current time ", event.time)
log.PutContent("content", event.content)
}
logGroupHashMap[event.logStore]?.PutLog(log)
}

View File

@ -0,0 +1,12 @@
package com.gh.common.syncpage
interface ISyncAdapterHandler {
/**
* @param position position to query
* @return Pair first: item sync id
* Pair second: item data entity
*/
fun getSyncData(position: Int): Pair<String, Any>?
}

View File

@ -0,0 +1,43 @@
package com.gh.common.syncpage
import androidx.annotation.Keep
@Keep
data class SyncDataEntity(
/**
* 标识一条数据的唯一ID
*
* 与[ISyncAdapterHandler.getSyncData]返回的Pair first一致
*/
val syncId: String,
/**
* 需要同步的字段名
*
* 与@SyncPage注解的值一致
*/
val syncFieldName: String?,
/**
* 需要同步的具体内容
*/
val syncFieldValue: Any?,
/**
* 同步完一次是否自动删除
*/
val remove: Boolean = true,
/**
* 是否需要查询同步实体的父级字段
*
* 由于反射可能会导致较大的性能消耗,默认关闭,具体按实际情况开启
*/
val checkInherited: Boolean = false,
/**
* 是否需要查询同步实体的嵌套实体内容
*
* 由于反射可能会导致较大的性能消耗,默认关闭,具体按实际情况开启
*/
val checkFieldEntity: Boolean = false)

View File

@ -0,0 +1,20 @@
package com.gh.common.syncpage
object SyncFieldConstants {
// 是否点赞
const val ANSWER_VOTE = "ANSWER_VOTE"
const val ARTICLE_VOTE = "ARTICLE_VOTE"
// 赞同数量
const val ANSWER_VOTE_COUNT = "ANSWER_VOTE_COUNT"
const val ARTICLE_VOTE_COUNT = "ARTICLE_VOTE_COUNT"
// 评论数量
const val ANSWER_COMMENT_COUNT = "ANSWER_COMMENT_COUNT"
const val ARTICLE_COMMENT_COUNT = "ARTICLE_COMMENT_COUNT"
// 回答数量
const val ANSWER_COUNT = "ANSWER_COUNT"
}

View File

@ -0,0 +1,154 @@
package com.gh.common.syncpage
import androidx.lifecycle.MutableLiveData
import com.gh.common.annotation.SyncIgnore
import com.gh.common.annotation.SyncPage
import com.gh.common.util.debugOnly
import com.gh.common.util.toJson
import com.gh.common.util.tryCatchInRelease
import com.halo.assistant.HaloApp
import com.lightgame.utils.Utils
import java.lang.reflect.Field
/**
* 页面之间实现数据同步(主要是单个字段的同步)
*
* 实现思路:
* 1.把需要同步的数据以一个特殊ID作为唯一标识并存于一个全局的仓库
* 2.利用LiveData进行页面回调,再通过[ISyncAdapterHandler.getSyncData]找到需要被同步的数据
* 3.最后利用反射进行数据替换,具体请见[SyncPageRepository.replaceSyncData]
*
* 具体的接入方式(以列表为例)
* 1.通过[SyncPageRepository.postSyncData]提交同步数据
* 2.在Fragment重写[BaseFragment.addSyncPageObserver]开启同步事件监听
* 3.在Fragment重写[BaseFragment.provideSyncAdapter]提供获取数据的来源
* - [BaseFragment.provideSyncAdapter]提供的Adapter必须实现[ISyncAdapterHandler]接口
*
*/
object SyncPageRepository {
// 只有在新增操作时,才需要进行页面刷新
val syncPageLiveData = MutableLiveData<List<SyncDataEntity>>()
val syncDataList = ArrayList<SyncDataEntity>()
// size: 防止删除刚刚添加的数据
@JvmStatic
fun clearSyncData() {
tryCatchInRelease {
synchronized(syncDataList) {
if (syncDataList.size > 0) {
debugOnly {
Utils.log("SyncPageRepository clearSyncData 存在" + syncDataList.size + "条数据尚未处理,即将删除")
}
syncDataList.clear()
}
}
}
}
@JvmStatic
fun removeSyncData(list: List<SyncDataEntity>) {
tryCatchInRelease {
synchronized(syncDataList) {
for (syncDataEntity in list) {
val remove = syncDataList.remove(syncDataEntity)
debugOnly {
Utils.log("SyncPageRepository removeSyncData ->" + syncDataEntity.syncId +
", fieldName->" + syncDataEntity.syncFieldName +
", remove->" + remove)
}
}
}
}
debugOnly {
Utils.log("SyncPageRepository removeSyncData ->" + syncDataList.size)
}
}
// 提交同步数据
fun postSyncData(entity: SyncDataEntity) {
tryCatchInRelease {
synchronized(syncDataList) {
// 检查是否存在重复操作
for (syncDataEntity in syncDataList) {
if (syncDataEntity.syncId == entity.syncId && syncDataEntity.syncFieldName == entity.syncFieldName) {
syncDataList.remove(syncDataEntity)
debugOnly {
Utils.log("SyncPageRepository postSyncData 存在重复操作->" + entity.toJson())
}
break
}
}
syncDataList.add(entity)
syncPageLiveData.postValue(syncDataList)
debugOnly {
Utils.log("SyncPageRepository postSyncData->" + entity.toJson())
}
}
}
}
fun handleSyncData(rawData: Any, syncData: SyncDataEntity): Boolean {
val fields = if (syncData.checkInherited) {
getAllFieldsList(rawData::class.java)
} else rawData::class.java.declaredFields.toList()
var isNeedNotify = false
for (field in fields) {
isNeedNotify = replaceSyncData(field, rawData, syncData)
if (isNeedNotify) break
}
if (!isNeedNotify) {
debugOnly {
Utils.log("SyncPageRepository sync failure-> " + syncData.syncFieldName)
}
}
return isNeedNotify
}
private fun replaceSyncData(field: Field, extractObject: Any, syncData: SyncDataEntity): Boolean {
field.getAnnotation(SyncPage::class.java)?.syncNames?.forEach { syncName ->
if (syncName == syncData.syncFieldName && field.getAnnotation(SyncIgnore::class.java) == null) {
field.isAccessible = true
debugOnly {
Utils.log("SyncPageRepository sync success-> " + syncData.syncFieldName + ", fieldName->" + field.name + ", fieldValue->" + field.get(extractObject))
}
field.set(extractObject, syncData.syncFieldValue)
return true
}
}
if (syncData.checkFieldEntity) {
// 递归查询
val pkgName = field.type.getPackage()?.name ?: return false
if (pkgName.contains(HaloApp.getInstance().application.packageName) && field.getAnnotation(SyncIgnore::class.java) == null) {
field.isAccessible = true
val extractEntityObject = field.get(extractObject) ?: return false
field.type.declaredFields.forEach {
if (replaceSyncData(it, extractEntityObject, syncData)) return true
}
}
}
return false
}
// 包括父类 Field 对象
private fun getAllFieldsList(cls: Class<*>?): List<Field> {
if (cls == null) return arrayListOf()
val allFields = arrayListOf<Field>()
var currentClass = cls
while (currentClass != null) {
val declaredFields = currentClass.declaredFields
allFields.addAll(declaredFields)
currentClass = currentClass.superclass
}
return allFields
}
}

View File

@ -0,0 +1,98 @@
package com.gh.common.syncpage.example
import android.content.Context
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.gh.common.constant.ItemViewType
import com.gh.common.syncpage.ISyncAdapterHandler
import com.gh.gamecenter.R
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder
import com.gh.gamecenter.baselist.ListAdapter
import com.gh.gamecenter.databinding.CommunityAnswerItemBinding
import com.gh.gamecenter.manager.UserManager
import com.gh.gamecenter.qa.answer.CommunityAnswerItemViewHolder
import com.gh.gamecenter.qa.answer.detail.AnswerDetailActivity
import com.gh.gamecenter.qa.article.detail.ArticleDetailActivity
import com.gh.gamecenter.qa.entity.AnswerEntity
import com.gh.gamecenter.qa.entity.Questions
import com.gh.gamecenter.qa.questions.detail.QuestionsDetailActivity
class ExampleAdapter(context: Context) : ListAdapter<AnswerEntity>(context), ISyncAdapterHandler {
override fun areItemsTheSame(oldItem: AnswerEntity?, newItem: AnswerEntity?): Boolean {
return oldItem?.id == newItem?.id
}
override fun getItemViewType(position: Int): Int {
if (position == itemCount - 1) return ItemViewType.ITEM_FOOTER
return ItemViewType.ITEM_BODY
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
val view: View
return when (viewType) {
ItemViewType.ITEM_FOOTER -> {
view = mLayoutInflater.inflate(R.layout.refresh_footerview, parent, false)
FooterViewHolder(view)
}
else -> {
view = mLayoutInflater.inflate(R.layout.community_answer_item, parent, false)
CommunityAnswerItemViewHolder(CommunityAnswerItemBinding.bind(view))
}
}
}
override fun getItemCount(): Int {
return if (mEntityList.isNotEmpty()) mEntityList.size + FOOTER_ITEM_COUNT else 0
}
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
when (getItemViewType(position)) {
ItemViewType.ITEM_BODY -> {
val answer = mEntityList[position]
if ("community_article" == answer.type) {
val questions = Questions()
questions.title = answer.articleTitle
answer.questions = questions
}
val answerViewHolder = holder as CommunityAnswerItemViewHolder
val binding = answerViewHolder.binding
answerViewHolder.bindAnswerItem(answer, "", getPath())
binding.title.setOnClickListener {
if ("community_article" == answer.type) {
mContext.startActivity(ArticleDetailActivity.getIntent(mContext, UserManager.getInstance().community, answer.id!!, "", getPath()))
} else {
val questions = answer.questions
mContext.startActivity(QuestionsDetailActivity.getIntent(mContext, questions.id, "", getPath()))
}
}
answerViewHolder.itemView.setOnClickListener {
if ("community_article" == answer.type) {
mContext.startActivity(ArticleDetailActivity.getIntent(mContext, UserManager.getInstance().community, answer.id!!, "", getPath()))
} else {
mContext.startActivity(AnswerDetailActivity.getIntent(mContext, answer.id, "", getPath()))
}
}
}
ItemViewType.ITEM_FOOTER -> {
val footerViewHolder = holder as FooterViewHolder
footerViewHolder.initItemPadding()
footerViewHolder.initFooterViewHolder(mIsLoading, mIsNetworkError, mIsOver, R.string.ask_loadover_hint)
}
}
}
override fun getSyncData(position: Int): Pair<String, AnswerEntity>? {
if (position >= mEntityList.size) return null
val entity = mEntityList[position]
return Pair(entity.id ?: "", entity)
}
fun getPath(): String {
return "问答-推荐-按时间"
}
}

View File

@ -0,0 +1,65 @@
package com.gh.common.syncpage.example
import android.os.Bundle
import android.view.View
import androidx.lifecycle.ViewModelProviders
import androidx.recyclerview.widget.RecyclerView
import com.gh.common.view.VerticalItemDecoration
import com.gh.gamecenter.baselist.ListFragment
import com.gh.gamecenter.baselist.NormalListViewModel
import com.gh.gamecenter.manager.UserManager
import com.gh.gamecenter.qa.entity.AnswerEntity
import com.gh.gamecenter.retrofit.RetrofitManager
import com.halo.assistant.HaloApp
import io.reactivex.Observable
class ExampleFragment : ListFragment<AnswerEntity, NormalListViewModel<AnswerEntity>>() {
private var mAdapter: ExampleAdapter? = null
override fun provideListAdapter(): ExampleAdapter {
if (mAdapter == null) {
mAdapter = ExampleAdapter(requireContext())
}
return mAdapter!!
}
override fun getItemDecoration(): RecyclerView.ItemDecoration {
return VerticalItemDecoration(context, 8F, false)
}
override fun provideDataObservable(page: Int): Observable<MutableList<AnswerEntity>> {
return RetrofitManager.getInstance(context).api.getCommunitiesRecommendNewest(UserManager.getInstance().community.id, page)
}
override fun provideListViewModel(): NormalListViewModel<AnswerEntity> {
val factory = NormalListViewModel.Factory(HaloApp.getInstance().application, this)
return ViewModelProviders.of(this, factory).get(NormalListViewModel::class.java) as NormalListViewModel<AnswerEntity>
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
// SyncPageRepository.syncPageLiveData.observe(this, Observer {
// it ?: return@Observer
// val adapter = mListRv.adapter
// if (adapter !is ISyncAdapterHandler) return@Observer
// for(position in 0 until adapter.itemCount) {
// val syncKey = adapter.getSyncData(position)
// for (syncDataEntity in it) {
// if (syncDataEntity.syncId == syncKey?.first) {
// val isSuccess = SyncPageRepository.handleSyncData(syncKey.second, syncDataEntity)
// if (isSuccess) adapter.notifyItemChanged(position)
// }
// }
// }
// })
}
override fun provideSyncAdapter(): RecyclerView.Adapter<*>? {
return mListRv.adapter
}
override fun addSyncPageObserver(): Boolean {
return true
}
}

View File

@ -1,13 +1,17 @@
package com.gh.common.util;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import com.gh.common.avoidcallback.Callback;
import com.gh.gamecenter.LoginActivity;
import com.gh.gamecenter.manager.UserManager;
import com.lightgame.utils.Utils;
import org.jetbrains.annotations.Nullable;
/**
* Created by khy on 28/06/17.
*/
@ -32,6 +36,28 @@ public class CheckLoginUtils {
}
}
public static void checkLogin(final Context context, Bundle nextToBundle, boolean isTriggerNextStep, String entrance, OnLoginListener listener) {
if (!isLogin()) {
if (listener != null) Utils.toast(context, "需要登录");
LogUtils.login("dialog", null, entrance);
LogUtils.login("activity", null, entrance);
// 有可能App未启动
Bundle bundle = new Bundle();
bundle.putString(EntranceUtils.KEY_ENTRANCE, entrance);
bundle.putString(EntranceUtils.KEY_TO, LoginActivity.class.getName());
EntranceUtils.jumpActivity(context, nextToBundle, bundle, (resultCode, data) -> {
if (isTriggerNextStep && listener != null && isLogin()) {
listener.onLogin();
}
});
} else {
if (listener != null) {
listener.onLogin();
}
}
}
public static boolean isLogin() {
return !TextUtils.isEmpty(UserManager.getInstance().getToken());
}

View File

@ -72,11 +72,6 @@ object CommentHelper {
videoId: String? = null,
listener: OnCommentCallBackListener? = null) {
val dialogOptions = ArrayList<String>()
if (commentEntity.me == null || !commentEntity.me?.isCommentOwner!!) {
dialogOptions.add("回复")
}
dialogOptions.add("复制")
dialogOptions.add("投诉")
@ -97,18 +92,6 @@ object CommentHelper {
when (it) {
"管理" -> showControlDialog(context, answerId, articleId, communityId, commentEntity, commentEntity.me!!)
"回复" -> {
context.ifLogin("回答详情-评论-回复") {
if (listener != null) {
listener.onCommentCallback(commentEntity)
} else if (!TextUtils.isEmpty(commentEntity.id)) {
context.startActivity(MessageDetailActivity.getMessageDetailIntent(context, commentEntity, commentEntity.id))
} else {
Utils.toast(context, "缺少关键属性")
}
}
}
"复制" -> copyText(commentEntity.content, context)
"投诉" -> {

View File

@ -13,9 +13,7 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import com.gh.gamecenter.CommentDetailActivity;
import com.gh.gamecenter.MessageDetailActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.OnCommentCallBackListener;
import com.gh.gamecenter.adapter.viewholder.CommentViewHolder;
import com.gh.gamecenter.entity.CommentEntity;
import com.gh.gamecenter.entity.MeEntity;
@ -85,8 +83,6 @@ public class CommentUtils {
public static void showReportDialog(final CommentEntity commentEntity,
final Context context,
final boolean showConversation,
final OnCommentCallBackListener listener,
final String newsId,
final String patch) {
final Dialog dialog = new Dialog(context);
@ -96,11 +92,6 @@ public class CommentUtils {
container.setPadding(0, DisplayUtils.dip2px(context, 12), 0, DisplayUtils.dip2px(context, 12));
List<String> dialogType = new ArrayList<>();
if (commentEntity.getMe() == null || !commentEntity.getMe().isCommentOwner()) {
dialogType.add("回复");
}
dialogType.add("复制");
dialogType.add("投诉");
@ -126,17 +117,6 @@ public class CommentUtils {
public void onClick(View v) {
dialog.cancel();
switch (reportTv.getText().toString()) {
case "回复":
CheckLoginUtils.checkLogin(context, patch + "-回复", () -> {
if (listener != null) {
listener.onCommentCallback(commentEntity);
} else if (!TextUtils.isEmpty(newsId)) {
context.startActivity(MessageDetailActivity.getMessageDetailIntent(context, commentEntity, newsId));
} else {
Utils.toast(context, "缺少关键属性");
}
});
break;
case "复制":
copyText(commentEntity.getContent(), context);
break;
@ -218,13 +198,13 @@ public class CommentUtils {
public static void postVote(final Context context, final CommentEntity commentEntity,
final TextView commentLikeCountTv, final ImageView commentLikeIv,
final OnVoteListener listener) {
if (commentLikeCountTv.getCurrentTextColor() == ContextCompat.getColor(context, R.color.theme)) {
if (commentLikeCountTv.getCurrentTextColor() == ContextCompat.getColor(context, R.color.theme_font)) {
Utils.toast(context, "已经点过赞啦!");
return;
}
commentEntity.setVote(commentEntity.getVote() + 1);
commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.theme));
commentLikeIv.setImageResource(R.drawable.vote_icon_select);
commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.theme_font));
commentLikeIv.setImageResource(R.drawable.comment_vote_select);
commentLikeCountTv.setText(NumberUtils.transSimpleCount(commentEntity.getVote()));
commentLikeCountTv.setVisibility(View.VISIBLE);
@ -242,7 +222,7 @@ public class CommentUtils {
commentEntity.setVote(commentEntity.getVote() - 1);
commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.hint));
commentLikeIv.setImageResource(R.drawable.vote_icon_unselect);
commentLikeIv.setImageResource(R.drawable.comment_vote_unselect);
commentLikeCountTv.setText(NumberUtils.transSimpleCount(commentEntity.getVote()));
if (commentEntity.getVote() == 0) {
commentLikeCountTv.setVisibility(View.GONE);
@ -284,13 +264,13 @@ public class CommentUtils {
entrance = "社区文章详情-评论-点赞";
}
CheckLoginUtils.checkLogin(context, entrance, () -> {
if (commentLikeCountTv.getCurrentTextColor() == ContextCompat.getColor(context, R.color.theme)) {
if (commentLikeCountTv.getCurrentTextColor() == ContextCompat.getColor(context, R.color.theme_font)) {
Utils.toast(context, "已经点过赞啦!");
return;
}
commentEntity.setVote(commentEntity.getVote() + 1);
commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.theme));
commentLikeIv.setImageResource(R.drawable.vote_icon_select);
commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.theme_font));
commentLikeIv.setImageResource(R.drawable.comment_vote_select);
commentLikeCountTv.setText(NumberUtils.transSimpleCount(commentEntity.getVote()));
commentLikeCountTv.setVisibility(View.VISIBLE);
@ -307,7 +287,7 @@ public class CommentUtils {
public void postFailed(Throwable e) {
commentEntity.setVote(commentEntity.getVote() - 1);
commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.hint));
commentLikeIv.setImageResource(R.drawable.vote_icon_unselect);
commentLikeIv.setImageResource(R.drawable.comment_vote_unselect);
commentLikeCountTv.setText(NumberUtils.transSimpleCount(commentEntity.getVote()));
if (commentEntity.getVote() == 0) {
commentLikeCountTv.setVisibility(View.GONE);
@ -340,14 +320,22 @@ public class CommentUtils {
public static void setCommentUserView(Context mContext, CommentViewHolder holder, CommentEntity entity) {
MeEntity userDataEntity = entity.getMe();
holder.commentLikeCountTv.setTextColor(ContextCompat.getColor(mContext, R.color.hint));
holder.commentLikeIv.setImageResource(R.drawable.vote_icon_unselect);
holder.commentLikeIv.setImageResource(R.drawable.comment_vote_unselect);
if (userDataEntity == null || !userDataEntity.isCommentOwner()) {
holder.replyLine.setVisibility(View.VISIBLE);
holder.commentReply.setVisibility(View.VISIBLE);
} else {
holder.replyLine.setVisibility(View.GONE);
holder.commentReply.setVisibility(View.GONE);
}
if (entity.getVote() == 0) {
holder.commentLikeCountTv.setVisibility(View.GONE);
} else { // 检查是否已点赞
if (userDataEntity != null && (userDataEntity.isCommentVoted())) {
holder.commentLikeCountTv.setTextColor(ContextCompat.getColor(mContext, R.color.theme));
holder.commentLikeIv.setImageResource(R.drawable.vote_icon_select);
holder.commentLikeCountTv.setTextColor(ContextCompat.getColor(mContext, R.color.theme_font));
holder.commentLikeIv.setImageResource(R.drawable.comment_vote_select);
}
holder.commentLikeCountTv.setVisibility(View.VISIBLE);
holder.commentLikeCountTv.setText(NumberUtils.transSimpleCount(entity.getVote()));
@ -367,10 +355,11 @@ public class CommentUtils {
UserInfoEntity userInfo = UserManager.getInstance().getUserInfoEntity();
if (userDataEntity != null && userDataEntity.isCommentOwner() && userInfo != null) {
if (entity.getMe() != null && entity.getMe().isContentOwner()) {
holder.commentUserNameTv.setText(userInfo.getName() + "(作者)");
holder.commentAuthorTv.setVisibility(View.VISIBLE);
} else {
holder.commentUserNameTv.setText(userInfo.getName());
holder.commentAuthorTv.setVisibility(View.GONE);
}
holder.commentUserNameTv.setText(userInfo.getName());
if (userInfo.getAuth() != null) {
ImageUtils.display(holder.commentUserBadgeIv, userInfo.getAuth().getIcon());
} else {
@ -379,10 +368,11 @@ public class CommentUtils {
ImageUtils.displayIcon(holder.commentUserIconDv, userInfo.getIcon());
} else {
if (entity.getMe() != null && entity.getMe().isContentOwner()) {
holder.commentUserNameTv.setText(entity.getUser().getName() + "(作者)");
holder.commentAuthorTv.setVisibility(View.VISIBLE);
} else {
holder.commentUserNameTv.setText(entity.getUser().getName());
holder.commentAuthorTv.setVisibility(View.GONE);
}
holder.commentUserNameTv.setText(entity.getUser().getName());
if (entity.getUser().getAuth() != null) {
ImageUtils.display(holder.commentUserBadgeIv, entity.getUser().getAuth().getIcon());
} else {

View File

@ -5,6 +5,7 @@ import android.graphics.BitmapFactory
import android.graphics.Matrix
import com.gh.common.constant.Config
import com.gh.gamecenter.entity.SettingsEntity
import com.github.piasy.biv.metadata.ImageInfoExtractor
import com.halo.assistant.HaloApp
import java.io.File
import java.io.FileOutputStream
@ -26,11 +27,16 @@ object CompressImageUtils {
* 压缩图片并保存到目标文件
* 该压缩方法是同步执行 请勿在主线程执行
* 返回源文件的三种情况:小于特定值,图片类型为GIF,压缩失败
* ---------------------------------------------------------------------------------------------
* 关于压缩格式问题:
* 1.图片详情对动态Webp/静态Webp的判断存在问题导致部分静态Webp图片误判为动态Webp而直接委托Fresco处理出现无法缩放问题
* 2.为了解决上述问题如果压缩是检测到是动态Webp时直接压缩为JPEG这样就能解决图片详情无法缩放问题todo 这样会导致动态Webp无法播放
*/
@Throws(Exception::class)
fun compressImageAndSaveToFile(imageFile: File, compressGif: Boolean): File {
val imageType = ImageInfoExtractor.getImageType(imageFile)
// 小于某一个设定的值时,直接返回原图
if (imageFile.length() < getImageSetting().processLimitSize) {
if (imageType != ImageInfoExtractor.TYPE_ANIMATED_WEBP && imageFile.length() < getImageSetting().processLimitSize) {
return imageFile
}
@ -49,7 +55,7 @@ object CompressImageUtils {
} else if (options.outMimeType.contains("gif") && !compressGif) { // gif直接返回原图
return imageFile
} else {
Bitmap.CompressFormat.WEBP
Bitmap.CompressFormat.JPEG
}
fileOutputStream = FileOutputStream(cacheDir)
@ -165,6 +171,7 @@ object CompressImageUtils {
enum class CompressType {
// 0: 短边等比压缩至1280 H:长边 W:短边
LIMIT_SHORT,
// 1: 取长边等比压缩至1280 H:短边 W: 长边
LIMIT_LONG
}

View File

@ -9,8 +9,6 @@ import com.gh.gamecenter.manager.DataCollectionManager;
import com.gh.gamecenter.manager.PackagesManager;
import com.lightgame.download.DownloadEntity;
import org.json.JSONArray;
import java.util.HashMap;
import java.util.Map;
@ -169,24 +167,4 @@ public class DataCollectionUtils {
map.put("type", args[2]);
DataCollectionManager.onEvent(context, "concern", map);
}
//上传推荐位数据
public static void uploadPosition(Context context, String... args) {
if (args.length < 3) {
return;
}
Map<String, Object> map = new HashMap<>();
map.put("page", args[0]);
map.put("location", args[1]);
map.put("name", args[2]);
DataCollectionManager.onEvent(context, "position", map);
}
//上传应用列表
public static void uploadAppList(Context context, JSONArray applist) {
Map<String, Object> map = new HashMap<>();
map.put("applist", applist);
DataCollectionManager.onEvent(context, "applist", map);
}
}

View File

@ -2,8 +2,7 @@ package com.gh.common.util;
import android.content.Context;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
import com.gh.common.loghub.LoghubUtils;
import com.halo.assistant.HaloApp;
import com.lightgame.download.DownloadEntity;
import com.lightgame.utils.Util_System_Phone_State;
@ -14,12 +13,6 @@ import org.json.JSONObject;
import java.util.HashMap;
import java.util.Map;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
/**
* Created by LGT on 2016/12/8.
* 日志上传工具类
@ -68,12 +61,7 @@ public class DataLogUtils {
params.put("time", String.valueOf(Utils.getTime(context)));
params.put("content", new JSONObject(map).toString());
RequestBody body = RequestBody.create(MediaType.parse("application/json"),
new JSONObject(params).toString());
RetrofitManager.getInstance(context).getData().postLog(body)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<ResponseBody>());
LoghubUtils.log(new JSONObject(params), "common", true);
}
// 网络错误

View File

@ -13,6 +13,7 @@ import com.gh.gamecenter.entity.LinkEntity;
import com.gh.gamecenter.entity.PluginLocation;
import com.gh.gamecenter.manager.PackagesManager;
import com.lightgame.download.DownloadEntity;
import com.lightgame.utils.Utils;
/**
* Created by khy on 27/06/17.
@ -22,6 +23,7 @@ import com.lightgame.download.DownloadEntity;
public class DetailDownloadUtils {
public static void detailInitDownload(DetailViewHolder viewHolder, boolean isCheck) {
String downloadAddWord = viewHolder.gameEntity.getDownloadAddWord();
if (viewHolder.gameEntity != null
&& Config.isShowDownload(viewHolder.gameEntity.getId())
@ -34,10 +36,11 @@ public class DetailDownloadUtils {
if (viewHolder.gameEntity.isReservable()) {
if (!ReservationRepository.thisGameHasBeenReserved(viewHolder.gameEntity.getId())) {
if (TextUtils.isEmpty(viewHolder.downloadAddWord)) {
if (TextUtils.isEmpty(downloadAddWord)) {
viewHolder.mDownloadPb.setText(String.format("预约" + "《%s》", viewHolder.gameEntity.getName()));
} else {
viewHolder.mDownloadPb.setText(String.format("预约" + "《%s》%s", viewHolder.gameEntity.getName(), viewHolder.downloadAddWord));
viewHolder.mDownloadPb.setText(String.format("预约" + "《%s》%s", viewHolder.gameEntity.getName(), downloadAddWord));
}
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.RESERVABLE);
} else {
@ -49,10 +52,10 @@ public class DetailDownloadUtils {
if (viewHolder.gameEntity.getApk().isEmpty() || viewHolder.gameEntity.getDownloadOffStatus() != null) {
LinkEntity h5LinkEntity = viewHolder.gameEntity.getH5Link();
if (h5LinkEntity != null) {
if ("play".equals(h5LinkEntity.getType())) {
String defaultString = String.format("开始玩" + "《%s》", viewHolder.gameEntity.getName());
String defaultString = String.format("开始玩" + "《%s》", viewHolder.gameEntity.getName());
viewHolder.mDownloadPb.setText(TextUtils.isEmpty(h5LinkEntity.getText()) ? defaultString : h5LinkEntity.getText());
} else {
viewHolder.mDownloadPb.setText(TextUtils.isEmpty(h5LinkEntity.getText()) ? "查看" : h5LinkEntity.getText());
@ -60,35 +63,39 @@ public class DetailDownloadUtils {
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.H5_GAME);
} else {
if ("dialog".equals(viewHolder.gameEntity.getDownloadOffStatus())) {
viewHolder.mDownloadPb.setText(TextUtils.isEmpty(viewHolder.downloadOffText) ? "查看详情" : viewHolder.downloadOffText);
viewHolder.mDownloadPb.setText(TextUtils.isEmpty(viewHolder.gameEntity.getDownloadOffText()) ? "查看详情" : viewHolder.gameEntity.getDownloadOffText());
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.NONE_WITH_HINT);
} else {
viewHolder.mDownloadPb.setText(TextUtils.isEmpty(viewHolder.downloadOffText) ? "暂无下载" : viewHolder.downloadOffText);
viewHolder.mDownloadPb.setText(TextUtils.isEmpty(viewHolder.gameEntity.getDownloadOffText()) ? "暂无下载" : viewHolder.gameEntity.getDownloadOffText());
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.NONE);
}
}
} else {
} else if (viewHolder.gameEntity.getApk().size() == 1) {
String status = GameUtils.getDownloadBtnText(viewHolder.context, viewHolder.gameEntity, PluginLocation.only_game);
switch (status) {
case "插件化":
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.PLUGIN);
break;
case "打开":
case "启动":
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.LAUNCH_OR_OPEN);
break;
default:
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.NORMAL);
break;
if (viewHolder.context.getString(R.string.pluggable).equals(status)) {
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.PLUGIN);
} else if (viewHolder.context.getString(R.string.launch).equals(status)) {
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.LAUNCH_OR_OPEN);
} else {
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.NORMAL);
}
String downloadText;
if (viewHolder.isNewsDetail) {
viewHolder.mDownloadPb.setText(status);
} else if (TextUtils.isEmpty(viewHolder.downloadAddWord)) {
viewHolder.mDownloadPb.setText(String.format(status + "《%s》", viewHolder.gameEntity.getName()));
downloadText = status;
} else if (viewHolder.context.getString(R.string.pluggable).equals(status)) {
downloadText = "升级" + (TextUtils.isEmpty(downloadAddWord) ? "" : "" + downloadAddWord) + getDownloadSizeText(viewHolder);
} else if (viewHolder.context.getString(R.string.launch).equals(status)) {
downloadText = status + (TextUtils.isEmpty(downloadAddWord) ? "" : "-" + downloadAddWord);
} else if (viewHolder.context.getString(R.string.attempt).equals(status)) {
downloadText = status + getDownloadSizeText(viewHolder);
} else {
viewHolder.mDownloadPb.setText(String.format(status + "《%s》%s", viewHolder.gameEntity.getName(), viewHolder.downloadAddWord));
downloadText = status + (TextUtils.isEmpty(downloadAddWord) ? "" : downloadAddWord) + getDownloadSizeText(viewHolder);
}
viewHolder.mDownloadPb.setText(downloadText);
} else {
viewHolder.mDownloadPb.setText("选择下载你的版本" + (TextUtils.isEmpty(downloadAddWord) ? "" : "-" + downloadAddWord) + " >");
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.NORMAL);
}
if (isCheck && viewHolder.gameEntity.getApk().size() == 1) {
String url = viewHolder.gameEntity.getApk().get(0).getUrl();
@ -100,6 +107,10 @@ public class DetailDownloadUtils {
}
}
private static String getDownloadSizeText(DetailViewHolder viewHolder) {
return String.format("%s", viewHolder.gameEntity.getApk().get(0).getSize());
}
public static void detailInvalidate(DetailViewHolder viewHolder) {
viewHolder.mDownloadPb.setProgress((int) (viewHolder.downloadEntity.getPercent() * 10));
DownloadEntity downloadEntity = viewHolder.downloadEntity;
@ -128,7 +139,7 @@ public class DetailDownloadUtils {
case done:
viewHolder.mDownloadPb.setText(R.string.install);
if (downloadEntity.isPluggable()
&& PackagesManager.INSTANCE.isInstalled(downloadEntity.getPackageName())) {
&& PackagesManager.isInstalled(downloadEntity.getPackageName())) {
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.INSTALL_PLUGIN);
} else {
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.INSTALL_NORMAL);
@ -143,6 +154,4 @@ public class DetailDownloadUtils {
break;
}
}
}

View File

@ -8,6 +8,8 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.os.CountDownTimer;
import android.preference.PreferenceManager;
import android.text.Html;
import android.text.SpannableStringBuilder;
@ -28,23 +30,24 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import com.facebook.drawee.generic.GenericDraweeHierarchy;
import com.gh.common.AppExecutor;
import com.gh.common.constant.Config;
import com.gh.common.dialog.TrackableDialog;
import com.gh.common.view.DrawableView;
import com.gh.common.view.FixLinearLayoutManager;
import com.gh.common.view.LimitHeightLinearLayout;
import com.gh.common.view.MaxHeightNestedScrollView;
import com.gh.gamecenter.AboutActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.WebActivity;
import com.gh.gamecenter.adapter.viewholder.PrivacyPolicyItemViewHolder;
import com.gh.gamecenter.databinding.ImprintContentItemBinding;
import com.gh.gamecenter.databinding.PrivacyItemBinding;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.entity.PrivacyPolicyEntity;
import com.gh.gamecenter.entity.SettingsEntity;
import com.gh.gamecenter.entity.TrackableEntity;
import com.halo.assistant.HaloApp;
import com.halo.assistant.fragment.SettingsFragment;
@ -52,9 +55,17 @@ import com.lightgame.adapter.BaseRecyclerAdapter;
import com.lightgame.utils.AppManager;
import com.lightgame.utils.Utils;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.RecyclerView;
public class DialogUtils {
public static Dialog showWaitDialog(Context context, String msg) {
@ -200,7 +211,7 @@ public class DialogUtils {
String mb = size.toUpperCase().replaceAll("MB", "").trim();
Float i = Float.valueOf(mb);
if (NetworkUtils.isWifiOr4GConnected(context) && i <= 50) {
AppExecutor.getUiExecutor().executeWithDelay(() -> Utils.toast(context, "当前使用移动网络下载,请注意流量消耗"),500);
AppExecutor.getUiExecutor().executeWithDelay(() -> Utils.toast(context, "当前使用移动网络下载,请注意流量消耗"), 500);
return true;
}
@ -241,7 +252,7 @@ public class DialogUtils {
Context finalContext = context;
allowOnce.setOnClickListener(v -> {
AppExecutor.getUiExecutor().executeWithDelay(() -> {
Utils.toast(HaloApp.getInstance().getApplication(), "已使用移动网络下载,请注意流量消耗");
Utils.toast(finalContext, "已使用移动网络下载,请注意流量消耗");
}, 500);
listener.onConfirm();
dialog.dismiss();
@ -261,7 +272,7 @@ public class DialogUtils {
AppExecutor.getUiExecutor().executeWithDelay(() -> {
// 显示了弹窗以后,即便下面这个 toast 放在 listener.onConfirm 后调用也是显示 listener.onConfirm 里的 toast
// 喷了,延时包治疑难杂症
Utils.toast(HaloApp.getInstance().getApplication(), "已使用移动网络下载,请注意流量消耗");
Utils.toast(finalContext, "已使用移动网络下载,请注意流量消耗");
}, 500);
listener.onConfirm();
dialog.dismiss();
@ -646,9 +657,9 @@ public class DialogUtils {
Button negativeBtn = alertDialog.getButton(android.app.AlertDialog.BUTTON_NEGATIVE);
positiveBtn.setTextSize(13);
positiveBtn.setTextColor(ContextCompat.getColor(context, R.color.theme));
positiveBtn.setTextColor(ContextCompat.getColor(context, R.color.theme_font));
negativeBtn.setTextSize(13);
negativeBtn.setTextColor(ContextCompat.getColor(context, R.color.theme));
negativeBtn.setTextColor(ContextCompat.getColor(context, R.color.theme_font));
if (mesage != null) {
mesage.setGravity(Gravity.CENTER);
mesage.setTextSize(24);
@ -878,19 +889,24 @@ public class DialogUtils {
// 区分此 dialog 是点击 dialog 外部取消的还是点击返回取消的
AtomicBoolean isCanceledByClickOutsideOfDialog = new AtomicBoolean(true);
final Dialog dialog = new Dialog(activityContext, android.R.style.Theme_Black_NoTitleBar_Fullscreen);
final Dialog dialog = new Dialog(activityContext, R.style.GhAlertDialog);
View contentView = LayoutInflater.from(activityContext).inflate(R.layout.dialog_privacy_policy, null);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(contentView);
Window window = dialog.getWindow();
if (window != null) {
window.getDecorView().setPadding(0, 0, 0, 0);
window.setBackgroundDrawableResource(android.R.color.transparent);
WindowManager.LayoutParams params = window.getAttributes();
params.horizontalMargin = 0;
params.width = context.getResources().getDisplayMetrics().widthPixels;
params.height = context.getResources().getDisplayMetrics().heightPixels;
params.width = context.getResources().getDisplayMetrics().widthPixels - DisplayUtils.dip2px(40);
int height = context.getResources().getDisplayMetrics().heightPixels - DisplayUtils.dip2px(120);
int maxHeight = DisplayUtils.dip2px(546);
if (height > maxHeight) {
params.height = maxHeight;
} else {
params.height = height;
}
window.setAttributes(params);
}
@ -898,6 +914,7 @@ public class DialogUtils {
TextView bottomContent = contentView.findViewById(R.id.bottom_content);
TextView topContent = contentView.findViewById(R.id.top_content);
TextView allowButton = contentView.findViewById(R.id.allow_button);
TextView disallowButton = contentView.findViewById(R.id.disallow_button);
TextView linkContent = contentView.findViewById(R.id.link_content);
RecyclerView permissions = contentView.findViewById(R.id.permissions_content);
@ -938,7 +955,7 @@ public class DialogUtils {
@Override
public void updateDrawState(@NonNull TextPaint ds) {
super.updateDrawState(ds);
ds.setColor(ContextCompat.getColor(activityContext, R.color.text_1383EB));
ds.setColor(ContextCompat.getColor(activityContext, R.color.theme_font));
ds.setUnderlineText(false);
}
@ -954,7 +971,7 @@ public class DialogUtils {
@Override
public void updateDrawState(@NonNull TextPaint ds) {
super.updateDrawState(ds);
ds.setColor(ContextCompat.getColor(activityContext, R.color.text_1383EB));
ds.setColor(ContextCompat.getColor(activityContext, R.color.theme_font));
ds.setUnderlineText(false);
}
@ -968,17 +985,19 @@ public class DialogUtils {
title.setText(entity.getTitle());
linkContent.setText(skipText);
linkContent.setMovementMethod(new LinkMovementMethod());
allowButton.setText("我知道了");
topContent.setText(entity.getTopContent());
bottomContent.setText(entity.getBottomContent());
allowButton.setOnClickListener(view -> {
dialog.dismiss();
MtaHelper.onEvent("隐私政策弹窗", "隐私政策弹窗", "点击我知道了");
callback.onCallback();
MtaHelper.onEvent("隐私政策弹窗", "隐私政策弹窗", "点击同意");
});
dialog.setOnDismissListener(d -> {
callback.onCallback();
disallowButton.setOnClickListener(v -> {
dialog.dismiss();
showPrivacyPolicyDisallowDialog(activityContext, entity, callback);
MtaHelper.onEvent("隐私政策弹窗", "隐私政策弹窗", "不同意并退出App");
});
dialog.setOnCancelListener(cd -> {
@ -997,6 +1016,38 @@ public class DialogUtils {
MtaHelper.onEvent("隐私政策弹窗", "隐私政策弹窗", "出现弹窗");
try {
dialog.setCancelable(false);
dialog.show();
} catch (Exception ignored) {
}
}
public static void showPrivacyPolicyDisallowDialog(Context context,
@NonNull PrivacyPolicyEntity entity,
EmptyCallback callback) {
final Context activityContext = checkDialogContext(context);
final Dialog dialog = new Dialog(activityContext, R.style.DialogWindowTransparent);
View contentView = LayoutInflater.from(activityContext).inflate(R.layout.dialog_disallow_privacy_policy, null);
View backButton = contentView.findViewById(R.id.back_button);
View reviewButton = contentView.findViewById(R.id.review_button);
backButton.setOnClickListener(v -> {
MtaHelper.onEvent("隐私政策弹窗", "退出提示弹窗", "退出应用");
dialog.dismiss();
AppManager.getInstance().appExit(activityContext);
});
reviewButton.setOnClickListener(v -> {
MtaHelper.onEvent("隐私政策弹窗", "退出提示弹窗", "再次查看");
dialog.dismiss();
showPrivacyPolicyDialog(activityContext, entity, callback);
});
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCancelable(false);
dialog.setContentView(contentView);
try {
dialog.show();
} catch (Exception ignored) {
@ -1056,6 +1107,7 @@ public class DialogUtils {
R.style.GhAlertDialog,
trackableEntity.getEvent(),
trackableEntity.getKey(),
trackableEntity.getValue(),
trackableEntity.getCancelValue(),
trackableEntity.getKeyBackValue(),
trackableEntity.getLogShowEvent());
@ -1150,6 +1202,147 @@ public class DialogUtils {
return dialog;
}
public static void showDownloadMutexDialog(Context context) {
context = checkDialogContext(context);
final Dialog dialog = new Dialog(context, R.style.GhAlertDialog);
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_downlaod_mutex, null);
TextView positive = contentView.findViewById(R.id.dialog_positive);
CountDownTimer timer = new CountDownTimer(6000, 1000) {
public void onTick(long millisUntilFinished) {
positive.setText(("我知道了(" + millisUntilFinished / 1000 + ""));
}
public void onFinish() {
dialog.dismiss();
}
};
timer.start();
positive.setOnClickListener(v -> {
dialog.dismiss();
});
Window window = dialog.getWindow();
if (window != null) {
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(contentView);
dialog.show();
}
public static void showVersionNumberDialog(Context context, GameEntity gameEntity, @NonNull ConfirmListener listener) {
context = checkDialogContext(context);
if (!gameEntity.isShowVersionNumber()) {
listener.onConfirm();
} else {
final Dialog dialog = new Dialog(context, R.style.GhAlertDialog);
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_version_number, null);
TextView contentTv = contentView.findViewById(R.id.contentTv);
TextView cancelTv = contentView.findViewById(R.id.cancelTv);
TextView continueTv = contentView.findViewById(R.id.continueTv);
contentTv.setText(gameEntity.getVersionNumberString());
cancelTv.setOnClickListener(v -> dialog.dismiss());
continueTv.setOnClickListener(v -> {
listener.onConfirm();
dialog.dismiss();
});
Window window = dialog.getWindow();
if (window != null) {
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(contentView);
dialog.show();
}
}
public static void showImprintDialog(Context context, GameEntity gameEntity, String titleName) {
context = checkDialogContext(context);
Dialog dialog = new Dialog(context, R.style.full_dialog);
View inflate = LayoutInflater.from(context).inflate(R.layout.imprint_dialog, null);
dialog.setContentView(inflate);
dialog.show();
Window window = dialog.getWindow();
WindowManager.LayoutParams params;
if (window != null) {
params = window.getAttributes();
params.width = (int) (context.getResources().getDisplayMetrics().widthPixels * 0.9);
window.setAttributes(params);
window.setBackgroundDrawableResource(R.drawable.full_dialog_background);
}
inflate.findViewById(R.id.imprint_close).setOnClickListener(v -> dialog.dismiss());
LinearLayout content = inflate.findViewById(R.id.imprint_content);
((TextView) inflate.findViewById(R.id.imprint_title)).setText(titleName);
View head = LayoutInflater.from(context).inflate(R.layout.imprint_content_item, null);
content.addView(head, LinearLayout.LayoutParams.MATCH_PARENT, DisplayUtils.dip2px(30));
LimitHeightLinearLayout imprintContainer = inflate.findViewById(R.id.imprint_container);
imprintContainer.setLimitHeight((int) (context.getResources().getDisplayMetrics().heightPixels * 0.8));
ArrayList<ApkEntity> list = gameEntity.getApk();
SettingsEntity settings = Config.getSettings();
for (int i = 0; i < list.size(); i++) {
ApkEntity apk = gameEntity.getApk().get(i);
if (settings != null && settings.getGameDownloadBlackList().contains(apk.getPackageName())) {
continue;
}
View item = LayoutInflater.from(context).inflate(R.layout.imprint_content_item, null);
ImprintContentItemBinding bind = DataBindingUtil.bind(item);
bind.setApk(apk);
bind.setPlatformName(PlatformUtils.getInstance(context).getPlatformName(apk.getPlatform()));
content.addView(item, LinearLayout.LayoutParams.MATCH_PARENT, DisplayUtils.dip2px(40));
}
// close line
View view = new View(context);
view.setBackgroundColor(context.getResources().getColor(R.color.text_5d5d5d));
view.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, DisplayUtils.dip2px(1)));
content.addView(view);
}
public static void showKaifuRemindDialog(Context context, String content, String gameName) {
context = checkDialogContext(context);
final Dialog dialog = new TrackableDialog(context, R.style.GhAlertDialog, "开服说明弹窗", "弹窗", gameName, null, null, true);
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_kaifu_remind, null);
TextView contentTv = contentView.findViewById(R.id.contentTv);
MaxHeightNestedScrollView scrollView = contentView.findViewById(R.id.scrollView);
contentTv.setText(Html.fromHtml(content));
TextView ok = contentView.findViewById(R.id.dialog_ok);
scrollView.setScrollChangedListener((l, t, oldl, oldt) -> {
MtaHelper.onEvent("开服说明弹窗", "滑动内容", gameName);
});
ok.setOnClickListener(v -> {
MtaHelper.onEvent("开服说明弹窗", "弹窗", "点击我知道了");
MtaHelper.onEvent("开服说明弹窗", "点击我知道了", gameName);
dialog.dismiss();
});
Window window = dialog.getWindow();
if (window != null) {
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(contentView);
dialog.show();
}
/**
* @param context may be is application context
* @return activity context
@ -1163,6 +1356,7 @@ public class DialogUtils {
return context;
}
// currentActivity 是否存在 isDestroyed 的情况?
return AppManager.getInstance().currentActivity();
}

View File

@ -149,7 +149,14 @@ object DirectUtils {
"community_special_column" -> context.startActivity(AskColumnDetailActivity.getIntentByColumnId(context, linkEntity.link, linkEntity.community!!, entrance, path))
"web", "inurl", "web链接" -> directToWebView(context, url = linkEntity.link!!, entrance = BaseActivity.mergeEntranceAndPath(entrance, path))
"web", "inurl", "web链接" -> {
when {
linkEntity.link!!.contains("v.douyin") && PackageHelper.localPackageNameSet.contains("com.ss.android.ugc.aweme") -> {
directDouyin(context, "1402577827140941")
}
else -> directToWebView(context, url = linkEntity.link!!, entrance = BaseActivity.mergeEntranceAndPath(entrance, path))
}
}
"qq", "QQ" -> directToQqConversation(context, linkEntity.link)
@ -181,7 +188,7 @@ object DirectUtils {
"column_collection", "专题合集" -> directToColumnCollection(context, linkEntity.link!!, -1, entrance)
"server" -> {
"server", "game_server" -> {
context.startActivity(GameServersActivity.getIntent(context, entrance, path))
}
@ -197,6 +204,20 @@ object DirectUtils {
"game_video" -> directToGameVideo(context, linkEntity.link ?: "", entrance, path)
"libao" -> directToGiftDetail(context, linkEntity.link ?: "", entrance)
"feedback" -> directToFeedback(context, linkEntity.name, linkEntity.text, entrance)
"qa" -> directToQa(context, linkEntity.text ?: "", linkEntity.link ?: "")
"qa_collection" -> directToQaCollection(context, linkEntity.text ?: "", linkEntity.link
?: "")
"anliwall" -> directToAmway(context, fixedTopAmwayCommentId = null, entrance = entrance, path = path)
"" -> {
// do nothing
}
else -> {
if (unknownCallback != null) {
unknownCallback.invoke()
@ -207,11 +228,25 @@ object DirectUtils {
}
}
/**
* 跳转至QA
*/
fun directToQa(context: Context, text: String, id: String) {
context.startActivity(QaActivity.getIntent(context, navigationTitle = text, qaId = id))
}
/**
* 跳转至QA合集
*/
fun directToQaCollection(context: Context, text: String, id: String) {
context.startActivity(QaActivity.getIntent(context, navigationTitle = text, qaCollectionId = id))
}
/**
* 跳转至专题合集
*/
fun directToColumnCollection(context: Context, id: String, position: Int = -1, entrance: String) {
context.startActivity(ColumnCollectionDetailActivity.getIntent(context, id, position, entrance))
fun directToColumnCollection(context: Context, id: String, position: Int = -1, entrance: String, columnName: String = "") {
context.startActivity(ColumnCollectionDetailActivity.getIntent(context, id, position, entrance, columnName))
}
/**
@ -234,6 +269,21 @@ object DirectUtils {
context.startActivity(UserHomeActivity.getIntent(context, userId ?: "", entrance, path))
}
/**
* 跳转至个人主页
* @param position 定位到某个tab 0游戏评论 1问答 2视频
*/
@JvmStatic
fun directToHomeActivity(context: Context, userId: String?, position: Int, entrance: String? = null, path: String? = null) {
val bundle = Bundle()
bundle.putString(KEY_USER_ID, userId)
bundle.putString(KEY_TO, UserHomeActivity::class.java.name)
bundle.putString(KEY_ENTRANCE, BaseActivity.mergeEntranceAndPath(entrance, path))
bundle.putString(KEY_PATH, path)
bundle.putInt(KEY_POSITION, position)
jumpActivity(context, bundle)
}
/**
* 回到首页
*/
@ -246,11 +296,15 @@ object DirectUtils {
* 跳转到游戏详情
*/
@JvmStatic
fun directToGameDetail(context: Context, id: String, entrance: String? = null, autoDownload: Boolean? = null) {
fun directToGameDetail(context: Context, id: String, entrance: String? = null, autoDownload: Boolean? = null, scrollToLibao: Boolean = false) {
val bundle = Bundle()
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
bundle.putString(KEY_TO, GameDetailActivity::class.java.simpleName)
bundle.putString(KEY_GAMEID, id)
if (scrollToLibao) {
bundle.putInt(KEY_TARGET, GameDetailFragment.INDEX_TRENDES)
bundle.putBoolean(KEY_SCROLL_TO_LIBAO, scrollToLibao)
}
bundle.putBoolean(KEY_AUTO_DOWNLOAD, autoDownload ?: false)
jumpActivity(context, bundle)
}
@ -289,12 +343,21 @@ object DirectUtils {
// 反馈
@JvmStatic
fun directToFeedback(context: Context, content: String? = null, entrance: String? = null) {
directToFeedback(context, content, null, entrance)
}
@JvmStatic
fun directToFeedback(context: Context, content: String? = null, hintType: String? = null, entrance: String? = null) {
val bundle = Bundle()
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
bundle.putString(KEY_TO, SuggestionActivity::class.java.simpleName)
bundle.putString(KEY_CONTENT, content)
bundle.putString(KEY_SUGGEST_HINT_TYPE, KEY_PLUGIN)
bundle.putSerializable(EntranceUtils.KEY_SUGGESTTYPE, SuggestType.gameQuestion)
if (TextUtils.isEmpty(hintType)) {
bundle.putString(KEY_SUGGEST_HINT_TYPE, KEY_PLUGIN)
} else {
bundle.putString(KEY_SUGGEST_HINT_TYPE, hintType)
}
bundle.putSerializable(KEY_SUGGESTTYPE, SuggestType.gameQuestion)
jumpActivity(context, bundle)
}
@ -423,6 +486,7 @@ object DirectUtils {
return true
} catch (e: Exception) {
// 未安装手Q或安装的版本不支持
Utils.toast(context, "请安装QQ客户端")
return false
}
}
@ -502,7 +566,7 @@ object DirectUtils {
* @param fromLocation 可见 [VideoDetailContainerViewModel.Location]
*/
@JvmStatic
fun directToVideoDetail(context: Context, videoId: String, fromLocation: String, showComment: Boolean = false, gameId: String = "", entrance: String? = null, path: String? = "", referer: String = "") {
fun directToVideoDetail(context: Context, videoId: String, fromLocation: String, showComment: Boolean = false, gameId: String = "", entrance: String? = null, path: String? = "", referer: String = "", type: String = "", act: String = "") {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
val bundle = Bundle()
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
@ -513,12 +577,19 @@ object DirectUtils {
bundle.putString(KEY_LOCATION, fromLocation)
bundle.putBoolean(KEY_SHOW_COMMENT, showComment)
bundle.putString(KEY_REFERER, referer)
bundle.putString(KEY_TYPE, type)
bundle.putString(KEY_ACTIVITY_NAME, act)
jumpActivity(context, bundle)
} else {
DialogUtils.showLowSystemVersionDialog(context)
}
}
@JvmStatic
fun directToVideoDetail(context: Context, videoId: String, fromLocation: String, showComment: Boolean = false, gameId: String = "", entrance: String? = null, path: String? = "", referer: String = "") {
directToVideoDetail(context, videoId, fromLocation, showComment, gameId, entrance, path, referer, "", "")
}
/**
* 跳转至安利墙
* @param fixedTopAmwayCommentId 需要置顶的安利Id
@ -567,4 +638,13 @@ object DirectUtils {
// context.startActivity(GameVideoActivity.getIntent(context, gameId, entrance, path))
jumpActivity(context, bundle)
}
@JvmStatic
fun directDouyin(context: Context, userId: String) {
if (PackageHelper.localPackageNameSet.contains("com.ss.android.ugc.aweme")) {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("snssdk1128://user/profile/$userId"))
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(intent)
}
}
}

View File

@ -13,6 +13,7 @@ import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
@ -237,6 +238,18 @@ public class DisplayUtils {
return (resourceId > 0 && hasSoftKeys(context)) ? resources.getDimensionPixelSize(resourceId) : 0;
}
//判断导航栏是否显示
public static boolean isNavigationBarShow(Activity activity) {
ViewGroup vp = (ViewGroup) activity.getWindow().getDecorView();
for (int i = 0; i < vp.getChildCount(); i++) {
View child = vp.getChildAt(i);
if (child.getId() != -1 && "navigationBarBackground".equals(activity.getResources().getResourceEntryName(child.getId())) && child.getMeasuredHeight() != 0) {
return true;
}
}
return false;
}
public static boolean hasSoftKeys(Context context) {
if (!(context instanceof Activity)) return false;

View File

@ -8,13 +8,21 @@ import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.collection.ArrayMap;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import com.gh.common.constant.Config;
import com.gh.common.dialog.CertificationDialog;
import com.gh.common.dialog.DeviceRemindDialog;
import com.gh.common.dialog.ReserveDialogFragment;
import com.gh.common.exposure.ExposureEvent;
import com.gh.common.exposure.ExposureUtils;
import com.gh.common.repository.ReservationRepository;
import com.gh.common.view.DownloadDialog;
import com.gh.download.DownloadManager;
import com.gh.download.dialog.DownloadDialog;
import com.gh.gamecenter.DownloadManagerActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.WebActivity;
@ -32,12 +40,9 @@ import com.lightgame.utils.Utils;
import java.util.concurrent.LinkedBlockingQueue;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.collection.ArrayMap;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
/**
* todo 下载判断不能以按钮文案为判断条件,否则按钮文案修改时又要修改判断逻辑
*/
public class DownloadItemUtils {
// 更新下载进度条
@ -125,20 +130,20 @@ public class DownloadItemUtils {
holder.gameDownloadBtn.setTextColor(Color.WHITE);
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_pause_dn);
}
if (gameEntity.isLibaoExists()) {
holder.gameLibaoIcon.setVisibility(View.VISIBLE);
} else {
holder.gameLibaoIcon.setVisibility(View.GONE);
}
}
public static void updateItem(Context context, GameEntity gameEntity, GameViewHolder holder,
boolean isShowPlatform) {
updateItem(context, gameEntity, holder, isShowPlatform, PluginLocation.only_game);
updateItem(context, gameEntity, holder, isShowPlatform, PluginLocation.only_game, false);
}
public static void updateItem(Context context, GameEntity gameEntity, GameViewHolder holder,
boolean isShowPlatform, PluginLocation pluginLocation) {
boolean isShowPlatform, boolean hideDownloadBtnIfNoAvailableContent) {
updateItem(context, gameEntity, holder, isShowPlatform, PluginLocation.only_game, hideDownloadBtnIfNoAvailableContent);
}
public static void updateItem(Context context, GameEntity gameEntity, GameViewHolder holder,
boolean isShowPlatform, PluginLocation pluginLocation, boolean hideDownloadBtnIfNoAvailableContent) {
// 控制是否显示下载按钮
if (!Config.isShowDownload(gameEntity.getId()) || context.getString(R.string.app_name).equals(gameEntity.getName())) {
@ -147,12 +152,6 @@ public class DownloadItemUtils {
holder.gameDownloadBtn.setVisibility(View.VISIBLE);
}
if (gameEntity.isLibaoExists()) {
holder.gameLibaoIcon.setVisibility(View.VISIBLE);
} else {
holder.gameLibaoIcon.setVisibility(View.GONE);
}
// 显示预约
if (gameEntity.isReservable()) {
holder.gameDes.setVisibility(View.VISIBLE);
@ -171,14 +170,14 @@ public class DownloadItemUtils {
}
if (gameEntity.getApk().isEmpty()
|| gameEntity.getDownloadOffStatus() != null) {
|| gameEntity.getDownloadOffStatus() != null) {
LinkEntity h5LinkEntity = gameEntity.getH5Link();
String offStatus = gameEntity.getDownloadOffStatus();
holder.gameDes.setVisibility(View.VISIBLE);
holder.gameProgressbar.setVisibility(View.GONE);
holder.gameInfo.setVisibility(View.GONE);
if (h5LinkEntity != null) {
if ("play".equals(h5LinkEntity.getType())) {
holder.gameDownloadBtn.setText("开始玩");
@ -195,6 +194,9 @@ public class DownloadItemUtils {
holder.gameDownloadBtn.setText("暂无");
holder.gameDownloadBtn.setTextColor(ContextCompat.getColor(context, R.color.button_gray));
holder.gameDownloadBtn.setBackgroundResource(R.drawable.news_detail_comment);
if (hideDownloadBtnIfNoAvailableContent) {
holder.gameDownloadBtn.setVisibility(View.GONE);
}
}
holder.gameDownloadBtn.setClickable(false);
}
@ -334,10 +336,10 @@ public class DownloadItemUtils {
holder.gameDownloadBtn.setText(R.string.install);
holder.gameDownloadBtn.setTextColor(Color.WHITE);
if (downloadEntity.isPluggable()
&& PackagesManager.INSTANCE.isInstalled(downloadEntity.getPackageName())) {
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_plugin_style);
&& PackagesManager.isInstalled(downloadEntity.getPackageName())) {
holder.gameDownloadBtn.setBackgroundResource(R.drawable.download_button_pluggable_style);
} else {
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_download_style);
holder.gameDownloadBtn.setBackgroundResource(R.drawable.download_button_normal_style);
}
}
}
@ -420,7 +422,7 @@ public class DownloadItemUtils {
}
return;
}
if (gameEntity.getApk().size() == 0 && gameEntity.getH5Link() != null) {
downloadBtn.setOnClickListener(v -> {
MtaHelper.onEvent("H5页面", "入口", "列表页_" + gameEntity.getName());
@ -449,7 +451,15 @@ public class DownloadItemUtils {
clickCallback.onCallback();
}
PermissionHelper.checkStoragePermissionBeforeAction(context, () -> {
DownloadDialog.getInstance(context).showPopupWindow(v, gameEntity, entrance, location, traceEvent);
CertificationDialog.showCertificationDialog(context, gameEntity, () -> {
DialogUtils.showVersionNumberDialog(context, gameEntity, () -> {
DownloadDialog.showDownloadDialog(
v.getContext(),
gameEntity,
entrance,
location);
});
});
});
});
}
@ -480,19 +490,38 @@ public class DownloadItemUtils {
if (str.equals(context.getString(R.string.download))) {
// 先弹下载弹窗(如果需要的话)
DownloadDialogHelper.findAvailableDialogAndShow(context, gameEntity, apk, () -> {
DialogUtils.checkDownload(context, apk.getSize(),
isSubscribe -> download(context, gameEntity, downloadBtn, entrance, location, isSubscribe, traceEvent));
CertificationDialog.showCertificationDialog(context, gameEntity, () -> {
DialogUtils.checkDownload(context, apk.getSize(),
isSubscribe -> download(context, gameEntity, downloadBtn, entrance, location, isSubscribe, traceEvent));
});
});
DataLogUtils.uploadGameLog(context, gameEntity.getId(), gameEntity.getName(), entrance);
} else if (str.equals(context.getString(R.string.pluggable))) {
} else if (str.equals(context.getString(R.string.attempt))) {
DownloadDialogHelper.findAvailableDialogAndShow(context, gameEntity, apk, () -> {
CertificationDialog.showCertificationDialog(context, gameEntity, () -> {
DialogUtils.showVersionNumberDialog(context, gameEntity, () -> {
DialogUtils.checkDownload(context, apk.getSize(),
isSubscribe -> download(context, gameEntity, downloadBtn, entrance, location, isSubscribe, traceEvent));
});
});
});
DataLogUtils.uploadGameLog(context, gameEntity.getId(), gameEntity.getName(), entrance);
} else if (str.contains("")) {
if (entrance.contains("我的游戏")) {
MtaHelper.onEvent("我的游戏_启动", "插件化", gameEntity.getName());
}
DownloadDialogHelper.findAvailableDialogAndShow(context, gameEntity, apk, () -> {
DialogUtils.checkDownload(context, apk.getSize(),
isSubscribe -> plugin(context, gameEntity, downloadBtn, entrance, location, isSubscribe, traceEvent));
});
if (gameEntity.getPluggableCollection() != null) {
DownloadDialog.showDownloadDialog(context, gameEntity, entrance, location);
} else {
DownloadDialogHelper.findAvailableDialogAndShow(context, gameEntity, apk, () -> {
CertificationDialog.showCertificationDialog(context, gameEntity, () -> {
DialogUtils.checkDownload(context, apk.getSize(),
isSubscribe -> plugin(context, gameEntity, downloadBtn, entrance, location, isSubscribe, traceEvent));
});
});
}
} else if (str.equals(context.getString(R.string.install))) {
install(context, gameEntity, position, adapter);
} else if (str.equals(context.getString(R.string.launch))) {
@ -536,6 +565,7 @@ public class DownloadItemUtils {
downloadBtn.setText(R.string.downloading);
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_downloading_style);
downloadBtn.setTextColor(ContextCompat.getColorStateList(context, R.color.text_downloading_style));
DeviceRemindDialog.Companion.showDeviceRemindDialog(context, gameEntity);
} else {
Utils.toast(context, msg);
}
@ -575,6 +605,8 @@ public class DownloadItemUtils {
gameEntity.getEntryMap().remove(apkEntity.getPlatform());
}
adapter.notifyItemChanged(position);
} else if (PackageUtils.isCanPluggable(apkEntity)) {
DialogUtils.showPluginDialog(context, () -> context.startActivity(PackageUtils.getUninstallIntent(context, path)));
} else {
PackageUtils.launchSetup(context, downloadEntity);
}
@ -584,12 +616,12 @@ public class DownloadItemUtils {
//更新
private static void update(Context context, GameEntity gameEntity, String entrance, String location, boolean isSubscribe, @Nullable ExposureEvent traceEvent) {
ApkEntity apkEntity = gameEntity.getApk().get(0);
ExposureUtils.DownloadType downloadType = ExposureUtils.getUpdateType(apkEntity);
DataUtils.onGameUpdateEvent(context, gameEntity.getName(), apkEntity.getPlatform(), "下载开始");
ExposureEvent downloadExposureEvent = ExposureUtils.logADownloadExposureEvent(gameEntity, apkEntity
.getPlatform(), traceEvent, downloadType);
.getPlatform(), traceEvent, downloadType);
DownloadManager.createDownload(context, gameEntity, "更新", entrance, location, isSubscribe, downloadExposureEvent);
}

View File

@ -0,0 +1,239 @@
package com.gh.common.util
import android.content.pm.PackageManager
import android.os.Build
import android.preference.PreferenceManager
import com.gh.base.BaseActivity
import com.gh.common.constant.Constants
import com.gh.common.exposure.ExposureUtils
import com.gh.download.DownloadManager
import com.gh.gamecenter.BuildConfig
import com.gh.gamecenter.R
import com.gh.gamecenter.SuggestionActivity
import com.gh.gamecenter.entity.GameEntity
import com.gh.gamecenter.entity.SimpleGameEntity
import com.gh.gamecenter.eventbus.EBDownloadStatus
import com.gh.gamecenter.eventbus.EBShowDialog
import com.gh.gamecenter.retrofit.Response
import com.gh.gamecenter.retrofit.RetrofitManager
import com.gh.gamecenter.suggest.SuggestType
import com.halo.assistant.HaloApp
import com.halo.assistant.fragment.SettingsFragment
import com.lightgame.download.DataWatcher
import com.lightgame.download.DownloadEntity
import com.lightgame.download.DownloadStatus
import com.lightgame.download.FileUtils
import com.lightgame.utils.AppManager
import com.lightgame.utils.Util_System_Phone_State
import com.lightgame.utils.Utils
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import okhttp3.MediaType
import okhttp3.RequestBody
import org.greenrobot.eventbus.EventBus
import org.json.JSONObject
import java.util.*
object DownloadObserver {
private val mApplication = HaloApp.getInstance().application
@JvmStatic
fun initObserver() {
val dataWatcher = object : DataWatcher() {
override fun onDataChanged(downloadEntity: DownloadEntity) {
val gameId = downloadEntity.getRealGameId(Constants.GAME_ID_DIVIDER)
if (downloadEntity.status != DownloadStatus.downloading) {
LogUtils.uploadDownloadEvent(downloadEntity)
}
if (DownloadStatus.hijack == downloadEntity.status) {
// 链接被劫持
processHijack(downloadEntity)
val nameAndPlatform = (downloadEntity.name + ":"
+ PlatformUtils.getInstance(mApplication).getPlatformName(downloadEntity.platform))
MtaHelper.onEvent("下载劫持",
"游戏名字", nameAndPlatform,
"网络状态", DeviceUtils.getNetwork(mApplication))
return
} else if (DownloadStatus.notfound == downloadEntity.status) {
// 404 Not Found
// 删除任务
downloadEntity.status = DownloadStatus.cancel
DownloadManager.getInstance(mApplication).cancel(downloadEntity.url)
Utils.toast(mApplication, "该链接已失效!请联系管理员。")
MtaHelper.onEventWithBasicDeviceInfo("下载失败弹窗",
"游戏", downloadEntity.name,
"平台", downloadEntity.platform)
DialogUtils.showAlertDialog(AppManager.getInstance().currentActivity(), "下载失败", "下载链接已失效,建议提交反馈", "立即反馈", "取消", {
SuggestionActivity.startSuggestionActivity(AppManager.getInstance().currentActivity(),
SuggestType.gameQuestion, "notfound",
StringUtils.buildString(downloadEntity.name, ",问题反馈:下载链接失效"),
SimpleGameEntity(gameId, downloadEntity.name, ""))
}, null)
return
} else if (DownloadStatus.neterror == downloadEntity.status || DownloadStatus.timeout == downloadEntity.status) {
Utils.toast(mApplication, "网络不稳定,下载任务已暂停")
DataLogUtils.uploadNeterrorLog(mApplication, downloadEntity)
MtaHelper.onEventWithBasicDeviceInfo("下载自动暂停",
"游戏", downloadEntity.name,
"平台", downloadEntity.platform)
}
if (DownloadStatus.done == downloadEntity.status) {
if (downloadEntity.name.contains(mApplication.getString(R.string.app_name))) {
MtaHelper.onEvent("软件更新", "下载完成")
tryWithDefaultCatch {
// 会有 ActivityNotFoundException 异常catch 掉不管了
mApplication.startActivity(PackageUtils.getInstallIntent(mApplication, downloadEntity.path, true))
}
DataLogUtils.uploadUpgradeLog(mApplication, "install") //上传更新安装数据
} else {
statDoneEvent(downloadEntity)
val platform = PlatformUtils.getInstance(mApplication)
.getPlatformName(downloadEntity.platform)
if (platform != null) {
when {
downloadEntity.isPluggable -> // 弹出插件化提示框
EventBus.getDefault().post(EBShowDialog(BaseActivity.PLUGGABLE, downloadEntity.path))
downloadEntity.isPlugin -> Utils.toast(mApplication, downloadEntity.name + " - " + platform + " - 下载完成")
else -> Utils.toast(mApplication, downloadEntity.name + " - 下载完成")
}
} else {
Utils.toast(mApplication, downloadEntity.name + " - 下载完成")
}
if (!downloadEntity.isPluggable) {
// 是否是自动安装
if (PreferenceManager.getDefaultSharedPreferences(mApplication).getBoolean(SettingsFragment.AUTO_INSTALL_SP_KEY, true)) {
if (FileUtils.isEmptyFile(downloadEntity.path)) {
Utils.toast(mApplication, R.string.install_failure_hint)
DownloadManager.getInstance(mApplication).cancel(downloadEntity.url)
} else {
if (PackageUtils.isCanLaunchSetup(mApplication, downloadEntity.path)) {
downloadEntity.meta[Constants.MARK_ALREADY_TRIGGERED_INSTALLATION] = "YES"
tryWithDefaultCatch {
mApplication.startActivity(PackageUtils.getInstallIntent(mApplication, downloadEntity.path))
}
} else {
// 弹出卸载提示框
EventBus.getDefault().post(EBShowDialog(BaseActivity.PLUGGABLE, downloadEntity.path))
}
}
}
}
// 统计下载完成
uploadData(gameId, downloadEntity.platform)
}
// 下载过程分析统计
val pm = mApplication.packageManager
val packageInfo = pm.getPackageArchiveInfo(downloadEntity.path, PackageManager.GET_ACTIVITIES)
if (packageInfo == null) {
MtaHelper.onEventWithBasicDeviceInfo("解析包错误分析",
"游戏名字", downloadEntity.name + ":" + PlatformUtils.getInstance(mApplication).getPlatformName(downloadEntity.platform))
MtaHelper.onEventWithBasicDeviceInfo("解析包错误_新",
"游戏", downloadEntity.name + ":" + PlatformUtils.getInstance(mApplication).getPlatformName(downloadEntity.platform))
}
}
if (downloadEntity.status == DownloadStatus.done) {
EventBus.getDefault().post(EBDownloadStatus("done", "", "", "", downloadEntity.packageName, ""))
}
DownloadNotificationHelper.addOrUpdateDownloadNotification(downloadEntity)
}
}
// 添加观察者
DownloadManager.getInstance(mApplication).addObserver(dataWatcher)
}
// 统计下载完成事件
private fun statDoneEvent(downloadEntity: DownloadEntity) {
var type: ExposureUtils.DownloadType
val platform = PlatformUtils.getInstance(HaloApp.getInstance().application).getPlatformName(downloadEntity.platform)
val kv1 = HashMap<String, Any>()
kv1["版本"] = platform
kv1["状态"] = "下载完成"
kv1["用户机型"] = Build.MODEL
kv1["设备IMEI"] = Util_System_Phone_State.getDeviceId(HaloApp.getInstance().application)
kv1["网络状态"] = DeviceUtils.getNetwork(HaloApp.getInstance().application)
kv1["光环助手版本"] = BuildConfig.VERSION_NAME
if (downloadEntity.isUpdate) {
type = ExposureUtils.DownloadType.UPDATE
if (downloadEntity.isPlugin) {
type = ExposureUtils.DownloadType.PLUGIN_UPDATE
}
DataUtils.onEvent(mApplication, "游戏更新", downloadEntity.name, kv1)
} else {
type = ExposureUtils.DownloadType.DOWNLOAD
}
val kv2 = HashMap<String, Any>()
kv2["版本"] = downloadEntity.platform
kv2["状态"] = "下载完成"
kv2["位置"] = downloadEntity.entrance ?: "null"
kv2["游戏分平台"] = downloadEntity.name + "-" + platform
kv2["光环助手版本"] = BuildConfig.VERSION_NAME
DataUtils.onEvent(mApplication, "游戏下载位置", downloadEntity.name, kv2)
if (downloadEntity.isPluggable) {
val kv3 = HashMap<String, Any>()
kv3["下载"] = "下载完成"
kv3["版本"] = downloadEntity.platform
kv3["位置"] = downloadEntity.entrance ?: "null"
type = ExposureUtils.DownloadType.PLUGIN_DOWNLOAD
DataUtils.onEvent(mApplication, "插件化", downloadEntity.name, kv3)
MtaHelper.onEvent(
"插件化_新",
"位置", downloadEntity.entrance,
"游戏", downloadEntity.name + "-" + downloadEntity.platform,
"操作", "下载完成",
"网络状态", DeviceUtils.getNetwork(HaloApp.getInstance().application))
}
ExposureUtils.logADownloadCompleteExposureEvent(
GameEntity(downloadEntity.getRealGameId(Constants.GAME_ID_DIVIDER), downloadEntity.name),
downloadEntity.platform,
downloadEntity.exposureTrace,
type)
DataCollectionUtils.uploadDownload(mApplication, downloadEntity, "完成")
}
private fun processHijack(downloadEntity: DownloadEntity) {
// 删除任务
downloadEntity.status = DownloadStatus.cancel
DownloadManager.getInstance(mApplication).cancel(downloadEntity.url)
// 弹出提示框
EventBus.getDefault().post(EBShowDialog(BaseActivity.DOWNLOAD_HIJACK))
// 记录链接被劫持
DataCollectionUtils.uploadHijack(mApplication, downloadEntity)
// 上传劫持log
DataLogUtils.uploadHijack(mApplication, downloadEntity)
}
// 统计下载
private fun uploadData(id: String, platform: String?) {
val params = HashMap<String, String>()
params["game"] = id
params["platform"] = platform ?: ""
val body = RequestBody.create(MediaType.parse("application/json"),
JSONObject(params).toString())
RetrofitManager.getInstance(mApplication).api.postDownload(body)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(Response())
}
}

View File

@ -4,11 +4,15 @@ import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.gh.common.avoidcallback.AvoidOnResultManager;
import com.gh.common.avoidcallback.Callback;
import com.gh.gamecenter.MainActivity;
import com.gh.gamecenter.NormalActivity;
import com.gh.gamecenter.SplashScreenActivity;
import com.gh.gamecenter.normal.NormalFragment;
import androidx.appcompat.app.AppCompatActivity;
/**
* @author CsHeng
* @Date 2017/4/25
@ -18,6 +22,7 @@ import com.gh.gamecenter.normal.NormalFragment;
public class EntranceUtils {
public static final String KEY_TO = "to";
public static final String KEY_NEXT_TO = "next_to";
public static final String KEY_NEWSID = "newsId";
public static final String KEY_GAMEID = "gameId";
public static final String KEY_ID = "id";
@ -30,6 +35,7 @@ public class EntranceUtils {
public static final String HOST_VIDEO_STREAMING_HOME = "video_streaming_home";//视频流-首页
public static final String HOST_VIDEO_STREAMING_DESC = "video_streaming_desc";//视频流-游戏介绍进入
public static final String HOST_VIDEO_COLLECTION = "video_collection";//视频合集
public static final String HOST_USERHOME = "userhome";//个人主页
public static final String HOST_VIDEO = "video";
public static final String HOST_COMMUNITY_ARTICLE = "community_article";
public static final String HOST_COMMUNITY_COLUMN = "community_column";
@ -80,6 +86,7 @@ public class EntranceUtils {
public static final String KEY_OLDERUSER = "isOldUser";
public static final String KEY_SEARCHKEY = "searchKey";
public static final String KEY_HINT = "hint";
public static final String KEY_GAME = "game";
public static final String KEY_GAME_ICON_URL = "gameIconUrl";
public static final String KEY_SHARECONTENT = "shareContent";
public static final String KEY_SUGGESTTYPE = "suggestType";
@ -107,6 +114,7 @@ public class EntranceUtils {
public static final String KEY_CATEGORY_INIT_TITLE = "category_init_title";
public static final String KEY_BLOCK_DATA = "blockData";
public static final String KEY_ASK_TAG = "askTag";
public static final String KEY_SCROLL_TO_LIBAO = "libao";
public static final String KEY_ASK_COLUMN_TAG = "askColumnTag";
public static final String KEY_COMMUNITY_ID = "community_id";
public static final String KEY_COMMUNITY_NAME = "community_name";
@ -131,6 +139,7 @@ public class EntranceUtils {
public static final String KEY_DIRECT_COMMENT = "directComment";
public static final String KEY_SORT = "sort";
public static final String KEY_AMWAY = "amway";
public static final String KEY_SKIP_SUCCESS_PAGE = "skipSuccessPage";
public static final String KEY_COLLECTION_ID = "collectionId";
public static final String KEY_NAVIGATION_TITLE = "navigationTitle";
public static final String KEY_IMAGE_CROP_RATIO = "imageCropRatio";
@ -140,8 +149,14 @@ public class EntranceUtils {
public static final String KEY_IS_HOME_VIDEO = "isHomeVideo";
public static final String KEY_IS_HOME = "isHome";
public static final String KEY_WEB_SHARE = "webShare";
public static final String KEY_ACTIVITY_NAME = "activityName";//活动名称
public static final String KEY_REQUIRE_REDIRECT = "require_redirect"; // 标记需要再跳转
public static final String KEY_COLUMNNAME = "columnName";
public static final String KEY_QA_ID = "qaId";
public static final String KEY_QA_COLLECTION_ID = "qaCollectionId";
public static void jumpActivity(Context context, Bundle bundle) {
bundle.putBoolean(KEY_REQUIRE_REDIRECT, true);
//TODO 把其他类似的跳转启动逻辑也处理掉
if (RunningUtils.isRunning(context)
@ -164,4 +179,34 @@ public class EntranceUtils {
}
}
public static void jumpActivity(Context context, Bundle nextToBundle, Bundle bundle, Callback callback) {
bundle.putBoolean(KEY_REQUIRE_REDIRECT, true);
//TODO 把其他类似的跳转启动逻辑也处理掉
if (RunningUtils.isRunning(context)
&& MainActivity.class.getName().equals(RunningUtils.getBaseActivity(context))) {
// 应用正在运行,前台或后台
String to = bundle.getString(KEY_TO);
Class<?> clazz = ClassUtils.forName(to);
if (clazz == null) clazz = MainActivity.class;
if (NormalFragment.class.isAssignableFrom(clazz)) { // 兼容NormalFragment
NormalActivity.startFragmentNewTask(context, (Class<? extends NormalFragment>) clazz, bundle);
} else {
Intent intent1 = new Intent(context, clazz);
//TODO:添加FLAG_ACTIVITY_NEW_TASK会导致一跳转页面callback就被调用
//intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent1.putExtras(bundle);
AvoidOnResultManager.Companion.getInstance((AppCompatActivity) context)
.startForResult(intent1, callback);
}
} else {
// 应用未在运行
if (nextToBundle != null) {
bundle.putBundle(KEY_NEXT_TO, nextToBundle);
}
context.startActivity(SplashScreenActivity.getSplashScreenIntent(context, bundle));
}
}
}

View File

@ -23,6 +23,10 @@ object ErrorHelper {
customizedHandler: (code: Int) -> Boolean) {
val errorEntity = errorString?.toObject<ErrorEntity>()
if (customizedHandler(errorEntity?.code ?: 0)) {
return
}
if (errorEntity == null) {
Utils.toast(context, R.string.post_failure_hint)
return
@ -33,11 +37,7 @@ object ErrorHelper {
return
}
if (customizedHandler(errorEntity.code ?: 0)) {
return
} else {
handleError(context, showHighPriorityHint, errorEntity)
}
handleError(context, showHighPriorityHint, errorEntity)
}
/**
@ -115,10 +115,11 @@ object ErrorHelper {
403074 -> Utils.toast(context, "该微信号(${errorEntity.data?.nickname})已绑定")
403078 -> Utils.toast(context, "已点赞")
403072 -> Utils.toast(context, R.string.comment_failed_userblocked)
403082 -> Utils.toast(context, "作者已关闭评论")
403020 -> if (showHighPriorityHint) {
DialogUtils.showAlertDialog(context,
"限制提醒",
"提醒",
"提问过于频繁,请先休息一下哦",
"知道了", null, null, null)
} else {

View File

@ -13,6 +13,7 @@ import android.view.View
import android.widget.PopupWindow
import android.widget.TextView
import androidx.annotation.ColorRes
import androidx.core.content.ContextCompat
import androidx.core.text.HtmlCompat
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
@ -222,6 +223,29 @@ inline fun tryWithDefaultCatch(action: (() -> Unit)) {
}
}
/**
* 只在正式版本进行 try catch 操作
*
* 对于个别偶发的异常尽量不要做暴力的 try catch 处理
*/
inline fun tryCatchInRelease(action: (() -> Unit)) {
try {
action.invoke()
} catch (e: Throwable) {
if (BuildConfig.DEBUG) throw e
else e.printStackTrace()
}
}
/**
* 在 debug 状态下抛出异常
*/
fun throwExceptionInDebug(message: String = "", predicate: Boolean = true) {
if (predicate && BuildConfig.DEBUG) {
throw RuntimeException(message)
}
}
/**
* String related
*/
@ -390,7 +414,7 @@ fun FragmentActivity.checkStoragePermissionBeforeAction(action: (() -> Unit)) {
fun TextView.setTextWithHighlightedTextWrappedInsideWrapper(text: CharSequence,
wrapper: String = Constants.DEFAULT_TEXT_WRAPPER,
@ColorRes
highlightColorId: Int = R.color.theme,
highlightColorId: Int = R.color.theme_font,
copyClickedText: Boolean = false,
highlightedTextClickListener: (() -> Unit)? = null) {
TextHelper.highlightTextThatIsWrappedInsideWrapper(this, text, wrapper, highlightColorId, object : SimpleCallback<String> {
@ -419,7 +443,7 @@ fun TextView.setTextChangedListener(action: (s: CharSequence, start: Int, before
}
fun Int.toColor(): Int {
return HaloApp.getInstance().application.resources.getColor(this)
return ContextCompat.getColor(HaloApp.getInstance().application, this)
}
fun Int.toResString(): String {

View File

@ -82,11 +82,70 @@ object GameRepositoryHelper {
return null
}
fun replaceInstalledApp(gameList: MutableList<GameEntity>,
alreadyDisplayedGameIdSet: HashSet<String>,
relatedCollectionId: String,
shouldLogReplaceEvent: Boolean) {
val positionOfTheGameToReplaceList = arrayListOf<Int>()
// 标记需要替换的已安装游戏
for ((index, game) in gameList.withIndex()) {
// 是大图形式的游戏时不标记替换
if ((index == 0 && !gameList[0].image.isNullOrEmpty())) {
continue
}
var isThisPositionAdded = false
// 检查是否已安装该游戏里同包名的 APK
for (apk in game.getApk()) {
if (PackageHelper.validLocalPackageNameSet.contains(apk.packageName)) {
// 将该位置的游戏标记为需要替换
positionOfTheGameToReplaceList.add(index)
isThisPositionAdded = true
break
}
}
// 若此游戏所包含的 apk 没有已安装,那么再检查是否已安装有预设相关包名
if (!isThisPositionAdded) {
var relatedPackageList = arrayListOf<String>()
for (entity in PackageHelper.relatedPackageList) {
if (entity.gameId == game.id) {
relatedPackageList = ArrayList(entity.packages)
break
}
}
for (packageName in relatedPackageList) {
if (PackageHelper.validLocalPackageNameSet.contains(packageName)) {
positionOfTheGameToReplaceList.add(index)
break
}
}
}
}
if (positionOfTheGameToReplaceList.isNotEmpty()) {
if (shouldLogReplaceEvent) {
MtaHelper.onEvent("首页_加载", "启动光环", "替换游戏")
}
for (position in positionOfTheGameToReplaceList) {
val replacingGame = getOneUniqueGame(relatedCollectionId, alreadyDisplayedGameIdSet)
replacingGame?.let {
gameList[position] = replacingGame
}
}
}
}
private fun isThisGameUnique(game: GameEntity, gameIdList: HashSet<String>): Boolean {
// 若该补充游戏已经存在关联关系,判定为非唯一
for (relatedId in game.relatedGameIds!!) {
gameIdList.contains(relatedId)
return false
if (gameIdList.contains(relatedId)) {
return false
}
}
for (apk in game.getApk()) {
// 检查本地是否已安装该游戏,已过滤那部分框架服务的包名

View File

@ -5,12 +5,12 @@ import android.graphics.Color;
import android.text.TextUtils;
import android.widget.TextView;
import androidx.core.content.ContextCompat;
import com.gh.common.constant.Config;
import com.gh.download.DownloadManager;
import com.gh.gamecenter.R;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.ApkLink;
import com.gh.gamecenter.entity.GameCollectionEntity;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.entity.GameUpdateEntity;
import com.gh.gamecenter.entity.PluginLocation;
@ -19,8 +19,11 @@ import com.gh.gamecenter.manager.PackagesManager;
import com.lightgame.download.DownloadEntity;
import com.lightgame.download.DownloadStatus;
import java.util.ArrayList;
import java.util.List;
import androidx.annotation.Nullable;
public class GameUtils {
@ -53,13 +56,13 @@ public class GameUtils {
String status = getDownloadBtnText(context, gameEntity, pluginLocation);
downloadBtn.setTextColor(Color.WHITE);
downloadBtn.setText(status);
if ("插件化".equals(status)) {
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_plugin_style);
} else if ("打开".equals(status) || "启动".equals(status)) {
downloadBtn.setBackgroundResource(R.drawable.detail_download_open_style);
downloadBtn.setTextColor(ContextCompat.getColor(context, R.color.theme));
if (context.getString(R.string.pluggable).equals(status)) {
downloadBtn.setBackgroundResource(R.drawable.download_button_pluggable_style);
String pluginDesc = gameEntity.getPluginDesc();
if (pluginDesc.length() > 3) pluginDesc = pluginDesc.substring(0, 3);
downloadBtn.setText((pluginDesc + ""));
} else {
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_download_style);
downloadBtn.setBackgroundResource(R.drawable.download_button_normal_style);
}
}
@ -67,6 +70,10 @@ public class GameUtils {
* 获取下载按钮文案
*/
public static String getDownloadBtnText(Context context, GameEntity gameEntity, PluginLocation pluginLocation) {
if (gameEntity.getApk().size() > 1) {
return context.getString(R.string.expand);
}
int doneCount = 0; // 下载完成数量
int pluginCount = 0; // 可插件化数量
int updateCount = 0; // 可更新数量
@ -118,18 +125,59 @@ public class GameUtils {
} else if (updateCount != 0) {
return context.getString(R.string.update);
} else if (installCount != 0) {
if (gameEntity.getApk().size() == 1) {
return context.getString(R.string.launch);
} else {
return context.getString(R.string.open);
}
return context.getString(R.string.launch);
} else if (gameEntity.getVersionNumber().contains("无版号") && Config.isGameDomeSwitchOpen()) {
return context.getString(R.string.attempt);
} else {
return context.getString(R.string.download);
}
}
/**
* 获取GameUpdateEntity
* 获取简单的下载按钮文案,只需要知道是否已下载,是否已安装
*/
public static String getSimpleDownloadBtnText(Context context, GameEntity gameEntity) {
int doneCount = 0; // 下载完成数量
int installCount = 0; // 已安装数量
DownloadEntity downloadEntity;
Object gh_id;
apkFor:
for (ApkEntity apkEntity : gameEntity.getApk()) {
// filter by packageName
SettingsEntity settings = Config.getSettings();
if (settings != null && gameEntity.getApk().size() > 1) {
for (String pkgName : settings.getGameDownloadBlackList()) {
if (pkgName.equals(apkEntity.getPackageName())) {
continue apkFor;
}
}
}
downloadEntity = DownloadManager.getInstance(context).getDownloadEntityByUrl(apkEntity.getUrl());
if (downloadEntity != null) {
if (downloadEntity.getStatus().equals(DownloadStatus.done)) {
doneCount++;
}
}
if (PackagesManager.INSTANCE.isInstalled(apkEntity.getPackageName())) {
gh_id = PackageUtils.getMetaData(context, apkEntity.getPackageName(), "gh_id");
if (gh_id == null || gh_id.equals(gameEntity.getId())) {
installCount++;
}
}
}
if (doneCount != 0) {
return context.getString(R.string.install);
} else if (installCount != 0) {
return context.getString(R.string.launch);
} else {
return context.getString(R.string.download);
}
}
/**
* 获取GameUpdateEntity(插件化)
*/
public static GameUpdateEntity getGameUpdateEntity(GameEntity gameEntity, ApkEntity apkEntity) {
GameUpdateEntity gameUpdateEntity = new GameUpdateEntity();
@ -150,7 +198,50 @@ public class GameUtils {
gameUpdateEntity.setPlugin(apkEntity.getPlugin());
gameUpdateEntity.setDownload(gameEntity.getDownload());
gameUpdateEntity.setIndexPlugin(gameEntity.getIndexPlugin());
gameUpdateEntity.setPluginDesc(gameEntity.getPluginDesc());
GameCollectionEntity pluggableCollection = getPluggableCollectionFromGameEntity(gameEntity, apkEntity.getPackageName());
if (pluggableCollection != null) {
gameUpdateEntity.setPluggableCollection(pluggableCollection);
}
return gameUpdateEntity;
}
@Nullable
public static GameCollectionEntity getPluggableCollectionFromGameEntity(GameEntity gameEntity, String targetPkg) {
// 添加插件化包所在的合集
for (GameCollectionEntity collectionEntity : gameEntity.getCollection()) {
if (collectionEntity.getPackages().contains(targetPkg)) {
ArrayList<ApkEntity> saveApkEntity = new ArrayList<>();
for (String pkg : collectionEntity.getPackages()) {
for (ApkEntity apk : gameEntity.getApk()) {
if (pkg.equals(apk.getPackageName())) {
saveApkEntity.add(apk);
break;
}
}
}
ArrayList<ApkLink> apkLinks = gameEntity.getApkLink();
if (apkLinks != null) {
for (ApkLink apkLink : apkLinks) {
if (apkLink.getCollection().equals(collectionEntity.getId())) {
ApkEntity element = new ApkEntity();
element.setApkLink(apkLink);
if (saveApkEntity.size() > apkLink.getSort()) {
saveApkEntity.add(apkLink.getSort(), element);
} else {
saveApkEntity.add(element);
}
}
}
}
collectionEntity.setSaveApkEntity(saveApkEntity);
return collectionEntity;
}
}
return null;
}
}

View File

@ -10,6 +10,9 @@ import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
import androidx.core.content.ContextCompat;
import com.gh.common.view.DrawableView;
import com.gh.gamecenter.R;
import com.gh.gamecenter.entity.TagStyleEntity;
@ -21,8 +24,6 @@ import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
import androidx.core.content.ContextCompat;
/**
* @author 温冠超
* @email 294299195@qq.com
@ -32,21 +33,16 @@ import androidx.core.content.ContextCompat;
*/
public class GameViewUtils {
public static void setLabelList(Context context, LinearLayout labelLayout, List<String> tag, String tagType, List<TagStyleEntity> tagStyle) {
public static void setLabelList(Context context, LinearLayout labelLayout, List<TagStyleEntity> tagStyle) {
labelLayout.removeAllViews();
if (tag == null || tag.isEmpty()) {
labelLayout.addView(getGameTagView(context, "官方版", 0, tagType, null));
if (tagStyle == null || tagStyle.isEmpty()) {
TagStyleEntity tagEntity = new TagStyleEntity();
tagEntity.setName("官方版");
labelLayout.addView(getNewGameTagView(context, tagEntity, 0));
} else {
for (int i = 0, size = tag.size(); i < size; i++) {
View view;
if (i == size - 1) {
view = getGameTagView(context, tag.get(i), 0, tagType, tagStyle.size() > i ? tagStyle.get(i) : null);
} else {
view = getGameTagView(context, tag.get(i), DisplayUtils.dip2px(context, 8), tagType, tagStyle.size() > i ? tagStyle.get(i) : null);
}
if (view != null) {
labelLayout.addView(view);
}
for (int i = 0, size = tagStyle.size(); i < size; i++) {
View view = getNewGameTagView(context, tagStyle.get(i), i == size - 1 ? 0 : DisplayUtils.dip2px(context, 8));
labelLayout.addView(view);
if (labelLayout.getChildCount() == 3) {
break;
}
@ -76,6 +72,32 @@ public class GameViewUtils {
}
}
// 新的游戏标签样式 version>=4.0.0
private static TextView getNewGameTagView(Context context, TagStyleEntity tagEntity, int rightMargin) {
// 参数不全,用旧样式实现
if (TextUtils.isEmpty(tagEntity.getBackground())) {
return getGameTagView(context, tagEntity.getName(), rightMargin, "type", tagEntity);
}
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lparams.rightMargin = rightMargin;
TextView tag = new TextView(context);
tag.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10);
tag.setSingleLine(true);
tag.setText(tagEntity.getName());
tag.setLayoutParams(lparams);
tag.setPadding(
DisplayUtils.dip2px(context, 4),
0,
DisplayUtils.dip2px(context, 4),
DisplayUtils.dip2px(context, 1));
tag.setTextColor(Color.parseColor("#" + tagEntity.getColor()));
tag.setBackground(DrawableView.getServerDrawable(Color.parseColor("#" + tagEntity.getBackground())));
return tag;
}
private static TextView getGameTagView(Context context, String tagStr, int rightMargin, String tagType, TagStyleEntity tagEntity) {
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

View File

@ -22,6 +22,12 @@ object GsonUtils {
return gson.fromJson(json.toString(), type)
}
@JvmStatic
fun <T> fromJsonList(json: String): List<T> {
val type = object : TypeToken<List<T>>() {}.type
return gson.fromJson(json, type)
}
@JvmStatic
fun toJson(any: Any?): String {
return gson.toJson(any)

View File

@ -0,0 +1,37 @@
package com.gh.common.util;
import com.contrarywind.adapter.WheelAdapter;
/**
* 注意选择后的数据其实是dates的position需要在回调时对返回的date数据进行转换
*
* 例子请见:
* {@link com.gh.gamecenter.servers.add.AddKaiFuActivity}
*/
public class HaloWheelViewAdapter implements WheelAdapter {
private int[] dates;
public HaloWheelViewAdapter(int[] dates) {
this.dates = dates;
}
@Override
public Object getItem(int index) {
return dates[index];
}
@Override
public int getItemsCount() {
return dates.length;
}
@Override
public int indexOf(Object o) {
try {
return (int) o;
} catch (Exception e) {
return -1;
}
}
}

View File

@ -32,4 +32,39 @@ public class HtmlUtils {
return htmlStr.trim(); //返回文本字符串
}
/**
* 去除html代码及文本
*/
public static String stripHtmlCode(String htmlStr) {
if (TextUtils.isEmpty(htmlStr)) return "";
String regEx_script = "<script[^>]*?>[\\s\\S]*?<\\/script>"; //定义script的正则表达式
String regEx_style = "<style[^>]*?>[\\s\\S]*?<\\/style>"; //定义style的正则表达式
String regEx_html = "<[^>]+>[\\s\\S]*?<\\/[^>]+>"; //定义HTML标签的正则表达式
String regEx_html_single = "<[^>]+>"; //定义HTML单标签的正则表达式
String regEx_blank = "\\s+"; //定义空白字符的正则表达式
Pattern p_script = Pattern.compile(regEx_script, Pattern.CASE_INSENSITIVE);
Matcher m_script = p_script.matcher(htmlStr);
htmlStr = m_script.replaceAll(""); //过滤script标签
Pattern p_style = Pattern.compile(regEx_style, Pattern.CASE_INSENSITIVE);
Matcher m_style = p_style.matcher(htmlStr);
htmlStr = m_style.replaceAll(""); //过滤style标签
Pattern p_html = Pattern.compile(regEx_html, Pattern.CASE_INSENSITIVE);
Matcher m_html = p_html.matcher(htmlStr);
htmlStr = m_html.replaceAll(""); //过滤html标签
Pattern p_html_single = Pattern.compile(regEx_html_single, Pattern.CASE_INSENSITIVE);
Matcher m_html_single = p_html_single.matcher(htmlStr);
htmlStr = m_html_single.replaceAll(""); //过滤html单标签
Pattern p_blank = Pattern.compile(regEx_blank, Pattern.CASE_INSENSITIVE);
Matcher m_blank = p_blank.matcher(htmlStr);
htmlStr = m_blank.replaceAll(" ");//过滤空白字符
return htmlStr.trim(); //返回文本字符串
}
}

View File

@ -16,12 +16,14 @@ import com.facebook.drawee.controller.ControllerListener
import com.facebook.drawee.drawable.ScalingUtils
import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder
import com.facebook.drawee.view.SimpleDraweeView
import com.facebook.imagepipeline.core.ImagePipeline
import com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber
import com.facebook.imagepipeline.image.ImageInfo
import com.facebook.imagepipeline.request.ImageRequest
import com.facebook.imagepipeline.request.ImageRequestBuilder
import com.gh.common.constant.Config
import com.gh.gamecenter.R
import com.halo.assistant.HaloApp
import java.io.ByteArrayOutputStream
@ -236,7 +238,7 @@ object ImageUtils {
fun display(view: SimpleDraweeView?, url: String?) {
url?.let {
// 图片是以 gif 结尾的就
if (it.endsWith(".gif")) {
if (it.endsWith(".gif") && view?.getTag(R.id.tag_show_gif) != false) {
if (view?.tag == url) return@let
val controller = Fresco.newDraweeControllerBuilder()
@ -323,6 +325,14 @@ object ImageUtils {
draweeView.setImageURI("res:///" + res)
}
//预加载图片
@JvmStatic
fun prefetchToDiskCache(url: String){
val imagePipeline = Fresco.getImagePipeline()
val imageRequest = ImageRequest.fromUri(url)
imagePipeline.prefetchToDiskCache(imageRequest, HaloApp.getInstance().application)
}
public interface OnImageloadListener {
fun onLoadFinal(imageInfo: ImageInfo?)
}

View File

@ -68,7 +68,7 @@ public class InstallUtils {
if (!TextUtils.isEmpty(installVersion) && downloadEntity != null &&
installVersion.equals(downloadEntity.getVersionName())) {
if (!downloadEntity.isPluggable() || PackageUtils.isSignature(context, packageName)) {
EventBus.getDefault().post(new EBPackage("安装", packageName));
EventBus.getDefault().post(new EBPackage("安装", packageName, installVersion));
}
}
}
@ -85,7 +85,7 @@ public class InstallUtils {
keys.add(packageName);
} else if (!list.contains(packageName)) {
keys.add(packageName);
EventBus.getDefault().post(new EBPackage("卸载", packageName));
EventBus.getDefault().post(new EBPackage("卸载", packageName, ""));
}
}
for (String key : keys) {

View File

@ -166,12 +166,12 @@ public class LibaoUtils {
case "coming":
libaoBtn.setText(R.string.libao_coming);
libaoBtn.setBackgroundResource(R.drawable.button_normal_border);
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme));
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme_font));
break;
case "used_up":
libaoBtn.setText(R.string.libao_used_up);
libaoBtn.setBackgroundResource(R.drawable.button_normal_border);
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme));
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme_font));
break;
case "finish":
libaoBtn.setText(R.string.libao_finish);
@ -181,12 +181,12 @@ public class LibaoUtils {
case "linged":
libaoBtn.setText(R.string.libao_linged);
libaoBtn.setBackgroundResource(R.drawable.button_normal_border);
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme));
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme_font));
break;
case "taoed":
libaoBtn.setText(R.string.libao_taoed);
libaoBtn.setBackgroundResource(R.drawable.button_normal_border);
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme));
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme_font));
break;
case "copy":
libaoBtn.setText(R.string.libao_copy);
@ -195,7 +195,7 @@ public class LibaoUtils {
case "repeatLing":
libaoBtn.setText(R.string.libao_repeat_ling);
libaoBtn.setBackgroundResource(R.drawable.button_normal_border);
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme));
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme_font));
break;
case "repeatLinged":
libaoBtn.setText(R.string.libao_repeat_ling);
@ -204,7 +204,7 @@ public class LibaoUtils {
case "repeatTao":
libaoBtn.setText(R.string.libao_repeat_tao);
libaoBtn.setBackgroundResource(R.drawable.button_normal_border);
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme));
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme_font));
break;
case "repeatTaoed":
libaoBtn.setText(R.string.libao_repeat_tao);
@ -227,6 +227,82 @@ public class LibaoUtils {
}
}
public static void setLiBaoBtnStatusRound(final TextView libaoBtn, String status, Context context) {
libaoBtn.setTextColor(Color.WHITE);
if (TextUtils.isEmpty(status)) return;
switch (status) {
case "ling":
libaoBtn.setText(R.string.libao_ling);
libaoBtn.setBackgroundResource(R.drawable.button_normal_round_style);
break;
case "tao":
libaoBtn.setText(R.string.libao_tao);
libaoBtn.setBackgroundResource(R.drawable.button_normal_round_style);
break;
case "coming":
libaoBtn.setText(R.string.libao_coming);
libaoBtn.setBackgroundResource(R.drawable.button_normal_round_border);
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme_font));
break;
case "used_up":
libaoBtn.setText(R.string.libao_used_up);
libaoBtn.setBackgroundResource(R.drawable.button_normal_round_border);
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme_font));
break;
case "finish":
libaoBtn.setText(R.string.libao_finish);
libaoBtn.setBackgroundResource(R.drawable.button_border_round_gray);
libaoBtn.setTextColor(context.getResources().getColor(R.color.button_gray));
break;
case "linged":
libaoBtn.setText(R.string.libao_linged);
libaoBtn.setBackgroundResource(R.drawable.button_normal_round_border);
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme_font));
break;
case "taoed":
libaoBtn.setText(R.string.libao_taoed);
libaoBtn.setBackgroundResource(R.drawable.button_normal_round_border);
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme_font));
break;
case "copy":
libaoBtn.setText(R.string.libao_copy);
libaoBtn.setBackgroundResource(R.drawable.button_normal_round_style);
break;
case "repeatLing":
libaoBtn.setText(R.string.libao_repeat_ling);
libaoBtn.setBackgroundResource(R.drawable.button_normal_round_border);
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme_font));
break;
case "repeatLinged":
libaoBtn.setText(R.string.libao_repeat_ling);
libaoBtn.setBackgroundResource(R.drawable.button_normal_round_style);
break;
case "repeatTao":
libaoBtn.setText(R.string.libao_repeat_tao);
libaoBtn.setBackgroundResource(R.drawable.button_normal_round_border);
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme_font));
break;
case "repeatTaoed":
libaoBtn.setText(R.string.libao_repeat_tao);
libaoBtn.setBackgroundResource(R.drawable.button_normal_round_style);
break;
case "unshelve":
libaoBtn.setBackgroundResource(R.drawable.button_border_round_gray);
libaoBtn.setText(R.string.libao_unshelve);
libaoBtn.setTextColor(context.getResources().getColor(R.color.button_gray));
break;
case "check":
libaoBtn.setText(R.string.libao_check);
libaoBtn.setBackgroundResource(R.drawable.button_normal_round_style);
break;
default:
libaoBtn.setBackgroundResource(R.drawable.button_border_round_gray);
libaoBtn.setText("异常");
libaoBtn.setTextColor(context.getResources().getColor(R.color.button_gray));
break;
}
}
public static void initLibaoBtn(final Context context, final TextView libaoBtn, final LibaoEntity libaoEntity,
final boolean isInstallRequired, final LibaoDetailAdapter adapter, final String entrance) {
String status = libaoEntity.getStatus();

View File

@ -46,7 +46,7 @@ public class NewsUtils {
* 统计阅读量
*/
public static void statNewsViews(Context context, String news_id) {
RetrofitManager.getInstance(context).getData().postNewsViews(news_id)
RetrofitManager.getInstance(context).getApi().postArticleVisit(news_id)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<ResponseBody>());

View File

@ -1,5 +1,6 @@
package com.gh.common.util;
import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
@ -19,6 +20,7 @@ import com.gh.gamecenter.BuildConfig;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.entity.GameUpdateEntity;
import com.gh.gamecenter.manager.PackagesManager;
import com.halo.assistant.HaloApp;
import com.lightgame.download.DownloadEntity;
import com.lightgame.utils.Utils;
@ -29,12 +31,17 @@ import org.json.JSONObject;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.InputStream;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import androidx.annotation.Nullable;
import androidx.core.content.FileProvider;
public class PackageUtils {
@ -44,47 +51,39 @@ public class PackageUtils {
/*
* 判断是否可以更新只判断gh_version的大小
*/
public static List<GameUpdateEntity> isCanUpdate(Context context, GameEntity gameEntity) {
public static List<GameUpdateEntity> getUpdateData(Context context, GameEntity gameEntity) {
List<GameUpdateEntity> updateList = new ArrayList<>();
boolean isAPluginGame = false;
// 插件更新
for (ApkEntity apkEntity : gameEntity.getApk()) {
// 判断是否gh_version是否存在
String gh_version = (String) PackageUtils.getMetaData(context, apkEntity.getPackageName(), "gh_version");
Object gh_id = PackageUtils.getMetaData(context, apkEntity.getPackageName(), "gh_id");
if (gh_version != null && apkEntity.getGhVersion() != null && gh_id != null) {
// 确定这是一个插件游戏
if (!isAPluginGame) isAPluginGame = true;
gh_version = gh_version.substring(2);
if (Long.parseLong(gh_version) < Long.parseLong(apkEntity.getGhVersion()) && apkEntity.getForce()
&& gh_id.equals(gameEntity.getId())) {
GameUpdateEntity updateEntity = new GameUpdateEntity();
updateEntity.setId(gameEntity.getId());
updateEntity.setName(gameEntity.getName());
updateEntity.setIcon(gameEntity.getIcon());
updateEntity.setPackageName(apkEntity.getPackageName());
updateEntity.setSize(apkEntity.getSize());
updateEntity.setVersion(apkEntity.getVersion());
updateEntity.setGhVersion(apkEntity.getGhVersion());
updateEntity.setUrl(apkEntity.getUrl());
updateEntity.setPlatform(apkEntity.getPlatform());
updateEntity.setEtag(apkEntity.getEtag());
updateEntity.setBrief(gameEntity.getBrief());
updateEntity.setTag(gameEntity.getTag());
updateEntity.setTagStyle(gameEntity.getTagStyle());
updateEntity.setDownload(gameEntity.getDownload());
updateEntity.setIndexPlugin(gameEntity.getIndexPlugin());
updateList.add(updateEntity);
}
if (isCanUpdate(apkEntity, gameEntity.getId())) {
GameUpdateEntity updateEntity = new GameUpdateEntity();
updateEntity.setId(gameEntity.getId());
updateEntity.setName(gameEntity.getName());
updateEntity.setIcon(gameEntity.getIcon());
updateEntity.setPackageName(apkEntity.getPackageName());
updateEntity.setSize(apkEntity.getSize());
updateEntity.setVersion(apkEntity.getVersion());
updateEntity.setGhVersion(apkEntity.getGhVersion());
updateEntity.setUrl(apkEntity.getUrl());
updateEntity.setPlatform(apkEntity.getPlatform());
updateEntity.setEtag(apkEntity.getEtag());
updateEntity.setBrief(gameEntity.getBrief());
updateEntity.setTag(gameEntity.getTag());
updateEntity.setTagStyle(gameEntity.getTagStyle());
updateEntity.setDownload(gameEntity.getDownload());
updateEntity.setIndexPlugin(gameEntity.getIndexPlugin());
updateEntity.setPluginDesc(gameEntity.getPluginDesc());
updateList.add(updateEntity);
}
}
// 不是插件游戏
if (!isAPluginGame) {
for (ApkEntity apkEntity : gameEntity.getApkNormal()) {
// 插件游戏更新
for (ApkEntity apkEntity : gameEntity.getApkNormal()) {
// ghVersion 不存在即是非插件游戏
if (TextUtils.isEmpty(apkEntity.getGhVersion())) {
String versionFromRequest = apkEntity.getVersion();
String versionFromInstalledApp = getVersionByPackage(apkEntity.getPackageName());
@ -112,6 +111,7 @@ public class PackageUtils {
updateEntity.setTag(gameEntity.getTag());
updateEntity.setTagStyle(gameEntity.getTagStyle());
updateEntity.setIndexPlugin(gameEntity.getIndexPlugin());
updateEntity.setPluginDesc(gameEntity.getPluginDesc());
updateList.add(updateEntity);
}
}
@ -137,6 +137,19 @@ public class PackageUtils {
return null;
}
/**
* 获取已安装游戏的光环ID(游戏ID)
*
* @param packageName
* @return
*/
@Nullable
public static Object getGhId(String packageName) {
return getMetaData(HaloApp.getInstance().getApplication(), packageName, "gh_id");
}
/*
* 判断是否是插件包
*/
@ -169,6 +182,9 @@ public class PackageUtils {
public static boolean compareSignatureBetweenInstalledAppWithApk(Context context, String packageName, String apkFilePath) {
try {
Signature sig = context.getPackageManager().getPackageInfo(packageName, PackageManager.GET_SIGNATURES).signatures[0];
// Fuck HUAWEI, 华为系统调用 getPackageArchiveInfo 获取魔羯 apk 的签名时会耗时超过5秒造成 ANR没有找到解决方法
// 如果可以的话尽量避免调用 getPackageArchiveInfo 方法
Signature releaseSig = context.getPackageManager().getPackageArchiveInfo(apkFilePath, PackageManager.GET_SIGNATURES).signatures[0];
return sig.hashCode() == releaseSig.hashCode();
} catch (Exception e) {
@ -177,6 +193,28 @@ public class PackageUtils {
return false;
}
// 从 APK 中获取公钥(只支持包含 V1 签名的 APK
private static String getApkSignatureFromFile(String apkFilePath) {
try {
ZipFile apkFile = new ZipFile(apkFilePath);
Enumeration<?> entries = apkFile.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = ((ZipEntry) entries.nextElement());
String entryName = entry.getName();
if (entryName.contains("META-INF") && entryName.endsWith(".RSA")) {
InputStream is = apkFile.getInputStream(entry);
CertificateFactory cf = CertificateFactory.getInstance("X.509");
X509Certificate cert = (X509Certificate) cf.generateCertificates(is).toArray()[0];
return cert.getPublicKey().toString();
}
}
return "";
} catch (Exception e) {
return "";
}
}
/*
* 解析签名
*/
@ -192,7 +230,7 @@ public class PackageUtils {
}
return ret;
}
/*
* 启动安装应用程序
*/
@ -216,8 +254,10 @@ public class PackageUtils {
}
}
/*
* 根据apk路径获取apk包名、签名 根据包名 判断 是否已安装游戏 根据签名 判断 是否一致
/**
* 根据 path 获取 apk 信息确定处理方式
*
* @return true 为直接唤起系统 PackageInstaller, false 为需要插件化
*/
public static boolean isCanLaunchSetup(Context context, String path) {
String packageName = getPackageNameByPath(context, path);
@ -225,7 +265,7 @@ public class PackageUtils {
if (TextUtils.isEmpty(packageName)) {
return true;
}
boolean isContain = com.gh.gamecenter.manager.PackagesManager.INSTANCE.isInstalled(packageName);
boolean isContain = PackagesManager.isInstalled(packageName);
if (!isContain) {
return true;
}
@ -235,13 +275,19 @@ public class PackageUtils {
return true;
}
// 由于新增了非插件的也能更新的功能,倘若两个签名一样的话就不走下面的光环签名判断了
if (compareSignatureBetweenInstalledAppWithApk(context, packageName, path)) {
// 判断当前已安装应用是否为光环签名
if (publicKey.equals(getApkSignatureByPackageName(context, packageName))) {
return true;
}
String signature = getApkSignatureByPackageName(context, packageName);
return publicKey.equals(signature);
// 从 APK 文件里读取公钥,与已安装的公钥比较判断是否一样
String signatureFromApk = getApkSignatureFromFile(path);
if (!TextUtils.isEmpty(signatureFromApk)) {
return signatureFromApk.equals(getApkSignatureByPackageName(context, packageName));
}
// 若已安装的应用的签名与即将要安装的签名一致也返回 true
return compareSignatureBetweenInstalledAppWithApk(context, packageName, path);
}
/*
@ -264,8 +310,9 @@ public class PackageUtils {
installIntent.setDataAndType(uri, "application/vnd.android.package-archive");
installIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
} else {
if (isInAppUpdate) {
// 应用内更新不加 FLAG_ACTIVITY_NEW_TASK 在模拟器上会出现安装完成后安装界面也一并消失的类似闪退的表现
// 应用内更新不加 FLAG_ACTIVITY_NEW_TASK 在模拟器上会出现安装完成后安装界面也一并消失的类似闪退的表现
// Application 上下文就更不用说了
if (isInAppUpdate || context instanceof Application) {
installIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
installIntent.setDataAndType(uri, "application/vnd.android.package-archive");
@ -451,4 +498,55 @@ public class PackageUtils {
return null;
}
/**
* todo 统一判断
* <p>
* 判断游戏包是否可以更新
*
* @param apkEntity apkEntity 必须是已安装的游戏
* @param gameId 游戏id
* @return true可以更新 false不可以更新
*/
public static boolean isCanUpdate(ApkEntity apkEntity, String gameId) {
// gh_version: gh + timestamp
String gh_version = (String) PackageUtils.getMetaData(
HaloApp.getInstance().getApplication(),
apkEntity.getPackageName(),
"gh_version");
// gh_version: game id
Object gh_id = PackageUtils.getMetaData(
HaloApp.getInstance().getApplication(),
apkEntity.getPackageName(),
"gh_id");
if (gh_version != null && apkEntity.getGhVersion() != null && gh_id != null) {
gh_version = gh_version.substring(2);
return Long.parseLong(gh_version) < Long.parseLong(apkEntity.getGhVersion())
&& apkEntity.getForce()
&& gh_id.equals(gameId);
}
return false;
}
/**
* todo 统一判断
* <p>
* 判断游戏包是否可以插件化
*
* @param apkEntity apkEntity 必须是已安装的游戏
* @return true可以插件化 false不可以插件化
*/
public static boolean isCanPluggable(ApkEntity apkEntity) {
String gh_id = (String) PackageUtils.getMetaData(
HaloApp.getInstance().getApplication(),
apkEntity.getPackageName(),
"gh_id");
return PackageUtils.isInstalled(HaloApp.getInstance().getApplication(), apkEntity.getPackageName())
&& gh_id == null
&& !TextUtils.isEmpty(apkEntity.getGhVersion())
&& !PackageUtils.isSignature(HaloApp.getInstance().getApplication(), apkEntity.getPackageName());
}
}

View File

@ -4,10 +4,9 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Handler;
import androidx.core.content.ContextCompat;
import androidx.collection.ArrayMap;
import android.text.TextUtils;
import com.gh.common.AppExecutor;
import com.gh.gamecenter.R;
import com.gh.gamecenter.entity.PlatformEntity;
import com.gh.gamecenter.eventbus.EBReuse;
@ -30,6 +29,8 @@ import java.util.Locale;
import java.util.Properties;
import java.util.Set;
import androidx.collection.ArrayMap;
import androidx.core.content.ContextCompat;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import retrofit2.HttpException;
@ -153,7 +154,7 @@ public class PlatformUtils {
}
}
if (urls.size() != 0) {
HaloApp.getInstance().getMainExecutor().execute(new Runnable() {
AppExecutor.getIoExecutor().execute(new Runnable() {
@Override
public void run() {
int success = 0;

View File

@ -1,6 +1,7 @@
package com.gh.common.util;
import android.content.Context;
import android.os.Build;
import android.text.TextUtils;
import com.gh.gamecenter.R;
@ -9,6 +10,7 @@ import com.gh.gamecenter.retrofit.JSONObjectResponse;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
import com.lightgame.utils.Utils;
import com.walkud.rom.checker.RomIdentifier;
import org.json.JSONObject;
@ -25,10 +27,23 @@ import retrofit2.HttpException;
*/
public class PostCommentUtils {
public static void addCommentData(final Context context, final String newsId, final String content,
public static void addCommentData(final Context context, final String newsId, final JSONObject content,
final CommentEntity commentEntity,
final PostCommentListener listener) {
RequestBody body = RequestBody.create(MediaType.parse("application/json"), content);
try {
JSONObject device = new JSONObject();
device.put("os", "Android");
device.put("model", Build.MODEL);
device.put("manufacturer", Build.MANUFACTURER);
device.put("android_version", android.os.Build.VERSION.RELEASE);
device.put("rom", RomIdentifier.getRom().name() + " " + RomIdentifier.getRom().getVersionName());
content.put("device", device);
} catch (Exception e) {
e.printStackTrace();
}
RequestBody body = RequestBody.create(MediaType.parse("application/json"), content.toString());
Observable<ResponseBody> observable;
if (commentEntity != null) {
observable = RetrofitManager.getInstance(context).getApi().postReplyComment(commentEntity.getId(), body);

View File

@ -1,102 +0,0 @@
package com.gh.common.util;
import android.util.Base64;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.PublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.X509EncodedKeySpec;
import javax.crypto.Cipher;
public class RSEUtils {
/**
* 公钥
*/
private static final String PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQConqikyOCl5f/VO/vZ+s6wVOhFJcI7o7hYvaLQ5Lzt5/HXbozTeRrGonKFPJurapf9hzjkg0F4/BNFMGXRVlReVdwh+Px5rbXU/ceikF8Ouf67qxiGAuDVC+4e3eIHh+mH68DlqWFJ78sB80iSLXelflGuHkbTOTtaC5F2l+AgxQIDAQAB";
/**
* 加密算法RSA
*/
private static final String KEY_ALGORITHM = "RSA";
/**
* 使用公钥加密
*
* @param content
* @return
*/
public static String encryptByPublic(String content) {
try {
PublicKey pubkey = getPublicKeyFromX509();
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
cipher.init(Cipher.ENCRYPT_MODE, pubkey);
byte[] data = content.getBytes("UTF-8");
byte[] output = cipher.doFinal(data);
String s = new String(Base64.encode(output, Base64.DEFAULT));
return s;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 得到公钥
*
* @return PublicKey 公钥
* @throws NoSuchAlgorithmException
* @throws InvalidKeySpecException
*/
private static PublicKey getPublicKeyFromX509() throws Exception {
byte[] decodedKey = Base64.decode(PUBLIC_KEY, Base64.DEFAULT);
X509EncodedKeySpec x509 = new X509EncodedKeySpec(decodedKey);
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
return keyFactory.generatePublic(x509);
}
/**
* 使用公钥解密
*
* @param content 密文
* @return 解密后的字符串
*/
public static String decryptByPublic(String content) {
try {
PublicKey pubkey = getPublicKeyFromX509();
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
cipher.init(Cipher.DECRYPT_MODE, pubkey);
InputStream ins = new ByteArrayInputStream(Base64.decode(content,
Base64.DEFAULT));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[128];
int len;
while ((len = ins.read(buffer)) != -1) {
byte[] block;
if (buffer.length == len) {
block = buffer;
} else {
block = new byte[len];
for (int i = 0; i < len; i++) {
block[i] = buffer[i];
}
}
baos.write(cipher.doFinal(block));
}
return new String(baos.toByteArray(), "utf-8");
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}

View File

@ -31,6 +31,7 @@ import com.facebook.imagepipeline.image.CloseableImage;
import com.gh.common.constant.Config;
import com.gh.gamecenter.R;
import com.gh.gamecenter.WeiBoShareActivity;
import com.gh.gamecenter.eventbus.EBShare;
import com.lightgame.utils.Utils;
import com.sina.weibo.sdk.WbSdk;
import com.sina.weibo.sdk.auth.AuthInfo;
@ -45,6 +46,8 @@ import com.tencent.tauth.IUiListener;
import com.tencent.tauth.Tencent;
import com.tencent.tauth.UiError;
import org.greenrobot.eventbus.EventBus;
import java.io.ByteArrayOutputStream;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
@ -52,7 +55,6 @@ import java.util.List;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import kotlin.jvm.functions.Function0;
import static com.gh.common.util.LoginHelper.WEIBO_SCOPE;
@ -98,6 +100,7 @@ public class ShareUtils {
private PopupWindow popupWindow;
private ShareType mShareType;
public static ShareType shareType;//全局保存shareType分享成功后判断分享的类型
private WeakReference<Activity> mActivity;
@ -107,6 +110,7 @@ public class ShareUtils {
@Override
public void onComplete(Object o) {
Utils.toast(mContext, R.string.share_success_hint);
EventBus.getDefault().post(new EBShare(ShareUtils.shareType));
}
@Override
@ -149,7 +153,7 @@ public class ShareUtils {
return false;
}
public void showShareWindowsCancelCallback(Activity activity, View view, String url, String icon, String shareTitle, String shareSummary, ShareType shareType, Function0 function) {
public void showShareWindowsCallback(Activity activity, View view, String url, String icon, String shareTitle, String shareSummary, ShareType shareType, ShareCallBack callBack) {
if (activity.isFinishing()) return;
this.mActivity = new WeakReference<>(activity);
this.shareIcon = icon;
@ -157,6 +161,7 @@ public class ShareUtils {
this.mSummary = shareSummary;
this.mTitle = shareTitle;
this.mShareType = shareType;
ShareUtils.shareType = mShareType;
View contentView = View.inflate(activity, R.layout.share_popup_layout, null);
contentView.setFocusable(true);
@ -177,8 +182,12 @@ public class ShareUtils {
ShareRecyclerViewAdapter shareRecyclerViewAdapter = new ShareRecyclerViewAdapter();
shareRecyclerView.setAdapter(shareRecyclerViewAdapter);
shareRecyclerViewAdapter.setOnItemClickListener(position -> {
if ("取消".equals(arrLabel[position])) {
function.invoke();
if (callBack != null) {
if (position == arrLabel.length - 1) {
callBack.onCancel();
} else {
callBack.onSuccess(arrLabel[position]);
}
}
});
@ -197,13 +206,18 @@ public class ShareUtils {
arrLogo[7] = R.drawable.share_cancel_logo;
}
popupWindow = new PopupWindow(contentView, LinearLayout.LayoutParams.MATCH_PARENT
popupWindow = new SharePopupWindow(contentView, LinearLayout.LayoutParams.MATCH_PARENT
, LinearLayout.LayoutParams.MATCH_PARENT, true);
popupWindow.setAnimationStyle(R.style.mypopwindow_anim_style);
popupWindow.setAnimationStyle(R.style.popwindow_exit_only_anim_style);
//解决PopupWindow无法覆盖状态栏
popupWindow.setClippingEnabled(false);
int bottomLocation = -DisplayUtils.retrieveNavigationHeight(activity);
if (!DisplayUtils.isNavigationBarShow(activity)) {
bottomLocation = 0;
}
try {
popupWindow.showAtLocation(view, Gravity.BOTTOM, 0, 0);
popupWindow.showAtLocation(view, Gravity.NO_GRAVITY, 0, bottomLocation);
} catch (Exception e) {
e.printStackTrace();
}
@ -215,7 +229,9 @@ public class ShareUtils {
&& event.getRepeatCount() == 0
&& popupWindow != null
&& popupWindow.isShowing()) {
function.invoke();
if (callBack != null) {
callBack.onCancel();
}
popupWindow.dismiss();
}
return false;
@ -224,67 +240,7 @@ public class ShareUtils {
public void showShareWindows(Activity activity, View view, String url, String icon, String shareTitle, String shareSummary, ShareType shareType) {
if (activity.isFinishing()) return;
this.mActivity = new WeakReference<>(activity);
this.shareIcon = icon;
this.shareUrl = url;
this.mSummary = shareSummary;
this.mTitle = shareTitle;
this.mShareType = shareType;
View contentView = View.inflate(activity, R.layout.share_popup_layout, null);
contentView.setFocusable(true);
contentView.setFocusableInTouchMode(true);
RecyclerView shareRecyclerView = contentView.findViewById(R.id.share_rv);
shareRecyclerView.setPadding(DisplayUtils.dip2px(mContext, 20), DisplayUtils.dip2px(mContext, 10), DisplayUtils.dip2px(mContext, 20), 0);
//RecyclerView禁止滑动
GridLayoutManager gridLayoutManager = new GridLayoutManager(mContext, 4) {
@Override
public boolean canScrollVertically() {
return false;
}
};
shareRecyclerView.setLayoutManager(gridLayoutManager);
shareRecyclerView.setAdapter(new ShareRecyclerViewAdapter());
if (mShareType == ShareType.shareGh) {
RelativeLayout layout = (RelativeLayout) view;
layout.addView(contentView);
arrLabel[6] = "邮件";
arrLogo[6] = R.drawable.share_email_logo;
arrLabel[7] = "复制链接";
arrLogo[7] = R.drawable.share_copyfont_logo;
return;
} else {
arrLabel[6] = "复制链接";
arrLogo[6] = R.drawable.share_copyfont_logo;
arrLabel[7] = "取消";
arrLogo[7] = R.drawable.share_cancel_logo;
}
popupWindow = new PopupWindow(contentView, LinearLayout.LayoutParams.MATCH_PARENT
, LinearLayout.LayoutParams.MATCH_PARENT, true);
popupWindow.setAnimationStyle(R.style.mypopwindow_anim_style);
try {
popupWindow.showAtLocation(view, Gravity.BOTTOM, 0, 0);
} catch (Exception e) {
e.printStackTrace();
}
contentView.setOnClickListener(v -> popupWindow.dismiss());
contentView.setOnKeyListener((v, keyCode, event) -> {
if (keyCode == KeyEvent.KEYCODE_BACK
&& event.getRepeatCount() == 0
&& popupWindow != null
&& popupWindow.isShowing()) {
popupWindow.dismiss();
}
return false;
});
showShareWindowsCallback(activity, view, url, icon, shareTitle, shareSummary, shareType, null);
}
//QQ分享
@ -694,4 +650,25 @@ public class ShareUtils {
void onItemClick(int position);
}
}
public interface ShareCallBack {
void onSuccess(String label);
void onCancel();
}
private static class SharePopupWindow extends PopupWindow {
SharePopupWindow(View contentView, int width, int height, boolean focusable) {
super(contentView, width, height, focusable);
}
@Override
public void dismiss() {
View backgroundView = getContentView().findViewById(R.id.share_container);
if (backgroundView != null) {
backgroundView.setBackgroundColor(Color.TRANSPARENT);
}
getContentView().postDelayed(super::dismiss, 0);
}
}
}

View File

@ -1,6 +1,7 @@
package com.gh.common.util
import android.content.Context
import android.graphics.Color
import android.graphics.Typeface
import android.text.SpannableStringBuilder
import android.text.Spanned
@ -21,6 +22,14 @@ class SpanBuilder(content: String) {
return this
}
fun color(start: Int, end: Int, colorHexInString: String): SpanBuilder {
tryWithDefaultCatch {
val colorSpan = ForegroundColorSpan(Color.parseColor(colorHexInString))
spannableString.setSpan(colorSpan, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
}
return this
}
fun size(start: Int, end: Int, dpSize: Int): SpanBuilder {
val s = AbsoluteSizeSpan(dpSize, true)
spannableString.setSpan(s, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)

View File

@ -4,6 +4,7 @@ import android.app.Activity
import android.content.Context
import android.content.Intent
import android.os.Parcelable
import androidx.fragment.app.Fragment
import com.gh.common.annotation.Synchronize
import com.gh.common.util.SyncDataBetweenPageHelper.resultHandle
import com.gh.common.util.SyncDataBetweenPageHelper.startActivityForResult
@ -12,7 +13,7 @@ import com.gh.gamecenter.gamedetail.rating.RatingAdapter
import com.gh.gamecenter.gamedetail.rating.RatingReplyActivity
/**
* 页面之间实现数据同步
* 页面之间实现数据同步(前提:页面之前拥有同一个数据实体)
* 需要同步的数据,在相应的字段加上[Synchronize]注解,关键方法[resultHandle]
* 如无特殊情况,尽量使用下面方法进行页面联动
* 注意: [startActivityForResult] intent的数据实体key必须是Class的SimpleName
@ -38,6 +39,12 @@ object SyncDataBetweenPageHelper {
}
}
fun startActivityForResult(fragment: Fragment, intent: Intent, requestCode: Int, dataPosition: Int) {
intent.putExtra(DATA_POSITION_TAG, dataPosition)
intent.putExtra(REQUEST_CODE_TAG, requestCode)
fragment.startActivityForResult(intent, requestCode)
}
fun <T : Parcelable> setResultAndFinish(context: Context, syncData: T?, resultCode: Int = Activity.RESULT_OK): Boolean {
if (context is Activity) {
val requestCode = context.intent.getIntExtra(REQUEST_CODE_TAG, DEFAULT_NUMBER)

View File

@ -5,6 +5,7 @@ import android.content.Context
import android.graphics.Color
import android.text.*
import android.text.style.ClickableSpan
import android.text.style.ForegroundColorSpan
import android.text.style.RelativeSizeSpan
import android.view.View
import android.widget.EditText
@ -91,8 +92,9 @@ object TextHelper {
}
@JvmStatic
fun highlightTextThatIsWrappedInsideWrapperByDefault(textView: TextView, text: String) {
textView.text = getHighlightedSpannableStringThatIsWrappedInsideWrapper(textView.context, text, "###", R.color.theme, object : SimpleCallback<String> {
fun highlightTextThatIsWrappedInsideWrapperByDefault(textView: TextView, text: String?) {
textView.text = getHighlightedSpannableStringThatIsWrappedInsideWrapper(textView.context, text
?: "", "###", R.color.theme_font, object : SimpleCallback<String> {
override fun onCallback(arg: String) {
val application = HaloApp.getInstance().application
val cmb = application.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
@ -122,7 +124,7 @@ object TextHelper {
text: CharSequence,
wrapper: String = "###",
@ColorRes
highlightColorId: Int = R.color.theme,
highlightColorId: Int = R.color.theme_font,
highlightedTextClickListener: SimpleCallback<String>? = object : SimpleCallback<String> {
override fun onCallback(arg: String) {
val application = HaloApp.getInstance().application
@ -185,15 +187,15 @@ object TextHelper {
*/
fun getCommentLabelSpannableStringBuilder(comment: CharSequence,
amwayStyle: Boolean = false,
tagStrokeColor: String = "#FFDAA2",
tagTextColor: String = "#FF9B06"): SpannableStringBuilder {
tagStrokeColor: String = "#FA8E00",
tagTextColor: String = "#FA8E00"): SpannableStringBuilder {
val contents = SpannableStringBuilder()
var count = 0
val splits = comment.split("<tag>")
splits.forEachIndexed { index, s ->
if (index != 0) {
val item = "<tag>$s"
val pattern = Pattern.compile("<tag>(\\S+)</tag>([\\S,\n]+)")
val pattern = Pattern.compile("<tag>(\\S+)</tag>([\\S\\s\n]+)")
val matcher = pattern.matcher(item)
if (matcher.find()) {
val label = matcher.group(1)
@ -220,6 +222,35 @@ object TextHelper {
return contents
}
fun getCommentLabelSpannableStringBuilder(comment: CharSequence, colorRes: Int): SpannableStringBuilder {
val contents = SpannableStringBuilder()
var count = 0
val splits = comment.split("<tag>")
splits.forEachIndexed { index, s ->
if (index != 0) {
val item = "<tag>$s"
val pattern = Pattern.compile("<tag>(\\S+)</tag>([\\S\\s\n]+)")
val matcher = pattern.matcher(item)
if (matcher.find()) {
val label = matcher.group(1)
var content = item.substring(item.indexOf("</tag>") + 6)
if (index == splits.size - 1) content += " "
val newLabel = "#$label# "
contents.append(newLabel)
contents.setSpan(ForegroundColorSpan(ContextCompat.getColor(HaloApp.getInstance().application, colorRes)),
count, count + newLabel.length - 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
count += newLabel.length
contents.append(content)
count += content.length
}
} else {
contents.append(s)
count += s.length
}
}
return contents
}
private fun getRoundStrokeBackgroundColorSpan(amwayStyle: Boolean,
tagStrokeColor: String,
tagTextColor: String): RoundStrokeBackgroundColorSpan {

View File

@ -1,5 +1,7 @@
package com.gh.common.util
import java.sql.Timestamp
import java.text.ParseException
import java.text.SimpleDateFormat
import java.util.*
@ -19,4 +21,40 @@ object TimeUtils {
val formatter = SimpleDateFormat("yyyy-MM-dd", Locale.CHINA)
return formatter.format(date)
}
fun getFormatTime(time: Long, pattern: String = "yyyy-MM-dd"): String {
val f = SimpleDateFormat(pattern, Locale.CHINA)
return f.format(Date(time * 1000))
}
fun getFormatDate(timestamp: Long): String {
val format = SimpleDateFormat("yyyy-MM-dd", Locale.CHINA)
format.timeZone = TimeZone.getTimeZone("Asia/Shanghai")
val testDate: String
val today = format.parse(format.format(Date())).time
val day = timestamp * 1000
val timeFormat = SimpleDateFormat("HH:mm", Locale.CHINA)
val time = timeFormat.format(day)
testDate = if (day >= today && day < today + 86400 * 1000) {
"今天 $time"
} else if (day >= today + 86400 * 1000 && day < today + 86400 * 1000 * 2) {
"明天 $time"
} else {
SimpleDateFormat("MM-dd HH:mm", Locale.CHINA).format(day)
}
return testDate
}
//判断是不是今天
fun isToday(timestamp: Long): Boolean {
val format = SimpleDateFormat("yyyy-MM-dd", Locale.CHINA)
format.timeZone = TimeZone.getTimeZone("Asia/Shanghai")
val today = format.parse(format.format(Date())).time
val day = timestamp * 1000
if (day >= today && day < today + 86400 * 1000) {
return true
}
return false
}
}

View File

@ -30,6 +30,7 @@ public class TimestampUtils {
intervalMap.put(".*games.*", 15);
intervalMap.put(".*articles.*", 20);
intervalMap.put(".*halo_addons.*", 10);
intervalMap.put(".*packages.*", 1);
}
private static void initCDMap() {
@ -39,6 +40,7 @@ public class TimestampUtils {
cdMap.put(".*games.*", Constants.GAME_CD);
cdMap.put(".*articles.*", Constants.NEWS_CD);
cdMap.put(".*halo_addons.*", Constants.ADDONS_CD);
cdMap.put(".*packages.*", Constants.PACKAGES_CD);
}
/*

View File

@ -1,188 +0,0 @@
package com.gh.common.util;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.net.TrafficStats;
import java.util.Calendar;
import java.util.List;
public class TrafficUtils {
static TrafficUtils instance;
DB db;
Context context;
private TrafficUtils(Context context) {
this.context = context.getApplicationContext();
db = new DB(this.context);
}
public static TrafficUtils getInstance(Context context) {
return getInstance(context, false);
}
public static TrafficUtils getInstance(Context context, boolean update) {
if (instance == null) {
synchronized (TrafficUtils.class) {
if (instance == null) {
instance = new TrafficUtils(context);
}
}
}
if (update) {
instance.update();
}
return instance;
}
public void update() {
// 获取所有的安装在手机上的应用软件的信息,并且获取这些软件里面的权限信息
PackageManager pm = context.getPackageManager();// 获取系统应用包管理
// 获取每个包内的androidmanifest.xml信息它的权限等等
List<PackageInfo> pinfos = pm.getInstalledPackages(PackageManager.GET_PERMISSIONS);
// 遍历每个应用包信息
for (PackageInfo info : pinfos) {
// 请求每个程序包对应的androidManifest.xml里面的权限
String[] premissions = info.requestedPermissions;
if (premissions != null && premissions.length > 0) {
// 找出需要网络服务的应用程序
for (String premission : premissions) {
if ("android.permission.INTERNET".equals(premission)) {
// 获取每个应用程序在操作系统内的进程id
int uId = info.applicationInfo.uid;
// 如果返回-1代表不支持使用该方法注意必须是2.2以上的
long rx = TrafficStats.getUidRxBytes(uId);
// 如果返回-1代表不支持使用该方法注意必须是2.2以上的
long tx = TrafficStats.getUidTxBytes(uId);
if (rx >= 0 && tx >= 0) {
db.update(info.packageName, rx + tx);
}
}
}
}
}
db.clean(Calendar.getInstance().getTimeInMillis() - 3600 * 24 * 30);
}
public long getTraffic(List<String> packageNameList) {
return this.getTraffic(packageNameList, Calendar.getInstance()
.getTimeInMillis() - 3600 * 24 * 7);
}
public long getTraffic(List<String> packageNameList, long from) {
return this.getTraffic(packageNameList, from, Calendar.getInstance()
.getTimeInMillis());
}
public long getTraffic(List<String> packageNameList, long from, long to) {
long traffic = 0;
for (String packageName : packageNameList) {
traffic += db.getTraffic(packageName, from, to);
}
return traffic;
}
public long getTraffice(String packageName) {
return db.getTraffic(packageName, Calendar.getInstance()
.getTimeInMillis() - 3600 * 24 * 7);
}
public long getTraffice(String packageName, long from) {
return db.getTraffic(packageName, from);
}
class DB extends SQLiteOpenHelper {
static final String name = "gh_traffic.db";
static final int version = 1;
String traffic = "CREATE TABLE traffic(" + "package text,"
+ "traffic integer not null," + "time integer not null" + ");";
public DB(Context context) {
super(context, name, null, version);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(traffic);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
public void update(String packageName, long traffic) {
String sql = "INSERT INTO traffic (package, traffic, time) VALUES (?, ?, ?)";
Object[] bindArgs = new Object[]{packageName, traffic,
Calendar.getInstance().getTimeInMillis()};
this.getWritableDatabase().execSQL(sql, bindArgs);
}
public void clean(long time) {
String sql = "DELETE FROM traffic WHERE time < ? ";
Object[] bindArgs = new Object[]{time};
this.getWritableDatabase().execSQL(sql, bindArgs);
}
public long getTraffic(String packageName, long from) {
return getTraffic(packageName, from, Calendar.getInstance()
.getTimeInMillis());
}
public long getTraffic(String packageName, long from, long to) {
long traffic = 0;
String sql = "SELECT * FROM traffic WHERE package = ? AND time >= ? AND time <= ? ORDER BY time DESC";
String selectionArgs[] = new String[]{packageName,
String.valueOf(from), String.valueOf(to)};
Cursor cursor = this.getReadableDatabase().rawQuery(sql,
selectionArgs);
if (cursor.getCount() > 1) {
cursor.moveToFirst();
long traffic1 = cursor
.getLong(cursor.getColumnIndex("traffic"));
// long time1 = cursor.getLong(cursor.getColumnIndex("time"));
cursor.moveToLast();
long traffic2 = cursor
.getLong(cursor.getColumnIndex("traffic"));
// long time2 = cursor.getLong(cursor.getColumnIndex("time"));
traffic = traffic1 - traffic2;
// long cha = traffic1 - traffic2;
// if(cha > 0){
// traffic = cha / (time2 - time1);
// }
} else if (cursor.getCount() == 1) {
sql = "SELECT * FROM traffic WHERE package = ? AND time < ? ORDER BY time DESC";
selectionArgs = new String[]{packageName,
String.valueOf(from)};
Cursor cursor2 = this.getReadableDatabase().rawQuery(sql,
selectionArgs);
if (cursor2.moveToNext()) {
cursor.moveToFirst();
long traffic1 = cursor.getLong(cursor
.getColumnIndex("traffic"));
// long time1 =
// cursor.getLong(cursor.getColumnIndex("time"));
long traffic2 = cursor2.getLong(cursor
.getColumnIndex("traffic"));
// long time2 =
// cursor2.getLong(cursor.getColumnIndex("time"));
traffic = traffic1 - traffic2;
// long cha = traffic1 - traffic2;
// if(cha > 0){
// traffic = cha / (time2 - time1);
// }
}
cursor2.close();
}
cursor.close();
return traffic;
}
}
}

View File

@ -0,0 +1,209 @@
package com.gh.common.view
import android.content.Context
import android.util.AttributeSet
import android.view.*
import android.widget.LinearLayout
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import androidx.viewpager2.widget.ViewPager2
import com.facebook.drawee.view.SimpleDraweeView
import com.facebook.imagepipeline.image.ImageInfo
import com.gh.common.util.DisplayUtils
import com.gh.common.util.ImageUtils
import com.gh.common.util.rxTimer
import com.gh.gamecenter.R
import com.gh.gamecenter.entity.SettingsEntity
import io.reactivex.disposables.Disposable
import kotlin.math.abs
/**
* 视频流广告轮播控件
*/
class AdBannerView : LinearLayout {
private lateinit var mViewPager2: ViewPager2
private var mDatas = ArrayList<SettingsEntity.Advertisement>()
var isAutoPlay = true
private var currentPage = 0
private var autoDurationTime = 6000L
private var mRxTimer: Disposable? = null
private var lastX: Float = 0F
private var lastY: Float = 0F
private var startX: Float = 0F
private var startY: Float = 0F
private val mTouchSlop = ViewConfiguration.get(context).scaledTouchSlop
private val bannerWidth = DisplayUtils.dip2px(52f)
var onItemClick: ((position: Int) -> Unit)? = null
private lateinit var mIndicatorLayout: LinearLayout
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
init {
initViews()
}
private fun initViews() {
orientation = VERTICAL
mViewPager2 = ViewPager2(context).apply {
layoutParams = ViewGroup.LayoutParams(bannerWidth, bannerWidth)
orientation = ViewPager2.ORIENTATION_HORIZONTAL
registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
override fun onPageSelected(position: Int) {
super.onPageSelected(position)
currentPage = position
slideIndicator(currentPage % mDatas.size)
}
})
}
val recyclerView = mViewPager2.getChildAt(0) as RecyclerView
recyclerView.overScrollMode = RecyclerView.OVER_SCROLL_NEVER
addView(mViewPager2)
mIndicatorLayout = LinearLayout(context).apply {
orientation = HORIZONTAL
gravity = Gravity.CENTER
val params = LayoutParams(LayoutParams.MATCH_PARENT, DisplayUtils.dip2px(5F))
params.topMargin = DisplayUtils.dip2px(8f)
layoutParams = params
}
addView(mIndicatorLayout)
}
fun start(datas: ArrayList<SettingsEntity.Advertisement>) {
if (datas.isNullOrEmpty()) throw IllegalArgumentException("广告列表不能为空")
val adapter = mViewPager2.adapter
mDatas = datas
if (adapter == null) {
val bannerAdapter = AdBannerAdapter()
mViewPager2.adapter = bannerAdapter
} else {
adapter.notifyDataSetChanged()
}
currentPage = (mViewPager2.adapter as AdBannerAdapter).getActualFirstPositionInCenter()
mViewPager2.setCurrentItem(currentPage, false)
if (mDatas.size > 1) {
addIndicator()
slideIndicator(currentPage % mDatas.size)
autoPlay()
}
}
private fun autoPlay() {
if (isAutoPlay && mDatas.size > 1) {
if (mRxTimer != null && !mRxTimer!!.isDisposed) {
mRxTimer?.dispose()
mRxTimer = null
}
mRxTimer = rxTimer(autoDurationTime) {
slidePage()
}
}
}
private fun slidePage() {
currentPage++
mViewPager2.setCurrentItem(currentPage, true)
}
fun resumePage() {
autoPlay()
}
fun pausePage() {
if (mRxTimer != null && !mRxTimer!!.isDisposed) {
mRxTimer?.dispose()
mRxTimer = null
}
}
private fun addIndicator() {
mIndicatorLayout.removeAllViews()
mDatas.forEach { _ ->
val view = View(context).apply {
background = ContextCompat.getDrawable(context, R.drawable.selector_video_detail_ad_indicator)
val params = LayoutParams(DisplayUtils.dip2px(4F), DisplayUtils.dip2px(4F))
params.leftMargin = DisplayUtils.dip2px(2F)
params.rightMargin = DisplayUtils.dip2px(2F)
layoutParams = params
}
mIndicatorLayout.addView(view)
}
}
private fun slideIndicator(position: Int) {
for (i in 0 until mIndicatorLayout.childCount) {
val childAt = mIndicatorLayout.getChildAt(i)
childAt.isSelected = i == position
}
}
override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
val action = ev.action
if (action == MotionEvent.ACTION_DOWN) {
lastX = ev.rawX
startX = lastX
lastY = ev.rawY
startY = lastY
} else if (action == MotionEvent.ACTION_MOVE) {
lastX = ev.rawX
lastY = ev.rawY
val distanceX = abs(lastX - startX)
val distanceY = abs(lastY - startY)
val disallowIntercept: Boolean
disallowIntercept = if (mViewPager2.orientation == ViewPager2.ORIENTATION_HORIZONTAL) {
distanceX > mTouchSlop && distanceX > distanceY
} else {
distanceY > mTouchSlop && distanceY > distanceX
}
parent.requestDisallowInterceptTouchEvent(disallowIntercept)
} else if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) {
return abs(lastX - startX) > mTouchSlop || abs(lastY - startY) > mTouchSlop
}
return super.onInterceptTouchEvent(ev)
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
if (mRxTimer != null && !mRxTimer!!.isDisposed) {
mRxTimer?.dispose()
mRxTimer = null
}
}
fun getAdDatas(): ArrayList<SettingsEntity.Advertisement> {
return mDatas
}
private inner class AdBannerAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
return object : RecyclerView.ViewHolder(LayoutInflater.from(context).inflate(R.layout.item_ad_banner, parent, false)) {}
}
override fun getItemCount(): Int = if (mDatas.size == 1) mDatas.size else Int.MAX_VALUE
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
val ad = mDatas[position % mDatas.size]
val view = holder.itemView as SimpleDraweeView
ImageUtils.display(view, ad.image)
holder.itemView.setOnClickListener {
onItemClick?.invoke(position % mDatas.size)
}
}
fun getActualFirstPositionInCenter(): Int {
if (mDatas.size == 1) return 0
var index = itemCount / 2
if (index % mDatas.size != 0) {
index -= (index % mDatas.size)
}
return index - 1
}
}
}

View File

@ -14,26 +14,26 @@ public class CenterImageSpan extends ImageSpan {
public CenterImageSpan(Context context, int resourceId) {
super(context, resourceId);
}
public CenterImageSpan(Drawable drawable) {
super( drawable);
super(drawable);
}
@Override
public int getSize(Paint paint, CharSequence text, int start, int end,
Paint.FontMetricsInt fm) {
Drawable d = getDrawable();
Rect rect = d.getBounds();
if (fm != null) {
Paint.FontMetricsInt fontMetricsInt) {
Drawable drawable = getDrawable();
Rect rect = drawable.getBounds();
if (fontMetricsInt != null) {
Paint.FontMetricsInt fmPaint = paint.getFontMetricsInt();
int fontHeight = fmPaint.bottom - fmPaint.top;
int fontHeight = fmPaint.descent - fmPaint.ascent;
int drHeight = rect.bottom - rect.top;
int centerY = fmPaint.ascent + fontHeight / 2;
int top = drHeight / 2 - fontHeight / 4;
int bottom = drHeight / 2 + fontHeight / 4;
fm.ascent = -bottom;
fm.top = -bottom;
fm.bottom = top;
fm.descent = top;
fontMetricsInt.ascent = centerY - drHeight / 2;
fontMetricsInt.top = fontMetricsInt.ascent;
fontMetricsInt.bottom = centerY + drHeight / 2 + 1; // fuck 这里不加 1px 会导致图片底部被截掉 1px
fontMetricsInt.descent = fontMetricsInt.bottom;
}
return rect.right;
}
@ -41,14 +41,14 @@ public class CenterImageSpan extends ImageSpan {
@Override
public void draw(Canvas canvas, CharSequence text, int start, int end,
float x, int top, int y, int bottom, Paint paint) {
Drawable b = getDrawable();
Drawable drawable = getDrawable();
canvas.save();
int transY;
transY = ((bottom - top) - b.getBounds().bottom) / 2 + top;
Paint.FontMetricsInt fmPaint = paint.getFontMetricsInt();
int fontHeight = fmPaint.descent - fmPaint.ascent;
int centerY = y + fmPaint.descent - fontHeight / 2;
int transY = centerY - (drawable.getBounds().bottom - drawable.getBounds().top) / 2;
canvas.translate(x, transY);
if (b.isVisible()) {
b.draw(canvas);
}
drawable.draw(canvas);
canvas.restore();
}

View File

@ -12,6 +12,7 @@ import android.view.animation.Animation;
import android.view.animation.CycleInterpolator;
import android.view.animation.TranslateAnimation;
import com.gh.common.util.DisplayUtils;
import com.gh.gamecenter.R;
@ -49,7 +50,8 @@ public class ClearEditTextNormal extends androidx.appcompat.widget.AppCompatEdit
mClearDrawable = getResources().getDrawable(R.drawable.icon_close);
}
mClearDrawable.setBounds(0, 0, mClearDrawable.getIntrinsicWidth(), mClearDrawable.getIntrinsicHeight());
// mClearDrawable.setBounds(0, 0, mClearDrawable.getIntrinsicWidth(), mClearDrawable.getIntrinsicHeight());
mClearDrawable.setBounds(0, 0, DisplayUtils.dip2px(16), DisplayUtils.dip2px(16));
//默认设置隐藏图标
setClearIconVisible(false);
//设置焦点改变的监听

View File

@ -0,0 +1,34 @@
package com.gh.common.view
import android.content.Context
import android.graphics.Rect
import android.view.View
import android.widget.LinearLayout
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.RecyclerView
class CustomDividerItemDecoration(
context: Context,
var onlyDecorateTheFirstItem: Boolean = false,
var notDecorateTheFirstItem: Boolean = false,
var notDecorateTheLastItem: Boolean = false,
var notDecorateTheFirstTwoItems: Boolean = false) : DividerItemDecoration(context, LinearLayout.VERTICAL) {
override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) {
if (onlyDecorateTheFirstItem) {
if (parent.getChildAdapterPosition(view) == 0) outRect[0, 0, 0] = drawable!!.intrinsicHeight
} else {
if (parent.getChildAdapterPosition(view) == 0
&& (notDecorateTheFirstItem || notDecorateTheFirstTwoItems)) {
outRect.set(0, 0, 0, 0)
} else if (parent.getChildAdapterPosition(view) == 1 && notDecorateTheFirstTwoItems) {
outRect.set(0, 0, 0, 0)
} else if (parent.getChildAdapterPosition(view) == parent.adapter!!.itemCount - 1 && notDecorateTheLastItem) {
outRect.set(0, 0, 0, 0)
} else {
outRect[0, 0, 0] = drawable!!.intrinsicHeight
}
}
}
}

View File

@ -1,25 +1,63 @@
package com.gh.common.view;
import android.text.Layout;
import android.text.Selection;
import android.text.Spannable;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.view.MotionEvent;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.TextView;
public class CustomLinkMovementMethod extends LinkMovementMethod {
@Override
public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) {
boolean b = super.onTouchEvent(widget, buffer, event);
int action = event.getAction();
boolean isTouchEventConsumed = false;
if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_DOWN) {
int x = (int) event.getX();
int y = (int) event.getY();
x -= widget.getTotalPaddingLeft();
y -= widget.getTotalPaddingTop();
x += widget.getScrollX();
y += widget.getScrollY();
Layout layout = widget.getLayout();
int line = layout.getLineForVertical(y);
int off = layout.getOffsetForHorizontal(line, x);
ClickableSpan[] links = buffer.getSpans(off, off, ClickableSpan.class);
if (links.length != 0) {
ClickableSpan link = links[0];
if (action == MotionEvent.ACTION_UP) {
link.onClick(widget);
} else if (action == MotionEvent.ACTION_DOWN) {
// 下面这行代码会造成触摸 clickbleSpan 时 RecyclerView 的 item 高度变更 : (
// 看起来像是跟文字选择相关的东西,反正我们的 clickSpan 也不让选,直接屏蔽掉了
// Selection.setSelection(buffer,
// buffer.getSpanStart(link),
// buffer.getSpanEnd(link));
}
isTouchEventConsumed = true;
} else {
Selection.removeSelection(buffer);
}
}
//解决点击事件冲突问题
if (!b && event.getAction() == MotionEvent.ACTION_UP) {
if (!isTouchEventConsumed && event.getAction() == MotionEvent.ACTION_UP) {
ViewParent parent = iterateViewParentForClicking(widget.getParent());//处理widget的父控件点击事件
if (parent != null && parent instanceof ViewGroup) {
if (parent instanceof ViewGroup) {
return ((ViewGroup) parent).performClick();
}
}
return b;
return false;
}
@ -33,14 +71,13 @@ public class CustomLinkMovementMethod extends LinkMovementMethod {
}
return null;
}
public static CustomLinkMovementMethod getInstance() {
if (sInstance == null) sInstance = new CustomLinkMovementMethod();
return sInstance;
}
private static CustomLinkMovementMethod sInstance;
}

View File

@ -1,662 +0,0 @@
package com.gh.common.view;
import android.app.Dialog;
import android.content.Context;
import androidx.databinding.DataBindingUtil;
import androidx.annotation.Nullable;
import androidx.viewpager.widget.ViewPager;
import androidx.viewpager.widget.ViewPager.OnPageChangeListener;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.PopupWindow;
import android.widget.TextView;
import com.gh.common.constant.Config;
import com.gh.common.exposure.ExposureEvent;
import com.gh.common.util.ClickUtils;
import com.gh.common.util.DirectUtils;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.PackageUtils;
import com.gh.common.util.PlatformUtils;
import com.gh.common.util.SPUtils;
import com.gh.download.DownloadManager;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.OnCollectionCallBackListener;
import com.gh.gamecenter.adapter.PlatformPagerAdapter;
import com.gh.gamecenter.databinding.ImprintContentItemBinding;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.ApkLink;
import com.gh.gamecenter.entity.GameCollectionEntity;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.entity.LinkEntity;
import com.gh.gamecenter.entity.SettingsEntity;
import com.gh.gamecenter.eventbus.EBDownloadStatus;
import com.gh.gamecenter.eventbus.EBPackage;
import com.gh.gamecenter.eventbus.EBReuse;
import com.gh.gamecenter.manager.PackagesManager;
import com.lightgame.download.DataWatcher;
import com.lightgame.download.DownloadEntity;
import com.lightgame.download.DownloadStatus;
import com.lightgame.utils.Utils;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
/**
* @author 温冠超
* @email 294299195@qq.com
* @date 2015-8-12
* @update 2015-8-12
* @des 弹出游戏版本下载按钮,点击并添加到下载任务中
*/
public class DownloadDialog implements OnCollectionCallBackListener {
private Context mContext;
private PopupWindow popupWindow;
private ViewPager viewPager;
private ViewPager collectionViewPager;
private LinearLayout dialog_ll_collection_hint;
private LinearLayout dialog_ll_hint;
private LinearLayout dialog_ll_collection;
private View mDialogMorePlatformHint;
private List<ApkEntity> gameApk;
private GameEntity gameEntity;
private PlatformPagerAdapter adapter;
private PlatformPagerAdapter collectionAdapter;
private ExposureEvent traceEvent;
private static final String DOWNLOAD_PLATFORM_HINT = "download_platform_hint";
private String entrance;
private String location;
private String mAutoDownloadPlatform;
private final int row = 3;
private final int column = 3;
private boolean isLoadPlatform;
private DataWatcher dataWatcher = new DataWatcher() {
@Override
public void onDataChanged(DownloadEntity downloadEntity) {
if (downloadEntity.getName().equals(gameEntity.getName())
&& !DownloadStatus.delete.equals(DownloadManager.getInstance(mContext).getStatus(downloadEntity.getUrl()))) {
adapter.putDownloadEntity(downloadEntity);
if (collectionAdapter != null) {
collectionAdapter.putDownloadEntity(downloadEntity);
}
}
}
};
private DownloadDialog(Context context) {
mContext = context;
}
public static DownloadDialog getInstance(Context context) {
return new DownloadDialog(context);
}
// 自动下载并翻到相应页面
public void showPopupWindowAutoDownload(View view, GameEntity gameEntity, String autoDownloadPlatform,
String entrance, String location, ExposureEvent traceEvent) {
mAutoDownloadPlatform = autoDownloadPlatform;
showPopupWindow(view, gameEntity, entrance, location, traceEvent);
}
public void showPopupWindow(View view, GameEntity gameEntity, String entrance, String location) {
showPopupWindow(view, gameEntity, entrance, location, null);
}
public void showPopupWindow(View view, GameEntity gameEntity, String entrance, String location,
@Nullable ExposureEvent traceEvent) {
if (ClickUtils.isFastDoubleClick()) {
return;
}
this.gameEntity = gameEntity;
this.entrance = entrance;
this.location = location;
this.traceEvent = traceEvent;
gameApk = gameEntity.getApk();
if (gameEntity.getCollection() != null) {
mergeApkCollection(gameEntity);
}
if (gameEntity.getApkLink() != null) {
mergeApkLink(gameEntity);
}
sortApk();
// 一个自定义的布局,作为显示的内容
View contentView = View.inflate(mContext, R.layout.game_download_dialog, null);
TextView title = contentView.findViewById(R.id.dialog_title);
title.setText(gameEntity.getName());
viewPager = contentView.findViewById(R.id.dialog_viewPager);
dialog_ll_hint = contentView.findViewById(R.id.dialog_ll_hint);
dialog_ll_collection = contentView.findViewById(R.id.dialog_ll_collection);
dialog_ll_collection_hint = contentView.findViewById(R.id.dialog_ll_collection_hint);
collectionViewPager = contentView.findViewById(R.id.dialog_collection_viewPager);
mDialogMorePlatformHint = contentView.findViewById(R.id.dialog_more_platform_hit);
TextView dialogAd = contentView.findViewById(R.id.dialog_ad);
TextView dialogAdMirror = contentView.findViewById(R.id.dialog_ad_mirror);
mDialogMorePlatformHint.setOnClickListener(v -> {
mDialogMorePlatformHint.setVisibility(View.GONE);
SPUtils.setBoolean(DOWNLOAD_PLATFORM_HINT, false);
});
LinkEntity downloadAd = gameEntity.getDownloadAd();
if (downloadAd != null) {
dialogAd.setVisibility(View.VISIBLE);
dialogAd.setText(downloadAd.getTitle());
dialogAdMirror.setVisibility(View.INVISIBLE);
dialogAdMirror.setText(downloadAd.getTitle());
dialogAd.setOnClickListener(v -> {
if ("imprint".equals(downloadAd.getType())) {
showImprintDialog(downloadAd.getTitle());
} else {
DirectUtils.directToLinkPage(
mContext,
downloadAd,
entrance, "下载多平台弹窗");
}
});
}
isLoadPlatform = false;
init(new ArrayList<>(gameApk));
viewPager.addOnPageChangeListener(new MyPageChangeListener(dialog_ll_hint));
popupWindow = new PopupWindow(contentView, LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT, true);
contentView.setOnClickListener(v -> popupWindow.dismiss());
contentView.setFocusable(true);
contentView.setFocusableInTouchMode(true);
contentView.setOnKeyListener((v, keyCode, event) -> {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0
&& popupWindow != null && popupWindow.isShowing()) {
popupWindow.dismiss();
}
return false;
});
popupWindow.setOnDismissListener(() -> {
EventBus.getDefault().unregister(DownloadDialog.this);
DownloadManager.getInstance(mContext).removeObserver(dataWatcher);
});
popupWindow.setTouchable(true);
popupWindow.setFocusable(true);
// 设置popWindow的显示和消失动画
popupWindow.setAnimationStyle(R.style.mypopwindow_anim_style);
// 设置好参数之后再show
popupWindow.showAtLocation(view, Gravity.BOTTOM, 0, 0);
if (!EventBus.getDefault().isRegistered(DownloadDialog.this)) {
EventBus.getDefault().register(DownloadDialog.this);
}
DownloadManager.getInstance(mContext).addObserver(dataWatcher);
}
private void showImprintDialog(String titleName) {
Dialog dialog = new Dialog(mContext, R.style.full_dialog);
View inflate = LayoutInflater.from(mContext).inflate(R.layout.imprint_dialog, null);
dialog.setContentView(inflate);
dialog.show();
Window window = dialog.getWindow();
WindowManager.LayoutParams params;
if (window != null) {
params = window.getAttributes();
params.width = (int) (mContext.getResources().getDisplayMetrics().widthPixels * 0.9);
window.setAttributes(params);
window.setBackgroundDrawableResource(R.drawable.full_dialog_background);
}
inflate.findViewById(R.id.imprint_close).setOnClickListener(v -> dialog.dismiss());
LinearLayout content = inflate.findViewById(R.id.imprint_content);
((TextView) inflate.findViewById(R.id.imprint_title)).setText(titleName);
View head = LayoutInflater.from(mContext).inflate(R.layout.imprint_content_item, null);
content.addView(head, LayoutParams.MATCH_PARENT, DisplayUtils.dip2px(30));
LimitHeightLinearLayout imprintContainer = inflate.findViewById(R.id.imprint_container);
imprintContainer.setLimitHeight((int) (mContext.getResources().getDisplayMetrics().heightPixels * 0.8));
ArrayList<ApkEntity> list = gameEntity.getApk();
SettingsEntity settings = Config.getSettings();
for (int i = 0; i < list.size(); i++) {
ApkEntity apk = gameEntity.getApk().get(i);
if (settings != null && settings.getGameDownloadBlackList().contains(apk.getPackageName())) {
continue;
}
View item = LayoutInflater.from(mContext).inflate(R.layout.imprint_content_item, null);
ImprintContentItemBinding bind = DataBindingUtil.bind(item);
bind.setApk(apk);
bind.setPlatformName(PlatformUtils.getInstance(mContext).getPlatformName(apk.getPlatform()));
content.addView(item, LayoutParams.MATCH_PARENT, DisplayUtils.dip2px(40));
}
// close line
View view = new View(mContext);
view.setBackgroundColor(mContext.getResources().getColor(R.color.text_5d5d5d));
view.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, DisplayUtils.dip2px(1)));
content.addView(view);
}
private void sortApk() {
for (ApkEntity apkEntity : gameApk) {
GameCollectionEntity apkCollection = apkEntity.getApkCollection();
if (apkCollection != null) {
List<ApkEntity> saveApkEntity = apkCollection.getSaveApkEntity();
if (saveApkEntity != null) {
for (ApkEntity entity : saveApkEntity) {
int sortValue = getSortValue(entity);
if (apkEntity.getOrder() < sortValue) {
apkEntity.setOrder(sortValue);
}
}
}
continue;
}
apkEntity.setOrder(getSortValue(apkEntity));
}
Comparator<ApkEntity> comparator = (lhs, rhs) -> rhs.getOrder() - lhs.getOrder();
Collections.sort(gameApk, comparator);
}
private int getSortValue(ApkEntity apkEntity) {
/*
* 安装插件 10
* 插件化下载中 9
* 插件化 8
* 安装更新 7
* 更新下载中 6
* 更新 5
* 安装 4
* 下载中 3
* 启动 2
* 默认有图片1
* 默认无图片0
*/
Object gh_id;
String packageName = apkEntity.getPackageName();
DownloadEntity downloadEntity = DownloadManager.getInstance(mContext).getDownloadEntityByUrl(apkEntity.getUrl());
if (downloadEntity == null) {
if (!TextUtils.isEmpty(packageName) && PackagesManager.INSTANCE.isInstalled(packageName)) {
gh_id = PackageUtils.getMetaData(mContext, packageName, "gh_id");
if (gh_id == null || gh_id.equals(gameEntity.getId())) {
if (!PackageUtils.isSignature(mContext, packageName)) {
return 8;
} else if (PackagesManager.INSTANCE.isCanUpdate(gameEntity.getId(), packageName)) {
return 5;
} else {
return 2;
}
}
}
if (apkEntity.getOrder() < 1) apkEntity.setOrder(1);
String platform = apkEntity.getPlatform();
int id = PlatformUtils.getInstance(mContext).getPlatformPic(platform);
if (id == 0) {
String path = PlatformUtils.getInstance(mContext).getPlatformPicUrl(platform);
if (path == null) {
return 0;
}
}
} else {
if (downloadEntity.getStatus().equals(DownloadStatus.done)) {
if (downloadEntity.isPluggable()) {
return 10;
} else if (downloadEntity.isUpdate()) {
return 7;
} else {
return 4;
}
} else {
if (downloadEntity.isPluggable()) {
return 9;
} else if (downloadEntity.isUpdate()) {
return 6;
} else {
return 3;
}
}
}
return 0;
}
// 合并ApkLink
private void mergeApkLink(GameEntity gameEntity) {
for (ApkLink apkLink : gameEntity.getApkLink()) {
if (!TextUtils.isEmpty(apkLink.getCollection())) {
for (int i = 0; i < gameApk.size(); i++) {
ApkEntity apkEntity = gameApk.get(i);
GameCollectionEntity apkCollection = apkEntity.getApkCollection();
if (apkCollection != null && apkCollection.getSaveApkEntity() != null) {
List<ApkEntity> saveApkEntity = apkCollection.getSaveApkEntity();
if (apkLink.getCollection().equals(apkCollection.getId())) {
ApkEntity element = new ApkEntity();
element.setApkLink(apkLink);
if (saveApkEntity.size() > apkLink.getSort()) {
saveApkEntity.add(apkLink.getSort(), element);
} else {
saveApkEntity.add(element);
}
}
}
}
} else {
ApkEntity element = new ApkEntity();
element.setApkLink(apkLink);
if (gameApk.size() > apkLink.getSort()) {
gameApk.add(apkLink.getSort(), element);
} else {
gameApk.add(element);
}
}
}
}
// 合并ApkCollection
private void mergeApkCollection(GameEntity gameEntity) {
List<ApkEntity> gameCollectionApk = new ArrayList<>();
ConcurrentHashMap<String, Integer> hashMap = new ConcurrentHashMap<>();
boolean isCollection;
for (ApkEntity apkEntity : gameApk) {
isCollection = false;
for (GameCollectionEntity gameCollectionEntity : gameEntity.getCollection()) {
for (String packageName : gameCollectionEntity.getPackage()) {
if (packageName.equals(apkEntity.getPackageName())) {
isCollection = true;
if (hashMap.get(gameCollectionEntity.getName()) != null) {
gameCollectionApk.get(hashMap.get(gameCollectionEntity.getName()))
.getApkCollection().getSaveApkEntity().add(apkEntity);
} else {
ApkEntity newApkEntity = new ApkEntity();
GameCollectionEntity collectionEntity = new GameCollectionEntity();
List<ApkEntity> saveApkList = new ArrayList<>();
saveApkList.add(apkEntity);
collectionEntity.setSaveApkEntity(saveApkList);
collectionEntity.setId(gameCollectionEntity.getId());
collectionEntity.setName(gameCollectionEntity.getName());
collectionEntity.setIcon(gameCollectionEntity.getIcon());
collectionEntity.setColor(gameCollectionEntity.getColor());
newApkEntity.setApkCollection(collectionEntity);
gameCollectionApk.add(newApkEntity);
hashMap.put(gameCollectionEntity.getName(), gameCollectionApk.size() - 1);
}
}
}
}
if (!isCollection) {
gameCollectionApk.add(apkEntity);
}
}
gameApk = gameCollectionApk;
}
private void init(List<ApkEntity> apkList) {
for (int i = 0; i < apkList.size(); i++) {
String platformName = PlatformUtils.getInstance(mContext)
.getPlatformName(apkList.get(i).getPlatform());
if (platformName == null) {
apkList.remove(i);
i--;
if (!isLoadPlatform) {
PlatformUtils.getInstance(mContext).getPlatform();
isLoadPlatform = true;
}
}
}
ApkEntity skipEntiy = new ApkEntity();
skipEntiy.setPackageName("求版本");
apkList.add(skipEntiy); // 添加一个跳转投票
dialog_ll_hint.removeAllViews();
int size = (int) Math.ceil(apkList.size() / (double) (row * column));
addHintPoint(dialog_ll_hint, size);
if (size >= 2) {
boolean isShowPlatformHint = SPUtils.getBoolean(DOWNLOAD_PLATFORM_HINT, true);
if (isShowPlatformHint) {
mDialogMorePlatformHint.setVisibility(View.VISIBLE);
}
}
int count = apkList.size();
int vpHeight;
if (count <= 3) {
vpHeight = 90;
} else if (count <= 6) {
vpHeight = 150;
} else {
vpHeight = 210;
}
ViewGroup.LayoutParams layoutParams = viewPager.getLayoutParams();
layoutParams.height = DisplayUtils.dip2px(mContext, vpHeight);
viewPager.setLayoutParams(layoutParams);
int currentItem = 0;
if (viewPager != null) {
currentItem = viewPager.getCurrentItem();
}
if (!TextUtils.isEmpty(mAutoDownloadPlatform)) {
for (int i = 0; i < apkList.size(); i++) {
ApkEntity apkEntity = apkList.get(i);
if (mAutoDownloadPlatform.equals(apkEntity.getPlatform())) {
currentItem = (i / 9);
break;
}
GameCollectionEntity apkCollection = apkEntity.getApkCollection();
if (apkCollection != null) {
List<ApkEntity> saveApkEntity = apkCollection.getSaveApkEntity();
if (saveApkEntity != null) {
for (ApkEntity entity : saveApkEntity) {
if (mAutoDownloadPlatform.equals(entity.getPlatform())) {
currentItem = (i / 9);
break;
}
}
}
}
}
}
Utils.log("currentItem = " + currentItem);
adapter = new PlatformPagerAdapter(mContext, this,
gameEntity, apkList, mAutoDownloadPlatform, entrance, location, traceEvent);
viewPager.setAdapter(adapter);
viewPager.setCurrentItem(currentItem);
if (currentItem != 0) setDownloadOvalHint(dialog_ll_hint, currentItem);
}
private void addHintPoint(LinearLayout linearLayout, int size) {
if (size <= 1) {
return;
}
for (int i = 0; i < size; i++) {
ImageView imageView = new ImageView(mContext);
LayoutParams lparams = new LayoutParams(
DisplayUtils.dip2px(mContext, 6), DisplayUtils.dip2px(mContext, 6));
if (i == 0) {
lparams.leftMargin = 0;
imageView.setImageResource(R.drawable.download_oval_hint_up);
} else {
lparams.leftMargin = DisplayUtils.dip2px(mContext, 9);
imageView.setImageResource(R.drawable.oval_hint_gray_bg);
}
imageView.setLayoutParams(lparams);
linearLayout.addView(imageView);
}
}
// 接收安装成功的消息,更新界面
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(EBPackage busFour) {
if ("安装".equals(busFour.getType())) {
adapter.removeDownloadEntityByPackageName(busFour.getPackageName());
if (collectionAdapter != null) {
collectionAdapter.removeDownloadEntityByPackageName(busFour.getPackageName());
}
} else if ("卸载".equals(busFour.getType())) {
adapter.updateItem(busFour.getPackageName());
if (collectionAdapter != null) {
collectionAdapter.updateItem(busFour.getPackageName());
}
}
}
//接收下载被删除消息
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(EBDownloadStatus status) {
if ("delete".equals(status.getStatus())) {
String url = status.getUrl();
adapter.removeDownloadEntityByUrl(url);
if (collectionAdapter != null) {
collectionAdapter.removeDownloadEntityByUrl(url);
}
// DownloadManager.getInstance(mContext).putStatus(url, "delete");
}
}
// 接收platform数据改变消息更新界面
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(EBReuse reuse) {
if ("PlatformChanged".equals(reuse.getType())) {
DownloadManager.getInstance(mContext).removeObserver(dataWatcher);
init(new ArrayList<>(gameApk));
DownloadManager.getInstance(mContext).addObserver(dataWatcher);
}
}
// 显示合集
@Override
public void showCollection(GameCollectionEntity gameCollectionEntity) {
dialog_ll_collection.setVisibility(View.VISIBLE);
List<ApkEntity> saveApkList = gameCollectionEntity.getSaveApkEntity();
int count = saveApkList.size();
int vpHeight;
if (count <= 3) {
vpHeight = 82;
} else if (count <= 6) {
vpHeight = 142;
} else {
vpHeight = 202;
}
ViewGroup.LayoutParams layoutParams = collectionViewPager.getLayoutParams();
layoutParams.height = DisplayUtils.dip2px(mContext, vpHeight);
collectionViewPager.setLayoutParams(layoutParams);
dialog_ll_collection_hint.removeAllViews();
int size = (int) Math.ceil(count / (double) (row * column));
addHintPoint(dialog_ll_collection_hint, size);
collectionAdapter = new PlatformPagerAdapter(
mContext, null, gameEntity, saveApkList,
mAutoDownloadPlatform, entrance, location, traceEvent);
collectionViewPager.setAdapter(collectionAdapter);
collectionViewPager.addOnPageChangeListener(new MyPageChangeListener(dialog_ll_collection_hint));
int currentItem = 0;
if (!TextUtils.isEmpty(mAutoDownloadPlatform)) {
for (int i = 0; i < saveApkList.size(); i++) {
ApkEntity apkEntity = saveApkList.get(i);
if (mAutoDownloadPlatform.equals(apkEntity.getPlatform())) {
currentItem = (i / 9);
break;
}
}
}
if (currentItem != 0) {
collectionViewPager.setCurrentItem(currentItem);
setDownloadOvalHint(dialog_ll_collection_hint, currentItem);
}
mAutoDownloadPlatform = null;
}
// 隐藏合集
@Override
public void hideCollection() {
dialog_ll_collection.setVisibility(View.GONE);
collectionAdapter = null;
}
private class MyPageChangeListener implements OnPageChangeListener {
private LinearLayout linearLayout;
public MyPageChangeListener(LinearLayout linearLayout) {
this.linearLayout = linearLayout;
}
@Override
public void onPageScrolled(int i, float v, int i1) {
}
@Override
public void onPageSelected(int position) {
setDownloadOvalHint(linearLayout, position);
}
@Override
public void onPageScrollStateChanged(int i) {
}
}
private void setDownloadOvalHint(LinearLayout linearLayout, int position) {
for (int i = 0, size = linearLayout.getChildCount(); i < size; i++) {
if (i == position % size) {
((ImageView) linearLayout.getChildAt(i))
.setImageResource(R.drawable.download_oval_hint_up);
} else {
((ImageView) linearLayout.getChildAt(i))
.setImageResource(R.drawable.oval_hint_gray_bg);
}
}
}
}

View File

@ -24,9 +24,7 @@ import androidx.core.content.ContextCompat;
public class DownloadProgressBar extends ProgressBar {
public static final int MAX_LENGTH = 1000;
public static final int DOWNLOAD_NORMAL_STYLE = 0;
public static final int DOWNLOAD_RECT_STYLE = 1;
public static final int DOWNLOAD_IMAGE_STYLE = 2;
public static final int DOWNLOAD_SLIDE_STYLE = 3;
public enum DownloadType {
NORMAL,
@ -92,7 +90,7 @@ public class DownloadProgressBar extends ProgressBar {
super.onDraw(canvas);
if (TextUtils.isEmpty(mText)) return;
mPaint.setColor(mDefaultColor == 0 ? ContextCompat.getColor(getContext(), R.color.theme) : mDefaultColor); // 初始化颜色
mPaint.setColor(mDefaultColor == 0 ? ContextCompat.getColor(getContext(), R.color.theme_font) : mDefaultColor); // 初始化颜色
mPaint.setTextSize(mTextSize);
mFakeTextPaint.setTextSize(mTextSize);
mFakeTextPaint.setStyle(Paint.Style.FILL_AND_STROKE);
@ -115,8 +113,6 @@ public class DownloadProgressBar extends ProgressBar {
int color = Color.WHITE;
if (DOWNLOAD_IMAGE_STYLE == mDownloadStyle) {
color = Color.BLACK;
} else if (DOWNLOAD_SLIDE_STYLE == mDownloadStyle) {
color = getResources().getColor(R.color.theme);
}
mPaint.setColor(color); // 反向颜色
}
@ -167,73 +163,48 @@ public class DownloadProgressBar extends ProgressBar {
case NONE_WITH_HINT:
case INSTALL_NORMAL:
case H5_GAME:
switch (mDownloadStyle) {
case DOWNLOAD_RECT_STYLE:
setProgressDrawable(getResources().getDrawable(R.drawable.detail_download_normal_rect_style));
mDefaultColor = Color.WHITE;
break;
case DOWNLOAD_IMAGE_STYLE:
setProgressDrawable(getResources().getDrawable(R.drawable.detail_download_normal_image_style));
mDefaultColor = Color.BLACK;
break;
default:
setProgressDrawable(getResources().getDrawable(R.drawable.game_item_btn_download_style));
mDefaultColor = Color.WHITE;
break;
if (mDownloadStyle == DOWNLOAD_IMAGE_STYLE) {
setProgressDrawable(getResources().getDrawable(R.drawable.detail_download_normal_image_style));
mDefaultColor = Color.BLACK;
} else {
setProgressDrawable(getResources().getDrawable(R.drawable.download_button_normal_style));
mDefaultColor = Color.WHITE;
}
setProgress(0);
break;
case PLUGIN:
case INSTALL_PLUGIN:
setProgressDrawable(getResources().getDrawable(mDownloadStyle == DOWNLOAD_RECT_STYLE
? R.drawable.detail_download_plugin_install_rect_style : R.drawable.game_item_btn_plugin_style));
setProgressDrawable(getResources().getDrawable(R.drawable.download_button_pluggable_style));
mDefaultColor = Color.WHITE;
setProgress(0);
break;
case NONE:
setProgressDrawable(getResources().getDrawable(mDownloadStyle == DOWNLOAD_RECT_STYLE
? R.drawable.detail_download_none_rect_style : R.drawable.news_detail_comment));
setProgressDrawable(getResources().getDrawable(R.drawable.news_detail_comment));
mDefaultColor = ContextCompat.getColor(getContext(), R.color.hint);
setProgress(0);
break;
case LAUNCH_OR_OPEN:
switch (mDownloadStyle) {
case DOWNLOAD_RECT_STYLE:
setProgressDrawable(getResources().getDrawable(R.drawable.detail_download_open_rect_style));
mDefaultColor = ContextCompat.getColor(getContext(), R.color.theme);
break;
case DOWNLOAD_IMAGE_STYLE:
setProgressDrawable(getResources().getDrawable(R.drawable.detail_download_open_image_style));
mDefaultColor = Color.WHITE;
break;
default:
setProgressDrawable(getResources().getDrawable(R.drawable.detail_download_open_style));
mDefaultColor = ContextCompat.getColor(getContext(), R.color.theme);
break;
if (mDownloadStyle == DOWNLOAD_IMAGE_STYLE) {
setProgressDrawable(getResources().getDrawable(R.drawable.detail_download_open_image_style));
mDefaultColor = Color.WHITE;
} else {
setProgressDrawable(getResources().getDrawable(R.drawable.download_button_normal_style));
mDefaultColor = Color.WHITE;
}
setProgress(0);
break;
case DOWNLOADING_NORMAL:
switch (mDownloadStyle) {
case DOWNLOAD_RECT_STYLE:
setProgressDrawable(getResources().getDrawable(R.drawable.detail_downloading_normal_rect_style));
mDefaultColor = ContextCompat.getColor(getContext(), R.color.theme);
break;
case DOWNLOAD_IMAGE_STYLE:
case DOWNLOAD_SLIDE_STYLE:
setProgressDrawable(getResources().getDrawable(R.drawable.detail_downloading_normal_image_style));
mDefaultColor = Color.WHITE;
break;
default:
setProgressDrawable(getResources().getDrawable(R.drawable.detail_downloading_normal_style));
mDefaultColor = ContextCompat.getColor(getContext(), R.color.theme);
break;
if (mDownloadStyle == DOWNLOAD_IMAGE_STYLE) {
setProgressDrawable(getResources().getDrawable(R.drawable.detail_downloading_normal_image_style));
mDefaultColor = Color.WHITE;
} else {
setProgressDrawable(getResources().getDrawable(R.drawable.detail_downloading_normal_style));
mDefaultColor = ContextCompat.getColor(getContext(), R.color.theme_font);
}
break;
case DOWNLOADING_PLUGIN:
setProgressDrawable(getResources().getDrawable(mDownloadStyle == DOWNLOAD_RECT_STYLE
? R.drawable.detail_downloading_plugin_rect_style : R.drawable.detail_downloading_plugin_style));
mDefaultColor = ContextCompat.getColor(getContext(), R.color.btn_plugin);
setProgressDrawable(getResources().getDrawable(R.drawable.detail_downloading_plugin_style));
mDefaultColor = ContextCompat.getColor(getContext(), R.color.text_00B8B8);
break;
case RESERVABLE:
setProgressDrawable(getResources().getDrawable(R.drawable.button_reserve));

View File

@ -97,6 +97,13 @@ object DrawableView {
return drawable
}
@JvmStatic
fun getCornerGradientDrawable(startColor: Int, endColor: Int, radius: Float = 999F): Drawable {
val drawable = GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, intArrayOf(startColor, endColor))
drawable.cornerRadius = DisplayUtils.dip2px(radius).toFloat()
return drawable
}
fun convertAlphaKey(percent: Int): String {
val hexString = Integer.toHexString(Math.round((255 * percent / 100).toFloat()))
return (if (hexString.length < 2) "0" else "") + hexString

View File

@ -1,6 +1,10 @@
package com.gh.common.view
import android.annotation.SuppressLint
import android.content.Context
import android.text.SpannableString
import android.text.SpannableStringBuilder
import android.text.TextUtils
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatTextView
@ -16,6 +20,7 @@ class EllipsizeTextView : AppCompatTextView {
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
@SuppressLint("DrawAllocation")
override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
super.onLayout(changed, left, top, right, bottom)
if (lineCount > maxLines) {
@ -30,7 +35,7 @@ class EllipsizeTextView : AppCompatTextView {
val cutWidth = paint.measureText(text.subSequence(secondLastLineEnd, lastLineEnd - i).toString() + "...")
if (cutWidth <= layout.width) {
charSequence = text.subSequence(0, lastLineEnd - i)
text = "$charSequence..."
text = SpannableStringBuilder().append(charSequence).append("...")
break
}
}

View File

@ -0,0 +1,592 @@
package com.gh.common.view;
import android.content.Context;
import android.graphics.Paint;
import android.os.Build;
import android.text.Layout;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.style.AlignmentSpan;
import android.text.style.ClickableSpan;
import android.util.AttributeSet;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Transformation;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatTextView;
import com.gh.gamecenter.R;
import java.lang.reflect.Field;
/**
* 参考: https://github.com/MrTrying/ExpandableText-Example
* <p>
* todo 辣鸡代码,有时间移除并在 {@link ExpandTextView} 实现该功能
*/
public class ExpandAndCloseTextView extends AppCompatTextView {
public static final String ELLIPSIS_STRING = new String(new char[]{'\u2026'});
private static final int DEFAULT_MAX_LINE = 3;
private static final String DEFAULT_OPEN_SUFFIX = " 展开";
private static final String DEFAULT_CLOSE_SUFFIX = " 收起";
volatile boolean animating = false;
boolean isClosed = false;
private int mMaxLines = DEFAULT_MAX_LINE;
/**
* TextView可展示宽度包含paddingLeft和paddingRight
*/
private int initWidth = 0;
/**
* 原始文本
*/
private CharSequence originalText;
private SpannableStringBuilder mOpenSpannableStr, mCloseSpannableStr;
private boolean hasAnimation = false;
private Animation mOpenAnim, mCloseAnim;
private int mOpenHeight, mCLoseHeight;
private boolean mExpandable;
private boolean mCloseInNewLine;
@Nullable
private SpannableString mOpenSuffixSpan, mCloseSuffixSpan;
private String mOpenSuffixStr = DEFAULT_OPEN_SUFFIX;
private String mCloseSuffixStr = DEFAULT_CLOSE_SUFFIX;
private int mOpenSuffixColor, mCloseSuffixColor;
private View.OnClickListener mOnClickListener;
private CharSequenceToSpannableHandler mCharSequenceToSpannableHandler;
public ExpandAndCloseTextView(Context context) {
super(context);
initialize();
}
public ExpandAndCloseTextView(Context context, AttributeSet attrs) {
super(context, attrs);
initialize();
}
public ExpandAndCloseTextView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initialize();
}
/**
* 初始化
*/
private void initialize() {
mOpenSuffixColor = mCloseSuffixColor = getResources().getColor( R.color.theme_font);
setMovementMethod(CustomLinkMovementMethod.getInstance());
setIncludeFontPadding(false);
updateOpenSuffixSpan();
updateCloseSuffixSpan();
}
@Override
public boolean hasOverlappingRendering() {
return false;
}
public void setOriginalText(CharSequence originalText) {
this.originalText = originalText;
mExpandable = false;
mCloseSpannableStr = new SpannableStringBuilder();
final int maxLines = mMaxLines;
SpannableStringBuilder tempText = charSequenceToSpannable(originalText);
mOpenSpannableStr = charSequenceToSpannable(originalText);
if (maxLines != -1) {
Layout layout = createStaticLayout(tempText);
mExpandable = layout.getLineCount() > maxLines;
if (mExpandable) {
//拼接展开内容
if (mCloseInNewLine) {
mOpenSpannableStr.append("\n");
}
if (mCloseSuffixSpan != null) {
mOpenSpannableStr = new SpannableStringBuilder(autoSplitText(mOpenSpannableStr.toString()));
mOpenSpannableStr.append(mCloseSuffixSpan);
}
//计算原文截取位置
int endPos = layout.getLineEnd(maxLines - 1);
if (originalText.length() <= endPos) {
mCloseSpannableStr = charSequenceToSpannable(originalText);
} else {
mCloseSpannableStr = charSequenceToSpannable(originalText.subSequence(0, endPos));
}
SpannableStringBuilder tempText2 = charSequenceToSpannable(mCloseSpannableStr).append(ELLIPSIS_STRING);
if (mOpenSuffixSpan != null) {
tempText2.append(mOpenSuffixSpan);
}
//循环判断,收起内容添加展开后缀后的内容
Layout tempLayout = createStaticLayout(tempText2);
while (tempLayout.getLineCount() > maxLines) {
int lastSpace = mCloseSpannableStr.length() - 1;
if (lastSpace == -1) {
break;
}
if (originalText.length() <= lastSpace) {
mCloseSpannableStr = charSequenceToSpannable(originalText);
} else {
mCloseSpannableStr = charSequenceToSpannable(originalText.subSequence(0, lastSpace));
}
tempText2 = charSequenceToSpannable(mCloseSpannableStr).append(ELLIPSIS_STRING);
if (mOpenSuffixSpan != null) {
tempText2.append(mOpenSuffixSpan);
}
tempLayout = createStaticLayout(tempText2);
}
int lastSpace = mCloseSpannableStr.length() - mOpenSuffixSpan.length();
if (lastSpace >= 0 && originalText.length() > lastSpace) {
CharSequence redundantChar = originalText.subSequence(lastSpace, lastSpace + mOpenSuffixSpan.length());
int offset = hasEnCharCount(redundantChar) - hasEnCharCount(mOpenSuffixSpan) + 1;
lastSpace = offset <= 0 ? lastSpace : lastSpace - offset;
mCloseSpannableStr = charSequenceToSpannable(originalText.subSequence(0, lastSpace));
}
//计算收起的文本高度
mCLoseHeight = tempLayout.getHeight() + getPaddingTop() + getPaddingBottom();
mCloseSpannableStr.append(ELLIPSIS_STRING);
mCloseSpannableStr = new SpannableStringBuilder(autoSplitText(mCloseSpannableStr.toString()));
if (mOpenSuffixSpan != null) {
mCloseSpannableStr.append(mOpenSuffixSpan);
}
}
}
isClosed = mExpandable;
if (mExpandable) {
setText(mCloseSpannableStr);
//设置监听
super.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// switchOpenClose();
// if (mOnClickListener != null) {
// mOnClickListener.onClick(v);
// }
}
});
} else {
setText(mOpenSpannableStr);
}
}
private int hasEnCharCount(CharSequence str) {
int count = 0;
if (!TextUtils.isEmpty(str)) {
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
if (c >= ' ' && c <= '~') {
count++;
}
}
}
return count;
}
private void switchOpenClose() {
if (mExpandable) {
isClosed = !isClosed;
if (isClosed) {
close();
} else {
open();
}
}
}
/**
* 设置是否有动画
*
* @param hasAnimation
*/
public void setHasAnimation(boolean hasAnimation) {
this.hasAnimation = hasAnimation;
}
/**
* 展开
*/
private void open() {
if (hasAnimation) {
Layout layout = createStaticLayout(mOpenSpannableStr);
mOpenHeight = layout.getHeight() + getPaddingTop() + getPaddingBottom();
executeOpenAnim();
} else {
ExpandAndCloseTextView.super.setMaxLines(Integer.MAX_VALUE);
setText(mOpenSpannableStr);
if (mOpenCloseCallback != null) {
mOpenCloseCallback.onOpen();
}
}
}
/**
* 收起
*/
private void close() {
if (hasAnimation) {
executeCloseAnim();
} else {
ExpandAndCloseTextView.super.setMaxLines(mMaxLines);
setText(mCloseSpannableStr);
if (mOpenCloseCallback != null) {
mOpenCloseCallback.onClose();
}
}
}
/**
* 执行展开动画
*/
private void executeOpenAnim() {
//创建展开动画
if (mOpenAnim == null) {
mOpenAnim = new ExpandCollapseAnimation(this, mCLoseHeight, mOpenHeight);
mOpenAnim.setFillAfter(true);
mOpenAnim.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
ExpandAndCloseTextView.super.setMaxLines(Integer.MAX_VALUE);
setText(mOpenSpannableStr);
}
@Override
public void onAnimationEnd(Animation animation) {
// 动画结束后textview设置展开的状态
getLayoutParams().height = mOpenHeight;
requestLayout();
animating = false;
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
}
if (animating) {
return;
}
animating = true;
clearAnimation();
// 执行动画
startAnimation(mOpenAnim);
}
/**
* 执行收起动画
*/
private void executeCloseAnim() {
//创建收起动画
if (mCloseAnim == null) {
mCloseAnim = new ExpandCollapseAnimation(this, mOpenHeight, mCLoseHeight);
mCloseAnim.setFillAfter(true);
mCloseAnim.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
animating = false;
ExpandAndCloseTextView.super.setMaxLines(mMaxLines);
setText(mCloseSpannableStr);
getLayoutParams().height = mCLoseHeight;
requestLayout();
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
}
if (animating) {
return;
}
animating = true;
clearAnimation();
// 执行动画
startAnimation(mCloseAnim);
}
/**
* @param spannable
* @return
*/
private Layout createStaticLayout(SpannableStringBuilder spannable) {
int contentWidth = initWidth - getPaddingLeft() - getPaddingRight();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
StaticLayout.Builder builder = StaticLayout.Builder.obtain(spannable, 0, spannable.length(), getPaint(), contentWidth);
builder.setAlignment(Layout.Alignment.ALIGN_NORMAL);
builder.setIncludePad(getIncludeFontPadding());
builder.setLineSpacing(getLineSpacingExtra(), getLineSpacingMultiplier());
return builder.build();
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
return new StaticLayout(spannable, getPaint(), contentWidth, Layout.Alignment.ALIGN_NORMAL,
getLineSpacingMultiplier(), getLineSpacingExtra(), getIncludeFontPadding());
} else {
return new StaticLayout(spannable, getPaint(), contentWidth, Layout.Alignment.ALIGN_NORMAL,
getFloatField("mSpacingMult", 1f), getFloatField("mSpacingAdd", 0f), getIncludeFontPadding());
}
}
private float getFloatField(String fieldName, float defaultValue) {
float value = defaultValue;
if (TextUtils.isEmpty(fieldName)) {
return value;
}
try {
// 获取该类的所有属性值域
Field[] fields = this.getClass().getDeclaredFields();
for (Field field : fields) {
if (TextUtils.equals(fieldName, field.getName())) {
value = field.getFloat(this);
break;
}
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return value;
}
/**
* @param charSequence
* @return
*/
private SpannableStringBuilder charSequenceToSpannable(@NonNull CharSequence charSequence) {
SpannableStringBuilder spannableStringBuilder = null;
if (mCharSequenceToSpannableHandler != null) {
spannableStringBuilder = mCharSequenceToSpannableHandler.charSequenceToSpannable(charSequence);
}
if (spannableStringBuilder == null) {
spannableStringBuilder = new SpannableStringBuilder(charSequence);
}
return spannableStringBuilder;
}
/**
* 初始化TextView的可展示宽度
*
* @param width
*/
public void initWidth(int width) {
initWidth = width;
}
@Override
public void setMaxLines(int maxLines) {
this.mMaxLines = maxLines;
super.setMaxLines(maxLines);
}
/**
* 设置展开后缀text
*
* @param openSuffix
*/
public void setOpenSuffix(String openSuffix) {
mOpenSuffixStr = openSuffix;
updateOpenSuffixSpan();
}
/**
* 设置展开后缀文本颜色
*
* @param openSuffixColor
*/
public void setOpenSuffixColor(@ColorInt int openSuffixColor) {
mOpenSuffixColor = openSuffixColor;
updateOpenSuffixSpan();
}
/**
* 设置收起后缀text
*
* @param closeSuffix
*/
public void setCloseSuffix(String closeSuffix) {
mCloseSuffixStr = closeSuffix;
updateCloseSuffixSpan();
}
/**
* 设置收起后缀文本颜色
*
* @param closeSuffixColor
*/
public void setCloseSuffixColor(@ColorInt int closeSuffixColor) {
mCloseSuffixColor = closeSuffixColor;
updateCloseSuffixSpan();
}
/**
* 收起后缀是否另起一行
*
* @param closeInNewLine
*/
public void setCloseInNewLine(boolean closeInNewLine) {
mCloseInNewLine = closeInNewLine;
updateCloseSuffixSpan();
}
/**
* 更新展开后缀Spannable
*/
private void updateOpenSuffixSpan() {
if (TextUtils.isEmpty(mOpenSuffixStr)) {
mOpenSuffixSpan = null;
return;
}
mOpenSuffixSpan = new SpannableString(mOpenSuffixStr);
mOpenSuffixSpan.setSpan(new ClickableSpan() {
@Override
public void onClick(@NonNull View widget) {
switchOpenClose();
}
@Override
public void updateDrawState(@NonNull TextPaint ds) {
super.updateDrawState(ds);
ds.setColor(mOpenSuffixColor);
ds.setUnderlineText(false);
}
}, 0, mOpenSuffixStr.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
}
/**
* 更新收起后缀Spannable
*/
private void updateCloseSuffixSpan() {
if (TextUtils.isEmpty(mCloseSuffixStr)) {
mCloseSuffixSpan = null;
return;
}
mCloseSuffixSpan = new SpannableString(mCloseSuffixStr);
if (mCloseInNewLine) {
AlignmentSpan alignmentSpan = new AlignmentSpan.Standard(Layout.Alignment.ALIGN_OPPOSITE);
mCloseSuffixSpan.setSpan(alignmentSpan, 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
mCloseSuffixSpan.setSpan(new ClickableSpan() {
@Override
public void onClick(@NonNull View widget) {
switchOpenClose();
}
@Override
public void updateDrawState(@NonNull TextPaint ds) {
super.updateDrawState(ds);
ds.setColor(mCloseSuffixColor);
ds.setUnderlineText(false);
}
}, 1, mCloseSuffixStr.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
private String autoSplitText(final String rawText) {
final Paint tvPaint = getPaint(); //paint包含字体等信息
final float tvWidth = initWidth - getPaddingLeft() - getPaddingRight(); //控件可用宽度
//将原始文本按行拆分
String[] rawTextLines = rawText.replaceAll("\r", "").split("\n");
StringBuilder sbNewText = new StringBuilder();
for (String rawTextLine : rawTextLines) {
if (tvPaint.measureText(rawTextLine) <= tvWidth) {
//如果整行宽度在控件可用宽度之内,就不处理了
sbNewText.append(rawTextLine);
} else {
//如果整行宽度超过控件可用宽度,则按字符测量,在超过可用宽度的前一个字符处手动换行
float lineWidth = 0;
for (int cnt = 0; cnt != rawTextLine.length(); ++cnt) {
char ch = rawTextLine.charAt(cnt);
lineWidth += tvPaint.measureText(String.valueOf(ch));
if (lineWidth <= tvWidth) {
sbNewText.append(ch);
} else {
sbNewText.append("\n");
lineWidth = 0;
--cnt;
}
}
}
sbNewText.append("\n");
}
//把结尾多余的\n去掉
if (!rawText.endsWith("\n")) {
sbNewText.deleteCharAt(sbNewText.length() - 1);
}
return sbNewText.toString();
}
@Override
public void setOnClickListener(View.OnClickListener onClickListener) {
mOnClickListener = onClickListener;
}
public OpenAndCloseCallback mOpenCloseCallback;
public void setOpenAndCloseCallback(OpenAndCloseCallback callback) {
this.mOpenCloseCallback = callback;
}
public interface OpenAndCloseCallback {
void onOpen();
void onClose();
}
/**
* 设置文本内容处理
*
* @param handler
*/
public void setCharSequenceToSpannableHandler(CharSequenceToSpannableHandler handler) {
mCharSequenceToSpannableHandler = handler;
}
public interface CharSequenceToSpannableHandler {
@NonNull
SpannableStringBuilder charSequenceToSpannable(CharSequence charSequence);
}
class ExpandCollapseAnimation extends Animation {
private final View mTargetView;//动画执行view
private final int mStartHeight;//动画执行的开始高度
private final int mEndHeight;//动画结束后的高度
ExpandCollapseAnimation(View target, int startHeight, int endHeight) {
mTargetView = target;
mStartHeight = startHeight;
mEndHeight = endHeight;
setDuration(400);
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
mTargetView.setScrollY(0);
//计算出每次应该显示的高度,改变执行view的高度实现动画
mTargetView.getLayoutParams().height = (int) ((mEndHeight - mStartHeight) * interpolatedTime + mStartHeight);
mTargetView.requestLayout();
}
}
}

View File

@ -0,0 +1,181 @@
package com.gh.common.view;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Build;
import android.text.Layout;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.style.ClickableSpan;
import android.util.AttributeSet;
import android.view.View;
import com.gh.common.util.DisplayUtils;
import com.gh.gamecenter.R;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.core.content.ContextCompat;
public class ExpandTextView extends AppCompatTextView {
private CharSequence mSnapshotText;
private String mEndText = "...";
private String mExpandText = mEndText + "全文";
private boolean mUseGradientAlphaEndText = false;
private int mMaxLines = 3; // 由于sdk版本限制(getMaxLines) 这里设置默认值
private static int DEFAULT_ADDITIONAL_END_TEXT_COUNT = 2;
private boolean mInitLayout = false;
private boolean mIsExpanded = false; // 位于 recyclerView 时需要自行在外层管理是否已展开
private ExpandCallback mExpandCallback;
public ExpandTextView(Context context) {
super(context);
}
public ExpandTextView(Context context, AttributeSet attrs) {
super(context, attrs);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
mMaxLines = getMaxLines();
}
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.ExpandTextView);
mUseGradientAlphaEndText = ta.getBoolean(R.styleable.ExpandTextView_useGradientAlphaEndText, false);
mEndText = ta.getString(R.styleable.ExpandTextView_endText) == null ? mEndText : ta.getString(R.styleable.ExpandTextView_endText);
mExpandText = ta.getString(R.styleable.ExpandTextView_expandText) == null ? mExpandText : ta.getString(R.styleable.ExpandTextView_expandText);
ta.recycle();
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
if (mInitLayout && !mIsExpanded && getLineCount() > mMaxLines) {
mSnapshotText = getText();
mInitLayout = false;
showExpandButton();
}
}
public void setExpendText(String text) {
this.mExpandText = text;
}
public void setExpandCallback(ExpandCallback callback) {
this.mExpandCallback = callback;
}
@Override
public void setText(CharSequence text, BufferType type) {
mInitLayout = true;
super.setText(text, type);
}
private void showExpandButton() {
String finalEndText = "";
Layout layout = getLayout();
int start = layout.getLineStart(0);
int lastLineEnd = layout.getLineEnd(mMaxLines - 1);
int lastLineStart = layout.getLineStart(mMaxLines - 1);
float lastLineRight = layout.getLineRight(mMaxLines - 1);
int viewWidth = getWidth() - getPaddingRight() - getPaddingLeft();
int additionalEndTextCount = 0;
TextPaint paint = getPaint();
float expandTextWidth;
if (mUseGradientAlphaEndText) {
additionalEndTextCount = DEFAULT_ADDITIONAL_END_TEXT_COUNT;
// 如果不加多个括号的话有可能算不对,惊了,明明是同样的 paint 同样的文字,长度却会略有不同
expandTextWidth = paint.measureText(mEndText + mExpandText + " ");
} else {
expandTextWidth = paint.measureText(mExpandText);
}
CharSequence content = mSnapshotText.subSequence(start, lastLineEnd);
if (viewWidth - lastLineRight > expandTextWidth) {
if (mUseGradientAlphaEndText) {
finalEndText = content.toString().substring(content.length() - additionalEndTextCount, content.length()) + mEndText;
finalEndText = finalEndText.replace("\n", "");
content = content.subSequence(0, content.length() - additionalEndTextCount) + finalEndText + mExpandText;
} else {
content = content.toString().trim() + mExpandText;
}
} else {
CharSequence lastText = mSnapshotText.subSequence(lastLineStart, lastLineEnd);
for (int i = lastText.length() - 1; i > 0; i--) {
CharSequence sequence = lastText.subSequence(0, i);
float w = paint.measureText(sequence.toString());
if (viewWidth - w - DisplayUtils.dip2px(5) > expandTextWidth) {
if (mUseGradientAlphaEndText) {
finalEndText = lastText.subSequence(i - additionalEndTextCount, i) + mEndText;
finalEndText = finalEndText.replace("\n", "");
content = mSnapshotText.subSequence(start, lastLineStart + i - additionalEndTextCount) + finalEndText + mExpandText;
} else {
content = mSnapshotText.subSequence(start, lastLineStart + i) + mExpandText;
}
break;
}
}
}
SpannableStringBuilder msp = new SpannableStringBuilder(mSnapshotText);
int length = msp.length();
int startPosition = 0;
startPosition = content.length() - finalEndText.length() - mExpandText.length();
startPosition = Math.max(startPosition, 0);
// 避免越界
if (startPosition >= length) return;
msp.replace(startPosition, length, finalEndText + mExpandText);
msp.setSpan(new ClickableSpan() {
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
ds.setColor(ContextCompat.getColor(getContext(), R.color.theme_font));
ds.setUnderlineText(false);
}
@Override
public void onClick(View widget) {
mIsExpanded = true;
setMaxLines(Integer.MAX_VALUE);
setText(mSnapshotText);
if (mExpandCallback != null) {
mExpandCallback.onExpand();
}
}
}, startPosition + mEndText.length(), msp.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
msp.setSpan(new GradientAlphaTextSpan(), startPosition, startPosition + finalEndText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
setText(msp);
setMovementMethod(CustomLinkMovementMethod.getInstance());
}
/**
* 此方法仅更改标记,不做实际展开的操作
*/
public void setIsExpanded(boolean isExpanded) {
mIsExpanded = isExpanded;
}
public void setExpandMaxLines(int maxLines) {
mMaxLines = maxLines;
setMaxLines(maxLines);
}
public interface ExpandCallback {
void onExpand();
}
}

View File

@ -1,134 +0,0 @@
package com.gh.common.view;
import android.content.Context;
import android.graphics.Color;
import android.os.Build;
import android.text.Layout;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.style.BackgroundColorSpan;
import android.text.style.ClickableSpan;
import android.util.AttributeSet;
import android.view.View;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.core.content.ContextCompat;
import com.gh.common.util.DisplayUtils;
import com.gh.gamecenter.R;
public class ExpendTextView extends AppCompatTextView {
private CharSequence mSnapshotText;
private String mExpendText = "...全文";
private int mMaxLines = 3; // 由于sdk版本限制(getMaxLines) 这里设置默认值
private boolean mInitLayout = false;
private boolean mOpenLayout = false;
private ExpandCallback mExpandCallback;
public ExpendTextView(Context context) {
super(context);
}
public ExpendTextView(Context context, AttributeSet attrs) {
super(context, attrs);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
mMaxLines = getMaxLines();
}
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
if (mInitLayout && !mOpenLayout && getLineCount() > mMaxLines) {
mSnapshotText = getText();
mInitLayout = false;
showExpendButton();
}
}
public void setExpendText(String text) {
this.mExpendText = text;
}
public void setExpandCallback(ExpandCallback callback) {
this.mExpandCallback = callback;
}
@Override
public void setText(CharSequence text, BufferType type) {
mInitLayout = true;
super.setText(text, type);
}
private void showExpendButton() {
Layout layout = getLayout();
int start = layout.getLineStart(0);
int lastLineEnd = layout.getLineEnd(mMaxLines - 1);
int lastLineStart = layout.getLineStart(mMaxLines - 1);
float lastLineRight = layout.getLineRight(mMaxLines - 1);
int viewWidth = getWidth() - getPaddingRight() - getPaddingLeft();
TextPaint paint = getPaint();
float expendTextWidth = paint.measureText(mExpendText);
CharSequence content = mSnapshotText.subSequence(start, lastLineEnd);
if (viewWidth - lastLineRight > expendTextWidth) {
content = content.toString().trim() + mExpendText;
} else {
CharSequence lastText = mSnapshotText.subSequence(lastLineStart, lastLineEnd);
for (int i = lastText.length() - 1; i > 0; i--) {
CharSequence sequence = lastText.subSequence(0, i);
float w = paint.measureText(sequence.toString());
if (viewWidth - w - DisplayUtils.dip2px(5) > expendTextWidth) {
content = mSnapshotText.subSequence(start, lastLineStart + i) + mExpendText;
break;
}
}
}
SpannableStringBuilder msp = new SpannableStringBuilder(mSnapshotText);
int length = msp.length();
int startPosition = content.length() - mExpendText.length();
startPosition = startPosition < 0 ? 0 : startPosition;
msp.replace(startPosition, length, mExpendText);
msp.setSpan(new ClickableSpan() {
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
ds.setColor(ContextCompat.getColor(getContext(), R.color.theme));
ds.setUnderlineText(false);
}
@Override
public void onClick(View widget) {
mOpenLayout = true;
setMaxLines(Integer.MAX_VALUE);
setText(mSnapshotText);
if (mExpandCallback != null) {
mExpandCallback.onExpand();
}
}
}, startPosition + 3, msp.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
msp.setSpan(new BackgroundColorSpan(Color.WHITE), startPosition, msp.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
setText(msp);
setMovementMethod(CustomLinkMovementMethod.getInstance());
}
public void setExpendMaxLines(int maxLines) {
mMaxLines = maxLines;
setMaxLines(maxLines);
}
public interface ExpandCallback {
void onExpand();
}
}

View File

@ -0,0 +1,124 @@
package com.gh.common.view
import android.content.Context
import android.graphics.Color
import android.graphics.Paint
import android.graphics.drawable.GradientDrawable
import android.util.AttributeSet
import android.view.Gravity
import android.view.View
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.gh.common.util.DisplayUtils
import com.gh.gamecenter.R
import com.gh.gamecenter.entity.TagStyleEntity
import kotlin.math.ceil
/**
* 标签最多显示一行,显示的个数由行宽决定
*/
class FlexLinearLayout @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : LinearLayout(context, attrs) {
private var mTotalCount = 0
private var mTags = ArrayList<TagStyleEntity>()
private var mItemHeight = DisplayUtils.dip2px(20F)
private var mPadding = DisplayUtils.dip2px(5F)
private var mMargin = DisplayUtils.dip2px(4F)
private var mTextSize = 10F
private var mLastItemWidth = DisplayUtils.dip2px(18F)//最后更多按钮宽度
private var mTotalWidth = 0
var onClickListener: OnItemClickListener? = null
init {
gravity = Gravity.CENTER_VERTICAL
}
fun setTags(tags: ArrayList<TagStyleEntity>) {
mTags.clear()
mTotalCount = tags.size
mTotalWidth = measuredWidth
val paint = Paint()
paint.textSize = DisplayUtils.sp2px(context, mTextSize).toFloat()
var currentWidth = mLastItemWidth.toFloat()
tags.forEach {
val strWidth = getTextWidth(paint, it.name)
if (currentWidth + strWidth + mPadding * 2 + mMargin <= mTotalWidth) {
currentWidth += strWidth + mPadding * 2 + mMargin
mTags.add(it)
}
}
if (mTags.isNotEmpty()) {
addTags()
}
}
private fun getTextWidth(paint: Paint, str: String?): Int {
var width = 0
if (str != null && str.isNotEmpty()) {
val len = str.length
val widths = FloatArray(len)
paint.getTextWidths(str, widths)
for (i in 0 until len) {
width += ceil(widths[i].toDouble()).toInt()
}
}
return width
}
private fun addTags() {
removeAllViews()
mTags.forEach {
addView(createView(it))
}
if (mTotalCount != mTags.size) {
val imageView = ImageView(context).apply {
val params = LayoutParams(mLastItemWidth, mItemHeight)
layoutParams = params
setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_game_detail_label_more))
background = createBackgroundDrawable()
scaleType=ImageView.ScaleType.CENTER
}
imageView.setOnClickListener {
onClickListener?.onMoreClickListener()
}
addView(imageView)
}
}
private fun createView(tag: TagStyleEntity): View {
return TextView(context).apply {
text = tag.name
includeFontPadding = false
textSize = mTextSize
gravity = Gravity.CENTER
setTextColor(Color.parseColor("#333333"))
val params = LayoutParams(LayoutParams.WRAP_CONTENT, mItemHeight)
params.setMargins(0, 0, mMargin, 0)
setPadding(mPadding, 0, mPadding, 0)
layoutParams = params
val gradientDrawable = createBackgroundDrawable()
background = gradientDrawable
setOnClickListener {
onClickListener?.onItemClickListener(tag)
}
}
}
private fun createBackgroundDrawable(): GradientDrawable {
val gradientDrawable = GradientDrawable()
gradientDrawable.setColor(Color.TRANSPARENT)
gradientDrawable.setStroke(DisplayUtils.dip2px(context, 1f), Color.parseColor("#C2C6CC"))
gradientDrawable.cornerRadius = DisplayUtils.dip2px(2f).toFloat()
return gradientDrawable
}
interface OnItemClickListener {
fun onMoreClickListener()
fun onItemClickListener(tag: TagStyleEntity)
}
}

View File

@ -0,0 +1,31 @@
package com.gh.common.view
import android.graphics.Canvas
import android.graphics.LinearGradient
import android.graphics.Paint
import android.graphics.Shader
import android.text.style.ReplacementSpan
import androidx.core.graphics.ColorUtils
class GradientAlphaTextSpan() : ReplacementSpan() {
override fun getSize(paint: Paint, text: CharSequence?, start: Int, end: Int, fm: Paint.FontMetricsInt?): Int {
return paint.measureText(text, start, end).toInt()
}
override fun draw(canvas: Canvas, text: CharSequence?, start: Int, end: Int, x: Float, top: Int, y: Int, bottom: Int, paint: Paint) {
val originalColor = paint.color
val originalColorWithAlphaChanged = ColorUtils.setAlphaComponent(paint.color, 1)
val textWidth = paint.measureText(text, start, end).toInt()
val mShader = LinearGradient(x, 0F, x + textWidth - 10, 0F,
originalColor, originalColorWithAlphaChanged, Shader.TileMode.CLAMP)
paint.shader = mShader
canvas.drawText(text, start, end, x, y.toFloat(), paint)
paint.shader = null
}
}

View File

@ -0,0 +1,68 @@
package com.gh.common.view
import android.graphics.*
import android.text.style.ReplacementSpan
import androidx.annotation.Dimension
import com.gh.common.util.DisplayUtils
import com.halo.assistant.HaloApp
class GradientRoundBackgroundColorSpan(private val startColor: String,
private val endColor: String,
private val textColor: String,
@Dimension(unit = Dimension.SP)
private val textSize: Int = 0) : ReplacementSpan() {
override fun getSize(paint: Paint, text: CharSequence, start: Int, end: Int, fm: Paint.FontMetricsInt?): Int {
return paint.measureText(text, start, end).toInt()
}
override fun draw(canvas: Canvas, text: CharSequence, start: Int, end: Int, x: Float, top: Int, y: Int, bottom: Int, paint: Paint) {
val originalColor = paint.color
val originalTextSize = paint.textSize
paint.style = Paint.Style.FILL
val fontMetrics = paint.fontMetrics
// 原文字宽度
val originalTextWidth = paint.measureText(text, start, end).toInt()
// 当目标字体大小与原字体大小不一样时,需要先用目标字体大小测量字体宽度
if (textSize != 0) {
paint.textSize = DisplayUtils.sp2px(HaloApp.getInstance().application, textSize.toFloat()).toFloat()
}
// 目标文字宽度
val textWidth = paint.measureText(text, start, end).toInt()
// 用原字体大小画椭圆
paint.textSize = originalTextSize
//添加渐变Shader
val mShader = LinearGradient(0F, top.toFloat(), x + originalTextWidth, top + fontMetrics.bottom - fontMetrics.top,
Color.parseColor(startColor), Color.parseColor(endColor), Shader.TileMode.CLAMP)
paint.shader = mShader
canvas.drawRoundRect(RectF(
x,
top.toFloat(),
x + originalTextWidth,
top + fontMetrics.bottom - fontMetrics.top),
DisplayUtils.dip2px(HaloApp.getInstance().application, 5f).toFloat(),
DisplayUtils.dip2px(HaloApp.getInstance().application, 5f).toFloat(),
paint)
//重置paint
paint.color = Color.parseColor(this.textColor)
//移除渐变Shader否则绘制的文字也是渐变色
paint.shader = null
paint.style = Paint.Style.FILL
// 用目标字体大小画字
if (textSize != 0) {
paint.textSize = DisplayUtils.sp2px(HaloApp.getInstance().application, textSize.toFloat()).toFloat()
}
val offsetX = (originalTextWidth - textWidth) / 2
canvas.drawText(text, start, end, x + offsetX, y.toFloat(), paint)
paint.color = originalColor
}
}

View File

@ -21,7 +21,7 @@ class HighlightableTextView @JvmOverloads constructor(context: Context, attrs: A
}
override fun setText(text: CharSequence?, type: BufferType?) {
super.setText(TextHelper.getHighlightedSpannableStringThatIsWrappedInsideWrapper(context, text.toString(), "###", R.color.theme, object : SimpleCallback<String> {
super.setText(TextHelper.getHighlightedSpannableStringThatIsWrappedInsideWrapper(context, text.toString(), "###", R.color.theme_font, object : SimpleCallback<String> {
override fun onCallback(arg: String) {
val application = HaloApp.getInstance().application
val cmb = application.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager

View File

@ -0,0 +1,44 @@
package com.gh.common.view
import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import android.view.ViewConfiguration
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import kotlin.math.abs
class InterceptRecyclerView : RecyclerView {
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
private var startX = 0F
private var startY = 0F
override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
if (ev.action == MotionEvent.ACTION_DOWN) {
startX = ev.x
startY = ev.y
} else if (ev.action == MotionEvent.ACTION_MOVE) {
val dx = ev.x - startX
val dy = ev.y - startY
val scaledTouchSlop = ViewConfiguration.get(context).scaledTouchSlop
if (layoutManager != null && layoutManager is LinearLayoutManager) {
val orientation = (layoutManager as LinearLayoutManager).orientation
if (orientation == HORIZONTAL) {
if (abs(dx) > scaledTouchSlop && abs(dx) > abs(dy)) {
parent.requestDisallowInterceptTouchEvent(true)
} else if (abs(dy) > scaledTouchSlop && abs(dy) > abs(dx)) {
parent.requestDisallowInterceptTouchEvent(false)
}
}
}
}
return super.dispatchTouchEvent(ev)
}
}

View File

@ -0,0 +1,114 @@
package com.gh.common.view
import android.animation.*
import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import android.view.View
import android.view.animation.LinearInterpolator
import android.widget.ImageView
import android.widget.RelativeLayout
import androidx.core.content.ContextCompat
import com.gh.gamecenter.R
import java.util.*
class LikeView : RelativeLayout {
private val num = floatArrayOf(-35f, -25f, -15f, 0f, 15f, 25f, 35f)
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
fun runLikeAnimation(event: MotionEvent) {
val iv = ImageView(context)
val lp = LayoutParams(168, 150)
val widthPixels = context.resources.displayMetrics.widthPixels
val leftMargin = if (event.rawX.toInt() + 84 > widthPixels) {
widthPixels - 168
} else {
event.rawX.toInt() - 84
}
lp.leftMargin = leftMargin
lp.topMargin = event.rawY.toInt() - 220
iv.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_double_click_like))
iv.layoutParams = lp
addView(iv)
val animatorSet = AnimatorSet()
animatorSet.play(
scaleAni(iv, "scaleX", 1f, 2f, 50, 0))
.with(scaleAni(iv, "scaleY", 1f, 2f, 50, 0))
//缩放动画X轴2倍缩小至0.9倍
.with(scaleAni(iv, "scaleX", 2f, 0.9f, 100, 50))
//缩放动画Y轴2倍缩放至0.9倍
.with(scaleAni(iv, "scaleY", 2f, 0.9f, 100, 50))
//旋转动画,随机旋转角
.with(rotation(iv, 0, 0, num[Random().nextInt(6)]))
//渐变透明动画透明度从0-1
.with(alphaAni(iv, 0F, 1F, 100, 0))
//缩放动画X轴0.9倍缩小至
.with(scaleAni(iv, "scaleX", 0.9f, 1F, 50, 150))
//缩放动画Y轴0.9倍缩放至
.with(scaleAni(iv, "scaleY", 0.9f, 1F, 50, 150))
//位移动画Y轴从0上移至600
.with(translationY(iv, 0F, -800F, 1200, 400))
//透明动画从1-0
.with(alphaAni(iv, 1F, 0F, 500, 400))
//缩放动画X轴1至3倍
.with(scaleAni(iv, "scaleX", 1F, 3f, 800, 400))
//缩放动画Y轴1至3倍
.with(scaleAni(iv, "scaleY", 1F, 3f, 800, 400))
animatorSet.start()
animatorSet.addListener(object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator?) {
super.onAnimationEnd(animation)
removeViewInLayout(iv)
}
})
}
private fun scaleAni(view: View, propertyName: String, from: Float, to: Float, time: Long, delayTime: Long): ObjectAnimator {
val ani: ObjectAnimator = ObjectAnimator.ofFloat(view, propertyName, from, to)
ani.interpolator = LinearInterpolator()
ani.startDelay = delayTime
ani.duration = time
return ani
}
private fun translationX(view: View, from: Float, to: Float, time: Long, delayTime: Long): ObjectAnimator {
val ani: ObjectAnimator = ObjectAnimator.ofFloat(view, "translationX", from, to)
ani.interpolator = LinearInterpolator()
ani.startDelay = delayTime
ani.duration = time
return ani
}
private fun translationY(view: View, from: Float, to: Float, time: Long, delayTime: Long): ObjectAnimator {
val ani: ObjectAnimator = ObjectAnimator.ofFloat(view, "translationY", from, to)
ani.interpolator = LinearInterpolator()
ani.startDelay = delayTime
ani.duration = time
return ani
}
private fun alphaAni(view: View, from: Float, to: Float, time: Long, delayTime: Long): ObjectAnimator {
val ani = ObjectAnimator.ofFloat(view, "alpha", from, to)
ani.interpolator = LinearInterpolator()
ani.startDelay = delayTime
ani.duration = time
return ani
}
private fun rotation(view: View, time: Long, delayTime: Long, vararg values: Float): ObjectAnimator {
val ani = ObjectAnimator.ofFloat(view, "rotation", *values)
ani.duration = time
ani.startDelay = delayTime
ani.interpolator = TimeInterpolator { input -> input }
return ani
}
}

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