Compare commits
289 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 783fbecb00 | |||
| de1b5ba2f3 | |||
| 9a9e288c44 | |||
| 424b48f631 | |||
| 86d1cd4e12 | |||
| e700ff4744 | |||
| 34729c8c28 | |||
| 5a08611fdd | |||
| a73da1d6e4 | |||
| 28b8c20756 | |||
| 6941821b71 | |||
| 3c2244701c | |||
| 38dc873e2e | |||
| c24ffb2489 | |||
| 929864be30 | |||
| bd87163a9b | |||
| 785c740668 | |||
| 25aa16f774 | |||
| 9ec89c0dc1 | |||
| 3e5bd2b087 | |||
| 9de6cff13b | |||
| 6b98bc9fca | |||
| cdf9b0a071 | |||
| ff57e9c759 | |||
| b253113843 | |||
| b7305337bf | |||
| 455e2ad723 | |||
| 8cf87b991b | |||
| ae0b289c3e | |||
| 9404c3349a | |||
| 28afbb8d35 | |||
| 5b24443121 | |||
| 1f9aacbbbd | |||
| d194b33a5d | |||
| 55010f0ef7 | |||
| 49fab9ed04 | |||
| 1cd1b578ec | |||
| 184c56aac5 | |||
| 7c39037472 | |||
| 786a803793 | |||
| 273f0e185d | |||
| eebc2c3940 | |||
| 3a964d629e | |||
| ff041f705e | |||
| af62fc9a68 | |||
| 6ff415cc0d | |||
| 41de94e6f5 | |||
| 60d91ca04e | |||
| 19004b2073 | |||
| 70b536e6bd | |||
| 5009678587 | |||
| a7a01bbe16 | |||
| 9b2ce51c87 | |||
| c735d4e717 | |||
| 6fb4dac45d | |||
| 3d49258b84 | |||
| c23aa12d09 | |||
| 6f6ddf9fbd | |||
| 63837b5c31 | |||
| 27e245c241 | |||
| 7775494ade | |||
| a3ce139b86 | |||
| ad470f10f4 | |||
| 302d12083b | |||
| d40dd15af4 | |||
| 440eb8a07b | |||
| 361b861d5f | |||
| b518b2961a | |||
| bfae4e1501 | |||
| d3e13dd8c6 | |||
| 073c35ca08 | |||
| 99b4373561 | |||
| 52dcea477e | |||
| 6abb8d715b | |||
| 51016b0704 | |||
| d14c150070 | |||
| f59f8a3e5b | |||
| 965be0b5cd | |||
| 716900fc5d | |||
| 14280d802e | |||
| 39924857e5 | |||
| c88bda6615 | |||
| ecb80ca70d | |||
| 51b03b78ce | |||
| a7fd029ed2 | |||
| 5beb29ad09 | |||
| e7dc2ca810 | |||
| b5ce0db1ff | |||
| c8b52902e9 | |||
| dbc4e0ac26 | |||
| a0d2860970 | |||
| 77c1a05a4a | |||
| aeee2e049d | |||
| 525b184ad4 | |||
| 76e0fe9f9a | |||
| 06ddef114c | |||
| 32cdcc1304 | |||
| 4a2b414b59 | |||
| 937497aec9 | |||
| 38d2c189e8 | |||
| 57aeacf3f5 | |||
| fe4036b768 | |||
| 5dd479c492 | |||
| 5f1ff1fc6f | |||
| b08fb1f170 | |||
| e2f6180d6d | |||
| 90d19ea381 | |||
| 13738f08eb | |||
| 1b76184946 | |||
| 711431f7c9 | |||
| 4ea3f7ccf0 | |||
| 80cd86ea29 | |||
| f87bb6cd06 | |||
| ea726a22bd | |||
| 7e3afe7d70 | |||
| 8131c58fbf | |||
| 674e32a096 | |||
| f5d42a3e01 | |||
| a079a03adc | |||
| 8485f94133 | |||
| 5d60a8f03b | |||
| ec4319b74a | |||
| 41c3f9d073 | |||
| c27990b395 | |||
| 2e9a823ee1 | |||
| 590afccae7 | |||
| 7a82780826 | |||
| c75e363a06 | |||
| 573b7b61cf | |||
| 9f9e1bc9fd | |||
| 34e11b1569 | |||
| cc7b77a8ad | |||
| ed3a75ddc0 | |||
| 983c01df57 | |||
| 9d95b7aa6b | |||
| 5319cb8679 | |||
| b4b1a63c22 | |||
| 2dfd57de80 | |||
| cbc8876656 | |||
| 4e6b8bf6b3 | |||
| da92826f6a | |||
| f1a4e429f3 | |||
| 3cd248a2c5 | |||
| 7f5dd97359 | |||
| c0ee431d1f | |||
| f56de73eb6 | |||
| a0b5cd00d5 | |||
| 66b5f3d896 | |||
| a4346a6f34 | |||
| 83894f6530 | |||
| 9b776bb029 | |||
| ea72fb09e0 | |||
| b2b390cf8b | |||
| 926abe248f | |||
| 95468cf83e | |||
| 259b93eb25 | |||
| f59646643f | |||
| 7130417e60 | |||
| 458a9f2a63 | |||
| 0f85497f75 | |||
| 3c0c6afd43 | |||
| 345cdb41bc | |||
| b78fa40eff | |||
| 193831ae7e | |||
| bcb9dc3ba8 | |||
| 7903cdc44a | |||
| a66c1ea50b | |||
| 978e8f160b | |||
| a49351a146 | |||
| 07d9b416a3 | |||
| f9edb69370 | |||
| deac313ba3 | |||
| b149f9acf2 | |||
| 7c96ba090e | |||
| 11ab908848 | |||
| 3d2978b2e5 | |||
| 7ad3a7ae92 | |||
| 9042488a65 | |||
| b08e13f05a | |||
| 6271fd4998 | |||
| 4d747a3df3 | |||
| 5ce057d40e | |||
| 1e2e8f932f | |||
| 5accb9c1f1 | |||
| 5b102d65c7 | |||
| c609ddd721 | |||
| 0c3783d127 | |||
| f702ab6115 | |||
| 7dd760e0fb | |||
| c6f3b5998c | |||
| 28440d97de | |||
| 2b2b71fe01 | |||
| f5a9e7b487 | |||
| d43842a0e6 | |||
| a557962f17 | |||
| 560c682157 | |||
| a0ae36f511 | |||
| bdee17ffc4 | |||
| 5829f09f8c | |||
| bc6fa5e7db | |||
| 1607cea9ce | |||
| 426019ea7c | |||
| 1b878a50c4 | |||
| 97525189b7 | |||
| 999947751a | |||
| 2def61ab43 | |||
| 5e07ef488c | |||
| 7af47c0caf | |||
| 1a5ed3c05f | |||
| 9cc9b09861 | |||
| cef4432d97 | |||
| 18be6acc34 | |||
| 27d0dd40d0 | |||
| b05fa626f6 | |||
| f1fc84ea5f | |||
| 3942154c05 | |||
| ff182ee3c7 | |||
| 10cc275970 | |||
| 21821d584e | |||
| 6b8716eff8 | |||
| 47434e2943 | |||
| 4c3b327cff | |||
| 3454d13e48 | |||
| 0aad7c59ee | |||
| ee8e4e0338 | |||
| a430c51c97 | |||
| b59508e9e5 | |||
| 08deac1dea | |||
| a2dc3f3d5b | |||
| 679cfab088 | |||
| 9144595aaf | |||
| 8a545180a2 | |||
| 17c5793558 | |||
| 8afc346a2c | |||
| 026bb7f67b | |||
| b971e7dbf6 | |||
| ec39ef16e4 | |||
| ae07bacbb7 | |||
| 0f0d8da6cd | |||
| 2a1c99efac | |||
| caa89d3f4c | |||
| 1602816d08 | |||
| 1062cf5924 | |||
| f6e5cd3fd7 | |||
| c675196cb2 | |||
| 8b9c2668d1 | |||
| c1a927ed88 | |||
| 4d4416c1df | |||
| f4833983c0 | |||
| 89eb99d813 | |||
| 683a68d179 | |||
| 598af67338 | |||
| d9d0ffc3b9 | |||
| 4d8e04580e | |||
| cfaddf2f22 | |||
| c72b194107 | |||
| d7f33ff8b1 | |||
| 91e491b66a | |||
| 31b7e40ab0 | |||
| f2b094fff0 | |||
| 185ee7f0f4 | |||
| f446b15f7a | |||
| 52a833f18b | |||
| 37fc68977c | |||
| 96ee71a594 | |||
| 1c2dda9353 | |||
| 96a9fd0ad7 | |||
| c53c27e350 | |||
| fd4f32bb3c | |||
| cbd2d8ed6c | |||
| 3dd06bc620 | |||
| 3a829e1cfd | |||
| 183e1a85c3 | |||
| 6b696234ab | |||
| 21ac1d1f17 | |||
| 4163b81f70 | |||
| 6c3268ce72 | |||
| 4d87f86fcd | |||
| 4a37401dc2 | |||
| 8cf90193fc | |||
| 9942a51cad | |||
| 4980d96c8c | |||
| f32c8748ed | |||
| 7b886679e1 | |||
| 2620c04b09 | |||
| c22157f2f5 | |||
| 09f02bc225 | |||
| 9fc9549a28 | |||
| 0099afad09 |
2
.gitmodules
vendored
2
.gitmodules
vendored
@ -1,4 +1,4 @@
|
||||
[submodule "libraries/LGLibrary"]
|
||||
path = libraries/LGLibrary
|
||||
url = git@gitlab.ghzhushou.com:client/client-common.git
|
||||
url = git@gitlab.ghzhushou.com:android/common-library.git
|
||||
branch = master
|
||||
|
||||
30
CHANGELOG.md
30
CHANGELOG.md
@ -35,4 +35,32 @@
|
||||
### Ver 3.6.1
|
||||
* 可以后台控制关闭资讯功能
|
||||
* 版块、分类、专题详情、游戏详情、礼包详情增加预览骨架
|
||||
* 下载按钮状态可以通过接口屏蔽相应的包
|
||||
* 下载按钮状态可以通过接口屏蔽相应的包
|
||||
|
||||
### Ver 3.6.2
|
||||
* 资讯/问答入口和插件功能线上控制(不可逆)
|
||||
* 首页不显示已安装的游戏
|
||||
* 插件求版本功能增加内部跳转
|
||||
* 下载面板增加公告和版本说明功能
|
||||
* 接入腾讯`广点通`(广告)
|
||||
|
||||
### ver 3.6.3
|
||||
* 社区搜索修改
|
||||
- 增加 `文章/用户` 模块
|
||||
- 增加 `搜索置顶` 功能
|
||||
* 回答详情/社区文章详情修改
|
||||
- 支持文案样式(加粗/斜体/删除线)和段落样式(引用/标题)
|
||||
- 支持关闭评论功能
|
||||
- 回答详情新增上下切换回答
|
||||
* 社区编辑框(回答/文章)修改
|
||||
- 支持批量插入图片(使用知乎Matisse实现)
|
||||
- 新增插入特殊样式,文案样式(加粗/斜体/删除线)和段落样式(引用/标题)
|
||||
* 编辑框部分 JS/CSS 使用远程文件
|
||||
|
||||
### ver 3.6.4
|
||||
* 增加浏览记录(回答/文章/资讯/游戏)
|
||||
* 回答/社区文章 增加反对功能
|
||||
* 社区编辑框增加插入文章/回答/游戏
|
||||
- 低版本兼容方案: 插入的样式默认隐藏,只有在3.6.4及以上才会显示
|
||||
* 游戏详情评分模块增加`小编评论`区域以及样式修改
|
||||
* 游戏评分增加回复功能
|
||||
|
||||
@ -69,6 +69,11 @@ android {
|
||||
buildConfigField "String", "MTA_APPKEY", "\"${MTA_APPKEY}\""
|
||||
buildConfigField "String", "TD_APPID", "\"${TD_APPID}\""
|
||||
|
||||
/**
|
||||
* Build Time 供区分 jenkins 打包时间用
|
||||
*/
|
||||
buildConfigField "long", "BUILD_TIME", "0"
|
||||
|
||||
}
|
||||
|
||||
// gradle 2.2以上默认同时启用v1和v2(优先用于Android N)
|
||||
@ -91,7 +96,7 @@ android {
|
||||
signingConfig signingConfigs.debug
|
||||
|
||||
buildConfigField "String", "EXPOSURE_REPO", "\"test\""
|
||||
buildConfigField "String", "EXPOSURE_VERSION", "\"E2\""
|
||||
buildConfigField "String", "EXPOSURE_VERSION", "\"E3\""
|
||||
}
|
||||
release {
|
||||
debuggable false
|
||||
@ -101,7 +106,7 @@ android {
|
||||
signingConfig signingConfigs.release
|
||||
|
||||
buildConfigField "String", "EXPOSURE_REPO", "\"exposure\""
|
||||
buildConfigField "String", "EXPOSURE_VERSION", "\"E2\""
|
||||
buildConfigField "String", "EXPOSURE_VERSION", "\"E3\""
|
||||
}
|
||||
}
|
||||
|
||||
@ -249,6 +254,7 @@ dependencies {
|
||||
implementation "android.arch.lifecycle:extensions:${archLifecycleVersion}"
|
||||
implementation "android.arch.persistence.room:runtime:${archRoomVersion}"
|
||||
kapt "android.arch.persistence.room:compiler:${archRoomVersion}"
|
||||
implementation "android.arch.persistence.room:rxjava2:${archRoomVersion}"
|
||||
|
||||
implementation 'com.google.android:flexbox:0.2.2'
|
||||
|
||||
@ -273,6 +279,8 @@ dependencies {
|
||||
|
||||
implementation 'com.ethanhua:skeleton:1.1.1'
|
||||
implementation 'io.supercharge:shimmerlayout:2.1.0'
|
||||
implementation "com.tencent.mm.opensdk:wechat-sdk-android-without-mta:5.3.1"
|
||||
implementation 'com.walkud.rom.checker:RomChecker:1.0.0'
|
||||
|
||||
implementation project(':libraries:gid')
|
||||
implementation project(':libraries:LGLibrary')
|
||||
@ -280,9 +288,10 @@ dependencies {
|
||||
implementation project(':libraries:QQShare')
|
||||
implementation project(':libraries:TalkingData')
|
||||
implementation project(':libraries:UmengPush')
|
||||
implementation project(':libraries:WechatShare')
|
||||
// implementation project(':libraries:WechatShare')
|
||||
implementation project(':libraries:LogHub')
|
||||
implementation project(':libraries:im')
|
||||
implementation project(':libraries:Matisse')
|
||||
}
|
||||
File propFile = file('sign.properties')
|
||||
if (propFile.exists()) {
|
||||
|
||||
@ -41,12 +41,7 @@
|
||||
<uses-permission android:name = "android.permission.WRITE_SETTINGS" />
|
||||
|
||||
<!-- bugly with tinker -->
|
||||
<uses-permission android:name = "android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name = "android.permission.INTERNET" />
|
||||
<uses-permission android:name = "android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name = "android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name = "android.permission.READ_LOGS" />
|
||||
<uses-permission android:name = "android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name = "android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
|
||||
<supports-screens
|
||||
@ -60,7 +55,7 @@
|
||||
<application
|
||||
android:name = "com.halo.assistant.TinkerApp"
|
||||
android:allowBackup = "true"
|
||||
android:icon = "@drawable/logo"
|
||||
android:icon = "@mipmap/logo"
|
||||
android:label = "@string/app_name"
|
||||
android:resizeableActivity = "true"
|
||||
android:theme = "@style/AppCompatTheme.APP"
|
||||
@ -363,8 +358,8 @@
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.gamedetail.rating.edit.RatingEditActivity"
|
||||
android:windowSoftInputMode = "stateVisible"
|
||||
android:screenOrientation = "portrait" />
|
||||
android:screenOrientation = "portrait"
|
||||
android:windowSoftInputMode = "stateVisible" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.qa.questions.edit.manager.HistoryDetailActivity"
|
||||
@ -374,6 +369,26 @@
|
||||
android:name = "com.gh.gamecenter.qa.questions.edit.manager.HistoryActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.qa.editor.InsertAnswerWrapperActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.qa.editor.GameActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.qa.editor.InsertArticleWrapperActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.gamedetail.rating.RatingReplyActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = ".history.HistoryActivity"
|
||||
android:screenOrientation = "portrait" />
|
||||
|
||||
<activity
|
||||
android:name = "com.gh.gamecenter.qa.comment.CommentActivity"
|
||||
android:screenOrientation = "portrait"
|
||||
@ -398,6 +413,14 @@
|
||||
</intent-filter >
|
||||
</activity >
|
||||
|
||||
<activity
|
||||
android:name = "${applicationId}.wxapi.WXEntryActivity"
|
||||
android:exported = "true"
|
||||
android:label = "@string/app_name"
|
||||
android:launchMode = "singleTop"
|
||||
android:screenOrientation = "portrait"
|
||||
android:theme = "@android:style/Theme.Translucent.NoTitleBar" ></activity >
|
||||
|
||||
<provider
|
||||
android:name = "android.support.v4.content.FileProvider"
|
||||
android:authorities = "${applicationId}"
|
||||
|
||||
@ -1,28 +1,163 @@
|
||||
function requestContentFocus() {
|
||||
$('#editor').focus();
|
||||
$("#editor").focus();
|
||||
}
|
||||
|
||||
function setupWhenContentEditable() {
|
||||
var editor = $('#editor');
|
||||
if (!editor[0].hasAttribute('contenteditable')) {
|
||||
return;
|
||||
var editor = $("#editor");
|
||||
if (!editor[0].hasAttribute("contenteditable")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// paste
|
||||
editor.on("paste", function(e) {
|
||||
e.preventDefault();
|
||||
var text = (e.originalEvent || e).clipboardData.getData("text/plain");
|
||||
text = text.replace(/\n/g, "<br>");
|
||||
if ("" != text) {
|
||||
document.execCommand("insertHTML", false, text);
|
||||
} else {
|
||||
window.onPasteListener.onPaste();
|
||||
}
|
||||
});
|
||||
|
||||
// paste 回调只会获取粘贴之前的光标位置,需要自己手动加上粘贴文本的长度,并保证粘贴的是纯文本
|
||||
editor.on('paste', function(e) {
|
||||
e.preventDefault();
|
||||
var text = (e.originalEvent || e).clipboardData.getData('text/plain');
|
||||
text = text.replace(/\n/g, '<br>');
|
||||
if("" != text) {
|
||||
document.execCommand("insertHTML", false, text);
|
||||
} else {
|
||||
window.onPasteListener.onPaste();
|
||||
}
|
||||
});
|
||||
|
||||
requestContentFocus();
|
||||
requestContentFocus();
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
setupWhenContentEditable();
|
||||
function getStyle(dom, name) {
|
||||
return window.getComputedStyle(dom)[name];
|
||||
}
|
||||
|
||||
function customLinkgo(self) {
|
||||
var datas = self.dataset.datas;
|
||||
console.log(datas)
|
||||
window.OnLinkClickListener.onClick(datas);
|
||||
}
|
||||
|
||||
var typeClassList = [
|
||||
"community_article-container",
|
||||
"answer-container",
|
||||
"game-container"
|
||||
];
|
||||
|
||||
function removeDomByParent(curDom) {
|
||||
if (curDom.parentElement) {
|
||||
curDom.parentElement.removeChild(curDom);
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener("load", function() {
|
||||
var EditorDom = document.querySelector("#editor");
|
||||
setupWhenContentEditable();
|
||||
|
||||
document.addEventListener("keydown", function(e) {
|
||||
var event = e || window.event;
|
||||
|
||||
if (event.keyCode === 8) {
|
||||
var s = document.getSelection();
|
||||
var r = s.getRangeAt(0);
|
||||
|
||||
if (r.startOffset === r.endOffset && r.endOffset === 0) {
|
||||
var preDOM = s.focusNode.previousElementSibling;
|
||||
|
||||
if (
|
||||
preDOM &&
|
||||
preDOM instanceof Element &&
|
||||
preDOM.nodeName === "IMG" &&
|
||||
getStyle(preDOM, "display") === "block"
|
||||
) {
|
||||
preDOM.parentElement.removeChild(preDOM);
|
||||
}
|
||||
}
|
||||
|
||||
var customDom = s.focusNode;
|
||||
if (customDom) {
|
||||
if (
|
||||
r.startContainer.nodeName.toLowerCase() === "blockquote" &&
|
||||
r.startOffset === 0
|
||||
) {
|
||||
RE.formatBlock();
|
||||
e.preventDefault();
|
||||
} else if (
|
||||
customDom.nodeName === "#text" &&
|
||||
customDom.previousElementSibling &&
|
||||
typeClassList.indexOf(customDom.previousElementSibling.className) >
|
||||
-1 &&
|
||||
r.startOffset === 1
|
||||
) {
|
||||
var needDeleteDom = customDom.previousElementSibling;
|
||||
needDeleteDom.insertAdjacentElement(
|
||||
"afterend",
|
||||
document.createElement("br")
|
||||
);
|
||||
} else if (
|
||||
customDom instanceof Element &&
|
||||
customDom.childNodes[s.focusOffset] &&
|
||||
customDom.childNodes[s.focusOffset].previousElementSibling &&
|
||||
typeClassList.indexOf(
|
||||
customDom.childNodes[s.focusOffset].previousElementSibling.className
|
||||
) > -1
|
||||
) {
|
||||
customDom =
|
||||
customDom.childNodes[s.focusOffset].previousElementSibling;
|
||||
customDom.parentElement.removeChild(customDom);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener("keyup", function(e) {
|
||||
var event = e || window.event;
|
||||
if (event.keyCode === 13) {
|
||||
var s = document.getSelection();
|
||||
var curDom = s.focusNode;
|
||||
var preDom = curDom.previousElementSibling;
|
||||
|
||||
if (
|
||||
curDom.nodeName.toLowerCase() === "blockquote" &&
|
||||
preDom.nodeName.toLowerCase() === "blockquote"
|
||||
) {
|
||||
if (
|
||||
preDom.childNodes.length > 1 ||
|
||||
(preDom.childNodes.length === 1 &&
|
||||
preDom.childNodes[0].tagName !== "BR")
|
||||
) {
|
||||
curDom.style.marginTop = 0;
|
||||
preDom.style.marginBottom = 0;
|
||||
} else if (
|
||||
(curDom.childNodes.length === 0 ||
|
||||
(curDom.childNodes.length === 1 &&
|
||||
curDom.childNodes[0].tagName === "BR")) &&
|
||||
(preDom.childNodes.length === 0 ||
|
||||
(preDom.childNodes.length === 1 &&
|
||||
preDom.childNodes[0].tagName === "BR"))
|
||||
) {
|
||||
|
||||
removeDomByParent(curDom);
|
||||
|
||||
var startQuoteDom = preDom.previousElementSibling;
|
||||
startQuoteDom && startQuoteDom.nodeName.toLowerCase() === "blockquote"
|
||||
? (startQuoteDom.style.marginBottom = "10px")
|
||||
: null;
|
||||
|
||||
var range = document.createRange();
|
||||
range.selectNode(preDom);
|
||||
s.removeAllRanges();
|
||||
s.addRange(range);
|
||||
|
||||
RE.formatBlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener("selectionchange", function(e) {
|
||||
var event = e || window.event;
|
||||
var targetDom = event.target.activeElement;
|
||||
if (targetDom.id === "editor" && targetDom.lastElementChild) {
|
||||
if (typeClassList.indexOf(targetDom.lastElementChild.className) > -1) {
|
||||
var brDom = document.createElement("br");
|
||||
EditorDom.appendChild(brDom);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -4,12 +4,13 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<link rel="stylesheet" type="text/css" href="normalize.css">
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
<!--<link rel="stylesheet" type="text/css" href="https://resource.ghzs.com/css/halo_app.css">-->
|
||||
</head>
|
||||
<body>
|
||||
<div id="editor" contenteditable="true"></div>
|
||||
<script type="text/javascript" src="zepto.min.js"></script>
|
||||
<script type="text/javascript" src="rich_editor.js"></script>
|
||||
<script type="text/javascript" src="content.js"></script>
|
||||
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/vanilla-lazyload/10.15.0/lazyload.min.js"></script>-->
|
||||
<!--<script type="text/javascript" src="content.js"></script>-->
|
||||
<!--<script type="text/javascript" src="https://resource.ghzs.com/js/halo_app.js"></script>-->
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -14,6 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// alert("")
|
||||
|
||||
var RE = {};
|
||||
|
||||
RE.currentSelection = {
|
||||
@ -22,6 +24,17 @@ RE.currentSelection = {
|
||||
"endContainer": 0,
|
||||
"endOffset": 0};
|
||||
|
||||
// 引用远端的JS 和 CSS
|
||||
var script = document.createElement("script")
|
||||
script.src = "https://resource.ghzs.com/js/halo.js" + "?timestamp=" + Math.round(new Date().getTime() / 1000 / 1000)
|
||||
document.body.appendChild(script)
|
||||
|
||||
var style = document.createElement("link")
|
||||
style.rel = "stylesheet"
|
||||
style.type = "text/css"
|
||||
style.href = "https://resource.ghzs.com/css/halo.css" + "?timestamp=" + Math.round(new Date().getTime() / 1000 / 1000)
|
||||
document.head.appendChild(style)
|
||||
|
||||
RE.editor = document.getElementById('editor');
|
||||
|
||||
document.addEventListener("selectionchange", function() { RE.backuprange(); });
|
||||
@ -94,16 +107,8 @@ RE.setInputEnabled = function(inputEnabled) {
|
||||
RE.editor.contentEditable = String(inputEnabled);
|
||||
}
|
||||
|
||||
RE.setFocusByEnd = function() {
|
||||
//alert("111111")
|
||||
// var txt =RE.editor.createTextRange();
|
||||
// ("22222")
|
||||
// txt.moveStart('character',-1);
|
||||
// ("333333")
|
||||
// txt.collapse(true);
|
||||
// ("444444")
|
||||
// txt.select();
|
||||
// alert("ddddddd")
|
||||
RE.formatBlock = function() {
|
||||
document.execCommand('formatBlock', false, 'p');
|
||||
}
|
||||
|
||||
RE.undo = function() {
|
||||
@ -166,6 +171,7 @@ RE.setFontSize = function(fontSize){
|
||||
|
||||
RE.setHeading = function(heading) {
|
||||
document.execCommand('formatBlock', false, '<h'+heading+'>');
|
||||
RE.sendElementNameToNative()
|
||||
}
|
||||
|
||||
RE.setIndent = function() {
|
||||
@ -190,6 +196,9 @@ RE.setJustifyRight = function() {
|
||||
|
||||
RE.setBlockquote = function() {
|
||||
document.execCommand('formatBlock', false, '<blockquote>');
|
||||
// var blockId = window.getSelection().focusNode.parentNode;
|
||||
// $(blockId).addClass("haloBlock")
|
||||
RE.sendElementNameToNative()
|
||||
}
|
||||
|
||||
RE.insertImage = function(url) {
|
||||
@ -197,19 +206,17 @@ RE.insertImage = function(url) {
|
||||
RE.insertHTML(html);
|
||||
}
|
||||
|
||||
//RE.lazyLoad = function() {
|
||||
// var myLazyLoad = new LazyLoad({
|
||||
// elements_selector: ".lazy"
|
||||
// })
|
||||
//}
|
||||
|
||||
// 替换成缩略图
|
||||
RE.replaceTbImage = function(imgRuleFlag, gifRuleFlag) {
|
||||
var imgs = document.getElementsByTagName("img");
|
||||
var index = 0
|
||||
for (var i = 0; i < imgs.length; i++) {
|
||||
var img = imgs[i];
|
||||
var imageClassName = img.className;
|
||||
// console.log(imageClassName)
|
||||
if (imageClassName == "image-link") continue;
|
||||
if(img.src.indexOf("?") > 0) continue;
|
||||
|
||||
// console.log(i)
|
||||
var tbImg
|
||||
if(img.src.indexOf(".gif") > 0) {
|
||||
tbImg = img.src + gifRuleFlag
|
||||
@ -220,7 +227,7 @@ RE.replaceTbImage = function(imgRuleFlag, gifRuleFlag) {
|
||||
img.style.cssText = "max-width: 60%; display:block; margin:15px auto; height: auto;"
|
||||
img.src = tbImg;
|
||||
|
||||
if (i == 0) {
|
||||
if (index == 0) {
|
||||
var bigImg = document.createElement('img');
|
||||
bigImg.src = "file:///android_asset/web_load_dfimg_icon.png";
|
||||
bigImg.style.cssText = "max-width: 20%; margin:15px 0 0 0; height: auto;"
|
||||
@ -236,6 +243,7 @@ RE.replaceTbImage = function(imgRuleFlag, gifRuleFlag) {
|
||||
}
|
||||
|
||||
}
|
||||
index ++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -244,6 +252,8 @@ RE.replaceAllDfImage = function(imgRuleFlag, gifRuleFlag) {
|
||||
var imgs = document.getElementsByTagName("img");
|
||||
for (var i = 0; i < imgs.length; i++) {
|
||||
var img = imgs[i];
|
||||
var imageClassName = img.className;
|
||||
if (imageClassName == "image-link") continue;
|
||||
if(img.src.indexOf("web_load_dfimg_icon") > 0) {
|
||||
img.parentNode.removeChild(img.parentNode.childNodes[0]);
|
||||
i--;
|
||||
@ -268,6 +278,8 @@ RE.hideShowBigPic = function() {
|
||||
var j = 0;
|
||||
for (var i = 0; i < imgs.length; i++) {
|
||||
var img = imgs[i];
|
||||
var imageClassName = img.className;
|
||||
if (imageClassName == "image-link") continue;
|
||||
if(img.src.indexOf(",thumbnail") > 0 && img.src.indexOf(".gif") == -1) {
|
||||
j++;
|
||||
}
|
||||
@ -277,6 +289,8 @@ RE.hideShowBigPic = function() {
|
||||
var imgs = document.getElementsByTagName("img");
|
||||
for (var i = 0; i < imgs.length; i++) {
|
||||
var img = imgs[i];
|
||||
var imageClassName = img.className;
|
||||
if (imageClassName == "image-link") continue;
|
||||
if(img.src.indexOf("web_load_dfimg_icon") > 0) {
|
||||
img.parentNode.removeChild(img.parentNode.childNodes[0]);
|
||||
break;
|
||||
@ -289,6 +303,8 @@ RE.replaceDfImageByUrl = function(imgUrl, imgRuleFlag, gifRuleFlag) {
|
||||
var imgs = document.getElementsByTagName("img");
|
||||
for (var i = 0; i < imgs.length; i++) {
|
||||
var img = imgs[i];
|
||||
var imageClassName = img.className;
|
||||
if (imageClassName == "image-link") continue;
|
||||
if (img.src.indexOf(imgUrl) != -1) {
|
||||
img.style.cssText = "max-width: 100%; display:block; margin:8px auto; height: auto;"
|
||||
if(img.src.indexOf(".gif") > 0) {
|
||||
@ -305,6 +321,8 @@ RE.ImageClickListener = function() {
|
||||
var imgs = document.getElementsByTagName("img");
|
||||
for (var i = 0; i < imgs.length; i++) {
|
||||
var img = imgs[i];
|
||||
var imageClassName = img.className;
|
||||
if (imageClassName == "image-link") continue;
|
||||
window.imagelistener.imageArr(img.src);
|
||||
img.onclick = function() {
|
||||
window.imagelistener.imageClick(this.src);
|
||||
@ -357,12 +375,16 @@ RE.backuprange = function(){
|
||||
}
|
||||
|
||||
RE.restorerange = function(){
|
||||
var selection = window.getSelection();
|
||||
selection.removeAllRanges();
|
||||
var range = document.createRange();
|
||||
range.setStart(RE.currentSelection.startContainer, RE.currentSelection.startOffset);
|
||||
range.setEnd(RE.currentSelection.endContainer, RE.currentSelection.endOffset);
|
||||
selection.addRange(range);
|
||||
try {
|
||||
var selection = window.getSelection();
|
||||
selection.removeAllRanges();
|
||||
var range = document.createRange();
|
||||
range.setStart(RE.currentSelection.startContainer, RE.currentSelection.startOffset);
|
||||
range.setEnd(RE.currentSelection.endContainer, RE.currentSelection.endOffset);
|
||||
selection.addRange(range);
|
||||
} catch(error) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
RE.enabledEditingItems = function(e) {
|
||||
@ -432,12 +454,145 @@ RE.removeFormat = function() {
|
||||
document.execCommand('removeFormat', false, null);
|
||||
}
|
||||
|
||||
RE.insertCustomStyleLink = function(data) {
|
||||
var entity = JSON.parse(data)
|
||||
var html = "<br/><div class='"+ entity.type +"-container'>\n" +
|
||||
" <a class='"+ entity.type +"' href=\"javascript:void(0);\" contenteditable=\"false\" onclick=\"customLinkgo(this)\" data-datas='"+ data +"'>\n" +
|
||||
" <div class='flex-container'>\n" +
|
||||
" <div class='gh-internal-content img-left'>\n" +
|
||||
" <img class = \"image-link\" src='"+ entity.icon +"' />\n" +
|
||||
" </div>\n" +
|
||||
" <div class='gh-internal-content content-right'>\n" +
|
||||
" <p class='content-title'>"+ entity.title +"</p>\n" +
|
||||
" <p class='contents'>"+ entity.brief +"</p>\n" +
|
||||
" </div>\n" +
|
||||
" </div>\n" +
|
||||
" </a>\n" +
|
||||
" </div><br/>"
|
||||
var tags = "", gameHtml = ""
|
||||
if (entity.tags != null) {
|
||||
for (var i = 0; i < entity.tags.length; i++) {
|
||||
tags += "<label>"+ entity.tags[i]+"</label>"
|
||||
}
|
||||
|
||||
gameHtml = "<br/><div class='"+ entity.type +"-container'>\n" +
|
||||
" <a class='"+ entity.type +"' href=\"javascript:void(0);\" contenteditable=\"false\" onclick=\"customLinkgo(this)\" data-datas='"+ data +"'>\n" +
|
||||
" <div class='flex-container'>\n" +
|
||||
" <div class='gh-internal-content img-left'>\n" +
|
||||
" <img class='image-link' src='"+ entity.icon +"' />\n" +
|
||||
" </div>\n" +
|
||||
" <div class='gh-internal-content content-right'>\n" +
|
||||
" <p class='content-title'>"+ entity.title +"</p>\n" +
|
||||
" <p class='tags'>"+ tags +"</p>\n" +
|
||||
" </div>\n" +
|
||||
" </div>\n" +
|
||||
" </a></div><br/>"
|
||||
}
|
||||
|
||||
switch(entity.type) {
|
||||
case "answer":
|
||||
document.execCommand("insertHTML",false, html);
|
||||
break
|
||||
case "community_article":
|
||||
document.execCommand("insertHTML",false, html);
|
||||
break
|
||||
case "game":
|
||||
document.execCommand("insertHTML",false, gameHtml);
|
||||
break
|
||||
}
|
||||
RE.callback();
|
||||
}
|
||||
|
||||
RE.showLinkStyle = function() {
|
||||
var answerElement = document.getElementsByClassName("answer-container");
|
||||
for (var i=0;i<answerElement.length;i+=1){
|
||||
answerElement[i].style.display = 'inline';
|
||||
}
|
||||
var articleElement = document.getElementsByClassName("community_article-container");
|
||||
for (var i=0;i<articleElement.length;i+=1){
|
||||
articleElement[i].style.display = 'inline';
|
||||
}
|
||||
var gameElement = document.getElementsByClassName("game-container");
|
||||
for (var i=0;i<gameElement.length;i+=1){
|
||||
gameElement[i].style.display = 'inline';
|
||||
}
|
||||
}
|
||||
|
||||
RE.hideLinkStyle = function() {
|
||||
var answerElement = document.getElementsByClassName("answer-container");
|
||||
for (var i=0;i<answerElement.length;i+=1){
|
||||
answerElement[i].style.display = 'none';
|
||||
}
|
||||
var articleElement = document.getElementsByClassName("community_article-container");
|
||||
for (var i=0;i<articleElement.length;i+=1){
|
||||
articleElement[i].style.display = 'none';
|
||||
}
|
||||
var gameElement = document.getElementsByClassName("game-container");
|
||||
for (var i=0;i<gameElement.length;i+=1){
|
||||
gameElement[i].style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
// Event Listeners
|
||||
RE.editor.addEventListener("input", RE.callback);
|
||||
|
||||
RE.editor.addEventListener("keyup", function(e) {
|
||||
var KEY_LEFT = 37, KEY_RIGHT = 39;
|
||||
if (e.which == KEY_LEFT || e.which == KEY_RIGHT) {
|
||||
RE.enabledEditingItems(e);
|
||||
}
|
||||
RE.sendElementNameToNative()
|
||||
});
|
||||
RE.editor.addEventListener("click", RE.enabledEditingItems);
|
||||
|
||||
RE.editor.addEventListener("click", function(e) {
|
||||
RE.enabledEditingItems
|
||||
RE.sendElementNameToNative()
|
||||
var s = document.getSelection()
|
||||
var isNeedRemoveR = RE.recursion(e.target)
|
||||
if (isNeedRemoveR && s.rangeCount) {
|
||||
s.removeAllRanges()
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener("selectionchange", function(e) {
|
||||
RE.sendElementNameToNative()
|
||||
});
|
||||
|
||||
RE.recursion = function(dom) {
|
||||
var parenDom = dom.parentElement
|
||||
if (parenDom && parenDom instanceof Element &&
|
||||
typeClassList.indexOf(parenDom.className) > -1) {
|
||||
return parenDom
|
||||
} else if(parenDom && parenDom instanceof Element &&
|
||||
typeClassList.indexOf(parenDom.className) === -1 && parenDom.nodeName !== 'BODY') {
|
||||
return RE.recursion(parenDom)
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
// 返回组件标签 多个标签以"空格"划分
|
||||
RE.sendElementNameToNative = function() {
|
||||
if (window.getSelection) {
|
||||
var selection = window.getSelection()
|
||||
if (selection.rangeCount > 0) {
|
||||
var range = selection.getRangeAt(0);
|
||||
var container = range.startContainer;
|
||||
var elements = " " + container.localName + " ";
|
||||
var parentElement;
|
||||
while(true) {
|
||||
if(parentElement != null) {
|
||||
parentElement = parentElement.parentElement
|
||||
} else {
|
||||
parentElement = container.parentElement
|
||||
}
|
||||
if (parentElement == null || parentElement.localName == null) {
|
||||
break;
|
||||
}
|
||||
elements = elements + " " + parentElement.localName + " "
|
||||
}
|
||||
// console.log(elements)
|
||||
window.OnCursorChangeListener.onElements(elements);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
239
app/src/main/java/com/gh/base/BaseRichEditorActivity.kt
Normal file
239
app/src/main/java/com/gh/base/BaseRichEditorActivity.kt
Normal file
@ -0,0 +1,239 @@
|
||||
package com.gh.base
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.view.View
|
||||
import android.webkit.JavascriptInterface
|
||||
import butterknife.OnClick
|
||||
import com.gh.common.view.RichEditor
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.qa.editor.GameActivity
|
||||
import com.gh.gamecenter.qa.editor.InsertAnswerWrapperActivity
|
||||
import com.gh.gamecenter.qa.editor.InsertArticleWrapperActivity
|
||||
import com.gh.gamecenter.qa.entity.AnswerEntity
|
||||
import com.gh.gamecenter.qa.entity.ArticleEntity
|
||||
import com.gh.gamecenter.qa.entity.EditorInsertEntity
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Utils
|
||||
import com.lightgame.view.CheckableImageView
|
||||
import kotterknife.bindView
|
||||
|
||||
abstract class BaseRichEditorActivity : BaseActivity() {
|
||||
|
||||
val mRichEditor by bindView<RichEditor>(R.id.rich_editor)
|
||||
|
||||
private val mEditorFont by bindView<CheckableImageView>(R.id.editor_font)
|
||||
private val mEditorLink by bindView<CheckableImageView>(R.id.editor_link)
|
||||
private val mEditorParagraph by bindView<CheckableImageView>(R.id.editor_paragraph)
|
||||
private val mEditorFontBold by bindView<CheckableImageView>(R.id.editor_font_bold)
|
||||
private val mEditorFontItalic by bindView<CheckableImageView>(R.id.editor_font_italic)
|
||||
private val mEditorFontStrikeThrough by bindView<CheckableImageView>(R.id.editor_font_strikethrough)
|
||||
private val mEditorParagraphH1 by bindView<CheckableImageView>(R.id.editor_paragraph_h1)
|
||||
private val mEditorParagraphH2 by bindView<CheckableImageView>(R.id.editor_paragraph_h2)
|
||||
private val mEditorParagraphH3 by bindView<CheckableImageView>(R.id.editor_paragraph_h3)
|
||||
private val mEditorParagraphH4 by bindView<CheckableImageView>(R.id.editor_paragraph_h4)
|
||||
private val mEditorParagraphQuote by bindView<CheckableImageView>(R.id.editor_paragraph_quote)
|
||||
private val mEditorFontContainer by bindView<View>(R.id.editor_font_container)
|
||||
private val mEditorParagraphContainer by bindView<View>(R.id.editor_paragraph_container)
|
||||
private val mEditorLinkContainer by bindView<View>(R.id.editor_link_container)
|
||||
private val mEditorInsertDetail by bindView<View>(R.id.editor_insert_detail)
|
||||
|
||||
private var mCurrentParagraphStyle = ""
|
||||
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (resultCode != Activity.RESULT_OK) return
|
||||
var insertData: EditorInsertEntity? = null
|
||||
when (requestCode) {
|
||||
INSERT_ANSWER_CODE -> {
|
||||
val answer = data?.getParcelableExtra<AnswerEntity>(AnswerEntity::class.java.simpleName)
|
||||
if (answer != null) insertData = EditorInsertEntity.transform(answer)
|
||||
}
|
||||
INSERT_ARTICLE_CODE -> {
|
||||
val article = data?.getParcelableExtra<ArticleEntity>(ArticleEntity::class.java.simpleName)
|
||||
if (article != null) insertData = EditorInsertEntity.transform(article)
|
||||
}
|
||||
INSERT_GAME_CODE -> {
|
||||
val game = data?.getParcelableExtra<GameEntity>(GameEntity::class.java.simpleName)
|
||||
if (game != null) insertData = EditorInsertEntity.transform(game)
|
||||
}
|
||||
}
|
||||
if (mCurrentParagraphStyle == ELEMENT_PARAGRAPH_QUOTE || mCurrentParagraphStyle == ELEMENT_PARAGRAPH_P) {
|
||||
mRichEditor.insertHtml(" ")
|
||||
if (mCurrentParagraphStyle == ELEMENT_PARAGRAPH_QUOTE) mRichEditor.formatBlock()
|
||||
}
|
||||
|
||||
mRichEditor.insertCustomStyleLink(insertData)
|
||||
}
|
||||
|
||||
@SuppressLint("AddJavascriptInterface")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
mRichEditor.setPadding(20, 15, 20, 15)
|
||||
// 防止个别手机在Js里无法获取粘贴内容
|
||||
mRichEditor.addJavascriptInterface(OnPasteListener(), "onPasteListener")
|
||||
mRichEditor.addJavascriptInterface(OnCursorChangeListener(), "OnCursorChangeListener")
|
||||
}
|
||||
|
||||
@OnClick(R.id.editor_image, R.id.editor_font, R.id.editor_link, R.id.editor_paragraph,
|
||||
R.id.editor_font_bold, R.id.editor_font_italic, R.id.editor_font_strikethrough,
|
||||
R.id.editor_paragraph_h1, R.id.editor_paragraph_h2, R.id.editor_paragraph_h3,
|
||||
R.id.editor_paragraph_h4, R.id.editor_font_container, R.id.editor_paragraph_container,
|
||||
R.id.editor_paragraph_quote, R.id.editor_link_answer, R.id.editor_link_article,
|
||||
R.id.editor_link_game)
|
||||
fun onRichClick(view: View) {
|
||||
when (view.id) {
|
||||
R.id.editor_font -> {
|
||||
mEditorFont.isChecked = !mEditorFont.isChecked
|
||||
mEditorParagraph.isChecked = false
|
||||
mEditorLink.isChecked = false
|
||||
mEditorFontContainer.visibility = if (mEditorFont.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorParagraphContainer.visibility = if (!mEditorFont.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorLinkContainer.visibility = if (!mEditorFont.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorInsertDetail.visibility = mEditorFontContainer.visibility
|
||||
}
|
||||
R.id.editor_paragraph -> {
|
||||
mEditorParagraph.isChecked = !mEditorParagraph.isChecked
|
||||
mEditorFont.isChecked = false
|
||||
mEditorLink.isChecked = false
|
||||
mEditorParagraphContainer.visibility = if (mEditorParagraph.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorFontContainer.visibility = if (!mEditorParagraph.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorLinkContainer.visibility = if (!mEditorParagraph.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorInsertDetail.visibility = mEditorParagraphContainer.visibility
|
||||
}
|
||||
R.id.editor_link -> {
|
||||
mEditorLink.isChecked = !mEditorLink.isChecked
|
||||
mEditorFont.isChecked = false
|
||||
mEditorParagraph.isChecked = false
|
||||
mEditorLinkContainer.visibility = if (mEditorLink.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorParagraphContainer.visibility = if (!mEditorLink.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorFontContainer.visibility = if (!mEditorLink.isChecked) View.VISIBLE else View.GONE
|
||||
mEditorInsertDetail.visibility = mEditorLinkContainer.visibility
|
||||
}
|
||||
R.id.editor_font_bold -> {
|
||||
mEditorFontBold.isChecked = !mEditorFontBold.isChecked
|
||||
mRichEditor.setBold()
|
||||
}
|
||||
R.id.editor_font_italic -> {
|
||||
mEditorFontItalic.isChecked = !mEditorFontItalic.isChecked
|
||||
mRichEditor.setItalic()
|
||||
}
|
||||
R.id.editor_font_strikethrough -> {
|
||||
mEditorFontStrikeThrough.isChecked = !mEditorFontStrikeThrough.isChecked
|
||||
mRichEditor.setStrikeThrough()
|
||||
}
|
||||
R.id.editor_paragraph_h1 -> {
|
||||
if (mEditorParagraphH1.isChecked) {
|
||||
mRichEditor.formatBlock()
|
||||
} else {
|
||||
mRichEditor.setHeading(1)
|
||||
}
|
||||
mEditorParagraphH1.isChecked = !mEditorParagraphH1.isChecked
|
||||
}
|
||||
R.id.editor_paragraph_h2 -> {
|
||||
if (mEditorParagraphH2.isChecked) {
|
||||
mRichEditor.formatBlock()
|
||||
} else {
|
||||
mRichEditor.setHeading(2)
|
||||
}
|
||||
mEditorParagraphH2.isChecked = !mEditorParagraphH2.isChecked
|
||||
}
|
||||
R.id.editor_paragraph_h3 -> {
|
||||
if (mEditorParagraphH3.isChecked) {
|
||||
mRichEditor.formatBlock()
|
||||
} else {
|
||||
mRichEditor.setHeading(3)
|
||||
}
|
||||
mEditorParagraphH3.isChecked = !mEditorParagraphH3.isChecked
|
||||
}
|
||||
R.id.editor_paragraph_h4 -> {
|
||||
if (mEditorParagraphH4.isChecked) {
|
||||
mRichEditor.formatBlock()
|
||||
} else {
|
||||
mRichEditor.setHeading(4)
|
||||
}
|
||||
mEditorParagraphH4.isChecked = !mEditorParagraphH4.isChecked
|
||||
}
|
||||
R.id.editor_paragraph_quote -> {
|
||||
if (mEditorParagraphQuote.isChecked) {
|
||||
mRichEditor.formatBlock()
|
||||
} else {
|
||||
mRichEditor.setBlockquote()
|
||||
}
|
||||
mEditorParagraphQuote.isChecked = !mEditorParagraphQuote.isChecked
|
||||
}
|
||||
R.id.editor_link_answer -> {
|
||||
startActivityForResult(InsertAnswerWrapperActivity.getIntent(this), INSERT_ANSWER_CODE)
|
||||
}
|
||||
R.id.editor_link_article -> {
|
||||
startActivityForResult(InsertArticleWrapperActivity.getIntent(this), INSERT_ARTICLE_CODE)
|
||||
}
|
||||
R.id.editor_link_game -> {
|
||||
startActivityForResult(GameActivity.getIntent(this), INSERT_GAME_CODE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private inner class OnCursorChangeListener {
|
||||
@JavascriptInterface
|
||||
fun onElements(elements: String) {
|
||||
Utils.log("-----------------------")
|
||||
Utils.log(elements)
|
||||
Utils.log(mRichEditor.html)
|
||||
Utils.log("-----------------------")
|
||||
|
||||
mCurrentParagraphStyle = when {
|
||||
elements.contains(ELEMENT_PARAGRAPH_QUOTE) -> ELEMENT_PARAGRAPH_QUOTE
|
||||
elements.contains(ELEMENT_PARAGRAPH_P) -> ELEMENT_PARAGRAPH_P
|
||||
else -> ""
|
||||
}
|
||||
|
||||
mBaseHandler.post {
|
||||
mEditorFontBold.isChecked = elements.contains(ELEMENT_NAME_BOLD)
|
||||
mEditorFontItalic.isChecked = elements.contains(ELEMENT_NAME_ITALIC)
|
||||
mEditorFontStrikeThrough.isChecked = elements.contains(ELEMENT_NAME_STRIKE)
|
||||
mEditorParagraphH1.isChecked = elements.contains(ELEMENT_PARAGRAPH_H1)
|
||||
mEditorParagraphH2.isChecked = elements.contains(ELEMENT_PARAGRAPH_H2)
|
||||
mEditorParagraphH3.isChecked = elements.contains(ELEMENT_PARAGRAPH_H3)
|
||||
mEditorParagraphH4.isChecked = elements.contains(ELEMENT_PARAGRAPH_H4)
|
||||
mEditorParagraphQuote.isChecked = elements.contains(ELEMENT_PARAGRAPH_QUOTE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private inner class OnPasteListener {
|
||||
@JavascriptInterface
|
||||
fun onPaste() {
|
||||
val clipboard =
|
||||
HaloApp.getInstance().application.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
val clipText = clipboard.text.toString()
|
||||
if (!TextUtils.isEmpty(clipText)) {
|
||||
// 替换换行符号否则 插入失败
|
||||
val text = clipText.replace("[ ]".toRegex(), " ").replace("[\r\n]".toRegex(), "<br/>")
|
||||
mBaseHandler.post { mRichEditor.insertHtml(text) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val ELEMENT_NAME_BOLD = " b "
|
||||
const val ELEMENT_NAME_ITALIC = " i "
|
||||
const val ELEMENT_NAME_STRIKE = " strike "
|
||||
const val ELEMENT_PARAGRAPH_H1 = " h1 "
|
||||
const val ELEMENT_PARAGRAPH_H2 = " h2 "
|
||||
const val ELEMENT_PARAGRAPH_H3 = " h3 "
|
||||
const val ELEMENT_PARAGRAPH_H4 = " h4 "
|
||||
const val ELEMENT_PARAGRAPH_P = " p "
|
||||
const val ELEMENT_PARAGRAPH_QUOTE = " blockquote "
|
||||
const val INSERT_ANSWER_CODE = 411
|
||||
const val INSERT_ARTICLE_CODE = 412
|
||||
const val INSERT_GAME_CODE = 413
|
||||
}
|
||||
}
|
||||
@ -137,7 +137,8 @@ class GHUmengNotificationService : UmengMessageService() {
|
||||
|
||||
notificationManager.notify(getNotificationTag(context), NOTIFICATION_ID, notification)
|
||||
} else {
|
||||
if (HALO_MESSAGE_DIALOG == pushData.body?.custom) {
|
||||
if (UserManager.getInstance().isLoggedIn
|
||||
&& HALO_MESSAGE_DIALOG == pushData.body?.custom) {
|
||||
// 回答了问题或者关注了问题的消息
|
||||
val msg = gson.fromJson(message, PushMessageEntity::class.java)
|
||||
val data = msg?.extra?.data
|
||||
@ -164,8 +165,7 @@ class GHUmengNotificationService : UmengMessageService() {
|
||||
bundle.putString(EntranceUtils.KEY_TO, AnswerDetailActivity::class.java.name)
|
||||
EntranceUtils.jumpActivity(context, bundle)
|
||||
|
||||
DataUtils.onMtaEvent(context, "消息弹窗",
|
||||
type, "Does not contains any parameter.")
|
||||
DataUtils.onMtaEvent(context, "消息弹窗", type, "Does not contains any parameter.")
|
||||
|
||||
// 标记已读
|
||||
val jsonObject = JSONObject()
|
||||
|
||||
@ -22,4 +22,12 @@ object AppExecutor {
|
||||
mainThreadHandler.postDelayed(command, delay)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun runOnIoThread(f: () -> Unit) {
|
||||
AppExecutor.ioExecutor.execute(f)
|
||||
}
|
||||
|
||||
fun runOnUiThread(f: () -> Unit) {
|
||||
AppExecutor.uiExecutor.execute(f)
|
||||
}
|
||||
@ -6,10 +6,11 @@ import com.gh.base.GHUmengNotificationService
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.common.exposure.meta.MetaUtil
|
||||
import com.gh.common.util.edit
|
||||
import com.gh.common.util.toJson
|
||||
import com.gh.common.util.toObject
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.gh.gamecenter.entity.AliasEntity
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.google.gson.Gson
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Utils
|
||||
import com.umeng.commonsdk.UMConfigure
|
||||
@ -25,7 +26,6 @@ import org.json.JSONObject
|
||||
|
||||
object PushManager {
|
||||
|
||||
var gson = Gson()
|
||||
var deviceToken: String? = ""
|
||||
var previousAlias: AliasEntity? = null
|
||||
var application = HaloApp.getInstance().application
|
||||
@ -53,7 +53,7 @@ object PushManager {
|
||||
registerDevice()
|
||||
|
||||
val aliasInSp = PreferenceManager.getDefaultSharedPreferences(application).getString(SP_PUSH_ALIAS, "")
|
||||
previousAlias = gson.fromJson(aliasInSp, AliasEntity::class.java)
|
||||
previousAlias = aliasInSp.toObject()
|
||||
|
||||
if (previousAlias == null) {
|
||||
getAndSetAlias()
|
||||
@ -114,7 +114,7 @@ object PushManager {
|
||||
|
||||
previousAlias = alias
|
||||
PreferenceManager.getDefaultSharedPreferences(application).edit {
|
||||
putString(SP_PUSH_ALIAS, gson.toJson(previousAlias))
|
||||
putString(SP_PUSH_ALIAS, previousAlias?.toJson())
|
||||
}
|
||||
|
||||
pushAgent.setAlias(alias.alias, alias.aliasType) { b, s ->
|
||||
|
||||
@ -102,6 +102,10 @@ class TimeElapsedHelper(val fragment: Fragment?, val activity: Activity?) {
|
||||
}
|
||||
}
|
||||
|
||||
fun resetCounting() {
|
||||
elapsedTime = 0
|
||||
}
|
||||
|
||||
fun pauseCounting() {
|
||||
isWorking = false
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import android.text.TextUtils;
|
||||
|
||||
import com.gh.common.util.GsonUtils;
|
||||
import com.gh.common.util.PackageHelper;
|
||||
import com.gh.common.util.SPUtils;
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.entity.NewsEntity;
|
||||
import com.gh.gamecenter.entity.SettingsEntity;
|
||||
@ -77,7 +78,7 @@ public class Config {
|
||||
}
|
||||
|
||||
public static void setExceptionMsg(String errMsg) {
|
||||
getPreferences().edit().putString("errMsg", errMsg).apply();
|
||||
SPUtils.setString(getPreferences(), "errMsg", errMsg); //先用apply(),保存不了再用commit() 9.0机型保存不了信息
|
||||
}
|
||||
|
||||
public static boolean isShowDownload(String gameId) {
|
||||
@ -106,6 +107,10 @@ public class Config {
|
||||
|
||||
|
||||
public static boolean isShowPlugin(String gameId) {
|
||||
SharedPreferences preferences = getPreferences();
|
||||
boolean isFixPlugin = preferences.getBoolean(FIX_PLUGIN_KEY, false);
|
||||
if (isFixPlugin) return true;
|
||||
|
||||
if (TextUtils.isEmpty(gameId) || !isExistDownloadFilter())
|
||||
return false;
|
||||
|
||||
@ -118,10 +123,6 @@ public class Config {
|
||||
}
|
||||
}
|
||||
|
||||
SharedPreferences preferences = getPreferences();
|
||||
boolean isFixPlugin = preferences.getBoolean(FIX_PLUGIN_KEY, false);
|
||||
if (isFixPlugin) return true;
|
||||
|
||||
if ("all".equals(entity.getGame())) {
|
||||
if (entity.getPluginfy() && filterTime(entity.getTime())) {
|
||||
preferences.edit().putBoolean(FIX_PLUGIN_KEY, true).apply();
|
||||
@ -134,12 +135,17 @@ public class Config {
|
||||
}
|
||||
|
||||
public static boolean isShowPlugin() {
|
||||
SharedPreferences preferences = getPreferences();
|
||||
boolean isFixPlugin = preferences.getBoolean(FIX_PLUGIN_KEY, false);
|
||||
if (isFixPlugin) return true;
|
||||
|
||||
if (!isExistDownloadFilter())
|
||||
return false;
|
||||
|
||||
for (SettingsEntity.Download entity : getSettings().getDownload()) {
|
||||
if ("all".equals(entity.getGame())) {
|
||||
if (entity.getPluginfy() && filterTime(entity.getTime())) {
|
||||
preferences.edit().putBoolean(FIX_PLUGIN_KEY, true).apply();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,4 +47,5 @@ public class Constants {
|
||||
//评论 cd间隔
|
||||
public static final int COMMENT_CD = 60 * 1000;
|
||||
|
||||
public static final String[] REPORT_LIST = new String[]{"垃圾广告营销", "恶意攻击谩骂", "淫秽色情信息", "违法有害信息", "其它"};
|
||||
}
|
||||
|
||||
@ -33,7 +33,6 @@ public class ItemViewType {
|
||||
*/
|
||||
public static final int ITEM_BODY = 100;
|
||||
public static final int ITEM_FOOTER = 101;
|
||||
public static final int ITEM_TOP = 102;
|
||||
|
||||
public static final int ITEM_HEADER = 102;
|
||||
|
||||
}
|
||||
|
||||
@ -23,7 +23,6 @@ import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.GameUtils;
|
||||
import com.gh.common.util.GameViewUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.common.util.KaiFuUtils;
|
||||
import com.gh.common.util.NewsUtils;
|
||||
import com.gh.common.util.NumberUtils;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
@ -64,12 +63,16 @@ public class BindingAdapters {
|
||||
ImageUtils.displayIcon(view, imageUrl);
|
||||
}
|
||||
|
||||
|
||||
@BindingAdapter("imageUrl")
|
||||
public static void loadImage(SimpleDraweeView view, String imageUrl) {
|
||||
ImageUtils.display(view, imageUrl);
|
||||
}
|
||||
|
||||
@BindingAdapter("setTextSize")
|
||||
public static void setTextSize(TextView view, int number) {
|
||||
view.setTextSize(number);
|
||||
}
|
||||
|
||||
@BindingAdapter({"addDetailKaiFuView", "addDetailKaiFuViewListener", "isReadyPatch"})
|
||||
public static void addDetailKaiFuView(LinearLayout view, List<KaiFuCalendarEntity> list
|
||||
, OnViewClickListener listener, Boolean isReadyPatch) {
|
||||
@ -457,8 +460,8 @@ public class BindingAdapters {
|
||||
View testView = LayoutInflater.from(layout.getContext()).inflate(R.layout.game_test_label, null);
|
||||
TextView testType = testView.findViewById(R.id.test_type);
|
||||
TextView testTime = testView.findViewById(R.id.test_time);
|
||||
String type = gameEntity.getTest().getType();
|
||||
KaiFuUtils.setKaiFuType(testType, type);
|
||||
testType.setText(gameEntity.getTest().getType());
|
||||
testType.setBackgroundColor(ContextCompat.getColor(layout.getContext(), R.color.tag_yellow));
|
||||
|
||||
if (gameEntity.getTest().getStart() == 0) {
|
||||
testTime.setVisibility(View.GONE);
|
||||
|
||||
@ -3,7 +3,6 @@ package com.gh.common.exposure
|
||||
import android.arch.persistence.room.TypeConverter
|
||||
import com.gh.common.exposure.meta.Meta
|
||||
import com.gh.common.util.GsonUtils
|
||||
import com.google.gson.Gson
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
@ -36,7 +35,7 @@ class ExposureConverters {
|
||||
|
||||
@TypeConverter
|
||||
fun convertStringToETrace(sourceList: String): List<ExposureEvent> {
|
||||
return ArrayList(Arrays.asList(Gson().fromJson(sourceList, Array<ExposureEvent>::class.java))) as List<ExposureEvent>
|
||||
return ArrayList(Arrays.asList(GsonUtils.fromJson(sourceList, Array<ExposureEvent>::class.java))) as List<ExposureEvent>
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
|
||||
@ -2,10 +2,10 @@ package com.gh.common.exposure
|
||||
|
||||
import com.aliyun.sls.android.sdk.model.LogGroup
|
||||
import com.gh.common.exposure.time.TimeUtil
|
||||
import com.gh.common.util.toJson
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.gh.loghub.LgLOG
|
||||
import com.gh.loghub.LoghubHelper
|
||||
import com.google.gson.Gson
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Utils
|
||||
import java.util.concurrent.Executors
|
||||
@ -30,8 +30,6 @@ object ExposureManager {
|
||||
|
||||
private val loghubHelper = LoghubHelper.getInstance()
|
||||
|
||||
private val gson = Gson()
|
||||
|
||||
// exposureCache 用来过滤掉具有相同 id 的曝光事件,避免重复发送事件
|
||||
private val exposureCache = FixedSizeLinkedHashSet<String>(100)
|
||||
private val exposureSet = hashSetOf<ExposureEvent>()
|
||||
@ -127,11 +125,13 @@ object ExposureManager {
|
||||
val log = LgLOG(TimeUtil.currentTime())
|
||||
|
||||
log.PutContent("id", event.id)
|
||||
log.PutContent("payload", gson.toJson(event.payload))
|
||||
log.PutContent("payload", event.payload.toJson())
|
||||
log.PutContent("event", event.event.toString())
|
||||
log.PutContent("source", eliminateMultipleBrackets(gson.toJson(event.source)))
|
||||
log.PutContent("meta", gson.toJson(event.meta))
|
||||
log.PutContent("e-traces", if (event.eTrace != null) eliminateMultipleBrackets(gson.toJson(event.eTrace)) else "")
|
||||
log.PutContent("source", eliminateMultipleBrackets(event.source.toJson()))
|
||||
log.PutContent("meta", event.meta.toJson())
|
||||
log.PutContent("e-traces", if (event.eTrace != null) {
|
||||
eliminateMultipleBrackets(event.eTrace?.toJson() ?: "")
|
||||
} else "")
|
||||
log.PutTime(event.time)
|
||||
|
||||
return log
|
||||
|
||||
@ -20,5 +20,6 @@ data class Meta(
|
||||
val channel: String? = "",
|
||||
val appVersion: String? = "",
|
||||
val userId: String? = "",
|
||||
val exposureVersion: String? = ""
|
||||
val exposureVersion: String? = "",
|
||||
val rom: String? = ""
|
||||
) : Parcelable
|
||||
@ -14,6 +14,7 @@ import com.gh.gamecenter.BuildConfig
|
||||
import com.gh.gamecenter.manager.UserManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.leon.channel.helper.ChannelReaderUtil
|
||||
import com.walkud.rom.checker.RomIdentifier
|
||||
import java.io.File
|
||||
|
||||
object MetaUtil {
|
||||
@ -37,7 +38,8 @@ object MetaUtil {
|
||||
channel = getChannel(),
|
||||
appVersion = BuildConfig.VERSION_NAME,
|
||||
userId = UserManager.getInstance().userId,
|
||||
exposureVersion = BuildConfig.EXPOSURE_VERSION)
|
||||
exposureVersion = BuildConfig.EXPOSURE_VERSION,
|
||||
rom = RomIdentifier.getRom().name + "" + RomIdentifier.getRom().versionName)
|
||||
}
|
||||
|
||||
fun getMeta(): Meta {
|
||||
|
||||
43
app/src/main/java/com/gh/common/history/HistoryDatabase.kt
Normal file
43
app/src/main/java/com/gh/common/history/HistoryDatabase.kt
Normal file
@ -0,0 +1,43 @@
|
||||
package com.gh.common.history
|
||||
|
||||
import android.arch.persistence.room.Database
|
||||
import android.arch.persistence.room.Room
|
||||
import android.arch.persistence.room.RoomDatabase
|
||||
import android.arch.persistence.room.TypeConverters
|
||||
import com.gh.gamecenter.entity.HistoryGameEntity
|
||||
import com.gh.gamecenter.entity.NewsEntity
|
||||
import com.gh.gamecenter.qa.entity.AnswerEntity
|
||||
import com.gh.gamecenter.qa.entity.ArticleEntity
|
||||
import com.gh.gamecenter.room.converter.*
|
||||
import com.gh.gamecenter.room.dao.AnswerHistoryDao
|
||||
import com.gh.gamecenter.room.dao.ArticleHistoryDao
|
||||
import com.gh.gamecenter.room.dao.GameDao
|
||||
import com.gh.gamecenter.room.dao.NewsHistoryDao
|
||||
import com.halo.assistant.HaloApp
|
||||
|
||||
@Database(entities = [AnswerEntity::class, ArticleEntity::class, NewsEntity::class, HistoryGameEntity::class], version = 2, exportSchema = false)
|
||||
@TypeConverters(*[
|
||||
CountConverter::class,
|
||||
CommunityConverter::class,
|
||||
TimeConverter::class,
|
||||
AnswerUserConverter::class,
|
||||
ThumbnailConverter::class,
|
||||
TagStyleListConverter::class,
|
||||
StringArrayListConverter::class])
|
||||
|
||||
abstract class HistoryDatabase : RoomDatabase() {
|
||||
|
||||
abstract fun answerDao(): AnswerHistoryDao
|
||||
abstract fun articleDao(): ArticleHistoryDao
|
||||
abstract fun newsDao(): NewsHistoryDao
|
||||
abstract fun gameDao(): GameDao
|
||||
|
||||
companion object {
|
||||
val instance by lazy {
|
||||
Room.databaseBuilder(HaloApp.getInstance().application, HistoryDatabase::class.java, "USER_TRACK_HISTORY_DATABASE")
|
||||
.fallbackToDestructiveMigration()
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
107
app/src/main/java/com/gh/common/history/HistoryHelper.kt
Normal file
107
app/src/main/java/com/gh/common/history/HistoryHelper.kt
Normal file
@ -0,0 +1,107 @@
|
||||
package com.gh.common.history
|
||||
|
||||
import com.gh.common.runOnIoThread
|
||||
import com.gh.common.util.clearHtmlFormatCompletely
|
||||
import com.gh.common.util.removeInsertedContent
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.HistoryGameEntity
|
||||
import com.gh.gamecenter.entity.NewsEntity
|
||||
import com.gh.gamecenter.qa.entity.AnswerDetailEntity
|
||||
import com.gh.gamecenter.qa.entity.AnswerEntity
|
||||
import com.gh.gamecenter.qa.entity.ArticleDetailEntity
|
||||
import com.gh.gamecenter.qa.entity.ArticleEntity
|
||||
|
||||
object HistoryHelper {
|
||||
|
||||
fun insertAnswerEntity(answerDetailEntity: AnswerDetailEntity) {
|
||||
val answerEntity = convertAnswerDetailToAnswer(answerDetailEntity)
|
||||
runOnIoThread { HistoryDatabase.instance.answerDao().addAnswer(answerEntity) }
|
||||
}
|
||||
|
||||
fun insertArticleEntity(articleDetailEntity: ArticleDetailEntity) {
|
||||
val articleEntity = convertArticleDetailToArticle(articleDetailEntity)
|
||||
runOnIoThread { HistoryDatabase.instance.articleDao().addArticle(articleEntity) }
|
||||
}
|
||||
|
||||
fun insertGameEntity(gameEntity: GameEntity) {
|
||||
val historyGameEntity = convertGameEntityToHistoryGameEntity(gameEntity)
|
||||
runOnIoThread { HistoryDatabase.instance.gameDao().addGame(historyGameEntity) }
|
||||
}
|
||||
|
||||
private fun convertGameEntityToHistoryGameEntity(gameEntity: GameEntity): HistoryGameEntity {
|
||||
val historyGame = HistoryGameEntity()
|
||||
|
||||
historyGame.orderTag = System.currentTimeMillis()
|
||||
historyGame.id = gameEntity.id
|
||||
historyGame.brief = gameEntity.brief
|
||||
historyGame.des = gameEntity.des
|
||||
historyGame.icon = gameEntity.icon
|
||||
historyGame.name = gameEntity.name
|
||||
historyGame.tagStyle = gameEntity.tagStyle
|
||||
historyGame.tag = gameEntity.getTag()
|
||||
return historyGame
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun insertNewsEntity(newsEntity: NewsEntity) {
|
||||
newsEntity.orderTag = System.currentTimeMillis()
|
||||
runOnIoThread { HistoryDatabase.instance.newsDao().addNews(newsEntity) }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun deleteNewsEntity(newsId: String) {
|
||||
runOnIoThread { HistoryDatabase.instance.newsDao().deleteNews(NewsEntity().apply { id = newsId }) }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun deleteGameEntity(gameId: String) {
|
||||
runOnIoThread { HistoryDatabase.instance.gameDao().deleteGame(HistoryGameEntity(id = gameId)) }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun deleteArticleEntity(articleId: String) {
|
||||
runOnIoThread { HistoryDatabase.instance.articleDao().deleteArticle(ArticleEntity(id = articleId)) }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun deleteAnswerEntity(answerId: String) {
|
||||
runOnIoThread { HistoryDatabase.instance.answerDao().deleteAnswer(AnswerEntity().apply { primaryKey = answerId }) }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun emptyDatabase() {
|
||||
runOnIoThread { HistoryDatabase.instance.clearAllTables() }
|
||||
}
|
||||
|
||||
private fun convertArticleDetailToArticle(articleDetailEntity: ArticleDetailEntity): ArticleEntity {
|
||||
val articleEntity = ArticleEntity()
|
||||
|
||||
articleEntity.id = articleDetailEntity.id
|
||||
articleEntity.brief = articleDetailEntity.content.removeInsertedContent().clearHtmlFormatCompletely().replace(" +".toRegex()," ")
|
||||
articleEntity.count = articleDetailEntity.count
|
||||
articleEntity.community = articleDetailEntity.community
|
||||
articleEntity.time = articleDetailEntity.time
|
||||
articleEntity.title = articleDetailEntity.title
|
||||
articleEntity.user = articleDetailEntity.user
|
||||
articleEntity.orderTag = System.currentTimeMillis()
|
||||
|
||||
return articleEntity
|
||||
}
|
||||
|
||||
private fun convertAnswerDetailToAnswer(answerDetailEntity: AnswerDetailEntity): AnswerEntity {
|
||||
val answerEntity = AnswerEntity()
|
||||
|
||||
answerEntity.id = answerDetailEntity.id
|
||||
answerEntity.primaryKey = answerDetailEntity.id
|
||||
answerEntity.commentCount = answerDetailEntity.commentCount
|
||||
answerEntity.questions = answerDetailEntity.question
|
||||
answerEntity.vote = answerDetailEntity.vote
|
||||
answerEntity.user = answerDetailEntity.user
|
||||
answerEntity.orderTag = System.currentTimeMillis()
|
||||
answerEntity.brief = answerDetailEntity.content.removeInsertedContent().clearHtmlFormatCompletely().replace(" +".toRegex(), " ")
|
||||
answerEntity.time = answerDetailEntity.time
|
||||
|
||||
return answerEntity
|
||||
}
|
||||
|
||||
}
|
||||
@ -18,6 +18,7 @@ package com.gh.common.util
|
||||
|
||||
import android.animation.Animator
|
||||
import android.support.annotation.RequiresApi
|
||||
import android.view.ViewPropertyAnimator
|
||||
|
||||
/**
|
||||
* Since [Android KTX] has not release a stable build yet,
|
||||
@ -125,4 +126,26 @@ fun Animator.addPauseListener(
|
||||
}
|
||||
addPauseListener(listener)
|
||||
return listener
|
||||
}
|
||||
|
||||
fun ViewPropertyAnimator.doOnEnd(onEnd: ((animator: Animator?) -> Unit)? = null): ViewPropertyAnimator {
|
||||
val listener = object : Animator.AnimatorListener {
|
||||
override fun onAnimationRepeat(animation: Animator?) {
|
||||
|
||||
}
|
||||
|
||||
override fun onAnimationEnd(animation: Animator?) {
|
||||
onEnd?.invoke(animation)
|
||||
}
|
||||
|
||||
override fun onAnimationCancel(animation: Animator?) {
|
||||
|
||||
}
|
||||
|
||||
override fun onAnimationStart(animation: Animator?) {
|
||||
|
||||
}
|
||||
}
|
||||
this.setListener(listener)
|
||||
return this
|
||||
}
|
||||
@ -1,93 +0,0 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import retrofit2.HttpException;
|
||||
|
||||
/**
|
||||
* Created by khy on 28/12/17.
|
||||
*/
|
||||
|
||||
public class AskErrorResponseUtils {
|
||||
|
||||
public static void errorResponseControl(Context context, HttpException e) {
|
||||
if (e == null) return;
|
||||
int code = e.code();
|
||||
try {
|
||||
if (code == 403 || code == 401) {
|
||||
JSONObject object = new JSONObject(e.response().errorBody().string());
|
||||
errorResponseControl(context, object);
|
||||
} else {
|
||||
Utils.toast(context, "网络错误");
|
||||
}
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void errorResponseControl(Context context, JSONObject jsonObject) {
|
||||
int errorCode = 0;
|
||||
try {
|
||||
errorCode = jsonObject.getInt("code");
|
||||
switch (errorCode) {
|
||||
case 403001:
|
||||
Utils.toast(context, "标签名称太长了");
|
||||
break;
|
||||
case 403002:
|
||||
Utils.toast(context, "已经被邀请了");
|
||||
break;
|
||||
case 403003:
|
||||
Utils.toast(context, "每天最多可以邀请10次");
|
||||
break;
|
||||
case 403004:
|
||||
Utils.toast(context, "客户端提供的ID无效(空/无效ID)");
|
||||
break;
|
||||
case 403005:
|
||||
Utils.toast(context, "已经回答过了(限制频率)");
|
||||
break;
|
||||
case 403006:
|
||||
Utils.toast(context, "图片数量达到限制点");
|
||||
break;
|
||||
case 403007:
|
||||
Utils.toast(context, "不合法的用户");
|
||||
break;
|
||||
case 403008:
|
||||
Utils.toast(context, "已投票");
|
||||
break;
|
||||
case 403009:
|
||||
Utils.toast(context, "已经收藏过了");
|
||||
break;
|
||||
case 403010:
|
||||
Utils.toast(context, "无效的标签栏");
|
||||
break;
|
||||
case 403011:
|
||||
Utils.toast(context, "标题内容过长");
|
||||
break;
|
||||
case 403012:
|
||||
Utils.toast(context, "描述内容过长");
|
||||
break;
|
||||
case 403013:
|
||||
Utils.toast(context, "无效的标签");
|
||||
break;
|
||||
case 403014:
|
||||
Utils.toast(context, "标签数量太多了");
|
||||
break;
|
||||
case 403015:
|
||||
Utils.toast(context, "已经关注过了");
|
||||
break;
|
||||
case 404001:
|
||||
Utils.toast(context, "请求的资源不存在");
|
||||
break;
|
||||
default:
|
||||
Utils.toast(context, "网络错误");
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -7,6 +7,9 @@ import android.graphics.Matrix;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.media.ExifInterface;
|
||||
import android.os.Build;
|
||||
|
||||
import com.halo.assistant.HaloApp;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@ -186,15 +189,30 @@ public class BitmapUtils {
|
||||
|
||||
/**
|
||||
* Drawable转Bitmap
|
||||
* @param isSquare 是否是正方形
|
||||
*/
|
||||
public static Bitmap drawableToBitmap(Drawable drawable) {
|
||||
public static Bitmap drawableToBitmap(Drawable drawable, boolean isSquare) {
|
||||
if (drawable == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int w,h;
|
||||
|
||||
// 取 drawable 的长宽
|
||||
int w = drawable.getIntrinsicWidth();
|
||||
int h = drawable.getIntrinsicHeight();
|
||||
w = drawable.getIntrinsicWidth();
|
||||
h = drawable.getIntrinsicHeight();
|
||||
|
||||
// 在低于 5.1 和运行内存小于 2G 的设备上减小图片大小,避免 OOM,128 * 128 又不是不能看
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP
|
||||
|| DeviceUtils.getTotalRamSizeOfDevice(HaloApp.getInstance().getApplication()) < 2000) {
|
||||
if (isSquare) {
|
||||
w = w > 128 ? 128 : w;
|
||||
h = h > 128 ? 128 : h;
|
||||
} else {
|
||||
w = w > 128 ? w / 2 : w;
|
||||
h = h > 128 ? h / 2 : h;
|
||||
}
|
||||
}
|
||||
// 取 drawable 的颜色格式
|
||||
Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
|
||||
: Bitmap.Config.RGB_565;
|
||||
|
||||
@ -46,7 +46,7 @@ object CollectionUtils {
|
||||
try {
|
||||
val string = e.response()?.errorBody()?.string()
|
||||
val errorBody = JSONObject(string)
|
||||
if (errorBody.getInt("detail") == 403009) {
|
||||
if (errorBody.getInt("code") == 403009) {
|
||||
listener.onSuccess()
|
||||
return
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import com.gh.gamecenter.MessageDetailActivity
|
||||
import com.gh.gamecenter.adapter.OnCommentCallBackListener
|
||||
import com.gh.gamecenter.entity.CommentEntity
|
||||
import com.gh.gamecenter.entity.MeEntity
|
||||
import com.gh.gamecenter.entity.Permissions
|
||||
import com.gh.gamecenter.retrofit.Response
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.lightgame.utils.Utils
|
||||
@ -21,78 +22,41 @@ import retrofit2.HttpException
|
||||
|
||||
object CommentHelper {
|
||||
|
||||
// TODO 合并这两个方法的共同部分
|
||||
@JvmStatic
|
||||
fun showCommunityArticleCommentOptions(
|
||||
context: Context,
|
||||
commentEntity: CommentEntity,
|
||||
showConversation: Boolean,
|
||||
articleId: String,
|
||||
communityId: String,
|
||||
listener: OnCommentCallBackListener?) {
|
||||
val dialogOptions = ArrayList<String>()
|
||||
|
||||
if (commentEntity.me == null || !commentEntity.me?.isAnswerCommented!!) {
|
||||
dialogOptions.add("回复")
|
||||
}
|
||||
|
||||
dialogOptions.add("复制")
|
||||
dialogOptions.add("举报")
|
||||
|
||||
if (commentEntity.parentUser != null && showConversation) {
|
||||
dialogOptions.add("查看对话")
|
||||
}
|
||||
|
||||
DialogUtils.showListDialog(context, dialogOptions, null) {
|
||||
when (it) {
|
||||
"回复" -> {
|
||||
context.ifLogin("社区文章详情-评论-回复") {
|
||||
if (listener != null) {
|
||||
listener.onCommentCallback(commentEntity)
|
||||
} else if (!TextUtils.isEmpty(commentEntity.id)) {
|
||||
context.startActivity(MessageDetailActivity.getMessageDetailIntent(context, commentEntity, commentEntity.id))
|
||||
} else {
|
||||
Utils.toast(context, "缺少关键属性")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"复制" -> copyText(commentEntity.content, context)
|
||||
|
||||
"举报" -> context.ifLogin("社区文章详情-评论-举报") {
|
||||
showReportTypeDialog(context) { reportType ->
|
||||
PostCommentUtils.reportCommunityArticleComment(context, communityId, articleId, commentEntity.id, reportType,
|
||||
object : PostCommentUtils.PostCommentListener {
|
||||
override fun postSuccess(response: JSONObject?) {
|
||||
Utils.toast(context, "感谢您的举报")
|
||||
}
|
||||
|
||||
override fun postFailed(error: Throwable?) {
|
||||
if (error == null) {
|
||||
Utils.toast(context, "举报失败,请稍后重试")
|
||||
} else {
|
||||
Utils.toast(context, "举报失败,${error.message}")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
"查看对话" -> {
|
||||
context.startActivity(CommentDetailActivity
|
||||
.getCommunityArticleCommentIntent(context, articleId, commentEntity.id, communityId, null))
|
||||
}
|
||||
}
|
||||
}
|
||||
fun showCommunityArticleCommentOptions(context: Context,
|
||||
commentEntity: CommentEntity,
|
||||
showConversation: Boolean,
|
||||
articleId: String,
|
||||
communityId: String,
|
||||
listener: OnCommentCallBackListener?) {
|
||||
showCommentOptions(context = context,
|
||||
commentEntity = commentEntity,
|
||||
showConversation = showConversation,
|
||||
articleId = articleId,
|
||||
communityId = communityId,
|
||||
listener = listener)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun showAnswerCommentOptions(
|
||||
context: Context,
|
||||
commentEntity: CommentEntity,
|
||||
showConversation: Boolean,
|
||||
answerId: String,
|
||||
listener: OnCommentCallBackListener?) {
|
||||
fun showAnswerCommentOptions(context: Context,
|
||||
commentEntity: CommentEntity,
|
||||
showConversation: Boolean,
|
||||
answerId: String,
|
||||
listener: OnCommentCallBackListener?) {
|
||||
showCommentOptions(context = context,
|
||||
commentEntity = commentEntity,
|
||||
showConversation = showConversation,
|
||||
answerId = answerId,
|
||||
listener = listener)
|
||||
}
|
||||
|
||||
private fun showCommentOptions(context: Context,
|
||||
commentEntity: CommentEntity,
|
||||
showConversation: Boolean,
|
||||
articleId: String? = null,
|
||||
communityId: String? = null,
|
||||
answerId: String? = null,
|
||||
listener: OnCommentCallBackListener? = null) {
|
||||
val dialogOptions = ArrayList<String>()
|
||||
|
||||
if (commentEntity.me == null || !commentEntity.me?.isAnswerCommented!!) {
|
||||
@ -103,9 +67,10 @@ object CommentHelper {
|
||||
dialogOptions.add("举报")
|
||||
|
||||
commentEntity.me?.let {
|
||||
if (it.isModerator && (
|
||||
it.moderatorPermissions.contains(MeEntity.HIDE_ANSWER_COMMENT)
|
||||
|| it.moderatorPermissions.contains(MeEntity.TOP_ANSWER_COMMENT))) {
|
||||
if (it.isModerator || (it.moderatorPermissions.hideAnswerComment > Permissions.GUEST
|
||||
|| it.moderatorPermissions.topAnswerComment > Permissions.GUEST
|
||||
|| it.moderatorPermissions.hideCommunityArticleComment > Permissions.GUEST
|
||||
|| it.moderatorPermissions.topCommunityArticleComment > Permissions.GUEST)) {
|
||||
dialogOptions.add("管理")
|
||||
}
|
||||
}
|
||||
@ -116,7 +81,7 @@ object CommentHelper {
|
||||
|
||||
DialogUtils.showListDialog(context, dialogOptions, null) {
|
||||
when (it) {
|
||||
"管理" -> showControlDialog(context, answerId, commentEntity, commentEntity.me!!)
|
||||
"管理" -> showControlDialog(context, answerId, articleId, communityId, commentEntity, commentEntity.me!!)
|
||||
|
||||
"回复" -> {
|
||||
context.ifLogin("回答详情-评论-回复") {
|
||||
@ -132,56 +97,95 @@ object CommentHelper {
|
||||
|
||||
"复制" -> copyText(commentEntity.content, context)
|
||||
|
||||
"举报" -> context.ifLogin("回答详情-评论-举报") {
|
||||
showReportTypeDialog(context) { reportType ->
|
||||
PostCommentUtils.postAnswerReportData(context, commentEntity.id, answerId, reportType,
|
||||
object : PostCommentUtils.PostCommentListener {
|
||||
override fun postSuccess(response: JSONObject?) {
|
||||
Utils.toast(context, "感谢您的举报")
|
||||
}
|
||||
"举报" -> {
|
||||
context.ifLogin("回答详情-评论-举报") {
|
||||
showReportTypeDialog(context) { reportType ->
|
||||
|
||||
override fun postFailed(error: Throwable?) {
|
||||
if (error == null) {
|
||||
Utils.toast(context, "举报失败,请稍后重试")
|
||||
} else {
|
||||
Utils.toast(context, "举报失败,${error.message}")
|
||||
}
|
||||
val commentListener = object : PostCommentUtils.PostCommentListener {
|
||||
override fun postSuccess(response: JSONObject?) {
|
||||
Utils.toast(context, "感谢您的举报")
|
||||
}
|
||||
|
||||
override fun postFailed(error: Throwable?) {
|
||||
if (error == null) {
|
||||
Utils.toast(context, "举报失败,请稍后重试")
|
||||
} else {
|
||||
Utils.toast(context, "举报失败,${error.message}")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (answerId != null) {
|
||||
PostCommentUtils.postAnswerReportData(context, commentEntity.id, answerId, reportType, commentListener)
|
||||
} else {
|
||||
PostCommentUtils.reportCommunityArticleComment(context, communityId, articleId, commentEntity.id, reportType, commentListener)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"查看对话" -> {
|
||||
context.startActivity(CommentDetailActivity
|
||||
.getAnswerCommentIntent(context, commentEntity.id, answerId, null))
|
||||
if (answerId != null) {
|
||||
context.startActivity(CommentDetailActivity
|
||||
.getAnswerCommentIntent(context, commentEntity.id, answerId, null))
|
||||
} else {
|
||||
context.startActivity(CommentDetailActivity
|
||||
.getCommunityArticleCommentIntent(context, articleId, commentEntity.id, communityId, null))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showControlDialog(context: Context, answerId: String, comment: CommentEntity, me: MeEntity) {
|
||||
private fun showControlDialog(context: Context,
|
||||
answerId: String? = null,
|
||||
articleId: String? = null,
|
||||
communityId: String? = null,
|
||||
comment: CommentEntity,
|
||||
me: MeEntity) {
|
||||
val dialogOptions = arrayListOf<String>()
|
||||
val highlight = "置顶评论"
|
||||
val hide = "隐藏评论"
|
||||
|
||||
if (me.moderatorPermissions.contains(MeEntity.TOP_ANSWER_COMMENT)) {
|
||||
var canHighlightCommentDirectly = false
|
||||
var canHideCommentDirectly = false
|
||||
|
||||
if (me.moderatorPermissions.topAnswerComment > Permissions.GUEST
|
||||
|| me.moderatorPermissions.topCommunityArticleComment > Permissions.GUEST) {
|
||||
dialogOptions.add(highlight)
|
||||
if (me.moderatorPermissions.topAnswerComment > Permissions.REPORTER
|
||||
|| me.moderatorPermissions.topCommunityArticleComment > Permissions.REPORTER ) {
|
||||
canHighlightCommentDirectly = true
|
||||
}
|
||||
}
|
||||
|
||||
if (me.moderatorPermissions.contains(MeEntity.HIDE_ANSWER_COMMENT)) {
|
||||
if (me.moderatorPermissions.hideAnswerComment > Permissions.GUEST
|
||||
|| me.moderatorPermissions.hideCommunityArticleComment > Permissions.GUEST) {
|
||||
dialogOptions.add(hide)
|
||||
if (me.moderatorPermissions.hideAnswerComment > Permissions.REPORTER
|
||||
|| me.moderatorPermissions.hideCommunityArticleComment > Permissions.REPORTER ) {
|
||||
canHideCommentDirectly = true
|
||||
}
|
||||
}
|
||||
|
||||
val content = if (me.moderatorLevel == MeEntity.MODERATOR_LEVEL_PRIMARY) {
|
||||
"你的操作将提交给小编审核,确定提交吗?"
|
||||
} else {
|
||||
val highlightDialogHintContent = if (canHighlightCommentDirectly) {
|
||||
"你的操作将立即生效,确定提交吗?(你的管理权限为:高级)"
|
||||
} else {
|
||||
"你的操作将提交给小编审核,确定提交吗?"
|
||||
}
|
||||
|
||||
val hideDialogHintContent = if (canHideCommentDirectly) {
|
||||
"你的操作将立即生效,确定提交吗?(你的管理权限为:高级)"
|
||||
} else {
|
||||
"你的操作将提交给小编审核,确定提交吗?"
|
||||
}
|
||||
|
||||
val disabledOptions = arrayListOf<String>()
|
||||
|
||||
if (comment.priority != 0) {
|
||||
disabledOptions.add(highlight)
|
||||
}
|
||||
|
||||
comment.me?.let {
|
||||
if (it.isAnswerCommented) {
|
||||
disabledOptions.add(highlight)
|
||||
@ -191,7 +195,6 @@ object CommentHelper {
|
||||
DialogUtils.showListDialog(context, dialogOptions, disabledOptions) {
|
||||
when (it) {
|
||||
highlight -> {
|
||||
|
||||
if (comment.priority != 0) {
|
||||
Utils.toast(context, "评论已经置顶")
|
||||
return@showListDialog
|
||||
@ -204,77 +207,101 @@ object CommentHelper {
|
||||
}
|
||||
}
|
||||
|
||||
DialogUtils.showAlertDialog(context, highlight, content,
|
||||
"确定", "取消",
|
||||
{
|
||||
RetrofitManager.getInstance(context).api
|
||||
.highlightAnswerComment(answerId, comment.id)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
if (me.moderatorLevel == MeEntity.MODERATOR_LEVEL_PRIMARY) {
|
||||
Utils.toast(context, "提交成功")
|
||||
} else {
|
||||
Utils.toast(context, "置顶成功,请刷新列表")
|
||||
}
|
||||
}
|
||||
val highlightObserver = object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
if (canHighlightCommentDirectly) {
|
||||
Utils.toast(context, "置顶成功,请刷新列表")
|
||||
} else {
|
||||
Utils.toast(context, "提交成功")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailure(e: HttpException?) {
|
||||
super.onFailure(e)
|
||||
e?.let { httpException ->
|
||||
if (httpException.code() == 403) {
|
||||
val string = e.response().errorBody()?.string()
|
||||
val errorJson = JSONObject(string)
|
||||
val errorCode = errorJson.getInt("code")
|
||||
if (errorCode == 403059) {
|
||||
Utils.toast(getApplication(), "权限错误,请刷新后重试")
|
||||
return
|
||||
} else {
|
||||
Utils.toast(getApplication(), e.message())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}, null)
|
||||
override fun onFailure(e: HttpException?) {
|
||||
super.onFailure(e)
|
||||
e?.let { httpException ->
|
||||
if (httpException.code() == 403) {
|
||||
val string = e.response().errorBody()?.string()
|
||||
val errorJson = JSONObject(string)
|
||||
val errorCode = errorJson.getInt("code")
|
||||
if (errorCode == 403059) {
|
||||
Utils.toast(getApplication(), "权限错误,请刷新后重试")
|
||||
return
|
||||
} else {
|
||||
Utils.toast(getApplication(), e.message())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (answerId != null) {
|
||||
DialogUtils.showAlertDialog(context, highlight, highlightDialogHintContent,
|
||||
"确定", "取消", {
|
||||
RetrofitManager.getInstance(context).api
|
||||
.highlightAnswerComment(answerId, comment.id)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(highlightObserver)
|
||||
}, null)
|
||||
} else {
|
||||
DialogUtils.showAlertDialog(context, highlight, highlightDialogHintContent,
|
||||
"确定", "取消", {
|
||||
RetrofitManager.getInstance(context).api
|
||||
.highlightCommunityArticleComment(communityId, articleId, comment.id)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(highlightObserver)
|
||||
}, null)
|
||||
}
|
||||
}
|
||||
|
||||
hide -> {
|
||||
DialogUtils.showAlertDialog(context, hide, content,
|
||||
"确定", "取消",
|
||||
{
|
||||
RetrofitManager.getInstance(context).api
|
||||
.hideAnswerComment(answerId, comment.id)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
if (me.moderatorLevel == MeEntity.MODERATOR_LEVEL_PRIMARY) {
|
||||
Utils.toast(context, "提交成功")
|
||||
} else {
|
||||
Utils.toast(context, "隐藏成功,请刷新列表")
|
||||
}
|
||||
}
|
||||
val hideObserver = object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
if (canHideCommentDirectly) {
|
||||
Utils.toast(context, "隐藏成功,请刷新列表")
|
||||
} else {
|
||||
Utils.toast(context, "提交成功")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailure(e: HttpException?) {
|
||||
super.onFailure(e)
|
||||
e?.let { httpException ->
|
||||
if (httpException.code() == 403) {
|
||||
val string = e.response().errorBody()?.string()
|
||||
val errorJson = JSONObject(string)
|
||||
val errorCode = errorJson.getInt("code")
|
||||
if (errorCode == 403059) {
|
||||
Utils.toast(getApplication(), "权限错误,请刷新后重试")
|
||||
return
|
||||
} else {
|
||||
Utils.toast(getApplication(), e.message())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}, null)
|
||||
override fun onFailure(e: HttpException?) {
|
||||
super.onFailure(e)
|
||||
e?.let { httpException ->
|
||||
if (httpException.code() == 403) {
|
||||
val string = e.response().errorBody()?.string()
|
||||
val errorJson = JSONObject(string)
|
||||
val errorCode = errorJson.getInt("code")
|
||||
if (errorCode == 403059) {
|
||||
Utils.toast(getApplication(), "权限错误,请刷新后重试")
|
||||
return
|
||||
} else {
|
||||
Utils.toast(getApplication(), e.message())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (answerId != null) {
|
||||
DialogUtils.showAlertDialog(context, hide, hideDialogHintContent,
|
||||
"确定", "取消", {
|
||||
RetrofitManager.getInstance(context).api
|
||||
.hideAnswerComment(answerId, comment.id)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(hideObserver)
|
||||
}, null)
|
||||
} else {
|
||||
DialogUtils.showAlertDialog(context, hide, hideDialogHintContent,
|
||||
"确定", "取消", {
|
||||
RetrofitManager.getInstance(context).api
|
||||
.hideCommunityArticleComment(communityId, articleId, comment.id)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(hideObserver)
|
||||
}, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,6 @@ import android.app.Dialog;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
@ -20,11 +19,8 @@ import com.gh.gamecenter.adapter.OnCommentCallBackListener;
|
||||
import com.gh.gamecenter.adapter.viewholder.CommentViewHolder;
|
||||
import com.gh.gamecenter.entity.CommentEntity;
|
||||
import com.gh.gamecenter.entity.MeEntity;
|
||||
import com.gh.gamecenter.entity.RatingComment;
|
||||
import com.gh.gamecenter.entity.UserInfoEntity;
|
||||
import com.gh.gamecenter.manager.UserManager;
|
||||
import com.gh.gamecenter.retrofit.Response;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import org.json.JSONException;
|
||||
@ -37,11 +33,6 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.HttpException;
|
||||
|
||||
/**
|
||||
@ -80,111 +71,6 @@ public class CommentUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void showGameCommentOptions(final Context context,
|
||||
final RatingComment comment,
|
||||
final String gameId,
|
||||
final String entrance) {
|
||||
|
||||
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<>();
|
||||
|
||||
dialogType.add("复制");
|
||||
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 "复制":
|
||||
copyText(comment.getContent(), context);
|
||||
break;
|
||||
case "举报":
|
||||
CheckLoginUtils.checkLogin(context, entrance, () -> showGameCommentReportDialog(gameId, comment, context));
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(container);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
private static void showGameCommentReportDialog(final String gameId, final RatingComment comment, 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();
|
||||
}
|
||||
RequestBody body = RequestBody.create(MediaType.parse("application/json"), jsonObject.toString());
|
||||
RetrofitManager.getInstance(context).getApi()
|
||||
.reportGameComment(gameId, comment.getId(), body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Response<ResponseBody>() {
|
||||
@Override
|
||||
public void onResponse(@Nullable ResponseBody response) {
|
||||
Utils.toast(context, "感谢您的举报");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@Nullable HttpException e) {
|
||||
Utils.toast(context, "举报失败,请先检查网络设置");
|
||||
}
|
||||
});
|
||||
|
||||
reportTypeDialog.cancel();
|
||||
});
|
||||
}
|
||||
|
||||
reportTypeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
reportTypeDialog.setContentView(container);
|
||||
reportTypeDialog.show();
|
||||
}
|
||||
|
||||
|
||||
public static void showReportDialog(final CommentEntity commentEntity,
|
||||
final Context context,
|
||||
@ -263,135 +149,6 @@ public class CommentUtils {
|
||||
|
||||
}
|
||||
|
||||
// public static void showAnswerCommentOptions(final CommentEntity commentEntity, final Context context,
|
||||
// final OnCommentCallBackListener listener, final String id,
|
||||
// boolean showConversation, String answerId, String articleId, String articleCommunityId) {
|
||||
//
|
||||
// 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.getMe() == null || !commentEntity.getMe().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 "查看对话":
|
||||
// if (TextUtils.isEmpty(articleId)) {
|
||||
// context.startActivity(CommentDetailActivity.getAnswerCommentIntent(context, commentEntity.getId(), answerId, null));
|
||||
// } else {
|
||||
// context.startActivity(CommentDetailActivity.getCommunityArticleCommentIntent(context, articleId, commentEntity.getId(), articleCommunityId, null));
|
||||
// }
|
||||
// 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) {
|
||||
// if (error != null) {
|
||||
// Utils.toast(context, "举报失败" + error.getMessage());
|
||||
// } else {
|
||||
// Utils.toast(context, "举报失败,请稍候重试");
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// 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[]{"垃圾广告营销", "恶意攻击谩骂", "淫秽色情信息",
|
||||
"违法有害信息", "其它"};
|
||||
@ -458,7 +215,7 @@ public class CommentUtils {
|
||||
commentEntity.setVote(commentEntity.getVote() + 1);
|
||||
commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.theme));
|
||||
commentLikeIv.setImageResource(R.drawable.vote_icon_select);
|
||||
commentLikeCountTv.setText(String.valueOf(commentEntity.getVote()));
|
||||
commentLikeCountTv.setText(NumberUtils.transSimpleCount(commentEntity.getVote()));
|
||||
commentLikeCountTv.setVisibility(View.VISIBLE);
|
||||
|
||||
PostCommentUtils.addCommentVote(context, commentEntity.getId(),
|
||||
@ -476,7 +233,7 @@ public class CommentUtils {
|
||||
commentEntity.setVote(commentEntity.getVote() - 1);
|
||||
commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.hint));
|
||||
commentLikeIv.setImageResource(R.drawable.vote_icon_unselect);
|
||||
commentLikeCountTv.setText(String.valueOf(commentEntity.getVote()));
|
||||
commentLikeCountTv.setText(NumberUtils.transSimpleCount(commentEntity.getVote()));
|
||||
if (commentEntity.getVote() == 0) {
|
||||
commentLikeCountTv.setVisibility(View.GONE);
|
||||
} else {
|
||||
@ -518,7 +275,7 @@ public class CommentUtils {
|
||||
commentEntity.setVote(commentEntity.getVote() + 1);
|
||||
commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.theme));
|
||||
commentLikeIv.setImageResource(R.drawable.vote_icon_select);
|
||||
commentLikeCountTv.setText(String.valueOf(commentEntity.getVote()));
|
||||
commentLikeCountTv.setText(NumberUtils.transSimpleCount(commentEntity.getVote()));
|
||||
commentLikeCountTv.setVisibility(View.VISIBLE);
|
||||
|
||||
PostCommentUtils.voteAnswerComment(context, answerId, articleId, articleCommunityId, commentEntity.getId(),
|
||||
@ -536,7 +293,7 @@ public class CommentUtils {
|
||||
commentEntity.setVote(commentEntity.getVote() - 1);
|
||||
commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.hint));
|
||||
commentLikeIv.setImageResource(R.drawable.vote_icon_unselect);
|
||||
commentLikeCountTv.setText(String.valueOf(commentEntity.getVote()));
|
||||
commentLikeCountTv.setText(NumberUtils.transSimpleCount(commentEntity.getVote()));
|
||||
if (commentEntity.getVote() == 0) {
|
||||
commentLikeCountTv.setVisibility(View.GONE);
|
||||
} else {
|
||||
|
||||
@ -1,45 +1,47 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import com.gh.gamecenter.packagehelper.PackageRepository
|
||||
import com.gh.gamecenter.qa.entity.AskGameSelectEntity
|
||||
import com.gh.gamecenter.retrofit.Response
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
||||
/**
|
||||
* 用于判断社区跳转前社区是否可用
|
||||
*/
|
||||
object CommunityHelper {
|
||||
|
||||
private var availableCommunityList = listOf<AskGameSelectEntity>()
|
||||
/**
|
||||
* 为已开通的社区排序
|
||||
* 排序规则为将本地存在已安装游戏或已关联游戏的社区置顶
|
||||
*/
|
||||
fun sortOpenedCommunity(rawList: List<AskGameSelectEntity>?): ArrayList<AskGameSelectEntity> {
|
||||
val sortedList = ArrayList<AskGameSelectEntity>()
|
||||
rawList?.let {
|
||||
for (game in rawList) {
|
||||
var thisGameIsInstalled = false
|
||||
for (installGame in PackageRepository.gameInstalled) {
|
||||
if (PackageHelper.downloadPackageNameBlackList.contains(installGame.packageName)) {
|
||||
continue
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getAvailableCommunityList() {
|
||||
RetrofitManager.getInstance(HaloApp.getInstance().application).api
|
||||
.getAskGameSelect(HaloApp.getInstance().channel
|
||||
, UrlFilterUtils.getFilterQuery("status", "opened"), 1, 100)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : Response<List<AskGameSelectEntity>>() {
|
||||
override fun onResponse(response: List<AskGameSelectEntity>?) {
|
||||
if (response != null && response.isNotEmpty()) {
|
||||
availableCommunityList = response
|
||||
// 判断是否已安装
|
||||
if (installGame.id == game.game.id) {
|
||||
thisGameIsInstalled = true
|
||||
break
|
||||
}
|
||||
|
||||
// 判断是否关联了别游戏
|
||||
for (relatedGameId in game.game.relation) {
|
||||
if (installGame.id == relatedGameId) {
|
||||
thisGameIsInstalled = true
|
||||
break
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun isCommunityAvailable(communityId: String?): Boolean {
|
||||
communityId?.let {
|
||||
if (availableCommunityList.isEmpty()) return true
|
||||
for (entity in availableCommunityList) {
|
||||
if (communityId == entity.id) {
|
||||
return true
|
||||
// 将已安装的置顶
|
||||
if (thisGameIsInstalled) {
|
||||
sortedList.add(0, game)
|
||||
} else {
|
||||
sortedList.add(game)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
return sortedList
|
||||
}
|
||||
|
||||
}
|
||||
@ -2,7 +2,6 @@ package com.gh.common.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.facebook.drawee.drawable.ScalingUtils;
|
||||
@ -93,12 +92,9 @@ public class ConcernContentUtils {
|
||||
ScalingUtils.ScaleType.CENTER_CROP, list.get(position));
|
||||
break;
|
||||
}
|
||||
imageView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent checkIntent = ViewImageActivity.getViewImageIntent(context, (ArrayList<String>) list, position, entrance);
|
||||
context.startActivity(checkIntent);
|
||||
}
|
||||
imageView.setOnClickListener(v -> {
|
||||
Intent checkIntent = ViewImageActivity.getViewImageIntent(context, (ArrayList<String>) list, position, entrance);
|
||||
context.startActivity(checkIntent);
|
||||
});
|
||||
return imageView;
|
||||
}
|
||||
|
||||
@ -21,6 +21,9 @@ import retrofit2.HttpException
|
||||
*/
|
||||
object ConcernUtils {
|
||||
|
||||
/**
|
||||
* autoConcern:是否自动关注'关联关注'
|
||||
*/
|
||||
fun postConcernGameId(context: Context, gameId: String, listener: onConcernListener?, autoConcern: Boolean = false) {
|
||||
val mode = if (autoConcern) "auto" else "manual"
|
||||
|
||||
@ -92,7 +95,13 @@ object ConcernUtils {
|
||||
override fun onFailure(e: HttpException?) {
|
||||
super.onFailure(e)
|
||||
listener?.onError()
|
||||
AskErrorResponseUtils.errorResponseControl(context, e)
|
||||
var errorString: String? = null
|
||||
try {
|
||||
errorString = e?.response()?.errorBody()?.string()
|
||||
} catch (e1: Exception) {
|
||||
e1.printStackTrace()
|
||||
}
|
||||
ErrorHelper.handleError(context, errorString, false)
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -111,7 +120,13 @@ object ConcernUtils {
|
||||
override fun onFailure(e: HttpException?) {
|
||||
super.onFailure(e)
|
||||
listener?.onError()
|
||||
AskErrorResponseUtils.errorResponseControl(context, e)
|
||||
var errorString: String? = null
|
||||
try {
|
||||
errorString = e?.response()?.errorBody()?.string()
|
||||
} catch (e1: Exception) {
|
||||
e1.printStackTrace()
|
||||
}
|
||||
ErrorHelper.handleError(context, errorString, false)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@ -72,6 +72,7 @@ public class DetailDownloadUtils {
|
||||
switch (downloadEntity.getStatus()) {
|
||||
case downloading:
|
||||
case pause:
|
||||
case overflow:
|
||||
viewHolder.mDownloadPb.setText(R.string.downloading);
|
||||
if (downloadEntity.isPluggable() && PackagesManager.INSTANCE.isInstalled(downloadEntity.getPackageName())) {
|
||||
viewHolder.mDownloadPb.setDownloadType(DownloadProgressBar.DownloadType.DOWNLOADING_PLUGIN);
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
@ -238,7 +239,6 @@ public class DeviceUtils {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
// ping domain
|
||||
public static String ping(String domain) {
|
||||
try {
|
||||
@ -257,5 +257,13 @@ public class DeviceUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static long getTotalRamSizeOfDevice(Context context) {
|
||||
ActivityManager actManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
|
||||
if (actManager != null) {
|
||||
actManager.getMemoryInfo(memInfo);
|
||||
}
|
||||
return memInfo.totalMem / (1024 * 1024);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,91 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Baidu, Inc. All Rights Reserved.
|
||||
*/
|
||||
package com.gh.common.util;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* Created by sunpengfei on 15/11/4.
|
||||
*/
|
||||
public class DexUtils {
|
||||
|
||||
private static final int BUF_SIZE = 2048;
|
||||
|
||||
public static boolean prepareAssetsDex(Context context, File dexInternalStoragePath, String dex_file) {
|
||||
BufferedInputStream bis = null;
|
||||
OutputStream dexWriter = null;
|
||||
|
||||
try {
|
||||
bis = new BufferedInputStream(context.getAssets().open(dex_file));
|
||||
dexWriter = new BufferedOutputStream(new FileOutputStream(dexInternalStoragePath));
|
||||
byte[] buf = new byte[BUF_SIZE];
|
||||
int len;
|
||||
while ((len = bis.read(buf, 0, BUF_SIZE)) > 0) {
|
||||
dexWriter.write(buf, 0, len);
|
||||
}
|
||||
dexWriter.close();
|
||||
bis.close();
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
if (dexWriter != null) {
|
||||
try {
|
||||
dexWriter.close();
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (bis != null) {
|
||||
try {
|
||||
bis.close();
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean prepareDex(File dexInternalStoragePath, File dex_file) {
|
||||
BufferedInputStream bis = null;
|
||||
OutputStream dexWriter = null;
|
||||
|
||||
try {
|
||||
bis = new BufferedInputStream(new FileInputStream(dex_file));
|
||||
dexWriter = new BufferedOutputStream(new FileOutputStream(dexInternalStoragePath));
|
||||
byte[] buf = new byte[BUF_SIZE];
|
||||
int len;
|
||||
while ((len = bis.read(buf, 0, BUF_SIZE)) > 0) {
|
||||
dexWriter.write(buf, 0, len);
|
||||
}
|
||||
dexWriter.close();
|
||||
bis.close();
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
if (dexWriter != null) {
|
||||
try {
|
||||
dexWriter.close();
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (bis != null) {
|
||||
try {
|
||||
bis.close();
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -130,7 +130,7 @@ public class DialogUtils {
|
||||
ApplicationInfo appInfo = info.applicationInfo;
|
||||
appInfo.sourceDir = apkPath;
|
||||
appInfo.publicSourceDir = apkPath;
|
||||
Bitmap bitmap = BitmapUtils.drawableToBitmap(appInfo.loadIcon(pm));
|
||||
Bitmap bitmap = BitmapUtils.drawableToBitmap(appInfo.loadIcon(pm), true);
|
||||
|
||||
ImageView imageView = new ImageView(activity);
|
||||
imageView.setLayoutParams(new LinearLayout.LayoutParams(DisplayUtils.dip2px(activity, 25)
|
||||
@ -360,9 +360,16 @@ public class DialogUtils {
|
||||
} else if (NetworkUtils.isWifiConnected(context) || filter4GorSize(context, size)) {
|
||||
callBack.onResponse(false);
|
||||
} else {
|
||||
MtaHelper.onEvent("移动网络下载", NetworkUtils.getMobileNetworkType(context), "出现弹窗提示");
|
||||
showDownloadDialog(context,
|
||||
() -> callBack.onResponse(false),
|
||||
() -> callBack.onResponse(true));
|
||||
() -> {
|
||||
callBack.onResponse(false);
|
||||
MtaHelper.onEvent("移动网络下载", NetworkUtils.getMobileNetworkType(context), "立即下载");
|
||||
},
|
||||
() -> {
|
||||
callBack.onResponse(true);
|
||||
MtaHelper.onEvent("移动网络下载", NetworkUtils.getMobileNetworkType(context), "连上WiFi后自动下载");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -445,7 +452,53 @@ public class DialogUtils {
|
||||
TextView titleTv = contentView.findViewById(R.id.dialog_title);
|
||||
TextView negativeTv = contentView.findViewById(R.id.dialog_negative);
|
||||
TextView positiveTv = contentView.findViewById(R.id.dialog_positive);
|
||||
if (message.toString().contains("红包奖励")) {//将红包奖励四个字标红
|
||||
String str = message.toString().substring(0, message.toString().indexOf("红包奖励")) + "<font color='#FF0000'>红包奖励</font>";
|
||||
contentTv.setText(Html.fromHtml(str));
|
||||
} else {
|
||||
contentTv.setText(message);
|
||||
}
|
||||
titleTv.setText(title);
|
||||
negativeTv.setText(negative);
|
||||
positiveTv.setText(positive);
|
||||
|
||||
negativeTv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (clListener != null) {
|
||||
clListener.onCancel();
|
||||
}
|
||||
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();
|
||||
return dialog;
|
||||
}
|
||||
|
||||
|
||||
public static Dialog showAlertDialog(Context context, String title, Spanned message
|
||||
, String positive, String negative, final ConfirmListener cmListener, final CancelListener clListener) {
|
||||
|
||||
final Dialog dialog = new Dialog(context, R.style.GhAlertDialog);
|
||||
|
||||
View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_alert, null);
|
||||
TextView contentTv = contentView.findViewById(R.id.dialog_content);
|
||||
TextView titleTv = contentView.findViewById(R.id.dialog_title);
|
||||
TextView negativeTv = contentView.findViewById(R.id.dialog_negative);
|
||||
TextView positiveTv = contentView.findViewById(R.id.dialog_positive);
|
||||
contentTv.setText(message);
|
||||
titleTv.setText(title);
|
||||
negativeTv.setText(negative);
|
||||
@ -795,7 +848,7 @@ public class DialogUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param options 供以显示的选项
|
||||
* @param options 供以显示的选项
|
||||
* @param disabledOptions 显示为灰色的选项(是 options 的子集)
|
||||
*/
|
||||
public static void showListDialog(Context context,
|
||||
|
||||
@ -86,7 +86,7 @@ object DirectUtils {
|
||||
|
||||
"community_article" -> context.startActivity(ArticleDetailActivity.getIntent(context, linkEntity.community!!, linkEntity.link!!, entrance, path))
|
||||
|
||||
"community_column" -> context.startActivity(CommunitySubjectActivity.getIntent(context, linkEntity.community!!, linkEntity.link, entrance))
|
||||
"community_column" -> context.startActivity(CommunitySubjectActivity.getIntent(context, linkEntity.community!!, linkEntity.link, entrance, path))
|
||||
|
||||
"community_special_column" -> context.startActivity(AskColumnDetailActivity.getIntentByColumnId(context, linkEntity.link, linkEntity.community!!, entrance, path))
|
||||
|
||||
@ -99,7 +99,7 @@ object DirectUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到文章详情
|
||||
* 跳转到新闻详情
|
||||
*/
|
||||
@JvmStatic
|
||||
fun directToArticle(context: Context, id: String, entrance: String? = null) {
|
||||
|
||||
@ -83,7 +83,7 @@ public class DownloadItemUtils {
|
||||
DownloadManager.getInstance(context).sendMessageDelayed(msg, 3000);
|
||||
}
|
||||
}
|
||||
if (platform.equals(queue.peek())) {
|
||||
if (platform != null && platform.equals(queue.peek())) {
|
||||
if (entryMap == null) {
|
||||
entryMap = new ArrayMap<>();
|
||||
gameEntity.setEntryMap(entryMap);
|
||||
@ -96,6 +96,13 @@ public class DownloadItemUtils {
|
||||
}
|
||||
}
|
||||
|
||||
// 下载按钮显示为查看,并且不提供下载功能
|
||||
public static void updateItemWithViewOnlyStyle(GameViewHolder holder) {
|
||||
holder.gameDownloadBtn.setVisibility(View.VISIBLE);
|
||||
holder.gameDownloadBtn.setText("查看");
|
||||
holder.gameDownloadBtn.setClickable(false);
|
||||
}
|
||||
|
||||
public static void updateItem(Context context, GameEntity gameEntity, GameViewHolder holder,
|
||||
boolean isShowPlatform) {
|
||||
updateItem(context, gameEntity, holder, isShowPlatform, PluginLocation.only_game);
|
||||
@ -229,7 +236,8 @@ public class DownloadItemUtils {
|
||||
} else if (status.equals(DownloadStatus.pause)
|
||||
|| status.equals(DownloadStatus.timeout)
|
||||
|| status.equals(DownloadStatus.neterror)
|
||||
|| status.equals(DownloadStatus.subscribe)) {
|
||||
|| status.equals(DownloadStatus.subscribe)
|
||||
|| status.equals(DownloadStatus.overflow)) {
|
||||
holder.gameProgressbar.setProgress((int) (downloadEntity.getPercent() * 10));
|
||||
if (isShowPlatform && platform != null) {
|
||||
holder.gameDownloadSpeed.setText(String.format("%s - 暂停", platform));
|
||||
@ -239,10 +247,10 @@ public class DownloadItemUtils {
|
||||
holder.gameDownloadPercentage.setText(downloadEntity.getPercent() + "%");
|
||||
|
||||
if (isNormal) {
|
||||
if (status.equals(DownloadStatus.pause)) {
|
||||
holder.gameDownloadBtn.setText(R.string.downloading);
|
||||
} else {
|
||||
if (status.equals(DownloadStatus.waiting)) {
|
||||
holder.gameDownloadBtn.setText(R.string.waiting);
|
||||
} else {
|
||||
holder.gameDownloadBtn.setText(R.string.downloading);
|
||||
}
|
||||
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_downloading_style);
|
||||
holder.gameDownloadBtn.setTextColor(ContextCompat.getColorStateList(context, R.color.text_downloading_style));
|
||||
|
||||
@ -25,7 +25,7 @@ public class EntranceUtils {
|
||||
public static final String KEY_URL = "url";
|
||||
public static final String KEY_GAMENAME = "gameName";
|
||||
public static final String HOST_ARTICLE = "article";
|
||||
public static final String HOST_COMMUNITY_ARTICLE = "community.article";
|
||||
public static final String HOST_COMMUNITY_ARTICLE = "community_article";
|
||||
public static final String HOST_GAME = "game";
|
||||
public static final String HOST_GAME_DOWNLOAD = "game_download";
|
||||
public static final String HOST_COLUMN = "column";
|
||||
@ -98,7 +98,6 @@ public class EntranceUtils {
|
||||
public static final String KEY_COMMUNITY_DATA = "communityData";
|
||||
public static final String KEY_TRACE_EVENT = "trace_event";
|
||||
public static final String KEY_SUBJECT_DATA = "subjectData";
|
||||
public static final String KEY_SHOW_SELECT_COMMUNITY = "show_select_community";
|
||||
public static final String KEY_USER_ID = "user_id";
|
||||
public static final String KEY_QUESTION_TAG = "question_tag";
|
||||
public static final String KEY_COLUMN_ID = "column_id";
|
||||
@ -112,6 +111,7 @@ public class EntranceUtils {
|
||||
public static final String KEY_QUESTION_MODERATOR_PATCH = "questionModeratorPatch";
|
||||
public static final String KEY_SKIP_GAME_COMMENT = "skipGameComment";
|
||||
public static final String KEY_OPEN_PLATFORM_WINDOW = "openPlatformWindow";
|
||||
public static final String KEY_OPEN_KEYBOARD = "openKeyboard";
|
||||
|
||||
public static void jumpActivity(Context context, Bundle bundle) {
|
||||
|
||||
|
||||
@ -10,6 +10,54 @@ import com.lightgame.utils.Utils
|
||||
*/
|
||||
object ErrorHelper {
|
||||
|
||||
/**
|
||||
* 手动匹配处理特定错误码
|
||||
* [showHighPriorityHint] 用来标识有同样错误码可以触发两种处理时,为 true 时选择重要的
|
||||
* [customizedHandler] 返回 true 为已处理该错误码,false 则交由 [handleError] 处理
|
||||
*/
|
||||
fun handleErrorWithCustomizedHandler(context: Context,
|
||||
errorString: String?,
|
||||
showHighPriorityHint: Boolean = false,
|
||||
customizedHandler: (code: Int) -> Boolean) {
|
||||
val errorEntity = errorString?.toObject<ErrorEntity>()
|
||||
|
||||
if (errorEntity == null) {
|
||||
Utils.toast(context, R.string.post_failure_hint)
|
||||
return
|
||||
}
|
||||
|
||||
if (!errorEntity.toast.isNullOrEmpty()) {
|
||||
Utils.toast(context, errorEntity.toast)
|
||||
return
|
||||
}
|
||||
|
||||
if (customizedHandler(errorEntity.code ?: 0)) {
|
||||
return
|
||||
} else {
|
||||
handleError(context, showHighPriorityHint, errorEntity)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* [showHighPriorityHint] 用来标识有同样错误码可以触发两种处理时,为 true 时选择重要的
|
||||
*/
|
||||
@JvmStatic
|
||||
fun handleError(context: Context, errorString: String?, showHighPriorityHint: Boolean = false) {
|
||||
val errorEntity = errorString?.toObject<ErrorEntity>()
|
||||
|
||||
if (errorEntity == null) {
|
||||
Utils.toast(context, R.string.post_failure_hint)
|
||||
return
|
||||
}
|
||||
|
||||
if (!errorEntity.toast.isNullOrEmpty()) {
|
||||
Utils.toast(context, errorEntity.toast)
|
||||
return
|
||||
}
|
||||
|
||||
handleError(context, showHighPriorityHint, errorEntity)
|
||||
}
|
||||
|
||||
/***
|
||||
* 禁言错误,
|
||||
*403050: 评论回答
|
||||
@ -24,23 +72,7 @@ object ErrorHelper {
|
||||
*403054: 更新社区文章
|
||||
*403047: 回答点赞
|
||||
*/
|
||||
|
||||
/**
|
||||
* [important] 用来标识有同样错误码可以触发两种处理时,为 true 时选择重要的
|
||||
*/
|
||||
fun handleError(context: Context, errorString: String?, important: Boolean = false) {
|
||||
val errorEntity = errorString?.toObject<ErrorEntity>()
|
||||
|
||||
if (errorEntity == null) {
|
||||
Utils.toast(context, R.string.post_failure_hint)
|
||||
return
|
||||
}
|
||||
|
||||
if (!errorEntity.toast.isNullOrEmpty()) {
|
||||
Utils.toast(context, errorEntity.toast)
|
||||
return
|
||||
}
|
||||
|
||||
private fun handleError(context: Context, showHighPriorityHint: Boolean = false, errorEntity: ErrorEntity) {
|
||||
when (errorEntity.code) {
|
||||
403050,
|
||||
403051,
|
||||
@ -70,9 +102,10 @@ object ErrorHelper {
|
||||
403014 -> Utils.toast(context, "标签数量太多了")
|
||||
403015 -> Utils.toast(context, "已经关注过了")
|
||||
404001 -> Utils.toast(context, "请求的资源不存在")
|
||||
403016 -> Utils.toast(context, "标签内容可能包含敏感信息,请修改后再提交")
|
||||
403018 -> Utils.toast(context, R.string.comment_failed_unable)
|
||||
|
||||
403020 -> if (important!!) {
|
||||
403020 -> if (showHighPriorityHint) {
|
||||
DialogUtils.showAlertDialog(context,
|
||||
"限制提醒",
|
||||
"提问过于频繁,请先休息一下哦",
|
||||
@ -83,6 +116,8 @@ object ErrorHelper {
|
||||
|
||||
403021 -> Utils.toast(context, R.string.comment_failed_illegal)
|
||||
|
||||
403059 -> Utils.toast(context, "权限错误,请刷新后重试")
|
||||
|
||||
else -> Utils.toast(context, R.string.post_failure_hint)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,26 +1,42 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.arch.lifecycle.*
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.support.v4.app.Fragment
|
||||
import android.support.v4.app.FragmentActivity
|
||||
import android.support.v4.view.ViewPager
|
||||
import android.text.Html
|
||||
import android.text.Spanned
|
||||
import android.view.View
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Utils
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.RequestBody
|
||||
import java.net.URI
|
||||
|
||||
/**
|
||||
* 创建以 activity 为观察者上下文的 viewModel
|
||||
*/
|
||||
inline fun <reified VM : ViewModel> FragmentActivity.viewModelProvider(
|
||||
provider: ViewModelProvider.Factory
|
||||
provider: ViewModelProvider.Factory? = null
|
||||
) =
|
||||
ViewModelProviders.of(this, provider).get(VM::class.java)
|
||||
|
||||
/**
|
||||
* 创建以 activity 为观察者上下文的 viewModel
|
||||
*/
|
||||
inline fun <reified VM : ViewModel> Fragment.viewModelProviderFromParent(
|
||||
provider: ViewModelProvider.Factory? = null
|
||||
) =
|
||||
ViewModelProviders.of(requireActivity(), provider).get(VM::class.java)
|
||||
|
||||
/**
|
||||
* 创建以 fragment 为观察者上下文的 viewModel
|
||||
*/
|
||||
inline fun <reified VM : ViewModel> Fragment.viewModelProvider(
|
||||
provider: ViewModelProvider.Factory
|
||||
provider: ViewModelProvider.Factory? = null
|
||||
) =
|
||||
ViewModelProviders.of(this, provider).get(VM::class.java)
|
||||
|
||||
@ -88,14 +104,68 @@ inline fun <reified T : Any> T.toJson(): String {
|
||||
}
|
||||
|
||||
/**
|
||||
* 快速点击两下
|
||||
* 在限定 interval 里只触发一次 action
|
||||
*/
|
||||
fun fastDoubleClickAction(id: Int, interval: Long = 300, action: (() -> Unit)? = null) {
|
||||
if (ClickUtils.isFastDoubleClick(id, interval)) {
|
||||
fun debounceActionWithInterval(id: Int, interval: Long = 300, action: (() -> Unit)? = null) {
|
||||
if (!ClickUtils.isFastDoubleClick(id, interval)) {
|
||||
action?.invoke()
|
||||
}
|
||||
}
|
||||
|
||||
fun View.fastDoubleClickAction(interval: Long, action: (() -> Unit)? = null) {
|
||||
fastDoubleClickAction(id, interval, action)
|
||||
fun View.debounceActionWithInterval(interval: Long = 300, action: (() -> Unit)? = null) {
|
||||
debounceActionWithInterval(this.id, interval, action)
|
||||
}
|
||||
|
||||
/**
|
||||
* 告诉需要返回 true or false 的外层这个事件已经被消费(即返回 true)
|
||||
*/
|
||||
inline fun consume(f: () -> Unit): Boolean {
|
||||
f()
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* String related
|
||||
*/
|
||||
fun String.fromHtml(): Spanned {
|
||||
return Html.fromHtml(this)
|
||||
}
|
||||
|
||||
// 去掉文章/答案的插入内容
|
||||
fun String.removeInsertedContent(): String {
|
||||
val textRegex = "(?s)<div class=\"gh-internal-content content-right\".*?</div>"
|
||||
|
||||
return this.replace(textRegex.toRegex(), "")
|
||||
}
|
||||
|
||||
// 完全地清除所有 Html 格式
|
||||
fun String.clearHtmlFormatCompletely(): String {
|
||||
return Html.fromHtml(this).toString().replace('\n', 32.toChar())
|
||||
.replace(160.toChar(), 32.toChar()).replace(65532.toChar(), 32.toChar()).trim { it <= ' ' }
|
||||
}
|
||||
|
||||
// 如果该字符串长度超过固定长度的话,从头开始截取固定长度并返回
|
||||
fun String.subStringIfPossible(length: Int): String {
|
||||
return if (this.length > length) {
|
||||
this.substring(0, length)
|
||||
} else {
|
||||
this
|
||||
}
|
||||
}
|
||||
|
||||
fun String.copyTextAndToast(toastText: String = "复制成功") {
|
||||
val application = HaloApp.getInstance().application
|
||||
val cmb = application.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
cmb.text = this
|
||||
Utils.toast(application, toastText)
|
||||
}
|
||||
|
||||
fun Map<String, String>.createRequestBody(): RequestBody {
|
||||
val json = GsonUtils.toJson(this)
|
||||
return RequestBody.create(MediaType.parse("application/json"), json)
|
||||
}
|
||||
|
||||
// 对在浏览器(WebView)显示的路径进行转码
|
||||
fun String.decodeURI(): String {
|
||||
return URI(null, null, this, null).rawPath
|
||||
}
|
||||
@ -15,7 +15,6 @@ object GameRepositoryHelper {
|
||||
|
||||
private const val KEY_GAME_REPOSITORY = "game_repository"
|
||||
|
||||
// TODO 会有多线程操作问题(在此列表获取补充游戏数据时进行下拉刷新修改此列表)
|
||||
var gameCollectionList: List<SubjectEntity> = arrayListOf()
|
||||
|
||||
init {
|
||||
@ -28,22 +27,6 @@ object GameRepositoryHelper {
|
||||
@JvmStatic
|
||||
fun getGameRepository(context: Context) {
|
||||
|
||||
// Test only
|
||||
// RetrofitManager.getInstance(context)
|
||||
// .api
|
||||
// .remenkapai
|
||||
// .subscribeOn(Schedulers.io())
|
||||
// .subscribe(object : Response<List<GameEntity>>() {
|
||||
// override fun onResponse(response: List<GameEntity>?) {
|
||||
// val subjectEntityList = arrayListOf<SubjectEntity>()
|
||||
// val subjectEntity = SubjectEntity(id = "5ac46cca2924bc2870438d28")
|
||||
// subjectEntity.data = ArrayList(response)
|
||||
// subjectEntityList.add(subjectEntity)
|
||||
// updateGameRepository(subjectEntityList)
|
||||
// }
|
||||
// })
|
||||
|
||||
|
||||
RetrofitManager.getInstance(context)
|
||||
.api
|
||||
.reserveColumns
|
||||
@ -83,16 +66,15 @@ object GameRepositoryHelper {
|
||||
* @param collectionId 补充游戏库相应专题 ID
|
||||
* @param gameIdList 该专题里已经包含的游戏 ID 列表
|
||||
*/
|
||||
fun getOneUniqueGame(collectionId: String?, gameIdList: List<String>): GameEntity? {
|
||||
fun getOneUniqueGame(collectionId: String?, gameIdList: HashSet<String>): GameEntity? {
|
||||
collectionId?.let {
|
||||
val collection = gameCollectionList.find { it.id == collectionId }
|
||||
// Test only
|
||||
// val collection = gameCollectionList.find { it.id == "5ac46cca2924bc2870438d28" }
|
||||
|
||||
collection?.let {
|
||||
val game = collection.data?.find { game -> findUniqueGame(game, gameIdList) }
|
||||
val game = collection.data?.find { game -> isThisGameUnique(game, gameIdList) }
|
||||
game?.let {
|
||||
collection.data?.remove(game)
|
||||
// 产品说要记录补充专题的曝光数,所以这个游戏附带了所在专题的名字
|
||||
game.subjectName = collection.name
|
||||
return game
|
||||
}
|
||||
}
|
||||
@ -100,7 +82,12 @@ object GameRepositoryHelper {
|
||||
return null
|
||||
}
|
||||
|
||||
private fun findUniqueGame(game: GameEntity, gameIdList: List<String>): Boolean {
|
||||
private fun isThisGameUnique(game: GameEntity, gameIdList: HashSet<String>): Boolean {
|
||||
// 若该补充游戏已经存在关联关系,判定为非唯一
|
||||
for (relatedId in game.relatedGameIds!!) {
|
||||
gameIdList.contains(relatedId)
|
||||
return false
|
||||
}
|
||||
for (apk in game.getApk()) {
|
||||
// 检查本地是否已安装该游戏,已过滤那部分框架服务的包名
|
||||
if (PackageHelper.validLocalPackageNameSet.contains(apk.packageName)) {
|
||||
|
||||
@ -16,9 +16,9 @@ import com.sina.weibo.sdk.auth.Oauth2AccessToken;
|
||||
import com.sina.weibo.sdk.auth.WbAuthListener;
|
||||
import com.sina.weibo.sdk.auth.WbConnectErrorMessage;
|
||||
import com.sina.weibo.sdk.auth.sso.SsoHandler;
|
||||
import com.tencent.mm.sdk.openapi.IWXAPI;
|
||||
import com.tencent.mm.sdk.openapi.SendAuth;
|
||||
import com.tencent.mm.sdk.openapi.WXAPIFactory;
|
||||
import com.tencent.mm.opensdk.modelmsg.SendAuth;
|
||||
import com.tencent.mm.opensdk.openapi.IWXAPI;
|
||||
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
|
||||
import com.tencent.tauth.IUiListener;
|
||||
import com.tencent.tauth.Tencent;
|
||||
import com.tencent.tauth.UiError;
|
||||
|
||||
20
app/src/main/java/com/gh/common/util/GhMatisseFilter.kt
Normal file
20
app/src/main/java/com/gh/common/util/GhMatisseFilter.kt
Normal file
@ -0,0 +1,20 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.content.Context
|
||||
import com.zhihu.matisse.MimeType
|
||||
import com.zhihu.matisse.filter.Filter
|
||||
import com.zhihu.matisse.internal.entity.IncapableCause
|
||||
import com.zhihu.matisse.internal.entity.Item
|
||||
|
||||
class GhMatisseFilter : Filter() {
|
||||
|
||||
override fun constraintTypes(): MutableSet<MimeType> {
|
||||
return MimeType.ofVideo()
|
||||
}
|
||||
|
||||
override fun filter(context: Context?, item: Item?): IncapableCause? {
|
||||
if (!needFiltering(context, item)) return null
|
||||
return IncapableCause(IncapableCause.TOAST, "暂不支持视频")
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,36 +0,0 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
public class HMACUtils {
|
||||
|
||||
public static String encrypt(String data, String key) {
|
||||
try {
|
||||
SecretKeySpec signingKey = new SecretKeySpec(key.getBytes(), "HmacSHA256");
|
||||
Mac mac = Mac.getInstance("HmacSHA256");
|
||||
mac.init(signingKey);
|
||||
return byte2hex(mac.doFinal(data.getBytes()));
|
||||
} catch (NoSuchAlgorithmException | InvalidKeyException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String byte2hex(byte[] ciphertext) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String stmp;
|
||||
for (int i = 0; ciphertext != null && i < ciphertext.length; i++) {
|
||||
stmp = Integer.toHexString(ciphertext[i] & 0XFF);
|
||||
if (stmp.length() == 1) {
|
||||
builder.append('0');
|
||||
}
|
||||
builder.append(stmp);
|
||||
}
|
||||
return builder.toString().toLowerCase();
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,158 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Baidu, Inc. All Rights Reserved.
|
||||
*/
|
||||
package com.gh.common.util;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import dalvik.system.DexClassLoader;
|
||||
import dalvik.system.PathClassLoader;
|
||||
|
||||
/* compiled from: ProGuard */
|
||||
public final class HotFix {
|
||||
|
||||
public static void patch(Context context, String patchDexFile, String patchClassName) {
|
||||
if (patchDexFile != null && new File(patchDexFile).exists()) {
|
||||
try {
|
||||
if (hasLexClassLoader()) {
|
||||
injectInAliyunOs(context, patchDexFile, patchClassName);
|
||||
} else if (hasDexClassLoader()) {
|
||||
injectAboveEqualApiLevel14(context, patchDexFile, patchClassName);
|
||||
} else {
|
||||
injectBelowApiLevel14(context, patchDexFile, patchClassName);
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean hasLexClassLoader() {
|
||||
try {
|
||||
Class.forName("dalvik.system.LexClassLoader");
|
||||
return true;
|
||||
} catch (ClassNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void injectInAliyunOs(Context context, String patchDexFile, String patchClassName)
|
||||
throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException,
|
||||
InstantiationException, NoSuchFieldException {
|
||||
PathClassLoader obj = (PathClassLoader) context.getClassLoader();
|
||||
String replaceAll = new File(patchDexFile).getName().replaceAll("\\.[a-zA-Z0-9]+", ".lex");
|
||||
Class cls = Class.forName("dalvik.system.LexClassLoader");
|
||||
Object newInstance =
|
||||
cls.getConstructor(new Class[]{String.class, String.class, String.class, ClassLoader.class}).newInstance(
|
||||
new Object[]{context.getDir("dex", 0).getAbsolutePath() + File.separator + replaceAll,
|
||||
context.getDir("dex", 0).getAbsolutePath(), patchDexFile, obj});
|
||||
cls.getMethod("loadClass", new Class[]{String.class}).invoke(newInstance, new Object[]{patchClassName});
|
||||
setField(obj, PathClassLoader.class, "mPaths",
|
||||
appendArray(getField(obj, PathClassLoader.class, "mPaths"), getField(newInstance, cls, "mRawDexPath")));
|
||||
setField(obj, PathClassLoader.class, "mFiles",
|
||||
combineArray(getField(obj, PathClassLoader.class, "mFiles"), getField(newInstance, cls, "mFiles")));
|
||||
setField(obj, PathClassLoader.class, "mZips",
|
||||
combineArray(getField(obj, PathClassLoader.class, "mZips"), getField(newInstance, cls, "mZips")));
|
||||
setField(obj, PathClassLoader.class, "mLexs",
|
||||
combineArray(getField(obj, PathClassLoader.class, "mLexs"), getField(newInstance, cls, "mDexs")));
|
||||
}
|
||||
|
||||
private static boolean hasDexClassLoader() {
|
||||
try {
|
||||
Class.forName("dalvik.system.BaseDexClassLoader");
|
||||
return true;
|
||||
} catch (ClassNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void injectAboveEqualApiLevel14(Context context, String str, String str2)
|
||||
throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException {
|
||||
PathClassLoader pathClassLoader = (PathClassLoader) context.getClassLoader();
|
||||
Object a = combineArray(getDexElements(getPathList(pathClassLoader)),
|
||||
getDexElements(getPathList(
|
||||
new DexClassLoader(str, context.getDir("dex", 0).getAbsolutePath(), str, context.getClassLoader()))));
|
||||
Object a2 = getPathList(pathClassLoader);
|
||||
setField(a2, a2.getClass(), "dexElements", a);
|
||||
pathClassLoader.loadClass(str2);
|
||||
}
|
||||
|
||||
@TargetApi(14)
|
||||
private static void injectBelowApiLevel14(Context context, String str, String str2)
|
||||
throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException {
|
||||
PathClassLoader obj = (PathClassLoader) context.getClassLoader();
|
||||
DexClassLoader dexClassLoader =
|
||||
new DexClassLoader(str, context.getDir("dex", 0).getAbsolutePath(), str, context.getClassLoader());
|
||||
dexClassLoader.loadClass(str2);
|
||||
setField(obj, PathClassLoader.class, "mPaths",
|
||||
appendArray(getField(obj, PathClassLoader.class, "mPaths"), getField(dexClassLoader, DexClassLoader.class,
|
||||
"mRawDexPath")
|
||||
));
|
||||
setField(obj, PathClassLoader.class, "mFiles",
|
||||
combineArray(getField(obj, PathClassLoader.class, "mFiles"), getField(dexClassLoader, DexClassLoader.class,
|
||||
"mFiles")
|
||||
));
|
||||
setField(obj, PathClassLoader.class, "mZips",
|
||||
combineArray(getField(obj, PathClassLoader.class, "mZips"), getField(dexClassLoader, DexClassLoader.class,
|
||||
"mZips")));
|
||||
setField(obj, PathClassLoader.class, "mDexs",
|
||||
combineArray(getField(obj, PathClassLoader.class, "mDexs"), getField(dexClassLoader, DexClassLoader.class,
|
||||
"mDexs")));
|
||||
obj.loadClass(str2);
|
||||
}
|
||||
|
||||
private static void setField(Object obj, Class cls, String str, Object obj2)
|
||||
throws NoSuchFieldException, IllegalAccessException {
|
||||
Field declaredField = cls.getDeclaredField(str);
|
||||
declaredField.setAccessible(true);
|
||||
declaredField.set(obj, obj2);
|
||||
}
|
||||
|
||||
private static Object appendArray(Object obj, Object obj2) {
|
||||
Class componentType = obj.getClass().getComponentType();
|
||||
int length = Array.getLength(obj);
|
||||
Object newInstance = Array.newInstance(componentType, length + 1);
|
||||
Array.set(newInstance, 0, obj2);
|
||||
for (int i = 1; i < length + 1; i++) {
|
||||
Array.set(newInstance, i, Array.get(obj, i - 1));
|
||||
}
|
||||
return newInstance;
|
||||
}
|
||||
|
||||
private static Object getField(Object obj, Class cls, String str)
|
||||
throws NoSuchFieldException, IllegalAccessException {
|
||||
Field declaredField = cls.getDeclaredField(str);
|
||||
declaredField.setAccessible(true);
|
||||
return declaredField.get(obj);
|
||||
}
|
||||
|
||||
private static Object combineArray(Object obj, Object obj2) {
|
||||
Class componentType = obj2.getClass().getComponentType();
|
||||
int length = Array.getLength(obj2);
|
||||
int length2 = Array.getLength(obj) + length;
|
||||
Object newInstance = Array.newInstance(componentType, length2);
|
||||
for (int i = 0; i < length2; i++) {
|
||||
if (i < length) {
|
||||
Array.set(newInstance, i, Array.get(obj2, i));
|
||||
} else {
|
||||
Array.set(newInstance, i, Array.get(obj, i - length));
|
||||
}
|
||||
}
|
||||
return newInstance;
|
||||
}
|
||||
|
||||
private static Object getDexElements(Object obj) throws NoSuchFieldException, IllegalAccessException {
|
||||
return getField(obj, obj.getClass(), "dexElements");
|
||||
}
|
||||
|
||||
private static Object getPathList(Object obj) throws ClassNotFoundException, NoSuchFieldException,
|
||||
IllegalAccessException {
|
||||
return getField(obj, Class.forName("dalvik.system.BaseDexClassLoader"), "pathList");
|
||||
}
|
||||
|
||||
}
|
||||
@ -9,22 +9,9 @@ import java.util.regex.Pattern;
|
||||
* Created by khy on 27/12/17.
|
||||
*/
|
||||
|
||||
public class AskUtils {
|
||||
|
||||
// public static String voteCountFormat(int voteCount) {
|
||||
// String vote;
|
||||
// if (voteCount >= 10000) {
|
||||
// DecimalFormat df = new DecimalFormat("#.0万");
|
||||
// vote = df.format(voteCount / 10000f);
|
||||
// } else {
|
||||
// vote = String.valueOf(voteCount);
|
||||
// }
|
||||
// return vote;
|
||||
// }
|
||||
public class HtmlUtils {
|
||||
|
||||
public static String stripHtml(String htmlStr) {
|
||||
|
||||
|
||||
if (TextUtils.isEmpty(htmlStr)) return "";
|
||||
|
||||
String regEx_script = "<script[^>]*?>[\\s\\S]*?<\\/script>"; //定义script的正则表达式
|
||||
@ -45,5 +32,4 @@ public class AskUtils {
|
||||
|
||||
return htmlStr.trim(); //返回文本字符串
|
||||
}
|
||||
|
||||
}
|
||||
@ -2,9 +2,11 @@ package com.gh.common.util
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.drawable.Animatable
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.support.annotation.DrawableRes
|
||||
import android.support.v4.content.ContextCompat
|
||||
import com.facebook.common.executors.CallerThreadExecutor
|
||||
@ -20,6 +22,7 @@ import com.facebook.imagepipeline.request.ImageRequest
|
||||
import com.facebook.imagepipeline.request.ImageRequestBuilder
|
||||
import com.gh.common.constant.Config
|
||||
import com.gh.gamecenter.R
|
||||
import java.io.ByteArrayOutputStream
|
||||
|
||||
|
||||
object ImageUtils {
|
||||
@ -258,7 +261,10 @@ object ImageUtils {
|
||||
if (width != null && width > 0) {
|
||||
val transformUrlX2 = addLimitWidth(url, width * 2)
|
||||
val transformUrlX1 = addLimitWidth(url, width)
|
||||
if (NetworkUtils.isWifiOr4GConnected(context)) {
|
||||
// 当网络为 WIFI 或 4G, 且系统版本大于 5.0 && 手机内存大于 1G 才用高清图片
|
||||
if (NetworkUtils.isWifiOr4GConnected(context)
|
||||
&& Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP
|
||||
&& DeviceUtils.getTotalRamSizeOfDevice(context) > 1000) {
|
||||
transformUrl = transformUrlX2
|
||||
} else {
|
||||
// 检查X2大图是否被缓存
|
||||
@ -289,6 +295,24 @@ object ImageUtils {
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun bmpToByteArray(bmp: Bitmap, needRecycle: Boolean): ByteArray {
|
||||
val output = ByteArrayOutputStream()
|
||||
bmp.compress(Bitmap.CompressFormat.PNG, 100, output)
|
||||
if (needRecycle) {
|
||||
bmp.recycle()
|
||||
}
|
||||
|
||||
val result = output.toByteArray()
|
||||
try {
|
||||
output.close()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
@JvmStatic
|
||||
fun display(draweeView: SimpleDraweeView, @DrawableRes res: Int?) {
|
||||
|
||||
@ -64,15 +64,13 @@ public class InstallUtils {
|
||||
keys.add(packageName);
|
||||
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance(context).getDownloadEntityByPackageName(packageName);
|
||||
String installVersion = PackageUtils.getVersionByPackage(context, packageName);
|
||||
String installVersion = PackageUtils.getVersionByPackage(packageName);
|
||||
if (!TextUtils.isEmpty(installVersion) && downloadEntity != null &&
|
||||
installVersion.equals(downloadEntity.getVersionName())) {
|
||||
if (!downloadEntity.isPluggable() || PackageUtils.isSignature(context, packageName)) {
|
||||
EventBus.getDefault().post(new EBPackage("安装", packageName));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
for (String key : keys) {
|
||||
@ -109,7 +107,7 @@ public class InstallUtils {
|
||||
if (mInstance == null) {
|
||||
synchronized (InstallUtils.class) {
|
||||
if (mInstance == null) {
|
||||
mInstance = new InstallUtils(context);
|
||||
mInstance = new InstallUtils(context.getApplicationContext());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,32 +0,0 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.gamecenter.R;
|
||||
|
||||
/**
|
||||
* Created by khy on 2017/3/19.
|
||||
*/
|
||||
public class KaiFuUtils {
|
||||
|
||||
public static void setKaiFuType(TextView textView, String type) {
|
||||
if (type == null) return;
|
||||
textView.setText(type);
|
||||
textView.setBackgroundColor(ContextCompat.getColor(textView.getContext(), R.color.tag_yellow));
|
||||
// switch (type) {
|
||||
// case "不删档内测":
|
||||
// textView.setBackgroundColor(ContextCompat.getColor(textView.getContext(), R.color.content));
|
||||
// break;
|
||||
// case "删档内测":
|
||||
// textView.setBackgroundColor(ContextCompat.getColor(textView.getContext(), R.color.content));
|
||||
// break;
|
||||
// case "公测":
|
||||
// textView.setBackgroundColor(ContextCompat.getColor(textView.getContext(), R.color.tag_yellow));
|
||||
// break;
|
||||
// default:
|
||||
// textView.setBackgroundColor(ContextCompat.getColor(textView.getContext(), R.color.tag_yellow));
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
}
|
||||
@ -84,7 +84,7 @@ public class LibaoUtils {
|
||||
.subscribe(new JSONObjectResponse() {
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
listener.postSucced(response);
|
||||
listener.postSucceed(response);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -105,7 +105,7 @@ public class LibaoUtils {
|
||||
.subscribe(new JSONObjectResponse() {
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
listener.postSucced(response);
|
||||
listener.postSucceed(response);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -123,7 +123,7 @@ public class LibaoUtils {
|
||||
.subscribe(new Response<ResponseBody>() {
|
||||
@Override
|
||||
public void onResponse(ResponseBody response) {
|
||||
listener.postSucced(response);
|
||||
listener.postSucceed(response);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -140,7 +140,7 @@ public class LibaoUtils {
|
||||
.subscribe(new Response<List<LibaoStatusEntity>>() {
|
||||
@Override
|
||||
public void onResponse(List<LibaoStatusEntity> response) {
|
||||
listener.postSucced(response);
|
||||
listener.postSucceed(response);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -299,7 +299,7 @@ public class LibaoUtils {
|
||||
final Dialog loadingDialog = DialogUtils.showWaitDialog(context, "淘号中...");
|
||||
postLibaoTao(context, libaoEntity.getId(), new PostLibaoListener() {
|
||||
@Override
|
||||
public void postSucced(Object response) {
|
||||
public void postSucceed(Object response) {
|
||||
|
||||
if (loadingDialog != null) loadingDialog.dismiss();
|
||||
|
||||
@ -431,7 +431,7 @@ public class LibaoUtils {
|
||||
|
||||
postLibaoLing(context, libaoEntity.getId(), new PostLibaoListener() {
|
||||
@Override
|
||||
public void postSucced(Object response) {
|
||||
public void postSucceed(Object response) {
|
||||
if (loadingDialog != null) loadingDialog.dismiss();
|
||||
|
||||
JSONObject responseBody = (JSONObject) response;
|
||||
@ -629,7 +629,7 @@ public class LibaoUtils {
|
||||
|
||||
|
||||
public interface PostLibaoListener {
|
||||
void postSucced(Object response);
|
||||
void postSucceed(Object response);
|
||||
|
||||
void postFailed(Throwable error);
|
||||
}
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.retrofit.JSONObjectResponse;
|
||||
import com.gh.gamecenter.retrofit.Response;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
@ -12,8 +10,6 @@ import com.lightgame.utils.Utils;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.MediaType;
|
||||
@ -106,68 +102,6 @@ public class LoginUtils {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 请用 ErrorHelper.handleError 替代本方法
|
||||
*/
|
||||
@Deprecated
|
||||
public static void userPostErrorToast(String errorString, Context context, boolean isQuestion) {
|
||||
if (TextUtils.isEmpty(errorString)) {
|
||||
Utils.toast(context, R.string.post_failure_hint);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
JSONObject errorJson = new JSONObject(errorString);
|
||||
Iterator<String> iterator = errorJson.keys();
|
||||
while (iterator.hasNext()) {
|
||||
String key = iterator.next();
|
||||
if ("toast".equals(key)) {
|
||||
Utils.toast(context, errorJson.get(key).toString());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int errorCode = errorJson.getInt("code");
|
||||
switch (errorCode) {
|
||||
case 403018:
|
||||
Utils.toast(context, R.string.comment_failed_unable);
|
||||
case 403050:
|
||||
case 403053:
|
||||
case 403048:
|
||||
case 403049:
|
||||
case 403057:
|
||||
case 403045:
|
||||
case 403046:
|
||||
case 403054:
|
||||
Utils.toast(context, R.string.comment_failed_userbanned);
|
||||
break;
|
||||
case 403051:
|
||||
Utils.toast(context, R.string.comment_failed_userblocked);
|
||||
break;
|
||||
case 403020:
|
||||
if (isQuestion) {
|
||||
DialogUtils.showAlertDialog(context, "限制提醒"
|
||||
, "提问过于频繁,请先休息一下哦", "知道了"
|
||||
, null, null, null);
|
||||
} else {
|
||||
Utils.toast(context, R.string.comment_failed_toofrequent);
|
||||
}
|
||||
break;
|
||||
case 403021:
|
||||
Utils.toast(context, R.string.comment_failed_illegal);
|
||||
break;
|
||||
case 403047:
|
||||
Utils.toast(context, R.string.deny_vote_answer);
|
||||
break;
|
||||
default:
|
||||
Utils.toast(context, R.string.post_failure_hint);
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Utils.toast(context, R.string.post_failure_hint);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void captchaErrorHint(Context context, JSONObject content) {
|
||||
try {
|
||||
@ -318,12 +252,18 @@ public class LoginUtils {
|
||||
case 403016:
|
||||
Utils.toast(context, "内容违规,请修改后再保存");
|
||||
break;
|
||||
case 403021:
|
||||
Utils.toast(context, "内容可能包含敏感信息,请修改后再提交");
|
||||
break;
|
||||
case 403801:
|
||||
Utils.toast(context, "获取验证码太频繁,请稍后再试");
|
||||
break;
|
||||
case 403204:
|
||||
Utils.toast(context, "获取验证码太频繁,请稍后再试");
|
||||
break;
|
||||
case 400212:
|
||||
Utils.toast(context, "请输入正确的手机号");
|
||||
break;
|
||||
default:
|
||||
Utils.toast(context, code + "");
|
||||
break;
|
||||
|
||||
@ -11,11 +11,11 @@ import android.graphics.Matrix;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.support.v4.content.*;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
@ -28,19 +28,17 @@ import com.gh.common.constant.Config;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.lightgame.utils.Utils;
|
||||
import com.tencent.connect.share.QQShare;
|
||||
import com.tencent.mm.sdk.openapi.IWXAPI;
|
||||
import com.tencent.mm.sdk.openapi.SendMessageToWX;
|
||||
import com.tencent.mm.sdk.openapi.WXAPIFactory;
|
||||
import com.tencent.mm.sdk.openapi.WXImageObject;
|
||||
import com.tencent.mm.sdk.openapi.WXMediaMessage;
|
||||
import com.tencent.mm.sdk.platformtools.Util;
|
||||
import com.tencent.mm.opensdk.modelmsg.SendMessageToWX;
|
||||
import com.tencent.mm.opensdk.modelmsg.WXImageObject;
|
||||
import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
|
||||
import com.tencent.mm.opensdk.openapi.IWXAPI;
|
||||
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
|
||||
import com.tencent.tauth.IUiListener;
|
||||
import com.tencent.tauth.Tencent;
|
||||
import com.tencent.tauth.UiError;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
@ -308,7 +306,7 @@ public class MessageShareUtils {
|
||||
req.scene = SendMessageToWX.Req.WXSceneTimeline;
|
||||
|
||||
Bitmap compressBp = compressBitmap(shareBm);
|
||||
msg.thumbData = Util.bmpToByteArray(compressBp, true);
|
||||
msg.thumbData = ImageUtils.bmpToByteArray(compressBp, true);
|
||||
mIWXAPI.sendReq(req);
|
||||
|
||||
if (mPopupWindow == null) return;
|
||||
@ -376,7 +374,7 @@ public class MessageShareUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
} catch (Exception e) {
|
||||
Utils.log("消息分享异常" + e.toString());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
|
||||
@ -3,6 +3,7 @@ package com.gh.common.util;
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.telephony.TelephonyManager;
|
||||
|
||||
public class NetworkUtils {
|
||||
|
||||
@ -119,4 +120,48 @@ public class NetworkUtils {
|
||||
return "NONE";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前移动网络连接的类型信息(当连接的网络是移动网络时使用)
|
||||
*
|
||||
* @param context 上下文
|
||||
* @return 当前移动网络连接的类型信息
|
||||
*/
|
||||
public static String getMobileNetworkType(Context context) {
|
||||
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo info = connectivityManager.getActiveNetworkInfo();
|
||||
|
||||
if (info == null) return "unknown";
|
||||
|
||||
switch (info.getType()) {
|
||||
// Unknown
|
||||
case TelephonyManager.NETWORK_TYPE_UNKNOWN:
|
||||
return "unknown";
|
||||
// Cellular Data–2G
|
||||
case TelephonyManager.NETWORK_TYPE_EDGE:
|
||||
case TelephonyManager.NETWORK_TYPE_GPRS:
|
||||
case TelephonyManager.NETWORK_TYPE_CDMA:
|
||||
case TelephonyManager.NETWORK_TYPE_IDEN:
|
||||
case TelephonyManager.NETWORK_TYPE_1xRTT:
|
||||
return "2G";
|
||||
// Cellular Data–3G
|
||||
case TelephonyManager.NETWORK_TYPE_UMTS:
|
||||
case TelephonyManager.NETWORK_TYPE_HSDPA:
|
||||
case TelephonyManager.NETWORK_TYPE_HSPA:
|
||||
case TelephonyManager.NETWORK_TYPE_HSPAP:
|
||||
case TelephonyManager.NETWORK_TYPE_HSUPA:
|
||||
case TelephonyManager.NETWORK_TYPE_EVDO_0:
|
||||
case TelephonyManager.NETWORK_TYPE_EVDO_A:
|
||||
case TelephonyManager.NETWORK_TYPE_EVDO_B:
|
||||
return "3G";
|
||||
// Cellular Data–4G
|
||||
case TelephonyManager.NETWORK_TYPE_LTE:
|
||||
return "4G";
|
||||
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,18 +1,18 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import java.math.BigDecimal
|
||||
import java.text.DecimalFormat
|
||||
|
||||
object NumberUtils {
|
||||
|
||||
@JvmStatic
|
||||
fun transSimpleCount(count: Int): String {
|
||||
val s: String
|
||||
if (count > 10000) {
|
||||
s = if (count > 100000) {
|
||||
val number = count / 10000f
|
||||
val bd = BigDecimal(number.toDouble())
|
||||
s = bd.setScale(1, BigDecimal.ROUND_DOWN).toString() + "W"
|
||||
val fmt = DecimalFormat("#")
|
||||
fmt.format(number) + "万"
|
||||
} else {
|
||||
s = count.toString()
|
||||
count.toString()
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
44
app/src/main/java/com/gh/common/util/OptionDialogHelper.kt
Normal file
44
app/src/main/java/com/gh/common/util/OptionDialogHelper.kt
Normal file
@ -0,0 +1,44 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.view.Window
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import com.gh.gamecenter.R
|
||||
|
||||
object OptionDialogHelper {
|
||||
|
||||
fun showOptionDialog(context: Context, typeList: List<String>, callback: (String) -> Unit) {
|
||||
val dialog = Dialog(context)
|
||||
val container = LinearLayout(context)
|
||||
container.orientation = LinearLayout.VERTICAL
|
||||
container.setBackgroundColor(Color.WHITE)
|
||||
container.setPadding(0, DisplayUtils.dip2px(context, 12f), 0, DisplayUtils.dip2px(context, 12f))
|
||||
|
||||
for (type in typeList) {
|
||||
val reportTv = TextView(context)
|
||||
reportTv.text = type
|
||||
reportTv.textSize = 17f
|
||||
reportTv.setTextColor(ContextCompat.getColor(context, R.color.title))
|
||||
reportTv.setBackgroundResource(R.drawable.textview_white_style)
|
||||
val widthPixels = context.resources.displayMetrics.widthPixels
|
||||
reportTv.layoutParams = LinearLayout.LayoutParams(widthPixels * 9 / 10,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT)
|
||||
reportTv.setPadding(DisplayUtils.dip2px(context, 20f), DisplayUtils.dip2px(context, 12f),
|
||||
0, DisplayUtils.dip2px(context, 12f))
|
||||
container.addView(reportTv)
|
||||
|
||||
reportTv.setOnClickListener {
|
||||
callback.invoke(reportTv.text.toString())
|
||||
dialog.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||
dialog.setContentView(container)
|
||||
dialog.show()
|
||||
}
|
||||
}
|
||||
@ -19,6 +19,7 @@ import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.entity.ApkEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.entity.GameUpdateEntity;
|
||||
import com.halo.assistant.HaloApp;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import org.json.JSONArray;
|
||||
@ -79,7 +80,7 @@ public class PackageUtils {
|
||||
for (ApkEntity apkEntity : gameEntity.getApkNormal()) {
|
||||
|
||||
String versionFromRequest = apkEntity.getVersion();
|
||||
String versionFromInstalledApp = getVersionByPackage(context, apkEntity.getPackageName());
|
||||
String versionFromInstalledApp = getVersionByPackage(apkEntity.getPackageName());
|
||||
|
||||
// 是否需要显示更新
|
||||
boolean shouldShouldUpdate = apkEntity.getForce();
|
||||
@ -310,9 +311,9 @@ public class PackageUtils {
|
||||
/*
|
||||
* 获取apk的版本
|
||||
*/
|
||||
public static String getVersionByPackage(Context context, String packageName) {
|
||||
public static String getVersionByPackage(String packageName) {
|
||||
try {
|
||||
return context.getApplicationContext().getPackageManager().getPackageInfo(packageName,
|
||||
return HaloApp.getInstance().getApplication().getPackageManager().getPackageInfo(packageName,
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT).versionName;
|
||||
} catch (NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
@ -370,6 +371,25 @@ public class PackageUtils {
|
||||
return jsonArray;
|
||||
}
|
||||
|
||||
public static JSONObject getAppBasicInfoByPackageName(String packageName) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
PackageManager pm = HaloApp.getInstance().getApplication().getPackageManager();
|
||||
try {
|
||||
PackageInfo packageInfo = HaloApp.getInstance().getApplication().getPackageManager().getPackageInfo(packageName,
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT);
|
||||
if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
|
||||
jsonObject.put("name", pm.getApplicationLabel(packageInfo.applicationInfo).toString());
|
||||
jsonObject.put("package", packageName);
|
||||
jsonObject.put("version", packageInfo.versionName);
|
||||
}
|
||||
return jsonObject;
|
||||
} catch (JSONException | NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return jsonObject;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 启动应用
|
||||
*/
|
||||
|
||||
@ -133,7 +133,7 @@ public class PlatformUtils {
|
||||
}
|
||||
}
|
||||
|
||||
updataPlatform(platformMap, platformPicMap, platformPicUrlMap,
|
||||
updatePlatform(platformMap, platformPicMap, platformPicUrlMap,
|
||||
platformColorMap);
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@ public class PlatformUtils {
|
||||
}
|
||||
}
|
||||
|
||||
private void updataPlatform(ArrayMap<String, String> pMap,
|
||||
private void updatePlatform(ArrayMap<String, String> pMap,
|
||||
ArrayMap<String, Integer> pPMap, ArrayMap<String, String> pUMap,
|
||||
ArrayMap<String, String> pCMap) {
|
||||
platformMap = pMap;
|
||||
|
||||
47
app/src/main/java/com/gh/common/util/PushHelper.kt
Normal file
47
app/src/main/java/com/gh/common/util/PushHelper.kt
Normal file
@ -0,0 +1,47 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.content.Context
|
||||
import com.gh.gamecenter.receiver.UmengMessageReceiver
|
||||
import com.gh.gamecenter.retrofit.BiResponse
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.ResponseBody
|
||||
|
||||
object PushHelper {
|
||||
|
||||
/**
|
||||
* 提交推送点击事件,会尝试从 SP 读取之前失败的一并提交
|
||||
*/
|
||||
@JvmStatic
|
||||
fun postPushClickAction(context: Context, clickEvent: UmengMessageReceiver.ClickEvent? = null) {
|
||||
val clickEventList = arrayListOf<UmengMessageReceiver.ClickEvent>()
|
||||
|
||||
clickEvent?.let { clickEventList.add(it) }
|
||||
|
||||
val failedClickEventList = SPUtils.getString(UmengMessageReceiver.SP_CLICK_EVENT)
|
||||
.toObject<ArrayList<UmengMessageReceiver.ClickEvent>>()
|
||||
|
||||
failedClickEventList?.let { clickEventList.addAll(it) }
|
||||
|
||||
// 没有要提交的事件
|
||||
if (clickEventList.size == 0) return
|
||||
|
||||
val body = RequestBody.create(MediaType.parse("application/json"), clickEventList.toJson())
|
||||
|
||||
RetrofitManager.getInstance(context)
|
||||
.api
|
||||
.postUmengReceiveInfo(body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
SPUtils.setString(UmengMessageReceiver.SP_CLICK_EVENT, "")
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
SPUtils.setString(UmengMessageReceiver.SP_CLICK_EVENT, clickEventList.toJson())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -37,12 +37,11 @@ import com.sina.weibo.sdk.WbSdk;
|
||||
import com.sina.weibo.sdk.auth.AuthInfo;
|
||||
import com.tencent.connect.share.QQShare;
|
||||
import com.tencent.connect.share.QzoneShare;
|
||||
import com.tencent.mm.sdk.openapi.IWXAPI;
|
||||
import com.tencent.mm.sdk.openapi.SendMessageToWX;
|
||||
import com.tencent.mm.sdk.openapi.WXAPIFactory;
|
||||
import com.tencent.mm.sdk.openapi.WXMediaMessage;
|
||||
import com.tencent.mm.sdk.openapi.WXWebpageObject;
|
||||
import com.tencent.mm.sdk.platformtools.Util;
|
||||
import com.tencent.mm.opensdk.modelmsg.SendMessageToWX;
|
||||
import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
|
||||
import com.tencent.mm.opensdk.modelmsg.WXWebpageObject;
|
||||
import com.tencent.mm.opensdk.openapi.IWXAPI;
|
||||
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
|
||||
import com.tencent.tauth.IUiListener;
|
||||
import com.tencent.tauth.Tencent;
|
||||
import com.tencent.tauth.UiError;
|
||||
@ -296,10 +295,10 @@ public class ShareUtils {
|
||||
protected void onNewResultImpl(Bitmap bitmap) {
|
||||
Bitmap compressBp = compressBitmap(bitmap);
|
||||
if (mShareType == ShareType.askNormal || mShareType == ShareType.askInvite) {
|
||||
msg.thumbData = Util.bmpToByteArray(compressBp, true);
|
||||
msg.thumbData = ImageUtils.bmpToByteArray(compressBp, true);
|
||||
} else {
|
||||
Bitmap resultBp = addBackGround(compressBp);
|
||||
msg.thumbData = Util.bmpToByteArray(resultBp, true);
|
||||
msg.thumbData = ImageUtils.bmpToByteArray(resultBp, true);
|
||||
}
|
||||
mIWXAPI.sendReq(req);
|
||||
}
|
||||
|
||||
54
app/src/main/java/com/gh/common/util/SimpleRequestHelper.kt
Normal file
54
app/src/main/java/com/gh/common/util/SimpleRequestHelper.kt
Normal file
@ -0,0 +1,54 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import com.gh.gamecenter.retrofit.Response
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Utils
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import okhttp3.ResponseBody
|
||||
import retrofit2.HttpException
|
||||
|
||||
/**
|
||||
* 可以在此类发送一些无关页面操作的请求
|
||||
*/
|
||||
object SimpleRequestHelper {
|
||||
private val mApi = RetrofitManager.getInstance(HaloApp.getInstance().application).api
|
||||
|
||||
fun reportGameComment(gameId: String, commentId: String, type: String) {
|
||||
val map = HashMap<String, String>()
|
||||
map["reason"] = type
|
||||
mApi.reportGameComment(gameId, commentId, map.createRequestBody())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
Utils.toast(HaloApp.getInstance().application, "感谢您的举报")
|
||||
}
|
||||
|
||||
override fun onFailure(e: HttpException?) {
|
||||
ErrorHelper.handleError(HaloApp.getInstance().application, e?.response()?.errorBody()?.string())
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
fun reportGameCommentReply(gameId: String, commentId: String, replyId: String, type: String) {
|
||||
val map = HashMap<String, String>()
|
||||
map["reason"] = type
|
||||
mApi.reportGameCommentReply(gameId, commentId, replyId, map.createRequestBody())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
Utils.toast(HaloApp.getInstance().application, "感谢您的举报")
|
||||
}
|
||||
|
||||
override fun onFailure(e: HttpException?) {
|
||||
ErrorHelper.handleError(HaloApp.getInstance().application, e?.response()?.errorBody()?.string())
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -45,6 +45,16 @@ object SPUtils {
|
||||
return sp.getInt(key, defaultValue)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getLong(key: String, defaultValue: Long): Long {
|
||||
return sp.getLong(key, defaultValue)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun setLong(key: String, value: Long) {
|
||||
return sp.edit().putLong(key, value).apply()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun setBoolean(key: String, value: Boolean) {
|
||||
sp.edit().putBoolean(key, value).apply()
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.text.Editable
|
||||
import android.text.InputFilter
|
||||
import android.text.TextWatcher
|
||||
import android.widget.EditText
|
||||
import com.gh.gamecenter.R
|
||||
@ -9,7 +10,7 @@ object TextHelper {
|
||||
|
||||
@JvmStatic
|
||||
fun limitTheLengthOfEditText(editText: EditText, length: Int, exceedCallback: ExceedTextLengthLimitCallback? = null) {
|
||||
editText.addTextChangedListener(object :TextWatcher {
|
||||
editText.addTextChangedListener(object : TextWatcher {
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
|
||||
}
|
||||
@ -32,6 +33,22 @@ object TextHelper {
|
||||
})
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getFilter(maxLength: Int, msg: String)//限制最大长度-Toast弹窗提示
|
||||
: InputFilter {
|
||||
return InputFilter { source, start, end, dest, dstart, dend ->
|
||||
val keep = maxLength - (dest.length - (dend - dstart))
|
||||
if (keep < end - start) {
|
||||
ToastUtils.showToast(msg)
|
||||
}
|
||||
when {
|
||||
keep <= 0 -> ""
|
||||
keep >= end - start -> null
|
||||
else -> source.subSequence(start, start + keep)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface ExceedTextLengthLimitCallback {
|
||||
fun onExceed()
|
||||
}
|
||||
|
||||
40
app/src/main/java/com/gh/common/util/ToastUtils.kt
Normal file
40
app/src/main/java/com/gh/common/util/ToastUtils.kt
Normal file
@ -0,0 +1,40 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.widget.Toast
|
||||
|
||||
import com.halo.assistant.HaloApp
|
||||
|
||||
object ToastUtils {
|
||||
/** 之前显示的内容 */
|
||||
private var mOldMsg: String? = null
|
||||
/** Toast对象 */
|
||||
private var mToast: Toast? = null
|
||||
/** 第一次时间 */
|
||||
private var mOneTime: Long = 0
|
||||
/** 第二次时间 */
|
||||
private var mTwoTime: Long = 0
|
||||
|
||||
/**
|
||||
* 显示Toast
|
||||
* @param message
|
||||
*/
|
||||
fun showToast(message: String) {
|
||||
if (mToast == null) {
|
||||
mToast = Toast.makeText(HaloApp.getInstance().application, message, Toast.LENGTH_SHORT)
|
||||
mToast!!.show()
|
||||
mOneTime = System.currentTimeMillis()
|
||||
} else {
|
||||
mTwoTime = System.currentTimeMillis()
|
||||
if (message == mOldMsg) {
|
||||
if (mTwoTime - mOneTime > Toast.LENGTH_SHORT) {
|
||||
mToast!!.show()
|
||||
}
|
||||
} else {
|
||||
mOldMsg = message
|
||||
mToast!!.setText(message)
|
||||
mToast!!.show()
|
||||
}
|
||||
}
|
||||
mOneTime = mTwoTime
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.graphics.BitmapFactory
|
||||
import com.gh.gamecenter.retrofit.BiResponse
|
||||
import com.gh.gamecenter.retrofit.FileRequestBody
|
||||
@ -17,6 +18,8 @@ import okhttp3.MultipartBody
|
||||
import okhttp3.ResponseBody
|
||||
import org.json.JSONObject
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
|
||||
object UploadImageUtils {
|
||||
|
||||
@ -27,7 +30,7 @@ object UploadImageUtils {
|
||||
icon
|
||||
}
|
||||
|
||||
// 不处理图片,只是单纯的上次
|
||||
// 不处理图片,只是单纯的上传
|
||||
fun uploadImage(type: UploadType, imgPath: String, listener: OnUploadImageListener): Disposable {
|
||||
return Single.just(imgPath)
|
||||
.subscribeOn(Schedulers.computation())
|
||||
@ -99,8 +102,10 @@ object UploadImageUtils {
|
||||
})
|
||||
}
|
||||
|
||||
fun compressAndUploadImageList(type: UploadType, imgs: List<String>, compressGif: Boolean, listener: OnUploadImageListListener) {
|
||||
val postImageList = HashMap<String, String>()
|
||||
@SuppressLint("CheckResult")
|
||||
fun compressAndUploadImageList(type: UploadType, imgs: List<String>, compressGif: Boolean, listener: OnUploadImageListListener): Disposable? {
|
||||
var subscription: Disposable? = null
|
||||
val postImageList = LinkedHashMap<String, String>()
|
||||
|
||||
Observable.create(ObservableOnSubscribe<Map<String, String>> {
|
||||
val compressList = compressImageList(imgs, compressGif)
|
||||
@ -110,9 +115,12 @@ object UploadImageUtils {
|
||||
listTotal += img.length()
|
||||
}
|
||||
for (img in compressList) {
|
||||
if (subscription?.isDisposed == true) return@ObservableOnSubscribe
|
||||
val requestBody = FileRequestBody<ResponseBody>(img, object : RetrofitCallback<ResponseBody>() {
|
||||
override fun onProgress(total: Long, progress: Long) {
|
||||
listener.onProgress(listTotal, listProgress + progress)
|
||||
if (subscription?.isDisposed != true) {
|
||||
listener.onProgress(listTotal, listProgress + progress)
|
||||
}
|
||||
}
|
||||
})
|
||||
val part = MultipartBody.Part.createFormData("Filedata", getFileName(img), requestBody)
|
||||
@ -120,11 +128,12 @@ object UploadImageUtils {
|
||||
.uploadApi.uploadImage(part, type.name)
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
if (subscription?.isDisposed == true) return
|
||||
val string = data.string()
|
||||
if (!string.isNullOrEmpty()) {
|
||||
val url = JSONObject(string).getString("url")
|
||||
if (!url.isNullOrEmpty()) {
|
||||
val map = HashMap<String, String>()
|
||||
val map = LinkedHashMap<String, String>()
|
||||
map[img.path] = url
|
||||
it.onNext(map)
|
||||
return
|
||||
@ -134,7 +143,10 @@ object UploadImageUtils {
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
it.onError(exception)
|
||||
// 若遇到错误且 subscription?.isDisposed 为 true 时会抛出 io.reactivex.exceptions.UndeliverableException 异常
|
||||
// if (subscription?.isDisposed == true) return
|
||||
// it.onError(exception) // fuck
|
||||
it.onNext(Collections.emptyMap())
|
||||
}
|
||||
})
|
||||
listProgress += img.length()
|
||||
@ -143,8 +155,9 @@ object UploadImageUtils {
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Observer<Map<String, String>> {
|
||||
.subscribe(object : Observer<Map<String, String>?> {
|
||||
override fun onSubscribe(d: Disposable) {
|
||||
subscription = d
|
||||
}
|
||||
|
||||
override fun onComplete() {
|
||||
@ -156,12 +169,14 @@ object UploadImageUtils {
|
||||
}
|
||||
|
||||
override fun onNext(t: Map<String, String>) {
|
||||
postImageList.putAll(t)
|
||||
if (!t.isEmpty()) postImageList.putAll(t)
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
})
|
||||
return subscription
|
||||
}
|
||||
|
||||
// 同步调用->避免在主线程调用以免阻塞主线程
|
||||
@ -196,7 +211,7 @@ object UploadImageUtils {
|
||||
}
|
||||
|
||||
interface OnUploadImageListListener {
|
||||
fun onSuccess(imageUrl: Map<String, String>) // key:sourceImage value:compressImage
|
||||
fun onSuccess(imageUrl: LinkedHashMap<String, String>) // key:sourceImage value:compressImage
|
||||
fun onError() // 全部上传失败时回调
|
||||
fun onProgress(total: Long, progress: Long)
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ public class DownloadProgressBar extends ProgressBar {
|
||||
String txt = TextUtils.ellipsize(mText, mFakeTextPaint, width, TextUtils.TruncateAt.END).toString();
|
||||
srcCanvas.drawText(txt, getWidth() / 2, baseline, mPaint);
|
||||
mPaint.setXfermode(mDuffXFerMode);
|
||||
if (getProgress() != 0 && getProgress() != MAX_LENGTH) {
|
||||
if (getProgress() != 0) {
|
||||
mPaint.setColor(DOWNLOAD_IMAGE_STYLE == mDownloadStyle ? Color.BLACK : Color.WHITE); // 反向颜色
|
||||
}
|
||||
|
||||
@ -121,7 +121,6 @@ public class DownloadProgressBar extends ProgressBar {
|
||||
|
||||
public void setText(@StringRes int res) {
|
||||
setText(getResources().getString(res));
|
||||
invalidate(); // 文字绘制没有同步 就重绘多几遍吧 虽然不知到有没有用
|
||||
}
|
||||
|
||||
public void setDownloadType(DownloadType downloadType) {
|
||||
|
||||
@ -89,7 +89,8 @@ public class ExpendTextView extends android.support.v7.widget.AppCompatTextView
|
||||
}
|
||||
SpannableStringBuilder msp = new SpannableStringBuilder(content);
|
||||
int length = msp.length();
|
||||
msp.replace(length - mExpendText.length(), length, mExpendText);
|
||||
int startPosition = length - mExpendText.length();
|
||||
msp.replace(startPosition < 0 ? 0 : startPosition, length, mExpendText);
|
||||
msp.setSpan(new ClickableSpan() {
|
||||
@Override
|
||||
public void updateDrawState(TextPaint ds) {
|
||||
@ -114,6 +115,12 @@ public class ExpendTextView extends android.support.v7.widget.AppCompatTextView
|
||||
setMovementMethod(CustomLinkMovementMethod.getInstance());
|
||||
}
|
||||
|
||||
|
||||
public void setExpendMaxLines(int maxLines) {
|
||||
mMaxLines = maxLines;
|
||||
setMaxLines(maxLines);
|
||||
}
|
||||
|
||||
public interface ExpandCallback {
|
||||
void onExpand();
|
||||
}
|
||||
|
||||
@ -61,8 +61,6 @@ public class MessageSpannableTextView extends android.support.v7.widget.AppCompa
|
||||
markData.setKey(key);
|
||||
|
||||
mMarkList.add(markData);
|
||||
System.out.println(substring);
|
||||
System.out.println(s);
|
||||
} else {
|
||||
builder.append(s);
|
||||
if (i != split.length - 1 || sText.substring(sText.length() - 2, sText.length()).equals("}}")) {
|
||||
|
||||
@ -13,12 +13,14 @@ import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
|
||||
import com.gh.common.util.AskUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.GsonUtils;
|
||||
import com.gh.common.util.HtmlUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.common.util.NetworkUtils;
|
||||
import com.gh.common.util.RichEditorUtils;
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.qa.entity.EditorInsertEntity;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
@ -90,6 +92,7 @@ public class RichEditor extends WebView {
|
||||
private static final String SETUP_HTML = "file:///android_asset/editor.html";
|
||||
private static final String CALLBACK_SCHEME = "re-callback://";
|
||||
private static final String STATE_SCHEME = "re-state://";
|
||||
|
||||
private boolean isReady = false;
|
||||
private String mContents;
|
||||
private OnTextChangeListener mTextChangeListener;
|
||||
@ -122,11 +125,12 @@ public class RichEditor extends WebView {
|
||||
getSettings().setJavaScriptEnabled(true);
|
||||
setWebChromeClient(new WebChromeClient()); // 不要重写这个方法否则无法加载
|
||||
setWebViewClient(createWebViewClient());
|
||||
// 临时开启让 H5 同事调试
|
||||
if (BuildConfig.DEBUG && Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
|
||||
setWebContentsDebuggingEnabled(true);
|
||||
}
|
||||
loadUrl(SETUP_HTML);
|
||||
|
||||
loadUrl(SETUP_HTML);
|
||||
applyAttributes(context, attrs);
|
||||
}
|
||||
|
||||
@ -213,7 +217,6 @@ public class RichEditor extends WebView {
|
||||
}
|
||||
// getSettings().setBlockNetworkImage(true); // 先不加载网络图片,因为后面有资源替换操作防止流量无故丢失
|
||||
|
||||
// contents = contents.replace("src=", "class=\"lazy\" data-src=");
|
||||
try {
|
||||
exec("javascript:RE.setHtml('" + URLEncoder.encode(contents, "UTF-8") + "');");
|
||||
|
||||
@ -226,7 +229,6 @@ public class RichEditor extends WebView {
|
||||
replaceAllDfImageExcludeGif();
|
||||
}
|
||||
exec("javascript:RE.ImageClickListener()");
|
||||
// exec("javascript:RE.lazyLoad()");
|
||||
}
|
||||
|
||||
callback(contents);
|
||||
@ -234,6 +236,8 @@ public class RichEditor extends WebView {
|
||||
// No handling
|
||||
}
|
||||
mContents = contents;
|
||||
|
||||
showLinkStyle(); // 显示隐藏样式
|
||||
// getSettings().setBlockNetworkImage(false); // 重新加载图片
|
||||
}
|
||||
|
||||
@ -241,9 +245,26 @@ public class RichEditor extends WebView {
|
||||
return TextUtils.isEmpty(mContents) ? "" : mContents;
|
||||
}
|
||||
|
||||
public void setEditorFontColor(int color) {
|
||||
String hex = convertHexColorString(color);
|
||||
exec("javascript:RE.setBaseTextColor('" + hex + "');");
|
||||
public void insertCustomStyleLink(EditorInsertEntity entity) {
|
||||
if (entity == null) return;
|
||||
// 转译
|
||||
String brief = entity.getBrief();
|
||||
String title = entity.getTitle();
|
||||
brief = TextUtils.isEmpty(brief) ? "" : brief.replaceAll("[\\x00-\\x1F\\x7F]", "");
|
||||
title = TextUtils.isEmpty(title) ? "" : title.replaceAll("[\\x00-\\x1F\\x7F]", "");
|
||||
|
||||
entity.setBrief(TextUtils.htmlEncode(brief));
|
||||
entity.setTitle(TextUtils.htmlEncode(title));
|
||||
entity.setIcon(TextUtils.htmlEncode(entity.getIcon()));
|
||||
exec("javascript:RE.insertCustomStyleLink('" + GsonUtils.toJson(entity) + "');");
|
||||
}
|
||||
|
||||
public void hideLinkStyle() {
|
||||
exec("javascript:RE.hideLinkStyle();");
|
||||
}
|
||||
|
||||
public void showLinkStyle() {
|
||||
exec("javascript:RE.showLinkStyle();");
|
||||
}
|
||||
|
||||
public void setEditorFontSize(int px) {
|
||||
@ -290,6 +311,58 @@ public class RichEditor extends WebView {
|
||||
exec("javascript:RE.setBackgroundImage('url(data:image/png;base64," + base64 + ")');");
|
||||
}
|
||||
|
||||
public void replaceAllDfImageExcludeGif() {
|
||||
exec("javascript:RE.replaceAllDfImage('" +
|
||||
ImageUtils.getLimitWidthRule(mDefaultImageWidth) + IMAGE_FLAG_DEFAULT + "','" +
|
||||
ImageUtils.getWatermarkWidthGifRule(mThumbnailImageWidth) + IMAGE_FLAG_THUMBNAIL + "')");
|
||||
}
|
||||
|
||||
|
||||
public void replaceAllDfImage() {
|
||||
exec("javascript:RE.replaceAllDfImage('" +
|
||||
ImageUtils.getLimitWidthRule(mDefaultImageWidth) + IMAGE_FLAG_DEFAULT + "','" +
|
||||
ImageUtils.getDefaultGifRule() + IMAGE_FLAG_DEFAULT + "')");
|
||||
}
|
||||
|
||||
public void replaceDfImageByUrl(String imgUrl) {
|
||||
exec("javascript:RE.replaceDfImageByUrl('" + imgUrl + "','" +
|
||||
ImageUtils.getLimitWidthRule(mDefaultImageWidth) + IMAGE_FLAG_DEFAULT + "','" +
|
||||
ImageUtils.getDefaultGifRule() + IMAGE_FLAG_DEFAULT + "');");
|
||||
}
|
||||
|
||||
public void loadCSS(String cssFile) {
|
||||
String jsCSSImport = "(function() {" +
|
||||
" var head = document.getElementsByTagName(\"head\")[0];" +
|
||||
" var link = document.createElement(\"link\");" +
|
||||
" link.rel = \"stylesheet\";" +
|
||||
" link.type = \"text/css\";" +
|
||||
" link.href = \"" + cssFile + "\";" +
|
||||
" link.media = \"all\";" +
|
||||
" head.appendChild(link);" +
|
||||
"}) ();";
|
||||
exec("javascript:" + jsCSSImport + "");
|
||||
}
|
||||
|
||||
public void insertImage(String url) {
|
||||
exec("javascript:RE.prepareInsert();");
|
||||
exec("javascript:RE.insertImage('" + url + "');");
|
||||
}
|
||||
|
||||
public void insertHtml(String html) {
|
||||
exec("javascript:RE.prepareInsert();");
|
||||
exec("javascript:RE.insertHTML('" + html + "');");
|
||||
}
|
||||
|
||||
public void focusEditor() {
|
||||
requestFocus();
|
||||
exec("javascript:RE.focus();");
|
||||
}
|
||||
|
||||
public void insertLink(String href, String title) {
|
||||
exec("javascript:RE.prepareInsert();");
|
||||
exec("javascript:RE.insertLink('" + href + "', '" + title + "');");
|
||||
}
|
||||
|
||||
public void setBackground(String url) {
|
||||
exec("javascript:RE.setBackgroundImage('url(" + url + ")');");
|
||||
}
|
||||
@ -314,68 +387,90 @@ public class RichEditor extends WebView {
|
||||
exec("javascript:RE.setInputEnabled(" + inputEnabled + ")");
|
||||
}
|
||||
|
||||
public void replaceAllDfImageExcludeGif() {
|
||||
exec("javascript:RE.replaceAllDfImage('" +
|
||||
ImageUtils.getLimitWidthRule(mDefaultImageWidth) + IMAGE_FLAG_DEFAULT + "','" +
|
||||
ImageUtils.getWatermarkWidthGifRule(mThumbnailImageWidth) + IMAGE_FLAG_THUMBNAIL + "')");
|
||||
}
|
||||
|
||||
|
||||
public void replaceAllDfImage() {
|
||||
exec("javascript:RE.replaceAllDfImage('" +
|
||||
ImageUtils.getLimitWidthRule(mDefaultImageWidth) + IMAGE_FLAG_DEFAULT + "','" +
|
||||
ImageUtils.getDefaultGifRule() + IMAGE_FLAG_DEFAULT + "')");
|
||||
}
|
||||
|
||||
public void setFocusByEnd() {
|
||||
exec("javascript:RE.setFocusByEnd()");
|
||||
}
|
||||
|
||||
public void replaceDfImageByUrl(String imgUrl) {
|
||||
exec("javascript:RE.replaceDfImageByUrl('" + imgUrl + "','" +
|
||||
ImageUtils.getLimitWidthRule(mDefaultImageWidth) + IMAGE_FLAG_DEFAULT + "','" +
|
||||
ImageUtils.getDefaultGifRule() + IMAGE_FLAG_DEFAULT + "');");
|
||||
}
|
||||
|
||||
public void loadCSS(String cssFile) {
|
||||
String jsCSSImport = "(function() {" +
|
||||
" var head = document.getElementsByTagName(\"head\")[0];" +
|
||||
" var link = document.createElement(\"link\");" +
|
||||
" link.rel = \"stylesheet\";" +
|
||||
" link.type = \"text/css\";" +
|
||||
" link.href = \"" + cssFile + "\";" +
|
||||
" link.media = \"all\";" +
|
||||
" head.appendChild(link);" +
|
||||
"}) ();";
|
||||
exec("javascript:" + jsCSSImport + "");
|
||||
}
|
||||
|
||||
|
||||
public void setTextColor(int color) {
|
||||
exec("javascript:RE.prepareInsert();");
|
||||
|
||||
String hex = convertHexColorString(color);
|
||||
exec("javascript:RE.prepareInsert();");
|
||||
exec("javascript:RE.setTextColor('" + hex + "');");
|
||||
}
|
||||
|
||||
public void insertImage(String url) {
|
||||
exec("javascript:RE.prepareInsert();");
|
||||
exec("javascript:RE.insertImage('" + url + "');");
|
||||
public void removeFormat() {
|
||||
exec("javascript:RE.removeFormat();");
|
||||
}
|
||||
|
||||
public void insertHtml(String html) {
|
||||
exec("javascript:RE.prepareInsert();");
|
||||
exec("javascript:RE.insertHTML('" + html + "');");
|
||||
public void setHeading(int heading) {
|
||||
exec("javascript:RE.setHeading('" + heading + "');");
|
||||
}
|
||||
|
||||
public void focusEditor() {
|
||||
requestFocus();
|
||||
exec("javascript:RE.focus();");
|
||||
public void setIndent() {
|
||||
exec("javascript:RE.setIndent();");
|
||||
}
|
||||
|
||||
public void setOutdent() {
|
||||
exec("javascript:RE.setOutdent();");
|
||||
}
|
||||
|
||||
public void setAlignLeft() {
|
||||
exec("javascript:RE.setJustifyLeft();");
|
||||
}
|
||||
|
||||
public void setAlignCenter() {
|
||||
exec("javascript:RE.setJustifyCenter();");
|
||||
}
|
||||
|
||||
public void setAlignRight() {
|
||||
exec("javascript:RE.setJustifyRight();");
|
||||
}
|
||||
|
||||
public void setBlockquote() {
|
||||
exec("javascript:RE.setBlockquote();");
|
||||
}
|
||||
|
||||
public void setBullets() {
|
||||
exec("javascript:RE.setBullets();");
|
||||
}
|
||||
|
||||
public void setNumbers() {
|
||||
exec("javascript:RE.setNumbers();");
|
||||
}
|
||||
|
||||
public void undo() {
|
||||
exec("javascript:RE.undo();");
|
||||
}
|
||||
|
||||
public void redo() {
|
||||
exec("javascript:RE.redo();");
|
||||
}
|
||||
|
||||
public void setBold() {
|
||||
exec("javascript:RE.setBold();");
|
||||
}
|
||||
|
||||
public void setItalic() {
|
||||
exec("javascript:RE.setItalic();");
|
||||
}
|
||||
|
||||
public void setSubscript() {
|
||||
exec("javascript:RE.setSubscript();");
|
||||
}
|
||||
|
||||
public void setSuperscript() {
|
||||
exec("javascript:RE.setSuperscript();");
|
||||
}
|
||||
|
||||
public void setStrikeThrough() {
|
||||
exec("javascript:RE.setStrikeThrough();");
|
||||
}
|
||||
|
||||
public void setUnderline() {
|
||||
exec("javascript:RE.setUnderline();");
|
||||
}
|
||||
|
||||
public void formatBlock() {
|
||||
exec("javascript:RE.formatBlock();");
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return AskUtils.stripHtml(mContents);
|
||||
return HtmlUtils.stripHtml(mContents);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
package com.gh.common.view
|
||||
|
||||
import android.graphics.Rect
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.view.View
|
||||
|
||||
class SpacingItemDecoration(
|
||||
var onlyDecorateTheFirstItem: Boolean = false,
|
||||
var notDecorateTheFirstItem: Boolean = false,
|
||||
var notDecorateTheLastItem: Boolean = false,
|
||||
var left: Int = 0,
|
||||
var top: Int = 0,
|
||||
var right: Int = 0,
|
||||
var bottom: Int = 0)
|
||||
: RecyclerView.ItemDecoration() {
|
||||
|
||||
override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State?) {
|
||||
if (onlyDecorateTheFirstItem) {
|
||||
if (parent.getChildAdapterPosition(view) == 0) outRect.set(left, top, right, bottom)
|
||||
} else {
|
||||
if (parent.getChildAdapterPosition(view) == 0 && notDecorateTheFirstItem) {
|
||||
outRect.set(0, 0, 0, 0)
|
||||
} else if (parent.getChildAdapterPosition(view) == parent.adapter.itemCount - 1 && notDecorateTheLastItem) {
|
||||
outRect.set(0, 0, 0, 0)
|
||||
} else {
|
||||
outRect.set(left, top, right, bottom)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
64
app/src/main/java/com/gh/common/view/VerticalViewPager.kt
Normal file
64
app/src/main/java/com/gh/common/view/VerticalViewPager.kt
Normal file
@ -0,0 +1,64 @@
|
||||
package com.gh.common.view
|
||||
|
||||
import android.content.Context
|
||||
import android.support.v4.view.ViewPager
|
||||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
|
||||
class VerticalViewPager @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null)
|
||||
: ViewPager(context, attrs) {
|
||||
|
||||
init {
|
||||
// The majority of the magic happens here
|
||||
setPageTransformer(true, VerticalPageTransformer())
|
||||
// The easiest way to get rid of the overscroll drawing that happens on the left and right
|
||||
overScrollMode = View.OVER_SCROLL_NEVER
|
||||
}
|
||||
|
||||
private inner class VerticalPageTransformer : ViewPager.PageTransformer {
|
||||
override fun transformPage(view: View, position: Float) {
|
||||
if (position < -1) { // [-Infinity,-1)
|
||||
// This page is way off-screen to the left.
|
||||
view.alpha = 0F
|
||||
|
||||
} else if (position <= 1) { // [-1,1]
|
||||
view.alpha = 1F
|
||||
|
||||
// Counteract the default slide transition
|
||||
view.translationX = view.width * -position
|
||||
|
||||
//set Y position to swipe in from top
|
||||
val yPosition = position * view.height
|
||||
view.translationY = yPosition
|
||||
|
||||
} else { // (1,+Infinity]
|
||||
// This page is way off-screen to the right.
|
||||
view.alpha = 0F
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Swaps the X and Y coordinates of your touch event.
|
||||
*/
|
||||
private fun swapXY(ev: MotionEvent): MotionEvent {
|
||||
val width = width.toFloat()
|
||||
val height = height.toFloat()
|
||||
|
||||
val newX = ev.y / height * width
|
||||
val newY = ev.x / width * height
|
||||
|
||||
ev.setLocation(newX, newY)
|
||||
|
||||
return ev
|
||||
}
|
||||
|
||||
override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
|
||||
// val intercepted = super.onInterceptTouchEvent(swapXY(ev))
|
||||
// return touch coordinates to original reference frame for any child views
|
||||
// swapXY(ev)
|
||||
// we do not need it view pager to intercept touch event
|
||||
return false
|
||||
}
|
||||
}
|
||||
@ -18,6 +18,7 @@ import com.gh.common.util.DataCollectionUtils;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.GdtHelper;
|
||||
import com.gh.common.util.MD5Utils;
|
||||
import com.gh.common.util.MtaHelper;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.gamecenter.entity.ApkEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
@ -92,8 +93,13 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
|
||||
@Override
|
||||
public void onTaskError(DownloadEntity entity) {
|
||||
DownloadNotification.showDownloadingNotification(mContext);
|
||||
downloadingMap.remove(entity.getUrl());
|
||||
// 下载进度超出是任务出错,但不需要去掉状态栏通知 https://gitlab.ghzs.com/pm/halo-app-issues/issues/496
|
||||
if (entity.getStatus() == DownloadStatus.overflow) {
|
||||
MtaHelper.onEventWithBasicDeviceInfo("下载无法完成", "游戏", entity.getName());
|
||||
} else {
|
||||
DownloadNotification.showDownloadingNotification(mContext);
|
||||
downloadingMap.remove(entity.getUrl());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -29,7 +29,7 @@ public class DownloadNotification {
|
||||
|
||||
public static final String ACTION_INSTALL = "com.gh.gamecenter.INSTALL";
|
||||
public static final String ACTION_DOWNLOAD = "com.gh.gamecenter.DOWNLOAD";
|
||||
public static final int ICON = R.drawable.logo;
|
||||
public static final int ICON = R.mipmap.logo;
|
||||
public static final int NOTIFY_ID = 0x123;
|
||||
public static final int WAIT_NOTIFY_ID = 0x124;
|
||||
private static final String CHANNEL_ID = "Halo_Download";
|
||||
@ -69,7 +69,7 @@ public class DownloadNotification {
|
||||
}
|
||||
|
||||
final Notification notification = new NotificationCompat.Builder(context, CHANNEL_ID)
|
||||
.setSmallIcon(R.drawable.logo)
|
||||
.setSmallIcon(R.mipmap.logo)
|
||||
.setTicker(title)
|
||||
.setContentTitle(text)
|
||||
.setContentText(title)
|
||||
|
||||
@ -437,7 +437,7 @@ public class ChooseReceiverActivity extends BaseActivity implements View.OnClick
|
||||
byte[] receiveData = new byte[1024];
|
||||
byte[] sendData;
|
||||
Utils.log("=====ip::" + ipAddress);
|
||||
if (!"192.168.43.1".equals(ipAddress)) {
|
||||
if (!"logo.168.43.1".equals(ipAddress)) {
|
||||
// 连接失败,可能是连接的热点已经关闭, 关闭动画,开启扫描
|
||||
isStopScan = false;
|
||||
handler.sendEmptyMessage(0);
|
||||
|
||||
@ -39,12 +39,12 @@ public class CommentDetailActivity extends NormalActivity {
|
||||
public static Intent getCommunityArticleCommentIntent(Context context,
|
||||
String articleId,
|
||||
String articleCommentId,
|
||||
String articleCommunityId,
|
||||
String communityId,
|
||||
LinkEntity linkEntity) {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(CommentActivity.ARTICLE_ID, articleId);
|
||||
args.putString(EntranceUtils.KEY_ARTICLE_COMMENT_ID, articleCommentId);
|
||||
args.putString(CommentActivity.ARTICLE_COMMUNITY_ID, articleCommunityId);
|
||||
args.putString(CommentActivity.COMMUNITY_ID, communityId);
|
||||
args.putParcelable(EntranceUtils.KEY_LINK, linkEntity);
|
||||
return getTargetIntent(context, CommentDetailActivity.class, CommentConversationFragment.class, args);
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ public class GameDetailActivity extends NormalActivity {
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动游戏详情页面
|
||||
* 启动游戏详情页面,自动定位到评论页面
|
||||
*/
|
||||
public static void startGameDetailCommentActivity(Context context, String gameId, String entrance) {
|
||||
Bundle bundle = new Bundle();
|
||||
|
||||
@ -13,6 +13,8 @@ import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.ethanhua.skeleton.Skeleton;
|
||||
import com.ethanhua.skeleton.ViewSkeletonScreen;
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.base.OnRequestCallBackListener;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
@ -38,8 +40,6 @@ import java.util.ArrayList;
|
||||
|
||||
import butterknife.BindView;
|
||||
|
||||
import static com.gh.gamecenter.R.id.reuse_nodata_skip_tv_btn;
|
||||
import static com.gh.gamecenter.R.id.reuse_nodata_skip_tv_hint;
|
||||
import static com.gh.gamecenter.download.FileSendFragment.KC_REQUEST;
|
||||
|
||||
/**
|
||||
@ -53,14 +53,18 @@ public class InstallActivity extends BaseActivity implements InstallFragmentAdap
|
||||
RecyclerView mInstallRv;
|
||||
@BindView(R.id.reuse_nodata_skip)
|
||||
LinearLayout mNoDataSkip;
|
||||
@BindView(reuse_nodata_skip_tv_hint)
|
||||
@BindView(R.id.reuse_nodata_skip_tv_hint)
|
||||
TextView mNoDataSkipHint;
|
||||
@BindView(reuse_nodata_skip_tv_btn)
|
||||
@BindView(R.id.reuse_nodata_skip_tv_btn)
|
||||
TextView mNoDataSkipBtn;
|
||||
@BindView(R.id.list_skeleton)
|
||||
View mListSkeleton;
|
||||
|
||||
private PackageViewModel mPackageViewModel;
|
||||
private InstallFragmentAdapter mAdapter;
|
||||
|
||||
private ViewSkeletonScreen mSkeleton;
|
||||
|
||||
private boolean isEverpause = false;
|
||||
|
||||
private DataWatcher dataWatcher = new DataWatcher() {
|
||||
@ -103,6 +107,7 @@ public class InstallActivity extends BaseActivity implements InstallFragmentAdap
|
||||
super.onCreate(savedInstanceState);
|
||||
setNavigationTitle(getString(R.string.personale_mygame));
|
||||
mNoDataSkip.setVisibility(View.GONE);
|
||||
mSkeleton = Skeleton.bind(mListSkeleton).shimmer(false).load(R.layout.activity_install_skeleton).show();
|
||||
mNoDataSkipHint.setText("暂无游戏");
|
||||
mNoDataSkipBtn.setText("查看精品推荐");
|
||||
mNoDataSkipBtn.setOnClickListener(v -> {
|
||||
@ -113,12 +118,12 @@ public class InstallActivity extends BaseActivity implements InstallFragmentAdap
|
||||
mInstallRv.setLayoutManager(new LinearLayoutManager(this));
|
||||
((DefaultItemAnimator) mInstallRv.getItemAnimator()).setSupportsChangeAnimations(false);
|
||||
mAdapter = new InstallFragmentAdapter(this);
|
||||
mInstallRv.addItemDecoration(new VerticalItemDecoration(this, true));
|
||||
mInstallRv.addItemDecoration(new VerticalItemDecoration(this, 8, true));
|
||||
mInstallRv.setAdapter(mAdapter);
|
||||
|
||||
mPackageViewModel = ViewModelProviders.of(this, new PackageViewModel.Factory()).get(PackageViewModel.class);
|
||||
mPackageViewModel.getGameInstalledLiveData().observe(this,
|
||||
gameInstalls -> mAdapter.initData(PackagesManager.filterSameApk(gameInstalls)));
|
||||
gameInstalls -> mAdapter.initData(PackagesManager.filterSameApk(PackagesManager.filterDownloadBlackPackage(gameInstalls))));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -148,7 +153,7 @@ public class InstallActivity extends BaseActivity implements InstallFragmentAdap
|
||||
|
||||
@Override
|
||||
public void loadDone() {
|
||||
|
||||
mSkeleton.hide();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -163,6 +168,7 @@ public class InstallActivity extends BaseActivity implements InstallFragmentAdap
|
||||
|
||||
@Override
|
||||
public void loadEmpty() {
|
||||
mSkeleton.hide();
|
||||
mInstallRv.setVisibility(View.GONE);
|
||||
mNoDataSkip.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@ -35,6 +35,7 @@ import com.gh.gamecenter.entity.MeEntity;
|
||||
import com.gh.gamecenter.entity.UserDataLibaoEntity;
|
||||
import com.gh.gamecenter.eventbus.EBDownloadStatus;
|
||||
import com.gh.gamecenter.eventbus.EBPackage;
|
||||
import com.gh.gamecenter.eventbus.EBReuse;
|
||||
import com.gh.gamecenter.eventbus.EBUISwitch;
|
||||
import com.gh.gamecenter.retrofit.Response;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
@ -58,6 +59,7 @@ import io.reactivex.schedulers.Schedulers;
|
||||
import retrofit2.HttpException;
|
||||
|
||||
import static com.gh.gamecenter.R.id.reuse_tv_none_data;
|
||||
import static com.gh.gamecenter.personal.PersonalFragment.LOGIN_TAG;
|
||||
|
||||
/**
|
||||
* Created by khy on 2016/12/13.
|
||||
@ -312,8 +314,12 @@ public class LibaoDetailActivity extends BaseActivity implements LibaoDetailAdap
|
||||
.subscribe(new Response<LibaoEntity>() {
|
||||
@Override
|
||||
public void onResponse(LibaoEntity response) {
|
||||
mLibaoEntity = response;
|
||||
mLibaoEntity.setActive(true); // addLibaoDetail设置userData
|
||||
response.setActive(true); // addLibaoDetail设置userData
|
||||
if (mLibaoEntity != null) {
|
||||
mLibaoEntity.resetLibaoEntity(response);
|
||||
} else {
|
||||
mLibaoEntity = response;
|
||||
}
|
||||
mAdapter.setLibaoEntity(mLibaoEntity);
|
||||
mAdapter.notifyDataSetChanged();
|
||||
getGameDigest();
|
||||
@ -326,7 +332,7 @@ public class LibaoDetailActivity extends BaseActivity implements LibaoDetailAdap
|
||||
private void getLibaoStatus(String libaoId) {
|
||||
LibaoUtils.getLibaoStatus(this, libaoId, new LibaoUtils.PostLibaoListener() {
|
||||
@Override
|
||||
public void postSucced(Object response) {
|
||||
public void postSucceed(Object response) {
|
||||
List<LibaoStatusEntity> statusList = (List<LibaoStatusEntity>) response;
|
||||
|
||||
LibaoUtils.initLiBaoEntity(statusList.get(0), mLibaoEntity);
|
||||
@ -490,4 +496,11 @@ public class LibaoDetailActivity extends BaseActivity implements LibaoDetailAdap
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEventMainThread(EBReuse reuse) {
|
||||
if (reuse.getType().equals(LOGIN_TAG) && mLibaoEntity != null) { // 登入
|
||||
getLibaoDigest(mLibaoEntity.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.gh.gamecenter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Dialog;
|
||||
import android.app.NotificationManager;
|
||||
import android.arch.lifecycle.ViewModelProviders;
|
||||
@ -27,12 +28,12 @@ import android.widget.TextView;
|
||||
import com.gh.base.AppUncaughtHandler;
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.base.fragment.BaseFragment_ViewPager;
|
||||
import com.gh.common.AppExecutor;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.exposure.ExposureUtils;
|
||||
import com.gh.common.exposure.meta.MetaUtil;
|
||||
import com.gh.common.im.ImManager;
|
||||
import com.gh.common.util.ClassUtils;
|
||||
import com.gh.common.util.CommunityHelper;
|
||||
import com.gh.common.util.ConcernUtils;
|
||||
import com.gh.common.util.DataCollectionUtils;
|
||||
import com.gh.common.util.DataLogUtils;
|
||||
@ -44,10 +45,12 @@ import com.gh.common.util.DirectUtils;
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.common.util.GsonUtils;
|
||||
import com.gh.common.util.LogUtils;
|
||||
import com.gh.common.util.LunchType;
|
||||
import com.gh.common.util.MtaHelper;
|
||||
import com.gh.common.util.NetworkUtils;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.PlatformUtils;
|
||||
import com.gh.common.util.PushHelper;
|
||||
import com.gh.common.util.ThirdPartyPackageHelper;
|
||||
import com.gh.common.util.UrlFilterUtils;
|
||||
import com.gh.download.DownloadManager;
|
||||
@ -70,6 +73,7 @@ import com.gh.gamecenter.manager.UserManager;
|
||||
import com.gh.gamecenter.normal.NormalFragment;
|
||||
import com.gh.gamecenter.packagehelper.PackageViewModel;
|
||||
import com.gh.gamecenter.qa.AskFragment;
|
||||
import com.gh.gamecenter.retrofit.BiResponse;
|
||||
import com.gh.gamecenter.retrofit.Response;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
import com.gh.gamecenter.suggest.SuggestType;
|
||||
@ -90,6 +94,7 @@ import com.tencent.bugly.crashreport.CrashReport;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@ -136,7 +141,6 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
private boolean isSkipped = false;
|
||||
public static boolean isNewFirstLaunch;
|
||||
public static boolean openCommunityWithDefaultIdForTheFirsTime; // 是否根据 META-INFO 里的 JSON 自动选择默认的社区 ID
|
||||
|
||||
private Handler handler = new Handler();
|
||||
// 黄壮华 添加观察者 修改2015/8/15
|
||||
@ -260,7 +264,13 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
isNewFirstLaunch = mSp.getBoolean("isNewFirstLaunchV" + PackageUtils.getVersionName(), true);
|
||||
if (isNewFirstLaunch) {
|
||||
LogUtils.uploadDevice(DeviceTokenUtils.getLaunchType());
|
||||
final LunchType lunchType = DeviceTokenUtils.getLaunchType();
|
||||
// 延时两秒提交 APP 启动日志的,避免提交时还没获取到 GID
|
||||
AppExecutor.getUiExecutor().executeWithDelay(() -> {
|
||||
if (!this.isFinishing()) {
|
||||
LogUtils.uploadDevice(lunchType);
|
||||
}
|
||||
}, 2000L);
|
||||
getPluginUpdate();
|
||||
sendActivationInfo();
|
||||
mSp.edit().putBoolean("isNewFirstLaunchV" + PackageUtils.getVersionName(), false).apply();
|
||||
@ -306,9 +316,6 @@ public class MainActivity extends BaseActivity {
|
||||
handler.postDelayed(ImManager::attachIm, 1000);
|
||||
}
|
||||
|
||||
// 获取可用(没有被隐藏的)的社区列表
|
||||
CommunityHelper.getAvailableCommunityList();
|
||||
|
||||
if (getIntent().getBooleanExtra(SWITCH_TO_COMMUNITY, false)) {
|
||||
handler.postDelayed(this::switchToCommunityTabAndRefresh, 800);
|
||||
}
|
||||
@ -317,6 +324,10 @@ public class MainActivity extends BaseActivity {
|
||||
if (getIntent() != null && getIntent().getExtras() != null && !isSkipped) {
|
||||
doSkip();
|
||||
}
|
||||
|
||||
handler.postDelayed(() -> {
|
||||
PushHelper.postPushClickAction(this.getApplicationContext(), null);
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -336,7 +347,7 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
private void sendActivationInfo() {
|
||||
RetrofitManager.getInstance(this)
|
||||
.getApi().postBaiduActivationInfo()
|
||||
.getApi().postActivationInfo()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(new Response<>());
|
||||
}
|
||||
@ -707,7 +718,6 @@ public class MainActivity extends BaseActivity {
|
||||
InnerMetaInfoEntity info = gson.fromJson(reader, InnerMetaInfoEntity.class);
|
||||
if (info != null) {
|
||||
if (EntranceUtils.HOST_COMMUNITY.equals(info.getType())) {
|
||||
openCommunityWithDefaultIdForTheFirsTime = true;
|
||||
UserManager.getInstance().setCommunityData(new CommunityEntity(info.getLink(), info.getText()));
|
||||
runOnUiThread(() -> mMainWrapperFragment.setCurrentItem(MainWrapperFragment.INDEX_ASK));
|
||||
} else {
|
||||
@ -805,21 +815,15 @@ public class MainActivity extends BaseActivity {
|
||||
for (GameDigestEntity gameDigestEntity : response) {
|
||||
if (!TextUtils.isEmpty(gameDigestEntity.getId())) { // 关注游戏
|
||||
if (finalDownloadEntity != null && gameDigestEntity.getId().equals(finalDownloadEntity.getGameId())) {
|
||||
ConcernUtils.INSTANCE.postConcernGameId(MainActivity.this, gameDigestEntity.getId(), null, true);
|
||||
ConcernUtils.INSTANCE.postConcernGameId(MainActivity.this, gameDigestEntity.getId(), null, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 更新已安装游戏
|
||||
RetrofitManager.getInstance(MainActivity.this).getApi()
|
||||
.postPackage(UserManager.getInstance().getUserId(), packageName)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(new Response<>());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
postNewlyInstalledApp(packageName);
|
||||
}
|
||||
if ("卸载".equals(busFour.getType())) {
|
||||
mPackageViewModel.addUninstalledGame(packageName);
|
||||
@ -840,16 +844,58 @@ public class MainActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
// 更新已安装游戏
|
||||
RetrofitManager.getInstance(this).getApi()
|
||||
.deletePackage(UserManager.getInstance().getUserId(), packageName)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(new Response<>());
|
||||
deleteInstalledPackage(packageName);
|
||||
}
|
||||
|
||||
DataCollectionUtils.uploadInorunstall(this, busFour.getType(), busFour.getPackageName());
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void postNewlyInstalledApp(String packageName) {
|
||||
|
||||
JSONObject packageObject = PackageUtils.getAppBasicInfoByPackageName(packageName);
|
||||
|
||||
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"),
|
||||
packageObject.toString());
|
||||
|
||||
// 更新已安装游戏
|
||||
RetrofitManager.getInstance(MainActivity.this).getApi()
|
||||
.postNewlyInstalledApp(HaloApp.getInstance().getGid(), requestBody)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(new BiResponse<ResponseBody>() {
|
||||
@Override
|
||||
public void onSuccess(ResponseBody data) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NotNull Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void deleteInstalledPackage(String packageName) {
|
||||
// 删除已安装游戏
|
||||
RetrofitManager.getInstance(MainActivity.this).getApi()
|
||||
.deleteInstalledApp(HaloApp.getInstance().getGid(), packageName)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(new BiResponse<ResponseBody>() {
|
||||
@Override
|
||||
public void onSuccess(ResponseBody data) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NotNull Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 接收登录和登出更新事件统计的 Meta
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEventMainThread(EBReuse reuse) {
|
||||
|
||||
@ -24,6 +24,7 @@ import android.widget.TextView;
|
||||
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.base.OnRequestCallBackListener;
|
||||
import com.gh.common.history.HistoryHelper;
|
||||
import com.gh.common.util.ApkActiveUtils;
|
||||
import com.gh.common.util.CheckLoginUtils;
|
||||
import com.gh.common.util.ClickUtils;
|
||||
@ -46,6 +47,7 @@ import com.gh.gamecenter.eventbus.EBConcernChanged;
|
||||
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.newsdetail.NewsDetailAdapter;
|
||||
import com.gh.gamecenter.retrofit.Response;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
@ -66,6 +68,8 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import retrofit2.HttpException;
|
||||
|
||||
import static com.gh.gamecenter.personal.PersonalFragment.LOGIN_TAG;
|
||||
|
||||
|
||||
/**
|
||||
* 文章详情页面 要启动该页面 需要传入一下参数 放入 EssayEntity中传过来 文章 id 文章标题 title 文章发表时间 time
|
||||
@ -258,6 +262,8 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener,
|
||||
if (mNewsEntity.getType() != null) {
|
||||
setNavigationTitle(mNewsEntity.getType());
|
||||
}
|
||||
|
||||
HistoryHelper.insertNewsEntity(mNewsEntity);
|
||||
adapter.setId(mNewsEntity.getId());
|
||||
adapter.setType(mNewsEntity.getType());
|
||||
adapter.setTitle(mNewsEntity.getTitle());
|
||||
@ -418,9 +424,7 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener,
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (gameEntity != null
|
||||
&& gameEntity.getApk() != null
|
||||
&& gameEntity.getApk().size() == 1) {
|
||||
if (gameEntity != null && gameEntity.getApk().size() == 1) {
|
||||
DetailDownloadUtils.detailInitDownload(getDetailViewHolder(), true);
|
||||
}
|
||||
DownloadManager.getInstance(this).addObserver(dataWatcher);
|
||||
@ -487,6 +491,8 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener,
|
||||
|
||||
mNewsShare.setVisible(true);
|
||||
|
||||
HistoryHelper.insertNewsEntity(mNewsEntity);
|
||||
|
||||
DataUtils.onMtaEvent(NewsDetailActivity.this, "详情页面", "文章详情", response.getTitle());
|
||||
}
|
||||
|
||||
@ -650,10 +656,7 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener,
|
||||
// 接收下载被删除消息
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEvent(EBDownloadStatus status) {
|
||||
if ("delete".equals(status.getStatus())
|
||||
&& gameEntity != null
|
||||
&& gameEntity.getApk() != null
|
||||
&& gameEntity.getApk().size() == 1) {
|
||||
if ("delete".equals(status.getStatus()) && gameEntity != null && gameEntity.getApk().size() == 1) {
|
||||
String url = gameEntity.getApk().get(0).getUrl();
|
||||
if (url.equals(status.getUrl())) {
|
||||
DetailDownloadUtils.detailInitDownload(getDetailViewHolder(), false);
|
||||
@ -664,9 +667,7 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener,
|
||||
// 接受安装、卸载消息
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEventMainThread(EBPackage busFour) {
|
||||
if (gameEntity != null
|
||||
&& gameEntity.getApk() != null
|
||||
&& gameEntity.getApk().size() == 1) {
|
||||
if (gameEntity != null && gameEntity.getApk().size() == 1) {
|
||||
String packageName = gameEntity.getApk().get(0).getPackageName();
|
||||
if (packageName.equals(busFour.getPackageName())) {
|
||||
DetailDownloadUtils.detailInitDownload(getDetailViewHolder(), false);
|
||||
@ -674,4 +675,11 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener,
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEventMainThread(EBReuse reuse) {
|
||||
if (reuse.getType().equals(LOGIN_TAG) && adapter != null) { // 登入
|
||||
adapter.getNewsDetail();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -140,7 +140,7 @@ class PersonalHomeActivity : ListActivity<PersonalHistoryEntity, PersonalHomeVie
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun startTargetActivity(context: Context, userId: String?, entrance: String, path: String?) {
|
||||
fun startTargetActivity(context: Context, userId: String?, entrance: String?, path: String?) {
|
||||
if (!userId.isNullOrEmpty()) {
|
||||
val intent = Intent(context, PersonalHomeActivity::class.java)
|
||||
intent.putExtra(EntranceUtils.KEY_USER_ID, userId)
|
||||
|
||||
@ -7,6 +7,7 @@ import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.text.Editable;
|
||||
import android.text.InputFilter;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
@ -14,6 +15,7 @@ import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.common.util.DataCollectionUtils;
|
||||
@ -179,9 +181,7 @@ public class SearchActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
});
|
||||
TextHelper.limitTheLengthOfEditText(searchInput, 50, () -> {
|
||||
Utils.toast(searchInput.getContext(), "最多输入50个字");
|
||||
});
|
||||
searchInput.setFilters(new InputFilter[]{TextHelper.getFilter(50,"最多输入50个字")});
|
||||
|
||||
findViewById(R.id.btnGoBack).setOnClickListener(v -> finish());
|
||||
}
|
||||
|
||||
@ -19,7 +19,6 @@ import static com.gh.common.util.EntranceUtils.HOST_ANSWER;
|
||||
import static com.gh.common.util.EntranceUtils.HOST_ARTICLE;
|
||||
import static com.gh.common.util.EntranceUtils.HOST_COLUMN;
|
||||
import static com.gh.common.util.EntranceUtils.HOST_COMMUNITY;
|
||||
import static com.gh.common.util.EntranceUtils.HOST_COMMUNITY_ARTICLE;
|
||||
import static com.gh.common.util.EntranceUtils.HOST_DOWNLOAD;
|
||||
import static com.gh.common.util.EntranceUtils.HOST_GAME;
|
||||
import static com.gh.common.util.EntranceUtils.HOST_QUESTION;
|
||||
@ -103,7 +102,7 @@ public class SkipActivity extends BaseActivity {
|
||||
}
|
||||
startActivity(intent);
|
||||
break;
|
||||
case HOST_COMMUNITY_ARTICLE:
|
||||
case "community.article":
|
||||
DirectUtils.directToCommunityArticle(this, uri.getQueryParameter("articleId"), uri.getQueryParameter("communityId"), ENTRANCE_BROWSER);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -38,10 +38,14 @@ import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.DirectUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.common.util.GsonUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.common.util.MtaHelper;
|
||||
import com.gh.common.util.NetworkUtils;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.ShareUtils;
|
||||
import com.gh.common.util.UploadImageUtils;
|
||||
import com.gh.gamecenter.entity.ErrorEntity;
|
||||
import com.gh.gamecenter.entity.InstallGameEntity;
|
||||
import com.gh.gamecenter.entity.SettingsEntity;
|
||||
import com.gh.gamecenter.entity.SuggestionTypeEntity;
|
||||
@ -57,6 +61,7 @@ import com.halo.assistant.HaloApp;
|
||||
import com.lightgame.utils.Util_System_Keyboard;
|
||||
import com.lightgame.utils.Util_System_Phone_State;
|
||||
import com.lightgame.utils.Utils;
|
||||
import com.walkud.rom.checker.RomIdentifier;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.json.JSONArray;
|
||||
@ -67,10 +72,10 @@ import java.io.BufferedInputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -134,6 +139,10 @@ public class SuggestionActivity extends BaseActivity implements OnRequestCallBac
|
||||
TextView mPlatformEt;
|
||||
@BindView(R.id.suggest_platform_title)
|
||||
TextView mPlatformTitle;
|
||||
@BindView(R.id.suggest_link_et)
|
||||
TextView mLinkEt;
|
||||
@BindView(R.id.suggest_link_container)
|
||||
View mLinkContainer;
|
||||
|
||||
public static final int MEDIA_STORE_REQUEST = 1;
|
||||
public static final String SUGGESTION_HINT_TYPE = "SUGGESTION_HINT_TYPE";
|
||||
@ -245,10 +254,11 @@ public class SuggestionActivity extends BaseActivity implements OnRequestCallBac
|
||||
mAdTv.setVisibility(View.VISIBLE);
|
||||
mAdTv.setText(ad.getTitle());
|
||||
mAdTv.setOnClickListener(v -> {
|
||||
MtaHelper.onEvent("广告位统计", "意见反馈_功能收录", ad.getTitle());
|
||||
DirectUtils.directToLinkPage(this,
|
||||
ad.toLinkEntity(),
|
||||
"意见反馈",
|
||||
"意见反馈" + mSuggestType.getType());
|
||||
"(意见反馈-功能收录-广告位)",
|
||||
"");
|
||||
});
|
||||
}
|
||||
|
||||
@ -362,6 +372,7 @@ public class SuggestionActivity extends BaseActivity implements OnRequestCallBac
|
||||
mPlatformContainer.setVisibility(View.GONE);
|
||||
}
|
||||
} else if (type == SuggestType.gameCollect) {
|
||||
mLinkContainer.setVisibility(View.VISIBLE);
|
||||
mSuggestGameLl.setVisibility(View.VISIBLE);
|
||||
mGameNameTitle.setText(Html.fromHtml(getString(R.string.suggestion_game_name)));
|
||||
mSuggestTypeContainer.setVisibility(View.GONE);
|
||||
@ -601,7 +612,7 @@ public class SuggestionActivity extends BaseActivity implements OnRequestCallBac
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(@NotNull Map<String, String> imageUrl) {
|
||||
public void onSuccess(@NotNull LinkedHashMap<String, String> imageUrl) {
|
||||
Utils.log("意见反馈:图片上传完成");
|
||||
final JSONArray picArray = new JSONArray();
|
||||
for (String s : imageUrl.keySet()) {
|
||||
@ -633,6 +644,8 @@ public class SuggestionActivity extends BaseActivity implements OnRequestCallBac
|
||||
params.put("source", getString(R.string.app_name));
|
||||
params.put("imei", Util_System_Phone_State.getDeviceId(this));
|
||||
params.put("manufacturer", Build.MANUFACTURER);
|
||||
params.put("rom", RomIdentifier.getRom().name() + " " + RomIdentifier.getRom().getVersionName());
|
||||
params.put("link", mLinkEt.getText().toString());
|
||||
|
||||
params.put("suggestion_type", mSuggestType.getType());
|
||||
String message;
|
||||
@ -672,10 +685,7 @@ public class SuggestionActivity extends BaseActivity implements OnRequestCallBac
|
||||
}
|
||||
}
|
||||
|
||||
RequestBody body = RequestBody.create(MediaType.parse("application/json"),
|
||||
jsonObject.toString());
|
||||
|
||||
sendSuggestion(body);
|
||||
sendSuggestion(jsonObject);
|
||||
|
||||
if (CheckLoginUtils.isLogin()) {
|
||||
// 创建一条信息至七陌客服
|
||||
@ -684,8 +694,10 @@ public class SuggestionActivity extends BaseActivity implements OnRequestCallBac
|
||||
}
|
||||
}
|
||||
|
||||
private void sendSuggestion(final RequestBody body) {
|
||||
private void sendSuggestion(JSONObject jsonObject) {
|
||||
|
||||
RequestBody body = RequestBody.create(MediaType.parse("application/json"),
|
||||
jsonObject.toString());
|
||||
RetrofitManager.getInstance(this).getApi().postSuggestion(body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
@ -695,14 +707,12 @@ public class SuggestionActivity extends BaseActivity implements OnRequestCallBac
|
||||
if (postDialog != null) {
|
||||
postDialog.dismissAllowingStateLoss();
|
||||
}
|
||||
|
||||
toast("感谢您的反馈!");
|
||||
setResult(SUGGEST_TYPE_REQUEST);
|
||||
finish();
|
||||
try {
|
||||
Utils.log("sendSuggestion::onResponse->" + response.string());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
if (mHideHint.equals("APP闪退:")) {
|
||||
showKefuReportDialog();
|
||||
} else {
|
||||
toast("感谢您的反馈!");
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@ -716,15 +726,32 @@ public class SuggestionActivity extends BaseActivity implements OnRequestCallBac
|
||||
try {
|
||||
if (e != null && e.code() == 403) {
|
||||
String string = e.response().errorBody().string();
|
||||
JSONObject object = new JSONObject(string);
|
||||
int code = object.getInt("code");
|
||||
if (code == 403052) {
|
||||
ErrorEntity error = GsonUtils.fromJson(string, ErrorEntity.class);
|
||||
if (error.getCode() == 403052) {
|
||||
DialogUtils.showAlertDialog(SuggestionActivity.this, "提醒", "你已经提交过相同的反馈了"
|
||||
, "关闭提交", "返回修改", () -> {
|
||||
setResult(SUGGEST_TYPE_REQUEST);
|
||||
finish();
|
||||
}, null);
|
||||
return;
|
||||
} else if (error.getCode() == 403062) {
|
||||
DialogUtils.showAlertDialog(SuggestionActivity.this,
|
||||
"提示", "光环助手已收录游戏:" + error.getData().getGameName(),
|
||||
"退出并查看游戏", "仍然提交", () -> {
|
||||
GameDetailActivity.startGameDetailActivity(SuggestionActivity.this,
|
||||
error.getData().getGameId(), "(意见反馈-游戏收录-存在相同游戏)");
|
||||
finish();
|
||||
}, () -> {
|
||||
try {
|
||||
jsonObject.put("again", true);
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
postDialog = WaitingDialogFragment.newInstance(getString(R.string.dialog_feedback_doing));
|
||||
postDialog.show(getSupportFragmentManager(), null);
|
||||
sendSuggestion(jsonObject);
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (Exception e1) {
|
||||
@ -828,4 +855,35 @@ public class SuggestionActivity extends BaseActivity implements OnRequestCallBac
|
||||
startActivityForResult(intent, MEDIA_STORE_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
private void showKefuReportDialog() {
|
||||
// 只有是APP闪退反馈成功后弹出联系客服的弹窗
|
||||
String str = "您也可以联系客服进一步描述闪退的情况,如果您反馈的是新问题,即有机会获得红包奖励";
|
||||
DialogUtils.showWarningDialog(SuggestionActivity.this, "反馈成功", Html.fromHtml(str.substring(0, str.indexOf("红包奖励")) + "<font color='#FF0000'>红包奖励</font>"), "暂不", "联系客服",
|
||||
() -> {
|
||||
if (ShareUtils.isQQClientAvailable(this)) {
|
||||
finish();
|
||||
DirectUtils.directToQqConversation(this, "2586716223");
|
||||
} else {
|
||||
toast("本机未安装QQ应用");
|
||||
}
|
||||
},
|
||||
this::finish);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean handleBackPressed() {
|
||||
if (!TextUtils.isEmpty(mSuggestContentEt.getText().toString()) ||
|
||||
!TextUtils.isEmpty(mSuggestGameName.getText().toString()) ||
|
||||
!TextUtils.isEmpty(mLinkEt.getText().toString()) ||
|
||||
!TextUtils.isEmpty(mPlatformEt.getText().toString()) ||
|
||||
mAdapter.getFileList().size() > 0 ||
|
||||
mFunctionType != -1) {
|
||||
DialogUtils.showAlertDialog(this, "提示",
|
||||
"确定放弃反馈吗?", "继续反馈", "放弃",
|
||||
null, this::finish);
|
||||
return true;
|
||||
}
|
||||
return super.handleBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,10 +4,14 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.AppBarLayout;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
@ -15,9 +19,12 @@ import com.gc.materialdesign.views.ProgressBarCircularIndeterminate;
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.base.OnRequestCallBackListener;
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.common.util.TextHelper;
|
||||
import com.gh.common.view.VerticalItemDecoration;
|
||||
import com.gh.gamecenter.adapter.ToolBoxRvAdapter;
|
||||
import com.gh.gamecenter.suggest.SuggestType;
|
||||
import com.lightgame.utils.Util_System_Keyboard;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.OnClick;
|
||||
@ -27,8 +34,16 @@ import butterknife.OnClick;
|
||||
*/
|
||||
|
||||
public class ToolBoxActivity extends BaseActivity implements SwipeRefreshLayout.OnRefreshListener,
|
||||
ToolBoxRvAdapter.OnSearchCallBackListener, OnRequestCallBackListener {
|
||||
OnRequestCallBackListener {
|
||||
|
||||
@BindView(R.id.et_search)
|
||||
public EditText searchEt;
|
||||
@BindView(R.id.tv_search)
|
||||
public TextView searchTv;
|
||||
@BindView(R.id.tv_back)
|
||||
public TextView backTv;
|
||||
@BindView(R.id.toolbox_appbar)
|
||||
AppBarLayout mAppBar;
|
||||
@BindView(R.id.toolbox_rv)
|
||||
RecyclerView mToolboxRv;
|
||||
@BindView(R.id.reuse_none_data)
|
||||
@ -46,16 +61,10 @@ public class ToolBoxActivity extends BaseActivity implements SwipeRefreshLayout.
|
||||
private ToolBoxRvAdapter mRvAdapter;
|
||||
private ToolBoxRvAdapter mNormalRvAdapter;
|
||||
|
||||
|
||||
private boolean mIsSearch; // 记录页面状态 搜索页面/普通页面
|
||||
private String mSearchKey; // 记录搜索关键字
|
||||
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
changeAdapter(true);
|
||||
}
|
||||
};
|
||||
Runnable runnable = () -> changeAdapter(true);
|
||||
|
||||
@NonNull
|
||||
public static Intent getIntent(Context context, String entrance) {
|
||||
@ -64,7 +73,6 @@ public class ToolBoxActivity extends BaseActivity implements SwipeRefreshLayout.
|
||||
return intent;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_toolbox;
|
||||
@ -81,7 +89,7 @@ public class ToolBoxActivity extends BaseActivity implements SwipeRefreshLayout.
|
||||
|
||||
mLayoutManager = new LinearLayoutManager(this);
|
||||
mToolboxRv.setLayoutManager(mLayoutManager);
|
||||
mRvAdapter = new ToolBoxRvAdapter(this, this, ToolBoxActivity.this, mIsSearch, mSearchKey);
|
||||
mRvAdapter = new ToolBoxRvAdapter(this, this, mIsSearch, mSearchKey);
|
||||
mToolboxRv.addItemDecoration(new VerticalItemDecoration(this, 8, false));
|
||||
mToolboxRv.setAdapter(mRvAdapter);
|
||||
|
||||
@ -99,8 +107,52 @@ public class ToolBoxActivity extends BaseActivity implements SwipeRefreshLayout.
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mAppBar.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> {
|
||||
if (verticalOffset == 0) {
|
||||
mRefresh.setEnabled(true);
|
||||
} else {
|
||||
mRefresh.setEnabled(false);
|
||||
}
|
||||
int totalScrollRange = appBarLayout.getTotalScrollRange();
|
||||
if (totalScrollRange == -verticalOffset) {
|
||||
Util_System_Keyboard.hideSoftKeyboard(this);
|
||||
}
|
||||
});
|
||||
|
||||
initSearch();
|
||||
}
|
||||
|
||||
private void initSearch() {
|
||||
backTv.setOnClickListener(v -> search(false, searchEt.getText().toString()));
|
||||
|
||||
TextHelper.limitTheLengthOfEditText(searchEt, 20, () -> {
|
||||
Utils.toast(this, "最多输入20字");
|
||||
});
|
||||
|
||||
searchTv.setOnClickListener(v -> {
|
||||
if (TextUtils.isEmpty(searchEt.getText().toString())) {
|
||||
Utils.toast(this, R.string.search_hint);
|
||||
return;
|
||||
}
|
||||
search(true, searchEt.getText().toString());
|
||||
});
|
||||
|
||||
searchEt.setOnFocusChangeListener((v, hasFocus) -> {
|
||||
if (!hasFocus) {
|
||||
Util_System_Keyboard.hideSoftKeyboard(this, searchEt);
|
||||
}
|
||||
});
|
||||
|
||||
searchEt.setOnEditorActionListener((v, actionId, event) -> {
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
|
||||
searchTv.performClick();
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@OnClick({R.id.reuse_no_connection, R.id.reuse_none_data})
|
||||
public void onClick(View view) {
|
||||
if (view.getId() == R.id.reuse_no_connection) {
|
||||
@ -113,7 +165,6 @@ public class ToolBoxActivity extends BaseActivity implements SwipeRefreshLayout.
|
||||
SuggestionActivity.startSuggestionActivity(this, SuggestType.functionSuggest, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -122,7 +173,6 @@ public class ToolBoxActivity extends BaseActivity implements SwipeRefreshLayout.
|
||||
mNoneData.setVisibility(View.GONE);
|
||||
mNoConnection.setVisibility(View.GONE);
|
||||
mLoading.setVisibility(View.GONE);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -156,7 +206,6 @@ public class ToolBoxActivity extends BaseActivity implements SwipeRefreshLayout.
|
||||
mRefresh.postDelayed(runnable, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void search(boolean isSearch, String searchKey) {
|
||||
if (mNoneData.getVisibility() == View.VISIBLE) {
|
||||
mNoneData.setVisibility(View.GONE);
|
||||
@ -171,15 +220,26 @@ public class ToolBoxActivity extends BaseActivity implements SwipeRefreshLayout.
|
||||
|
||||
private void changeAdapter(boolean isRefresh) {
|
||||
if (mIsSearch) {
|
||||
mRvAdapter = new ToolBoxRvAdapter(this, this, this, mIsSearch, mSearchKey);
|
||||
mRvAdapter = new ToolBoxRvAdapter(this, this, mIsSearch, mSearchKey);
|
||||
} else {
|
||||
if (mNormalRvAdapter != null && !isRefresh) {
|
||||
mRvAdapter = mNormalRvAdapter;
|
||||
} else {
|
||||
mRvAdapter = new ToolBoxRvAdapter(this, this, this, mIsSearch, null);
|
||||
mRvAdapter = new ToolBoxRvAdapter(this, this, mIsSearch, null);
|
||||
mNormalRvAdapter = mRvAdapter;
|
||||
}
|
||||
}
|
||||
mToolboxRv.setAdapter(mRvAdapter);
|
||||
|
||||
if (mSearchKey != null) {
|
||||
searchEt.setText(mSearchKey);
|
||||
searchEt.setSelection(searchEt.getText().length());
|
||||
}
|
||||
|
||||
if (mIsSearch) {
|
||||
backTv.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
backTv.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ public class CleanApkAdapter extends BaseRecyclerAdapter<KcSelectGameViewHolder>
|
||||
appInfo.sourceDir = apk_path;
|
||||
appInfo.publicSourceDir = apk_path;
|
||||
Drawable apk_icon = appInfo.loadIcon(pm);
|
||||
apkEntity.setGameBm(BitmapUtils.drawableToBitmap(apk_icon));
|
||||
apkEntity.setGameBm(BitmapUtils.drawableToBitmap(apk_icon, true));
|
||||
/** apk的绝对路劲 */
|
||||
apkEntity.setGamePath(apk_path);
|
||||
/** apk的版本名称 String */
|
||||
|
||||
@ -75,17 +75,21 @@ public class ImagePagerAdapter extends RecyclingPagerAdapter {
|
||||
|
||||
view.setOnClickListener(v -> {
|
||||
|
||||
int size = mSlideEntityList.size();
|
||||
|
||||
if (size == 0) return;
|
||||
|
||||
// 首页轮播图数据统计
|
||||
DataLogUtils.uploadLunbotuLog(mContext, slideEntity.getType(),
|
||||
slideEntity.getText(), String.valueOf(getPosition(position) % mSlideEntityList.size() + 1));
|
||||
slideEntity.getText(), String.valueOf(getPosition(position) % size + 1));
|
||||
|
||||
String entrance = StringUtils.buildString("(游戏-专题:滚动图["
|
||||
, slideEntity.getText()
|
||||
, "=", slideEntity.getType()
|
||||
, "=", String.valueOf(getPosition(position) + 1)
|
||||
, "=", String.valueOf(size + 1)
|
||||
, "])");
|
||||
|
||||
DataUtils.onMtaEvent(mContext, "轮播图", mSource, String.valueOf(getPosition(position) % mSlideEntityList.size() + 1));
|
||||
DataUtils.onMtaEvent(mContext, "轮播图", mSource, String.valueOf(getPosition(position) % size + 1));
|
||||
|
||||
DirectUtils.directToLinkPage(mContext, slideEntity, entrance, "首页游戏");
|
||||
|
||||
|
||||
@ -201,8 +201,9 @@ public class InstallFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
if (this.gameList.size() != 0) {
|
||||
isRemove = true;
|
||||
notifyDataSetChanged();
|
||||
|
||||
initLocationMap();
|
||||
|
||||
mActivity.loadDone();
|
||||
} else {
|
||||
mActivity.loadEmpty();
|
||||
}
|
||||
@ -313,7 +314,7 @@ public class InstallFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
name = String.format("%s - %s", gameEntity.getName(),
|
||||
PlatformUtils.getInstance(mContext).getPlatformName(gameEntity.getApk().get(0).getPlatform()));
|
||||
holder.gameThumb.setImageDrawable(PackageUtils.getIconByPackage(mContext, gameEntity.getApk().get(0).getPackageName()));
|
||||
holder.gameDes.setText(String.format("V%s", PackageUtils.getVersionByPackage(mContext, gameEntity.getApk().get(0).getPackageName())));
|
||||
holder.gameDes.setText(String.format("V%s", PackageUtils.getVersionByPackage(gameEntity.getApk().get(0).getPackageName())));
|
||||
} else {
|
||||
name = gameEntity.getName();
|
||||
ImageUtils.display(holder.gameThumb, gameEntity.getIcon());
|
||||
@ -407,7 +408,7 @@ public class InstallFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
File file = new File(installedPackage.applicationInfo.sourceDir);
|
||||
fileInfo.setSize(file.length());
|
||||
Drawable drawable = installedPackage.applicationInfo.loadIcon(pm);
|
||||
fileInfo.setBitmap(BitmapUtils.drawableToBitmap(drawable));
|
||||
fileInfo.setBitmap(BitmapUtils.drawableToBitmap(drawable, true));
|
||||
fileInfo.setFileTag(String.valueOf(System.currentTimeMillis()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ public class KcSelectGameAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
installGameEntity.setGamePath(installedPackage.applicationInfo.sourceDir);
|
||||
try {
|
||||
Drawable drawable = installedPackage.applicationInfo.loadIcon(pm);
|
||||
installGameEntity.setGameBm(BitmapUtils.drawableToBitmap(drawable));
|
||||
installGameEntity.setGameBm(BitmapUtils.drawableToBitmap(drawable, true));
|
||||
|
||||
installGameEntity.setGameVersion(installedPackage.versionName);
|
||||
installGameEntity.setGameName(installedPackage.applicationInfo.loadLabel(pm).toString());
|
||||
|
||||
@ -245,7 +245,7 @@ public class LibaoDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
if (TextUtils.isEmpty(status)) {
|
||||
LibaoUtils.getLibaoStatus(mContext, mLibaoEntity.getId(), new LibaoUtils.PostLibaoListener() {
|
||||
@Override
|
||||
public void postSucced(Object response) {
|
||||
public void postSucceed(Object response) {
|
||||
List<LibaoStatusEntity> statusList = (List<LibaoStatusEntity>) response;
|
||||
if (statusList.size() != 0) {
|
||||
mLibaoEntity.setStatus(statusList.get(0).getStatus());
|
||||
|
||||
@ -20,6 +20,7 @@ import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.common.util.NewsUtils;
|
||||
import com.gh.common.util.NumberUtils;
|
||||
import com.gh.common.util.StringUtils;
|
||||
import com.gh.common.util.TimestampUtils;
|
||||
import com.gh.gamecenter.NewsDetailActivity;
|
||||
@ -247,14 +248,10 @@ public class MessageDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
private void initNewsDigestViewHolder(final NewsDigestViewHolder viewHolder) {
|
||||
|
||||
if (mConcernEntity.getViews() != 0) {
|
||||
viewHolder.readNum.setText(String.valueOf(mConcernEntity.getViews()));
|
||||
viewHolder.readNum.setText(NumberUtils.transSimpleCount(mConcernEntity.getViews()));
|
||||
}
|
||||
|
||||
if (mConcernEntity.getCommentnum() > 999) {
|
||||
viewHolder.commentnum.setText(R.string.thousand);
|
||||
} else {
|
||||
viewHolder.commentnum.setText(String.valueOf(mConcernEntity.getCommentnum()));
|
||||
}
|
||||
viewHolder.commentnum.setText(NumberUtils.transSimpleCount(mConcernEntity.getCommentnum()));
|
||||
|
||||
if (mConcernEntity.getBrief() != null) {
|
||||
viewHolder.content.setText(Html.fromHtml(mConcernEntity.getBrief()));
|
||||
|
||||
@ -314,7 +314,8 @@ public class PlatformAdapter extends BaseRecyclerAdapter<PlatformViewHolder> {
|
||||
|| status.equals(DownloadStatus.timeout)
|
||||
|| status.equals(DownloadStatus.neterror)
|
||||
|| status.equals(DownloadStatus.downloading)
|
||||
|| status.equals(DownloadStatus.waiting)) {
|
||||
|| status.equals(DownloadStatus.waiting)
|
||||
|| status.equals(DownloadStatus.overflow)) {
|
||||
viewHolder.mDownloadItemTvStatus.setText(R.string.downloading);
|
||||
} else if (status.equals(DownloadStatus.done)) {
|
||||
viewHolder.mDownloadItemTvStatus.setText(R.string.install);
|
||||
|
||||
@ -3,12 +3,8 @@ package com.gh.gamecenter.adapter;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.base.OnRequestCallBackListener;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
@ -19,16 +15,12 @@ import com.gh.gamecenter.SuggestionActivity;
|
||||
import com.gh.gamecenter.WebActivity;
|
||||
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
|
||||
import com.gh.gamecenter.adapter.viewholder.ReuseViewHolder;
|
||||
import com.gh.gamecenter.adapter.viewholder.SearchViewHolder;
|
||||
import com.gh.gamecenter.adapter.viewholder.ToolBoxViewHolder;
|
||||
import com.gh.gamecenter.entity.ToolBoxEntity;
|
||||
import com.gh.gamecenter.manager.UserManager;
|
||||
import com.gh.gamecenter.retrofit.Response;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
import com.gh.gamecenter.suggest.SuggestType;
|
||||
import com.lightgame.adapter.BaseRecyclerAdapter;
|
||||
import com.lightgame.utils.Util_System_Keyboard;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -47,29 +39,23 @@ import static com.gh.gamecenter.R.string.loading;
|
||||
public class ToolBoxRvAdapter extends BaseRecyclerAdapter {
|
||||
|
||||
private OnRequestCallBackListener mCallBackListener;
|
||||
private OnSearchCallBackListener mSearchListener;
|
||||
|
||||
private List<ToolBoxEntity> mEntityList;
|
||||
|
||||
private String mSearchKey;
|
||||
private String mToken;
|
||||
|
||||
// private boolean mLoadConcernDataOver;
|
||||
private boolean mIsSearch;
|
||||
private boolean mIsLoading;
|
||||
private boolean mIsOver;
|
||||
private boolean mIsNetworkError;
|
||||
private int mPage;
|
||||
|
||||
public ToolBoxRvAdapter(Context context, OnRequestCallBackListener listener, OnSearchCallBackListener searchListener,
|
||||
boolean isSearch, String key) {
|
||||
public ToolBoxRvAdapter(Context context, OnRequestCallBackListener listener, boolean isSearch, String key) {
|
||||
super(context);
|
||||
this.mIsSearch = isSearch;
|
||||
this.mSearchKey = key;
|
||||
mPage = 1;
|
||||
|
||||
mToken = UserManager.getInstance().getToken();
|
||||
mSearchListener = searchListener;
|
||||
mCallBackListener = listener;
|
||||
mEntityList = new ArrayList<>();
|
||||
loadData();
|
||||
@ -121,31 +107,9 @@ public class ToolBoxRvAdapter extends BaseRecyclerAdapter {
|
||||
});
|
||||
}
|
||||
|
||||
// 去除重复数据(普通列表排除关注数据)
|
||||
private static List<ToolBoxEntity> removeDuplicateData(List<ToolBoxEntity> sourceList, List<ToolBoxEntity> rawList) {
|
||||
if (sourceList == null || sourceList.isEmpty()
|
||||
|| rawList == null || rawList.isEmpty()) {
|
||||
return rawList;
|
||||
}
|
||||
String id;
|
||||
for (int i = 0; i < rawList.size(); i++) {
|
||||
id = rawList.get(i).getId();
|
||||
for (ToolBoxEntity toolBoxEntity : sourceList) {
|
||||
if (id.equals(toolBoxEntity.getId())) {
|
||||
rawList.remove(i);
|
||||
i--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return rawList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (position == 0) {
|
||||
return 0;
|
||||
} else if (position == 1) {
|
||||
return 1;
|
||||
} else if (position == getItemCount() - 1) {
|
||||
return 2;
|
||||
@ -156,10 +120,7 @@ public class ToolBoxRvAdapter extends BaseRecyclerAdapter {
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
if (viewType == 0) {
|
||||
View view = mLayoutInflater.inflate(R.layout.layout_search_bar, parent, false);
|
||||
return new SearchViewHolder(view);
|
||||
} else if (viewType == 2) {
|
||||
if (viewType == 2) {
|
||||
View view = mLayoutInflater.inflate(R.layout.refresh_footerview, parent, false);
|
||||
return new FooterViewHolder(view);
|
||||
} else if (viewType == 1) {
|
||||
@ -176,83 +137,26 @@ public class ToolBoxRvAdapter extends BaseRecyclerAdapter {
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
if (holder instanceof ToolBoxViewHolder) {
|
||||
ToolBoxViewHolder viewHolder = (ToolBoxViewHolder) holder;
|
||||
ToolBoxEntity toolBoxEntity = mEntityList.get(position - 2);
|
||||
ToolBoxEntity toolBoxEntity = mEntityList.get(position - 1);
|
||||
initToolBoxViewHolder(viewHolder, toolBoxEntity);
|
||||
} else if (holder instanceof FooterViewHolder) {
|
||||
FooterViewHolder viewHolder = (FooterViewHolder) holder;
|
||||
initFooterViewHolder(viewHolder);
|
||||
} else if (holder instanceof SearchViewHolder) {
|
||||
SearchViewHolder viewHolder = (SearchViewHolder) holder;
|
||||
initSearchViewHolder(viewHolder);
|
||||
} else if (holder instanceof ReuseViewHolder) {
|
||||
holder.itemView.setOnClickListener(v -> SuggestionActivity.startSuggestionActivity(mContext, SuggestType.functionSuggest, null, null));
|
||||
holder.itemView.setOnClickListener(v -> SuggestionActivity.startSuggestionActivity(mContext, SuggestType.normal, null, null));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (mEntityList.size() > 0) {
|
||||
return mEntityList.size() + 3;
|
||||
return mEntityList.size() + 2;
|
||||
} else {
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void initSearchViewHolder(final SearchViewHolder viewHolder) {
|
||||
|
||||
if (mSearchKey != null) {
|
||||
viewHolder.searchEt.setText(mSearchKey);
|
||||
}
|
||||
|
||||
if (mIsSearch) {
|
||||
viewHolder.backTv.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
viewHolder.backTv.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
viewHolder.backTv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mSearchListener.search(false, viewHolder.searchEt.getText().toString());
|
||||
}
|
||||
});
|
||||
|
||||
viewHolder.searchTv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
if (TextUtils.isEmpty(viewHolder.searchEt.getText().toString())) {
|
||||
Utils.toast(mContext, R.string.search_hint);
|
||||
return;
|
||||
}
|
||||
mSearchListener.search(true, viewHolder.searchEt.getText().toString());
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
viewHolder.searchEt.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
if (!hasFocus) {
|
||||
Util_System_Keyboard.hideSoftKeyboard(mContext, viewHolder.searchEt);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
viewHolder.searchEt.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
@Override
|
||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
|
||||
viewHolder.searchTv.performClick();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void initFooterViewHolder(FooterViewHolder viewHolder) {
|
||||
viewHolder.initItemPadding();
|
||||
if (mIsNetworkError) {
|
||||
@ -261,12 +165,7 @@ public class ToolBoxRvAdapter extends BaseRecyclerAdapter {
|
||||
viewHolder.loading.setVisibility(View.GONE);
|
||||
viewHolder.hint.setText(R.string.loading_failed_retry);
|
||||
viewHolder.itemView.setClickable(true);
|
||||
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
loadData();
|
||||
}
|
||||
});
|
||||
viewHolder.itemView.setOnClickListener(v -> loadData());
|
||||
} else if (mIsOver) {
|
||||
viewHolder.lineLeft.setVisibility(View.VISIBLE);
|
||||
viewHolder.lineRight.setVisibility(View.VISIBLE);
|
||||
@ -287,26 +186,19 @@ public class ToolBoxRvAdapter extends BaseRecyclerAdapter {
|
||||
viewHolder.mTitle.setText(toolBoxEntity.getName());
|
||||
ImageUtils.display(viewHolder.mGameThumb, toolBoxEntity.getIcon());
|
||||
|
||||
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String url = toolBoxEntity.getUrl();
|
||||
viewHolder.itemView.setOnClickListener(v -> {
|
||||
String url = toolBoxEntity.getUrl();
|
||||
// http://www.ghzs666.com/article/59291e7ce9a64a496cfd6897.html
|
||||
if (url != null && url.contains(URL_ARTICLE)) {
|
||||
String newsId = url.substring(url.lastIndexOf("/") + 1, url.length() - 5); // 5: ".html"
|
||||
Intent intent = NewsDetailActivity.getIntentById(mContext, newsId, "工具箱列表");
|
||||
mContext.startActivity(intent);
|
||||
} else {
|
||||
mContext.startActivity(WebActivity.getWebByCollectionTools(mContext, toolBoxEntity, false));
|
||||
}
|
||||
if (url != null && url.contains(URL_ARTICLE)) {
|
||||
String newsId = url.substring(url.lastIndexOf("/") + 1, url.length() - 5); // 5: ".html"
|
||||
Intent intent = NewsDetailActivity.getIntentById(mContext, newsId, "工具箱列表");
|
||||
mContext.startActivity(intent);
|
||||
} else {
|
||||
mContext.startActivity(WebActivity.getWebByCollectionTools(mContext, toolBoxEntity, false));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public int dataSize() {
|
||||
return mEntityList.size();
|
||||
}
|
||||
|
||||
public boolean isOver() {
|
||||
return mIsOver;
|
||||
}
|
||||
@ -318,8 +210,4 @@ public class ToolBoxRvAdapter extends BaseRecyclerAdapter {
|
||||
public boolean isNetworkError() {
|
||||
return mIsNetworkError;
|
||||
}
|
||||
|
||||
public interface OnSearchCallBackListener {
|
||||
void search(boolean isSearch, String searchKey);
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,8 +8,6 @@ import android.widget.TextView;
|
||||
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.entity.SubjectEntity;
|
||||
|
||||
import butterknife.BindView;
|
||||
|
||||
@ -49,84 +47,4 @@ public class GameTestViewHolder extends GameViewHolder {
|
||||
kaifuBottom = (TextView) itemView.findViewById(R.id.home2_game_kaifu_bottom);
|
||||
|
||||
}
|
||||
|
||||
// public void initGameTestViewHolder(Context context, GameFragmentAdapter adapter, List<SubjectEntity> subjectList,
|
||||
// List<GameEntity> pluginList, int position,
|
||||
// final OnGameTestItemClickListener onGameTestItemClickListener) {
|
||||
// int offset = 1;
|
||||
// if (!pluginList.isEmpty()) {
|
||||
// offset += 1;
|
||||
// }
|
||||
// for (int i = 0, size = subjectList.size(); i < size; i++) {
|
||||
// if (position > offset && position <= subjectList.get(i).getData().size() + offset) {
|
||||
// final GameEntity gameEntity = subjectList.get(i).getData().get(position - offset - 1);
|
||||
// if (gameEntity.getTest() != null) {
|
||||
// int order = position - offset - 1;
|
||||
// if (subjectList.get(i).getData().get(0).getImage() != null) {
|
||||
// order--;
|
||||
// }
|
||||
// final SubjectEntity subjectEntity = subjectList.get(i);
|
||||
// if (subjectEntity.isOrder()) {
|
||||
// gameOrder.setVisibility(View.VISIBLE);
|
||||
// gameOrder.setText(String.valueOf(order + 1));
|
||||
// } else {
|
||||
// gameOrder.setVisibility(View.GONE);
|
||||
// }
|
||||
//
|
||||
// ImageUtils.Companion.display(gameThumb, gameEntity.getIcon());
|
||||
// gameName.setText(gameEntity.getName());
|
||||
// if (gameEntity.getApk() == null || gameEntity.getApk().isEmpty()) {
|
||||
// gameDes.setText(gameEntity.getBrief());
|
||||
// } else {
|
||||
// gameDes.setText(String.format("%s %s", gameEntity.getApk().get(0).getSize(), gameEntity.getBrief()));
|
||||
// }
|
||||
//
|
||||
// String type = gameEntity.getTest().getType();
|
||||
// KaiFuUtils.setKaiFuType(gameTestType, type);
|
||||
//
|
||||
// if (gameEntity.getTest().getStart() == 0) {
|
||||
// gameTestTime.setVisibility(View.GONE);
|
||||
// } else {
|
||||
// gameTestTime.setText(GameViewUtils.getGameTestDate(gameEntity.getTest().getStart()));
|
||||
// }
|
||||
//
|
||||
// final int finalI = i;
|
||||
// itemView.setOnClickListener(new OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// if (onGameTestItemClickListener != null) {
|
||||
// onGameTestItemClickListener.onClick(gameEntity, subjectEntity, finalI);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// if (gameEntity.getTest().getEnd() != 0) {
|
||||
// long endTime = Long.valueOf(gameEntity.getTest().getEnd() + "000");
|
||||
// long todayTime = new Date().getTime();
|
||||
// if (todayTime > endTime) {
|
||||
// // 测试时间已过
|
||||
// gameEntity.setApk(null);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// DownloadItemUtils.setOnClickListener(context,
|
||||
// gameDownloadBtn, gameEntity, i, adapter,
|
||||
// StringUtils.buildString("(游戏-专题:",
|
||||
// subjectEntity.getName(), "-列表[", String.valueOf(i + 1), "])"),
|
||||
// StringUtils.buildString("游戏-专题-",
|
||||
// subjectEntity.getName(), ":", gameEntity.getName()));
|
||||
//
|
||||
// DownloadItemUtils.updateItem(context, gameEntity, this, true);
|
||||
//// adapter.initGameTest(this, gameEntity, order, subjectEntity);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// offset = subjectList.get(i).getData().size() + offset + 1;
|
||||
// }
|
||||
// }
|
||||
|
||||
public interface OnGameTestItemClickListener {
|
||||
void onClick(GameEntity gameEntity, SubjectEntity subjectEntity, int position);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
package com.gh.gamecenter.adapter.viewholder
|
||||
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import com.gh.base.BaseRecyclerViewHolder
|
||||
import com.gh.gamecenter.R
|
||||
import kotterknife.bindView
|
||||
|
||||
class ListSectionItemViewHolder(view: View) : BaseRecyclerViewHolder<Any>(view) {
|
||||
val sectionTitle by bindView<TextView>(R.id.list_section_title)
|
||||
}
|
||||
@ -23,6 +23,7 @@ import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Single;
|
||||
|
||||
public abstract class ListActivity<T, VM extends BaseListViewModel /* 该泛型位置对应getViewModelClass */>
|
||||
extends BaseActivity
|
||||
@ -144,6 +145,11 @@ public abstract class ListActivity<T, VM extends BaseListViewModel /* 该泛型
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Single<List> provideDataSingle(int page) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void onLoadRefresh() {
|
||||
mReuseNoConn.setVisibility(View.GONE);
|
||||
mReuseNoData.setVisibility(View.GONE);
|
||||
|
||||
@ -24,6 +24,7 @@ import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Single;
|
||||
|
||||
/**
|
||||
* Created by khy on 2/12/17.
|
||||
@ -32,7 +33,7 @@ import io.reactivex.Observable;
|
||||
public abstract class ListFragment<T, VM extends BaseListViewModel /* 该泛型位置对应getViewModelClass */> extends NormalFragment implements
|
||||
Observer<List<T>>,
|
||||
SwipeRefreshLayout.OnRefreshListener,
|
||||
OnDataObservable {
|
||||
OnDataObservable<T> {
|
||||
|
||||
@BindView(R.id.list_rv)
|
||||
protected RecyclerView mListRv;
|
||||
@ -161,6 +162,11 @@ public abstract class ListFragment<T, VM extends BaseListViewModel /* 该泛型
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Single<List<T>> provideDataSingle(int page) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void onLoadRefresh() {
|
||||
mReuseNoConn.setVisibility(View.GONE);
|
||||
mReuseNoData.setVisibility(View.GONE);
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.gh.gamecenter.baselist;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Application;
|
||||
import android.arch.lifecycle.MutableLiveData;
|
||||
import android.support.annotation.NonNull;
|
||||
@ -7,13 +8,17 @@ import android.support.annotation.NonNull;
|
||||
import com.gh.common.util.ApkActiveUtils;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.retrofit.BiResponse;
|
||||
import com.gh.gamecenter.retrofit.Response;
|
||||
import com.halo.assistant.HaloApp;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import retrofit2.HttpException;
|
||||
@ -42,14 +47,16 @@ public abstract class ListViewModel<LD /*ListData*/, ID /*ItemData*/> extends Ba
|
||||
mOverLimitSize = mCurLoadParams.getLoadSize() / 2;
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
protected void loadData() {
|
||||
if (mCurLoadParams == null) initLoadParams();
|
||||
|
||||
LoadParams loadParams = mRetryParams != null ? mRetryParams : mCurLoadParams;
|
||||
Observable<List<LD>> listObservable = provideDataObservable(loadParams.getLoadOffset());
|
||||
Single<List<LD>> listSingle = provideDataSingle(loadParams.getLoadOffset());
|
||||
LoadStatus curStatus = mLoadStatusLiveData.getValue();
|
||||
|
||||
if (listObservable == null || curStatus != null &&
|
||||
if ((listObservable == null && listSingle == null) || curStatus != null &&
|
||||
curStatus != LoadStatus.INIT_LOADED &&
|
||||
curStatus != LoadStatus.LIST_LOADED &&
|
||||
curStatus != LoadStatus.INIT) return;
|
||||
@ -60,43 +67,86 @@ public abstract class ListViewModel<LD /*ListData*/, ID /*ItemData*/> extends Ba
|
||||
mLoadStatusLiveData.setValue(LoadStatus.LIST_LOADING);
|
||||
}
|
||||
|
||||
listObservable
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Response<List<LD>>() {
|
||||
@Override
|
||||
public void onResponse(List<LD> response) {
|
||||
List<LD> previousData = mListLiveData.getValue();
|
||||
if (previousData == null || mCurLoadParams.getLoadOffset() == LoadParams.DEFAULT_OFFSET ||
|
||||
curStatus == LoadStatus.INIT) {
|
||||
previousData = new ArrayList<>();
|
||||
if (listObservable != null) {
|
||||
listObservable
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.map(this::filterData)
|
||||
.subscribe(new Response<List<LD>>() {
|
||||
@Override
|
||||
public void onResponse(List<LD> response) {
|
||||
List<LD> previousData = mListLiveData.getValue();
|
||||
if (previousData == null || mCurLoadParams.getLoadOffset() == LoadParams.DEFAULT_OFFSET ||
|
||||
curStatus == LoadStatus.INIT) {
|
||||
previousData = new ArrayList<>();
|
||||
}
|
||||
|
||||
// 针对游戏的一些操作(过滤隐藏APK,增加下载数据)
|
||||
if (response.size() > 0 && response.get(0) instanceof GameEntity) {
|
||||
for (LD entity : response) {
|
||||
GameEntity game = (GameEntity) entity;
|
||||
game.setEntryMap(DownloadManager.getInstance(HaloApp.getInstance()
|
||||
.getApplication()).getEntryMap(game.getName()));
|
||||
ApkActiveUtils.filterHideApk(game);
|
||||
}
|
||||
}
|
||||
|
||||
previousData.addAll(response);
|
||||
mListLiveData.postValue(previousData);
|
||||
loadStatusControl(response.size());
|
||||
}
|
||||
|
||||
// 针对游戏的一些操作(过滤隐藏APK,增加下载数据)
|
||||
if (response.size() > 0 && response.get(0) instanceof GameEntity) {
|
||||
for (LD entity : response) {
|
||||
GameEntity game = (GameEntity) entity;
|
||||
game.setEntryMap(DownloadManager.getInstance(HaloApp.getInstance()
|
||||
.getApplication()).getEntryMap(game.getName()));
|
||||
ApkActiveUtils.filterHideApk(game);
|
||||
@Override
|
||||
public void onFailure(HttpException e) {
|
||||
if (e != null && e.code() == 404) {
|
||||
loadStatusControl(0);
|
||||
} else {
|
||||
loadStatusControl(REQUEST_FAILURE_SIZE);
|
||||
mLoadExceptionLiveData.postValue(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if (listSingle != null) {
|
||||
listSingle.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.map(this::filterData)
|
||||
.subscribe(new BiResponse<List<LD>>() {
|
||||
@Override
|
||||
public void onFailure(@NotNull Exception exception) {
|
||||
if (exception instanceof HttpException && ((HttpException) exception).code() == 404) {
|
||||
loadStatusControl(0);
|
||||
} else {
|
||||
loadStatusControl(REQUEST_FAILURE_SIZE);
|
||||
if (exception instanceof HttpException) {
|
||||
mLoadExceptionLiveData.postValue((HttpException) exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
previousData.addAll(response);
|
||||
mListLiveData.postValue(previousData);
|
||||
loadStatusControl(response.size());
|
||||
}
|
||||
@Override
|
||||
public void onSuccess(List<LD> response) {
|
||||
List<LD> previousData = mListLiveData.getValue();
|
||||
if (previousData == null || mCurLoadParams.getLoadOffset() == LoadParams.DEFAULT_OFFSET ||
|
||||
curStatus == LoadStatus.INIT) {
|
||||
previousData = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(HttpException e) {
|
||||
if (e != null && e.code() == 404) {
|
||||
loadStatusControl(0);
|
||||
} else {
|
||||
loadStatusControl(REQUEST_FAILURE_SIZE);
|
||||
mLoadExceptionLiveData.postValue(e);
|
||||
// 针对游戏的一些操作(过滤隐藏APK,增加下载数据)
|
||||
if (response.size() > 0 && response.get(0) instanceof GameEntity) {
|
||||
for (LD entity : response) {
|
||||
GameEntity game = (GameEntity) entity;
|
||||
game.setEntryMap(DownloadManager.getInstance(HaloApp.getInstance()
|
||||
.getApplication()).getEntryMap(game.getName()));
|
||||
ApkActiveUtils.filterHideApk(game);
|
||||
}
|
||||
}
|
||||
|
||||
previousData.addAll(response);
|
||||
mListLiveData.postValue(previousData);
|
||||
loadStatusControl(response.size());
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected void loadStatusControl(int size) {
|
||||
@ -147,9 +197,18 @@ public abstract class ListViewModel<LD /*ListData*/, ID /*ItemData*/> extends Ba
|
||||
loadData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Single<List<LD>> provideDataSingle(int page) {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected abstract void mergeResultLiveData();
|
||||
|
||||
public MutableLiveData<HttpException> getLoadExceptionLiveData() {
|
||||
return mLoadExceptionLiveData;
|
||||
}
|
||||
|
||||
protected List<LD> filterData(@NonNull List<LD> list) {
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import android.support.annotation.NonNull;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Single;
|
||||
|
||||
/**
|
||||
* Created by khy on 21/03/18.
|
||||
@ -15,6 +16,7 @@ import io.reactivex.Observable;
|
||||
|
||||
public class NormalListViewModel<T> extends ListViewModel<T, T> {
|
||||
|
||||
// TODO 作为构造函数从外部传入会引起内存泄漏,当 View 被销毁时,这个类的实例还会持有原有 View 的引用
|
||||
private OnDataObservable mDataObservable;
|
||||
|
||||
public NormalListViewModel(@NonNull Application application, OnDataObservable dataObservable) {
|
||||
@ -34,6 +36,11 @@ public class NormalListViewModel<T> extends ListViewModel<T, T> {
|
||||
return mDataObservable.provideDataObservable(offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Single<List<T>> provideDataSingle(int page) {
|
||||
return mDataObservable.provideDataSingle(page);
|
||||
}
|
||||
|
||||
public static class Factory extends ViewModelProvider.NewInstanceFactory {
|
||||
@NonNull
|
||||
private final Application mApplication;
|
||||
|
||||
@ -3,6 +3,7 @@ package com.gh.gamecenter.baselist;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Single;
|
||||
|
||||
|
||||
/**
|
||||
@ -11,4 +12,8 @@ import io.reactivex.Observable;
|
||||
|
||||
public interface OnDataObservable<T> {
|
||||
Observable<List<T>> provideDataObservable(int page);
|
||||
|
||||
// 一般的网络请求只有成功或失败两种情况,并不会有 onNext 所以主流是使用 single ,
|
||||
// 譬如 room 的 rxjava 支持就只支持 single 不支持 observable 所以这里增加了个 single 来供那些既兼容网络数据又兼容 room 数据的页面
|
||||
Single<List<T>> provideDataSingle(int page);
|
||||
}
|
||||
|
||||
@ -13,9 +13,12 @@ import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.baselist.ListAdapter
|
||||
import com.gh.gamecenter.databinding.ItemCategoryBinding
|
||||
import com.gh.gamecenter.entity.CategoryEntity
|
||||
import net.cachapa.expandablelayout.ExpandableLayout
|
||||
|
||||
class CategoryDirectoryAdapter(context: Context, var categoryTitle: String) : ListAdapter<CategoryEntity>(context) {
|
||||
class CategoryDirectoryAdapter(context: Context, var categoryTitle: String)
|
||||
: ListAdapter<CategoryEntity>(context) {
|
||||
|
||||
var recyclerView: RecyclerView? = null
|
||||
var expandStatusMap: HashMap<Int, Boolean> = HashMap()
|
||||
|
||||
private var sixteenDp: Int = 0
|
||||
@ -39,13 +42,19 @@ class CategoryDirectoryAdapter(context: Context, var categoryTitle: String) : Li
|
||||
expandableStatusMap = expandStatusMap,
|
||||
isExpended = expandStatusMap[position] != null && expandStatusMap[position] == true,
|
||||
marginTop = sixteenDp,
|
||||
categoryTitle = categoryTitle)
|
||||
categoryTitle = categoryTitle,
|
||||
expandedAction = { recyclerView?.smoothScrollToPosition(position) })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal class CategoryViewHolder(var binding: ItemCategoryBinding) : RecyclerView.ViewHolder(binding.root) {
|
||||
fun bindCategory(category: CategoryEntity, expandableStatusMap: HashMap<Int, Boolean>, isExpended: Boolean, marginTop: Int, categoryTitle: String) {
|
||||
fun bindCategory(category: CategoryEntity,
|
||||
expandableStatusMap: HashMap<Int, Boolean>,
|
||||
isExpended: Boolean,
|
||||
marginTop: Int,
|
||||
categoryTitle: String,
|
||||
expandedAction: () -> Unit) {
|
||||
category.data?.let {
|
||||
var subCategoryView: SubCategoryView? = null
|
||||
|
||||
@ -91,13 +100,14 @@ class CategoryDirectoryAdapter(context: Context, var categoryTitle: String) : Li
|
||||
binding.containerExpandable.setExpanded(isExpended, false)
|
||||
binding.containerExpandable.setOnExpansionUpdateListener { _, state ->
|
||||
when (state) {
|
||||
0 -> {
|
||||
ExpandableLayout.State.COLLAPSED -> {
|
||||
binding.ivToggle.setImageResource(R.drawable.ic_category_arrow_down)
|
||||
expandableStatusMap[adapterPosition] = false
|
||||
}
|
||||
3 -> {
|
||||
ExpandableLayout.State.EXPANDED -> {
|
||||
binding.ivToggle.setImageResource(R.drawable.ic_category_arrow_up)
|
||||
expandableStatusMap[adapterPosition] = true
|
||||
expandedAction.invoke()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user