Compare commits

..

165 Commits
v3.1 ... v3.2.2

Author SHA1 Message Date
7e350cac41 下载劫持接入MTA,优化下载(有效防止解析包错误) 2018-05-15 19:01:17 +08:00
6e9edabd94 修复登录掉线问题,对接错误统计需求(MTA)光环助手V3.2.2需求汇总 2018-05-11 17:31:43 +08:00
665fbb0f6c PATCH_VERSION_NAME 升级为 3.2.1 2018-05-03 17:39:26 +08:00
fd0921870d 修复3.2的一些bug 2018-05-03 10:34:36 +08:00
0cc78b1055 3.2 tinker base 2018-04-28 14:52:09 +08:00
6dc3b5c382 修复专题分页异常问题 2018-04-27 06:27:29 +08:00
9ac373bf0e 光环助手V3.2 RELEASE(20180427-0410)测试问题汇总 2018-04-27 06:08:15 +08:00
02f96f9083 Merge remote-tracking branch 'origin/dev' into dev 2018-04-27 05:59:14 +08:00
c74997f306 修复切换选择游戏,社区专题会显示到原来的社区再更新为新社区的问题 2018-04-27 05:59:05 +08:00
58d4f22a6b 光环助手V3.2 RELEASE(20180427-0138)测试问题汇总 2018-04-27 03:58:24 +08:00
c5cf1c168e 答案被删除时隐藏收藏和更多按钮 2018-04-27 02:26:24 +08:00
36638a63ca ... 2018-04-27 02:04:06 +08:00
07de30ceea 统一投票样式,选择游戏入口显示小红点 2018-04-27 01:27:13 +08:00
35e15263b0 光环助手V3.2 RELEASE(20180426-2223)测试问题汇总(除2.8.9.10其他完成) 2018-04-27 01:26:03 +08:00
420867378b room数据库版本改为4 2018-04-26 22:41:52 +08:00
0cc183df22 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2018-04-26 21:57:56 +08:00
eb557ca9bd 光环助手V3.2 RELEASE(20180426-1800)测试问题汇总(1.2.9.10) 2018-04-26 21:57:44 +08:00
72b39a5982 回答详情回答过快增加 Toast 提醒,移动网络点击所有缩略图后隐藏 [显示大图] 按钮 2018-04-26 21:36:32 +08:00
b96ee6bc19 修复第二次启动光环助手,点击“问答”出现的引导图,点击“我知道了”前面的“我知道”没有反应 2018-04-26 18:06:47 +08:00
684fa318ec 接口limit改为page_size,修复游戏列表下载与详情下载安装判断不一致问题,安装游戏删除addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) 2018-04-26 17:09:16 +08:00
29faea14c6 光环助手V3.2 RELEASE(20180424-1820)测试问题汇总(完成部分) 2018-04-25 19:26:47 +08:00
c25f7a13db 游戏搜索以及社区搜索UI微调 2018-04-24 20:10:08 +08:00
715edd77e0 TimestampUtils 修改 2018-04-24 18:31:00 +08:00
25cc825ea6 光环助手V3.2 RELEASE(20180422-1800)测试问题汇总 2018-04-24 17:52:53 +08:00
f7e7819b84 修复UserManager equals判断问题 2018-04-23 17:27:41 +08:00
d305315d7e 光环助手V3.2 RELEASE(20180419-1810)测试问题汇总(完成) 2018-04-23 16:50:36 +08:00
965d756cba 光环助手V3.2 RELEASE(20180419-1810)UI问题汇总 2018-04-23 16:13:05 +08:00
29a19b5df6 光环助手V3.2 RELEASE(20180419-1810)测试问题汇总(运营汇总) 2018-04-23 11:09:00 +08:00
cb2cdd98e8 光环助手V3.2 RELEASE(20180419-1810)测试问题汇总(三.9和评论未完成) 2018-04-22 18:52:08 +08:00
da79a972f7 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2018-04-20 17:39:14 +08:00
3c13eff2cf Merge remote-tracking branch 'origin/dev' into dev 2018-04-19 18:36:34 +08:00
7050070310 修复评论弹窗没登录也能提交的问题问题 2018-04-19 18:36:14 +08:00
1dca4e8c0a 光环助手V3.2 RELEASE(20180418-1420)测试问题汇总(完成) 2018-04-19 18:00:23 +08:00
1163e04aaf Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2018-04-19 16:49:55 +08:00
73bc256ce6 光环助手V3.2 RELEASE(20180418-1420)测试问题汇总(部分完成) 2018-04-19 16:49:51 +08:00
df78db5686 UI微调 2018-04-19 16:42:08 +08:00
b64ceaf5d4 微调精选推荐的代码结构 2018-04-19 15:38:43 +08:00
eb9b4cd132 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2018-04-19 11:35:18 +08:00
b9eec94644 更改 AnswerEntity db key 2018-04-19 11:35:07 +08:00
4e388ec3d7 问答精选数据流修改 2018-04-19 11:13:23 +08:00
a5069789b3 问题/答案/评论 提交时增加限制(5秒内只能提交1次) 2018-04-19 10:59:41 +08:00
3797fd85ad 回答列表补充评论数 2018-04-19 10:43:30 +08:00
f0b0423872 修复新增回答后问题详情页面出现两条相同数据的问题 2018-04-19 09:55:30 +08:00
e5daf1d29f 修复问题详情和回答详情的部分问题 http://gitlab.ghzhushou.com/pm/halo-app-issues/issues/210 2018-04-18 21:19:50 +08:00
2b9f40a976 修复文章列表为空导致的闪退问题 2018-04-18 16:13:01 +08:00
05fbf28d2b 部分接口修改 2018-04-18 14:18:51 +08:00
e54d06def9 签到逻辑修改(保存本地数据库) 2018-04-18 10:12:37 +08:00
840eff3cc4 光环助手V3.2 DEV(20180415-1700)测试问题汇总
http://gitlab.ghzhushou.com/pm/halo-app-issues/issues/207
2018-04-17 15:16:25 +08:00
a0737d0010 fix issues http://gitlab.ghzhushou.com/pm/halo-app-issues/issues/203 2018-04-16 17:57:59 +08:00
9d93df888e 修复已知bug 2018-04-16 10:15:23 +08:00
90fbb235c3 光环助手V3.2 DEV(20180413-2100)测试问题汇总
http://gitlab.ghzhushou.com/pm/halo-app-issues/issues/206
2018-04-15 16:37:44 +08:00
9be884c672 间距调整 2018-04-13 14:36:12 +08:00
550a4cdecf Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2018-04-13 14:13:53 +08:00
0d883b76fe 光环助手V3.2 DEV(20180412-1000)测试问题汇总(完成部分) 2018-04-13 14:13:41 +08:00
e3c3101cab Merge remote-tracking branch 'origin/dev' into dev 2018-04-13 11:26:51 +08:00
cce289253d 修复回答详情以及评论列表的一些问题 http://gitlab.ghzhushou.com/pm/issues-Inbox/issues/345 2018-04-13 11:26:32 +08:00
2102dd729c 光环助手V3.2数据统计需求(MTA)(完成) 2018-04-12 18:37:00 +08:00
347a83cf0f 统一DataUtils 2018-04-12 17:08:50 +08:00
1f8d573fad Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2018-04-12 16:53:10 +08:00
72b6c2a176 Menu全部初始化放在onActivityCreated,页面间距修改 2018-04-12 16:53:01 +08:00
743e3660e9 微调回答评论列表UI 2018-04-12 15:27:22 +08:00
2ab6a49bec Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2018-04-12 14:43:41 +08:00
1e31e13384 修复已知BUG OkHttpNetworkInterceptor去除接口404处理 2018-04-12 14:42:15 +08:00
f77fbe680f 1、回答评论列表答案作者显示作者
2、修复回答详情页查看大图滑动后返回依旧不是大图的问题
2018-04-12 14:19:12 +08:00
53c55a3f36 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2018-04-11 21:32:18 +08:00
18d11e3421 删除无用图标 2018-04-11 21:32:10 +08:00
bf42834051 光环助手V3.2 DEV(20180410-1140)测试问题汇总(部分未完成)
光环助手V3.2 DEV(20180410-1140)文案优化(部分未完成)
2018-04-11 21:31:40 +08:00
ee6337276c 回答详情也以及回答列表问题修复 2018-04-11 19:01:06 +08:00
cdc001b43e Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2018-04-11 11:19:31 +08:00
f3eeaddec8 光环助手V3.2数据统计需求(登录,问答精选刷新) 2018-04-11 10:45:17 +08:00
b8e1e4e21c 首页-下载,下载列表右边button未与上方全部开始对齐,列表下载条占位往左扣减5dp 2018-04-10 21:07:57 +08:00
64f2c83894 为所有页面添加Activity(为了接入MTA页面访问统计) 2018-04-10 20:50:19 +08:00
f9211e17a1 修改问答评论页UI 2018-04-10 20:09:36 +08:00
f0c952848a 修复部分已知bug 2018-04-10 16:15:07 +08:00
c736068d0e 光环助手V3.2其它优化汇总 2018-04-10 11:34:39 +08:00
e0c9d43f02 重新整理签到 2018-04-09 10:25:12 +08:00
0a4b657a85 修复由于xml id问题导致的打包失败 2018-04-08 18:08:56 +08:00
0121d9601c 游戏求版本ListFragment改造 2018-04-07 17:34:10 +08:00
371a450f5a 首页游戏执行分页操作 2018-04-07 15:38:43 +08:00
2796145d26 我的光环-签到功能优化(完成) 2018-04-07 14:53:28 +08:00
5a662ac72b 升级 OkHttp 依赖来解决 HTTP/2 连接问题 (http://gitlab.ghzhushou.com/pm/halo-app-issues/issues/193) 2018-04-04 16:24:35 +08:00
6cd62cbd0a 回答详情页滑动时显示问题标题 2018-04-04 11:07:42 +08:00
299fa1a107 修复社区相关举报跳转至反馈页面没有提示选项问题 2018-04-02 18:30:43 +08:00
c39ba2e17e issues测试以及整理 2018-04-02 17:51:29 +08:00
414b5b3861 列表点击逻辑修改,助手版本升为3.2 2018-04-02 16:16:49 +08:00
6f89f4acce Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2018-04-02 14:51:18 +08:00
5f09fd1fa3 问答精选新增专题功能(完成) 2018-04-02 14:51:04 +08:00
00f1b0e8a3 Merge remote-tracking branch 'origin/dev' into dev 2018-04-02 11:14:37 +08:00
4473d0f787 修改回答详情页顶部title 2018-04-02 11:14:25 +08:00
d5255f91d0 修复问题详情闪退问题,修改CheckLoginUtils 2018-04-01 10:04:28 +08:00
57a3479144 问答精选列表数据流刷新(完成) 2018-03-30 18:21:24 +08:00
82c4ebf375 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2018-03-30 16:03:33 +08:00
23ca884684 所有接口offset改为page(完成) 2018-03-30 16:01:41 +08:00
cdfa999b05 评论弹窗显示条数 2018-03-29 18:28:47 +08:00
224092b30a 根据接口字段变动修改回答评论列表 2018-03-29 18:18:26 +08:00
8daefb2e42 消息中心改造基本完成(还差测试) 2018-03-29 17:51:14 +08:00
c0c0ef979d Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev
# Conflicts:
#	app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java
2018-03-28 17:28:12 +08:00
6f0738cebb 提问问题/修改问题(完成) 2018-03-28 17:22:24 +08:00
3c352921bb 根据接口变动修改回答详情页细节 2018-03-28 11:53:15 +08:00
4df8f18cc4 V3.2Api接口更改(分页改为page未完成) 2018-03-28 10:01:10 +08:00
120acdefc6 Resolve conflict. 2018-03-27 10:24:00 +08:00
7eb31085b0 修改回答详情评论接口传参 2018-03-27 10:16:51 +08:00
17a3446be4 增加回答详情页菜单选项弹窗 2018-03-26 10:25:07 +08:00
d713c67c9b 我的光环-消息中心改版 2018-03-24 18:33:10 +08:00
76d788ee66 增加部分回答详情评论的接口 2018-03-23 18:09:52 +08:00
1cf13fc2a1 提问页面流程优化(还差接口调试) 2018-03-23 16:44:09 +08:00
de08d4d32d 为回答详情添加评论(增加部分UI 2018-03-22 18:32:09 +08:00
dce3a91156 删除QuestionsDetailActivity 2018-03-22 16:48:17 +08:00
38bf17c932 问题详情与邀请回答优化(完成) 2018-03-22 16:31:02 +08:00
5d0ccb9a34 光环助手V3.2 CTA按钮样式优化方案(完成) 2018-03-21 11:58:15 +08:00
b557afde2c ListRepository add todo 2018-03-21 10:44:58 +08:00
ea9375c20e baseList多接口兼容完成 2018-03-21 10:41:51 +08:00
fa464a9f1d baseList多接口-资讯页面(完成) 2018-03-20 17:33:06 +08:00
b3ff6ea991 baseList多接口-资讯页面(未完成) 2018-03-20 15:22:20 +08:00
f9dbdd4aa8 baseList 兼容多接口列表 2018-03-19 18:15:08 +08:00
21d06d97ef 更改主题色(包括一些按钮的调整) 2018-03-16 18:24:02 +08:00
fb28a49537 所有TabLayout指示器统一长度 2018-03-16 15:31:07 +08:00
d124504d5b 详情(游戏,文章,礼包)下载改造完成 2018-03-15 17:14:34 +08:00
0c69e0c5e5 更改Fragment初始化Toolbar Menu的位置(onCreate ->onActivityCreated) 2018-03-13 16:38:55 +08:00
39aee1ce89 首页+发现+我的光环 页面优化:http://gitlab.ghzhushou.com/pm/halo-app-issues/issues/175(全部完成) 2018-03-13 15:01:01 +08:00
b3fe87b79a 光环助手V3.2 其它UI优化汇总:http://gitlab.ghzhushou.com/pm/halo-app-issues/issues/176(除第二点外其他的完成) 2018-03-13 11:45:56 +08:00
2dfdc17523 Merge branch 'plugin_control' into dev 2018-03-12 17:53:12 +08:00
c208e7f72d 3.1.1封包(0.0) 2018-02-07 21:00:05 +08:00
8722d0a65b 更改BaseList的数据传递和刷新方式 2018-02-07 19:29:47 +08:00
54f044dfa0 修复部分bug 2018-02-07 14:43:40 +08:00
b854a6dfef WebFragment onActivityResult 数据非空判断 2018-02-06 15:42:57 +08:00
badb99da59 tinker 版本升为3.1.1 准备打补丁包 2018-02-05 15:23:32 +08:00
30d99dbe54 修复切换社区时问答页面销毁导致无法更新问题 2018-02-05 15:12:39 +08:00
c44c4e8b2d 修复切换社区时问答页面销毁导致无法更新问题 2018-02-05 15:12:24 +08:00
656b2f469b NormalActivity getMenuItem 非空判断 2018-02-05 15:04:07 +08:00
39e17842cc bug修复 2018-02-05 14:23:31 +08:00
57f7c0bb31 .gitignore增加选项 2018-02-03 17:51:27 +08:00
76b03fa68b list大小判断 2018-02-03 17:47:41 +08:00
c99d6fb16f 适配开启不保留活动模式(未完全适配 只是尽量让app不要崩) 2018-02-03 17:34:00 +08:00
d29ccc0aca toast context判断 禁止context.getString 操作 2018-02-03 10:16:27 +08:00
bf51be498b ImageUtils 非空问题 2018-02-01 16:02:28 +08:00
6d941975e2 toast禁止使用context 2018-02-01 15:27:29 +08:00
0e075d28a5 imageUtils kotlin非空问题 2018-01-31 14:25:40 +08:00
4b5e6b574f 修复列表刷新FooterViewHolder的方式 以及调整邀请达人FooterViewHolder的间距 2018-01-31 10:56:20 +08:00
fc79581f8c NavigationTitle空处理 MessageDetailActivity继承NormalActivity 2018-01-30 20:48:32 +08:00
6176c47e2f 修复已知bug,debug状态关闭数据上报,release增加tinker开发设备(channel:GH_TEST) 2018-01-30 19:45:56 +08:00
9abe0eb158 Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev 2018-01-30 16:30:13 +08:00
4d7cedb8a6 解决社区游戏选择分页后数据异常问题,解决问题详情无法分页问题 2018-01-30 16:28:34 +08:00
2b02fe06ac Merge remote-tracking branch 'origin/dev' into dev 2018-01-30 11:34:27 +08:00
cd5f530fc6 Add todo. 2018-01-30 11:34:04 +08:00
b9085c7091 修复最新礼包无法下拉刷新问题,appbar在触控屏幕时禁止open/close,部分Fragment commit 替换成commitAllowingStateLoss 2018-01-30 10:38:26 +08:00
679ee71f89 修复channel脚本路劲问题,打tinker基础包 2018-01-28 16:10:12 +08:00
536f0e038a Activity 相关跳转(内部/外部)增加NormalActivity兼容 2018-01-28 15:34:13 +08:00
b087e35b30 修复问答-问题由于调整顺序可能会造成的闪退问题,修复社区-问题由于切换社区造成的数据异常 2018-01-28 14:33:30 +08:00
db3df649ce 优化下载超过100%问题 2018-01-26 16:51:47 +08:00
bb708277b1 修改昵称违规toast文案 2018-01-26 15:43:24 +08:00
c3b694dc6c 优化下载进度超过100%问题 登录相关增加错误toast 2018-01-26 15:34:21 +08:00
b9ff0b1c88 修复下载相关无法即时刷新页面问题 2018-01-25 19:06:04 +08:00
52be8db71f 后台控制关闭插件相关的功能 2018-01-25 17:41:54 +08:00
0e791133dd gradle internal publish 2018-01-24 18:12:01 +08:00
b4f760d69f 社区问题加载... 2018-01-24 18:02:55 +08:00
9bba3c9560 修复问答社区切换时造成数据异常问题 2018-01-24 17:59:49 +08:00
bcd61e87d3 修改草稿后重新刷新我的草稿列表 2018-01-24 11:28:15 +08:00
e8c0e523e6 光环助手V3.1 RELEASE(20180123-1205)测试汇总 2018-01-24 10:53:10 +08:00
af9e9a87b4 去除KEY_DATA, NormalActivity增加适配规则 2018-01-23 17:32:48 +08:00
2d1bb6435f 修复安装/卸载后游戏插件化区域无法更新问题 2018-01-23 14:50:41 +08:00
5680b8508d 问题详情标题去除行数限制 调整标签顺序 2018-01-23 11:00:21 +08:00
df0e9197dc 对话详情回复字数限制,答案/回答详情标题间距修改 2018-01-23 10:21:00 +08:00
79964160ff 发现页面入口点击统计 问答问题修改后刷新问题详情页面 2018-01-22 17:28:45 +08:00
0d46554b66 光环助手V3.1 RELEASE(20180118-2020)测试汇总(完成部分) 2018-01-22 16:07:07 +08:00
539 changed files with 14194 additions and 8907 deletions

3
.gitignore vendored
View File

@ -6,4 +6,5 @@ local.properties
.DS_Store
captures/
build/
release-app/
release-app/
scripts/apk-channel/

View File

@ -62,4 +62,5 @@
- 明确 MVVM 中 Repository 及其衍生类的具体实现方式
- 将实现细节从 View(Fragment、Activity) 剥离并以 MVVM 结构改造
- 将 ListViewModel 所对应的 ListRepository 合并到 ListViewModel 中
- 依照光环助手界面功能以大模块 - 小模块的方式去修改包结构,包内文件建议以包名摘要作为前缀
- 依照光环助手界面功能以大模块 - 小模块的方式去修改包结构,包内文件建议以包名摘要作为前缀
- 使用 RxJava 的 Debounce 和 Map 操作优化搜索触发机制 参考资料:[1](https://proandroiddev.com/building-an-autocompleting-edittext-using-rxjava-f69c5c3f5a40),[2](https://medium.com/@kurtisnusbaum/rxandroid-basics-part-2-6e877af352)

View File

@ -9,6 +9,10 @@ apply from: 'tinker-support.gradle'
android {
dataBinding {
enabled = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
@ -140,6 +144,10 @@ android {
}
}
dataBinding {
enabled = true
}
// productFlavors.all { flavor ->
// flavor.manifestPlaceholders = [CHANNEL_VALUE: name]//命令 gradlew assembleRelease
// }
@ -176,6 +184,7 @@ dependencies {
implementation "com.android.support:design:${androidSupport}"
implementation "com.android.support:support-v4:${androidSupport}"
implementation "com.android.support:appcompat-v7:${androidSupport}"
implementation "com.android.support:cardview-v7:${androidSupport}"
implementation "com.android.support:support-annotations:${androidSupport}"
implementation "com.android.support:percent:${androidSupport}"
implementation "com.android.support.constraint:constraint-layout:${constraintLayout}"

View File

@ -1,208 +0,0 @@
package com.gh.gamecenter;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import com.gh.common.constant.Config;
import com.gh.common.util.PackageUtils;
import com.tencent.bugly.crashreport.CrashReport;
import com.tencent.stat.MtaSDkException;
import com.tencent.stat.StatConfig;
import com.tencent.stat.StatCrashReporter;
import com.tencent.stat.StatReportStrategy;
import com.tencent.stat.StatService;
import com.tendcloud.tenddata.TCAgent;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
/**
* Created by LGT on 2016/6/15.
* 数据收集 工具类 TalkingData、MTA
*/
public class DataUtils {
public static final boolean DEBUG = true;
/**
* 初始化各种统计工具仅在release build非debug模式启用统计
*
* @param context
* @param channel
*/
public static void init(final Application context, String channel) {
// 神烦这些SDK上报debug就不开了
if (!DEBUG) return;
//TalkingData
try {
TCAgent.LOG_ON = false;
TCAgent.init(context, Config.TALKINGDATA_APPID, channel);
/**
*
* 不要启用!!!!不要启用,全部由{@link com.gh.base.AppUncaughtHandler}处理
*/
TCAgent.setReportUncaughtExceptions(false);
} catch (Exception e) {
e.printStackTrace();
}
//MTA
try {
/**
*
* 不要启用!!!!全部由{@link com.gh.base.AppUncaughtHandler}处理
*/
StatConfig.setAutoExceptionCaught(false);
StatCrashReporter crashReporter = StatCrashReporter.getStatCrashReporter(context);
crashReporter.setJavaCrashHandlerStatus(false);
// crashReporter.setEnableInstantReporting(true);
StatConfig.setDebugEnable(DEBUG);
// 设置数据上报策略
if (DEBUG) {
StatConfig.setStatSendStrategy(StatReportStrategy.INSTANT);
} else {
StatConfig.setStatSendStrategy(StatReportStrategy.PERIOD);
StatConfig.setSendPeriodMinutes(5);
}
// 设置启用Tlink
StatConfig.setTLinkStatus(true);
StatConfig.init(context);
StatConfig.setInstallChannel(channel);
StatConfig.setAntoActivityLifecycleStat(true);
StatConfig.setAppVersion(PackageUtils.getPatchVersionName());
// 开启收集服务
StatService.startStatService(context, Config.MTA_APPKEY, com.tencent.stat.common.StatConstants.VERSION);
StatService.registerActivityLifecycleCallbacks(context);
} catch (MtaSDkException e) {
e.printStackTrace();
}
// init bugly
try {
CrashReport.setIsDevelopmentDevice(context, "GH_TEST".equals(channel));
CrashReport.UserStrategy strategy = new CrashReport.UserStrategy(context);
strategy.setEnableANRCrashMonitor(false);
strategy.setEnableNativeCrashMonitor(false);
strategy.setAppChannel(channel);
strategy.setAppVersion(PackageUtils.getPatchVersionName());
CrashReport.initCrashReport(context, Config.BUGLY_APPID, DEBUG, strategy);
} catch (Exception e) {
e.printStackTrace();
}
// Logger.setLogger(context, new LoggerInterface() {
//
// @Override
// public void setTag(String tag) {
// CommonDebug.logMethodWithParams(this, tag);
// }
//
// @Override
// public void log(String content) {
// CommonDebug.logMethodWithParams(this, content);
// }
//
// @Override
// public void log(String content, Throwable t) {
// CommonDebug.logMethodWithParams(this, content, t);
// }
// });
}
public static void onEvent(Context var0, String var1, String var2) {
TCAgent.onEvent(var0, var1, var2);
StatService.trackCustomEvent(var0, var1, var2);
}
public static void onPause(Activity var0) {
TCAgent.onPageEnd(var0, var0.getClass().getSimpleName());
StatService.onPause(var0);
}
public static void onResume(Activity var0) {
TCAgent.onPageStart(var0, var0.getClass().getSimpleName());
StatService.onResume(var0);
}
// 游戏启动
public static void onGameLaunchEvent(Context context, String gameName, String platform, String page) {
Map<String, Object> kv = new HashMap<>();
kv.put("版本", platform);
kv.put("页面", page);
onEvent(context, "游戏启动", gameName, kv);
}
public static void onEvent(Context var0, String var1, String var2, Map<String, Object> var3) {
TCAgent.onEvent(var0, var1, var2, var3);
Properties prop = new Properties();
prop.setProperty("label", var2);
for (String key : var3.keySet()) {
prop.setProperty(key, var3.get(key) + "");
}
StatService.trackCustomKVEvent(var0, var1, prop);
}
// 游戏下载
public static void onGameDownloadEvent(Context context, String gameName, String platform, String entrance, String status) {
Map<String, Object> kv = new HashMap<>();
kv.put("版本", platform);
kv.put("状态", status);
onEvent(context, "游戏下载", gameName, kv);
Map<String, Object> kv2 = new HashMap<>();
kv2.put("版本", platform);
kv2.put("状态", status);
kv2.put("位置", entrance);
onEvent(context, "游戏下载位置", gameName, kv2);
Map<String, Object> kv3 = new HashMap<>();
kv3.put(entrance, "下载数");
kv3.put(entrance, status);
onEvent(context, "应用数据", gameName, kv3);
}
// 游戏更新
public static void onGameUpdateEvent(Context context, String gameName, String paltform, String status) {
Map<String, Object> kv = new HashMap<>();
kv.put("版本", paltform);
kv.put("状态", status);
onEvent(context, "游戏更新", gameName, kv);
}
public static void onError(Context context, Throwable throwable) {
// MTA主动上传错误
try {
StatService.reportException(context, throwable);
} catch (Exception e) {
}
// //bugly 作为默认处理异常的类库,已经上报了,此处不重复上报
// try {
// CrashReport.postCatchedException(throwable);
// } catch (Exception e) {
// }
//talkingdata
try {
TCAgent.onError(context, throwable);
} catch (Exception e) {
}
}
}

View File

@ -89,8 +89,7 @@
android:screenOrientation = "portrait" />
<!--android:theme = "@android:style/Theme.Black.NoTitleBar.Fullscreen" 退出时屏幕抖动 -->
<activity
android:name = "com.gh.gamecenter.ViewImageActivity" />
<activity android:name = "com.gh.gamecenter.ViewImageActivity" />
<activity
android:name = "com.gh.gamecenter.SearchActivity"
android:configChanges = "keyboardHidden"
@ -226,8 +225,13 @@
<activity
android:name = "com.gh.gamecenter.KaiFuActivity"
android:screenOrientation = "portrait" />
<activity
android:name = "com.gh.gamecenter.NormalActivity"
android:name = "com.gh.gamecenter.AskSearchActivity"
android:screenOrientation = "portrait" />
<activity
android:name = "com.gh.gamecenter.AnswerDetailActivity"
android:screenOrientation = "portrait" />
<activity
@ -235,9 +239,58 @@
android:screenOrientation = "portrait" />
<activity
android:name = "com.gh.gamecenter.AskSearchActivity"
android:name = "com.gh.gamecenter.AnswerFoldActivity"
android:screenOrientation = "portrait" />
<activity
android:name = "com.gh.gamecenter.AnswerEditActivity"
android:screenOrientation = "portrait" />
<activity
android:name = "com.gh.gamecenter.QuestionEditActivity"
android:screenOrientation = "portrait" />
<activity
android:name = "com.gh.gamecenter.ConcernInfoActivity"
android:screenOrientation = "portrait" />
<activity
android:name = "com.gh.gamecenter.InfoActivity"
android:screenOrientation = "portrait" />
<activity
android:name = "com.gh.gamecenter.MessageKeFuActivity"
android:screenOrientation = "portrait" />
<activity
android:name = "com.gh.gamecenter.CommunitiesSelectActivity"
android:screenOrientation = "portrait" />
<activity
android:name = "com.gh.gamecenter.CommunitySubjectActivity"
android:screenOrientation = "portrait" />
<activity
android:name = "com.gh.gamecenter.MessageInviteActivity"
android:screenOrientation = "portrait" />
<activity
android:name = "com.gh.gamecenter.MessageVoteActivity"
android:screenOrientation = "portrait" />
<activity
android:name = "com.gh.gamecenter.QuestionsInviteActivity"
android:screenOrientation = "portrait" />
<activity
android:name = "com.gh.gamecenter.MyAskActivity"
android:screenOrientation = "portrait" />
<activity
android:name = "com.gh.gamecenter.AskTabOrderActivity"
android:screenOrientation = "portrait" />
<!-- 使用小米/华为推送弹窗功能提高推送成功率-->
<activity
android:name = "com.gh.gamecenter.PushProxyActivity"

View File

@ -193,7 +193,7 @@ RE.setBlockquote = function() {
}
RE.insertImage = function(url) {
var html = "<div><img src =\"" + url + "\" style=\" max-width: 100%; display:block; margin:8px auto; height: auto;\"></div>"
var html = "<div><img src =\"" + url + "\" style=\" max-width: 100%; display:block; margin:8px auto; height: auto;\"></div><br>"
RE.insertHTML(html);
}
@ -239,6 +239,20 @@ RE.replaceAllDfImage = function() {
}
RE.hideShowBigPic = function() {
var imgs = document.getElementsByTagName("img");
var j = 0;
for (var i = 0; i < imgs.length; i++) {
var img = imgs[i];
if(img.src.indexOf("/tb/") > 0) {
j++;
}
}
if (j == 0) {
RE.replaceAllDfImage();
}
}
RE.replaceDfImageByUrl = function(imgUrl) {
var imgs = document.getElementsByTagName("img");
for (var i = 0; i < imgs.length; i++) {
@ -248,6 +262,7 @@ RE.replaceDfImageByUrl = function(imgUrl) {
img.src = img.src.replace("/tb/", "/");
}
}
RE.hideShowBigPic();
}
RE.ImageClickListener = function() {

View File

@ -11,7 +11,7 @@ import android.util.Log;
import com.gh.common.constant.Config;
import com.gh.common.util.DataCollectionUtils;
import com.gh.gamecenter.DataUtils;
import com.gh.common.util.DataUtils;
import com.gh.gamecenter.SplashScreenActivity;
import com.lightgame.config.CommonDebug;
import com.lightgame.download.FileUtils;

View File

@ -7,14 +7,15 @@ import android.os.Handler;
import android.os.Message;
import android.support.annotation.NonNull;
import com.gh.common.util.DataUtils;
import com.gh.common.util.DialogUtils;
import com.gh.common.util.PackageUtils;
import com.gh.common.util.RunningUtils;
import com.gh.common.util.ShareUtils;
import com.gh.common.util.StringUtils;
import com.gh.gamecenter.DataUtils;
import com.gh.gamecenter.LoginActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.SuggestionActivity;
import com.gh.gamecenter.eventbus.EBShowDialog;
import com.lightgame.download.FileUtils;
import com.lightgame.utils.Utils;
@ -32,7 +33,6 @@ import java.util.List;
import butterknife.ButterKnife;
import pub.devrel.easypermissions.EasyPermissions;
import static com.gh.common.util.EntranceUtils.KEY_DATA;
import static com.gh.common.util.EntranceUtils.KEY_ENTRANCE;
public abstract class BaseActivity extends BaseToolBarActivity implements EasyPermissions.PermissionCallbacks {
@ -78,9 +78,6 @@ public abstract class BaseActivity extends BaseToolBarActivity implements EasyPe
EventBus.getDefault().register(this);
ButterKnife.bind(this);
mEntrance = getIntent().getStringExtra(KEY_ENTRANCE);
if (getIntent().getBundleExtra(KEY_DATA) != null) {
mEntrance = getIntent().getBundleExtra(KEY_DATA).getString(KEY_ENTRANCE);
}
}
@Override
@ -127,7 +124,7 @@ public abstract class BaseActivity extends BaseToolBarActivity implements EasyPe
@Override
public void onConfirm() {
if (FileUtils.isEmptyFile(showDialog.getPath())) {
toast(getString(R.string.install_failure_hint));
toast(R.string.install_failure_hint);
} else {
startActivity(PackageUtils.getUninstallIntent(BaseActivity.this, showDialog.getPath()));
}
@ -153,6 +150,13 @@ public abstract class BaseActivity extends BaseToolBarActivity implements EasyPe
}
} else if ("notfound".equals(showDialog.getType())) {
DialogUtils.showAlertDialog(this, "下载失败", "下载链接已失效,建议提交反馈"
, "立即反馈", "取消"
, () -> {
SuggestionActivity.startSuggestionActivity(this, 4,
null, showDialog.getPath() + ",问题反馈:下载链接失效");
}, null);
}
}
}

View File

@ -25,6 +25,7 @@ public abstract class BaseRecyclerViewHolder<T> extends RecyclerView.ViewHolder
/**
* 具体的设置监听在childViewHolder 设置
*
* @param itemView
* @param data 一般情况下只传列表数据
* @param listClickListener 列表事件接口
@ -35,9 +36,22 @@ public abstract class BaseRecyclerViewHolder<T> extends RecyclerView.ViewHolder
this.mListClickListener = listClickListener;
}
public BaseRecyclerViewHolder(View itemView, OnListClickListener listClickListener) {
this(itemView);
this.mListClickListener = listClickListener;
}
public void setClickData(T clickData) {
this.mData = clickData;
}
@Override
public void onClick(View view) {
mListClickListener.onListClick(view, getAdapterPosition(), mData);
try {
mListClickListener.onListClick(view, getAdapterPosition(), mData);
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -4,14 +4,10 @@ import android.app.Activity;
import android.app.Application.ActivityLifecycleCallbacks;
import android.os.Bundle;
import com.gh.common.util.DataUtils;
import com.gh.download.DownloadManager;
import com.gh.gamecenter.DataUtils;
import com.lightgame.config.CommonDebug;
import com.lightgame.utils.AppManager;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
/**
* 1、写点针对生命周期的统计代码
* 2、写点通用的逻辑

View File

@ -1,5 +1,6 @@
package com.gh.base.adapter;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
@ -14,11 +15,19 @@ public class FragmentAdapter extends FragmentPagerAdapter {
private List<Fragment> mFragmentList;
private List<String> mTitleList;
public FragmentAdapter(FragmentManager fm, List<Fragment> fragmentList) {
super(fm);
this.mFragmentList = fragmentList;
}
public FragmentAdapter(FragmentManager fm, List<Fragment> fragmentList, List<String> titleList) {
super(fm);
this.mFragmentList = fragmentList;
this.mTitleList = titleList;
}
@Override
public Fragment getItem(int position) {
return mFragmentList.get(position);
@ -29,4 +38,12 @@ public class FragmentAdapter extends FragmentPagerAdapter {
return mFragmentList.size();
}
@Nullable
@Override
public CharSequence getPageTitle(int position) {
if (mTitleList != null && mTitleList.size() > position) {
return mTitleList.get(position);
}
return super.getPageTitle(position);
}
}

View File

@ -1,11 +1,15 @@
package com.gh.base.fragment;
import android.app.Dialog;
import android.arch.lifecycle.Lifecycle;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
import android.support.v4.app.DialogFragment;
import com.gh.gamecenter.R;
import com.lightgame.utils.RuntimeUtils;
import com.lightgame.utils.Utils;
/**
* @author CsHeng
@ -24,6 +28,24 @@ public class BaseDialogFragment extends DialogFragment {
return dialog;
}
public void toast(@StringRes int res) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
toast(getString(res));
}
public void toast(String msg) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
Utils.toast(getContext(), msg);
}
public void toastLong(@StringRes int msg) {
toastLong(getString(msg));
}
public void toastLong(String msg) {
RuntimeUtils.getInstance().toastLong(getContext(), msg);
}
}

View File

@ -0,0 +1,55 @@
package com.gh.base.fragment;
import android.app.Dialog;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.gh.gamecenter.R;
/**
* Wrap another fragment with dialog fragment.
*/
public class BaseDialogWrapperFragment extends BaseDialogFragment {
private Fragment mFragmentToWrap;
public static BaseDialogWrapperFragment getInstance(Fragment fragmentToWrap) {
BaseDialogWrapperFragment fragment = new BaseDialogWrapperFragment();
fragment.mFragmentToWrap = fragmentToWrap;
return fragment;
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_dialog_wrapper, null);
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getChildFragmentManager().beginTransaction().replace(R.id.fragment_placeholder, mFragmentToWrap).commitNowAllowingStateLoss();
}
@Override
public void onStart() {
super.onStart();
getDialog().getWindow().setGravity(Gravity.BOTTOM);
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = super.onCreateDialog(savedInstanceState);
dialog.setCanceledOnTouchOutside(true);
return dialog;
}
}

View File

@ -14,7 +14,6 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.gh.base.BaseToolBarActivity;
import com.gh.base.OnListClickListener;
import com.gh.base.OnRequestCallBackListener;
import com.gh.gamecenter.eventbus.EBMiPush;
@ -34,7 +33,6 @@ import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import static com.gh.common.util.EntranceUtils.KEY_DATA;
import static com.gh.common.util.EntranceUtils.KEY_ENTRANCE;
/**
@ -53,16 +51,16 @@ public abstract class BaseFragment<T> extends Fragment implements OnRequestCallB
protected final Handler mBaseHandler = new BaseFragment.BaseHandler(this);
protected static class BaseHandler extends Handler {
private final WeakReference<BaseFragment> mfragmentWeakReference;
private final WeakReference<BaseFragment> mFragmentWeakReference;
BaseHandler(BaseFragment fragment) {
mfragmentWeakReference = new WeakReference<>(fragment);
mFragmentWeakReference = new WeakReference<>(fragment);
}
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
mfragmentWeakReference.get().handleMessage(msg);
mFragmentWeakReference.get().handleMessage(msg);
}
}
@ -73,6 +71,13 @@ public abstract class BaseFragment<T> extends Fragment implements OnRequestCallB
@LayoutRes
protected abstract int getLayoutId();
/**
* 提供 Inflated 的 view ,可用于 data binding.
*/
protected View getInflatedLayout() {
return null;
}
/**
* 责任链谁处理了就返回true否则返回super.handleOnClick(View view)
*
@ -87,15 +92,6 @@ public abstract class BaseFragment<T> extends Fragment implements OnRequestCallB
handleOnClick(v);
}
protected void setNavigationTitle(@StringRes int res) {
setNavigationTitle(getString(res));
}
protected void setNavigationTitle(String title) {
if (getActivity() instanceof BaseToolBarActivity) {
((BaseToolBarActivity) getActivity()).setNavigationTitle(title);
}
}
protected void initView(View view) {
}
@ -114,14 +110,18 @@ public abstract class BaseFragment<T> extends Fragment implements OnRequestCallB
super.onCreate(savedInstanceState);
final Intent intent = getActivity().getIntent();
mEntrance = intent.getStringExtra(KEY_ENTRANCE);
if (intent.getBundleExtra(KEY_DATA) != null) {
mEntrance = intent.getBundleExtra(KEY_DATA).getString(KEY_ENTRANCE);
}
isEverPause = false;
EventBus.getDefault().register(this);
mCachedView = View.inflate(getContext(), getLayoutId(), null);
// For data binding.
if (getInflatedLayout() != null) {
mCachedView = getInflatedLayout();
} else {
mCachedView = View.inflate(getContext(), getLayoutId(), null);
}
ButterKnife.bind(this, mCachedView);
initView(mCachedView);
}

View File

@ -0,0 +1,106 @@
package com.gh.base.fragment;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;
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.lightgame.view.NoScrollableViewPager;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
/**
* Created by khy on 15/03/18.
*/
public abstract class BaseFragment_TabLayout extends NormalFragment implements ViewPager.OnPageChangeListener {
public static final String PAGE_INDEX = "PAGE_INDEX";
@BindView(R.id.fragment_tab_layout)
protected TabLayout mTabLayout;
@BindView(R.id.fragment_view_pager)
protected NoScrollableViewPager mViewPager;
@BindView(R.id.fragment_tab_indicator)
protected TabIndicatorView mTabIndicatorView;
protected List<Fragment> mFragmentsList;
protected List<String> mTabTitleList;
protected int mCheckedIndex = 0;
protected abstract void initFragmentList(List<Fragment> fragments);
protected abstract void initTabTitleList(List<String> tabTitleList);
protected int provideIndicatorWidth() {
return 65;
}
protected View provideTabView(int position, String tabTitle) {
return null;
}
@Override
protected int getLayoutId() {
return R.layout.fragment_taglyout_viewpager;
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) mCheckedIndex = getArguments().getInt(PAGE_INDEX, 0);
mFragmentsList = new ArrayList<>();
initFragmentList(mFragmentsList);
mTabTitleList = new ArrayList<>();
initTabTitleList(mTabTitleList);
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mViewPager.setOffscreenPageLimit(mFragmentsList.size());
mViewPager.addOnPageChangeListener(this);
mViewPager.setAdapter(new FragmentAdapter(getChildFragmentManager(), mFragmentsList, mTabTitleList));
mViewPager.setCurrentItem(mCheckedIndex);
mTabLayout.setupWithViewPager(mViewPager);
mTabIndicatorView.setupWithTabLayout(mTabLayout);
mTabIndicatorView.setupWithViewPager(mViewPager);
mTabIndicatorView.setIndicatorWidth(provideIndicatorWidth());
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;
tab.setCustomView(tabView);
}
}
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
}
@Override
public void onPageScrollStateChanged(int state) {
}
}

View File

@ -68,11 +68,6 @@ public abstract class BaseFragment_ViewPager extends NormalFragment implements D
mViewPager = (ViewPager) view.findViewById(getViewPagerId());
mViewPager.setOffscreenPageLimit(mFragmentsList.size());
mViewPager.setAdapter(mAdapter);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (mCheckedIndex < mFragmentsList.size()) {
mViewPager.setCurrentItem(mCheckedIndex, false);
}
@ -117,10 +112,15 @@ public abstract class BaseFragment_ViewPager extends NormalFragment implements D
}
List<Fragment> fragments = getChildFragmentManager().getFragments();
if (fragments != null) {
Fragment curFragment = fragments.get(mViewPager.getCurrentItem());
curFragment.onActivityResult(requestCode, resultCode, data);
for (Fragment fragment : fragments) {
fragment.onActivityResult(requestCode, resultCode, data);
}
}
}
public int getCurrentItem() {
return mViewPager != null ? mViewPager.getCurrentItem() : 0;
}
}

View File

@ -2,6 +2,7 @@ package com.gh.base.fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -26,6 +27,16 @@ public class WaitingDialogFragment extends BaseDialogFragment {
return fragment;
}
public static WaitingDialogFragment newInstance(String message, boolean isCancelable) {
Bundle args = new Bundle();
args.putString(KEY_MSG, message);
WaitingDialogFragment fragment = new WaitingDialogFragment();
fragment.setArguments(args);
fragment.setCancelable(isCancelable);
return fragment;
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@ -35,4 +46,12 @@ public class WaitingDialogFragment extends BaseDialogFragment {
return view;
}
@Override
public void show(FragmentManager manager, String tag) {
try {
super.show(manager, tag);
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,33 @@
package com.gh.base;
import android.content.Context;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
/**
* Created by khy on 25/04/18.
*/
public abstract class onDoubleTapListener implements View.OnTouchListener {
private GestureDetector mGestureDetector;
public onDoubleTapListener(Context context) {
mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onDoubleTap(MotionEvent e) {
onDoubleTapListener.this.onDoubleTap();
return true;
}
});
}
@Override
public boolean onTouch(View v, MotionEvent event) {
mGestureDetector.onTouchEvent(event);
return true;
}
public abstract void onDoubleTap();
}

View File

@ -4,8 +4,16 @@ package com.gh.common.constant;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import com.gh.common.util.GsonUtils;
import com.gh.gamecenter.BuildConfig;
import com.gh.gamecenter.entity.NewsEntity;
import com.gh.gamecenter.entity.SettingsEntity;
import com.halo.assistant.HaloApp;
import com.lightgame.utils.Utils;
import java.util.List;
public class Config {
@ -42,9 +50,23 @@ public class Config {
public static final String URL_ARTICLE = "http://www.ghzs666.com/article/"; // TODO ghzs/ghzs666 统一
public static final String PATCHES = "patches";
public static boolean isShow(Context context) {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
return sp.getBoolean("isShow", true);
private static SettingsEntity mSettingsEntity;
public static boolean isShow() {
// SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
// return sp.getBoolean("isShow", true);
if (!isExistDownloadFilter()) return false;
for (SettingsEntity.Download entity : mSettingsEntity.getDownload()) {
if ("all".equals(entity.getGame())) {
if (entity.isPluginfy() && "normal".equals(entity.getPolicy()) && filterTime(entity.getTime())) {
return true;
}
}
}
return false;
}
public static String getExceptionMsg(Context context) {
@ -56,4 +78,107 @@ public class Config {
PreferenceManager.getDefaultSharedPreferences(context).edit().putString("errMsg", errMsg).apply();
}
public static boolean isShowDownload(String gameId) {
if (TextUtils.isEmpty(gameId) || !isExistDownloadFilter())
return false;
for (SettingsEntity.Download entity : mSettingsEntity.getDownload()) {
if (gameId.equals(entity.getGame())) {
if ("normal".equals(entity.getPolicy()) && filterTime(entity.getTime())) {
return true;
} else {
return false;
}
} else if ("all".equals(entity.getGame())) {
if ("normal".equals(entity.getPolicy()) && filterTime(entity.getTime())) {
return true;
}
}
}
return false;
}
public static boolean isShowPlugin(String gameId) {
if (TextUtils.isEmpty(gameId) || !isExistDownloadFilter())
return false;
for (SettingsEntity.Download entity : mSettingsEntity.getDownload()) {
if (gameId.equals(entity.getGame())) {
if (entity.isPluginfy() && filterTime(entity.getTime())) {
return true;
} else {
return false;
}
} else if ("all".equals(entity.getGame())) {
if (entity.isPluginfy() && filterTime(entity.getTime())) {
return true;
}
}
}
return false;
}
public static boolean isShowPlugin() {
if (!isExistDownloadFilter())
return false;
for (SettingsEntity.Download entity : mSettingsEntity.getDownload()) {
if ("all".equals(entity.getGame())) {
if (entity.isPluginfy() && filterTime(entity.getTime())) {
return true;
}
}
}
return false;
}
private static boolean filterTime(SettingsEntity.Download.TimeEntity timeEntity) {
long end = timeEntity.getEnd();
long start = timeEntity.getStart();
long curTime = Utils.getTime(HaloApp.getInstance().getApplication());
if ((start == 0 || curTime >= start) && (end == 0 || curTime <= end)) {
return true;
}
return false;
}
public static void setSettings(SettingsEntity settingsEntity) {
if (settingsEntity != null && settingsEntity.getSuggestion() != null) {
String s = GsonUtils.Companion.getInstance().toJson(settingsEntity);
}
mSettingsEntity = settingsEntity;
}
public static SettingsEntity getSettings() {
return mSettingsEntity;
}
private static boolean isExistDownloadFilter() {
if (mSettingsEntity == null || mSettingsEntity.getDownload() == null || mSettingsEntity.getDownload().size() == 0) {
return false;
} else {
return true;
}
}
public static void filterPluginArticle(List<NewsEntity> list) {
if (isShowPlugin() || list == null) return;
for (int i = 0; i < list.size(); i++) {
NewsEntity newsEntity = list.get(i);
String title = newsEntity.getTitle();
if (!TextUtils.isEmpty(title) && title.contains("插件")) {
list.remove(i);
i--;
}
}
}
}

View File

@ -0,0 +1,149 @@
package com.gh.common.databind;
import android.databinding.BindingAdapter;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
import com.facebook.drawee.view.SimpleDraweeView;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.NewsUtils;
import com.gh.gamecenter.R;
import com.gh.gamecenter.entity.GameEntity;
/**
* Created by khy on 12/02/18.
*/
public class BindingAdapters {
@BindingAdapter("imageUrl")
public static void loadImage(SimpleDraweeView view, String imageUrl) {
view.setImageURI(imageUrl);
}
@BindingAdapter("visibleGone")
public static void showHide(View view, Boolean show) {
if (show) {
view.setVisibility(View.VISIBLE);
} else {
view.setVisibility(View.GONE);
}
}
@BindingAdapter("messageUnread")
public static void setMessageUnread(TextView view, int unreadCount) {
if (unreadCount < 100) {
view.setText(String.valueOf(unreadCount));
} else {
view.setText("99+");
}
}
@BindingAdapter("serverTypePadding")
public static void setServerTypePadding(TextView view, String serverType) {
int paddRight = 0;
if (TextUtils.isEmpty(serverType)) {
} else {
if ("删档内测".equals(serverType) || "不删档内测".equals(serverType)) {
if ("删档内测".equals(serverType)) {
paddRight = DisplayUtils.dip2px(view.getContext(), 50);
} else {
paddRight = DisplayUtils.dip2px(view.getContext(), 60);
}
} else {
paddRight = DisplayUtils.dip2px(view.getContext(), 30);
}
}
view.setPadding(0, 0, paddRight, 0);
}
@BindingAdapter("serverType")
public static void setServerType(TextView view, String serverType) {
view.setText(serverType);
if ("删档内测".equals(serverType) || "不删档内测".equals(serverType)) {
view.setBackgroundResource(R.drawable.textview_server_tag);
} else {
view.setBackgroundResource(R.drawable.textview_orange_up);
}
}
@BindingAdapter("articleType")
public static void setArticleType(TextView view, String articleType) {
NewsUtils.setNewsType(view, articleType, 0, 0);
}
@BindingAdapter("detailDownloadText")
public static void setDetailDownloadText(TextView view, GameEntity gameEntity) {
if (gameEntity == null || gameEntity.getApk().isEmpty()) {
view.setBackgroundResource(R.drawable.game_item_btn_pause_style);
view.setTextColor(0xFF999999);
view.setClickable(false);
}
}
@BindingAdapter("liBaoBtn")
public static void setLiBaoBtn(TextView view, String status) {
if (TextUtils.isEmpty(status)) return;
switch (status) {
case "coming":
view.setText(R.string.libao_coming);
view.setBackgroundResource(R.drawable.textview_blue_style);
break;
case "ling":
view.setText(R.string.libao_ling);
view.setBackgroundResource(R.drawable.textview_green_style);
break;
case "tao":
view.setText(R.string.libao_tao);
view.setBackgroundResource(R.drawable.textview_orange_style);
break;
case "used_up":
view.setText(R.string.libao_used_up);
view.setBackgroundResource(R.drawable.textview_cancel_up);
break;
case "finish":
view.setText(R.string.libao_finish);
view.setBackgroundResource(R.drawable.textview_cancel_up);
break;
case "linged":
view.setText(R.string.libao_linged);
view.setBackgroundResource(R.drawable.libao_linged_style);
view.setTextColor(ContextCompat.getColorStateList(view.getContext(), R.color.libao_linged_selector));
break;
case "taoed":
view.setText(R.string.libao_taoed);
view.setBackgroundResource(R.drawable.libao_taoed_style);
view.setTextColor(ContextCompat.getColorStateList(view.getContext(), R.color.libao_taoed_selector));
break;
case "copy":
view.setText(R.string.libao_copy);
view.setBackgroundResource(R.drawable.textview_blue_style);
break;
case "repeatLing":
view.setText(R.string.libao_repeat_ling);
view.setBackgroundResource(R.drawable.textview_cancel_up);
break;
case "repeatLinged":
view.setText(R.string.libao_repeat_ling);
view.setBackgroundResource(R.drawable.textview_green_style);
break;
case "repeatTao":
view.setText(R.string.libao_repeat_tao);
view.setBackgroundResource(R.drawable.textview_cancel_up);
break;
case "repeatTaoed":
view.setText(R.string.libao_repeat_tao);
view.setBackgroundResource(R.drawable.textview_orange_style);
break;
case "unshelve":
view.setBackgroundResource(R.drawable.textview_cancel_style);
view.setText(R.string.libao_unshelve);
break;
default:
view.setBackgroundResource(R.drawable.textview_cancel_style);
view.setText("异常");
}
}
}

View File

@ -2,7 +2,6 @@ package com.gh.common.util;
import android.content.Context;
import com.gh.gamecenter.R;
import com.lightgame.utils.Utils;
import org.json.JSONObject;
@ -18,29 +17,10 @@ public class AskErrorResponseUtils {
public static void errorResponseControl(Context context, HttpException e) {
if (e == null) return;
int code = e.code();
try {
JSONObject object = new JSONObject(e.response().errorBody().string());
int errorCode = object.getInt("code");
if (errorCode == 400) {
switch (errorCode) {
case 400001:
Utils.toast(context, "提交的参数不符合接口的要求");
break;
case 400003:
Utils.toast(context, "客户端提供的expert_id不存在");
break;
case 400004:
Utils.toast(context, "缺少参数");
break;
case 400005:
Utils.toast(context, "用户的评论被墙(黑名单)");
break;
default:
Utils.toast(context, context.getString(R.string.request_failure_normal_hint));
break;
}
} else if (code == 403) {
if (code == 403) {
JSONObject object = new JSONObject(e.response().errorBody().string());
int errorCode = object.getInt("code");
switch (errorCode) {
case 403001:
Utils.toast(context, "标签名称太长了");
@ -88,11 +68,17 @@ public class AskErrorResponseUtils {
Utils.toast(context, "已经关注过了");
break;
default:
Utils.toast(context, context.getString(R.string.request_failure_normal_hint));
Utils.toast(context, "网络错误");
break;
}
} else if (code == 401 && errorCode == 404001) {
Utils.toast(context, "请求的资源不存在");
} else if (code == 401) {
JSONObject object = new JSONObject(e.response().errorBody().string());
int errorCode = object.getInt("code");
if (errorCode == 404001) {
Utils.toast(context, "请求的资源不存在");
}
} else {
Utils.toast(context, "网络错误");
}
} catch (Exception e1) {

View File

@ -22,6 +22,7 @@ public class AskLogUtils {
public static void uploadQuestions(Context context, String tracers, Questions questions) {
if (context == null) return;
JSONObject object = new JSONObject();
try {
object.put("community_id", UserManager.getInstance().getCommunityId(context));
@ -38,6 +39,7 @@ public class AskLogUtils {
}
public static void uploadAnswers(Context context, String tracers, Questions questions, String answerId) {
if (context == null) return;
JSONObject object = new JSONObject();
try {
object.put("community_id", UserManager.getInstance().getCommunityId(context));
@ -55,7 +57,7 @@ public class AskLogUtils {
}
public static void uploadSearch(Context context, String searchKey) {
if (TextUtils.isEmpty(searchKey)) return;
if (TextUtils.isEmpty(searchKey) || context == null) return;
JSONObject object = new JSONObject();
try {
@ -71,7 +73,40 @@ public class AskLogUtils {
}
public static void communityRefresh(Context context, int dataCount) {
if (context == null) return;
JSONObject object = new JSONObject();
try {
object.put("subject", "community_refresh");
object.put("community_id", UserManager.getInstance().getCommunityId(context));
object.put("refresh_type", "recommend");
object.put("data_count", dataCount);
object.put("user_id", UserManager.getInstance().getUserId());
object.put("network", DeviceUtils.getNetwork(context));
} catch (JSONException e) {
e.printStackTrace();
}
upload(context, object);
}
public static void login(Context context, String loginStep, String loginType) {
if (context == null) return;
JSONObject object = new JSONObject();
try {
object.put("subject", "login");
object.put("step", loginStep);
object.put("login_type", loginType);
object.put("network", DeviceUtils.getNetwork(context));
} catch (JSONException e) {
e.printStackTrace();
}
upload(context, object);
}
private static void upload(Context context, JSONObject object) {
if (context == null) return;
try {
object.put("version", BuildConfig.PATCH_VERSION_NAME);
object.put("channel", HaloApp.getInstance().getChannel());

View File

@ -13,19 +13,21 @@ import com.gh.gamecenter.manager.UserManager;
public class CheckLoginUtils {
public static void checkLogin(final Context context, OnLoggenInListener listener) {
public static void checkLogin(final Context context, OnLoginListener listener) {
// String token = LoginUtils.getToken(context);
if (TextUtils.isEmpty(UserManager.getInstance().getToken())) {
AskLogUtils.login(context, "dialog", null);
DialogUtils.showWarningDialog(context, "登录提示", "需要登录才能使用该功能喔!", "取消", "快速登录",
new DialogUtils.ConfirmListener() {
@Override
public void onConfirm() {
AskLogUtils.login(context, "activity", null);
Intent intent = LoginActivity.getIntent(context);
context.startActivity(intent);
}
}, null);
} else {
listener.onLoggedIn();
listener.onLogin();
}
}
@ -33,7 +35,7 @@ public class CheckLoginUtils {
return !TextUtils.isEmpty(UserManager.getInstance().getToken());
}
public interface OnLoggenInListener {
void onLoggedIn();
public interface OnLoginListener {
void onLogin();
}
}

View File

@ -0,0 +1,44 @@
package com.gh.common.util;
import android.util.Log;
public class ClickUtils {
private static long lastClickTime = 0;
private static long DIFF = 800;
private static int lastButtonId = -1;
/**
* 判断两次点击的间隔如果小于800则认为是多次无效点击 * * @return
*/
public static boolean isFastDoubleClick() {
return isFastDoubleClick(-1, DIFF);
}
/**
* 判断两次点击的间隔如果小于800则认为是多次无效点击 * * @return
*/
public static boolean isFastDoubleClick(int buttonId) {
return isFastDoubleClick(buttonId, DIFF);
}
/**
* 判断两次点击的间隔如果小于diff则认为是多次无效点击 * * @param diff * @return
*/
public static boolean isFastDoubleClick(int buttonId, long diff) {
long time = System.currentTimeMillis();
long timeD = time - lastClickTime;
if (lastButtonId == buttonId && lastClickTime > 0 && timeD < diff) {
Log.v("isFastDoubleClick", "短时间内按钮多次触发");
return true;
}
lastClickTime = time;
lastButtonId = buttonId;
return false;
}
public static void releaseInterval() {
lastButtonId = 0;
}
}

View File

@ -2,10 +2,9 @@ package com.gh.common.util
import android.content.Context
import com.gh.gamecenter.eventbus.EBCollectionChanged
import com.gh.gamecenter.manager.UserManager
import com.gh.gamecenter.retrofit.Response
import com.gh.gamecenter.retrofit.RetrofitManager
import okhttp3.MediaType
import okhttp3.RequestBody
import okhttp3.ResponseBody
import org.greenrobot.eventbus.EventBus
import org.json.JSONObject
@ -25,11 +24,10 @@ object CollectionUtils {
fun postCollection(context: Context, content: String, type: CollectionType, listener: OnCollectionListener) {
val body = RequestBody.create(MediaType.parse("application/json"), content)
val postCollection = when (type) {
CollectionType.article -> RetrofitManager.getInstance(context).getApi().postCollectionArticle(body)
CollectionType.toolkit -> RetrofitManager.getInstance(context).getApi().postCollectionTools(body)
CollectionType.answer -> RetrofitManager.getInstance(context).getApi().postCollectionAnswer(content)
CollectionType.article -> RetrofitManager.getInstance(context).getApi().postCollectionArticle(UserManager.getInstance().userId, content)
CollectionType.toolkit -> RetrofitManager.getInstance(context).getApi().postCollectionTools(UserManager.getInstance().userId, content)
CollectionType.answer -> RetrofitManager.getInstance(context).getApi().postCollectionAnswer(UserManager.getInstance().userId, content)
}
postCollection
.subscribeOn(Schedulers.io())
@ -39,7 +37,7 @@ object CollectionUtils {
super.onResponse(response)
listener.onSuccess()
if(type != CollectionType.answer)
EventBus.getDefault().post(EBCollectionChanged(JSONObject(content).getString("_id"), true, type))
EventBus.getDefault().post(EBCollectionChanged(content, true, type))
}
override fun onFailure(e: HttpException?) {
@ -48,7 +46,7 @@ object CollectionUtils {
try {
val string = e.response()?.errorBody()?.string()
val errorBody = JSONObject(string)
if (errorBody.getInt("status") == 40031) {
if (errorBody.getInt("detail") == 403009) {
listener.onSuccess()
return
}
@ -65,9 +63,9 @@ object CollectionUtils {
val postCollection: Observable<ResponseBody>
when (type) {
CollectionType.article -> postCollection = RetrofitManager.getInstance(context).getApi().deletaCollectionArticle(id)
CollectionType.toolkit -> postCollection = RetrofitManager.getInstance(context).getApi().deleteCollectionTools(id)
CollectionType.answer -> postCollection = RetrofitManager.getInstance(context).getApi().deleteCollectionAnswer(id)
CollectionType.article -> postCollection = RetrofitManager.getInstance(context).getApi().deletaCollectionArticle(UserManager.getInstance().userId, id)
CollectionType.toolkit -> postCollection = RetrofitManager.getInstance(context).getApi().deleteCollectionTools(UserManager.getInstance().userId, id)
CollectionType.answer -> postCollection = RetrofitManager.getInstance(context).getApi().deleteCollectionAnswer(UserManager.getInstance().userId, id)
}
postCollection
.subscribeOn(Schedulers.io())
@ -88,17 +86,17 @@ object CollectionUtils {
}
fun patchCollection(context: Context, id: String, type: CollectionType) {
val postCollection = when (type) {
CollectionType.article -> RetrofitManager.getInstance(context).getApi().patchCollectionArticle(id)
CollectionType.toolkit -> RetrofitManager.getInstance(context).getApi().patchCollectionTools(id)
else -> {
return
}
}
postCollection
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Response<ResponseBody>() {})
// val postCollection = when (type) {
// CollectionType.article -> RetrofitManager.getInstance(context).getApi().patchCollectionArticle(id)
// CollectionType.toolkit -> RetrofitManager.getInstance(context).getApi().patchCollectionTools(id)
// else -> {
// return
// }
// }
// postCollection
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(object : Response<ResponseBody>() {})
}

View File

@ -1,6 +1,7 @@
package com.gh.common.util;
import android.app.Dialog;
import android.content.ClipboardManager;
import android.content.Context;
import android.graphics.Color;
import android.support.v4.content.ContextCompat;
@ -70,7 +71,7 @@ public class CommentUtils {
}
}
public static void showReportDialog(final CommentEntity commentEntity, final Context context,
public static void showReportDialog(final CommentEntity commentEntity, final Context context, final boolean showConversation,
final OnCommentCallBackListener listener, final String newsId) {
final Dialog dialog = new Dialog(context);
@ -89,7 +90,7 @@ public class CommentUtils {
dialogType.add("复制");
dialogType.add("举报");
if (commentEntity.getParent() != null) {
if (commentEntity.getParent() != null && showConversation) {
dialogType.add("查看对话");
}
@ -112,29 +113,21 @@ public class CommentUtils {
dialog.cancel();
switch (reportTv.getText().toString()) {
case "回复":
CheckLoginUtils.checkLogin(context, new CheckLoginUtils.OnLoggenInListener() {
@Override
public void onLoggedIn() {
if (listener != null) {
listener.onCommentCallback(commentEntity);
} else if (!TextUtils.isEmpty(newsId)) {
context.startActivity(MessageDetailActivity.getMessageDetailIntent(context, commentEntity, newsId));
} else {
Utils.toast(context, "缺少关键属性");
}
CheckLoginUtils.checkLogin(context, () -> {
if (listener != null) {
listener.onCommentCallback(commentEntity);
} else if (!TextUtils.isEmpty(newsId)) {
context.startActivity(MessageDetailActivity.getMessageDetailIntent(context, commentEntity, newsId));
} else {
Utils.toast(context, "缺少关键属性");
}
});
break;
case "复制":
LibaoUtils.copyLink(commentEntity.getContent(), context);
copyText(commentEntity.getContent(), context);
break;
case "举报":
CheckLoginUtils.checkLogin(context, new CheckLoginUtils.OnLoggenInListener() {
@Override
public void onLoggedIn() {
showReportTypeDialog(commentEntity, context);
}
});
CheckLoginUtils.checkLogin(context, () -> showReportTypeDialog(commentEntity, context));
break;
case "查看对话":
@ -151,6 +144,126 @@ public class CommentUtils {
}
public static void showAnswerCommentOptions(final CommentEntity commentEntity, final Context context,
final OnCommentCallBackListener listener, final String id, boolean showConversation, String answerId) {
final Dialog dialog = new Dialog(context);
LinearLayout container = new LinearLayout(context);
container.setOrientation(LinearLayout.VERTICAL);
container.setBackgroundColor(Color.WHITE);
container.setPadding(0, DisplayUtils.dip2px(context, 12), 0, DisplayUtils.dip2px(context, 12));
List<String> dialogType = new ArrayList<>();
if (commentEntity.getUserData() == null || !commentEntity.getUserData().isAnswerCommented()) {
dialogType.add("回复");
}
dialogType.add("复制");
dialogType.add("举报");
if (commentEntity.getParentUser() != null && showConversation) {
dialogType.add("查看对话");
}
for (String s : dialogType) {
final TextView reportTv = new TextView(context);
reportTv.setText(s);
reportTv.setTextSize(17);
reportTv.setTextColor(ContextCompat.getColor(context, R.color.title));
reportTv.setBackgroundResource(R.drawable.textview_white_style);
int widthPixels = context.getResources().getDisplayMetrics().widthPixels;
reportTv.setLayoutParams(new LinearLayout.LayoutParams((widthPixels * 9) / 10,
LinearLayout.LayoutParams.WRAP_CONTENT));
reportTv.setPadding(DisplayUtils.dip2px(context, 20), DisplayUtils.dip2px(context, 12),
0, DisplayUtils.dip2px(context, 12));
container.addView(reportTv);
reportTv.setOnClickListener(v -> {
dialog.cancel();
switch (reportTv.getText().toString()) {
case "回复":
CheckLoginUtils.checkLogin(context, () -> {
if (listener != null) {
listener.onCommentCallback(commentEntity);
} else if (!TextUtils.isEmpty(id)) {
context.startActivity(MessageDetailActivity.getMessageDetailIntent(context, commentEntity, id));
} else {
Utils.toast(context, "缺少关键属性");
}
});
break;
case "复制":
copyText(commentEntity.getContent(), context);
break;
case "举报":
CheckLoginUtils.checkLogin(context, () -> showAnswerReportDialog(answerId, commentEntity, context));
break;
case "查看对话":
context.startActivity(CommentDetailActivity.getAnswerCommentIntent(context, commentEntity.getId(), answerId));
break;
}
});
}
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(container);
dialog.show();
}
private static void showAnswerReportDialog(final String answerId, final CommentEntity commentEntity, final Context context) {
final String[] arrReportType = new String[]{"垃圾广告营销", "恶意攻击谩骂", "淫秽色情信息",
"违法有害信息", "其它"};
int widthPixels = context.getResources().getDisplayMetrics().widthPixels;
final Dialog reportTypeDialog = new Dialog(context);
LinearLayout container = new LinearLayout(context);
container.setOrientation(LinearLayout.VERTICAL);
container.setPadding(0, DisplayUtils.dip2px(context, 12), 0, DisplayUtils.dip2px(context, 12));
container.setBackgroundColor(Color.WHITE);
for (final String s : arrReportType) {
TextView reportTypeTv = new TextView(context);
reportTypeTv.setText(s);
reportTypeTv.setTextSize(17);
reportTypeTv.setTextColor(ContextCompat.getColor(context, R.color.title));
reportTypeTv.setBackgroundResource(R.drawable.textview_white_style);
reportTypeTv.setLayoutParams(new LinearLayout.LayoutParams((widthPixels * 9) / 10,
LinearLayout.LayoutParams.WRAP_CONTENT));
reportTypeTv.setPadding(DisplayUtils.dip2px(context, 20), DisplayUtils.dip2px(context, 12),
0, DisplayUtils.dip2px(context, 12));
container.addView(reportTypeTv);
reportTypeTv.setOnClickListener(v -> {
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("reason", s);
} catch (JSONException e) {
e.printStackTrace();
}
PostCommentUtils.postAnswerReportData(context, commentEntity.getId(), answerId, jsonObject.toString(),
new PostCommentUtils.PostCommentListener() {
@Override
public void postSuccess(JSONObject response) {
Utils.toast(context, "感谢您的举报");
}
@Override
public void postFailed(Throwable error) {
Utils.toast(context, error.toString());
}
});
reportTypeDialog.cancel();
});
}
reportTypeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
reportTypeDialog.setContentView(container);
reportTypeDialog.show();
}
private static void showReportTypeDialog(final CommentEntity commentEntity, final Context context) {
final String[] arrReportType = new String[]{"垃圾广告营销", "恶意攻击谩骂", "淫秽色情信息",
"违法有害信息", "其它"};
@ -185,7 +298,7 @@ public class CommentUtils {
e.printStackTrace();
}
PostCommentUtils.addReportData(context, jsonObject.toString(),
PostCommentUtils.addReportData(context, commentEntity.getId(), jsonObject.toString(),
new PostCommentUtils.PostCommentListener() {
@Override
public void postSuccess(JSONObject response) {
@ -209,59 +322,111 @@ public class CommentUtils {
public static void postVote(final Context context, final CommentEntity commentEntity,
final TextView commentLikeCountTv, final ImageView commentLikeIv, final OnVoteListener listener) {
CheckLoginUtils.checkLogin(context, new CheckLoginUtils.OnLoggenInListener() {
@Override
public void onLoggedIn() {
if (commentLikeCountTv.getCurrentTextColor() == ContextCompat.getColor(context, R.color.theme)) {
Utils.toast(context, "已经点过赞啦!");
return;
}
commentEntity.setVote(commentEntity.getVote() + 1);
commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.theme));
commentLikeIv.setImageResource(R.drawable.ic_like_select);
commentLikeCountTv.setText(String.valueOf(commentEntity.getVote()));
commentLikeCountTv.setVisibility(View.VISIBLE);
PostCommentUtils.addCommentVoto(context, commentEntity.getId(),
new PostCommentUtils.PostCommentListener() {
@Override
public void postSuccess(JSONObject response) {
if (listener != null) {
listener.onVote();
}
}
@Override
public void postFailed(Throwable e) {
commentEntity.setVote(commentEntity.getVote() - 1);
commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.hint));
commentLikeIv.setImageResource(R.drawable.ic_like_unselect);
commentLikeCountTv.setText(String.valueOf(commentEntity.getVote()));
if (commentEntity.getVote() == 0) {
commentLikeCountTv.setVisibility(View.GONE);
} else {
commentLikeCountTv.setVisibility(View.VISIBLE);
}
if (e instanceof HttpException) {
HttpException exception = (HttpException) e;
if (exception.code() == 403) {
try {
String detail = new JSONObject(exception.response().errorBody().string()).getString("detail");
if ("voted".equals(detail)) {
Utils.toast(context, "已经点过赞啦!");
}
} catch (Exception ex) {
ex.printStackTrace();
}
return;
}
}
Utils.toast(context, "网络异常,点赞失败");
}
});
CheckLoginUtils.checkLogin(context, () -> {
if (commentLikeCountTv.getCurrentTextColor() == ContextCompat.getColor(context, R.color.theme)) {
Utils.toast(context, "已经点过赞啦!");
return;
}
commentEntity.setVote(commentEntity.getVote() + 1);
commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.theme));
commentLikeIv.setImageResource(R.drawable.ic_like_select);
commentLikeCountTv.setText(String.valueOf(commentEntity.getVote()));
commentLikeCountTv.setVisibility(View.VISIBLE);
PostCommentUtils.addCommentVoto(context, commentEntity.getId(),
new PostCommentUtils.PostCommentListener() {
@Override
public void postSuccess(JSONObject response) {
if (listener != null) {
listener.onVote();
}
}
@Override
public void postFailed(Throwable e) {
commentEntity.setVote(commentEntity.getVote() - 1);
commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.hint));
commentLikeIv.setImageResource(R.drawable.ic_like_unselect);
commentLikeCountTv.setText(String.valueOf(commentEntity.getVote()));
if (commentEntity.getVote() == 0) {
commentLikeCountTv.setVisibility(View.GONE);
} else {
commentLikeCountTv.setVisibility(View.VISIBLE);
}
if (e instanceof HttpException) {
HttpException exception = (HttpException) e;
if (exception.code() == 403) {
try {
String detail = new JSONObject(exception.response().errorBody().string()).getString("detail");
if ("voted".equals(detail)) {
Utils.toast(context, "已经点过赞啦!");
}
} catch (Exception ex) {
ex.printStackTrace();
}
return;
}
}
Utils.toast(context, "网络异常,点赞失败");
}
});
});
}
public static void postVoteToAnswerComment(final Context context, String answerId, final CommentEntity commentEntity,
final TextView commentLikeCountTv, final ImageView commentLikeIv, final OnVoteListener listener) {
CheckLoginUtils.checkLogin(context, () -> {
if (commentLikeCountTv.getCurrentTextColor() == ContextCompat.getColor(context, R.color.theme)) {
Utils.toast(context, "已经点过赞啦!");
return;
}
commentEntity.setVote(commentEntity.getVote() + 1);
commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.theme));
commentLikeIv.setImageResource(R.drawable.ic_like_select);
commentLikeCountTv.setText(String.valueOf(commentEntity.getVote()));
commentLikeCountTv.setVisibility(View.VISIBLE);
PostCommentUtils.voteAnswerComment(context, answerId, commentEntity.getId(),
new PostCommentUtils.PostCommentListener() {
@Override
public void postSuccess(JSONObject response) {
if (listener != null) {
listener.onVote();
}
}
@Override
public void postFailed(Throwable e) {
commentEntity.setVote(commentEntity.getVote() - 1);
commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.hint));
commentLikeIv.setImageResource(R.drawable.ic_like_unselect);
commentLikeCountTv.setText(String.valueOf(commentEntity.getVote()));
if (commentEntity.getVote() == 0) {
commentLikeCountTv.setVisibility(View.GONE);
} else {
commentLikeCountTv.setVisibility(View.VISIBLE);
}
if (e instanceof HttpException) {
HttpException exception = (HttpException) e;
if (exception.code() == 403) {
try {
String detail = new JSONObject(exception.response().errorBody().string()).getString("detail");
if ("voted".equals(detail)) {
Utils.toast(context, "已经点过赞啦!");
}
} catch (Exception ex) {
ex.printStackTrace();
}
return;
}
}
Utils.toast(context, "网络异常,点赞失败");
}
});
});
}
@ -275,7 +440,7 @@ public class CommentUtils {
if (entity.getVote() == 0) {
holder.commentLikeCountTv.setVisibility(View.GONE);
} else { // 检查是否已点赞
if (userDataEntity != null && userDataEntity.isCommentVoted()) {
if (userDataEntity != null && (userDataEntity.isCommentVoted() || userDataEntity.isAnswerCommentVoted())) {
holder.commentLikeCountTv.setTextColor(ContextCompat.getColor(mContext, R.color.theme));
holder.commentLikeIv.setImageResource(R.drawable.ic_like_select);
}
@ -286,10 +451,18 @@ public class CommentUtils {
//检查是否是自身评论
UserInfoEntity userInfo = UserManager.getInstance().getUserInfoEntity();
if (userDataEntity != null && userDataEntity.isCommentOwn() && userInfo != null) {
holder.commentUserNameTv.setText(userInfo.getName());
if (entity.getUserData() != null && entity.getUserData().isAnswerOwn()) {
holder.commentUserNameTv.setText(userInfo.getName() + "(作者)");
} else {
holder.commentUserNameTv.setText(userInfo.getName());
}
ImageUtils.Companion.display(holder.commentUserIconDv, userInfo.getIcon());
} else {
holder.commentUserNameTv.setText(entity.getUser().getName());
if (entity.getUserData() != null && entity.getUserData().isAnswerOwn()) {
holder.commentUserNameTv.setText(entity.getUser().getName() + "(作者)");
} else {
holder.commentUserNameTv.setText(entity.getUser().getName());
}
if (TextUtils.isEmpty(entity.getUser().getIcon())) {
ImageUtils.Companion.display(holder.commentUserIconDv, R.drawable.user_default_icon_comment);
} else {
@ -298,6 +471,15 @@ public class CommentUtils {
}
}
//复制文字
public static void copyText(String copyContent, Context context) {
ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
cmb.setText(copyContent);
Utils.toast(context, "复制成功");
}
public interface OnVoteListener {
void onVote();
}

View File

@ -2,6 +2,7 @@ package com.gh.common.util
import android.content.Context
import com.gh.gamecenter.eventbus.EBConcernChanged
import com.gh.gamecenter.manager.UserManager
import com.gh.gamecenter.retrofit.Response
import com.gh.gamecenter.retrofit.RetrofitManager
import okhttp3.MediaType
@ -20,11 +21,11 @@ import rx.schedulers.Schedulers
object ConcernUtils {
fun postConcernGameId(context: Context, gameId: String, listener: onConcernListener?) {
val params = JSONArray()
params.put(gameId)
val body = RequestBody.create(MediaType.parse("application/json"), params.toString())
// val params = JSONArray()
// params.put(gameId)
// val body = RequestBody.create(MediaType.parse("application/json"), params.toString())
RetrofitManager.getInstance(context).getApi()
.postConcern(body)
.postConcern(UserManager.getInstance().userId, gameId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Response<ResponseBody>() {
@ -43,7 +44,7 @@ object ConcernUtils {
fun deleteConcernData(context: Context, gameId: String, listener: onConcernListener?) {
RetrofitManager.getInstance(context).getApi()
.deleteConcern(gameId)
.deleteConcern(UserManager.getInstance().userId, gameId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Response<ResponseBody>() {
@ -64,7 +65,7 @@ object ConcernUtils {
val body = RequestBody.create(MediaType.parse("application/json"),
data.toString())
RetrofitManager.getInstance(context).getApi()
.putConcern(body)
.putConcern(UserManager.getInstance().userId, body)
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.io())
.subscribe(object : Response<ResponseBody>() {
@ -77,7 +78,7 @@ object ConcernUtils {
fun deleteConcernQuestions(context: Context, questionsId: String, listener: onConcernListener?) {
RetrofitManager.getInstance(context).getApi()
.deleteConcernQuestions(questionsId)
.deleteConcernQuestions(UserManager.getInstance().userId, questionsId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Response<ResponseBody>() {
@ -96,7 +97,7 @@ object ConcernUtils {
fun postConcernQuestions(context: Context, questionsId: String, listener: onConcernListener?) {
RetrofitManager.getInstance(context).getApi()
.postConcernQuestions(questionsId)
.postConcernQuestions(UserManager.getInstance().userId, questionsId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Response<ResponseBody>() {

View File

@ -1,11 +1,12 @@
package com.gh.gamecenter;
package com.gh.common.util;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.text.TextUtils;
import com.gh.common.constant.Config;
import com.gh.common.util.PackageUtils;
import com.lightgame.config.CommonDebug;
import com.tencent.bugly.crashreport.CrashReport;
import com.tencent.stat.MtaSDkException;
import com.tencent.stat.StatConfig;
@ -32,6 +33,9 @@ public class DataUtils {
*/
public static void init(final Application context, String channel) {
if (CommonDebug.IS_DEBUG) {
return;
}
//TalkingData
try {
TCAgent.LOG_ON = false;
@ -81,7 +85,7 @@ public class DataUtils {
// init bugly
try {
CrashReport.setIsDevelopmentDevice(context, false);
CrashReport.setIsDevelopmentDevice(context, "GH_TEST".equals(channel));
CrashReport.UserStrategy strategy = new CrashReport.UserStrategy(context);
strategy.setEnableANRCrashMonitor(false);
@ -97,9 +101,29 @@ public class DataUtils {
}
// MTA ->次数统计Key-Value参数的事件
public static void onMtaEvent(Context context, String eventId, String... kv) {
if (CommonDebug.IS_DEBUG && (kv == null || kv.length % 2 != 0)) {
throw new IllegalStateException("onEvent kv 必须不为空且数量为偶数");
}
Properties prop = new Properties();
for (int i = 0; i < kv.length; i++) {
if (i % 2 != 0 || i != 0) {
String key = kv[i - 1];
String value = kv[i];
if (!TextUtils.isEmpty(key) && !TextUtils.isEmpty(value)) {
prop.setProperty(key, value);
}
}
}
StatService.trackCustomKVEvent(context, eventId, prop);
}
public static void onEvent(Context var0, String var1, String var2) {
TCAgent.onEvent(var0, var1, var2);
StatService.trackCustomEvent(var0, var1, var2);
Properties prop = new Properties();
prop.setProperty(var1, var2);
StatService.trackCustomKVEvent(var0, var1, prop);
}
public static void onPause(Activity var0) {

View File

@ -1,10 +1,10 @@
package com.gh.common.util;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.view.View;
import com.gh.common.constant.Config;
import com.gh.common.view.DownloadProgressBar;
import com.gh.download.DownloadManager;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.viewholder.DetailViewHolder;
@ -19,118 +19,56 @@ import com.lightgame.download.DownloadEntity;
public class DetailDownloadUtils {
public static void detailInitDownload(DetailViewHolder viewHolder, boolean isCheck) {
if (Config.isShow(viewHolder.context)) {
if (viewHolder.gameEntity != null
&& Config.isShowDownload(viewHolder.gameEntity.getId())
&& !"光环助手".equals(viewHolder.gameEntity.getName())) {
viewHolder.downloadBottom.setVisibility(View.VISIBLE);
} else {
viewHolder.downloadBottom.setVisibility(View.GONE);
return;
}
if (viewHolder.gameEntity != null && "光环助手".equals(viewHolder.gameEntity.getName())) {
viewHolder.downloadBottom.setVisibility(View.GONE);
} else if (viewHolder.gameEntity == null || viewHolder.gameEntity.getApk().isEmpty()) {
viewHolder.downloadTv.setVisibility(View.VISIBLE);
viewHolder.downloadPb.setVisibility(View.GONE);
viewHolder.downloadPer.setVisibility(View.GONE);
if (TextUtils.isEmpty(viewHolder.downloadOffText)) {
viewHolder.downloadTv.setText("暂无下载");
} else {
viewHolder.downloadTv.setText(viewHolder.downloadOffText);
}
viewHolder.downloadTv.setBackgroundResource(R.drawable.game_item_btn_pause_style);
viewHolder.downloadTv.setTextColor(0xFF999999);
viewHolder.downloadTv.setClickable(false);
} else {
viewHolder.downloadTv.setVisibility(View.VISIBLE);
viewHolder.downloadPb.setVisibility(View.GONE);
viewHolder.downloadPer.setVisibility(View.GONE);
boolean isInstalled = false;
if (viewHolder.gameEntity.getApk().size() == 1
&& PackageManager.isInstalled(viewHolder.gameEntity.getApk().get(0).getPackageName())) {
isInstalled = true;
}
if (isInstalled) {
if (PackageManager.isCanUpdate(viewHolder.gameEntity.getId(), viewHolder.gameEntity.getApk().get(0).getPackageName())) {
if (viewHolder.isNewsDetail) {
viewHolder.downloadTv.setText(R.string.update);
} else if (TextUtils.isEmpty(viewHolder.downloadAddWord)) {
viewHolder.downloadTv.setText(String.format("更新《%s》",
viewHolder.gameEntity.getName()));
} else {
viewHolder.downloadTv.setText(String.format("更新《%s》%s",
viewHolder.gameEntity.getName(), viewHolder.downloadAddWord));
}
viewHolder.downloadTv.setBackgroundResource(
R.drawable.game_item_btn_download_style);
} else {
if (viewHolder.gameEntity.getTag() != null && viewHolder.gameEntity.getTag().size() != 0
&& !TextUtils.isEmpty(viewHolder.gameEntity.getApk().get(0).getGhVersion())
&& !PackageUtils.isSignature(viewHolder.context, viewHolder.gameEntity.getApk().get(0).getPackageName())) {
if (viewHolder.isNewsDetail) {
viewHolder.downloadTv.setText(R.string.pluggable);
} else if (TextUtils.isEmpty(viewHolder.downloadAddWord)) {
viewHolder.downloadTv.setText(String.format("插件化《%s》",
viewHolder.gameEntity.getName()));
} else {
viewHolder.downloadTv.setText(String.format("插件化《%s》%s",
viewHolder.gameEntity.getName(), viewHolder.downloadAddWord));
}
viewHolder.downloadTv.setBackgroundResource(
R.drawable.game_item_btn_plugin_style);
} else {
if (viewHolder.isNewsDetail) {
viewHolder.downloadTv.setText(R.string.launch);
} else if (TextUtils.isEmpty(viewHolder.downloadAddWord)) {
viewHolder.downloadTv.setText(String.format("启动《%s》",
viewHolder.gameEntity.getName()));
} else {
viewHolder.downloadTv.setText(String.format("启动《%s》%s",
viewHolder.gameEntity.getName(), viewHolder.downloadAddWord));
}
viewHolder.downloadTv.setBackgroundResource(
R.drawable.game_item_btn_launch_style);
}
}
} else {
String status = GameUtils.getDownloadBtnText(viewHolder.context, viewHolder.gameEntity);
switch (status) {
case "插件化":
viewHolder.downloadTv.setBackgroundResource(R.drawable.game_item_btn_plugin_style);
break;
case "打开":
viewHolder.downloadTv.setBackgroundResource(R.drawable.game_item_btn_launch_style);
break;
default:
viewHolder.downloadTv.setBackgroundResource(R.drawable.game_item_btn_download_style);
break;
}
if (viewHolder.isNewsDetail) {
viewHolder.downloadTv.setText(status);
} else if (TextUtils.isEmpty(viewHolder.downloadAddWord)) {
viewHolder.downloadTv.setText(String.format(status + "《%s》",
viewHolder.gameEntity.getName()));
} else {
viewHolder.downloadTv.setText(String.format(status + "《%s》%s",
viewHolder.gameEntity.getName(), viewHolder.downloadAddWord));
}
if (viewHolder.gameEntity.getApk().isEmpty()) {
viewHolder.mDownloadPb.setText(TextUtils.isEmpty(viewHolder.downloadOffText) ? "暂无下载" : viewHolder.downloadOffText);
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.NONE);
} else {
String status = GameUtils.getDownloadBtnText(viewHolder.context, viewHolder.gameEntity);
switch (status) {
case "插件化":
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.PLUGIN);
break;
case "打开":
if (viewHolder.gameEntity.getApk().size() == 1) {
status = "启动";
}
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.LAUNCH_OR_OPEN);
break;
default:
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.NORMAL);
break;
}
if (viewHolder.isNewsDetail) {
viewHolder.mDownloadPb.setText(status);
} else if (TextUtils.isEmpty(viewHolder.downloadAddWord)) {
viewHolder.mDownloadPb.setText(String.format(status + "《%s》", viewHolder.gameEntity.getName()));
} else {
viewHolder.mDownloadPb.setText(String.format(status + "《%s》%s", viewHolder.gameEntity.getName(), viewHolder.downloadAddWord));
}
}
if (isCheck && viewHolder.gameEntity != null
&& viewHolder.gameEntity.getApk().size() == 1) {
if (isCheck && viewHolder.gameEntity.getApk().size() == 1) {
String url = viewHolder.gameEntity.getApk().get(0).getUrl();
DownloadEntity downloadEntity = DownloadManager.getInstance(viewHolder.context).getDownloadEntityByUrl(url);
if (downloadEntity != null) {
viewHolder.downloadEntity = downloadEntity;
viewHolder.downloadTv.setVisibility(View.GONE);
viewHolder.downloadPb.setVisibility(View.VISIBLE);
viewHolder.downloadPer.setVisibility(View.VISIBLE);
detailInvalidate(viewHolder);
}
}
}
public static void detailInvalidate(DetailViewHolder viewHolder) {
viewHolder.downloadPb.setProgress((int) (viewHolder.downloadEntity.getPercent() * 10));
viewHolder.downloadPer.setTextColor(0xFFFFFFFF);
viewHolder.mDownloadPb.setProgress((int) (viewHolder.downloadEntity.getPercent() * 10));
DownloadEntity downloadEntity = viewHolder.downloadEntity;
switch (downloadEntity.getStatus()) {
case downloading:
@ -138,15 +76,20 @@ public class DetailDownloadUtils {
case timeout:
case neterror:
case waiting:
viewHolder.downloadPer.setText(R.string.downloading);
viewHolder.mDownloadPb.setText(R.string.downloading);
if (downloadEntity.isPluggable() && PackageManager.isInstalled(downloadEntity.getPackageName())) {
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.DOWNLOADING_PLUGIN);
} else {
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.DOWNLOADING_NORMAL);
}
break;
case done:
viewHolder.downloadPer.setText("安装");
viewHolder.mDownloadPb.setText(R.string.install);
if (downloadEntity.isPluggable()
&& PackageManager.isInstalled(downloadEntity.getPackageName())) {
viewHolder.downloadPb.setProgressDrawable(ContextCompat.getDrawable(viewHolder.context, R.drawable.progressbar_plugin_radius_style));
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.INSTALL_PLUGIN);
} else {
viewHolder.downloadPb.setProgressDrawable(ContextCompat.getDrawable(viewHolder.context, R.drawable.progressbar_normal_radius_style));
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.INSTALL_NORMAL);
}
break;
case cancel:

View File

@ -154,7 +154,7 @@ public class DeviceUtils {
return null;
}
private static String getNetwork(Context context) {
public static String getNetwork(Context context) {
NetworkInfo info = ((ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo();
if (info != null && info.isConnected()) {

View File

@ -327,7 +327,7 @@ public class DialogUtils {
public static void showWarningDialog(Context context, String title, CharSequence msg, final ConfirmListener listener) {
//TODO fix this
if (!(context instanceof Activity)) {
return ;
return;
}
showWarningDialog(context, title, msg, "取消", "确定", listener, null);
}
@ -525,7 +525,7 @@ public class DialogUtils {
@Override
public void onCancel(DialogInterface dialogInterface) {
if (clListener != null)
clListener.onCancel();
clListener.onCancel();
}
});
dialog.show();
@ -671,6 +671,44 @@ public class DialogUtils {
}
public static void showSignDialog(Context context, String title, CharSequence message, CharSequence message2
, String positive, final ConfirmListener cmListener) {
final Dialog dialog = new Dialog(context);
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_sign, null);
TextView contentTv = contentView.findViewById(R.id.dialog_content);
TextView titleTv = contentView.findViewById(R.id.dialog_title);
TextView negativeTv = contentView.findViewById(R.id.dialog_negative);
TextView positiveTv = contentView.findViewById(R.id.dialog_positive);
TextView content2Tv = contentView.findViewById(R.id.dialog_content2);
contentTv.setText(Html.fromHtml(message.toString()));
content2Tv.setText(Html.fromHtml(message2.toString()));
titleTv.setText(title);
positiveTv.setText(positive);
negativeTv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog.dismiss();
}
});
positiveTv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (cmListener != null) {
cmListener.onConfirm();
}
dialog.dismiss();
}
});
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(contentView);
dialog.show();
}
public interface ConfirmListener {
void onConfirm();
}

View File

@ -13,7 +13,6 @@ import android.widget.TextView;
import com.gh.common.constant.Config;
import com.gh.common.view.DownloadDialog;
import com.gh.download.DownloadManager;
import com.gh.gamecenter.DataUtils;
import com.gh.gamecenter.DownloadManagerActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.viewholder.GameViewHolder;
@ -61,9 +60,10 @@ public class DownloadItemUtils {
gameEntity.setEntryMap(entryMap);
}
entryMap.put(platform, downloadEntity);
if (!DownloadStatus.pause.equals(DownloadManager.getInstance(context).getStatus(downloadEntity.getUrl()))) {
adapter.notifyItemChanged(index);
}
adapter.notifyItemChanged(index);
// if (!DownloadStatus.pause.equals(DownloadManager.getInstance(context).getStatus(downloadEntity.getUrl()))) {
// adapter.notifyItemChanged(index);
// }
} else {
if (!queue.contains(platform)) {
queue.offer(platform);
@ -95,7 +95,7 @@ public class DownloadItemUtils {
public static void updateItem(Context context, GameEntity gameEntity, GameViewHolder holder, boolean isShowPlatform) {
// 控制是否显示下载按钮
if (!Config.isShow(context) || context.getString(R.string.app_name).equals(gameEntity.getName())) {
if (!Config.isShowDownload(gameEntity.getId()) || context.getString(R.string.app_name).equals(gameEntity.getName())) {
holder.gameDownloadBtn.setVisibility(View.GONE);
} else {
holder.gameDownloadBtn.setVisibility(View.VISIBLE);
@ -111,8 +111,9 @@ public class DownloadItemUtils {
holder.gameDes.setVisibility(View.VISIBLE);
holder.gameProgressbar.setVisibility(View.GONE);
holder.gameInfo.setVisibility(View.GONE);
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_pause_style);
holder.gameDownloadBtn.setBackgroundResource(R.drawable.news_detail_comment);
holder.gameDownloadBtn.setText("暂无");
holder.gameDownloadBtn.setTextColor(ContextCompat.getColor(context, R.color.button_gray));
holder.gameDownloadBtn.setClickable(false);
} else if (gameEntity.getApk().size() == 1) {
updateNormalItem(context, holder, gameEntity, isShowPlatform);
@ -155,14 +156,19 @@ public class DownloadItemUtils {
holder.gameDownloadBtn.setText(R.string.update);
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_download_style);
} else {
Object gh_id = PackageUtils.getMetaData(context, packageName, "gh_id");
if (gameEntity.getTag() != null && gameEntity.getTag().size() != 0
&& !TextUtils.isEmpty(apkEntity.getGhVersion())
&& !PackageUtils.isSignature(context, packageName)) {
holder.gameDownloadBtn.setText(R.string.pluggable);
setwhat(context, holder, apkEntity, packageName);
} else {
} else if (gh_id == null || gh_id.equals(gameEntity.getId())) {
holder.gameDownloadBtn.setText(R.string.launch);
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_launch_style);
holder.gameDownloadBtn.setTextColor(ContextCompat.getColor(context, R.color.theme));
holder.gameDownloadBtn.setBackgroundResource(R.drawable.detail_downloading_normal_style);
} else {
holder.gameDownloadBtn.setText(R.string.download);
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_download_style);
}
}
} else {
@ -439,7 +445,7 @@ public class DownloadItemUtils {
if (downloadEntity != null) {
final String path = downloadEntity.getPath();
if (FileUtils.isEmptyFile(path)) {
Utils.toast(context, context.getString(R.string.install_failure_hint));
Utils.toast(context, R.string.install_failure_hint);
DownloadManager.getInstance(context).cancel(downloadEntity.getUrl());
if (gameEntity.getEntryMap() != null) {
gameEntity.getEntryMap().remove(apkEntity.getPlatform());

View File

@ -64,7 +64,15 @@ public class EntranceUtils {
public static final String KEY_ANSWER_CONTENT = "answerContent";
public static final String KEY_QUESTIONS_ID = "questionsId";
public static final String KEY_QUESTIONS_TITLE = "questionsTitle";
public static final String KEY_ANSWER_OPEN_IN_NEW_PAGE = "openInNewPage";
public static final String KEY_QUESTIONS_PATCH = "questionsPatch";
public static final String KEY_INVITE_SEARCH_KEY = "inviteSearchKey";
public static final String KEY_MESSAGE_TYPE = "messageType";
public static final String KEY_QUESTIONS_SEARCH_KEY = "questionsSearchKey";
public static final String KEY_SHOW_ANSWER_COMMENT = "showAnswerComment";
public static final String KEY_VERSION_UPDATE = "versionUpdate";
public static final String KEY_CHECK_QUESTION_CONCERN = "check_question_concern";
public static final String KEY_DRAFT_ID = "draft_id";
public static void jumpActivity(Context context, Bundle bundle) {
@ -76,12 +84,12 @@ public class EntranceUtils {
if (!TextUtils.isEmpty(to)) {
Class<?> clazz = ClassUtils.forName(to);
if (clazz != null) {
if (NormalFragment.class.isAssignableFrom(clazz)) { // todo
NormalActivity.startFragment(context, (Class<? extends NormalFragment>) clazz, bundle);
if (NormalFragment.class.isAssignableFrom(clazz)) { // 兼容NormalFragment
NormalActivity.startFragmentNewTask(context, (Class<? extends NormalFragment>) clazz, bundle);
} else {
Intent intent1 = new Intent(context, clazz);
intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent1.putExtra(KEY_DATA, bundle);
intent1.putExtras(bundle);
context.startActivity(intent1);
}
}

View File

@ -2,6 +2,7 @@ package com.gh.common.util;
import android.content.Context;
import android.graphics.Color;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.widget.TextView;
@ -51,7 +52,8 @@ public class GameUtils {
if ("插件化".equals(status)) {
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_plugin_style);
} else if ("打开".equals(status)) {
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_launch_style);
downloadBtn.setBackgroundResource(R.drawable.detail_downloading_normal_style);
downloadBtn.setTextColor(ContextCompat.getColor(context, R.color.theme));
} else {
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_download_style);
}

View File

@ -173,7 +173,9 @@ public class GetLoginDataUtils {
}
public void WCLofinCallBack(JSONObject content) {
mLoginListener.OnLoginData(content, LoginTag.wechat);
if (mLoginListener != null) {
mLoginListener.OnLoginData(content, LoginTag.wechat);
}
}
public void onWeiboCallback(int requestCode, int resultCode, Intent data) {

View File

@ -7,6 +7,7 @@ import android.graphics.drawable.ColorDrawable
import android.net.Uri
import android.support.annotation.DrawableRes
import android.support.v4.content.ContextCompat
import android.text.TextUtils
import com.facebook.common.executors.CallerThreadExecutor
import com.facebook.drawee.backends.pipeline.Fresco
import com.facebook.drawee.controller.BaseControllerListener
@ -22,6 +23,7 @@ import com.gh.common.constant.Config
import com.gh.gamecenter.R
import com.gh.gamecenter.manager.UserManager
import com.gh.gamecenter.retrofit.Response
import com.lightgame.config.CommonDebug
import com.lightgame.download.FileUtils
import com.lightgame.utils.Utils
import org.json.JSONObject
@ -36,28 +38,48 @@ import java.net.HttpURLConnection
class ImageUtils private constructor() {
// 自适应图片宽高
fun display(simpleDraweeView: SimpleDraweeView, url: String?, width: Int) {
fun display(simpleDraweeView: SimpleDraweeView?, url: String?, width: Int) {
val listener = object : BaseControllerListener<ImageInfo>() {
override fun onFinalImageSet(id: String?, imageInfo: ImageInfo?, animatable: Animatable?) {
if (imageInfo == null) {
return
}
val layoutParams = simpleDraweeView.layoutParams
val layoutParams = simpleDraweeView?.layoutParams
val scale = imageInfo.height.toFloat() / imageInfo.width.toFloat()
layoutParams.height = (width * scale).toInt()
simpleDraweeView.layoutParams = layoutParams
layoutParams?.height = (width * scale).toInt()
simpleDraweeView?.layoutParams = layoutParams
}
}
simpleDraweeView.controller = Fresco.newDraweeControllerBuilder()
simpleDraweeView?.controller = Fresco.newDraweeControllerBuilder()
.setUri(url)
.setControllerListener(listener)
.build()
}
// 自适应图片宽高
fun displayScale(simpleDraweeView: SimpleDraweeView?, url: String?, height: Int) {
val listener = object : BaseControllerListener<ImageInfo>() {
override fun onFinalImageSet(id: String?, imageInfo: ImageInfo?, animatable: Animatable?) {
if (imageInfo == null) {
return
}
val layoutParams = simpleDraweeView?.layoutParams
val scale = imageInfo.width.toFloat()/imageInfo.height.toFloat()
layoutParams?.width = (height * scale).toInt()
simpleDraweeView?.layoutParams = layoutParams
}
}
simpleDraweeView?.controller = Fresco.newDraweeControllerBuilder()
.setUri(url)
.setControllerListener(listener)
.build()
}
// 设置缩放类型,设置按压状态下的叠加图
fun display(resources: Resources, simpleDraweeView: SimpleDraweeView,
scaleType: ScalingUtils.ScaleType, url: String?) {
val context = simpleDraweeView.context
fun display(resources: Resources?, simpleDraweeView: SimpleDraweeView?,
scaleType: ScalingUtils.ScaleType?, url: String?) {
if (simpleDraweeView == null) return
val context = simpleDraweeView.context ?: return
simpleDraweeView.hierarchy = GenericDraweeHierarchyBuilder(resources)
.setFadeDuration(500)
.setPressedStateOverlay(ColorDrawable(ContextCompat.getColor(context, R.color.pressed_bg)))
@ -70,8 +92,9 @@ class ImageUtils private constructor() {
}
// 设置占位符
fun display(resources: Resources, simpleDraweeView: SimpleDraweeView, url: String?, placeholderImage: Int) {
val context = simpleDraweeView.context
fun display(resources: Resources?, simpleDraweeView: SimpleDraweeView?, url: String?, placeholderImage: Int) {
if (simpleDraweeView == null) return
val context = simpleDraweeView.context ?: return
simpleDraweeView.hierarchy = GenericDraweeHierarchyBuilder(resources)
.setFadeDuration(500)
.setPressedStateOverlay(ColorDrawable(ContextCompat.getColor(context, R.color.pressed_bg)))
@ -83,9 +106,9 @@ class ImageUtils private constructor() {
}
// 图片下载监听和设置低高分辨率图片
fun display(simpleDraweeView: SimpleDraweeView, url: String?, lowUrl: String?,
fun display(simpleDraweeView: SimpleDraweeView?, url: String?, lowUrl: String?,
listener: ControllerListener<in ImageInfo>) {
simpleDraweeView.controller = Fresco.newDraweeControllerBuilder()
simpleDraweeView?.controller = Fresco.newDraweeControllerBuilder()
.setImageRequest(ImageRequest.fromUri(url))
.setControllerListener(listener)
.setLowResImageRequest(ImageRequest.fromUri(lowUrl)) // 低分辨率图片
@ -93,7 +116,7 @@ class ImageUtils private constructor() {
}
// 获取bitmap
fun display(context: Context, url: String?, dataSubscriber: BaseBitmapDataSubscriber) {
fun display(context: Context?, url: String?, dataSubscriber: BaseBitmapDataSubscriber) {
val imageRequest = ImageRequestBuilder
.newBuilderWithSource(Uri.parse(url))
.setProgressiveRenderingEnabled(true)
@ -132,10 +155,10 @@ class ImageUtils private constructor() {
for (s in imgArr) {
path = context.getCacheDir().path + File.separator + System.currentTimeMillis() + index + ".jpg"
if (BitmapUtils.savePicture(path, s, 200000)) {
subscriber.onNext(FileUtils.uploadFile(Config.API_HOST + "support/upload/img?type=community", path, s, UserManager.getInstance().token))
subscriber.onNext(FileUtils.uploadFile(Config.API_HOST + "images?type=community", path, s, UserManager.getInstance().token))
index++
} else {
subscriber.onNext(FileUtils.uploadFile(Config.API_HOST + "support/upload/img?type=community", s, s, UserManager.getInstance().token))
subscriber.onNext(FileUtils.uploadFile(Config.API_HOST + "images?type=community", s, s, UserManager.getInstance().token))
}
}
subscriber.onCompleted()
@ -169,18 +192,22 @@ class ImageUtils private constructor() {
})
}
fun postImage(context: Context, picturePath: String, listener: OnPostImageListener) {
fun postImage(context: Context?, picturePath: String?, listener: OnPostImageListener) {
if (context == null || TextUtils.isEmpty(picturePath)) return
Observable.create(Observable.OnSubscribe<JSONObject> { subscriber ->
val path = context.getCacheDir().path + File.separator + System.currentTimeMillis() + ".jpg"
if (BitmapUtils.savePicture(path, picturePath, 200000)) {
subscriber.onNext(FileUtils.uploadFile(Config.API_HOST + "support/upload/img?type=community", path, UserManager.getInstance().token))
subscriber.onNext(FileUtils.uploadFile(Config.API_HOST + "images?type=community", path, UserManager.getInstance().token))
} else {
subscriber.onNext(FileUtils.uploadFile(Config.API_HOST + "support/upload/img?type=community", picturePath, UserManager.getInstance().token))
subscriber.onNext(FileUtils.uploadFile(Config.API_HOST + "images?type=community", picturePath, UserManager.getInstance().token))
}
}).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Response<JSONObject>() {
override fun onResponse(response: JSONObject?) {
if (CommonDebug.IS_DEBUG) {
Utils.log("postImage:onResponse=>" + response.toString())
}
listener.postSuccess(response)
}
@ -193,7 +220,6 @@ class ImageUtils private constructor() {
}
interface OnPostImageListener {
fun postSuccess(response: JSONObject?)

View File

@ -26,6 +26,7 @@ import com.gh.gamecenter.eventbus.EBReuse;
import com.gh.gamecenter.eventbus.EBUISwitch;
import com.gh.gamecenter.geetest.GeetestListener;
import com.gh.gamecenter.geetest.GeetestUtils;
import com.gh.gamecenter.manager.UserManager;
import com.gh.gamecenter.retrofit.JSONObjectResponse;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
@ -118,7 +119,7 @@ public class LibaoUtils {
public static void deleteLibaoCode(final Context context, final String code,
final PostLibaoListener listener) {
RetrofitManager.getInstance(context).getApi().deleteLibaoCode(code)
RetrofitManager.getInstance(context).getApi().deleteLibaoCode(UserManager.getInstance().getUserId(), code)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<ResponseBody>() {
@ -135,7 +136,7 @@ public class LibaoUtils {
}
public static void getLibaoStatus(Context context, String ids, final PostLibaoListener listener) {
RetrofitManager.getInstance(context).getApi().getLibaoStatus(ids)
RetrofitManager.getInstance(context).getApi().getLibaoStatus(UrlFilterUtils.getFilterQuery("libao_ids", ids))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<List<LibaoStatusEntity>>() {
@ -151,147 +152,236 @@ public class LibaoUtils {
});
}
public static void initLibaoBtn(final Context context, final TextView libaoBtn, final LibaoEntity libaoEntity,
final boolean isInstallRequired, final LibaoDetailAdapter adapter, final String entrance) {
public static void setLiBaoBtnStatus(final TextView libaoBtn, String status, Context context) {
libaoBtn.setTextColor(Color.WHITE);
final String status = libaoEntity.getStatus();
if (TextUtils.isEmpty(status)) return;
switch (status) {
case "coming":
libaoBtn.setText(R.string.libao_coming);
libaoBtn.setBackgroundResource(R.drawable.textview_blue_style);
break;
case "ling":
libaoBtn.setText(R.string.libao_ling);
libaoBtn.setBackgroundResource(R.drawable.textview_green_style);
libaoBtn.setBackgroundResource(R.drawable.button_normal_style);
break;
case "tao":
libaoBtn.setText(R.string.libao_tao);
libaoBtn.setBackgroundResource(R.drawable.textview_orange_style);
libaoBtn.setBackgroundResource(R.drawable.button_normal_style);
break;
case "coming":
libaoBtn.setText(R.string.libao_coming);
libaoBtn.setBackgroundResource(R.drawable.button_normal_border);
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme));
break;
case "used_up":
libaoBtn.setText(R.string.libao_used_up);
libaoBtn.setBackgroundResource(R.drawable.textview_cancel_up);
libaoBtn.setBackgroundResource(R.drawable.button_normal_border);
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme));
break;
case "finish":
libaoBtn.setText(R.string.libao_finish);
libaoBtn.setBackgroundResource(R.drawable.textview_cancel_up);
libaoBtn.setBackgroundResource(R.drawable.button_border_gray);
libaoBtn.setTextColor(context.getResources().getColor(R.color.button_gray));
break;
case "linged":
libaoBtn.setText(R.string.libao_linged);
libaoBtn.setBackgroundResource(R.drawable.libao_linged_style);
libaoBtn.setTextColor(ContextCompat.getColorStateList(context, R.color.libao_linged_selector));
libaoBtn.setBackgroundResource(R.drawable.button_normal_border);
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme));
break;
case "taoed":
libaoBtn.setText(R.string.libao_taoed);
libaoBtn.setBackgroundResource(R.drawable.libao_taoed_style);
libaoBtn.setTextColor(ContextCompat.getColorStateList(context, R.color.libao_taoed_selector));
libaoBtn.setBackgroundResource(R.drawable.button_normal_border);
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme));
break;
case "copy":
libaoBtn.setText(R.string.libao_copy);
libaoBtn.setBackgroundResource(R.drawable.textview_blue_style);
libaoBtn.setBackgroundResource(R.drawable.button_normal_style);
break;
case "repeatLing":
libaoBtn.setText(R.string.libao_repeat_ling);
libaoBtn.setBackgroundResource(R.drawable.textview_cancel_up);
libaoBtn.setBackgroundResource(R.drawable.button_normal_border);
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme));
break;
case "repeatLinged":
libaoBtn.setText(R.string.libao_repeat_ling);
libaoBtn.setBackgroundResource(R.drawable.textview_green_style);
libaoBtn.setBackgroundResource(R.drawable.button_normal_style);
break;
case "repeatTao":
libaoBtn.setText(R.string.libao_repeat_tao);
libaoBtn.setBackgroundResource(R.drawable.textview_cancel_up);
libaoBtn.setBackgroundResource(R.drawable.button_normal_border);
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme));
break;
case "repeatTaoed":
libaoBtn.setText(R.string.libao_repeat_tao);
libaoBtn.setBackgroundResource(R.drawable.textview_orange_style);
libaoBtn.setBackgroundResource(R.drawable.button_normal_style);
break;
case "unshelve":
libaoBtn.setBackgroundResource(R.drawable.textview_cancel_style);
libaoBtn.setBackgroundResource(R.drawable.button_border_gray);
libaoBtn.setText(R.string.libao_unshelve);
libaoBtn.setTextColor(context.getResources().getColor(R.color.button_gray));
break;
default:
libaoBtn.setBackgroundResource(R.drawable.textview_cancel_style);
libaoBtn.setBackgroundResource(R.drawable.button_border_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();
setLiBaoBtnStatus(libaoBtn, status, context);
libaoBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CheckLoginUtils.checkLogin(context, new CheckLoginUtils.OnLoggenInListener() {
@Override
public void onLoggedIn() {
// 领取限制
if ("领取".equals(libaoBtn.getText().toString()) || "淘号".equals(libaoBtn.getText().toString())) {
if (isInstallRequired && !isAppInstalled(context, libaoEntity.getPackageName())) {
String platform;
if (TextUtils.isEmpty(libaoEntity.getPlatform())) {
platform = "";
} else {
platform = PlatformUtils.getInstance(context)
.getPlatformName(libaoEntity.getPlatform()) + "";
}
CheckLoginUtils.checkLogin(context, () -> {
// 领取限制
if ("领取".equals(libaoBtn.getText().toString()) || "淘号".equals(libaoBtn.getText().toString())) {
if (isInstallRequired && !isAppInstalled(context, libaoEntity.getPackageName())) {
String platform;
if (TextUtils.isEmpty(libaoEntity.getPlatform())) {
platform = "";
} else {
platform = PlatformUtils.getInstance(context)
.getPlatformName(libaoEntity.getPlatform()) + "";
}
String dialogContent = context.getString(R.string.ling_rules_dialog, libaoEntity.getGame().getName(), platform);
DialogUtils.showWarningDialog(context, "条件不符",
Html.fromHtml(dialogContent), "关闭", "立即安装"
, new DialogUtils.ConfirmListener() {
@Override
public void onConfirm() {
adapter.openDownload();
}
}, null);
String dialogContent = context.getString(R.string.ling_rules_dialog, libaoEntity.getGame().getName(), platform);
DialogUtils.showWarningDialog(context, "条件不符",
Html.fromHtml(dialogContent), "关闭", "立即安装"
, new DialogUtils.ConfirmListener() {
@Override
public void onConfirm() {
adapter.openDownload();
}
}, null);
return;
}
}
switch (libaoBtn.getText().toString()) {
case "未开始":
Utils.toast(context, "还没到开始领取时间");
break;
case "查看":
Intent intent = LibaoDetailActivity.getIntent(context, libaoEntity, entrance);
context.startActivity(intent);
break;
case "再领一个":
case "领取":
if ("repeatLing".equals(status)) {
DialogUtils.showWarningDialog(context, "礼包刷新提醒"
, "礼包每天0点刷新换新区或者换新角色需要继续领取礼包的童鞋请于明天0点之后回来即可[再领一个]"
, null, "知道了", null, null);
} else {
libaoLing(context, libaoBtn, libaoEntity, adapter, isInstallRequired, null, entrance);
}
break;
case "再淘一个":
case "淘号":
if ("repeatTao".equals(status)) {
Utils.toast(context, "没到重复淘号时间, 礼包每天0点刷新");
return;
}
}
final Dialog loadingDialog = DialogUtils.showWaitDialog(context, "淘号中...");
postLibaoTao(context, libaoEntity.getId(), new PostLibaoListener() {
@Override
public void postSucced(Object response) {
switch (libaoBtn.getText().toString()) {
case "未开始":
Utils.toast(context, "还没到开始领取时间");
break;
case "查看":
Intent intent = LibaoDetailActivity.getIntent(context, libaoEntity, entrance);
context.startActivity(intent);
break;
case "再领一个":
case "领取":
if ("repeatLing".equals(status)) {
DialogUtils.showWarningDialog(context, "礼包刷新提醒"
, "礼包每天0点刷新换新区或者换新角色需要继续领取礼包的童鞋请于明天0点之后回来即可[再领一个]"
, null, "知道了", null, null);
} else {
libaoLing(context, libaoBtn, libaoEntity, adapter, isInstallRequired, null, entrance);
}
break;
case "再淘一个":
case "淘号":
if ("repeatTao".equals(status)) {
Utils.toast(context, "没到重复淘号时间, 礼包每天0点刷新");
return;
}
final Dialog loadingDialog = DialogUtils.showWaitDialog(context, "淘号中...");
postLibaoTao(context, libaoEntity.getId(), new PostLibaoListener() {
@Override
public void postSucced(Object response) {
if (loadingDialog != null) loadingDialog.dismiss();
if (loadingDialog != null) loadingDialog.dismiss();
JSONObject responseBody = (JSONObject) response;
String libaoCode = null;
try {
libaoCode = responseBody.getString("code");
} catch (JSONException e) {
e.printStackTrace();
}
JSONObject responseBody = (JSONObject) response;
String libaoCode = null;
if (TextUtils.isEmpty(libaoCode)) {
try {
libaoCode = responseBody.getString("code");
String detail = responseBody.getString("detail");
switch (detail) {
case "maintaining":
Utils.toast(context, "网络状态异常,请稍后再试");
break;
case "fail to compete":
Utils.toast(context, "淘号失败,稍后重试");
break;
default:
Utils.toast(context, "淘号异常");
break;
}
} catch (JSONException e) {
e.printStackTrace();
}
return;
}
if (TextUtils.isEmpty(libaoCode)) {
Utils.toast(context, "淘号成功");
libaoEntity.setStatus("taoed");
EventBus.getDefault().post(new EBReuse("libaoChanged"));
adapter.initLibaoCode(new UserDataLibaoEntity(libaoCode, "tao", Utils.getTime(context)));
final String finalLibaoCode = libaoCode;
DialogUtils.showWarningDialog(context, "淘号成功"
, Html.fromHtml(context.getString(R.string.taoed_dialog, libaoCode))
, "关闭", " 复制礼包码"
, new DialogUtils.ConfirmListener() {
@Override
public void onConfirm() {
copyLink(finalLibaoCode, context);
if (isInstallRequired) {
libaoBtn.postDelayed(new Runnable() {
@Override
public void run() {
Spanned msg = Html.fromHtml(
context.getString(R.string.taoed_copy_dialog
, finalLibaoCode));
lunningAppDialog(context
, msg, libaoEntity);
}
}, 300);
}
}
}, null);
}
@Override
public void postFailed(Throwable error) {
Utils.log("---" + error.toString());
if (loadingDialog != null) loadingDialog.dismiss();
if (error instanceof HttpException) {
HttpException exception = (HttpException) error;
if (exception.code() == 403) {
try {
String detail = responseBody.getString("detail");
JSONObject errorJson = new JSONObject(exception.response().errorBody().string());
String detail = errorJson.getString("detail");
// Utils.toast(context, "返回::" + detail);
switch (detail) {
case "coming":
Utils.toast(context, "礼包领取时间未开始");
break;
case "finish":
Utils.toast(context, "礼包领取时间已结束");
break;
case "fetched":
Utils.toast(context, "你今天已领过这个礼包了, 不能再淘号");
libaoBtn.setText("已淘号");
libaoBtn.setBackgroundResource(R.drawable.libao_taoed_style);
libaoBtn.setTextColor(ContextCompat.getColorStateList(context, R.color.libao_taoed_selector));
libaoEntity.setStatus("taoed");
break;
case "try tao":
case "used up":
DialogUtils.showHintDialog(context, "礼包已领光"
, "手速不够快,礼包已经被抢光了,十分抱歉", "知道了");
break;
case "maintaining":
Utils.toast(context, "网络状态异常,请稍后再试");
break;
@ -299,104 +389,21 @@ public class LibaoUtils {
Utils.toast(context, "淘号失败,稍后重试");
break;
default:
Utils.toast(context, "淘号异常");
Utils.toast(context, "操作失败");
break;
}
} catch (JSONException e) {
e.printStackTrace();
} catch (Exception ex) {
ex.printStackTrace();
Utils.toast(context, "礼包处理异常" + ex.toString());
}
return;
}
Utils.toast(context, "淘号成功");
libaoEntity.setStatus("taoed");
EventBus.getDefault().post(new EBReuse("libaoChanged"));
adapter.initLibaoCode(new UserDataLibaoEntity(libaoCode, "tao", Utils.getTime(context)));
final String finalLibaoCode = libaoCode;
DialogUtils.showWarningDialog(context, "淘号成功"
, Html.fromHtml(context.getString(R.string.taoed_dialog, libaoCode))
, "关闭", " 复制礼包码"
, new DialogUtils.ConfirmListener() {
@Override
public void onConfirm() {
copyLink(finalLibaoCode, context);
if (isInstallRequired) {
libaoBtn.postDelayed(new Runnable() {
@Override
public void run() {
Spanned msg = Html.fromHtml(
context.getString(R.string.taoed_copy_dialog
, finalLibaoCode));
lunningAppDialog(context
, msg, libaoEntity);
}
}, 300);
}
}
}, null);
}
@Override
public void postFailed(Throwable error) {
Utils.log("---" + error.toString());
if (loadingDialog != null) loadingDialog.dismiss();
if (error instanceof HttpException) {
HttpException exception = (HttpException) error;
if (exception.code() == 403) {
try {
JSONObject errorJson = new JSONObject(exception.response().errorBody().string());
String detail = errorJson.getString("detail");
// Utils.toast(context, "返回::" + detail);
switch (detail) {
case "coming":
Utils.toast(context, "礼包领取时间未开始");
break;
case "finish":
Utils.toast(context, "礼包领取时间已结束");
break;
case "fetched":
Utils.toast(context, "你今天已领过这个礼包了, 不能再淘号");
libaoBtn.setText("已淘号");
libaoBtn.setBackgroundResource(R.drawable.libao_taoed_style);
libaoBtn.setTextColor(ContextCompat.getColorStateList(context, R.color.libao_taoed_selector));
libaoEntity.setStatus("taoed");
break;
case "try tao":
case "used up":
DialogUtils.showHintDialog(context, "礼包已领光"
, "手速不够快,礼包已经被抢光了,十分抱歉", "知道了");
break;
case "maintaining":
Utils.toast(context, "网络状态异常,请稍后再试");
break;
case "fail to compete":
Utils.toast(context, "淘号失败,稍后重试");
break;
default:
Utils.toast(context, "操作失败");
break;
}
} catch (Exception ex) {
ex.printStackTrace();
Utils.toast(context, "礼包处理异常" + ex.toString());
}
return;
}
}
Utils.toast(context, "发生异常");
}
});
break;
}
Utils.toast(context, "发生异常");
}
});
break;
}
});
}
@ -481,7 +488,8 @@ public class LibaoUtils {
Utils.toast(context, "你已领过这个礼包了");
int countdown = 0;
if (errorJson.toString().contains("countdown")) {
countdown = errorJson.getInt("countdown");
JSONObject data = errorJson.getJSONObject("data");
countdown = data.getInt("countdown");
}
if (countdown > 0 && countdown < 60 * 10) {
EventBus.getDefault().post(new EBUISwitch(REFRESH_LIBAO_TIME, countdown));

View File

@ -2,6 +2,7 @@ package com.gh.common.util;
import android.content.Context;
import com.gh.gamecenter.R;
import com.gh.gamecenter.retrofit.JSONObjectResponse;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
@ -108,7 +109,11 @@ public class LoginUtils {
String string = responseBody.string();
JSONObject content = new JSONObject(string);
int code = content.getInt("code");
outputErrorHint(context, code);
if (code == 403202) {
captchaErrorHint(context, content);
} else {
outputErrorHint(context, code);
}
} catch (Exception e1) {
e1.printStackTrace();
Utils.toast(context, "无法获取验证码,请检查你的网络状态");
@ -142,58 +147,106 @@ public class LoginUtils {
});
}
public static void outputErrorHint(Context context, int code) {
public static boolean userPostErrorToast(Throwable throwable, Context context, boolean isComment) {
if (throwable instanceof HttpException) {
HttpException exception = (HttpException) throwable;
if (exception.code() == 403) {
try {
JSONObject errorJson = new JSONObject(exception.response().errorBody().string());
int errorCode = errorJson.getInt("code");
switch (errorCode) {
case 403019:
if (isComment) {
Utils.toast(context, R.string.comment_failed_userblocked);
} else {
Utils.toast(context, R.string.comment_failed_userbanned);
}
break;
case 403020:
Utils.toast(context, R.string.comment_failed_toofrequent);
break;
case 403021:
Utils.toast(context, R.string.comment_failed_illegal);
break;
default:
Utils.toast(context, R.string.comment_failed_unknown);
break;
}
} catch (Exception ex) {
ex.printStackTrace();
Utils.toast(context, "无法识别错误类型");
}
return true;
}
}
return false;
}
public static void captchaErrorHint(Context context, JSONObject content) {
try {
JSONObject detail = content.getJSONObject("detail");
if ("isv.BUSINESS_LIMIT_CONTROL".equals(detail.getString("sub_code"))) {
Utils.toast(context, "获取验证码太频繁,请稍后再试");
} else {
Utils.toast(context, detail.getString("sub_msg"));
}
} catch (JSONException e) {
e.printStackTrace();
}
}
public static void outputErrorHint(Context context, int code) {
switch (code) {
case 40000:
Utils.toast(context, "参数不全");
break;
case 40001:
case 400001:
Utils.toast(context, "验证码获取过快,请稍后重试");// 已经发送过短信
break;
case 40002:
case 400002:
Utils.toast(context, "请求第三方开放平台时发生错误");
break;
case 40003:
case 400003:
Utils.toast(context, "上传用户头像时发生错误");
break;
case 40101:
case 400101:
Utils.toast(context, "缺少参数 app_id");
break;
case 40102:
case 400102:
Utils.toast(context, "缺少签名验证的头信息");
break;
case 40104:
case 400104:
Utils.toast(context, "缺少token");
break;
case 40105:
case 400105:
Utils.toast(context, "缺少手机号码");
break;
case 40106:
case 400106:
Utils.toast(context, "缺少用户名");
break;
case 40107:
case 400107:
Utils.toast(context, "缺少密码参数");
break;
case 40202:
case 400202:
Utils.toast(context, "无效的手机号码");
break;
case 40203:
case 400203:
Utils.toast(context, "无效的用户名");
break;
case 40204:
case 400204:
Utils.toast(context, "无效的头像地址");
break;
case 40205:
case 400205:
Utils.toast(context, "无效的性别参数");
break;
case 40206:
case 400206:
Utils.toast(context, "无效的地区参数");
break;
case 40208:
case 400208:
Utils.toast(context, "无效的密码");
break;
case 40209:
case 400209:
Utils.toast(context, "无效的URL 地址");
break;
case 42000:
@ -211,68 +264,80 @@ public class LoginUtils {
case 42004:
Utils.toast(context, "无效的请求");
break;
case 40301:
case 400301:
Utils.toast(context, "签名验证失败");
break;
case 40302:
case 400302:
Utils.toast(context, "验证码错误");
break;
case 40303:
case 400303:
Utils.toast(context, "密码错误");
break;
case 40304:
case 400304:
Utils.toast(context, "不支持该种方式登录");
break;
case 40305:
case 400305:
Utils.toast(context, "错误的状态值(应用只有两种状态: working / stop)");
break;
case 40306:
case 400306:
Utils.toast(context, "传递了无法识别的参数");
break;
case 40401:
case 400401:
Utils.toast(context, "token过期");
break;
case 40402:
case 400402:
Utils.toast(context, "Service_id过期,主要原因是:收到手机短信验证码后长时间没有进行登录操作");
break;
case 40403:
case 400403:
Utils.toast(context, "验证码已过期");
break;
case 40501:
case 400501:
Utils.toast(context, "同名应用已经存在");
break;
case 40502:
Utils.toast(context, "用户名已存在");
case 400502:
Utils.toast(context, "昵称已存在");
break;
case 40503:
case 400503:
Utils.toast(context, "名称已经存在");
break;
case 40601:
case 400601:
Utils.toast(context, "应用不存在");
break;
case 40602:
case 400602:
Utils.toast(context, "用户不存在");
break;
case 40603:
case 400603:
Utils.toast(context, "用户系统不存在");
break;
case 40604:
case 400604:
Utils.toast(context, "用户已被冻结");
break;
case 40605:
case 400605:
Utils.toast(context, "用户没有冻结");
break;
case 40606:
case 400606:
Utils.toast(context, "该应用被停止运行了");
break;
case 40801:
case 400801:
Utils.toast(context, "访问过于频繁");
break;
case 403001:
Utils.toast(context, "设备异常,获取验证码失败,请更换登陆方式或明天再试");
break;
case 403202:
Utils.toast(context, "403202");
break;
case 400213:
Utils.toast(context, "昵称违规");
break;
case 403801:
Utils.toast(context, "获取验证码太频繁,请稍后再试");
break;
case 403204:
Utils.toast(context, "获取验证码太频繁,请稍后再试");
break;
default:
Utils.toast(context, "未知错误");
Utils.toast(context, code + "");
break;
}

View File

@ -86,7 +86,7 @@ public class MessageShareUtils {
@Override
public void onCancel() {
Utils.toast(mContext, mContext.getString(R.string.share_cancel_hint));
Utils.toast(mContext, R.string.share_cancel_hint);
}
};
// 适配快传成绩单分享

View File

@ -170,4 +170,35 @@ public class NewsUtils {
}
}
public static String getFormattedTime(long time) {
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd", Locale.getDefault());
try {
long today = format.parse(format.format(new Date())).getTime();
long day = time * 1000;
if (day >= today && day < today + 86400 * 1000) {
long min = new Date().getTime() / 1000 - day / 1000;
int hour = (int) (min / (60 * 60));
if (hour == 0) {
if (min < 60) {
return "刚刚";
} else {
return (String.format(Locale.getDefault(), "%d分钟前", (int) (min / 60)));
}
} else {
return (String.format(Locale.getDefault(), "%d小时前", hour));
}
} else if (day >= today - 86400 * 1000 && day < today) {
format.applyPattern("HH:mm");
return ("昨天 ");
} else {
format.applyPattern("yyyy-MM-dd");
return (format.format(day));
}
} catch (ParseException e) {
e.printStackTrace();
format.applyPattern("yyyy-MM-dd");
return (format.format(time * 1000));
}
}
}

View File

@ -10,9 +10,10 @@ import android.content.pm.Signature;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.Toast;
import com.gh.common.constant.Config;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.entity.GameUpdateEntity;
import com.lightgame.utils.Utils;
@ -35,17 +36,35 @@ public class PackageUtils {
/*
* 判断是否可以更新只判断gh_version的大小
*/
public static boolean isCanUpdate(Context context, GameUpdateEntity gameUpdateEntity) {
// 判断是否gh_version是否存在
String gh_version = (String) PackageUtils.getMetaData(
context, gameUpdateEntity.getPackageName(), "gh_version");
if (gh_version != null) {
gh_version = gh_version.substring(2);
// 判断gh_version的大小
return Long.parseLong(gh_version) < Long.parseLong(gameUpdateEntity.getGhVersion());
} else {
return false;
public static List<GameUpdateEntity> isCanUpdate(Context context, GameEntity gameEntity) {
List<GameUpdateEntity> updateList = new ArrayList<>();
for (ApkEntity apkEntity : gameEntity.getApk()) {
// 判断是否gh_version是否存在
String gh_version = (String) PackageUtils.getMetaData(context, apkEntity.getPackageName(), "gh_version");
if (gh_version != null) {
gh_version = gh_version.substring(2);
if (Long.parseLong(gh_version) < Long.parseLong(apkEntity.getGhVersion()) && apkEntity.getForce()) {
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());
updateList.add(updateEntity);
}
}
}
return updateList;
}
/*
@ -148,7 +167,7 @@ public class PackageUtils {
public static Intent getInstallIntent(Context context, String path) {
Uri uri = Uri.fromFile(new File(path));
Intent installIntent = new Intent(Intent.ACTION_VIEW);
installIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// installIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
installIntent.setDataAndType(uri, "application/vnd.android.package-archive");
InstallUtils.getInstance(context).addInstall(getPackageNameByPath(context, path));
return installIntent;
@ -193,6 +212,7 @@ public class PackageUtils {
*/
public static long getInstalledTime(Context context, String packageName) {
try {
if (context == null) return 0;
PackageInfo packageInfo = context.getApplicationContext().getPackageManager()
.getPackageInfo(packageName, 0);
return packageInfo.firstInstallTime;

View File

@ -4,6 +4,7 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Handler;
import android.support.v4.content.ContextCompat;
import android.support.v4.util.ArrayMap;
import android.text.TextUtils;
@ -207,7 +208,9 @@ public class PlatformUtils {
if (color != null) {
return color;
}
return "#00B7FA";
int themeColor = ContextCompat.getColor(HaloApp.getInstance().getApplication(), R.color.theme);
return String.format("#%06X", 0xFFFFFF & themeColor);
}
public int getPlatformPic(String platform) {

View File

@ -44,7 +44,63 @@ public class PostCommentUtils {
listener.postSuccess(response);
}
} else {
Utils.toast(context, context.getString(R.string.post_failure_hint));
Utils.toast(context, R.string.post_failure_hint);
}
}
@Override
public void onFailure(HttpException e) {
if (listener != null) {
listener.postFailed(e);
}
}
});
}
public static void addAnswerComment(final Context context, final String answerId, final String content,
final CommentEntity commentEntity,
final PostCommentListener listener) {
RequestBody body = RequestBody.create(MediaType.parse("application/json"), content);
Observable<ResponseBody> observable;
if (commentEntity != null) {
observable = RetrofitManager.getInstance(context).getApi().postReplyToAnswerComment(answerId, commentEntity.getId(), body);
} else {
observable = RetrofitManager.getInstance(context).getApi().postNewCommentToAnswer(answerId, body);
}
observable.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new JSONObjectResponse() {
@Override
public void onResponse(JSONObject response) {
if (response.length() != 0) {
if (listener != null) {
listener.postSuccess(response);
}
} else {
Utils.toast(context, R.string.post_failure_hint);
}
}
@Override
public void onFailure(HttpException e) {
if (listener != null) {
listener.postFailed(e);
}
}
});
}
public static void voteAnswerComment(final Context context,final String answerId, final String commentId,
final PostCommentListener listener) {
RetrofitManager.getInstance(context).getApi()
.postVoteAnswerComment(answerId,commentId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<ResponseBody>() {
@Override
public void onResponse(ResponseBody response) {
if (listener != null) {
listener.postSuccess(null);
}
}
@ -80,11 +136,31 @@ public class PostCommentUtils {
});
}
public static void addReportData(final Context context, final String reportData,
public static void addReportData(final Context context, final String commentId, final String reportData,
final PostCommentListener listener) {
RequestBody body = RequestBody.create(MediaType.parse("application/json"), reportData);
RetrofitManager.getInstance(context).getApi()
.postReportData(body)
.postReportData(commentId, body)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<ResponseBody>() {
@Override
public void onResponse(ResponseBody response) {
listener.postSuccess(null);
}
@Override
public void onFailure(HttpException e) {
listener.postFailed(e);
}
});
}
public static void postAnswerReportData(final Context context, final String commentId, final String answerId, final String reportData,
final PostCommentListener listener) {
RequestBody body = RequestBody.create(MediaType.parse("application/json"), reportData);
RetrofitManager.getInstance(context).getApi()
.postReportOfAnswerComment(answerId, commentId, body)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<ResponseBody>() {

View File

@ -101,17 +101,17 @@ public class ShareUtils {
public IUiListener QqShareListener = new IUiListener() {
@Override
public void onComplete(Object o) {
Utils.toast(mContext, mContext.getString(R.string.share_success_hint));
Utils.toast(mContext, R.string.share_success_hint);
}
@Override
public void onError(UiError uiError) {
Utils.toast(mContext, mContext.getString(R.string.share_fail_hint));
Utils.toast(mContext, R.string.share_fail_hint);
}
@Override
public void onCancel() {
Utils.toast(mContext, mContext.getString(R.string.share_cancel_hint));
Utils.toast(mContext, R.string.share_cancel_hint);
}
};
@ -147,6 +147,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 = activity;
this.shareIcon = icon;
this.shareUrl = url;
@ -154,7 +155,7 @@ public class ShareUtils {
this.mTitle = shareTitle;
this.mShareType = shareType;
View contentView = View.inflate(mContext, R.layout.share_popup_layout, null);
View contentView = View.inflate(mActivity, R.layout.share_popup_layout, null);
contentView.setFocusable(true);
contentView.setFocusableInTouchMode(true);
RecyclerView shareRecyclerView = (RecyclerView) contentView.findViewById(R.id.share_rv);
@ -190,7 +191,11 @@ public class ShareUtils {
popupWindow = new PopupWindow(contentView, LinearLayout.LayoutParams.MATCH_PARENT
, LinearLayout.LayoutParams.MATCH_PARENT, true);
popupWindow.setAnimationStyle(R.style.mypopwindow_anim_style);
popupWindow.showAtLocation(view, Gravity.BOTTOM, 0, 0);
try {
popupWindow.showAtLocation(view, Gravity.BOTTOM, 0, 0);
} catch (Exception e) {
e.printStackTrace();
}
contentView.setOnClickListener(new View.OnClickListener() {
@Override
@ -215,7 +220,7 @@ public class ShareUtils {
//QQ分享
private void qqShare() {
Utils.toast(mContext, mContext.getString(R.string.share_skip));
Utils.toast(mContext, R.string.share_skip);
Bundle params = new Bundle();
switch (mShareType) {
@ -243,7 +248,7 @@ public class ShareUtils {
//微信好友分享
private void wechatShare() {
Utils.toast(mContext, mContext.getString(R.string.share_skip));
Utils.toast(mContext, R.string.share_skip);
WXWebpageObject webpage = new WXWebpageObject();
WXMediaMessage msg = new WXMediaMessage(webpage);
webpage.webpageUrl = shareUrl;
@ -345,7 +350,7 @@ public class ShareUtils {
//QQ空间分享
private void qZoneShare() {
Utils.toast(mContext, mContext.getString(R.string.share_skip));
Utils.toast(mContext, R.string.share_skip);
Bundle params = new Bundle();
switch (mShareType) {
@ -377,7 +382,7 @@ public class ShareUtils {
//微信朋友圈分享
private void wechatMomentsShare() {
Utils.toast(mContext, mContext.getString(R.string.share_skip));
Utils.toast(mContext, R.string.share_skip);
WXWebpageObject webpage = new WXWebpageObject();
WXMediaMessage msg = new WXMediaMessage(webpage);
@ -508,8 +513,10 @@ public class ShareUtils {
shortMessageShare();
break;
case 6:
if (mShareType == ShareType.askInvite || mShareType == ShareType.askNormal) {
if (mShareType == ShareType.askInvite) {
copyLink(mTitle + " - 光环助手" + shareUrl);
} else if (mShareType == ShareType.askNormal) {
copyLink(shareUrl);
} else if (mShareType != ShareType.shareGh) {
copyLink(shareUrl);
} else {

View File

@ -3,7 +3,6 @@ package com.gh.common.util;
import android.support.v4.util.ArrayMap;
import android.text.TextUtils;
import com.gh.common.constant.Config;
import com.gh.common.constant.Constants;
import java.util.regex.Pattern;
@ -23,78 +22,18 @@ public class TimestampUtils {
private static void initIntervalMap() {
intervalMap = new ArrayMap<>();
intervalMap.put("^" + Config.API_HOST + "index/slides" + "$", 5);
intervalMap.put("^" + Config.API_HOST + "game/chajian" + "$", 10);
intervalMap.put("^" + Config.API_HOST + "game/tuijian" + "$", 15);
intervalMap.put("^" + Config.API_HOST + "game/.+/detail" + "$", 20);
intervalMap.put("^" + Config.API_HOST + "game/.+/digest" + "$", 25);
intervalMap.put("^" + Config.API_HOST + "game/remenkapai" + "$", 30);
intervalMap.put("^" + Config.API_HOST + "game/.+/news_digest" + "$", 35);
intervalMap.put("^" + Config.API_HOST + "game/column/.+\\?page=.+" + "$", 40);
intervalMap.put("^" + Config.API_HOST + "support/package/.+/game/digest" + "$", 45);
intervalMap.put("^" + Config.API_HOST + "game/danjiyouxi\\?limit=20\\&offset=.+" + "$", 50);
intervalMap.put("^" + Config.API_HOST + "news/.+/digest" + "$", 55);
intervalMap.put("^" + Config.API_HOST + "news/.+/detail" + "$", 60);
intervalMap.put("^" + Config.API_HOST + "news/.+/suggestion" + "$", 65);
intervalMap.put("^" + Config.API_HOST + "game/.+/news\\?limit=3" + "$", 70);
intervalMap.put("^" + Config.API_HOST + "zixun/zixun\\?limit=20\\&offset=.+" + "$", 75);
intervalMap.put("^" + Config.API_HOST + "game/.+/news\\?limit=20\\&offset=.+" + "$", 80);
intervalMap.put("^" + Config.API_HOST + "zixun/yuanchuang\\?limit=20\\&offset=.+" + "$", 85);
intervalMap.put("^" + Config.API_HOST + "news\\?type_group=.+\\&offset=.+\\&limit=20" + "$", 90);
intervalMap.put("^" + Config.API_HOST + "zixun/guanzhu\\?key=.+\\&limit=20\\&offset=.+" + "$", 95);
intervalMap.put("^" + Config.API_HOST + "game/.+/news\\?limit=20\\&offset=.+\\&type=.+" + "$", 100);
intervalMap.put("^" + Config.API_HOST + "zixun/guanzhu\\?game_id=.+\\&limit=20\\&offset=.+" + "$", 105);
intervalMap.put("^" + Config.API_HOST + "search/news\\?game_id=.+\\&keyword=.+\\&page=.+\\&limit=20" + "$", 110);
intervalMap.put("^" + Config.API_HOST + "search/game\\?keyword=.+" + "$", 115);
intervalMap.put("^" + Config.API_HOST + "support/setting/platform" + "$", 120);
intervalMap.put("^" + Config.API_HOST + "update/package/.+" + "$", 125);
intervalMap.put("^" + Config.API_HOST + "update/game/.+/package/.+" + "$", 130);
intervalMap.put("^" + Config.COMMENT_HOST + "article/.+/comment\\?limit=10\\&offset=.+" + "$", 135);
intervalMap.put("^" + Config.COMMENT_HOST + "article/.+/comment\\?order=hot\\&limit=10\\&offset=.+" + "$", 140);
intervalMap.put(".*index.*", 5);
intervalMap.put(".*columns.*", 10);
intervalMap.put(".*games.*", 15);
intervalMap.put(".*articles.*", 20);
}
private static void initCDMap() {
cdMap = new ArrayMap<>();
cdMap.put("^" + Config.API_HOST + "index/slides" + "$", Constants.GAME_CD);
cdMap.put("^" + Config.API_HOST + "game/chajian" + "$", Constants.GAME_CD);
cdMap.put("^" + Config.API_HOST + "game/tuijian" + "$", Constants.GAME_CD);
cdMap.put("^" + Config.API_HOST + "game/.+/detail" + "$", Constants.GAME_CD);
cdMap.put("^" + Config.API_HOST + "game/.+/digest" + "$", Constants.GAME_CD);
cdMap.put("^" + Config.API_HOST + "game/remenkapai" + "$", Constants.GAME_CD);
cdMap.put("^" + Config.API_HOST + "game/.+/news_digest" + "$", Constants.GAME_CD);
cdMap.put("^" + Config.API_HOST + "game/column/.+\\?page=.+" + "$", Constants.GAME_CD);
cdMap.put("^" + Config.API_HOST + "support/package/.+/game/digest" + "$", Constants.GAME_CD);
cdMap.put("^" + Config.API_HOST + "game/danjiyouxi\\?limit=20\\&offset=.+" + "$", Constants.GAME_CD);
cdMap.put("^" + Config.API_HOST + "news/.+/digest" + "$", Constants.NEWS_CD);
cdMap.put("^" + Config.API_HOST + "news/.+/detail" + "$", Constants.NEWS_CD);
cdMap.put("^" + Config.API_HOST + "news/.+/suggestion" + "$", Constants.NEWS_CD);
cdMap.put("^" + Config.API_HOST + "game/.+/news\\?limit=3" + "$", Constants.NEWS_CD);
cdMap.put("^" + Config.API_HOST + "zixun/zixun\\?limit=20\\&offset=.+" + "$", Constants.NEWS_CD);
cdMap.put("^" + Config.API_HOST + "game/.+/news\\?limit=20\\&offset=.+" + "$", Constants.NEWS_CD);
cdMap.put("^" + Config.API_HOST + "zixun/yuanchuang\\?limit=10\\&offset=.+" + "$", Constants.NEWS_CD);
cdMap.put("^" + Config.API_HOST + "news\\?type_group=.+\\&offset=.+\\&limit=20" + "$", Constants.NEWS_CD);
cdMap.put("^" + Config.API_HOST + "zixun/guanzhu\\?key=.+\\&limit=20\\&offset=.+" + "$", Constants.NEWS_CD);
cdMap.put("^" + Config.API_HOST + "game/.+/news\\?limit=20\\&offset=.+\\&type=.+" + "$", Constants.NEWS_CD);
cdMap.put("^" + Config.API_HOST + "zixun/guanzhu\\?game_id=.+\\&limit=20\\&offset=.+" + "$", Constants.NEWS_CD);
cdMap.put("^" + Config.API_HOST + "search/news\\?game_id=.+\\&keyword=.+\\&page=.+\\&limit=20" + "$", Constants.NEWS_CD);
cdMap.put("^" + Config.API_HOST + "search/game\\?keyword=.+" + "$", Constants.SEARCH_CD);
cdMap.put("^" + Config.API_HOST + "support/setting/platform" + "$", Constants.PLATFORM_CD);
cdMap.put("^" + Config.API_HOST + "update/package/.+" + "$", Constants.UPDATE_CD);
cdMap.put("^" + Config.API_HOST + "update/game/.+/package/.+" + "$", Constants.UPDATE_CD);
cdMap.put("^" + Config.COMMENT_HOST + "article/.+/comment\\?limit=10\\&offset=.+" + "$", Constants.COMMENT_CD);
cdMap.put("^" + Config.COMMENT_HOST + "article/.+/comment\\?order=hot\\&limit=10\\&offset=.+" + "$", Constants.COMMENT_CD);
cdMap.put("^" + Config.API_HOST + "device/.+/concern" + "$", 0);
cdMap.put("^" + Config.API_HOST + "device/.+/concern/.+" + "$", 0);
cdMap.put("^" + Config.API_HOST + "stat/download" + "$", 0);
cdMap.put("^" + Config.API_HOST + "disclaimer" + "$", 0);
cdMap.put("^" + Config.API_HOST + "search/game/default" + "$", 0);
cdMap.put("^" + Config.API_HOST + "support/upgrade\\?version=.+\\&channel=.+" + "$", 0);
cdMap.put("^" + Config.API_HOST + "support/time/current" + "$", 0);
cdMap.put("^" + Config.API_HOST + "support/setting/ui" + "$", 0);
cdMap.put("^" + Config.API_HOST + "support/download_status\\?version=.+\\&channel=.+" + "$", 0);
cdMap.put("^" + Config.API_HOST + "support/suggestion" + "$", 0);
cdMap.put("^" + Config.API_HOST + "game/.+/serverInfo" + "$", 0);
cdMap.put("^" + Config.API_HOST + "support/package/unused\\?skip=.+" + "$", 0);
cdMap.put(".*index.*", Constants.GAME_CD);
cdMap.put(".*columns.*", Constants.GAME_CD);
cdMap.put(".*games.*", Constants.GAME_CD);
cdMap.put(".*articles.*", Constants.NEWS_CD);
}
/*

View File

@ -0,0 +1,30 @@
package com.gh.common.util;
import android.support.annotation.NonNull;
import com.lightgame.config.CommonDebug;
/**
* Created by khy on 27/03/18.
*/
public class UrlFilterUtils {
// keyName,value,keyName,value......
public static String getFilterQuery(@NonNull String... arrStr) {
if (CommonDebug.IS_DEBUG && (arrStr.length <= 1 || arrStr.length % 2 != 0)) {
throw new IllegalStateException("UrlFilterUtils->getFilterQuery");
}
StringBuilder result = new StringBuilder();
for (int i = 0; i < arrStr.length; i++) {
String s = arrStr[i];
result.append(s);
if (i % 2 == 0) {
result.append(":");
} else if (i != arrStr.length - 1) {
result.append(",");
}
}
return result.toString();
}
}

View File

@ -86,8 +86,8 @@ public class DownloadDialog implements OnCollectionCallBackListener {
private LinearLayout dialog_ll_collection_hint;
private String entrance;
private String location;
private int row;
private int column;
private final int row = 3;
private final int column = 3;
private boolean isLoadPlatform;
private DownloadDialog() {
@ -117,9 +117,6 @@ public class DownloadDialog implements OnCollectionCallBackListener {
this.location = location;
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext);
row = sp.getInt("download_box_row", 3);
column = sp.getInt("download_box_column", 3);
gameApk = sortApk(new ArrayList<>(gameEntity.getApk()));
if (gameEntity.getCollection() != null) {

View File

@ -0,0 +1,137 @@
package com.gh.common.view;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.RectF;
import android.support.annotation.StringRes;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.widget.ProgressBar;
import com.gh.common.util.DisplayUtils;
import com.gh.gamecenter.R;
public class DownloadProgressBar extends ProgressBar {
private static final int MAX_LENGTH = 1000;
public enum DownloadType {
NORMAL,
NONE,
PLUGIN,
LAUNCH_OR_OPEN,
INSTALL_NORMAL,
INSTALL_PLUGIN,
DOWNLOADING_NORMAL,
DOWNLOADING_PLUGIN,
}
private PorterDuffXfermode mDuffXFerMode = new PorterDuffXfermode(PorterDuff.Mode.SRC_IN);
private Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private DownloadType mDownloadType;
private String mText;
private int mDefaultColor;
public DownloadProgressBar(Context context) {
super(context);
}
public DownloadProgressBar(Context context, AttributeSet attrs) {
super(context, attrs);
setMax(MAX_LENGTH);
setProgressDrawable(getResources().getDrawable(R.drawable.game_item_btn_download_style));
}
Bitmap srcBitmap;
Canvas srcCanvas;
RectF rectF;
private void create() {
srcBitmap = Bitmap.createBitmap(getMeasuredWidth(), getMeasuredHeight(), Bitmap.Config.ARGB_8888);
srcCanvas = new Canvas(srcBitmap);
rectF = new RectF(0, 0, getProgress() * getWidth() / MAX_LENGTH, getMeasuredHeight());
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (TextUtils.isEmpty(mText)) return;
mPaint.setColor(mDefaultColor == 0 ? ContextCompat.getColor(getContext(), R.color.theme) : mDefaultColor); // 初始化颜色
mPaint.setTextSize(DisplayUtils.sp2px(getContext(), 14));
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
mPaint.setXfermode(null);
create();
Paint.FontMetricsInt fontMetrics = mPaint.getFontMetricsInt();
int baseline = (getHeight() - fontMetrics.bottom - fontMetrics.top) / 2;
mPaint.setTextAlign(Paint.Align.CENTER);
srcCanvas.drawText(mText, getWidth() / 2, baseline, mPaint);
mPaint.setXfermode(mDuffXFerMode);
mPaint.setColor(Color.WHITE); // 反向颜色
srcCanvas.drawRect(rectF, mPaint);
canvas.drawBitmap(srcBitmap, 0, 0, null);
}
public void setText(String text) {
mText = text;
invalidate();
}
public String getText() {
return mText;
}
public void setText(@StringRes int res) {
setText(getResources().getString(res));
}
public void setDownloadType(DownloadType downloadType) {
switch (downloadType) {
case NORMAL:
case INSTALL_NORMAL:
setProgressDrawable(getResources().getDrawable(R.drawable.game_item_btn_download_style));
mDefaultColor = Color.WHITE;
break;
case PLUGIN:
case INSTALL_PLUGIN:
setProgressDrawable(getResources().getDrawable(R.drawable.game_item_btn_plugin_style));
mDefaultColor = Color.WHITE;
break;
case NONE:
setProgressDrawable(getResources().getDrawable(R.drawable.news_detail_comment)); // todo 是否需要点击效果
mDefaultColor = ContextCompat.getColor(getContext(), R.color.hint);
break;
case LAUNCH_OR_OPEN:
setProgress(0);
setProgressDrawable(getResources().getDrawable(R.drawable.detail_downloading_normal_style)); // todo 背景是否需要与下载中区分
mDefaultColor = ContextCompat.getColor(getContext(), R.color.theme);
break;
case DOWNLOADING_NORMAL: // todo bug 和列表用相同的drawable会复用
setProgressDrawable(getResources().getDrawable(R.drawable.detail_downloading_normal_style2));
mDefaultColor = ContextCompat.getColor(getContext(), R.color.theme);
break;
case DOWNLOADING_PLUGIN:
setProgressDrawable(getResources().getDrawable(R.drawable.detail_downloading_plugin_style));
mDefaultColor = ContextCompat.getColor(getContext(), R.color.btn_plugin);
break;
}
mDownloadType = downloadType;
}
public DownloadType getDownloadType() {
return mDownloadType;
}
}

View File

@ -1,106 +0,0 @@
package com.gh.common.view;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.text.Editable;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.ImageSpan;
import android.util.AttributeSet;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.List;
/**
* Created by khy on 14/12/17.
*/
public class EditorView extends android.support.v7.widget.AppCompatEditText {
int mEditorWidth;
List<String> mImgArr = new ArrayList<>();
public EditorView(Context context) {
super(context);
}
public EditorView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public EditorView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
private void insertPicToEt(String picturePath) {
Bitmap bitmap = compressPicture(picturePath);
if (bitmap == null) return;
mImgArr.add(picturePath);
ImageSpan imageSpan = new ImageSpan(getContext(), bitmap);
int index = getSelectionStart();
String tempUrl = "<img src=\"" + picturePath + "\" />";
SpannableString spannableString = new SpannableString(tempUrl);
spannableString.setSpan(imageSpan, 0, tempUrl.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
Editable editableText = getEditableText();
if (index < 0 || index >= editableText.length()) {
editableText.append(spannableString);
} else {
editableText.insert(index, spannableString);
}
if (bitmap.getWidth() >= mEditorWidth)
editableText.insert(index + spannableString.length(), "\n");
}
/**
* 压缩图片
* 规则:
* 1.如果图片大于当前EditText的最大宽度则按比例缩放使图片宽度和EditText的宽度保持一致 (高度不处理)
* 2.如果图片小于当前EditText 由于比例限制 将不处理
*
* @param srcPath 图片路径
* @return
*/
public Bitmap compressPicture(String srcPath) {
FileOutputStream fos = null;
BitmapFactory.Options op = new BitmapFactory.Options();
// 开始读入图片此时把options.inJustDecodeBounds 设回true了
op.inJustDecodeBounds = true;
Bitmap bitmap = BitmapFactory.decodeFile(srcPath, op);
op.inJustDecodeBounds = false;
// 缩放图片的尺寸
float w = op.outWidth;
float h = op.outHeight;
float index = w / h;
int width = mEditorWidth;
float hh = width / index;
float ww = width;
float be = 1.0f;
if (w > h && w > ww / 2) {
be = w / ww;
} else if (w < h && h > hh/2) {
be = h / hh;
}
if (be <= 0) {
be = 1.0f;
}
op.inSampleSize = (int) be;// 设置缩放比例,这个数字越大,图片大小越小.
// 重新读入图片注意此时已经把options.inJustDecodeBounds 设回false了
bitmap = BitmapFactory.decodeFile(srcPath, op);
int desWidth = (int) (w / be);
int desHeight = (int) (h / be);
return Bitmap.createScaledBitmap(bitmap, desWidth, desHeight, true);
}
public List<String> getImgArr() {
return mImgArr;
}
}

View File

@ -0,0 +1,45 @@
package com.gh.common.view;
import android.content.Context;
import android.view.animation.Interpolator;
import android.widget.Scroller;
/**
* Created by khy on 20/04/18.
*/
public class FixedSpeedScroller extends Scroller {
private int mDuration = 0;
public FixedSpeedScroller(Context context) {
super(context);
}
public FixedSpeedScroller(Context context, Interpolator interpolator) {
super(context, interpolator);
}
public FixedSpeedScroller(Context context, Interpolator interpolator, boolean flywheel) {
super(context, interpolator, flywheel);
}
@Override
public void startScroll(int startX, int startY, int dx, int dy, int duration) {
super.startScroll(startX, startY, dx, dy, mDuration);
}
@Override
public void startScroll(int startX, int startY, int dx, int dy) {
super.startScroll(startX, startY, dx, dy, mDuration);
}
public void setmDuration(int time) {
mDuration = time;
}
public int getmDuration() {
return mDuration;
}
}

View File

@ -0,0 +1,53 @@
package com.gh.common.view;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ScrollView;
import com.gh.common.util.DisplayUtils;
/**
* Created by khy on 2/04/18.
*/
public class LimitHeightScrollView extends ScrollView {
private int mLimitHeight;
public LimitHeightScrollView(Context context) {
super(context);
}
public LimitHeightScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
mLimitHeight = DisplayUtils.dip2px(getContext(), 240);
}
public LimitHeightScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
if (heightMode == MeasureSpec.EXACTLY) {
heightSize = heightSize <= mLimitHeight ? heightSize
: mLimitHeight;
}
if (heightMode == MeasureSpec.UNSPECIFIED) {
heightSize = heightSize <= mLimitHeight ? heightSize
: mLimitHeight;
}
if (heightMode == MeasureSpec.AT_MOST) {
heightSize = heightSize <= mLimitHeight ? heightSize
: mLimitHeight;
}
int maxHeightMeasureSpec = MeasureSpec.makeMeasureSpec(heightSize,
heightMode);
super.onMeasure(widthMeasureSpec, maxHeightMeasureSpec);
}
}

View File

@ -17,6 +17,7 @@ import android.webkit.WebViewClient;
import com.gh.common.util.AskUtils;
import com.gh.common.util.NetworkUtils;
import com.gh.common.util.RichEditorUtils;
import com.gh.gamecenter.BuildConfig;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
@ -105,6 +106,9 @@ public class RichEditor extends WebView {
getSettings().setJavaScriptEnabled(true);
setWebChromeClient(new WebChromeClient());
setWebViewClient(createWebviewClient());
if (BuildConfig.DEBUG && Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
setWebContentsDebuggingEnabled(true);
}
loadUrl(SETUP_HTML);
applyAttributes(context, attrs);

View File

@ -15,18 +15,15 @@ import android.view.ViewTreeObserver;
import com.gh.common.util.DisplayUtils;
import com.gh.gamecenter.R;
import com.lightgame.config.CommonDebug;
import com.lightgame.utils.Utils;
/**
* Created by khy on 2/12/17.
*/
public class TabIndicatorView extends View implements TabLayout.OnTabSelectedListener, ViewPager.OnPageChangeListener {
public class TabIndicatorView extends View implements ViewPager.OnPageChangeListener {
private TabLayout mTabLayout;
private ViewPager mViewPager;
private int mIndicatorSpace;
@ -56,11 +53,7 @@ public class TabIndicatorView extends View implements TabLayout.OnTabSelectedLis
public void setupWithTabLayout(final TabLayout tableLayout) {
mTabLayout = tableLayout;
tableLayout.setSelectedTabIndicatorColor(Color.TRANSPARENT);
tableLayout.setOnTabSelectedListener(this);
tableLayout.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
@Override
public void onScrollChanged() {
@ -70,14 +63,6 @@ public class TabIndicatorView extends View implements TabLayout.OnTabSelectedLis
});
ViewCompat.setElevation(this, ViewCompat.getElevation(mTabLayout));
tableLayout.post(new Runnable() {
@Override
public void run() {
if (mTabLayout.getTabCount() > 0)
onTabSelected(mTabLayout.getTabAt(0));
}
});
//清除Tab background
for (int tab = 0; tab < tableLayout.getTabCount(); tab++) {
@ -87,12 +72,11 @@ public class TabIndicatorView extends View implements TabLayout.OnTabSelectedLis
}
public void setupWithViewPager(ViewPager viewPager) {
mViewPager = viewPager;
viewPager.addOnPageChangeListener(this);
}
public void setIndicatorWidth(int width) {
this.mIndicatorWidth = DisplayUtils.dip2px(getContext(), width);
if (width > 0) this.mIndicatorWidth = DisplayUtils.dip2px(getContext(), width);
}
public void setIndicatorSpace(int space) {
@ -187,44 +171,8 @@ public class TabIndicatorView extends View implements TabLayout.OnTabSelectedLis
}
@Override
public void onPageScrollStateChanged(int state) {
}
/**
* 当已经有一个ViewPager后当TabLayout的tab改变的时候在onTabSelected方法直接调用ViewPager的
* setCurrentItem方法调用这个方法后会触发ViewPager的scroll事件也就是在onPageScrolled方法中调用
* generatePath方法来更新Path如果没有ViewPager的话直接在onTabSelected的方法中调用generatePath
* 方法。
**/
@Override
public void onTabSelected(TabLayout.Tab tab) {
if (mViewPager != null) {
if (CommonDebug.IS_DEBUG) {
Utils.log("onTabSelected : TabPosition=>" + tab.getPosition()
+ " ViewPagerCount=>" + mViewPager.getAdapter().getCount());
}
if (tab.getPosition() != mViewPager.getCurrentItem())
try {
mViewPager.setCurrentItem(tab.getPosition());
} catch (Exception e) {
e.printStackTrace();
}
} else {
generatePath(tab.getPosition(), 0);
invalidate();
}
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
}

View File

@ -128,12 +128,13 @@ public class DownloadManager implements DownloadStatusListener {
String url = (String) msg.obj;
switch (msg.what) {
case DownloadConfig.CONTINUE_DOWNLOAD_TASK:
if (System.currentTimeMillis() - lastTimeMap.get(url) >= 1000) {
resume(url);
if (lastTimeMap.get(url) != null && System.currentTimeMillis() - lastTimeMap.get(url) >= 1000) {
DownloadEntity downloadEntity = getDownloadEntityByUrl(url);
if (downloadEntity != null) add(downloadEntity);
}
break;
case DownloadConfig.PAUSE_DOWNLOAD_TASK:
if (System.currentTimeMillis() - lastTimeMap.get(url) >= 1000) {
if (lastTimeMap.get(url) != null && System.currentTimeMillis() - lastTimeMap.get(url) >= 1000) {
pause(url);
}
break;
@ -412,32 +413,6 @@ public class DownloadManager implements DownloadStatusListener {
mHandler.sendMessageDelayed(msg, delayMillis);
}
/**
* 根据url恢复下载 //TODO 这个可以删除的全都在add判断add的时候不需要关注任务真实状态
*
* @param url
*/
@Deprecated
void resume(String url) {
DownloadEntity entry = getDownloadEntityByUrl(url);
// 暂停任务后,把文件删除,然后点继续,文件不存在,需要重新加入下载队列进行下载
if (checkDownloadEntryRecordValidate(url)) {
Utils.toast(mContext, "文件不存在!已重新加入下载队列");
add(entry);
} else {
if (entry != null) {
if (isFileCompleted(url)) {
entry.setStatus(DownloadStatus.done);
DataChanger.INSTANCE.notifyDataChanged(entry);
} else if (!isTaskDownloading(url)) {
mContext.startService(getIntent(entry, DownloadStatus.resume));
}
}
}
Utils.log(DownloadManager.class.getSimpleName(), "resume");
}
/**
* 根据url取消下载并删除已下载的文件
*

View File

@ -9,7 +9,6 @@ import com.halo.assistant.fragment.AboutFragment;
/**
* Created by khy on 2017/2/28.
*/
@Deprecated
public class AboutActivity extends NormalActivity {
@NonNull
@ -18,7 +17,7 @@ public class AboutActivity extends NormalActivity {
// return new IntentFactory.Builder(context)
// .setActivity(AboutActivity.class)
// .setFragment(AboutFragment.class).build();
return getIntent(context, AboutFragment.class);
return getTargetIntent(context, AboutActivity.class, AboutFragment.class);
}
}

View File

@ -0,0 +1,31 @@
package com.gh.gamecenter;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import com.gh.common.util.EntranceUtils;
import com.gh.gamecenter.ask.AnswerDetailFragment;
/**
* Created by khy on 10/04/18.
*/
public class AnswerDetailActivity extends NormalActivity {
public static final String TAG = "AnswerDetailActivity";
@NonNull
public static Intent getIntent(Context context, String answerId, String entrance) {
return getIntent(context, answerId, entrance, false);
}
@NonNull
public static Intent getIntent(Context context, String answerId, String entrance, boolean isOpenCommentManager) {
Bundle bundle = new Bundle();
bundle.putString(EntranceUtils.KEY_ANSWER_ID, answerId);
bundle.putString(EntranceUtils.KEY_ENTRANCE, entrance);
bundle.putBoolean(EntranceUtils.KEY_SHOW_ANSWER_COMMENT, isOpenCommentManager);
return getTargetIntent(context, AnswerDetailActivity.class, AnswerDetailFragment.class, bundle);
}
}

View File

@ -0,0 +1,48 @@
package com.gh.gamecenter;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.gh.common.util.EntranceUtils;
import com.gh.gamecenter.ask.questionsdetail.AnswerEditFragment;
/**
* Created by khy on 10/04/18.
*/
public class AnswerEditActivity extends NormalActivity {
public static Intent getIntent(Context context, String questionId, String questionTitle, boolean showInNewPage) {
Bundle bundle = new Bundle();
bundle.putString(EntranceUtils.KEY_QUESTIONS_ID, questionId);
bundle.putString(EntranceUtils.KEY_QUESTIONS_TITLE, questionTitle);
bundle.putBoolean(EntranceUtils.KEY_ANSWER_OPEN_IN_NEW_PAGE, showInNewPage);
return getTargetIntent(context, AnswerEditActivity.class, AnswerEditFragment.class, bundle);
}
public static Intent getIntent(Context context, String questionId, String questionTitle, String draftId, boolean showInNewPage) {
Bundle bundle = new Bundle();
bundle.putString(EntranceUtils.KEY_QUESTIONS_ID, questionId);
bundle.putString(EntranceUtils.KEY_QUESTIONS_TITLE, questionTitle);
bundle.putBoolean(EntranceUtils.KEY_ANSWER_OPEN_IN_NEW_PAGE, showInNewPage);
bundle.putString(EntranceUtils.KEY_DRAFT_ID, draftId);
return getTargetIntent(context, AnswerEditActivity.class, AnswerEditFragment.class, bundle);
}
public static Intent getIntent(Context context, String questionId, String questionTitle) {
Bundle bundle = new Bundle();
bundle.putString(EntranceUtils.KEY_QUESTIONS_ID, questionId);
bundle.putString(EntranceUtils.KEY_QUESTIONS_TITLE, questionTitle);
return getTargetIntent(context, AnswerEditActivity.class, AnswerEditFragment.class, bundle);
}
public static Intent getIntent(Context context, String answerId, String questionTitle, String content) {
Bundle bundle = new Bundle();
bundle.putString(EntranceUtils.KEY_ANSWER_ID, answerId);
bundle.putString(EntranceUtils.KEY_QUESTIONS_TITLE, questionTitle);
bundle.putString(EntranceUtils.KEY_ANSWER_CONTENT, content);
return getTargetIntent(context, AnswerEditActivity.class, AnswerEditFragment.class, bundle);
}
}

View File

@ -0,0 +1,23 @@
package com.gh.gamecenter;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.gh.common.util.EntranceUtils;
import com.gh.gamecenter.ask.questionsdetail.AnswerFoldFragment;
/**
* Created by khy on 10/04/18.
*/
public class AnswerFoldActivity extends NormalActivity {
public static Intent getIntent(Context context, String questionsId, String entrance) {
Bundle bundle = new Bundle();
bundle.putString(EntranceUtils.KEY_QUESTIONS_ID, questionsId);
bundle.putString(EntranceUtils.KEY_ENTRANCE, entrance);
return getTargetIntent(context, AnswerFoldActivity.class, AnswerFoldFragment.class, bundle);
}
}

View File

@ -15,8 +15,6 @@ import android.widget.TextView;
import com.gh.base.BaseActivity;
import com.gh.common.util.CheckLoginUtils;
import com.gh.common.util.EntranceUtils;
import com.gh.gamecenter.ask.QuestionsEditFragment;
import com.gh.gamecenter.ask.search.AskSearchFragment;
import com.lightgame.utils.Util_System_Keyboard;
@ -115,9 +113,7 @@ public class AskSearchActivity extends BaseActivity {
mSearchEt.setText("");
} else if (v.getId() == R.id.btnQuestions) {
CheckLoginUtils.checkLogin(this, () -> {
Bundle bundle = new Bundle();
bundle.putString(EntranceUtils.KEY_SEARCHKEY, mSearchKey);
NormalActivity.startFragment(this, QuestionsEditFragment.class, bundle);
startActivity(QuestionEditActivity.getIntent(this, mSearchKey));
});
}
}

View File

@ -0,0 +1,17 @@
package com.gh.gamecenter;
import android.content.Context;
import android.content.Intent;
import com.gh.gamecenter.ask.AskTabOrderFragment;
/**
* Created by khy on 10/04/18.
*/
public class AskTabOrderActivity extends NormalActivity {
public static Intent getIntent(Context context) {
return getTargetIntent(context, AskTabOrderActivity.class, AskTabOrderFragment.class);
}
}

View File

@ -593,7 +593,7 @@ public class ChooseReceiverActivity extends BaseActivity implements View.OnClick
// 连接失败-动画
private void connFailedAnimView() {
getSupportActionBar().show();
Utils.toast(ChooseReceiverActivity.this, "连接失败");
toast("连接失败");
if (mScaleAnimation != null) {
mScaleAnimation.cancel();
}

View File

@ -9,7 +9,6 @@ import com.halo.assistant.fragment.ApkCleanerFragment;
/**
* Created by khy on 2017/1/24.
*/
@Deprecated
public class CleanApkActivity extends NormalActivity {
@NonNull
@ -19,7 +18,7 @@ public class CleanApkActivity extends NormalActivity {
// .setActivity(CleanApkActivity.class)
// .setFragment(ApkCleanerFragment.class).build();
return getIntent(context, ApkCleanerFragment.class);
return getTargetIntent(context, CleanApkActivity.class, ApkCleanerFragment.class);
}
}

View File

@ -2,26 +2,23 @@ package com.gh.gamecenter;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import com.gh.base.fragment.BaseFragment_ViewPager;
import com.gh.gamecenter.collection.CollectionWrapperFragment;
/**
* Created by khy on 18/07/17.
*/
@Deprecated
public class CollectionActivity extends NormalActivity {
@NonNull
public static Intent getCollectionActivity(Context context) {
Bundle args = new Bundle();
args.putInt(BaseFragment_ViewPager.ARGS_INDEX, CollectionWrapperFragment.INDEX_TOOL);
// Bundle args = new Bundle();
// args.putInt(BaseFragment_TabLayout.PAGE_INDEX, CollectionWrapperFragment.INDEX_TOOL);
// return new IntentFactory.Builder(context)
// .setActivity(CollectionActivity.class)
// .setFragment(CollectionWrapperFragment.class).setArgs(args).build();
return getIntent(context, CollectionWrapperFragment.class, args);
return getTargetIntent(context, CollectionActivity.class, CollectionWrapperFragment.class);
}
}

View File

@ -5,12 +5,12 @@ import android.content.Intent;
import android.os.Bundle;
import com.gh.common.util.EntranceUtils;
import com.gh.gamecenter.ask.viewmodel.AnswerCommentConversationFragment;
import com.halo.assistant.fragment.comment.CommentDetailFragment;
/**
* Created by khy on 2017/3/22.
*/
@Deprecated
public class CommentDetailActivity extends NormalActivity {
public static Intent getIntent(Context context, String commentId) {
@ -19,7 +19,17 @@ public class CommentDetailActivity extends NormalActivity {
// return new IntentFactory.Builder(context)
// .setActivity(CommentDetailActivity.class)
// .setFragment(CommentDetailFragment.class).setArgs(args).build();
return getIntent(context, CommentDetailFragment.class, args);
return getTargetIntent(context, CommentDetailActivity.class, CommentDetailFragment.class, args);
}
public static Intent getAnswerCommentIntent(Context context, String commentId, String answerId) {
Bundle args = new Bundle();
args.putString(EntranceUtils.KEY_COMMENTID, commentId);
args.putString(EntranceUtils.KEY_ANSWER_ID, answerId);
// return new IntentFactory.Builder(context)
// .setActivity(CommentDetailActivity.class)
// .setFragment(CommentDetailFragment.class).setArgs(args).build();
return getTargetIntent(context, CommentDetailActivity.class, AnswerCommentConversationFragment.class, args);
}
}

View File

@ -23,11 +23,6 @@ public class CommonActivity extends BaseToolBarActivity implements ToolbarContro
}
@Override
public void setNavigationTitle(CharSequence res) {
}
@Override
public void setToolbarMenu(int res) {

View File

@ -0,0 +1,17 @@
package com.gh.gamecenter;
import android.content.Context;
import android.content.Intent;
import com.gh.gamecenter.ask.SelectGameFragment;
/**
* Created by khy on 10/04/18.
*/
public class CommunitiesSelectActivity extends NormalActivity {
public static Intent getIntent(Context context) {
return getTargetIntent(context, CommunitiesSelectActivity.class, SelectGameFragment.class);
}
}

View File

@ -0,0 +1,21 @@
package com.gh.gamecenter;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.gh.gamecenter.ask.entity.AskSubjectEntity;
import com.gh.gamecenter.ask.subject.AskSubjectFragment;
/**
* Created by khy on 10/04/18.
*/
public class CommunitySubjectActivity extends NormalActivity {
public static Intent getIntent(Context context, AskSubjectEntity entity) {
Bundle bundle = new Bundle();
bundle.putParcelable(AskSubjectEntity.TAG, entity);
return getTargetIntent(context, CommunitySubjectActivity.class, AskSubjectFragment.class, bundle);
}
}

View File

@ -11,7 +11,6 @@ import com.halo.assistant.fragment.myconcern.MyConcernFragment;
/**
* 我的关注页面
*/
@Deprecated
public class ConcernActivity extends NormalActivity {
@NonNull
@ -21,7 +20,7 @@ public class ConcernActivity extends NormalActivity {
// return new IntentFactory.Builder(context)
// .setActivity(ConcernActivity.class)
// .setFragment(MyConcernFragment.class).setArgs(args).build();
return getIntent(context, MyConcernFragment.class, args);
return getTargetIntent(context, ConcernActivity.class, MyConcernFragment.class, args);
}

View File

@ -0,0 +1,17 @@
package com.gh.gamecenter;
import android.content.Context;
import android.content.Intent;
import com.gh.gamecenter.info.ConcernFragment;
/**
* Created by khy on 10/04/18.
*/
public class ConcernInfoActivity extends NormalActivity {
public static Intent getIntent(Context context) {
return getTargetIntent(context, ConcernInfoActivity.class, ConcernFragment.class);
}
}

View File

@ -129,7 +129,7 @@ public class CropImageActivity extends BaseActivity {
@Override
public Observable<JSONObject> call(String token) {
if (token != null) {
return Observable.just(FileUtils.uploadFile(Config.API_HOST + "support/upload/img?type=icon", path, token));
return Observable.just(FileUtils.uploadFile(Config.API_HOST + "images?type=icon", path, token));
}
dialog.dismiss();
handler.sendEmptyMessage(1);
@ -141,7 +141,7 @@ public class CropImageActivity extends BaseActivity {
if (result != null) {
try {
if (result.getInt("statusCode") == 401) {
return Observable.just(FileUtils.uploadFile(Config.API_HOST + "support/upload/img?type=icon", path,mUserManager.getToken()));
return Observable.just(FileUtils.uploadFile(Config.API_HOST + "images?type=icon", path,mUserManager.getToken()));
}
} catch (JSONException e) {
e.printStackTrace();
@ -188,7 +188,7 @@ public class CropImageActivity extends BaseActivity {
sp.edit().putString("updateIconCount", jsonObject.toString()).apply();
Intent data = new Intent();
data.putExtra(EntranceUtils.KEY_URL, result.getString("icon"));
data.putExtra(EntranceUtils.KEY_URL, result.getString("url"));
setResult(RESULT_OK, data);
finish();

View File

@ -4,7 +4,7 @@ import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.gh.base.fragment.BaseFragment_ViewPager;
import com.gh.base.fragment.BaseFragment_TabLayout;
import com.gh.common.util.EntranceUtils;
import com.gh.gamecenter.download.DownloadFragment;
@ -21,6 +21,10 @@ public class DownloadManagerActivity extends NormalActivity {
public static final String TAG = "DownloadManagerActivity";
@Override
protected Intent provideNormalIntent() {
return getTargetIntent(this, DownloadManagerActivity.class, DownloadFragment.class);
}
public static Intent getDownloadMangerIntent(Context context, String url, String entrance) {
// Intent intent = new Intent(context, DownloadManagerActivity.class);
@ -29,7 +33,7 @@ public class DownloadManagerActivity extends NormalActivity {
Bundle bundle = new Bundle();
bundle.putString(EntranceUtils.KEY_URL, url);
bundle.putString(EntranceUtils.KEY_ENTRANCE, entrance);
return getIntent(context, DownloadFragment.class, bundle);
return getTargetIntent(context, DownloadManagerActivity.class, DownloadFragment.class, bundle);
}
public static Intent getDownloadMangerIntent(Context context, int position, String entrance) {
@ -38,8 +42,8 @@ public class DownloadManagerActivity extends NormalActivity {
// intent.putExtra(EntranceUtils.KEY_ENTRANCE, entrance);
Bundle bundle = new Bundle();
bundle.putString(EntranceUtils.KEY_ENTRANCE, entrance);
bundle.putInt(BaseFragment_ViewPager.ARGS_INDEX, position);
return getIntent(context, DownloadFragment.class, bundle);
bundle.putInt(BaseFragment_TabLayout.PAGE_INDEX, position);
return getTargetIntent(context, DownloadManagerActivity.class, DownloadFragment.class, bundle);
}

View File

@ -471,6 +471,7 @@ public class FileSenderActivity extends BaseActivity implements FileSenderAdapte
@Override
public void OnCancelPosition(int position) {
if (position >= mFileSenderList.size()) return;
FileSender fileSender = mFileSenderList.get(position);
Utils.log("发送方准备取消发送" + position);
if (fileSender != null && fileSender.isRunning()) {

View File

@ -1,8 +1,10 @@
package com.gh.gamecenter;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.gh.common.util.DataUtils;
import com.gh.common.util.EntranceUtils;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.gamedetail.GameDetailFragment;
@ -13,16 +15,23 @@ import com.gh.gamecenter.gamedetail.GameDetailFragment;
*/
public class GameDetailActivity extends NormalActivity {
@Override
protected Intent provideNormalIntent() {
return getTargetIntent(this, GameDetailActivity.class, GameDetailFragment.class);
}
/**
* 启动游戏详情页面
*/
public static void startGameDetailActivity(Context context, GameEntity gameEntity, String entrance) {
DataUtils.onMtaEvent(context, "详情页面", "游戏详情", gameEntity != null ? gameEntity.getName() : "");
Bundle bundle = new Bundle();
bundle.putString(EntranceUtils.KEY_ENTRANCE, entrance);
bundle.putParcelable(GameEntity.TAG, gameEntity);
// context.startActivity(new IntentFactory.Builder(context).setActivity(GameDetailActivity.class)
// .setFragment(GameDetailFragment.class).setArgs(bundle).build());
context.startActivity(getIntent(context, GameDetailFragment.class, bundle));
context.startActivity(getTargetIntent(context, GameDetailActivity.class, GameDetailFragment.class, bundle));
}
/**
@ -34,7 +43,20 @@ public class GameDetailActivity extends NormalActivity {
bundle.putString(EntranceUtils.KEY_ENTRANCE, entrance);
// context.startActivity(new IntentFactory.Builder(context).setActivity(GameDetailActivity.class)
// .setFragment(GameDetailFragment.class).setArgs(bundle).build());
context.startActivity(getIntent(context, GameDetailFragment.class, bundle));
context.startActivity(getTargetIntent(context, GameDetailActivity.class, GameDetailFragment.class, bundle));
}
/**
* @param switchToFirstTag 是否跳转到动态 tab
*/
public static void startGameDetailActivity(Context context, String gameId, String entrance, boolean switchToFirstTag) {
Bundle bundle = new Bundle();
bundle.putString(EntranceUtils.KEY_GAMEID, gameId);
bundle.putString(EntranceUtils.KEY_ENTRANCE, entrance);
bundle.putBoolean(EntranceUtils.KEY_TARGET, switchToFirstTag);
// context.startActivity(new IntentFactory.Builder(context).setActivity(GameDetailActivity.class)
// .setFragment(GameDetailFragment.class).setArgs(bundle).build());
context.startActivity(getTargetIntent(context, GameDetailActivity.class, GameDetailFragment.class, bundle));
}
}

View File

@ -30,7 +30,7 @@ public class GameNewsActivity extends NormalActivity {
// return new IntentFactory.Builder(context)
// .setActivity(GameNewsActivity.class)
// .setFragment(GameNewsSearchFragment.class).setArgs(args).build();
return getIntent(context, GameNewsSearchFragment.class, args);
return getTargetIntent(context, GameNewsActivity.class, GameNewsSearchFragment.class, args);
}
}

View File

@ -0,0 +1,16 @@
package com.gh.gamecenter;
import android.content.Context;
import android.content.Intent;
import com.gh.gamecenter.info.InfoWrapperFragment;
/**
* Created by khy on 10/04/18.
*/
public class InfoActivity extends NormalActivity {
public static Intent getIntent(Context context) {
return getTargetIntent(context, InfoActivity.class, InfoWrapperFragment.class);
}
}

View File

@ -4,25 +4,9 @@ import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.view.Gravity;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.gh.base.BaseActivity;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.EntranceUtils;
import com.gh.gamecenter.eventbus.EBKaiFuReset;
import com.gh.gamecenter.kaifu.KaiFuFragment;
import com.gh.gamecenter.kaifu.KaiFuWrapperFragment;
import com.halo.assistant.ui.IntentFactory;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import butterknife.BindView;
/**
* Created by khy on 18/08/17.
@ -37,7 +21,7 @@ public class KaiFuActivity extends NormalActivity {
// return new IntentFactory.Builder(context)
// .setActivity(KaiFuActivity.class)
// .setFragment(KaiFuWrapperFragment.class).setArgs(args).build();
return getIntent(context, KaiFuWrapperFragment.class, args);
return getTargetIntent(context, KaiFuActivity.class, KaiFuWrapperFragment.class, args);
}
}

View File

@ -6,7 +6,7 @@ import android.os.Bundle;
import android.support.annotation.NonNull;
import com.gh.common.util.EntranceUtils;
import com.gh.gamecenter.libao.LibaoWrapperFragment;
import com.gh.gamecenter.libao.LibaoFragment;
/**
* Created by khy on 2016/12/12.
@ -18,10 +18,7 @@ public class LibaoActivity extends NormalActivity {
public static Intent getIntent(Context context, String entrance) {
Bundle args = new Bundle();
args.putString(EntranceUtils.KEY_ENTRANCE, entrance);
// return new IntentFactory.Builder(context)
// .setActivity(LibaoActivity.class)
// .setFragment(LibaoWrapperFragment.class).setArgs(args).build();
return getIntent(context, LibaoWrapperFragment.class, args);
return getTargetIntent(context, LibaoActivity.class, LibaoFragment.class, args);
}
}

View File

@ -21,6 +21,7 @@ import com.gh.common.util.DetailDownloadUtils;
import com.gh.common.util.EntranceUtils;
import com.gh.common.util.LibaoUtils;
import com.gh.common.util.TokenUtils;
import com.gh.common.view.DownloadProgressBar;
import com.gh.common.view.VerticalItemDecoration;
import com.gh.download.DownloadManager;
import com.gh.gamecenter.adapter.LibaoDetailAdapter;
@ -73,8 +74,8 @@ public class LibaoDetailActivity extends BaseActivity implements LibaoDetailAdap
TextView mNoneDataTv;
@BindView(R.id.reuse_none_data)
LinearLayout mNoneData;
@BindView(R.id.detail_tv_download)
TextView mDownloadTv;
@BindView(R.id.detail_progressbar)
DownloadProgressBar mDownloadPb;
private LibaoDetailAdapter mAdapter;
@ -180,7 +181,7 @@ public class LibaoDetailActivity extends BaseActivity implements LibaoDetailAdap
mIsScroll = true;
mAdapter = new LibaoDetailAdapter(this, this, this, mLibaoEntity, mDownloadTv, mEntrance);
mAdapter = new LibaoDetailAdapter(this, this, this, mLibaoEntity, mDownloadPb, mEntrance);
mLibaoDetailRv.setLayoutManager(new LinearLayoutManager(this) {
@Override
public boolean canScrollVertically() {
@ -369,10 +370,15 @@ public class LibaoDetailActivity extends BaseActivity implements LibaoDetailAdap
@Override
public void onFailure(HttpException e) {
mLibaoDetailRv.setVisibility(View.GONE);
mLlLoading.setVisibility(View.GONE);
mLibaoDetailRv.setPadding(0, 0, 0, 0);
mNoConnection.setVisibility(View.VISIBLE);
if (e != null && e.code() == 404) {
mLibaoDetailRv.setVisibility(View.GONE);
mLlLoading.setVisibility(View.GONE);
mLibaoDetailRv.setPadding(0, 0, 0, 0);
mNoneDataTv.setText("天了噜~页面不见了");
mNoneData.setVisibility(View.VISIBLE);
} else {
loadError();
}
}
});
}
@ -450,8 +456,9 @@ public class LibaoDetailActivity extends BaseActivity implements LibaoDetailAdap
mLibaoDetailRv.setVisibility(View.GONE);
mLlLoading.setVisibility(View.GONE);
mLibaoDetailRv.setPadding(0, 0, 0, 0);
mNoneDataTv.setText("天了噜~页面不见了");
mNoneDataTv.setText("页面不见了~");
mNoneData.setVisibility(View.VISIBLE);
toast("内容可能已被删除");
}
// 领取/淘号失败,根据返回的时间重新倒数

View File

@ -14,6 +14,6 @@ public class LoginActivity extends NormalActivity {
@NonNull
public static Intent getIntent(Context context) {
return getIntent(context, LoginFragment.class);
return getTargetIntent(context, LoginActivity.class, LoginFragment.class);
}
}

View File

@ -11,6 +11,7 @@ import android.content.pm.PackageInfo;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.SystemClock;
import android.preference.PreferenceManager;
import android.provider.Settings;
@ -32,14 +33,17 @@ import com.gh.common.util.ClassUtils;
import com.gh.common.util.ConcernUtils;
import com.gh.common.util.DataCollectionUtils;
import com.gh.common.util.DataLogUtils;
import com.gh.common.util.DataUtils;
import com.gh.common.util.DeviceUtils;
import com.gh.common.util.DialogUtils;
import com.gh.common.util.EntranceUtils;
import com.gh.common.util.GameUtils;
import com.gh.common.util.GsonUtils;
import com.gh.common.util.NetworkUtils;
import com.gh.common.util.PackageUtils;
import com.gh.common.util.PlatformUtils;
import com.gh.common.util.TrafficUtils;
import com.gh.common.util.UrlFilterUtils;
import com.gh.download.DownloadManager;
import com.gh.gamecenter.db.info.GameInfo;
import com.gh.gamecenter.db.info.InstallInfo;
@ -47,9 +51,11 @@ import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.GameDigestEntity;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.entity.GameUpdateEntity;
import com.gh.gamecenter.entity.SettingsEntity;
import com.gh.gamecenter.eventbus.EBDownloadStatus;
import com.gh.gamecenter.eventbus.EBNetworkState;
import com.gh.gamecenter.eventbus.EBPackage;
import com.gh.gamecenter.eventbus.EBReuse;
import com.gh.gamecenter.eventbus.EBShowDialog;
import com.gh.gamecenter.eventbus.EBSkip;
import com.gh.gamecenter.fragment.MainWrapperFragment;
@ -69,6 +75,7 @@ import com.google.gson.reflect.TypeToken;
import com.halo.assistant.HaloApp;
import com.lightgame.config.CommonDebug;
import com.lightgame.download.DataWatcher;
import com.lightgame.download.DownloadConfig;
import com.lightgame.download.DownloadEntity;
import com.lightgame.download.DownloadStatus;
import com.lightgame.download.FileUtils;
@ -104,7 +111,6 @@ import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action1;
import rx.schedulers.Schedulers;
import static com.gh.common.util.EntranceUtils.KEY_DATA;
import static com.gh.common.util.EntranceUtils.KEY_TO;
import static com.gh.gamecenter.fragment.MainWrapperFragment.INDEX_PERSONAL;
@ -115,6 +121,9 @@ public class MainActivity extends BaseActivity {
public final static String EB_MAINACTIVITY_TAG = "MainActivity";
public final static String EB_SKIP_GAMEFRAGMENT = "GameFragment";
private MainWrapperFragment mMainWrapperFragment;
private SharedPreferences sp;
private InstallManager mInstallManager;
@ -127,7 +136,7 @@ public class MainActivity extends BaseActivity {
public void run() {
if (getIntent() != null && getIntent().getExtras() != null && !isSkipped) {
isSkipped = true;
Bundle bundle = getIntent().getBundleExtra(KEY_DATA);
Bundle bundle = getIntent().getExtras();
if (bundle != null) {
String to = bundle.getString(KEY_TO);
if (!TextUtils.isEmpty(to)) {
@ -147,7 +156,7 @@ public class MainActivity extends BaseActivity {
NormalActivity.startFragment(MainActivity.this, (Class<? extends NormalFragment>) clazz, bundle);
} else {
Intent skipIntent = new Intent(MainActivity.this, clazz);
skipIntent.putExtra(KEY_DATA, bundle);
skipIntent.putExtras(bundle);
startActivity(skipIntent);
}
}
@ -164,6 +173,9 @@ public class MainActivity extends BaseActivity {
if (DownloadStatus.hijack.equals(downloadEntity.getStatus())) {
// 链接被劫持
processHijack(downloadEntity);
String nameAndPlatform = downloadEntity.getName() + ":"
+ PlatformUtils.getInstance(getApplicationContext()).getPlatformName(downloadEntity.getPlatform());
DataUtils.onMtaEvent(getApplicationContext(), "下载劫持", "游戏名字", nameAndPlatform, "网络状态" + DeviceUtils.getNetwork(getApplication()));
return;
} else if (DownloadStatus.notfound.equals(downloadEntity.getStatus())) {
// 404 Not Found
@ -171,6 +183,8 @@ public class MainActivity extends BaseActivity {
downloadEntity.setStatus(DownloadStatus.cancel);
DownloadManager.getInstance(getApplicationContext()).cancel(downloadEntity.getUrl());
toast("该链接已失效!请联系管理员。");
EventBus.getDefault().post(new EBShowDialog("notfound", downloadEntity.getName()));
return;
} else if (DownloadStatus.neterror.equals(downloadEntity.getStatus())
|| DownloadStatus.timeout.equals(downloadEntity.getStatus())) {
@ -219,6 +233,24 @@ public class MainActivity extends BaseActivity {
// 统计下载完成
uploadData(downloadEntity.getGameId(), downloadEntity.getPlatform());
}
// 下载过程分析统计
android.content.pm.PackageManager pm = getApplicationContext().getPackageManager();
PackageInfo packageInfo = pm.getPackageArchiveInfo(downloadEntity.getPath(), android.content.pm.PackageManager.GET_ACTIVITIES);
if (packageInfo == null) {
/**
* 解析包错误信息收集
* 1.真实下载Url
* 2.下载次数()
* 3.
*/
DataUtils.onMtaEvent(getApplication(), "解析包错误分析"
, "游戏名字", downloadEntity.getName() + ":"
+ PlatformUtils.getInstance(getApplicationContext()).getPlatformName(downloadEntity.getPlatform())
, "网络状态", DeviceUtils.getNetwork(getApplication()));
}
}
}
};
@ -357,6 +389,9 @@ public class MainActivity extends BaseActivity {
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean("isSkipped", isSkipped);
if (mMainWrapperFragment != null) {
outState.putInt(BaseFragment_ViewPager.ARGS_INDEX, mMainWrapperFragment.getCurrentItem());
}
}
@Override
@ -404,7 +439,7 @@ public class MainActivity extends BaseActivity {
for (int i = 0, size = localList.size(); i < size; i++) {
final String packageName = localList.get(i);
RetrofitManager.getInstance(this).getApi().getGameDigestByPackageName(packageName)
RetrofitManager.getInstance(this).getApi().getGameDigestByPackageName(UrlFilterUtils.getFilterQuery("package", packageName))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<List<GameDigestEntity>>() {
@ -521,7 +556,7 @@ public class MainActivity extends BaseActivity {
// 更新用户已安装游戏
RequestBody body = RequestBody.create(MediaType.parse("application/json"),
new JSONArray(installed).toString());
RetrofitManager.getInstance(MainActivity.this).getApi().putPackage(body)
RetrofitManager.getInstance(MainActivity.this).getApi().putPackage(UserManager.getInstance().getUserId(), body)
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.io())
.subscribe(new Response<ResponseBody>());
@ -578,19 +613,20 @@ public class MainActivity extends BaseActivity {
private void checkGameUpdate(String packageName) {
Object gh_id = PackageUtils.getMetaData(this, packageName, "gh_id");
Observable<GameUpdateEntity> observable;
Observable<GameEntity> observable;
if (gh_id == null) {
observable = RetrofitManager.getInstance(this).getApi().getGameUpdate(packageName);
observable = RetrofitManager.getInstance(this).getApi().getGameUpdate(UrlFilterUtils.getFilterQuery("packages", packageName));
} else {
observable = RetrofitManager.getInstance(this).getApi().getGameUpdate((String) gh_id, packageName);
observable = RetrofitManager.getInstance(this).getApi().getGameUpdateById((String) gh_id);
}
observable.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<GameUpdateEntity>() {
.subscribe(new Response<GameEntity>() {
@Override
public void onResponse(GameUpdateEntity response) {
if (PackageUtils.isCanUpdate(MainActivity.this, response)) {
PackageManager.addUpdate(response);
public void onResponse(GameEntity response) {
List<GameUpdateEntity> updateList = PackageUtils.isCanUpdate(getApplication(), response);
if (updateList.size() > 0) {
PackageManager.addUpdateList(updateList);
EventBus.getDefault().post(new EBDownloadStatus("update"));
}
}
@ -646,7 +682,14 @@ public class MainActivity extends BaseActivity {
isSkipped = savedInstanceState.getBoolean("isSkipped");
}
replaceFragment(new MainWrapperFragment());
mMainWrapperFragment = new MainWrapperFragment();
if (savedInstanceState != null) {
mMainWrapperFragment.setArguments(savedInstanceState);
} else if (getIntent() != null) {
Bundle extras = getIntent().getExtras();
mMainWrapperFragment.setArguments(extras);
}
replaceFragment(mMainWrapperFragment);
mInstallManager = new InstallManager(getApplicationContext());
@ -661,6 +704,9 @@ public class MainActivity extends BaseActivity {
checkDevice(); // 根据设备信息判断用户是否是新用户
}
// 获取默认配置
getGhzsSettings();
// 初始化PlatformUtils
PlatformUtils.getInstance(getApplicationContext());
@ -670,10 +716,8 @@ public class MainActivity extends BaseActivity {
// 检查是否有权限读取应用列表
checkPermission();
getSuggestionType();
final String message = Config.getExceptionMsg(this);
if (!TextUtils.isEmpty(UserManager.getInstance().getToken()) && !TextUtils.isEmpty(message)) {
if (!TextUtils.isEmpty(message)) {
Config.setExceptionMsg(this, null);
AppUncaughtHandler.reportException(this, new Throwable(message));
DialogUtils.showWarningDialog(this, "发生闪退", "光环助手刚刚发生了闪退,马上反馈以帮助我们更好地修复问题?(只需简单描述你刚才的操作)"
@ -693,13 +737,45 @@ public class MainActivity extends BaseActivity {
handler.postDelayed(skipRun, 500);
}
private void getGhzsSettings() {
String channel = HaloApp.getInstance().getChannel();
RetrofitManager.getInstance(this)
.getApi().getSettings(PackageUtils.getVersionName(this), channel)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<SettingsEntity>() {
@Override
public void onResponse(SettingsEntity response) {
Config.setSettings(response);
// 意见反馈
SharedPreferences.Editor edit = sp.edit();
edit.putString(SuggestionActivity.SUGGESTION_HINT_TYPE,
GsonUtils.Companion.getInstance().toJson(response.getSuggestion()));
edit.apply();
// 设置默认社区
if (TextUtils.isEmpty(UserManager.getInstance().getCommunityId(getApplication())) &&
response.getCommunity() != null) {
SettingsEntity.Community community = response.getCommunity();
UserManager.getInstance().setCommunityId(getApplication(), community.getId(), community.getName());
}
EventBus.getDefault().post(new EBReuse("Refresh"));
}
});
}
private void checkRetryDownload() {
if (!NetworkUtils.isWifiConnected(this)) return;
for (DownloadEntity downloadEntity : DownloadManager.getInstance(this).getAll()) {
if (DownloadStatus.neterror.equals(downloadEntity.getStatus()) ||
DownloadStatus.timeout.equals(downloadEntity.getStatus())) {
DownloadManager.getInstance(this).add(downloadEntity);
Message msg = Message.obtain();
msg.what = DownloadConfig.CONTINUE_DOWNLOAD_TASK;
msg.obj = downloadEntity.getUrl();
DownloadManager.getInstance(getApplicationContext()).sendMessageDelayed(msg, 1000);
}
Utils.log("checkRetryDownload::" + downloadEntity.getStatus());
}
@ -829,34 +905,6 @@ public class MainActivity extends BaseActivity {
}, null);
}
private void getSuggestionType() {
RetrofitManager.getInstance(this).getApi()
.getSuggestionType()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<ResponseBody>() {
@Override
public void onResponse(ResponseBody response) {
super.onResponse(response);
try {
String string = response.string();
SharedPreferences.Editor edit = sp.edit();
edit.putString("SuggestionType", string);
edit.apply();
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void onError(Throwable e) {
super.onError(e);
Utils.log("反馈的问题选项::ERROR::" + e.toString());
}
});
}
private void checkPermission() {
List<PackageInfo> installedList = getPackageManager().getInstalledPackages(0);
if (installedList.isEmpty()) {
@ -919,6 +967,9 @@ public class MainActivity extends BaseActivity {
public void onEventMainThread(EBNetworkState busNetworkState) {
if (busNetworkState.isNetworkConnected()) {
checkRetryDownload();
if (Config.getSettings() == null) {
getGhzsSettings();
}
}
}
@ -960,7 +1011,7 @@ public class MainActivity extends BaseActivity {
}
// 安装后关注游戏
RetrofitManager.getInstance(this).getApi().getGameDigestByPackageName(packageName)
RetrofitManager.getInstance(this).getApi().getGameDigestByPackageName(UrlFilterUtils.getFilterQuery("package", packageName))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<List<GameDigestEntity>>() {
@ -983,12 +1034,8 @@ public class MainActivity extends BaseActivity {
}
}
// 更新已安装游戏
JSONArray params = new JSONArray();
params.put(packageName);
RequestBody body = RequestBody.create(
MediaType.parse("application/json"), params.toString());
RetrofitManager.getInstance(MainActivity.this).getApi()
.postPackage(body)
.postPackage(UserManager.getInstance().getUserId(), packageName)
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.io())
.subscribe(new Response<ResponseBody>());
@ -1016,7 +1063,7 @@ public class MainActivity extends BaseActivity {
// 更新已安装游戏
RetrofitManager.getInstance(this).getApi()
.deletePackage(packageName)
.deletePackage(UserManager.getInstance().getUserId(), packageName)
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.io())
.subscribe(new Response<ResponseBody>());

View File

@ -5,7 +5,7 @@ import android.content.Intent;
import android.os.Bundle;
import com.gh.common.util.EntranceUtils;
import com.gh.gamecenter.message.MessageCenterFragment;
import com.gh.gamecenter.message.MessageFragment;
/**
* Created by khy on 21/07/17.
@ -19,7 +19,7 @@ public class MessageActivity extends NormalActivity {
// .setFragment(MessageCenterFragment.class).build();
Bundle bundle = new Bundle();
bundle.putString(EntranceUtils.KEY_ENTRANCE, entrance);
return getIntent(context, MessageCenterFragment.class, bundle);
return getTargetIntent(context, MessageActivity.class, MessageFragment.class, bundle);
}
}

View File

@ -8,14 +8,13 @@ import com.gh.gamecenter.entity.CommentEntity;
import com.gh.gamecenter.entity.ConcernEntity;
import com.gh.gamecenter.message.MessageDetailFragment;
import com.halo.assistant.HaloApp;
import com.halo.assistant.ui.IntentFactory;
/**
* Created by khy on 2016/11/8.
* 消息详情界面(评论详情)
*/
@Deprecated
public class MessageDetailActivity extends CommonActivity {
public class MessageDetailActivity extends NormalActivity {
// 评论回复
public static Intent getMessageDetailIntent(Context context, CommentEntity entity, String newsId) {
@ -25,10 +24,7 @@ public class MessageDetailActivity extends CommonActivity {
intent.putExtra("openSoftInput", true);
intent.putExtra(CommentEntity.TAG, entity);
return new IntentFactory.Builder(context)
.setArgs(intent.getExtras())
.setActivity(MessageDetailActivity.class)
.setFragment(MessageDetailFragment.class).build();
return getTargetIntent(context, MessageDetailActivity.class, MessageDetailFragment.class, intent.getExtras());
}
public static Intent getIntentByEntity(Context context, ConcernEntity concernEntity, String entrance) {
@ -37,10 +33,7 @@ public class MessageDetailActivity extends CommonActivity {
HaloApp.put(ConcernEntity.TAG, concernEntity);
intent.putExtra(EntranceUtils.KEY_ENTRANCE, entrance);
// return intent;
return new IntentFactory.Builder(context)
.setArgs(intent.getExtras())
.setActivity(MessageDetailActivity.class)
.setFragment(MessageDetailFragment.class).build();
return getTargetIntent(context, MessageDetailActivity.class, MessageDetailFragment.class, intent.getExtras());
}
public static Intent getIntentById(Context context, String newsId, Integer commentNum, Boolean openSoftInput, String entrance) {
@ -50,10 +43,7 @@ public class MessageDetailActivity extends CommonActivity {
intent.putExtra("commentNum", commentNum);
intent.putExtra("openSoftInput", openSoftInput);
// return intent;
return new IntentFactory.Builder(context)
.setArgs(intent.getExtras())
.setActivity(MessageDetailActivity.class)
.setFragment(MessageDetailFragment.class).build();
return getTargetIntent(context, MessageDetailActivity.class, MessageDetailFragment.class, intent.getExtras());
}
}

View File

@ -0,0 +1,21 @@
package com.gh.gamecenter;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.gh.common.util.EntranceUtils;
import com.gh.gamecenter.message.MessageNormalFragment;
/**
* Created by khy on 10/04/18.
*/
public class MessageInviteActivity extends NormalActivity {
public static Intent getIntent(Context context, String messageType) {
Bundle bundle = new Bundle();
bundle.putString(EntranceUtils.KEY_MESSAGE_TYPE, messageType);
return getTargetIntent(context, MessageInviteActivity.class, MessageNormalFragment.class, bundle);
}
}

View File

@ -0,0 +1,17 @@
package com.gh.gamecenter;
import android.content.Context;
import android.content.Intent;
import com.gh.gamecenter.message.KeFuFragment;
/**
* Created by khy on 10/04/18.
*/
public class MessageKeFuActivity extends NormalActivity {
public static Intent getIntent(Context context) {
return getTargetIntent(context, MessageKeFuActivity.class, KeFuFragment.class);
}
}

View File

@ -0,0 +1,21 @@
package com.gh.gamecenter;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.gh.common.util.EntranceUtils;
import com.gh.gamecenter.message.MessageNormalFragment;
/**
* Created by khy on 10/04/18.
*/
public class MessageVoteActivity extends NormalActivity {
public static Intent getIntent(Context context, String messageType) {
Bundle bundle = new Bundle();
bundle.putString(EntranceUtils.KEY_MESSAGE_TYPE, messageType);
return getTargetIntent(context, MessageVoteActivity.class, MessageNormalFragment.class, bundle);
}
}

View File

@ -0,0 +1,21 @@
package com.gh.gamecenter;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.gh.common.util.EntranceUtils;
import com.gh.gamecenter.ask.myask.MyAskWrapperFragment;
/**
* Created by khy on 10/04/18.
*/
public class MyAskActivity extends NormalActivity {
public static Intent getIntent(Context context) {
Bundle bundle = new Bundle();
bundle.putString(EntranceUtils.KEY_ENTRANCE, "(我的光环)+(我的问答)");
return getTargetIntent(context, MyAskActivity.class, MyAskWrapperFragment.class, bundle);
}
}

View File

@ -28,6 +28,7 @@ import com.gh.common.util.ApkActiveUtils;
import com.gh.common.util.CheckLoginUtils;
import com.gh.common.util.CollectionUtils;
import com.gh.common.util.DataCollectionUtils;
import com.gh.common.util.DataUtils;
import com.gh.common.util.DetailDownloadUtils;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.EntranceUtils;
@ -46,7 +47,6 @@ import com.gh.gamecenter.eventbus.EBPackage;
import com.gh.gamecenter.newsdetail.NewsDetailAdapter;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
import com.google.gson.Gson;
import com.jakewharton.rxbinding.view.RxView;
import com.lightgame.download.DataWatcher;
import com.lightgame.download.DownloadEntity;
@ -54,7 +54,6 @@ import com.lightgame.utils.Utils;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.json.JSONObject;
import java.util.HashMap;
import java.util.Map;
@ -163,6 +162,7 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener,
* 启动新闻详情页面
*/
public static void startNewsDetailActivity(Context context, NewsEntity newsEntity, String entrance) {
DataUtils.onMtaEvent(context, "详情页面", "文章详情", newsEntity != null ? newsEntity.getTitle() : "");
if (!TextUtils.isEmpty(newsEntity.getLink())) {
context.startActivity(WebActivity.getIntentByNews(context, newsEntity, entrance));
} else {
@ -180,6 +180,7 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener,
* 在收藏启动新闻详情页面
*/
public static void startNewsDetailByCollection(Context context, NewsEntity newsEntity, String entrance) {
DataUtils.onMtaEvent(context, "详情页面", "文章详情", newsEntity != null ? newsEntity.getTitle() : "");
if (!TextUtils.isEmpty(newsEntity.getLink())) {
Intent intent = WebActivity.getIntentByNews(context, newsEntity, entrance);
context.startActivity(intent);
@ -243,6 +244,7 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener,
super.onCreate(savedInstanceState);
setNavigationTitle("");
mNoneDataTv.setText("页面不见咯");
// 增加actionBar Button
RelativeLayout reuse_actionbar = findViewById(R.id.reuse_actionbar);
@ -251,6 +253,7 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener,
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mNewsShare.getLayoutParams();
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
params.addRule(RelativeLayout.CENTER_VERTICAL);
params.setMargins(0, 0, DisplayUtils.dip2px(this, 4), 0);
reuse_actionbar.addView(mNewsShare, params);
mNewsCollection = (ImageView) LayoutInflater.from(this).inflate(R.layout.menu_action_collection, reuse_actionbar, false);
@ -258,7 +261,7 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener,
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mNewsCollection.getLayoutParams();
params2.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
params2.addRule(RelativeLayout.CENTER_VERTICAL);
params2.setMargins(0, 0, params.width, 0);
params2.setMargins(0, 0, params.width - DisplayUtils.dip2px(this, 7), 0);
reuse_actionbar.addView(mNewsCollection, params2);
mDetailRv.setHasFixedSize(true);
@ -269,9 +272,7 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener,
newsId = getIntent().getStringExtra(EntranceUtils.KEY_NEWSID);
mIsCollectionNews = getIntent().getBooleanExtra(KEY_COLLECTIONNEWS, false);
if (getIntent().getBundleExtra(EntranceUtils.KEY_DATA) != null) {
newsId = getIntent().getBundleExtra(EntranceUtils.KEY_DATA).getString(EntranceUtils.KEY_NEWSID);
}
if (newsId == null) {
mNewsEntity = getIntent().getParcelableExtra(NewsEntity.TAG);
if (mNewsEntity != null) {
@ -283,10 +284,6 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener,
adapter.setTitle(mNewsEntity.getTitle());
adapter.getNewsDetail();
mNewsShare.setVisibility(View.VISIBLE);
if (mIsCollectionNews) {
getNewsDigest(mNewsEntity.getId());
}
}
} else {
getNewsDigest(newsId);
@ -432,11 +429,16 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener,
mReuseLoading.setVisibility(View.GONE);
mDetailBottomLl.setVisibility(View.GONE);
mNoConn.setVisibility(View.VISIBLE);
mNoneData.setVisibility(View.GONE);
}
@Override
public void loadEmpty() {
mDetailRv.setVisibility(View.GONE);
mReuseLoading.setVisibility(View.GONE);
mDetailBottomLl.setVisibility(View.GONE);
mNoConn.setVisibility(View.GONE);
mNoneData.setVisibility(View.VISIBLE);
}
private void getNewsDigest(final String newsId) {
@ -447,17 +449,6 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener,
@Override
public void onResponse(NewsEntity response) {
if (mIsCollectionNews && mNewsEntity != null && response != null) { // 对比查看收藏文章是否修改
Gson gson = new Gson();
String newEntity = gson.toJson(response.getThumbnail());
String entity = gson.toJson(mNewsEntity.getThumbnail());
if (!newEntity.equals(entity) || !response.getType().equals(mNewsEntity.getType())
|| !response.getTitle().equals(mNewsEntity.getTitle())) {
CollectionUtils.INSTANCE.patchCollection(NewsDetailActivity.this, response.getId(), CollectionUtils.CollectionType.article);
} else {
Utils.log("========相同");
}
return;
}
@ -472,6 +463,8 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener,
adapter.getNewsDetail();
mNewsShare.setVisibility(View.VISIBLE);
DataUtils.onMtaEvent(NewsDetailActivity.this, "详情页面", "文章详情", response.getTitle());
}
@Override
@ -553,65 +546,59 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener,
mNoConn.setVisibility(View.GONE);
handler.postDelayed(runnable, 1000);
} else if (v == mDetailCommentLl) {
CheckLoginUtils.checkLogin(this, new CheckLoginUtils.OnLoggenInListener() {
@Override
public void onLoggedIn() {
Intent intent = MessageDetailActivity.getIntentById(NewsDetailActivity.this, adapter.getNewsDetailEntity().getId(), null, true
, mEntrance + "(新闻详情[" + adapter.getTitle() + "])");
startActivity(intent);
}
CheckLoginUtils.checkLogin(this, () -> {
Intent intent = MessageDetailActivity.getIntentById(NewsDetailActivity.this, adapter.getNewsDetailEntity().getId(), null, true
, mEntrance + "(新闻详情[" + adapter.getTitle() + "])");
startActivity(intent);
});
} else if (v == mNewsCollection) {
CheckLoginUtils.checkLogin(this, new CheckLoginUtils.OnLoggenInListener() {
@Override
public void onLoggedIn() {
final NewsDetailEntity newsDetailEntity = adapter.getNewsDetailEntity();
mNewsCollection.setEnabled(false);
if (newsDetailEntity.getUserData() != null && newsDetailEntity.getUserData().isArticleFavorite()) {
CollectionUtils.INSTANCE.deleteCollection(NewsDetailActivity.this, mNewsEntity.getId(),
CollectionUtils.CollectionType.article,
new CollectionUtils.OnCollectionListener() {
@Override
public void onSuccess() {
newsDetailEntity.getUserData().setArticleFavorite(false);
mNewsCollection.setEnabled(true);
mNewsCollection.setImageResource(R.drawable.menu_ic_collect_unselect);
toast(getString(R.string.collection_cancel));
}
CheckLoginUtils.checkLogin(this, () -> {
final NewsDetailEntity newsDetailEntity = adapter.getNewsDetailEntity();
mNewsCollection.setEnabled(false);
if (newsDetailEntity.getUserData() != null && newsDetailEntity.getUserData().isArticleFavorite()) {
CollectionUtils.INSTANCE.deleteCollection(NewsDetailActivity.this, mNewsEntity.getId(),
CollectionUtils.CollectionType.article,
new CollectionUtils.OnCollectionListener() {
@Override
public void onSuccess() {
newsDetailEntity.getUserData().setArticleFavorite(false);
mNewsCollection.setEnabled(true);
mNewsCollection.setImageResource(R.drawable.menu_ic_collect_unselect);
toast(R.string.collection_cancel);
}
@Override
public void onError() {
mNewsCollection.setEnabled(true);
toast(getString(R.string.collection_cancel_failure));
}
});
@Override
public void onError() {
mNewsCollection.setEnabled(true);
toast(R.string.collection_cancel_failure);
}
});
} else {
Map<String, String> map = new HashMap<>();
map.put("_id", mNewsEntity.getId());
CollectionUtils.INSTANCE.postCollection(NewsDetailActivity.this, new JSONObject(map).toString(),
CollectionUtils.CollectionType.article,
new CollectionUtils.OnCollectionListener() {
@Override
public void onSuccess() {
UserDataEntity userData = newsDetailEntity.getUserData();
if (userData == null) {
userData = new UserDataEntity();
newsDetailEntity.setUserData(userData);
}
userData.setArticleFavorite(true);
mNewsCollection.setEnabled(true);
mNewsCollection.setImageResource(R.drawable.menu_ic_collect_select);
toast(getString(R.string.collection_success));
} else {
// Map<String, String> map = new HashMap<>();
// map.put("_id", mNewsEntity.getId());
CollectionUtils.INSTANCE.postCollection(NewsDetailActivity.this, mNewsEntity.getId(),
CollectionUtils.CollectionType.article,
new CollectionUtils.OnCollectionListener() {
@Override
public void onSuccess() {
UserDataEntity userData = newsDetailEntity.getUserData();
if (userData == null) {
userData = new UserDataEntity();
newsDetailEntity.setUserData(userData);
}
userData.setArticleFavorite(true);
mNewsCollection.setEnabled(true);
mNewsCollection.setImageResource(R.drawable.menu_ic_collect_select);
toast(R.string.collection_success);
}
@Override
public void onError() {
mNewsCollection.setEnabled(true);
toast(getString(R.string.collection_failure));
}
});
}
@Override
public void onError() {
mNewsCollection.setEnabled(true);
toast(R.string.collection_failure);
}
});
}
});
}

View File

@ -25,7 +25,7 @@ public class NewsSearchActivity extends NormalActivity {
// return new IntentFactory.Builder(context)
// .setActivity(NewsSearchActivity.class)
// .setFragment(GameNewsSearchResultFragment.class).setArgs(args).build();
return getIntent(context, GameNewsSearchResultFragment.class, args);
return getTargetIntent(context, NewsSearchActivity.class, GameNewsSearchResultFragment.class, args);
}
}

View File

@ -1,6 +1,5 @@
package com.gh.gamecenter;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
@ -11,12 +10,16 @@ import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;
import com.gh.base.BaseActivity;
import com.gh.gamecenter.normal.NormalFragment;
import com.gh.gamecenter.normal.ToolbarController;
import com.lightgame.OnTitleClickListener;
import java.util.List;
import butterknife.BindView;
@ -24,7 +27,7 @@ import butterknife.BindView;
* Created by khy on 17/10/17.
*/
public class NormalActivity extends BaseActivity implements ToolbarController, Toolbar.OnMenuItemClickListener {
public abstract class NormalActivity extends BaseActivity implements ToolbarController, Toolbar.OnMenuItemClickListener {
@BindView(R.id.normal_toolbar)
Toolbar mNormalToolbar;
@ -36,25 +39,30 @@ public class NormalActivity extends BaseActivity implements ToolbarController, T
public static final String NORMAL_FRAGMENT_NAME = "normalFragmentName";
public static final String NORMAL_FRAGMENT_BUNDLE = "normalFragmentBundle";
@Deprecated
protected static Intent getIntent(Context context, Class<? extends NormalFragment> t) {
Intent intent = new Intent(context, NormalActivity.class);
intent.putExtra(NORMAL_FRAGMENT_NAME, t.getCanonicalName());
return intent;
// 针对部分跳转不符合NormalActivity规则的额外处理主要绑定NormalFragment
protected Intent provideNormalIntent() {
return null;
}
@Deprecated
protected static Intent getIntent(Context context, Class<? extends NormalFragment> t, Bundle bundle) {
Intent intent = new Intent(context, NormalActivity.class);
protected static Intent getTargetIntent(Context context, Class<? extends NormalActivity> cls, Class<? extends NormalFragment> t, Bundle bundle) {
Intent intent = new Intent(context, cls);
intent.putExtra(NORMAL_FRAGMENT_NAME, t.getCanonicalName());
intent.putExtra(NORMAL_FRAGMENT_BUNDLE, bundle);
return intent;
}
protected static Intent getTargetIntent(Context context, Class<? extends NormalActivity> cls, Class<? extends NormalFragment> t) {
Intent intent = new Intent(context, cls);
intent.putExtra(NORMAL_FRAGMENT_NAME, t.getCanonicalName());
return intent;
}
public static void startFragment(Context context, Class<? extends NormalFragment> t) {
public static void startFragmentNewTask(Context context, Class<? extends NormalFragment> t, Bundle bundle) {
Intent intent = new Intent(context, NormalActivity.class);
intent.putExtra(NORMAL_FRAGMENT_NAME, t.getCanonicalName());
intent.putExtra(NORMAL_FRAGMENT_BUNDLE, bundle);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
@ -65,23 +73,6 @@ public class NormalActivity extends BaseActivity implements ToolbarController, T
context.startActivity(intent);
}
public static void startFragmentForResult(Context context, Class<? extends NormalFragment> t, int requestCode) {
Intent intent = new Intent(context, NormalActivity.class);
intent.putExtra(NORMAL_FRAGMENT_NAME, t.getCanonicalName());
if (context instanceof Activity) {
((Activity) context).startActivityForResult(intent, requestCode);
}
}
public static void startFragmentForResult(Context context, Class<? extends NormalFragment> t, Bundle bundle, int requestCode) {
Intent intent = new Intent(context, NormalActivity.class);
intent.putExtra(NORMAL_FRAGMENT_NAME, t.getCanonicalName());
intent.putExtra(NORMAL_FRAGMENT_BUNDLE, bundle);
if (context instanceof Activity) {
((Activity) context).startActivityForResult(intent, requestCode);
}
}
@Override
protected int getLayoutId() {
@ -91,8 +82,14 @@ public class NormalActivity extends BaseActivity implements ToolbarController, T
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState == null && getIntent() != null) {
handleIntent(getIntent());
if (getIntent() != null) {
if (savedInstanceState == null) {
handleIntent(getIntent());
} else {
for (Fragment fragment : getSupportFragmentManager().getFragments()) {
if (fragment instanceof NormalFragment) mTargetFragment = fragment;
}
}
}
// setSupportActionBar(mNormalToolbar); // 替换actionBar后 toolBar无法控制
mNormalToolbar.setNavigationIcon(R.drawable.ic_bar_back);
@ -102,6 +99,14 @@ public class NormalActivity extends BaseActivity implements ToolbarController, T
onBackPressed();
}
});
mNormalTitle.setOnClickListener(view -> {
final List<Fragment> fragmentList = getSupportFragmentManager().getFragments();
for (Fragment fragment : fragmentList) {
if (fragment instanceof OnTitleClickListener) {
((OnTitleClickListener) fragment).onTitleClick();
}
}
});
}
@Override
@ -113,23 +118,34 @@ public class NormalActivity extends BaseActivity implements ToolbarController, T
private void handleIntent(Intent intent) {
String fraName = intent.getStringExtra(NORMAL_FRAGMENT_NAME);
Bundle bundle = intent.getBundleExtra(NORMAL_FRAGMENT_BUNDLE);
if (TextUtils.isEmpty(fraName)) return;
if (TextUtils.isEmpty(fraName)) {
if (provideNormalIntent() == null) {
return;
}
fraName = provideNormalIntent().getStringExtra(NORMAL_FRAGMENT_NAME);
if (bundle == null) bundle = getIntent().getExtras();
if (TextUtils.isEmpty(fraName)) return;
}
mTargetFragment = Fragment.instantiate(this, fraName, bundle);
getSupportFragmentManager().beginTransaction().replace(R.id.normal_content, mTargetFragment).commitNowAllowingStateLoss();
}
@Override
public void setNavigationTitle(@StringRes int res) {
if (mNormalTitle == null) return;
mNormalTitle.setText(res);
}
@Override
public void setNavigationTitle(CharSequence res) {
mNormalTitle.setText(res);
public void setNavigationTitle(String res) {
if (mNormalTitle == null) return;
if (res != null)
mNormalTitle.setText(res);
}
@Override
public void setToolbarMenu(@MenuRes int res) {
if (mNormalToolbar == null) return;
mNormalToolbar.inflateMenu(res);
mNormalToolbar.setOnMenuItemClickListener(this);
@ -138,16 +154,23 @@ public class NormalActivity extends BaseActivity implements ToolbarController, T
MenuItem menuItem = menu.getItem(i);
// menu设置actionLayout后无法捕捉点击事件以icon为tag如果icon is null 手动设置menuItem点击事件
if (menuItem != null && menuItem.getIcon() == null) {
menuItem.getActionView().setOnClickListener((v) -> this.onMenuItemClick(menuItem));
if (menuItem.getActionView() != null) {
menuItem.getActionView().setOnClickListener((v) -> this.onMenuItemClick(menuItem));
}
}
}
}
@Override
public MenuItem getMenuItem(int res) {
if (mNormalToolbar == null) return null; //后续页面做好判断
return mNormalToolbar.getMenu().findItem(res);
}
public Menu getMenu() {
return mNormalToolbar.getMenu();
}
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
if (mTargetFragment instanceof NormalFragment) {
@ -163,4 +186,11 @@ public class NormalActivity extends BaseActivity implements ToolbarController, T
}
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (mTargetFragment instanceof NormalFragment) {
((NormalFragment) mTargetFragment).onTouchEvent(ev);
}
return super.dispatchTouchEvent(ev);
}
}

View File

@ -0,0 +1,32 @@
package com.gh.gamecenter;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.gh.common.util.EntranceUtils;
import com.gh.gamecenter.ask.QuestionsEditFragment;
import com.gh.gamecenter.ask.entity.QuestionsDetailEntity;
/**
* Created by khy on 10/04/18.
*/
public class QuestionEditActivity extends NormalActivity {
public static Intent getIntent(Context context, String searchKey) {
Bundle bundle = new Bundle();
bundle.putString(EntranceUtils.KEY_SEARCHKEY, searchKey);
return getTargetIntent(context, QuestionEditActivity.class, QuestionsEditFragment.class, bundle);
}
public static Intent getIntent(Context context) {
return getTargetIntent(context, QuestionEditActivity.class, QuestionsEditFragment.class);
}
public static Intent getIntent(Context context, QuestionsDetailEntity entity) {
Bundle bundle = new Bundle();
bundle.putParcelable(QuestionsDetailEntity.TAG, entity);
return getTargetIntent(context, QuestionEditActivity.class, QuestionsEditFragment.class, bundle);
}
}

View File

@ -1,205 +1,32 @@
package com.gh.gamecenter;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.RelativeLayout;
import com.gh.base.BaseActivity;
import com.gh.common.util.EntranceUtils;
import com.gh.common.util.ShareUtils;
import com.gh.gamecenter.ask.entity.QuestionsDetailEntity;
import com.gh.gamecenter.ask.questionsdetail.AnswerEditFragment;
import com.gh.gamecenter.ask.questionsdetail.AnswerFoldFragment;
import com.gh.gamecenter.ask.questionsdetail.QuestionsDetailFragment;
import com.gh.gamecenter.ask.questionsdetail.QuestionsInviteFragment;
/**
* Created by khy on 7/12/17.
* Created by khy on 10/04/18.
*/
public class QuestionsDetailActivity extends BaseActivity implements FragmentManager.OnBackStackChangedListener, View.OnClickListener {
public class QuestionsDetailActivity extends NormalActivity {
public static final String TAG = "QuestionsDetailActivity";
public static final String QUESTIONS_DETAIL_ANSWER = "answer";
public static final String QUESTIONS_DETAIL_INVITE = "invite";
public static final String QUESTIONS_DETAIL_FOLD = "fold";
public static final String QUESTIONS_DETAIL = "questions_detail";
private static final int QUESTIONS_DETAIL_ANSWER_REQUEST = 110;
private View mShareIv;
private QuestionsDetailFragment mQuestionsDetailFragment;
private String mQuestionsId;
public static Intent getIntent(Context context, String questionsId, String entrance) {
Intent intent = new Intent(context, QuestionsDetailActivity.class);
intent.putExtra(EntranceUtils.KEY_QUESTIONS_ID, questionsId);
intent.putExtra(EntranceUtils.KEY_ENTRANCE, entrance);
return intent;
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == QUESTIONS_DETAIL_ANSWER_REQUEST) {
if (resultCode == AnswerEditFragment.SAVE_DRAFTS) {
mQuestionsDetailFragment.postDraftsSuccess();
} else if (resultCode == Activity.RESULT_OK) {
if (data != null)
mQuestionsDetailFragment.postAnswerSuccess(data.getStringExtra(EntranceUtils.KEY_ANSWER_ID));
}
}
}
@Override
protected int getLayoutId() {
return R.layout.activity_ask_questionsdetail;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mQuestionsId = getIntent().getStringExtra(EntranceUtils.KEY_QUESTIONS_ID);
if (getIntent().getBundleExtra(EntranceUtils.KEY_DATA) != null) {
mQuestionsId = getIntent().getBundleExtra(EntranceUtils.KEY_DATA).getString(EntranceUtils.KEY_QUESTIONS_ID);
}
getSupportFragmentManager().addOnBackStackChangedListener(this);
show(QUESTIONS_DETAIL);
}
@Override
public boolean onHandleBackPressed() {
if (mQuestionsDetailFragment.isVisible()) {
finish();
} else {
getSupportFragmentManager().popBackStack();
}
return false;
}
@Override
public void onClick(View view) {
if (view == mShareIv) {
String shreIcon;
QuestionsDetailEntity data = mQuestionsDetailFragment.getQuestionsDetailData();
if (data == null) return;
if (data.getImages().size() > 0) {
shreIcon = data.getImages().get(0);
} else {
shreIcon = getString(R.string.share_ghzs_logo);
}
String description = data.getDescription();
if (TextUtils.isEmpty(description)) {
description = getString(R.string.ask_share_default_summary);
}
ShareUtils.getInstance(this).showShareWindows(this, view, getString(R.string.share_questions_url, data.getId())
, shreIcon
, getString(R.string.ask_share_questions_title, data.getTitle(), data.getAnswersCount())
, description, ShareUtils.ShareType.askNormal);
}
}
private void addShareView() {
RelativeLayout reuse_actionbar = mContentView.findViewById(R.id.reuse_actionbar);
mShareIv = LayoutInflater.from(this).inflate(R.layout.menu_action_share, reuse_actionbar, false);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mShareIv.getLayoutParams();
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
params.addRule(RelativeLayout.CENTER_VERTICAL);
reuse_actionbar.addView(mShareIv, params);
mShareIv.setOnClickListener(this);
}
public void show(String type) {
showMenu(type);
switch (type) {
case QUESTIONS_DETAIL_ANSWER:
showAnswerEdit(type);
break;
case QUESTIONS_DETAIL_INVITE:
showQuestionsInvite(type);
break;
case QUESTIONS_DETAIL_FOLD:
showDetailFold(type);
break;
case QUESTIONS_DETAIL:
showQuestionsDetail(type);
break;
}
}
private void showQuestionsDetail(String type) {
mQuestionsDetailFragment = QuestionsDetailFragment.getInstance(mQuestionsId);
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.layout_fragment_content, mQuestionsDetailFragment)
.commitAllowingStateLoss();
}
private void showDetailFold(String type) {
AnswerFoldFragment fragment = AnswerFoldFragment.getInstance(mQuestionsId, mEntrance + "+(问题详情)");
getSupportFragmentManager()
.beginTransaction()
.addToBackStack(type)
.replace(R.id.layout_fragment_content, fragment)
.commitAllowingStateLoss();
}
private void showQuestionsInvite(String type) {
QuestionsDetailEntity data = mQuestionsDetailFragment.getQuestionsDetailData();
if (data == null) return;
QuestionsInviteFragment fragment = QuestionsInviteFragment.getInstance(data);
getSupportFragmentManager()
.beginTransaction()
.addToBackStack(type)
.replace(R.id.layout_fragment_content, fragment)
.commitAllowingStateLoss();
}
private void showAnswerEdit(String type) {
public static Intent getIntent(Context context, String questionId, String entrance) {
Bundle bundle = new Bundle();
bundle.putString(EntranceUtils.KEY_QUESTIONS_ID, mQuestionsId);
bundle.putString(EntranceUtils.KEY_QUESTIONS_TITLE, mQuestionsDetailFragment.getQuestionsTitle());
NormalActivity.startFragmentForResult(this, AnswerEditFragment.class, bundle, QUESTIONS_DETAIL_ANSWER_REQUEST);
bundle.putString(EntranceUtils.KEY_QUESTIONS_ID, questionId);
bundle.putString(EntranceUtils.KEY_ENTRANCE, entrance);
return getTargetIntent(context, QuestionsDetailActivity.class, QuestionsDetailFragment.class, bundle);
}
private void showMenu(String type) {
switch (type) {
case QUESTIONS_DETAIL:
setNavigationTitle("问题详情");
if (mShareIv == null) {
addShareView();
} else {
mShareIv.setVisibility(View.VISIBLE);
}
break;
case QUESTIONS_DETAIL_INVITE:
setNavigationTitle("达人推荐");
if (mShareIv != null && mShareIv.getVisibility() == View.VISIBLE)
mShareIv.setVisibility(View.GONE);
break;
case QUESTIONS_DETAIL_FOLD:
setNavigationTitle("折叠回答");
if (mShareIv != null && mShareIv.getVisibility() == View.VISIBLE)
mShareIv.setVisibility(View.GONE);
break;
}
}
@Override
public void onBackStackChanged() {
if (mQuestionsDetailFragment.isVisible()) {
showMenu(QUESTIONS_DETAIL);
}
public static Intent getIntent(Context context, String questionId, String entrance, boolean isCheckConcern) {
Bundle bundle = new Bundle();
bundle.putString(EntranceUtils.KEY_QUESTIONS_ID, questionId);
bundle.putString(EntranceUtils.KEY_ENTRANCE, entrance);
bundle.putBoolean(EntranceUtils.KEY_CHECK_QUESTION_CONCERN, isCheckConcern);
return getTargetIntent(context, QuestionsDetailActivity.class, QuestionsDetailFragment.class, bundle);
}
}

View File

@ -0,0 +1,21 @@
package com.gh.gamecenter;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.gh.gamecenter.ask.entity.QuestionsDetailEntity;
import com.gh.gamecenter.ask.questionsdetail.invite.QuestionsInviteWrapperFragment;
/**
* Created by khy on 10/04/18.
*/
public class QuestionsInviteActivity extends NormalActivity {
public static Intent getIntent(Context context, QuestionsDetailEntity entity) {
Bundle bundle = new Bundle();
bundle.putParcelable(QuestionsDetailEntity.TAG, entity);
return getTargetIntent(context, QuestionsInviteActivity.class, QuestionsInviteWrapperFragment.class, bundle);
}
}

View File

@ -206,7 +206,6 @@ public class SearchActivity extends BaseActivity {
//热门搜索
isSearchDetail = true;
searchKey = key;
Utils.log("=======key::" + key);
searchInput.setText(key);
searchInput.setSelection(searchInput.getText().length());
setResultPresentModel(2);
@ -266,7 +265,7 @@ public class SearchActivity extends BaseActivity {
default:
break;
}
transaction.commit();
transaction.commitAllowingStateLoss();
}
@Subscribe(threadMode = ThreadMode.MAIN)

View File

@ -9,7 +9,6 @@ import com.halo.assistant.fragment.user.SelectPortraitFragment;
/**
* Created by khy on 2017/2/10.
*/
@Deprecated
public class SelectUserIconActivity extends NormalActivity {
@NonNull
@ -17,7 +16,7 @@ public class SelectUserIconActivity extends NormalActivity {
// return new IntentFactory.Builder(context)
// .setActivity(SelectUserIconActivity.class)
// .setFragment(SelectPortraitFragment.class).build();
return getIntent(context, SelectPortraitFragment.class);
return getTargetIntent(context,SelectUserIconActivity.class, SelectPortraitFragment.class);
}
}

View File

@ -18,7 +18,7 @@ import com.halo.assistant.fragment.SettingsFragment;
public class SettingActivity extends NormalActivity {
@NonNull
public static Intent getIntent(Context context, String entrance) {
public static Intent getIntent(Context context, boolean isUpdate, String entrance) {
// Intent intent = new Intent(context, SettingActivity.class);
// intent.putExtra(EntranceUtils.KEY_ENTRANCE, entrance);
// return intent;
@ -28,7 +28,8 @@ public class SettingActivity extends NormalActivity {
// .setFragment(SettingsFragment.class).build();
Bundle args = new Bundle();
args.putString(EntranceUtils.KEY_ENTRANCE, entrance);
return getIntent(context, SettingsFragment.class);
args.putBoolean(EntranceUtils.KEY_VERSION_UPDATE, isUpdate);
return getTargetIntent(context, SettingActivity.class, SettingsFragment.class, args);
}
}

View File

@ -135,7 +135,7 @@ public class ShareCardPicActivity extends BaseActivity {
setNavigationTitle(getString(R.string.title_share_card_pic));
shareArrImg = new Vector<>();
shareArrImg.addAll(arrImg);
if (arrImg != null) shareArrImg.addAll(arrImg);
mActionbar.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), android.R.color.black));

View File

@ -8,7 +8,6 @@ import android.text.TextUtils;
import com.gh.base.BaseActivity;
import com.gh.common.util.EntranceUtils;
import com.gh.common.util.PlatformUtils;
import com.gh.gamecenter.ask.AnswerDetailFragment;
import com.lightgame.config.CommonDebug;
import com.lightgame.utils.Utils;
@ -64,10 +63,9 @@ public class SkipActivity extends BaseActivity {
}
Intent intent = new Intent();
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(KEY_ENTRANCE, ENTRANCE_BROWSER);
Bundle bundle = new Bundle();
bundle.putString(KEY_ENTRANCE, ENTRANCE_BROWSER);
if (host != null) {
switch (host) {
case HOST_ARTICLE:
@ -99,7 +97,7 @@ public class SkipActivity extends BaseActivity {
bundle.putString(KEY_PACKAGENAME, uri.getQueryParameter(KEY_PACKAGENAME));
break;
case HOST_ANSWER:
bundle.putString(KEY_TO, AnswerDetailFragment.TAG);
bundle.putString(KEY_TO, AnswerDetailActivity.TAG);
bundle.putString(KEY_ANSWER_ID, id);
bundle.putString(KEY_PACKAGENAME, uri.getQueryParameter(KEY_PACKAGENAME));
break;

View File

@ -4,7 +4,6 @@ import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
@ -27,19 +26,11 @@ import com.gh.common.util.TagUtils;
import com.gh.common.util.TimestampUtils;
import com.gh.common.util.TokenUtils;
import com.gh.download.DownloadManager;
import com.gh.gamecenter.eventbus.EBReuse;
import com.gh.gamecenter.manager.FilterManager;
import com.gh.gamecenter.retrofit.JSONObjectResponse;
import com.gh.gamecenter.retrofit.RetrofitManager;
import com.halo.assistant.HaloApp;
import com.lightgame.download.FileUtils;
import com.lightgame.utils.AppManager;
import com.lightgame.utils.Utils;
import org.greenrobot.eventbus.EventBus;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@ -49,10 +40,6 @@ import java.util.Locale;
import pub.devrel.easypermissions.AfterPermissionGranted;
import pub.devrel.easypermissions.EasyPermissions;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import static com.gh.common.util.EntranceUtils.KEY_DATA;
/**
* 引导页面
@ -89,7 +76,7 @@ public class SplashScreenActivity extends BaseActivity {
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(KEY_DATA, bundle);
intent.putExtras(bundle);
return intent;
}
@ -167,12 +154,8 @@ public class SplashScreenActivity extends BaseActivity {
// 跳转到主界面
private void launch() {
Bundle bundle = getIntent().getExtras();
if (getIntent().getBundleExtra(KEY_DATA) != null) {
bundle = getIntent().getBundleExtra(KEY_DATA);
}
Intent intent = new Intent(SplashScreenActivity.this, MainActivity.class);
intent.putExtra(KEY_DATA, bundle);
if (bundle != null) intent.putExtras(bundle);
startActivity(intent);
finish();
}
@ -204,14 +187,6 @@ public class SplashScreenActivity extends BaseActivity {
TagUtils.getInstance(getApplicationContext()).getTag();
}
// 获取下载按钮状态、开启or关闭
if (mSharedPreferences.getBoolean("isCheckShow", true)) {
getDownloadStatus();
}
// 获取界面设置
getUISetting();
// 更新本地时间
TokenUtils.getTime(this);
@ -306,62 +281,6 @@ public class SplashScreenActivity extends BaseActivity {
}
}
// 获取下载按钮显示状态
private void getDownloadStatus() {
String channel = HaloApp.getInstance().getChannel();
RetrofitManager.getInstance(this).getApi().getDownloadStatus(
PackageUtils.getVersionName(getApplicationContext()), channel)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new JSONObjectResponse() {
@Override
public void onResponse(JSONObject response) {
if (response.length() != 0) {
try {
String status = response.getString("status");
if ("on".equals(status)) {
Editor editor = mSharedPreferences.edit();
editor.putBoolean("isShow", true);
editor.putBoolean("isCheckShow", false);
editor.apply();
} else {
mSharedPreferences.edit().putBoolean("isShow", false).apply();
}
EventBus.getDefault().post(new EBReuse("Refresh"));
} catch (JSONException e) {
e.printStackTrace();
}
}
}
});
}
// 获取界面设置
private void getUISetting() {
RetrofitManager.getInstance(this).getApi().getUISetting()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new JSONObjectResponse() {
@Override
public void onResponse(JSONObject response) {
if (response.length() != 0) {
try {
Editor editor = mSharedPreferences.edit();
editor.putInt("download_box_row",
response.getJSONObject("download_box").getInt("row"));
editor.putInt("download_box_column",
response.getJSONObject("download_box").getInt("column"));
editor.putInt("game_detail_news_type_tab_column",
response.getJSONObject("game_detail_news_type_tab").getInt("column"));
editor.apply();
} catch (JSONException e) {
e.printStackTrace();
}
}
}
});
}
private class GuidePagerAdapter extends PagerAdapter {
private int[] mPics = {R.drawable.splash_01};

View File

@ -1,8 +1,10 @@
package com.gh.gamecenter;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.gh.common.util.DataUtils;
import com.gh.common.util.EntranceUtils;
import com.gh.gamecenter.subject.SubjectWrapperFragment;
@ -10,13 +12,18 @@ import com.gh.gamecenter.subject.SubjectWrapperFragment;
/**
* Created by khy on 2017/4/29.
*/
@Deprecated
public class SubjectActivity extends NormalActivity {
@Override
protected Intent provideNormalIntent() {
return getTargetIntent(this, SubjectActivity.class, SubjectWrapperFragment.class);
}
/**
* 启动专题页面
*/
public static void startSubjectActivity(Context context, String id, String name, boolean isOrder, String entrance) {
DataUtils.onMtaEvent(context, "详情页面", "专题详情", name);
Bundle args = new Bundle();
args.putString(EntranceUtils.KEY_ID, id);
args.putString(EntranceUtils.KEY_NAME, name);
@ -27,7 +34,7 @@ public class SubjectActivity extends NormalActivity {
// .setArgs(args)
// .setActivity(SubjectActivity.class)
// .setFragment(SubjectWrapperFragment.class).start();
context.startActivity(getIntent(context, SubjectWrapperFragment.class, args));
context.startActivity(getTargetIntent(context, SubjectActivity.class, SubjectWrapperFragment.class, args));
}
}

View File

@ -41,7 +41,6 @@ import com.gh.gamecenter.entity.InstallGameEntity;
import com.gh.gamecenter.entity.SuggestionTypeEntity;
import com.gh.gamecenter.entity.UserInfoEntity;
import com.gh.gamecenter.manager.UserManager;
import com.gh.gamecenter.retrofit.JSONObjectResponse;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
import com.gh.gamecenter.suggest.SuggestPicAdapter;
@ -49,6 +48,7 @@ import com.gh.gamecenter.suggest.SuggestSelectGameAdapter;
import com.gh.gamecenter.suggest.SuggestTypeAdapter;
import com.google.gson.Gson;
import com.halo.assistant.HaloApp;
import com.lightgame.config.CommonDebug;
import com.lightgame.download.FileUtils;
import com.lightgame.utils.Util_System_Keyboard;
import com.lightgame.utils.Util_System_Phone_State;
@ -74,6 +74,7 @@ import butterknife.BindView;
import butterknife.OnClick;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.HttpException;
import rx.Observable;
import rx.Observer;
@ -115,6 +116,7 @@ public class SuggestionActivity extends BaseActivity implements SuggestTypeAdapt
ScrollView mScrollView;
public static final int MEDIA_STORE_REQUEST = 1;
public static final String SUGGESTION_HINT_TYPE = "SUGGESTION_HINT_TYPE";
private SuggestPicAdapter mAdapter;
@ -171,7 +173,7 @@ public class SuggestionActivity extends BaseActivity implements SuggestTypeAdapt
File file = new File(picturePath);
if (file.length() > 8 * 1024 * 1024) {
toast(getString(R.string.suggestion_pic_hint));
toast(R.string.suggestion_pic_hint);
} else {
String newPath = getCacheDir() + File.separator + System.currentTimeMillis() + ".jpg";
Observable.create((Observable.OnSubscribe<Boolean>)
@ -208,12 +210,6 @@ public class SuggestionActivity extends BaseActivity implements SuggestTypeAdapt
String suggestContent = extras.getString(EntranceUtils.KEY_CONTENT);
String suggestHintType = extras.getString(EntranceUtils.KEY_SUGGEST_HINT_TYPE);
Bundle data = getIntent().getBundleExtra(EntranceUtils.KEY_DATA);
if (data != null) {
suggestContent = data.getString(EntranceUtils.KEY_CONTENT);
suggestHintType = data.getString(EntranceUtils.KEY_SUGGEST_HINT_TYPE);
curType = data.getInt(EntranceUtils.KEY_SUGGESTTYPE);
}
sp = PreferenceManager.getDefaultSharedPreferences(this);
@ -247,7 +243,7 @@ public class SuggestionActivity extends BaseActivity implements SuggestTypeAdapt
mSuggestContentEt.setVisibility(View.VISIBLE);
}
String suggestionType = sp.getString("SuggestionType", null);
String suggestionType = sp.getString(SUGGESTION_HINT_TYPE, null);
if (!TextUtils.isEmpty(suggestHintType) && !TextUtils.isEmpty(suggestionType)) {
Gson gson = new Gson();
SuggestionTypeEntity typeEntity = gson.fromJson(suggestionType, SuggestionTypeEntity.class);
@ -277,6 +273,12 @@ public class SuggestionActivity extends BaseActivity implements SuggestTypeAdapt
showHintDialog(service);
}
break;
case "report" :
List<String> report = typeEntity.getReport();
if (report != null && report.size() > 0) {
showHintDialog(report);
}
break;
}
}
}
@ -400,29 +402,26 @@ public class SuggestionActivity extends BaseActivity implements SuggestTypeAdapt
return;
}
CheckLoginUtils.checkLogin(this, new CheckLoginUtils.OnLoggenInListener() {
@Override
public void onLoggedIn() {
String email = mSuggestEmailEt.getText().toString().trim();
String url = mSuggestNewsLinkEt.getText().toString().trim();
CheckLoginUtils.checkLogin(this, () -> {
String email = mSuggestEmailEt.getText().toString().trim();
String url = mSuggestNewsLinkEt.getText().toString().trim();
if (!TextUtils.isEmpty(url) && !PatternUtils.isUrlAddress(url)) {
Utils.toast(SuggestionActivity.this, getString(R.string.suggestion_url_error_hint));
return;
}
if (!TextUtils.isEmpty(url) && !PatternUtils.isUrlAddress(url)) {
toast(R.string.suggestion_url_error_hint);
return;
}
if (TextUtils.isEmpty(email)) {
showConfirmDialog(email);
if (TextUtils.isEmpty(email)) {
showConfirmDialog(email);
} else {
postDialog = WaitingDialogFragment.newInstance(getString(R.string.dialog_feedback_doing));
postDialog.show(getSupportFragmentManager(), null);
List<String> fileList = mAdapter.getFileList();
if (fileList != null && fileList.size() > 0) {
postPic(email);
} else {
postDialog = WaitingDialogFragment.newInstance(getString(R.string.dialog_feedback_doing));
postDialog.show(getSupportFragmentManager(), null);
List<String> fileList = mAdapter.getFileList();
if (fileList != null && fileList.size() > 0) {
postPic(email);
} else {
initPostData(email, null);
}
initPostData(email, null);
}
}
});
@ -477,7 +476,7 @@ public class SuggestionActivity extends BaseActivity implements SuggestTypeAdapt
@Override
public void call(Subscriber<? super JSONObject> subscriber) {
for (String s : mAdapter.getFileList()) { // 加载图片时已经压缩
subscriber.onNext(FileUtils.uploadFile(Config.API_HOST + "support/upload/img?type=suggestion", s, UserManager.getInstance().getToken()));
subscriber.onNext(FileUtils.uploadFile(Config.API_HOST + "images?type=suggestion", s, UserManager.getInstance().getToken()));
}
subscriber.onCompleted();
}
@ -505,7 +504,7 @@ public class SuggestionActivity extends BaseActivity implements SuggestTypeAdapt
try {
int statusCode = result.getInt("statusCode");
if (statusCode == HttpURLConnection.HTTP_OK) {
picArray.put(result.getString("icon"));
picArray.put(result.getString("url"));
}
} catch (Exception e) {
e.printStackTrace();
@ -558,35 +557,29 @@ public class SuggestionActivity extends BaseActivity implements SuggestTypeAdapt
RetrofitManager.getInstance(this).getApi().postSuggestion(body)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new JSONObjectResponse() {
.subscribe(new Response<ResponseBody>() {
@Override
public void onResponse(JSONObject response) {
public void onResponse(ResponseBody response) {
if (postDialog != null) {
postDialog.dismissAllowingStateLoss();
}
if (response.length() != 0) {
try {
if ("ok".equals(response.getString("status"))) {
toast("感谢您的反馈!");
setResult(SUGGEST_TYPE_REQUEST);
finish();
} else {
toast("提交失败,请稍后尝试!");
}
} catch (JSONException e) {
e.printStackTrace();
}
} else {
toast("提交失败,请稍后尝试!");
toast("感谢您的反馈!");
setResult(SUGGEST_TYPE_REQUEST);
finish();
try {
Utils.log("sendSuggestion::onResponse->" + response.string());
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void onFailure(HttpException e) {
try {
if (e != null) {
if (CommonDebug.IS_DEBUG && e != null) {
String string = e.response().errorBody().string();
Utils.log("sendSuggestion::onFailure->" + string);
}
} catch (IOException e1) {
e1.printStackTrace();

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