Compare commits
403 Commits
molistar_r
...
molistar/1
Author | SHA1 | Date | |
---|---|---|---|
![]() |
e26d548515 | ||
![]() |
539be23e47 | ||
![]() |
dcafb35e24 | ||
![]() |
8fa429aca6 | ||
![]() |
f08b6d4577 | ||
![]() |
3ea7aecd5c | ||
![]() |
178f4e24ef | ||
![]() |
e2861459fb | ||
![]() |
d704a44106 | ||
![]() |
da81a4e905 | ||
![]() |
6c081d9a38 | ||
![]() |
37d897035f | ||
![]() |
cea25c7497 | ||
![]() |
47d2bfd145 | ||
![]() |
047e1454bd | ||
![]() |
714d5baec6 | ||
![]() |
b20ee8064c | ||
![]() |
711135ae90 | ||
![]() |
ecf42e368e | ||
![]() |
205e1180e7 | ||
![]() |
bc48cc86a9 | ||
![]() |
e7b73a2961 | ||
![]() |
5070e21d16 | ||
![]() |
049006aa8b | ||
![]() |
86b498c00e | ||
![]() |
6df95cf11f | ||
![]() |
3b407c0bd6 | ||
![]() |
83af08076a | ||
![]() |
cdc1c51fec | ||
![]() |
a8191616a3 | ||
![]() |
410832690f | ||
![]() |
b1d2f0515b | ||
![]() |
82c2d8c25d | ||
![]() |
549088c99e | ||
![]() |
5910e7c5fd | ||
![]() |
53aed7599a | ||
![]() |
8aebb7c2c2 | ||
![]() |
3a120bf5f0 | ||
![]() |
2a0d8f06fa | ||
![]() |
495bae0d00 | ||
![]() |
2af7cec8dd | ||
![]() |
e9e4da8d60 | ||
![]() |
14c1805a2b | ||
![]() |
066fc4056b | ||
![]() |
f8ad0d3961 | ||
![]() |
0d974866c8 | ||
![]() |
b4f3c4f3e3 | ||
![]() |
f74b744f56 | ||
![]() |
b8f73ec0d5 | ||
![]() |
3ff80994f1 | ||
![]() |
c1426b39c4 | ||
![]() |
3b28974919 | ||
![]() |
63a28bc142 | ||
![]() |
729d626006 | ||
![]() |
a407268be1 | ||
![]() |
f4808e8acf | ||
![]() |
3e49dae43b | ||
![]() |
35d53ccdb2 | ||
![]() |
2a20d75ffd | ||
![]() |
5f157d8454 | ||
![]() |
5fbee068dc | ||
![]() |
046c7d66cd | ||
![]() |
accf4562b1 | ||
![]() |
5b90524144 | ||
![]() |
1284a6e8a2 | ||
![]() |
afdf3093a1 | ||
![]() |
843a37ed97 | ||
![]() |
f99c6d8b37 | ||
![]() |
7add521040 | ||
![]() |
b673f5603f | ||
![]() |
a4f9559ad9 | ||
![]() |
3226109442 | ||
![]() |
3c60225e35 | ||
![]() |
0a70c6a478 | ||
![]() |
16a8f9a52a | ||
![]() |
2a1983aa46 | ||
![]() |
eb187ebc56 | ||
![]() |
f4ef62d2d6 | ||
![]() |
49a10d9f40 | ||
![]() |
42b47fcb64 | ||
![]() |
709b0b0274 | ||
![]() |
b6d59b5986 | ||
![]() |
ef80b15f27 | ||
![]() |
c14d376a1a | ||
![]() |
7f8cd70d99 | ||
![]() |
d2a686f572 | ||
![]() |
693a14d6cf | ||
![]() |
cf078ebc5b | ||
![]() |
408fe443f4 | ||
![]() |
442bd1f238 | ||
![]() |
4eed4c0cfb | ||
![]() |
bf3ea4b437 | ||
![]() |
f161a8e96b | ||
![]() |
574f290004 | ||
![]() |
a46b5b4f32 | ||
![]() |
936dd2f8e8 | ||
![]() |
9d0b6e3a9f | ||
![]() |
14fa576814 | ||
![]() |
9d14936d9c | ||
![]() |
3dec68b1fc | ||
![]() |
3c75f0e86a | ||
![]() |
0caee6e191 | ||
![]() |
b9f87b4984 | ||
![]() |
2b22fb3d4c | ||
![]() |
d80128f217 | ||
![]() |
57a7bee15d | ||
![]() |
677eb4327b | ||
![]() |
d8815a23e7 | ||
![]() |
a7faa20321 | ||
![]() |
612bd50545 | ||
![]() |
3187bc0d37 | ||
![]() |
48d2bc88b8 | ||
![]() |
168c0eab09 | ||
![]() |
d1fc37aa24 | ||
![]() |
94cebe457a | ||
![]() |
6e8f69d273 | ||
![]() |
80d852114c | ||
![]() |
634adc5f19 | ||
![]() |
3408f444aa | ||
![]() |
95f65558a4 | ||
![]() |
fbb7d20f3d | ||
![]() |
12edababcd | ||
![]() |
97949c4828 | ||
![]() |
78fa5751a6 | ||
![]() |
a6798cf35d | ||
![]() |
89940edd58 | ||
![]() |
fb202c1c73 | ||
![]() |
840a1243aa | ||
![]() |
2019411763 | ||
![]() |
e0e07c718a | ||
![]() |
02595f81f7 | ||
![]() |
95d0527fc9 | ||
![]() |
bc3426c574 | ||
![]() |
a2976dbc74 | ||
![]() |
e942696e14 | ||
![]() |
7c3dee48ae | ||
![]() |
eabb3a5bd3 | ||
![]() |
fbc76a0bd3 | ||
![]() |
d044756bd7 | ||
![]() |
8ad993bb6b | ||
![]() |
f325df4ed0 | ||
![]() |
19cbd94e98 | ||
![]() |
85b9ce903f | ||
![]() |
408ec3f811 | ||
![]() |
cafeee5305 | ||
![]() |
818acaee8f | ||
![]() |
e72423708e | ||
![]() |
5ba98cdb9e | ||
![]() |
13d87309e1 | ||
![]() |
dc5d160086 | ||
![]() |
7dca9a1ed5 | ||
![]() |
fc2c2433aa | ||
![]() |
7aeb80599d | ||
![]() |
53b7bb87f1 | ||
![]() |
994f0900a7 | ||
![]() |
764227edcd | ||
![]() |
640d59d4f5 | ||
![]() |
11bc8068bd | ||
![]() |
bc8f1a6660 | ||
![]() |
93fc9d2fef | ||
![]() |
2d9c152bd6 | ||
![]() |
0e3d9695f9 | ||
![]() |
1acbead001 | ||
![]() |
b25276875b | ||
![]() |
6de2f68106 | ||
![]() |
7ff35b1a50 | ||
![]() |
0c4df905e3 | ||
![]() |
aa0baeccf1 | ||
![]() |
8a66c4bdb8 | ||
![]() |
5c262c93c9 | ||
![]() |
2b0e52ac20 | ||
![]() |
d2d738f618 | ||
![]() |
cdbb895a68 | ||
![]() |
a6f5b24a6d | ||
![]() |
126215949f | ||
![]() |
92a0e4b408 | ||
![]() |
5be8ebde3a | ||
![]() |
2396eb9089 | ||
![]() |
65ef4810e3 | ||
![]() |
c72af689e5 | ||
![]() |
c8f83b4ad8 | ||
![]() |
088756891e | ||
![]() |
e2ad02e8a6 | ||
![]() |
8f4fd9bf7e | ||
![]() |
e998245340 | ||
![]() |
ac212c4949 | ||
![]() |
115d0d3a01 | ||
![]() |
2aef4076ef | ||
![]() |
ded1072961 | ||
![]() |
37eaf9d08d | ||
![]() |
17a56f4c65 | ||
![]() |
89b381bfbc | ||
![]() |
58f1002b4e | ||
![]() |
8475180048 | ||
![]() |
4903a3f9a8 | ||
![]() |
6b6e72ff25 | ||
![]() |
9d96b25208 | ||
![]() |
494628918d | ||
![]() |
6229ba57be | ||
![]() |
cab7e3542e | ||
![]() |
a62278ed30 | ||
![]() |
3d707b19db | ||
![]() |
21d982246c | ||
![]() |
21f0a84904 | ||
![]() |
92070af5e8 | ||
![]() |
6ca5589efc | ||
![]() |
d472d671ba | ||
![]() |
9a7c41b6b2 | ||
![]() |
d3b3ce8be2 | ||
![]() |
812061a601 | ||
![]() |
c666c39769 | ||
![]() |
1b09c46bfc | ||
![]() |
37b91c22cb | ||
![]() |
e500d7a01f | ||
![]() |
cab220d917 | ||
![]() |
70040c5ee1 | ||
![]() |
7576b30ae7 | ||
![]() |
dc1ae42fa1 | ||
![]() |
42c82e1c0b | ||
![]() |
70d0049477 | ||
![]() |
0eeb9cd105 | ||
![]() |
e5b2e3f5e7 | ||
![]() |
a7076f7bc8 | ||
![]() |
54c07468d5 | ||
![]() |
8135142287 | ||
![]() |
5a067ec0fd | ||
![]() |
e377a51094 | ||
![]() |
01093d39c5 | ||
![]() |
e386c0cf58 | ||
![]() |
fffb78a9f6 | ||
![]() |
209ebabd34 | ||
![]() |
5697be0ba9 | ||
![]() |
de6d892df5 | ||
![]() |
f21e14ca5b | ||
![]() |
c4c03edc5f | ||
![]() |
72863b8bde | ||
![]() |
9be483de4b | ||
![]() |
bf3098d5c3 | ||
![]() |
94f33e2fa7 | ||
![]() |
a54b7967c9 | ||
![]() |
bd00bb7e91 | ||
![]() |
a86950f80a | ||
![]() |
ca8f581c69 | ||
![]() |
7c8685d652 | ||
![]() |
89065de00f | ||
![]() |
338bedb0e0 | ||
![]() |
6635167a30 | ||
![]() |
7c23f5e24b | ||
![]() |
d51aba4908 | ||
![]() |
2a3aa0a77e | ||
![]() |
ff25fd4ded | ||
![]() |
d7be587078 | ||
![]() |
9f7187e7ae | ||
![]() |
7f38169684 | ||
![]() |
3bc264cccb | ||
![]() |
912ef11d1b | ||
![]() |
62679db186 | ||
![]() |
ea92c08ca1 | ||
![]() |
9ae80b839b | ||
![]() |
01f3418f43 | ||
![]() |
5e634b1fda | ||
![]() |
32ac09ef60 | ||
![]() |
ae4dea2ab0 | ||
![]() |
f76582b1f6 | ||
![]() |
f121ef5ad1 | ||
![]() |
a7a04c2950 | ||
![]() |
af0ba80b30 | ||
![]() |
c986a2dce6 | ||
![]() |
376fbdaeb2 | ||
![]() |
7fd10e1222 | ||
![]() |
edb8c962cd | ||
![]() |
378ea3802d | ||
![]() |
04f434531c | ||
![]() |
a18b0d3f4d | ||
![]() |
58c298bbd6 | ||
![]() |
35bc665f03 | ||
![]() |
414a248418 | ||
![]() |
22b45993e4 | ||
![]() |
2af211457b | ||
![]() |
29a62a034d | ||
![]() |
a2980914e8 | ||
![]() |
920b159820 | ||
![]() |
6e37bd9c68 | ||
![]() |
1d399777b1 | ||
![]() |
3626d5708a | ||
![]() |
ebd9ddd8de | ||
![]() |
20497cb2b7 | ||
![]() |
61bb91920d | ||
![]() |
6a30060bf9 | ||
![]() |
76abafe1cc | ||
![]() |
6256151928 | ||
![]() |
3d59e7f244 | ||
![]() |
66f8a527f9 | ||
![]() |
57d0852d14 | ||
![]() |
38b0af2f35 | ||
![]() |
062c2ee0a9 | ||
![]() |
4ff5ca40e3 | ||
![]() |
ad543ccbbc | ||
![]() |
2d8f3939ee | ||
![]() |
e43b3348bf | ||
![]() |
8f552d6663 | ||
![]() |
a7c528fff1 | ||
![]() |
afc1d5ef69 | ||
![]() |
4a3c8cbdac | ||
![]() |
1c9c084c3e | ||
![]() |
39cd73b021 | ||
![]() |
f6e5017fbb | ||
![]() |
8562768556 | ||
![]() |
7d6f0c360b | ||
![]() |
e635f69b1f | ||
![]() |
66e9a1442e | ||
![]() |
30036526bd | ||
![]() |
de71c445c1 | ||
![]() |
088d27c51c | ||
![]() |
42007aa075 | ||
![]() |
bc441a8ac2 | ||
![]() |
5b9ada0902 | ||
![]() |
5f441aa8eb | ||
![]() |
9e8a95c1d6 | ||
![]() |
ac14be2c88 | ||
![]() |
e334c7ce16 | ||
![]() |
32b0fba6fb | ||
![]() |
d9a39877f1 | ||
![]() |
681bd8bca9 | ||
![]() |
fc62f8cd28 | ||
![]() |
696dc32234 | ||
![]() |
99e85366b3 | ||
![]() |
70785fdf47 | ||
![]() |
b353105ca2 | ||
![]() |
62dc2e3c9d | ||
![]() |
9c63c56488 | ||
![]() |
d3b16529e1 | ||
![]() |
d73770cfe2 | ||
![]() |
191990426a | ||
![]() |
87052c52c1 | ||
![]() |
568a42799d | ||
![]() |
c0663e4aa8 | ||
![]() |
a8e7634920 | ||
![]() |
8d292ccac0 | ||
![]() |
b81f0c0808 | ||
![]() |
b354931ed2 | ||
![]() |
f538dde6da | ||
![]() |
a37ff5d9b8 | ||
![]() |
f675e3e085 | ||
![]() |
63553473bf | ||
![]() |
15f8ae439b | ||
![]() |
f73b56726a | ||
![]() |
cbca06b03d | ||
![]() |
9b0168f614 | ||
![]() |
70b9e5cbdd | ||
![]() |
f95f8fb0f5 | ||
![]() |
8b90c472e3 | ||
![]() |
c924a2b2ac | ||
![]() |
e7d2c0cf75 | ||
![]() |
5946726d0b | ||
![]() |
ca266841ac | ||
![]() |
5c9ad5b2fb | ||
![]() |
68e6d2aa15 | ||
![]() |
fcecc29add | ||
![]() |
81ba536dba | ||
![]() |
3bf1af2c0b | ||
![]() |
48de4c765b | ||
![]() |
eb6fb9b2da | ||
![]() |
5cf07b86b3 | ||
![]() |
0fce835c0c | ||
![]() |
dcbd5aae25 | ||
![]() |
b5541afc5d | ||
![]() |
25e0c29dbc | ||
![]() |
46c6ee3e99 | ||
![]() |
6277322ebe | ||
![]() |
a8bc86b5aa | ||
![]() |
291f85c310 | ||
![]() |
26ea3dbfd5 | ||
![]() |
14a70f29c8 | ||
![]() |
96174fbfeb | ||
![]() |
492b5f7263 | ||
![]() |
408afcebcb | ||
![]() |
18904e853e | ||
![]() |
61ac515cf9 | ||
![]() |
c47281401e | ||
![]() |
58abce7456 | ||
![]() |
fdd6f1836f | ||
![]() |
5928151853 | ||
![]() |
c4cc6153df | ||
![]() |
ecdeee3e76 | ||
![]() |
a39a11343c | ||
![]() |
c5d0b80f1b | ||
![]() |
520efa04f8 | ||
![]() |
5b1b469316 | ||
![]() |
7ce3990728 | ||
![]() |
542e12a88b | ||
![]() |
7373093946 | ||
![]() |
792b140f0f | ||
![]() |
c64d74aa7d | ||
![]() |
73f24839d4 | ||
![]() |
9a532c5c3f | ||
![]() |
1b74aa08ce | ||
![]() |
831d219f36 | ||
![]() |
6858130a7e | ||
![]() |
db9077fbbc | ||
![]() |
e67ab3c1b3 | ||
![]() |
df0b246062 | ||
![]() |
bf133e5dc6 |
@@ -20,11 +20,11 @@ android {
|
||||
|
||||
flavorDimensions 'default'
|
||||
buildConfigField "boolean", "ISOLATION_MODE", "$isolationMode"
|
||||
resConfigs "en"
|
||||
resConfigs "en", "zh-rTW", "ar"
|
||||
if (isolationMode) {
|
||||
resValue "string", "app_name", "Mo-debug"
|
||||
resValue "string", "app_launch_name", "Mo-debug"
|
||||
} else {
|
||||
resValue "string", "app_name", "Molistar"
|
||||
resValue "string", "app_launch_name", "MoliStar"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ android {
|
||||
if (abi == null) {
|
||||
abi = "universal"
|
||||
}
|
||||
outputFileName = "Molistar_${buildType.name}_v${defaultConfig.versionName}_${abi}_${date}.apk"
|
||||
outputFileName = "MoliStar_${buildType.name}_v${defaultConfig.versionName}_${abi}_${date}.apk"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,6 +114,10 @@ android {
|
||||
'src/module_bank_card/java',
|
||||
'src/module_super_admin/java',
|
||||
'src/module_album/java',
|
||||
'src/module_treasure_box/java',
|
||||
'src/module_public_chat/java',
|
||||
'src/module_game/java',
|
||||
'src/module_community/java',
|
||||
|
||||
]
|
||||
|
||||
@@ -127,6 +131,10 @@ android {
|
||||
'src/module_bank_card/res',
|
||||
'src/module_super_admin/res',
|
||||
'src/module_album/res',
|
||||
'src/module_treasure_box/res',
|
||||
'src/module_public_chat/res',
|
||||
'src/module_game/res',
|
||||
'src/module_community/res',
|
||||
|
||||
]
|
||||
|
||||
@@ -135,7 +143,7 @@ android {
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
def server_url_debug = '"http://api.molistar.xyz/"'
|
||||
def server_url_debug = '"http://beta.api.molistar.xyz/"'
|
||||
def server_url_release = '"https://api.molistar.xyz/"'
|
||||
|
||||
debug {
|
||||
@@ -213,7 +221,6 @@ dependencies {
|
||||
api "com.jzxiang.pickerview:TimePickerDialog:1.0.1"
|
||||
api "com.github.zyyoona7:EasyPopup:1.0.2"
|
||||
api "com.github.donkingliang:LabelsView:1.6.5"
|
||||
api "com.github.yyued:SVGAPlayer-Android:2.6.1"
|
||||
api "com.ms-square:expandableTextView:0.1.4"
|
||||
annotationProcessor 'androidx.annotation:annotation:1.6.0'
|
||||
|
||||
@@ -274,7 +281,7 @@ channel {
|
||||
//多渠道包的输出目录,默认为new File(project.buildDir,"channel")
|
||||
outputDir = new File(project.buildDir, "channelapk")
|
||||
//多渠道包的命名规则,默认为:${appName}-${versionName}-${versionCode}-${flavorName}-${buildType}-${buildTime}
|
||||
apkNameFormat = 'Molistar-${buildType}-${flavorName}-v${versionName}-${buildTime}'
|
||||
apkNameFormat = 'MoliStar-${buildType}-${flavorName}-v${versionName}-${buildTime}'
|
||||
//快速模式:生成渠道包时不进行校验(速度可以提升10倍以上,默认为false)
|
||||
fastMode = false
|
||||
//buildTime的时间格式,默认格式:yyyyMMdd-HHmmss
|
||||
@@ -287,9 +294,28 @@ aabResGuard {
|
||||
mappingFile = file("aab-res-guard-mapping.txt").toPath() // Mapping file used for incremental obfuscation
|
||||
whiteList = [ // White list rules
|
||||
"*.R.raw.*",
|
||||
"*.R.drawable.icon"
|
||||
"*.R.drawable.icon",
|
||||
// SUD游戏-start
|
||||
"*.R.drawable.fsm_*",
|
||||
"*.R.string.fsm_*",
|
||||
"*.R.layout.fsm_*",
|
||||
"*.R.color.fsm_*",
|
||||
"*.R.id.fsm_*",
|
||||
"*.R.style.fsm_*",
|
||||
"*.R.dimen.fsm_*",
|
||||
"*.R.array.fsm_*",
|
||||
"*.R.integer.fsm_*",
|
||||
"*.R.bool.fsm_*",
|
||||
"*.R.mipmap.fsm_*",
|
||||
"*.R.styleable.fsm_*",
|
||||
"*.R.id.*loading*",
|
||||
"*.R.id.container_progress",
|
||||
"*.R.id.reload_btn",
|
||||
"*.R.id.unitySurfaceView",
|
||||
"*.R.string.game_view_content_description"
|
||||
// SUD游戏-end
|
||||
]
|
||||
obfuscatedBundleFileName = "duplicated-app.aab" // Obfuscated file name, must end with '.aab'
|
||||
obfuscatedBundleFileName = "MoliStar-app.aab" // Obfuscated file name, must end with '.aab'
|
||||
mergeDuplicatedRes = true // Whether to allow the merge of duplicate resources
|
||||
enableFilterFiles = false // Whether to allow filter files
|
||||
filterList = [ // file filter rules
|
||||
@@ -299,7 +325,7 @@ aabResGuard {
|
||||
|
||||
enableFilterStrings = false // switch of filter strings
|
||||
unusedStringPath = file("unused.txt").toPath() // strings will be filtered in this file
|
||||
languageWhiteList = ["en", "zh"] // keep en,en-xx,zh,zh-xx etc. remove others.
|
||||
languageWhiteList = ["en", "zh", "ar", "zh-rTW"] // keep en,en-xx,zh,zh-xx etc. remove others.
|
||||
}
|
||||
|
||||
//以下均为非必须
|
||||
@@ -312,6 +338,58 @@ xmlClassGuard {
|
||||
"com.chwl.core": "com.hhchu.core",
|
||||
"com.chwl.library": "com.hhchu.library"]
|
||||
moveDir = [
|
||||
"com.chwl.app.community.dynamic" : "ffefcef.ddbccaec",
|
||||
"com.chwl.app.community.helper" : "eaeecbea.ccefdeaf",
|
||||
"com.chwl.app.community.holder" : "aafebee.febeeba",
|
||||
"com.chwl.app.community.im" : "eedadfa.cccedea",
|
||||
"com.chwl.app.community.publish" : "ddae.cfdb",
|
||||
"com.chwl.app.community.square" : "bddfb.eedde",
|
||||
"com.chwl.app.community.user_dynamic" : "ddcdbcbc.acbfcfba",
|
||||
"com.chwl.app.community.utils" : "cceaf.cbdcdb",
|
||||
"com.chwl.app.community.widget" : "bdfaa.beeefc",
|
||||
"com.chwl.app.community" : "cadfd.aeddb",
|
||||
"com.chwl.app.avroom.headline" : "eefce.eecad",
|
||||
"com.chwl.core.bean.game" : "caeccd.fdedac",
|
||||
"com.chwl.core.bean.room" : "afceec.aaafbc",
|
||||
"com.chwl.app.game" : "fcbfeb.ebfceac",
|
||||
"com.chwl.core.sud" : "baecf.deccfc",
|
||||
"com.chwl.library.download" : "aeacf.cecdd",
|
||||
"com.chwl.app.pay.activity" : "abbe.faaca",
|
||||
"com.chwl.app.pay.adapter" : "daddd.dcadd",
|
||||
"com.chwl.app.pay.fragment" : "fceff.acfcf",
|
||||
"com.chwl.app.pay.interfaces" : "eaadf.dbeecd",
|
||||
"com.chwl.app.pay.password" : "ebcfe.adfea",
|
||||
"com.chwl.app.pay.widget" : "fbfb.caeb",
|
||||
"com.chwl.app.avroom.online" : "bfbdecb.fafffbbc",
|
||||
"com.chwl.app.avroom.game" : "bbecfa.babcfd",
|
||||
"com.chwl.app.ui.webview.baishun" : "caebbec.bfcfbdf",
|
||||
"com.chwl.core.public_chat_hall.model" : "aada.dceaa",
|
||||
"com.chwl.app.avroom.rank" : "edadcb.beeaca",
|
||||
"com.chwl.app.fansteam" : "eabdedaed.cfeadaacfe",
|
||||
"com.chwl.core.fansteam" : "adbfd.adeecd",
|
||||
"com.chwl.app.public_chat.core.viewholder" : "fffa.accee",
|
||||
"com.chwl.app.public_chat.core" : "fcbdcbf.afaafbac",
|
||||
"com.chwl.app.public_chat.ui.message.headline" : "dfcfcad.cbcfdcf",
|
||||
"com.chwl.app.public_chat.ui.message" : "afdf.affbd",
|
||||
"com.chwl.library.language" : "faceb.abded",
|
||||
"com.chwl.app.ui.invite" : "cfdd.baac",
|
||||
"com.chwl.app.ui.link" : "fdb.ddbd",
|
||||
"com.chwl.app.ui.language" : "cffafe.edafba",
|
||||
"com.chwl.core.file.cos" : "cccdbdcce.eccffeccb",
|
||||
"com.chwl.app.notify.views" : "fbbdbcaa.dbfaeadb",
|
||||
"com.chwl.app.notify" : "eaafaa.edeeef",
|
||||
"com.chwl.app.support.float" : "eadbfff.eccceee",
|
||||
"com.chwl.app.avroom.gameplay" : "dfcf.dbdcb",
|
||||
"com.chwl.app.treasure_box.activity" : "fdbac.cdfab",
|
||||
"com.chwl.app.treasure_box.adapter" : "febab.bdfcb",
|
||||
"com.chwl.app.treasure_box.fragment" : "ecbbc.baaada",
|
||||
"com.chwl.app.treasure_box.module" : "aecae.aeacf",
|
||||
"com.chwl.app.treasure_box.presenter" : "ddaaee.bacbdcb",
|
||||
"com.chwl.app.treasure_box.widget" : "bedacc.bbbceb",
|
||||
"com.chwl.app.treasure_box" : "afccebdddd.ecdedbfcea",
|
||||
"com.chwl.core.treasure_box.bean" : "eeaaaa.bbedeee",
|
||||
"com.chwl.core.treasure_box.event" : "dfbfa.edacdb",
|
||||
"com.chwl.core.treasure_box.model" : "abdf.ebeab",
|
||||
"com.example.lib_utils.spannable" : "babdfb.baacfc",
|
||||
"com.example.lib_utils.log" : "cade.bebee",
|
||||
"com.example.lib_utils.ktx" : "aedbdf.cbfffd",
|
||||
|
2
app/proguard-rules.pro
vendored
2
app/proguard-rules.pro
vendored
@@ -482,7 +482,7 @@
|
||||
-keep public class com.alibaba.android.arouter.routes.**{*;}
|
||||
-keep public class com.alibaba.android.arouter.facade.**{*;}
|
||||
-keep class * implements com.alibaba.android.arouter.facade.template.ISyringe{*;}
|
||||
|
||||
-keep class tech.sud.mgp.SudMGPWrapper.** {*;}
|
||||
|
||||
#new after proguard
|
||||
-dontwarn bdcb.eedb.**
|
||||
|
@@ -82,12 +82,13 @@
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<!-- 对于 Android 12.0 及以上设备,还需要添加如下权限: -->
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
||||
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_REMOTE_MESSAGING" />
|
||||
<application
|
||||
android:name=".application.App"
|
||||
android:allowBackup="false"
|
||||
android:icon="@mipmap/app_logo"
|
||||
android:label="@string/app_name"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_launch_name"
|
||||
android:largeHeap="true"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:resizeableActivity="true"
|
||||
@@ -127,6 +128,24 @@
|
||||
<!-- </intent-filter>-->
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".ui.link.LinkActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTop"
|
||||
android:theme="@style/transparent_activity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data
|
||||
android:host="app"
|
||||
android:scheme="molistar" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<!-- <meta-data-->
|
||||
<!-- android:name="firebase_crashlytics_collection_enabled"-->
|
||||
<!-- android:value="${CRASHLYTICS_COLLECTION_ENABLED}" /> <!– 刘海屏适配 begin –>-->
|
||||
@@ -223,7 +242,7 @@
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||
android:label="Molistar"
|
||||
android:label="MoliStar"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustPan|stateAlwaysHidden" /> <!-- 配置的service和receiver -->
|
||||
@@ -247,6 +266,12 @@
|
||||
android:name=".avroom.activity.RoomSettingActivity"
|
||||
android:label="@string/main_androidmanifest_07"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".avroom.activity.RoomTypeSwitchActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".avroom.activity.RoomBgSettingActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".avroom.activity.RoomManagerListActivity"
|
||||
android:label="@string/main_androidmanifest_08"
|
||||
@@ -299,6 +324,9 @@
|
||||
android:name=".ui.pay.ChargeActivity"
|
||||
android:label="@string/main_androidmanifest_018"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".ui.wallet.WalletActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".home.activity.CollectionRoomActivity"
|
||||
android:label="@string/main_androidmanifest_019"
|
||||
@@ -448,6 +476,15 @@
|
||||
android:name=".team.view.UpdateTeamNameActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
<activity
|
||||
android:name=".treasure_box.activity.TreasureBoxActivity"
|
||||
android:theme="@style/transparent_activity" />
|
||||
<activity
|
||||
android:name=".treasure_box.activity.BoxRankingActivity"
|
||||
android:theme="@style/room_message_activity" />
|
||||
<activity
|
||||
android:name=".treasure_box.activity.TreasureBoxHonourActivity"
|
||||
android:theme="@style/dialog_web_view_activity" />
|
||||
<activity android:name=".ui.setting.VerifyPhoneActivity" />
|
||||
<activity android:name=".ui.setting.ModifyPwdActivity" />
|
||||
<activity
|
||||
@@ -639,7 +676,16 @@
|
||||
<activity
|
||||
android:name=".ui.webview.DialogWebViewActivity"
|
||||
android:theme="@style/dialog_web_view_activity"
|
||||
android:windowSoftInputMode="adjustPan" /> <!-- 隐私政策 -->
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".ui.webview.baishun.BaiShunGameWebActivity"
|
||||
android:theme="@style/dialog_web_view_activity"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".ui.webview.room_banner.RoomWebDialogActivity"
|
||||
android:theme="@style/room_dialog_web_view_activity"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<!-- 隐私政策 -->
|
||||
<activity
|
||||
android:name=".ui.webview.DatingRuleWebViewActivity"
|
||||
android:theme="@style/dialog_web_view_activity" />
|
||||
@@ -831,21 +877,86 @@
|
||||
|
||||
<service
|
||||
android:name="com.netease.nimlib.service.NimService"
|
||||
android:foregroundServiceType="remoteMessaging"
|
||||
android:process=":core" />
|
||||
<service
|
||||
android:name="com.netease.nimlib.service.NimService$Aux"
|
||||
android:foregroundServiceType="remoteMessaging"
|
||||
android:process=":core" />
|
||||
<service
|
||||
android:name="com.netease.nimlib.job.NIMJobService"
|
||||
android:foregroundServiceType="remoteMessaging"
|
||||
android:permission="android.permission.BIND_JOB_SERVICE"
|
||||
android:process=":core" />
|
||||
<service android:name="com.netease.nimlib.service.ResponseService" />
|
||||
<service android:name="com.netease.nimlib.service.ResponseService"
|
||||
android:foregroundServiceType="remoteMessaging"/>
|
||||
<service
|
||||
android:name=".service.DaemonService"
|
||||
android:foregroundServiceType="mediaPlayback"
|
||||
android:enabled="true" />
|
||||
|
||||
<activity android:name=".avroom.room_album.RoomAlbumActivity" />
|
||||
|
||||
<activity android:name=".ui.language.LanguageActivity" />
|
||||
|
||||
<activity android:name=".public_chat.ui.message.PublicChatRoomMessageActivity"
|
||||
android:configChanges="keyboardHidden|orientation"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
|
||||
<activity
|
||||
android:name=".fansteam.FansTeamJoinActivity"
|
||||
android:theme="@style/dialog_web_view_activity" />
|
||||
<activity
|
||||
android:name=".fansteam.FansTeamJoinedActivity"
|
||||
android:theme="@style/dialog_web_view_activity" />
|
||||
<activity
|
||||
android:name=".fansteam.FansTeamListActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".decoration.view.DecorationStoreActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
<activity
|
||||
android:name=".pay.activity.GiveGoldActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
<activity
|
||||
android:name=".pay.activity.GiveGoldDetailActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
<activity
|
||||
android:name=".pay.activity.GiveGoldToUserActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".pay.activity.GiveGoldSearchActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
<activity
|
||||
android:name=".game.ui.game.GameActivity"
|
||||
android:hardwareAccelerated="true"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".community.dynamic.view.DynamicDetailActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".community.publish.view.PublishActivity"
|
||||
android:launchMode="singleTop"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateHidden|adjustNothing" />
|
||||
<activity
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
android:name=".ui.feedback.FeedbackActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity android:name=".ui.debug.DebugActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
<activity android:name=".ui.game_team.record.GameTeamRecordActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
</application>
|
||||
|
||||
</manifest>
|
BIN
app/src/main/assets/svga/bubble_tran_bg.svga
Normal file
BIN
app/src/main/assets/svga/bubble_tran_bg.svga
Normal file
Binary file not shown.
BIN
app/src/main/assets/svga/gold_box_bg.svga
Normal file
BIN
app/src/main/assets/svga/gold_box_bg.svga
Normal file
Binary file not shown.
BIN
app/src/main/assets/svga/home_pk.svga
Normal file
BIN
app/src/main/assets/svga/home_pk.svga
Normal file
Binary file not shown.
Binary file not shown.
BIN
app/src/main/assets/svga/room_menu_gift.svga
Normal file
BIN
app/src/main/assets/svga/room_menu_gift.svga
Normal file
Binary file not shown.
BIN
app/src/main/assets/svga/room_pk_pb_indicator.svga
Normal file
BIN
app/src/main/assets/svga/room_pk_pb_indicator.svga
Normal file
Binary file not shown.
BIN
app/src/main/assets/svga/single_room_pk_pb_indicator.svga
Normal file
BIN
app/src/main/assets/svga/single_room_pk_pb_indicator.svga
Normal file
Binary file not shown.
BIN
app/src/main/assets/svga/single_room_pk_vs.svga
Normal file
BIN
app/src/main/assets/svga/single_room_pk_vs.svga
Normal file
Binary file not shown.
BIN
app/src/main/assets/svga/smash_eggs_open.svga
Normal file
BIN
app/src/main/assets/svga/smash_eggs_open.svga
Normal file
Binary file not shown.
BIN
app/src/main/assets/svga/svga_voice_like_button.svga
Normal file
BIN
app/src/main/assets/svga/svga_voice_like_button.svga
Normal file
Binary file not shown.
BIN
app/src/main/ic_launcher-playstore.png
Normal file
BIN
app/src/main/ic_launcher-playstore.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
@@ -23,22 +23,30 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.chwl.app.base.GlobalViewModelOwner;
|
||||
import com.chwl.app.common.widget.dialog.DialogManager;
|
||||
import com.chwl.app.community.square.SquareFragment;
|
||||
import com.chwl.app.game.core.GameStateAbility;
|
||||
import com.chwl.app.game.data.GameModel2;
|
||||
import com.chwl.app.game.ui.game.GameActivity;
|
||||
import com.chwl.app.game.ui.game.GameIntent;
|
||||
import com.chwl.app.game.ui.home.GameHomeFragment;
|
||||
import com.chwl.app.star.StarFragment;
|
||||
import com.chwl.app.support.PreloadResourceViewModel;
|
||||
import com.chwl.app.ui.login.LoginPasswordActivity;
|
||||
import com.chwl.core.home.bean.MainTabInfo;
|
||||
import com.chwl.core.settings.SettingsModel;
|
||||
import com.chwl.library.utils.JavaUtil;
|
||||
import com.netease.nim.uikit.StatusBarUtil;
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
import com.netease.nim.uikit.common.util.string.StringUtil;
|
||||
import com.netease.nim.uikit.impl.cache.NimUserInfoCache;
|
||||
import com.netease.nimlib.sdk.NIMClient;
|
||||
import com.netease.nimlib.sdk.RequestCallbackWrapper;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomKickOutEvent;
|
||||
import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum;
|
||||
import com.netease.nimlib.sdk.msg.model.RecentContact;
|
||||
import com.netease.nimlib.sdk.team.TeamService;
|
||||
import com.netease.nimlib.sdk.team.constant.TeamMessageNotifyTypeEnum;
|
||||
import com.netease.nimlib.sdk.team.model.Team;
|
||||
import com.netease.nimlib.sdk.uinfo.model.NimUserInfo;
|
||||
import com.orhanobut.logger.Logger;
|
||||
import com.trello.rxlifecycle3.android.ActivityEvent;
|
||||
import com.chwl.app.application.IReportConstants;
|
||||
@@ -84,7 +92,6 @@ import com.chwl.core.channel_page.model.ChannelPageModel;
|
||||
import com.chwl.core.community.event.SquareTaskEvent;
|
||||
import com.chwl.core.community.event.UnReadCountEvent;
|
||||
import com.chwl.core.home.bean.MainTabType;
|
||||
import com.chwl.core.home.event.RefreshHomeDataEvent;
|
||||
import com.chwl.core.home.event.VisitorUnreadCountEvent;
|
||||
import com.chwl.core.home.model.GameHomeModel;
|
||||
import com.chwl.core.home.model.HomeModel;
|
||||
@@ -119,10 +126,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
@@ -135,13 +138,13 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
private static final String TAG = "MainActivity";
|
||||
private static final String EXTRA_APP_QUIT = "APP_QUIT";
|
||||
private final SparseArray<Fragment> fragmentArray = new SparseArray<>();
|
||||
private DragLayout avatarLayout;
|
||||
private View avatarLayout;
|
||||
private CircleImageView avatarImage;
|
||||
private LivingIconView userLivingView;
|
||||
private MainTabLayout mMainTabLayout;
|
||||
private AnchorCardView anchorCardView;
|
||||
private View viewClose;
|
||||
private int mCurrentTabType = MainTabType.TAB_TYPE_STAR;
|
||||
private int mCurrentTabType = MainTabType.TAB_TYPE_HOME;
|
||||
/**
|
||||
* 房间最小化动画,换成属性动画,原先的补间动画影响了activity的生命周期
|
||||
*/
|
||||
@@ -154,13 +157,15 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
private boolean mResumed = false;
|
||||
@Nullable
|
||||
private Fragment tempFragment = null;
|
||||
private DialogManager resumeGameDialogManager;
|
||||
|
||||
@Nullable
|
||||
private Runnable touchRunnable;
|
||||
|
||||
{
|
||||
fragmentArray.put(MainTabType.TAB_TYPE_STAR, new StarFragment());
|
||||
fragmentArray.put(MainTabType.TAB_TYPE_HOME, new HomeFragment());
|
||||
fragmentArray.put(MainTabType.TAB_TYPE_GAME, new GameHomeFragment());
|
||||
fragmentArray.put(MainTabType.TAB_TYPE_SQUARE, new SquareFragment());
|
||||
fragmentArray.put(MainTabType.TAB_TYPE_MSG, new ContactsListFragment());
|
||||
fragmentArray.put(MainTabType.TAB_TYPE_ME, new MeFragment());
|
||||
}
|
||||
@@ -219,7 +224,8 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
homeViewModel = new ViewModelProvider(this).get(HomeViewModel.class);
|
||||
ViewModelProvider viewModelProvider = new ViewModelProvider(this);
|
||||
homeViewModel = viewModelProvider.get(HomeViewModel.class);
|
||||
NimMiddleActivity.firstEnter = false;
|
||||
if (savedInstanceState != null) {
|
||||
mCurrentTabType = savedInstanceState.getInt(Constants.KEY_MAIN_POSITION);
|
||||
@@ -230,11 +236,10 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
.doOnError(throwable -> onNeedLogin())
|
||||
.subscribe();
|
||||
initView();
|
||||
InitialModel.get().getMainTabInfosLiveData().observeForever(mainTabInfo -> {
|
||||
if (mainTabInfo != null) {
|
||||
mMainTabLayout.setMainTabInfoList(mainTabInfo);
|
||||
}
|
||||
});
|
||||
List<MainTabInfo> mainTabInfo = InitialModel.get().getMainTabInfosLiveData().getValue();
|
||||
if (mainTabInfo != null) {
|
||||
mMainTabLayout.setMainTabInfoList(mainTabInfo);
|
||||
}
|
||||
initMaterialView();
|
||||
onParseIntent();
|
||||
updateDatas();
|
||||
@@ -243,17 +248,13 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
EventBus.getDefault().register(this);
|
||||
otherModelInit();
|
||||
|
||||
Observable.interval(60, TimeUnit.SECONDS)
|
||||
.compose(bindToLifecycle())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(aLong -> EventBus.getDefault().post(new RefreshHomeDataEvent()));
|
||||
|
||||
homeViewModel.getAnchorInfoLiveData().observe(this, anchorInfo -> {
|
||||
if (anchorInfo != null) {
|
||||
anchorCardView.setAnchorInfo(anchorInfo);
|
||||
DemoCache.saveAnchorCardView(2);
|
||||
}
|
||||
});
|
||||
checkResumeGame();
|
||||
}
|
||||
|
||||
private void otherModelInit() {
|
||||
@@ -263,6 +264,48 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
IMBroadcastManager.get().onCreate();
|
||||
ImageLoadUtilsV2.init(context);
|
||||
SettingsModel.get().checkSysAccount();
|
||||
initPreloadResource();
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void checkResumeGame() {
|
||||
GameModel2.INSTANCE.getResumeGameRoomInfo().compose(bindToLifecycle()).subscribe(gameRoomInfo -> {
|
||||
if (gameRoomInfo != null && gameRoomInfo.getData() != null) {
|
||||
Integer state = gameRoomInfo.getData().getMatchStatus();
|
||||
if (state != null && (state == GameStateAbility.STATE_MATCH_SUCCESS || state == GameStateAbility.STATE_MATCHING)) {
|
||||
if (resumeGameDialogManager == null) {
|
||||
resumeGameDialogManager = new DialogManager(this);
|
||||
}
|
||||
resumeGameDialogManager.showOkCancelDialog(getString(R.string.resume_game_tips), getString(R.string.join_organization_ok), getString(R.string.join_organization_no), false, new DialogManager.OkCancelDialogListener() {
|
||||
@Override
|
||||
public void onOk() {
|
||||
long gameId = JavaUtil.str2long(gameRoomInfo.getData().getMgId());
|
||||
int gameMode = 0;
|
||||
GameActivity.Companion.start(context, new GameIntent(gameId, gameMode));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
DialogManager.OkCancelDialogListener.super.onCancel();
|
||||
Long roomId = gameRoomInfo.getRoomId();
|
||||
if (roomId != null) {
|
||||
GameModel2.INSTANCE.closeGameRx(roomId).compose(bindToLifecycle()).subscribe(s -> {
|
||||
}, throwable -> {
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}, throwable -> {
|
||||
});
|
||||
}
|
||||
|
||||
private void initPreloadResource() {
|
||||
PreloadResourceViewModel viewModel = new ViewModelProvider(
|
||||
GlobalViewModelOwner.Companion.getInstance()
|
||||
).get(PreloadResourceViewModel.class);
|
||||
viewModel.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -395,6 +438,9 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
protected void onDestroy() {
|
||||
CleanLeakUtils.fixInputMethodManagerLeak(MainActivity.this);
|
||||
super.onDestroy();
|
||||
if (resumeGameDialogManager != null) {
|
||||
resumeGameDialogManager.dismissDialog();
|
||||
}
|
||||
ImInitHelper.get().unInit();
|
||||
EventBus.getDefault().unregister(this);
|
||||
stopRoomMinAnim();
|
||||
@@ -529,27 +575,7 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
private void updateRoomState() {
|
||||
RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
|
||||
if (roomInfo != null) {
|
||||
UserModel.get().getUserInfo(roomInfo.getUid())
|
||||
.subscribe(userInfo -> {
|
||||
if (userInfo != null) {
|
||||
displayAvatarLayout(userInfo.getAvatar(), roomInfo.getTitle(), userInfo.getErbanNo());
|
||||
} else {
|
||||
NimUserInfo nimUserInfo = NimUserInfoCache.getInstance().getUserInfo(roomInfo.getUid() + "");
|
||||
if (nimUserInfo == null) {
|
||||
NimUserInfoCache.getInstance().getUserInfoFromRemote(roomInfo.getUid() + "", new RequestCallbackWrapper<NimUserInfo>() {
|
||||
@Override
|
||||
public void onResult(int i, NimUserInfo nimUserInfo, Throwable throwable) {
|
||||
if (nimUserInfo != null) {
|
||||
displayAvatarLayout(nimUserInfo.getAvatar(), roomInfo.getTitle(), userInfo.getUid());
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
displayAvatarLayout(nimUserInfo.getAvatar(), roomInfo.getTitle(), userInfo.getUid());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
displayAvatarLayout(roomInfo.getAvatar(), roomInfo.getTitle(), roomInfo.getUid());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -600,16 +626,10 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
transaction.show(showFragment);
|
||||
if (tempFragment != null) {
|
||||
transaction.hide(tempFragment);
|
||||
if (tempFragment instanceof MainTabContentView) {
|
||||
((MainTabContentView) tempFragment).onVisibleStateChanged(false);
|
||||
}
|
||||
}
|
||||
tempFragment = showFragment;
|
||||
if (!isDestroyed()) {
|
||||
transaction.commitNowAllowingStateLoss();
|
||||
if (tempFragment instanceof MainTabContentView) {
|
||||
((MainTabContentView) tempFragment).onVisibleStateChanged(true);
|
||||
}
|
||||
}
|
||||
mCurrentTabType = tabType;
|
||||
|
||||
|
@@ -1,5 +1,4 @@
|
||||
package com.chwl.app
|
||||
|
||||
interface MainTabContentView {
|
||||
fun onVisibleStateChanged(showOrHide: Boolean) {}
|
||||
}
|
@@ -5,6 +5,7 @@ import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_HEADER_TY
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Color;
|
||||
import android.net.http.HttpResponseCache;
|
||||
import android.os.Build;
|
||||
@@ -12,15 +13,18 @@ import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.util.Supplier;
|
||||
import androidx.multidex.MultiDex;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.bumptech.glide.request.target.ViewTarget;
|
||||
import com.chwl.app.support.IMUserInfoProvider;
|
||||
import com.example.lib_utils.LanguageUtils;
|
||||
import com.chwl.library.language.LanguageHelper;
|
||||
import com.coorchice.library.utils.LogUtils;
|
||||
import com.example.lib_utils.ServiceTime;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.liulishuo.filedownloader.FileDownloader;
|
||||
import com.netease.nim.uikit.api.NimUIKit;
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
import com.netease.nimlib.sdk.NIMClient;
|
||||
@@ -80,7 +84,6 @@ import com.chwl.library.common.file.FileHelper;
|
||||
import com.chwl.library.net.rxnet.RxNet;
|
||||
import com.chwl.library.net.rxnet.converter.GsonConverterPlugins;
|
||||
import com.chwl.library.utils.AppMetaDataUtil;
|
||||
import com.chwl.library.utils.AppUtils;
|
||||
import com.chwl.library.utils.DeviceUuidFactory;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
@@ -321,6 +324,7 @@ public class App extends BaseApp {
|
||||
BasicConfig.INSTANCE.setVoiceDir(Constants.VOICE_DIR);
|
||||
BasicConfig.INSTANCE.setCacheDir(Constants.CACHE_DIR);
|
||||
BasicConfig.INSTANCE.setImageDir(Constants.IMAGE_CACHE_DIR);
|
||||
com.example.lib_utils.log.LogUtil.INSTANCE.setConsolePrinterEnabled(BuildConfig.DEBUG);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -412,13 +416,13 @@ public class App extends BaseApp {
|
||||
httpParams.put("netType", String.valueOf(SystemUtils.getNetworkType(context)));
|
||||
httpParams.put("model", SystemUtils.getPhoneModel());
|
||||
httpParams.put("appVersion", VersionUtil.getLocalName(context));
|
||||
httpParams.put("appVersionCode", String.valueOf(AppUtils.getVersionCode(context)));
|
||||
httpParams.put("appVersionCode", String.valueOf(VersionUtil.getVersionCode(context)));
|
||||
httpParams.put("deviceId", DeviceUuidFactory.getDeviceId(context));
|
||||
httpParams.put("androidId", MD5Utils.getMD5String(Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID)));
|
||||
httpParams.put("channel", AppMetaDataUtil.getChannelID());
|
||||
httpParams.put("lang", LanguageUtils.INSTANCE.getSystemLanguage().toLanguageTag());
|
||||
httpParams.put("lang", LanguageHelper.INSTANCE.getSystemLanguage().toLanguageTag());
|
||||
RxNet.init(context)
|
||||
.debug(Env.isDebug())
|
||||
.debug(Env.isRealDebug())
|
||||
.setBaseUrl(url)
|
||||
.addInterceptors(new ParamsInterceptor(httpParams))
|
||||
.addInterceptors(new NoParamsInterceptor())//注意:拦截器的添加顺序,请求的拦截顺序
|
||||
@@ -454,6 +458,7 @@ public class App extends BaseApp {
|
||||
.build();
|
||||
Realm.setDefaultConfiguration(config);
|
||||
|
||||
FileDownloader.setup(BasicConfig.INSTANCE.getAppContext());
|
||||
LogUtil.i(TAG, channel);
|
||||
}
|
||||
|
||||
@@ -522,6 +527,8 @@ public class App extends BaseApp {
|
||||
BasicConfig.INSTANCE.setAppContext(this.getApplicationContext());
|
||||
SharedPreferenceUtils.init(this);
|
||||
ResUtil.init(this);
|
||||
ResUtil.contextSupplier = () -> App.gStack.getTopContext();
|
||||
LanguageHelper.INSTANCE.wrapContext(instance);
|
||||
initOtherSDK();
|
||||
initContext(this);
|
||||
//首次启动事件
|
||||
@@ -550,6 +557,12 @@ public class App extends BaseApp {
|
||||
MultiDex.install(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(@NonNull Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
LanguageHelper.INSTANCE.wrapContext(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTerminate() {
|
||||
super.onTerminate();
|
||||
|
@@ -35,6 +35,8 @@ import com.chwl.library.utils.TimeUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Single;
|
||||
@@ -519,6 +521,7 @@ public class BottleLayout extends FrameLayout {
|
||||
double num = likeCountDouble / 10000;
|
||||
|
||||
DecimalFormat decimalFormat = new DecimalFormat("0.00");// 构造方法的字符格式这里如果小数不足2位,会以0补足.
|
||||
decimalFormat.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance(Locale.ENGLISH));
|
||||
BigDecimal bigDecimal = new BigDecimal(num);
|
||||
double likeCountFormat = bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
if (likeCountFormat > 9999) {
|
||||
|
@@ -47,4 +47,7 @@ public abstract class BottomViewListenerWrapper {
|
||||
|
||||
}
|
||||
|
||||
public void onRoomGameplayClick(boolean isOnlyPK){
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -1,23 +1,17 @@
|
||||
package com.chwl.app.avroom.activity;
|
||||
|
||||
import static android.view.View.VISIBLE;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ALL_SERVICE_GIFT;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_BOX;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_FAIRY;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_HEADER_TYPE_GIFT;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_SEA;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_ALL;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ROOM_PK;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_DRAW_GIFT_L5;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_ROOM_PK_NOTIFY;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.app.FragmentManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@@ -40,11 +34,19 @@ import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.chwl.app.notify.RoomNotifyManager;
|
||||
import com.chwl.app.ui.webview.baishun.BaiShunGameWebFragment;
|
||||
import com.chwl.app.ui.webview.baishun.IBaiShunGameListener;
|
||||
import com.chwl.library.widget.SVGAView;
|
||||
import com.chwl.core.monsterhunting.bean.MonsterDataBean;
|
||||
import com.chwl.core.room.game.bean.BaiShunGameConfig;
|
||||
import com.chwl.core.support.room.AudioRoomContext;
|
||||
import com.chwl.core.support.room.RoomWidget;
|
||||
import com.netease.nim.uikit.StatusBarUtil;
|
||||
import com.netease.nimlib.sdk.NIMSDK;
|
||||
import com.netease.nimlib.sdk.Observer;
|
||||
@@ -57,7 +59,6 @@ import com.opensource.svgaplayer.SVGAImageView;
|
||||
import com.opensource.svgaplayer.SVGAParser;
|
||||
import com.opensource.svgaplayer.SVGAVideoEntity;
|
||||
import com.orhanobut.logger.Logger;
|
||||
import com.trello.rxlifecycle3.android.ActivityEvent;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.avroom.dialog.NewUserGiftDialog;
|
||||
import com.chwl.app.avroom.dialog.SingleRoomTipDialog;
|
||||
@@ -79,12 +80,10 @@ import com.chwl.app.ui.patriarch.help.LimitEnterRoomHelper;
|
||||
import com.chwl.app.ui.user.activity.UserInfoActivity;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils;
|
||||
import com.chwl.app.ui.webview.CommonWebViewActivity;
|
||||
import com.chwl.app.ui.webview.DialogWebViewActivity;
|
||||
import com.chwl.app.ui.widget.NobleOpenNoticeView;
|
||||
import com.chwl.app.ui.widget.dialog.AllServiceGiftLevelDialog;
|
||||
import com.chwl.app.ui.widget.dialog.MonsterDialog;
|
||||
import com.chwl.app.utils.UserUtils;
|
||||
import com.chwl.app.room_chat.activity.RoomMsgActivity;
|
||||
import com.chwl.core.Constants;
|
||||
import com.chwl.core.DemoCache;
|
||||
import com.chwl.core.auth.AuthModel;
|
||||
@@ -93,18 +92,14 @@ import com.chwl.core.bean.BaseProtocol;
|
||||
import com.chwl.core.channel_page.bean.HelloMessageInfo;
|
||||
import com.chwl.core.gift.GiftModel;
|
||||
import com.chwl.core.gift.bean.GiftInfo;
|
||||
import com.chwl.core.gift.bean.LuckyBagNoticeInfo;
|
||||
import com.chwl.core.im.custom.bean.CustomAttachment;
|
||||
import com.chwl.core.im.custom.bean.FairyMsgAttachment;
|
||||
import com.chwl.core.im.custom.bean.NotifyH5Attachment;
|
||||
import com.chwl.core.im.custom.bean.NotifyH5Info;
|
||||
import com.chwl.core.im.custom.bean.RoomBoxPrizeAttachment;
|
||||
import com.chwl.core.im.custom.bean.RoomBoxPrizeInfo;
|
||||
import com.chwl.core.im.custom.bean.RoomLuckySeaAttachment;
|
||||
import com.chwl.core.im.custom.bean.RoomLuckySeaMsgBean;
|
||||
import com.chwl.core.im.custom.bean.RoomPKAttachment;
|
||||
import com.chwl.core.im.custom.bean.RoomPkBean;
|
||||
import com.chwl.core.im.custom.bean.RoomReceivedLuckyGiftAttachment;
|
||||
import com.chwl.core.im.custom.bean.TarotAttachment;
|
||||
import com.chwl.core.im.custom.bean.TarotMsgBean;
|
||||
import com.chwl.core.initial.InitialModel;
|
||||
@@ -115,7 +110,6 @@ import com.chwl.core.module_hall.hall.HallModel;
|
||||
import com.chwl.core.module_hall.hall.bean.SuperAdminInfo;
|
||||
import com.chwl.core.monsterhunting.bean.MonsterHuntingResult;
|
||||
import com.chwl.core.monsterhunting.bean.MonsterInfo;
|
||||
import com.chwl.core.monsterhunting.bean.MonsterProtocol;
|
||||
import com.chwl.core.monsterhunting.manager.MonsterDataManager;
|
||||
import com.chwl.core.noble.bean.AllServiceGiftProtocol;
|
||||
import com.chwl.core.noble.bean.NobleInfo;
|
||||
@@ -140,7 +134,6 @@ import com.chwl.core.support.room.RoomContext;
|
||||
import com.chwl.core.support.room.RoomView;
|
||||
import com.chwl.core.treasurefairy.bean.FairyMsgInfoBean;
|
||||
import com.chwl.core.user.UserModel;
|
||||
import com.chwl.core.user.bean.FirstChargeInfo;
|
||||
import com.chwl.core.user.bean.UserInfo;
|
||||
import com.chwl.core.utils.LogUtils;
|
||||
import com.chwl.core.utils.StringFormatUtils;
|
||||
@@ -158,13 +151,12 @@ import java.lang.ref.WeakReference;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.SingleObserver;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
|
||||
|
||||
/**
|
||||
@@ -186,6 +178,15 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
private static final String TAG = "AVRoomActivity";
|
||||
private static final int SHOW_RED_DIALOG_MAX = 10;
|
||||
public static boolean isPKModel = false;
|
||||
private static SVGAView.SVGACache svgaCache;
|
||||
|
||||
public static SVGAView.SVGACache getSvgaCache() {
|
||||
if (svgaCache == null) {
|
||||
svgaCache = SVGAView.newCache(20);
|
||||
}
|
||||
return svgaCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理限制进房
|
||||
*/
|
||||
@@ -227,6 +228,10 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
// 是否禁用VP滑动(true:不允许滑动;false:某些条件下可以滑动)
|
||||
private boolean viewPagerInputDisable;
|
||||
|
||||
private RoomNotifyManager roomNotify;
|
||||
|
||||
private BaiShunGameWebFragment baiShunGameFragment;
|
||||
|
||||
public static void start(Context context, long roomUid) {
|
||||
startForFromType(context, roomUid, FROM_TYPE_NORMAL, null, null);
|
||||
}
|
||||
@@ -505,6 +510,17 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
}
|
||||
});
|
||||
|
||||
roomNotify = new RoomNotifyManager(this);
|
||||
roomNotify.setOnShowUserCard(new Function1<String, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(String s) {
|
||||
if (mCurrentFragment != null) {
|
||||
mCurrentFragment.showUserCardDialog(s);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
roomNotify.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -893,6 +909,10 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
GiftModel.get().cancelCountDownTimer();
|
||||
EventBus.getDefault().unregister(this);
|
||||
DemoCache.saveBoolean("FirstCharge", false);
|
||||
if (svgaCache != null) {
|
||||
svgaCache.clear();
|
||||
}
|
||||
svgaCache = null;
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@@ -914,7 +934,9 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
|
||||
if (closeBaiShunGame()) {
|
||||
return;
|
||||
}
|
||||
if (AvRoomDataManager.get().isGamePlaying(AvRoomDataManager.get().getMicPosition(AuthModel.get().getCurrentUid()))) {
|
||||
getDialogManager().showOkCancelDialog(ResUtil.getString(R.string.avroom_activity_avroomactivity_09), false,
|
||||
this::minRoomCode);
|
||||
@@ -1170,56 +1192,56 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
if (baseProtocol == null) return;
|
||||
if (!isValid()) return;
|
||||
switch (baseProtocol.getFirst()) {
|
||||
case CUSTOM_MSG_HEADER_TYPE_GIFT:
|
||||
if (giftList == null) {
|
||||
giftList = new LinkedList<>();
|
||||
}
|
||||
int second2 = baseProtocol.getSecond();
|
||||
AllServiceGiftProtocol.DataBean data = JSON.parseObject(String.valueOf(baseProtocol.getData()), AllServiceGiftProtocol.DataBean.class);
|
||||
if (data == null || (data.getGiftUrl()) == null)
|
||||
return;
|
||||
giftList.add(data);
|
||||
if (second2 == CUSTOM_MSG_ALL_SERVICE_GIFT) {
|
||||
if (giftDialog != null && giftDialog.isShowing()) {
|
||||
// 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个
|
||||
AllServiceGiftProtocol.DataBean dataBean = giftList.peekFirst();
|
||||
if (dataBean != null) {
|
||||
return;
|
||||
} else {
|
||||
giftDialog.dismiss();
|
||||
}
|
||||
} else {
|
||||
showGiftDialog();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CUSTOM_MSG_BOX://寻爱之旅
|
||||
if (baseProtocol.getSecond() == CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA) {
|
||||
RoomBoxPrizeAttachment roomBoxPrizeAttachment = new RoomBoxPrizeAttachment(CUSTOM_MSG_BOX, CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA);
|
||||
RoomBoxPrizeInfo roomBoxPrizeBean = JSON.parseObject(String.valueOf(baseProtocol.getData()), RoomBoxPrizeInfo.class);
|
||||
roomBoxPrizeAttachment.setUid(roomBoxPrizeBean.getUid());
|
||||
roomBoxPrizeAttachment.setPrizeName(roomBoxPrizeBean.getPrizeName());
|
||||
roomBoxPrizeAttachment.setNick(roomBoxPrizeBean.getNick());
|
||||
roomBoxPrizeAttachment.setBoxTypeStr(roomBoxPrizeBean.getBoxTypeStr());
|
||||
roomBoxPrizeAttachment.setRoomUid(roomBoxPrizeBean.getRoomUid());
|
||||
roomBoxPrizeAttachment.setPrizeNum(roomBoxPrizeBean.getPrizeNum());
|
||||
roomBoxPrizeAttachment.setUserLevelLimit(roomBoxPrizeBean.getUserLevelLimit());
|
||||
if (AvRoomDataManager.get().isOpenPureMode()) {
|
||||
// 純凈模式打開後,僅能看跟自己相關的砸蛋消息
|
||||
if (Objects.equals(roomBoxPrizeAttachment.getUid(), AuthModel.get().getCurrentUid())) {
|
||||
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(String.valueOf(AvRoomDataManager.get().getRoomId()), roomBoxPrizeAttachment);
|
||||
IMNetEaseManager.get().addMessages(message);
|
||||
}
|
||||
} else {
|
||||
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(String.valueOf(AvRoomDataManager.get().getRoomId()), roomBoxPrizeAttachment);
|
||||
IMNetEaseManager.get().addMessages(message);
|
||||
IMNetEaseManager.get().getChatRoomEventObservable()
|
||||
.onNext(new RoomEvent()
|
||||
.setEvent(RoomEvent.BOX_NOTIFY_SVGA)
|
||||
.setChatRoomMessage(message));
|
||||
}
|
||||
}
|
||||
break;
|
||||
// case CUSTOM_MSG_HEADER_TYPE_GIFT:
|
||||
// if (giftList == null) {
|
||||
// giftList = new LinkedList<>();
|
||||
// }
|
||||
// int second2 = baseProtocol.getSecond();
|
||||
// AllServiceGiftProtocol.DataBean data = JSON.parseObject(String.valueOf(baseProtocol.getData()), AllServiceGiftProtocol.DataBean.class);
|
||||
// if (data == null || (data.getGiftUrl()) == null)
|
||||
// return;
|
||||
// giftList.add(data);
|
||||
// if (second2 == CUSTOM_MSG_ALL_SERVICE_GIFT) {
|
||||
// if (giftDialog != null && giftDialog.isShowing()) {
|
||||
// // 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个
|
||||
// AllServiceGiftProtocol.DataBean dataBean = giftList.peekFirst();
|
||||
// if (dataBean != null) {
|
||||
// return;
|
||||
// } else {
|
||||
// giftDialog.dismiss();
|
||||
// }
|
||||
// } else {
|
||||
// showGiftDialog();
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// case CUSTOM_MSG_BOX://寻爱之旅
|
||||
// if (baseProtocol.getSecond() == CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA) {
|
||||
// RoomBoxPrizeAttachment roomBoxPrizeAttachment = new RoomBoxPrizeAttachment(CUSTOM_MSG_BOX, CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA);
|
||||
// RoomBoxPrizeInfo roomBoxPrizeBean = JSON.parseObject(String.valueOf(baseProtocol.getData()), RoomBoxPrizeInfo.class);
|
||||
// roomBoxPrizeAttachment.setUid(roomBoxPrizeBean.getUid());
|
||||
// roomBoxPrizeAttachment.setPrizeName(roomBoxPrizeBean.getPrizeName());
|
||||
// roomBoxPrizeAttachment.setNick(roomBoxPrizeBean.getNick());
|
||||
// roomBoxPrizeAttachment.setBoxTypeStr(roomBoxPrizeBean.getBoxTypeStr());
|
||||
// roomBoxPrizeAttachment.setRoomUid(roomBoxPrizeBean.getRoomUid());
|
||||
// roomBoxPrizeAttachment.setPrizeNum(roomBoxPrizeBean.getPrizeNum());
|
||||
// roomBoxPrizeAttachment.setUserLevelLimit(roomBoxPrizeBean.getUserLevelLimit());
|
||||
// if (AvRoomDataManager.get().isOpenPureMode()) {
|
||||
// // 純凈模式打開後,僅能看跟自己相關的砸蛋消息
|
||||
// if (Objects.equals(roomBoxPrizeAttachment.getUid(), AuthModel.get().getCurrentUid())) {
|
||||
// ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(String.valueOf(AvRoomDataManager.get().getRoomId()), roomBoxPrizeAttachment);
|
||||
// IMNetEaseManager.get().addMessages(message);
|
||||
// }
|
||||
// } else {
|
||||
// ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(String.valueOf(AvRoomDataManager.get().getRoomId()), roomBoxPrizeAttachment);
|
||||
// IMNetEaseManager.get().addMessages(message);
|
||||
// IMNetEaseManager.get().getChatRoomEventObservable()
|
||||
// .onNext(new RoomEvent()
|
||||
// .setEvent(RoomEvent.BOX_NOTIFY_SVGA)
|
||||
// .setChatRoomMessage(message));
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
case CustomAttachment.CUSTOM_MESS_TAROT:
|
||||
if (baseProtocol.getSecond() == CustomAttachment.CUSTOM_MESS_TAROT_SENIOR_PRIZE_WINNING) {
|
||||
TarotMsgBean tarotMsgBean = JSON.parseObject(String.valueOf(baseProtocol.getData()), TarotMsgBean.class);
|
||||
@@ -1257,15 +1279,15 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
IMNetEaseManager.get().noticeRoomEvent(message, RoomEvent.LUCKY_SEA_GIFT_SERVER_NOTIFY);
|
||||
}
|
||||
break;
|
||||
case CUSTOM_MSG_LUCKY_GIFT://福袋
|
||||
if (baseProtocol.getSecond() == CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY || baseProtocol.getSecond() == CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL) {
|
||||
RoomReceivedLuckyGiftAttachment attachment = new RoomReceivedLuckyGiftAttachment(CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY);
|
||||
attachment.setLuckyBagNoticeInfo(JSON.parseObject(String.valueOf(baseProtocol.getData()), LuckyBagNoticeInfo.class));
|
||||
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(String.valueOf(AvRoomDataManager.get().getRoomId()), attachment);
|
||||
IMNetEaseManager.get().noticeServiceLuckyBagNotice(message);
|
||||
IMNetEaseManager.get().addMessages(message);
|
||||
}
|
||||
break;
|
||||
// case CUSTOM_MSG_LUCKY_GIFT://福袋
|
||||
// if (baseProtocol.getSecond() == CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY || baseProtocol.getSecond() == CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL) {
|
||||
// RoomReceivedLuckyGiftAttachment attachment = new RoomReceivedLuckyGiftAttachment(CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY);
|
||||
// attachment.setLuckyBagNoticeInfo(JSON.parseObject(String.valueOf(baseProtocol.getData()), LuckyBagNoticeInfo.class));
|
||||
// ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(String.valueOf(AvRoomDataManager.get().getRoomId()), attachment);
|
||||
// IMNetEaseManager.get().noticeServiceLuckyBagNotice(message);
|
||||
// IMNetEaseManager.get().addMessages(message);
|
||||
// }
|
||||
// break;
|
||||
case CUSTOM_MSG_FAIRY://夺宝精灵
|
||||
if (baseProtocol.getSecond() == CUSTOM_MSG_SUB_DRAW_GIFT_L5) {
|
||||
FairyMsgAttachment attachment = new FairyMsgAttachment(CUSTOM_MSG_FAIRY, CUSTOM_MSG_SUB_DRAW_GIFT_L5);
|
||||
@@ -1351,10 +1373,21 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FragmentManager getFragmentManager() {
|
||||
return super.getFragmentManager();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public RoomContext getRoomContext() {
|
||||
return RoomContext.Companion.get();
|
||||
return AudioRoomContext.Companion.get();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public LiveData<? extends RoomContext> getRoomContextLiveData() {
|
||||
return AudioRoomContext.Companion.getContextLiveData();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@@ -1363,6 +1396,19 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public androidx.fragment.app.FragmentManager getViewFragmentManager() {
|
||||
return getSupportFragmentManager();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public RoomWidget findWidget(@NonNull String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private static class GiftBroadcastObserver implements Observer<BroadcastMessage> {
|
||||
private WeakReference<AVRoomActivity> mReference;
|
||||
|
||||
@@ -1382,14 +1428,14 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
JSONObject jsonObject;
|
||||
try {
|
||||
jsonObject = JSON.parseObject(contentStr);
|
||||
if (jsonObject == null) return;
|
||||
if (jsonObject.containsKey("body")) {
|
||||
String body = jsonObject.getString("body");
|
||||
if (TextUtils.isEmpty(body)) return;
|
||||
activity.onReceivedGiftBroadcastMessage(body);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
jsonObject = null;
|
||||
}
|
||||
if (jsonObject == null) return;
|
||||
if (jsonObject.containsKey("body")) {
|
||||
String body = jsonObject.getString("body");
|
||||
if (TextUtils.isEmpty(body)) return;
|
||||
activity.onReceivedGiftBroadcastMessage(body);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1432,4 +1478,30 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void showBaiShunGame(String url, BaiShunGameConfig config) {
|
||||
closeBaiShunGame();
|
||||
baiShunGameFragment = BaiShunGameWebFragment.Companion.newInstance(url, config);
|
||||
baiShunGameFragment.setListener(new IBaiShunGameListener() {
|
||||
@Override
|
||||
public void onGameClose() {
|
||||
closeBaiShunGame();
|
||||
}
|
||||
});
|
||||
findViewById(R.id.layout_baishun_game).setVisibility(VISIBLE);
|
||||
getSupportFragmentManager().beginTransaction().add(R.id.layout_baishun_game, baiShunGameFragment).commitAllowingStateLoss();
|
||||
}
|
||||
|
||||
private boolean closeBaiShunGame() {
|
||||
boolean isClose = false;
|
||||
if (baiShunGameFragment != null) {
|
||||
if (baiShunGameFragment.isAdded()) {
|
||||
getSupportFragmentManager().beginTransaction().remove(baiShunGameFragment).commitAllowingStateLoss();
|
||||
isClose = true;
|
||||
}
|
||||
}
|
||||
findViewById(R.id.layout_baishun_game).setVisibility(View.GONE);
|
||||
baiShunGameFragment = null;
|
||||
return isClose;
|
||||
}
|
||||
}
|
@@ -210,7 +210,7 @@ public class CreatePKActivity extends BaseMvpActivity<ICreatePKView, CreatePKPre
|
||||
redTeamName.get(i).setText(userInfoList.get(i).getNick());
|
||||
} else {
|
||||
redTeamAvatar.get(i).setImageResource(R.mipmap.ic_red_seat);
|
||||
redTeamName.get(i).setText(R.string.wait_for_mic);
|
||||
redTeamName.get(i).setText(String.valueOf(i+1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ public class CreatePKActivity extends BaseMvpActivity<ICreatePKView, CreatePKPre
|
||||
blueTeamName.get(i).setText(userInfoList.get(i).getNick());
|
||||
} else {
|
||||
blueTeamAvatar.get(i).setImageResource(R.mipmap.ic_blue_seat);
|
||||
blueTeamName.get(i).setText(R.string.wait_for_mic);
|
||||
blueTeamName.get(i).setText(String.valueOf(i+1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,77 @@
|
||||
package com.chwl.app.avroom.activity
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import androidx.core.view.WindowCompat
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.adapter.RoomBgAdapter
|
||||
import com.chwl.app.base.BaseViewBindingActivity
|
||||
import com.chwl.app.databinding.RoomBgSettingActivityBinding
|
||||
import com.chwl.core.auth.AuthModel
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
import com.chwl.core.room.model.RoomSettingModel
|
||||
import com.chwl.library.utils.ResUtil
|
||||
import com.netease.nim.uikit.StatusBarUtil
|
||||
|
||||
class RoomBgSettingActivity : BaseViewBindingActivity<RoomBgSettingActivityBinding>() {
|
||||
private val adapter = RoomBgAdapter()
|
||||
|
||||
private val model = RoomSettingModel()
|
||||
override fun init() {
|
||||
initWhiteTitleBar(ResUtil.getString(R.string.room_theme))
|
||||
mTitleBar.setTitleColor(resources.getColor(R.color.white))
|
||||
mTitleBar.setLeftImageResource(R.drawable.arrow_left_white)
|
||||
binding.recyclerView.adapter = adapter
|
||||
adapter.selectItem(AvRoomDataManager.get().mCurrentRoomInfo?.backPic)
|
||||
adapter.setOnItemClickListener { _, view, position ->
|
||||
adapter.getItem(position)?.let {
|
||||
if (adapter.getSelectItem() != it) {
|
||||
showUpdateRoomBackgroundTips(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
val list = listOf(
|
||||
"https://image.molistar.xyz/BG_0.webp",
|
||||
"https://image.molistar.xyz/BG_1.webp",
|
||||
"https://image.molistar.xyz/BG_2.webp",
|
||||
"https://image.molistar.xyz/BG_3.webp",
|
||||
"https://image.molistar.xyz/BG_4.webp",
|
||||
"https://image.molistar.xyz/BG_5.webp"
|
||||
)
|
||||
adapter.setNewData(list)
|
||||
}
|
||||
|
||||
private fun showUpdateRoomBackgroundTips(url: String) {
|
||||
dialogManager.showOkCancelDialog(
|
||||
getString(R.string.room_theme_changed_tips),
|
||||
getString(R.string.btn_text_confirm_select_team_member)
|
||||
) {
|
||||
updateRoomBackground(url)
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private fun updateRoomBackground(url: String) {
|
||||
dialogManager.showProgressDialog(this)
|
||||
model.updateRoomBackground(AuthModel.get().currentUid, url)
|
||||
.compose(bindToLifecycle()).subscribe({
|
||||
dialogManager.dismissDialog()
|
||||
toast(R.string.avroom_dialog_roomimposedialog_04)
|
||||
adapter.selectItem(url)
|
||||
}, {
|
||||
dialogManager.dismissDialog()
|
||||
toast(it.message)
|
||||
})
|
||||
}
|
||||
|
||||
override fun needSteepStateBar(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun setStatusBar() {
|
||||
StatusBarUtil.transparencyBar(this)
|
||||
StatusBarUtil.StatusBarLightMode(this)
|
||||
WindowCompat.getInsetsController(window, window.decorView).let {
|
||||
it.isAppearanceLightStatusBars = false
|
||||
}
|
||||
}
|
||||
}
|
@@ -7,6 +7,7 @@ import android.text.TextUtils;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.chwl.core.room.bean.RoomOnlineUserBean;
|
||||
import com.netease.nim.uikit.StatusBarUtil;
|
||||
import com.netease.nim.uikit.common.util.sys.NetworkUtil;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMember;
|
||||
@@ -20,7 +21,6 @@ import com.chwl.app.avroom.view.IRoomInviteView;
|
||||
import com.chwl.app.base.BaseMvpActivity;
|
||||
import com.chwl.core.Constants;
|
||||
import com.chwl.core.noble.NobleResourceType;
|
||||
import com.chwl.core.room.bean.OnlineChatMember;
|
||||
import com.chwl.core.user.bean.UserInfo;
|
||||
import com.chwl.library.base.factory.CreatePresenter;
|
||||
import com.chwl.library.utils.ListUtils;
|
||||
@@ -106,8 +106,9 @@ public class RoomInviteActivity extends BaseMvpActivity<IRoomInviteView, RoomInv
|
||||
getMvpPresenter().requestChatMemberByPage(mPage, time, onlyManager);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onRequestChatMemberByPageSuccess(List<OnlineChatMember> memberList, int page) {
|
||||
public void onRequestRoomOnlineListSuccess(List<RoomOnlineUserBean> memberList) {
|
||||
|
||||
}
|
||||
|
||||
|
@@ -7,8 +7,10 @@ import android.view.View;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.avroom.adapter.CommonVPAdapter;
|
||||
import com.chwl.app.avroom.fragment.RoomCharmListFragment;
|
||||
import com.chwl.app.avroom.fragment.RoomContributeListFragment;
|
||||
import com.chwl.app.base.BaseBindingActivity;
|
||||
@@ -39,18 +41,8 @@ public class RoomRankListActivity extends BaseBindingActivity<ActivityRoomRankLi
|
||||
List<Fragment> list = new ArrayList<>();
|
||||
list.add(RoomCharmListFragment.newInstance());
|
||||
list.add(new RoomContributeListFragment());
|
||||
mBinding.viewPager.setAdapter(new FragmentStatePagerAdapter(getSupportFragmentManager()) {
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
return list.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return list.size();
|
||||
}
|
||||
});
|
||||
mBinding.viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||
mBinding.viewPager.setAdapter(new CommonVPAdapter(getSupportFragmentManager(),getLifecycle(),list));
|
||||
mBinding.viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback(){
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
|
||||
|
@@ -8,11 +8,17 @@ import android.text.SpannableString;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
|
||||
import com.chwl.app.avroom.giftvalue.GiftValueDialogUiHelper;
|
||||
import com.chwl.core.super_admin.util.SuperAdminUtil;
|
||||
import com.chwl.core.utils.net.DontWarnObserver;
|
||||
import com.chwl.core.utils.net.RxHelper;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
import com.netease.nim.uikit.StatusBarUtil;
|
||||
import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
|
||||
@@ -112,6 +118,7 @@ public class RoomSettingActivity extends BaseMvpActivity<IRoomSettingView, RoomS
|
||||
}
|
||||
initView();
|
||||
initLeaveMode();
|
||||
loadGiftValueState();
|
||||
getMvpPresenter().requestRoomInfo(roomInfo.getUid());
|
||||
mRoomBgLayout.setVisibility(View.GONE);
|
||||
if (!AvRoomDataManager.get().isRoomOwner() && !AvRoomDataManager.get().isSuperAdmin()) {
|
||||
@@ -149,6 +156,7 @@ public class RoomSettingActivity extends BaseMvpActivity<IRoomSettingView, RoomS
|
||||
managerLayout.setOnClickListener(this);
|
||||
blackLayout.setOnClickListener(this);
|
||||
mRoomBgLayout.setOnClickListener(this);
|
||||
binding.layoutTheme.setOnClickListener(this);
|
||||
|
||||
binding.switchAudio.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
@@ -190,6 +198,28 @@ public class RoomSettingActivity extends BaseMvpActivity<IRoomSettingView, RoomS
|
||||
}
|
||||
}
|
||||
|
||||
private void loadGiftValueState(){
|
||||
if (SuperAdminUtil.isSuperAdmin()) {
|
||||
binding.layoutGiftValue.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
if (AvRoomDataManager.get().isCpRoom()) {
|
||||
binding.layoutGiftValue.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
if (!AvRoomDataManager.get().isManager()) {
|
||||
binding.layoutGiftValue.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
if (AvRoomDataManager.get().isOpenKTV()) {
|
||||
binding.layoutGiftValue.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
boolean openGiftValue = AvRoomDataManager.get().isShowGiftValue();
|
||||
binding.layoutGiftValue.setVisibility(View.VISIBLE);
|
||||
setSelected(binding.switchGiftValue, openGiftValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更改房间设置的消息
|
||||
*/
|
||||
@@ -295,6 +325,9 @@ public class RoomSettingActivity extends BaseMvpActivity<IRoomSettingView, RoomS
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.layout_theme:
|
||||
startActivity(new Intent(context, RoomBgSettingActivity.class));
|
||||
break;
|
||||
case R.id.manager_layout:
|
||||
RoomManagerListActivity.start(this);
|
||||
break;
|
||||
@@ -516,10 +549,59 @@ public class RoomSettingActivity extends BaseMvpActivity<IRoomSettingView, RoomS
|
||||
}
|
||||
break;
|
||||
|
||||
case R.id.switch_gift_value:
|
||||
switchGiftValue();
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
private void switchGiftValue(){
|
||||
if (AvRoomDataManager.get().isCpRoom()) {
|
||||
return;
|
||||
}
|
||||
if (AvRoomDataManager.get().isDatingMode()) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_dialog_roomoperationdialog_029));
|
||||
return;
|
||||
}
|
||||
if (AvRoomDataManager.get().isOpenKTV()) {
|
||||
SingleToastUtil.showToast(R.string.before_open_gift_value_should_close_ktv_model);
|
||||
return;
|
||||
}
|
||||
//开启礼物值不需要弹框
|
||||
if (!AvRoomDataManager.get().isShowGiftValue()) {
|
||||
handleOpenGiftValue();
|
||||
return;
|
||||
}
|
||||
if (!GiftValueDialogUiHelper.get().isNeedConfirmDialog(
|
||||
GiftValueDialogUiHelper.TYPE_CLOSE_SHOW_GIFT_VALUE)) {
|
||||
handleOpenGiftValue();
|
||||
return;
|
||||
}
|
||||
GiftValueDialogUiHelper.get().showGiftValueDialog(context, getDialogManager(),
|
||||
GiftValueDialogUiHelper.TYPE_CLOSE_SHOW_GIFT_VALUE,
|
||||
this::handleOpenGiftValue);
|
||||
}
|
||||
|
||||
private void handleOpenGiftValue() {
|
||||
boolean isOpen = !binding.switchGiftValue.isSelected();
|
||||
getDialogManager().showProgressDialog(this);
|
||||
GiftValueModel.get().openGiftValue(isOpen)
|
||||
.compose(RxHelper.bindContext(context))
|
||||
.subscribe(new DontWarnObserver<String>() {
|
||||
@Override
|
||||
public void accept(String s, String error) {
|
||||
super.accept(s, error);
|
||||
getDialogManager().dismissDialog();
|
||||
if (error != null) {
|
||||
SingleToastUtil.showToast(error);
|
||||
} else {
|
||||
setSelected(binding.switchGiftValue, !binding.switchGiftValue.isSelected());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResultRequestTagAllSuccess(List<RoomSettingTabInfo> tabInfoList) {
|
||||
this.tabInfoList = tabInfoList;
|
||||
@@ -806,4 +888,10 @@ public class RoomSettingActivity extends BaseMvpActivity<IRoomSettingView, RoomS
|
||||
StatusBarUtil.transparencyBar(this);
|
||||
StatusBarUtil.StatusBarLightMode(this);
|
||||
}
|
||||
|
||||
private void setSelected(ImageView imageView, boolean isSelected) {
|
||||
imageView.setSelected(isSelected);
|
||||
imageView.setImageResource(isSelected ?
|
||||
R.drawable.icon_room_set_lock_true : R.drawable.icon_room_set_lock_false);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,142 @@
|
||||
package com.chwl.app.avroom.activity
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.view.View
|
||||
import androidx.core.view.isVisible
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseViewBindingActivity
|
||||
import com.chwl.app.databinding.RoomTypeSwitchActivityBinding
|
||||
import com.chwl.app.home.helper.OpenRoomHelper
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
import com.chwl.core.room.bean.RoomInfo
|
||||
import com.chwl.core.super_admin.util.SuperAdminUtil
|
||||
import com.chwl.library.utils.ResUtil
|
||||
import com.chwl.library.utils.SingleToastUtil
|
||||
import com.example.lib_utils.ktx.singleClick
|
||||
import com.netease.nim.uikit.StatusBarUtil
|
||||
|
||||
class RoomTypeSwitchActivity : BaseViewBindingActivity<RoomTypeSwitchActivityBinding>() {
|
||||
|
||||
private var currentType: Int? = null
|
||||
|
||||
private var selectType: Int? = null
|
||||
|
||||
companion object {
|
||||
fun isCanSwitch(): Boolean {
|
||||
if (SuperAdminUtil.isSuperAdmin()) {
|
||||
return false
|
||||
}
|
||||
if (AvRoomDataManager.get().roomType != RoomInfo.ROOMTYPE_HOME_PARTY && AvRoomDataManager.get().roomType != RoomInfo.ROOMTYPE_PARTY && AvRoomDataManager.get().roomType != RoomInfo.ROOMTYPE_REVELRY) {
|
||||
return false
|
||||
}
|
||||
if (AvRoomDataManager.get().isDatingMode) {
|
||||
return false
|
||||
}
|
||||
val roomInfo = AvRoomDataManager.get().mCurrentRoomInfo
|
||||
if (roomInfo == null || roomInfo.isPermitRoom == 1) {
|
||||
return false
|
||||
}
|
||||
return AvRoomDataManager.get().isManager
|
||||
}
|
||||
|
||||
fun start(context: Context) {
|
||||
context.startActivity(Intent(context, RoomTypeSwitchActivity::class.java))
|
||||
}
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
initWhiteTitleBar(ResUtil.getString(R.string.room_type))
|
||||
initEvent()
|
||||
this.currentType = AvRoomDataManager.get().mCurrentRoomInfo?.type
|
||||
updateSelectView(currentType)
|
||||
}
|
||||
|
||||
private fun initEvent() {
|
||||
binding.tvSubmit.singleClick {
|
||||
selectType?.let {
|
||||
if (currentType != it) {
|
||||
trySwitchRoomType(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
addTypeSelectClick(binding.iv9, RoomInfo.ROOMTYPE_HOME_PARTY)
|
||||
addTypeSelectClick(binding.iv10, RoomInfo.ROOMTYPE_PARTY)
|
||||
addTypeSelectClick(binding.iv15, RoomInfo.ROOMTYPE_REVELRY)
|
||||
}
|
||||
|
||||
private fun addTypeSelectClick(view: View, type: Int) {
|
||||
view.setOnClickListener {
|
||||
updateSelectView(type)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateSelectView(type: Int?) {
|
||||
this.selectType = type
|
||||
val views = mapOf(
|
||||
RoomInfo.ROOMTYPE_HOME_PARTY to binding.iv9Border,
|
||||
RoomInfo.ROOMTYPE_PARTY to binding.iv10Border,
|
||||
RoomInfo.ROOMTYPE_REVELRY to binding.iv15Border
|
||||
)
|
||||
val displayRes = mapOf(
|
||||
RoomInfo.ROOMTYPE_HOME_PARTY to R.drawable.room_type_bg_9,
|
||||
RoomInfo.ROOMTYPE_PARTY to R.drawable.room_type_bg_10,
|
||||
RoomInfo.ROOMTYPE_REVELRY to R.drawable.room_type_bg_15
|
||||
)
|
||||
views.forEach {
|
||||
it.value.isVisible = it.key == type
|
||||
}
|
||||
val resId = displayRes.get(type)
|
||||
if (resId != null) {
|
||||
binding.ivSelected.setImageResource(resId)
|
||||
} else {
|
||||
binding.ivSelected.setImageDrawable(null)
|
||||
}
|
||||
if (type == currentType) {
|
||||
binding.tvSubmit.setText(R.string.room_type_using)
|
||||
} else {
|
||||
binding.tvSubmit.setText(R.string.room_type_use)
|
||||
}
|
||||
}
|
||||
|
||||
private fun trySwitchRoomType(type: Int) {
|
||||
val currentType = this.currentType
|
||||
if (currentType != null && currentType > type) {
|
||||
dialogManager.showOkCancelDialog(
|
||||
ResUtil.getString(R.string.switch_room_type_tips),
|
||||
ResUtil.getString(R.string.login_fragment_adduserinfofragment_04)
|
||||
) {
|
||||
requestSwitchRoomType(type)
|
||||
}
|
||||
} else {
|
||||
requestSwitchRoomType(type)
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private fun requestSwitchRoomType(type: Int) {
|
||||
dialogManager.showProgressDialog(context)
|
||||
OpenRoomHelper.updateRoomInfoRx(
|
||||
AvRoomDataManager.get().mCurrentRoomInfo,
|
||||
type,
|
||||
0
|
||||
).compose(bindToLifecycle()).subscribe({
|
||||
dialogManager.dismissDialog()
|
||||
finish()
|
||||
}, {
|
||||
SingleToastUtil.showToast(it.message)
|
||||
dialogManager.dismissDialog()
|
||||
})
|
||||
}
|
||||
|
||||
override fun needSteepStateBar(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun setStatusBar() {
|
||||
super.setStatusBar()
|
||||
StatusBarUtil.transparencyBar(this)
|
||||
StatusBarUtil.StatusBarLightMode(this)
|
||||
}
|
||||
}
|
@@ -15,8 +15,12 @@ import androidx.annotation.Nullable;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.chwl.app.avroom.activity.AVRoomActivity;
|
||||
import com.chwl.app.utils.AvatarHelper;
|
||||
import com.chwl.library.widget.SVGAView;
|
||||
import com.chwl.core.utils.extension.StringExtensionKt;
|
||||
import com.coorchice.library.SuperTextView;
|
||||
import com.example.lib_utils.StringUtils2;
|
||||
import com.netease.nim.uikit.common.util.string.StringUtil;
|
||||
import com.opensource.svgaplayer.SVGAImageView;
|
||||
import com.chwl.app.R;
|
||||
@@ -55,6 +59,9 @@ public abstract class BaseMicroViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
public static final String MICRO_TYPE_DATING = "dating";
|
||||
public static final String MICRO_TYPE_DATING_VIP = "dating_vip";
|
||||
public static final String MICRO_TYPE_SINGLE = "single";
|
||||
public static final String MICRO_TYPE_PARTY = "party";
|
||||
public static final String MICRO_TYPE_REVELRY = "revelry";
|
||||
|
||||
protected static final int TYPE_KING = 2;
|
||||
protected static final int TYPE_BOSS = 1;
|
||||
protected static final int TYPE_NORMAL = 0;
|
||||
@@ -76,11 +83,16 @@ public abstract class BaseMicroViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
RoomQueueInfo roomQueueInfo = AvRoomDataManager.get().getRoomQueueMemberInfoByMicPosition(position - 1);
|
||||
if (roomQueueInfo == null) return;
|
||||
NormalMicroViewHolder holder = (NormalMicroViewHolder) viewHolder;
|
||||
holder.micPositionNameOffset = getMicPositionNameOffset();
|
||||
holder.bind(roomQueueInfo, position - 1);
|
||||
}
|
||||
|
||||
public abstract String microType();
|
||||
|
||||
protected int getMicPositionNameOffset() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 9;
|
||||
@@ -137,9 +149,7 @@ public abstract class BaseMicroViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
SVGAImageView ivHalo;
|
||||
|
||||
@Nullable
|
||||
ImageView ivHeadWear;
|
||||
@Nullable
|
||||
TextView tvNumber;
|
||||
SVGAView ivHeadWear;
|
||||
@Nullable
|
||||
ImageView ivCharmLevelTag;
|
||||
|
||||
@@ -148,6 +158,7 @@ public abstract class BaseMicroViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
|
||||
RoomQueueInfo info;
|
||||
int position = TYPE_INVALID;
|
||||
int micPositionNameOffset = 2;
|
||||
|
||||
NormalMicroViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
@@ -158,13 +169,15 @@ public abstract class BaseMicroViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
ivAvatar = itemView.findViewById(R.id.avatar);
|
||||
ivHeadWear = itemView.findViewById(R.id.iv_head_wear);
|
||||
tvNick = itemView.findViewById(R.id.nick);
|
||||
tvNumber = itemView.findViewById(R.id.tv_number);
|
||||
ivCharmLevelTag = itemView.findViewById(R.id.iv_charm_level_tag);
|
||||
ivKickGuard = itemView.findViewById(R.id.iv_kick_guard);
|
||||
|
||||
ivUpImage.setOnClickListener(this);
|
||||
ivLockImage.setOnClickListener(this);
|
||||
ivAvatar.setOnClickListener(this);
|
||||
if (ivHeadWear != null) {
|
||||
ivHeadWear.bindCache(AVRoomActivity.getSvgaCache());
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
@@ -270,6 +283,7 @@ public abstract class BaseMicroViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
private void clearHeadWear() {
|
||||
if (ivHeadWear == null) return;
|
||||
ivHeadWear.clearAnimation();
|
||||
ivHeadWear.stopAnimation();
|
||||
ivHeadWear.setImageDrawable(null);
|
||||
ivHeadWear.setTag(R.id.mic_item_head_wear, null);
|
||||
ivHeadWear.setVisibility(View.GONE);
|
||||
@@ -277,41 +291,29 @@ public abstract class BaseMicroViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
|
||||
protected void setDefalutText(int index) {
|
||||
tvNick.setTextColor(Color.WHITE);
|
||||
tvNick.setText(ResUtil.getString(R.string.avroom_adapter_basemicroviewadapter_01));
|
||||
|
||||
if (tvNumber != null) {
|
||||
tvNumber.setBackgroundResource(R.drawable.icon_bg_number_default);
|
||||
tvNumber.setTextColor(Color.WHITE);
|
||||
tvNumber.setText(String.valueOf(index + 1));
|
||||
}
|
||||
tvNick.setText(getMicPositionName(index));
|
||||
}
|
||||
|
||||
protected String getMicPositionName(int index) {
|
||||
return "NO." + (index + micPositionNameOffset);
|
||||
}
|
||||
|
||||
protected void setSelectText(int index, String nick, int gender) {
|
||||
tvNick.setText(StringExtensionKt.subAndReplaceDot(StringUtil.removeBlanks(nick), 7));
|
||||
tvNick.setTextColor(context.getResources().getColor(R.color.white));
|
||||
|
||||
if (tvNumber != null) {
|
||||
if (AvRoomDataManager.get().isOpenPKMode()) { // pk模式不加性别背景
|
||||
tvNumber.setBackgroundResource(R.drawable.icon_bg_number_default);
|
||||
tvNumber.setTextColor(context.getResources().getColor(R.color.white));
|
||||
} else {
|
||||
tvNumber.setBackgroundResource(gender == 1 ? R.drawable.bg_number_male : R.drawable.bg_number_female);
|
||||
tvNumber.setTextColor(context.getResources().getColor(R.color.white));
|
||||
}
|
||||
tvNumber.setText(String.valueOf(index + 1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//优先使用MicMemberInfo里面的头饰
|
||||
private void updateNobleView(MicMemberInfo chatRoomMember) {
|
||||
if (ivHeadWear == null) return;
|
||||
String headWear = chatRoomMember.getHeadWearUrl();
|
||||
int headWearType = chatRoomMember.getHeadWearType();
|
||||
if (TextUtils.isEmpty(headWear)) {
|
||||
headWear = NobleUtil.getHeadResource(HeadWearInfo.EFFECT, chatRoomMember) != null ?
|
||||
NobleUtil.getHeadResource(HeadWearInfo.EFFECT, chatRoomMember) :
|
||||
NobleUtil.getHeadResource(HeadWearInfo.PIC, chatRoomMember);
|
||||
String type = NobleUtil.getHeadResource(HeadWearInfo.TYPE, chatRoomMember);
|
||||
headWearType = StringUtils2.INSTANCE.toInt(type);
|
||||
}
|
||||
String nobleHeadWear = (String) NobleUtil.getResource(NobleResourceType.KEY_HEAD_WEAR, chatRoomMember);
|
||||
if (!TextUtils.isEmpty(headWear)) {
|
||||
@@ -319,7 +321,7 @@ public abstract class BaseMicroViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
//只有头饰发生改变才更新,防止闪烁
|
||||
if (!headWear.equals(ivHeadWear.getTag(R.id.mic_item_head_wear))) {
|
||||
ivHeadWear.setTag(R.id.mic_item_head_wear, headWear);
|
||||
NobleUtil.loadMicHeadWear(headWear, ivHeadWear, R.id.mic_item_head_wear, headWear);
|
||||
AvatarHelper.loadAvatarFrame(ivHeadWear, headWear, headWearType);
|
||||
}
|
||||
} else if (!TextUtils.isEmpty(nobleHeadWear)) {
|
||||
// 头饰
|
||||
@@ -500,10 +502,10 @@ public abstract class BaseMicroViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
//控制最高最低头饰
|
||||
Observer<Integer> headWearObserver = headWearValue -> {
|
||||
if (ivCharmLevelTag == null) return;
|
||||
ivCharmLevelTag.setVisibility(View.GONE);
|
||||
if (headWearValue == 1) {
|
||||
ivCharmLevelTag.setVisibility(View.VISIBLE);
|
||||
ivCharmLevelTag.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_charm_level_min));
|
||||
ivCharmLevelTag.setVisibility(View.GONE);
|
||||
// ivCharmLevelTag.setVisibility(View.VISIBLE);
|
||||
// ivCharmLevelTag.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_charm_level_min));
|
||||
} else if (headWearValue == 2) {
|
||||
ivCharmLevelTag.setVisibility(View.VISIBLE);
|
||||
ivCharmLevelTag.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_charm_level_max));
|
||||
@@ -586,6 +588,7 @@ public abstract class BaseMicroViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
protected void setDefalutText(int index) {
|
||||
//重新覆盖掉用户名的逻辑
|
||||
tvNick.setText("");
|
||||
tvNick.setVisibility(View.GONE);
|
||||
tvNick.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
|
||||
ivTag.setVisibility(View.GONE);
|
||||
}
|
||||
@@ -593,6 +596,7 @@ public abstract class BaseMicroViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
@Override
|
||||
protected void setSelectText(int index, String nick, int gender) {
|
||||
super.setSelectText(index, nick, gender);
|
||||
tvNick.setVisibility(View.VISIBLE);
|
||||
if (UserModel.get().getCacheLoginUserInfo() != null &&
|
||||
UserModel.get().getCacheLoginUserInfo().getUserInfoSkillVo() != null) {
|
||||
if (AvRoomDataManager.get().isRoomOwner() && !TextUtils.isEmpty(UserModel.get().getCacheLoginUserInfo().getUserInfoSkillVo().getSkillTag())) {
|
||||
|
@@ -27,6 +27,11 @@ public class CpMicroViewAdapter extends BaseMicroViewAdapter {
|
||||
return BaseMicroViewAdapter.MICRO_TYPE_CP;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMicPositionNameOffset() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindToRecyclerView(RecyclerView recyclerView) {
|
||||
GridLayoutManager layoutManager = new GridLayoutManager(context, 3);
|
||||
|
@@ -27,6 +27,9 @@ import com.chwl.library.utils.ResUtil
|
||||
* @date 2017/12/18
|
||||
*/
|
||||
class DatingMicroViewAdapter(context: Context?) : BaseMicroViewAdapter(context) {
|
||||
override fun getMicPositionNameOffset(): Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
/**
|
||||
* Set LayoutManager and bind this to RecyclerView
|
||||
@@ -146,6 +149,7 @@ class DatingMicroViewAdapter(context: Context?) : BaseMicroViewAdapter(context)
|
||||
if (info.mChatRoomMember == null) {
|
||||
tvNick.alpha = 1f
|
||||
tvNick.text = "主持人"
|
||||
tvNick.isVisible = true
|
||||
ivVipWear.isVisible = false
|
||||
} else {
|
||||
if (info.mChatRoomMember.isVipMic) {
|
||||
@@ -222,7 +226,6 @@ class DatingMicroViewAdapter(context: Context?) : BaseMicroViewAdapter(context)
|
||||
super.bind(info, position)
|
||||
ivVipWear.isVisible = true
|
||||
ivHeadWear?.isVisible = false
|
||||
tvNumber?.isVisible = false
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -54,7 +54,7 @@ class GameMicroViewAdapter(context: Context?) : BaseMicroViewAdapter(context) {
|
||||
width = when (itemCount) {
|
||||
6 -> ScreenUtil.screenWidth / 6
|
||||
7 -> ScreenUtil.screenWidth / 7
|
||||
else -> (ScreenUtil.screenWidth / 7.5f).toInt()
|
||||
else -> (ScreenUtil.screenWidth / 6f).toInt()
|
||||
}
|
||||
}
|
||||
super.bind(info, position)
|
||||
|
@@ -2,7 +2,6 @@ package com.chwl.app.avroom.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -13,8 +12,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.core.bean.RoomQueueInfo;
|
||||
import com.chwl.core.manager.AvRoomDataManager;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
|
||||
/**
|
||||
* @author xiaoyu
|
||||
@@ -27,6 +24,11 @@ public class MicroViewAdapter extends BaseMicroViewAdapter {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMicPositionNameOffset() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set LayoutManager and bind this to RecyclerView
|
||||
*/
|
||||
@@ -62,15 +64,6 @@ public class MicroViewAdapter extends BaseMicroViewAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, final int position) {
|
||||
RoomQueueInfo roomQueueInfo = AvRoomDataManager.get().getRoomQueueMemberInfoByMicPosition(position - 1);
|
||||
if (roomQueueInfo == null) {
|
||||
return;
|
||||
}
|
||||
NormalMicroViewHolder holder = (NormalMicroViewHolder) viewHolder;
|
||||
holder.bind(roomQueueInfo, position - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String microType() {
|
||||
@@ -91,27 +84,27 @@ public class MicroViewAdapter extends BaseMicroViewAdapter {
|
||||
@Override
|
||||
public void bind(RoomQueueInfo info, int position) {
|
||||
super.bind(info, position);
|
||||
if (position == 7) {
|
||||
ivUpImage.setImageResource(R.drawable.icon_room_up_micro_vip);
|
||||
} else {
|
||||
// if (position == 7) {
|
||||
// ivUpImage.setImageResource(R.drawable.icon_room_up_micro_vip);
|
||||
// } else {
|
||||
ivUpImage.setImageResource(R.drawable.icon_room_up_micro);
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void setDefalutText(int index) {
|
||||
if (index == 7) {
|
||||
tvNick.setTextColor(Color.WHITE);
|
||||
tvNick.setText(ResUtil.getString(R.string.avroom_adapter_microviewadapter_01));
|
||||
if (tvNumber != null) {
|
||||
tvNumber.setBackgroundResource(R.drawable.shape_micro_vip);
|
||||
tvNumber.setTextColor(Color.WHITE);
|
||||
tvNumber.setText(String.valueOf((index + 1)));
|
||||
}
|
||||
} else {
|
||||
// if (index == 7) {
|
||||
// tvNick.setTextColor(Color.WHITE);
|
||||
// tvNick.setText(ResUtil.getString(R.string.avroom_adapter_microviewadapter_01));
|
||||
// if (tvNumber != null) {
|
||||
// tvNumber.setBackgroundResource(R.drawable.shape_micro_vip);
|
||||
// tvNumber.setTextColor(Color.WHITE);
|
||||
// tvNumber.setText(String.valueOf((index + 1)));
|
||||
// }
|
||||
// } else {
|
||||
super.setDefalutText(index);
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -12,6 +12,9 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.chwl.app.utils.NamePlateHelper;
|
||||
import com.chwl.core.level.UserLevelVo;
|
||||
import com.chwl.core.room.bean.RoomOnlineUserBean;
|
||||
import com.netease.nim.uikit.impl.cache.NimUserInfoCache;
|
||||
import com.netease.nimlib.sdk.RequestCallbackWrapper;
|
||||
import com.netease.nimlib.sdk.uinfo.constant.GenderEnum;
|
||||
@@ -41,19 +44,16 @@ import io.reactivex.disposables.Disposable;
|
||||
* @author Administrator
|
||||
* @date 2017/12/4
|
||||
*/
|
||||
public class OnlineUserAdapter extends BaseMultiItemQuickAdapter<OnlineChatMember, BaseViewHolder> {
|
||||
|
||||
public class OnlineUserAdapter extends BaseMultiItemQuickAdapter<RoomOnlineUserBean, BaseViewHolder> {
|
||||
private boolean mIsHomeParty;
|
||||
private Disposable mDisposable;
|
||||
private Context context;
|
||||
private OnRoomOnlineNumberChangeListener mListener;
|
||||
|
||||
public OnlineUserAdapter(Context context, boolean isHomeParty) {
|
||||
super(null);
|
||||
addItemType(OnlineChatMember.NORMAL, R.layout.list_item_online_user);
|
||||
addItemType(OnlineChatMember.NOBLE, R.layout.list_item_online_user_mystery);
|
||||
addItemType(RoomOnlineUserBean.NORMAL, R.layout.list_item_online_user);
|
||||
addItemType(RoomOnlineUserBean.NOBLE, R.layout.list_item_online_user_mystery);
|
||||
mIsHomeParty = isHomeParty;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,149 +63,76 @@ public class OnlineUserAdapter extends BaseMultiItemQuickAdapter<OnlineChatMembe
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(@NonNull BaseViewHolder baseViewHolder, OnlineChatMember onlineChatMember) {
|
||||
if (onlineChatMember != null && onlineChatMember.chatRoomMember != null) {
|
||||
if (onlineChatMember.getItemType() == OnlineChatMember.NORMAL) {
|
||||
setNormalData(baseViewHolder, onlineChatMember);
|
||||
} else {
|
||||
setMysteryData();
|
||||
}
|
||||
protected void convert(@NonNull BaseViewHolder helper, RoomOnlineUserBean item) {
|
||||
if (item.getItemType() == OnlineChatMember.NOBLE) {
|
||||
return;
|
||||
}
|
||||
// 性别
|
||||
final ImageView sexImage = helper.getView(R.id.sex);
|
||||
if (item.getGender() == 1) {
|
||||
sexImage.setVisibility(View.VISIBLE);
|
||||
sexImage.setImageResource(R.drawable.ic_gender_male);
|
||||
} else if (item.getGender() == 2) {
|
||||
sexImage.setVisibility(View.VISIBLE);
|
||||
sexImage.setImageResource(R.drawable.ic_gender_female);
|
||||
} else {
|
||||
sexImage.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void setMysteryData() {
|
||||
//do nothing
|
||||
}
|
||||
// 昵称
|
||||
helper.setText(R.id.nick, RegexUtil.getPrintableString(item.getNick()));
|
||||
|
||||
private void setNormalData(BaseViewHolder baseViewHolder, OnlineChatMember onlineChatMember) {
|
||||
setSexData(baseViewHolder, onlineChatMember);
|
||||
|
||||
ImageView roomOnlineTag = baseViewHolder.getView(R.id.room_online_tag);
|
||||
ImageView managerLogo = baseViewHolder.getView(R.id.manager_logo);
|
||||
// roomOnlineTag.setVisibility(onlineChatMember.isOnMic ? View.VISIBLE : View.GONE);
|
||||
roomOnlineTag.setVisibility(View.GONE);
|
||||
managerLogo.setVisibility((onlineChatMember.isAdmin || onlineChatMember.isRoomOwer)
|
||||
? View.VISIBLE : View.GONE);
|
||||
managerLogo.setVisibility(View.GONE);
|
||||
// managerLogo.setImageResource(onlineChatMember.isAdmin ? R.drawable.icon_admin_logo
|
||||
// : R.drawable.icon_user_list_room_ownner);
|
||||
|
||||
baseViewHolder.setText(R.id.nick, RegexUtil.getPrintableString(onlineChatMember.chatRoomMember.getNick()));
|
||||
|
||||
NobleAvatarView nobleAvatarView = baseViewHolder.getView(R.id.noble_avatar_view);
|
||||
// 头像
|
||||
NobleAvatarView nobleAvatarView = helper.getView(R.id.noble_avatar_view);
|
||||
nobleAvatarView.setSize(37, 54, 0);
|
||||
nobleAvatarView.setData(onlineChatMember.chatRoomMember);
|
||||
nobleAvatarView.setData(item);
|
||||
|
||||
// 官字
|
||||
baseViewHolder.getView(R.id.iv_user_official).setVisibility(onlineChatMember.isOfficial() ? View.VISIBLE : View.GONE);
|
||||
helper.getView(R.id.iv_user_official).setVisibility(item.isOfficial() ? View.VISIBLE : View.GONE);
|
||||
|
||||
// 管理
|
||||
ImageView ivManager = helper.getView(R.id.manager_logo);
|
||||
if (item.getMemberType() != null && item.getMemberType().equals("MANAGER")) {
|
||||
ivManager.setVisibility(View.VISIBLE);
|
||||
ivManager.setImageResource(R.drawable.icon_admin_logo);
|
||||
} else if (item.getMemberType() != null && item.getMemberType().equals("CREATOR")) {
|
||||
ivManager.setVisibility(View.VISIBLE);
|
||||
ivManager.setImageResource(R.drawable.icon_user_list_room_ownner);
|
||||
} else {
|
||||
ivManager.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// 在麦
|
||||
ImageView ivMic = helper.getView(R.id.room_online_tag);
|
||||
ivMic.setVisibility(item.isInMic() ? View.VISIBLE : View.GONE);
|
||||
|
||||
|
||||
//等级
|
||||
UserLevelVo levelVo = item.getUserLevelVo();
|
||||
String experLevelUrl = null;
|
||||
String charmLevelUrl = null;
|
||||
if (levelVo != null) {
|
||||
experLevelUrl = levelVo.getExperUrl();
|
||||
charmLevelUrl = levelVo.getCharmUrl();
|
||||
}
|
||||
//经验等级
|
||||
AppCompatImageView ivUserExper = baseViewHolder.getView(R.id.iv_user_exper);
|
||||
String experLevelUrl = NobleUtil.getLevel(UserLevelResourceType.EXPER_URL, onlineChatMember.chatRoomMember);
|
||||
AppCompatImageView ivUserExper = helper.getView(R.id.iv_user_exper);
|
||||
boolean isExperLevelUrlEmpty = TextUtils.isEmpty(experLevelUrl);
|
||||
ivUserExper.setVisibility(!isExperLevelUrlEmpty ? View.VISIBLE : View.GONE);
|
||||
if (!isExperLevelUrlEmpty) {
|
||||
ImageLoadUtils.loadImage(mContext, experLevelUrl, ivUserExper);
|
||||
}
|
||||
//魅力等级
|
||||
AppCompatImageView ivUserCharm = baseViewHolder.getView(R.id.iv_user_charm);
|
||||
String charmLevelUrl = NobleUtil.getLevel(UserLevelResourceType.CHARM_URL, onlineChatMember.chatRoomMember);
|
||||
AppCompatImageView ivUserCharm = helper.getView(R.id.iv_user_charm);
|
||||
boolean isCharmLevelUrlEmpty = TextUtils.isEmpty(charmLevelUrl);
|
||||
ivUserCharm.setVisibility(!isCharmLevelUrlEmpty ? View.VISIBLE : View.GONE);
|
||||
if (!isCharmLevelUrlEmpty) {
|
||||
ImageLoadUtils.loadImage(mContext, charmLevelUrl, ivUserCharm);
|
||||
}
|
||||
|
||||
// 官方主播铭牌标识
|
||||
String fixWord = NobleUtil.getLevel(UserInfo.OAC_NAME, onlineChatMember.chatRoomMember);
|
||||
String iconPic = NobleUtil.getLevel(UserInfo.OAC_ICON, onlineChatMember.chatRoomMember);
|
||||
View inOfficialMask = baseViewHolder.getView(R.id.in_official_mask);
|
||||
if (!TextUtils.isEmpty(fixWord) && !TextUtils.isEmpty(iconPic)) {
|
||||
inOfficialMask.setVisibility(View.VISIBLE);
|
||||
TextView tvOfficialMask = inOfficialMask.findViewById(R.id.tv_official_mask);
|
||||
if (tvOfficialMask != null) {
|
||||
tvOfficialMask.setText(fixWord);
|
||||
}
|
||||
|
||||
ImageView ivOfficialMask = inOfficialMask.findViewById(R.id.iv_official_mask);
|
||||
if (ivOfficialMask != null) {
|
||||
ImageLoadUtils.loadImage(mContext, iconPic, ivOfficialMask);
|
||||
}
|
||||
|
||||
} else {
|
||||
inOfficialMask.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// 铭牌
|
||||
String namePlateWord = NobleUtil.getLevel(UserInfo.NAMEPLATE_WORD, onlineChatMember.chatRoomMember);
|
||||
String namePlatePic = NobleUtil.getLevel(UserInfo.NAMEPLATE_PIC, onlineChatMember.chatRoomMember);
|
||||
View inNamePlate = baseViewHolder.getView(R.id.in_nameplate);
|
||||
if (!TextUtils.isEmpty(namePlateWord) && !TextUtils.isEmpty(namePlatePic)) {
|
||||
inNamePlate.setVisibility(View.VISIBLE);
|
||||
TextView tvNamePlate = inNamePlate.findViewById(R.id.tv_official_mask);
|
||||
if (tvNamePlate != null) {
|
||||
tvNamePlate.setText(namePlateWord);
|
||||
}
|
||||
|
||||
ImageView ivNamePlate = inNamePlate.findViewById(R.id.iv_official_mask);
|
||||
if (ivNamePlate != null) {
|
||||
ImageLoadUtils.loadImage(mContext, namePlatePic, ivNamePlate);
|
||||
}
|
||||
|
||||
} else {
|
||||
inNamePlate.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
AppCompatImageView ivUserLevel = baseViewHolder.getView(R.id.iv_noble_level);
|
||||
String resource = (String) NobleUtil.getResource(NobleResourceType.KEY_BADGE, onlineChatMember.chatRoomMember);
|
||||
if (TextUtils.isEmpty(resource)) {
|
||||
ivUserLevel.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
ivUserLevel.setVisibility(View.VISIBLE);
|
||||
NobleUtil.loadResource(resource, ivUserLevel);
|
||||
}
|
||||
|
||||
private void setSexData(BaseViewHolder baseViewHolder, OnlineChatMember onlineChatMember) {
|
||||
final ImageView sexImage = baseViewHolder.getView(R.id.sex);
|
||||
String gender = NobleUtil.getLevel(UserInfo.GENDER, onlineChatMember.chatRoomMember);
|
||||
if ("1".equals(gender)) {
|
||||
sexImage.setVisibility(View.VISIBLE);
|
||||
sexImage.setImageResource(R.drawable.ic_gender_male);
|
||||
} else if ("2".equals(gender)) {
|
||||
sexImage.setVisibility(View.VISIBLE);
|
||||
sexImage.setImageResource(R.drawable.ic_gender_female);
|
||||
} else {
|
||||
NimUserInfo nimUserInfo = NimUserInfoCache.getInstance().getUserInfo(onlineChatMember.chatRoomMember.getAccount());
|
||||
if (nimUserInfo == null) {
|
||||
NimUserInfoCache.getInstance().getUserInfoFromRemote(onlineChatMember.chatRoomMember.getAccount(),
|
||||
new RequestCallbackWrapper<NimUserInfo>() {
|
||||
@Override
|
||||
public void onResult(int i, NimUserInfo nimUserInfo, Throwable throwable) {
|
||||
if (nimUserInfo != null) {
|
||||
if (nimUserInfo.getGenderEnum() == GenderEnum.MALE) {
|
||||
sexImage.setVisibility(View.VISIBLE);
|
||||
sexImage.setImageResource(R.drawable.ic_gender_male);
|
||||
} else if (nimUserInfo.getGenderEnum() == GenderEnum.FEMALE) {
|
||||
sexImage.setVisibility(View.VISIBLE);
|
||||
sexImage.setImageResource(R.drawable.ic_gender_female);
|
||||
} else {
|
||||
sexImage.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (nimUserInfo.getGenderEnum() == GenderEnum.MALE) {
|
||||
sexImage.setVisibility(View.VISIBLE);
|
||||
sexImage.setImageResource(R.drawable.ic_gender_male);
|
||||
} else if (nimUserInfo.getGenderEnum() == GenderEnum.FEMALE) {
|
||||
sexImage.setVisibility(View.VISIBLE);
|
||||
sexImage.setImageResource(R.drawable.ic_gender_female);
|
||||
} else {
|
||||
sexImage.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
View inNamePlate = helper.getView(R.id.in_nameplate);
|
||||
NamePlateHelper.INSTANCE.load(inNamePlate, inNamePlate.findViewById(R.id.tv_official_mask), inNamePlate.findViewById(R.id.iv_official_mask), item);
|
||||
}
|
||||
|
||||
private void registerRoomEvent() {
|
||||
@@ -242,7 +169,7 @@ public class OnlineUserAdapter extends BaseMultiItemQuickAdapter<OnlineChatMembe
|
||||
updateMemberIn(roomEvent);
|
||||
} else if (event == RoomEvent.ROOM_MEMBER_EXIT) {
|
||||
if (mListener != null) {
|
||||
mListener.onMemberExit(roomEvent.getAccount(), mData);
|
||||
mListener.onMemberExit(roomEvent.getAccount());
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -250,19 +177,19 @@ public class OnlineUserAdapter extends BaseMultiItemQuickAdapter<OnlineChatMembe
|
||||
|
||||
private void updateMemberIn(RoomEvent roomEvent) {
|
||||
if (mListener != null) {
|
||||
mListener.onMemberIn(roomEvent.getAccount(), mData);
|
||||
mListener.onMemberIn(roomEvent.getAccount());
|
||||
}
|
||||
}
|
||||
|
||||
private void updateManager(RoomEvent roomEvent) {
|
||||
if (mListener != null)
|
||||
mListener.onUpdateMemberManager(roomEvent.getAccount(),
|
||||
roomEvent.getEvent() == RoomEvent.ROOM_MANAGER_REMOVE, mData);
|
||||
roomEvent.getEvent() == RoomEvent.ROOM_MANAGER_REMOVE);
|
||||
}
|
||||
|
||||
private void updateDownUpMic(String account, boolean isUpMic) {
|
||||
if (mListener != null) {
|
||||
mListener.onMemberDownUpMic(account, isUpMic, mData);
|
||||
mListener.onMemberDownUpMic(account, isUpMic);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,34 +210,29 @@ public class OnlineUserAdapter extends BaseMultiItemQuickAdapter<OnlineChatMembe
|
||||
*
|
||||
* @param account
|
||||
*/
|
||||
void onMemberIn(String account, List<OnlineChatMember> dataList);
|
||||
void onMemberIn(String account);
|
||||
|
||||
/**
|
||||
* 成员出去回调
|
||||
*
|
||||
* @param account
|
||||
* @param dataList
|
||||
*/
|
||||
void onMemberExit(String account, List<OnlineChatMember> dataList);
|
||||
void onMemberExit(String account);
|
||||
|
||||
/**
|
||||
* 成员上下麦更新
|
||||
*
|
||||
* @param account
|
||||
* @param isUpMic
|
||||
* @param dataList
|
||||
*/
|
||||
void onMemberDownUpMic(String account, boolean isUpMic,
|
||||
List<OnlineChatMember> dataList);
|
||||
void onMemberDownUpMic(String account, boolean isUpMic);
|
||||
|
||||
/**
|
||||
* 设置管理员回调
|
||||
*
|
||||
* @param account
|
||||
* @param dataList
|
||||
*/
|
||||
void onUpdateMemberManager(String account, boolean isRemoveManager,
|
||||
List<OnlineChatMember> dataList);
|
||||
void onUpdateMemberManager(String account, boolean isRemoveManager);
|
||||
|
||||
void addMemberBlack();
|
||||
}
|
||||
|
@@ -0,0 +1,79 @@
|
||||
package com.chwl.app.avroom.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.core.bean.RoomQueueInfo;
|
||||
import com.chwl.core.manager.AvRoomDataManager;
|
||||
|
||||
/**
|
||||
* @author xiaoyu
|
||||
* @date 2017/12/18
|
||||
*/
|
||||
|
||||
public class PartyMicroViewAdapter extends BaseMicroViewAdapter {
|
||||
|
||||
public PartyMicroViewAdapter(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set LayoutManager and bind this to RecyclerView
|
||||
*/
|
||||
@Override
|
||||
public void bindToRecyclerView(RecyclerView recyclerView) {
|
||||
GridLayoutManager layoutManager = new GridLayoutManager(context, 5);
|
||||
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
recyclerView.setAdapter(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View item;
|
||||
item = LayoutInflater.from(parent.getContext()).
|
||||
inflate(R.layout.list_item_micro, parent, false);
|
||||
return new MicroViewHolder(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String microType() {
|
||||
return BaseMicroViewAdapter.MICRO_TYPE_PARTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return TYPE_NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
class MicroViewHolder extends GiftValueViewHolder {
|
||||
MicroViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bind(RoomQueueInfo info, int position) {
|
||||
super.bind(info, position);
|
||||
ivUpImage.setImageResource(R.drawable.icon_room_up_micro);
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void setDefalutText(int index) {
|
||||
super.setDefalutText(index);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
package com.chwl.app.avroom.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.core.bean.RoomQueueInfo;
|
||||
import com.chwl.core.manager.AvRoomDataManager;
|
||||
|
||||
/**
|
||||
* @author xiaoyu
|
||||
* @date 2017/12/18
|
||||
*/
|
||||
|
||||
public class RevelryMicroViewAdapter extends BaseMicroViewAdapter {
|
||||
|
||||
public RevelryMicroViewAdapter(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set LayoutManager and bind this to RecyclerView
|
||||
*/
|
||||
@Override
|
||||
public void bindToRecyclerView(RecyclerView recyclerView) {
|
||||
GridLayoutManager layoutManager = new GridLayoutManager(context, 5);
|
||||
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
recyclerView.setAdapter(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View item;
|
||||
item = LayoutInflater.from(parent.getContext()).
|
||||
inflate(R.layout.list_item_micro, parent, false);
|
||||
return new MicroViewHolder(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String microType() {
|
||||
return BaseMicroViewAdapter.MICRO_TYPE_REVELRY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return TYPE_NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 15;
|
||||
}
|
||||
|
||||
class MicroViewHolder extends GiftValueViewHolder {
|
||||
MicroViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bind(RoomQueueInfo info, int position) {
|
||||
super.bind(info, position);
|
||||
ivUpImage.setImageResource(R.drawable.icon_room_up_micro);
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void setDefalutText(int index) {
|
||||
super.setDefalutText(index);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
package com.chwl.app.avroom.adapter
|
||||
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import androidx.core.view.isVisible
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.DataSource
|
||||
import com.bumptech.glide.load.engine.GlideException
|
||||
import com.bumptech.glide.request.RequestListener
|
||||
import com.bumptech.glide.request.target.Target
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.ui.utils.load
|
||||
|
||||
class RoomBgAdapter : BaseQuickAdapter<String, BaseViewHolder>(R.layout.room_bg_setting_item) {
|
||||
private var selectItem: String? = null
|
||||
override fun convertPayloads(
|
||||
helper: BaseViewHolder,
|
||||
item: String?,
|
||||
payloads: MutableList<Any>
|
||||
) {
|
||||
super.convertPayloads(helper, item, payloads)
|
||||
convertStatus(helper, item)
|
||||
}
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: String?) {
|
||||
val imageView = helper.getView<ImageView>(R.id.iv_image)
|
||||
imageView.load(item)
|
||||
convertStatus(helper, item)
|
||||
}
|
||||
|
||||
private fun convertStatus(helper: BaseViewHolder, item: String?) {
|
||||
val statusView = helper.getView<View>(R.id.tv_status)
|
||||
statusView.isVisible = item == selectItem
|
||||
}
|
||||
|
||||
fun getSelectItem() = selectItem
|
||||
|
||||
fun selectItem(url: String?) {
|
||||
selectItem = url
|
||||
notifyItemRangeChanged(0, itemCount, true)
|
||||
}
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
package com.chwl.app.avroom.adapter
|
||||
|
||||
import android.widget.ImageView
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.ui.utils.load
|
||||
import com.chwl.core.room.bean.RoomIcon
|
||||
import com.chwl.core.room.game.bean.GameInfo
|
||||
|
||||
class RoomGameListAdapter :
|
||||
BaseQuickAdapter<GameInfo, BaseViewHolder>(R.layout.room_gameplay_item2) {
|
||||
override fun convert(helper: BaseViewHolder, item: GameInfo?) {
|
||||
helper.setText(R.id.tv_name, item?.name)
|
||||
val iconView = helper.getView<ImageView>(R.id.iv_icon)
|
||||
iconView.load(item?.pic2)
|
||||
}
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
package com.chwl.app.avroom.adapter
|
||||
|
||||
import android.widget.ImageView
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.bean.RoomGameplayItem
|
||||
import com.chwl.app.ui.utils.load
|
||||
|
||||
class RoomGameplayAdapter :
|
||||
BaseQuickAdapter<RoomGameplayItem, BaseViewHolder>(R.layout.room_gameplay_item2) {
|
||||
override fun convert(helper: BaseViewHolder, item: RoomGameplayItem?) {
|
||||
helper.setText(R.id.tv_name, item?.getName())
|
||||
val iconView = helper.getView<ImageView>(R.id.iv_icon)
|
||||
val iconRes = item?.getIconRes()
|
||||
if (iconRes != null) {
|
||||
iconView.setImageResource(iconRes)
|
||||
} else {
|
||||
val iconUrl = item?.getIconUrl()
|
||||
iconView.load(iconUrl ?: "")
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,106 @@
|
||||
package com.chwl.app.avroom.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.view.Gravity;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.ui.widget.XRecyclerView.ScaleTransitionPagerTitleView;
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter;
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.commonnavigator.abs.IPagerIndicator;
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.commonnavigator.abs.IPagerTitleView;
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.commonnavigator.indicators.GradientLineRoundPagerIndicator;
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RoomMessageIndicatorAdapter extends CommonNavigatorAdapter {
|
||||
private final Context mContext;
|
||||
private final List<? extends CharSequence> mTitleList;
|
||||
|
||||
private int textSize = 14;
|
||||
private float minScale = 1f;
|
||||
private boolean showIndicator = true;
|
||||
private OnItemSelectListener mOnItemSelectListener;
|
||||
|
||||
public RoomMessageIndicatorAdapter(Context context, List<? extends CharSequence> charSequences) {
|
||||
this.mContext = context;
|
||||
this.mTitleList = charSequences;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mTitleList == null ? 0 : mTitleList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPagerTitleView getTitleView(Context context, final int i) {
|
||||
ScaleTransitionPagerTitleView scaleTransitionPagerTitleView = new ScaleTransitionPagerTitleView(context, true);
|
||||
scaleTransitionPagerTitleView.setNormalColor(ContextCompat.getColor(context, R.color.white_transparent_60));
|
||||
scaleTransitionPagerTitleView.setSelectedColor(ContextCompat.getColor(context, R.color.color_FFFFFF));
|
||||
scaleTransitionPagerTitleView.setMinScale(minScale);
|
||||
scaleTransitionPagerTitleView.setTextSize(textSize);
|
||||
int padding = UIUtil.dip2px(context, 13);
|
||||
scaleTransitionPagerTitleView.setPadding(padding, 0, padding, 0);
|
||||
scaleTransitionPagerTitleView.setText(mTitleList.get(i));
|
||||
scaleTransitionPagerTitleView.setOnClickListener(view -> {
|
||||
if (mOnItemSelectListener != null) {
|
||||
mOnItemSelectListener.onItemSelect(i, scaleTransitionPagerTitleView);
|
||||
}
|
||||
|
||||
});
|
||||
return scaleTransitionPagerTitleView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPagerIndicator getIndicator(Context context) {
|
||||
LinePagerIndicator indicator = new LinePagerIndicator(context);
|
||||
indicator.setMode(LinePagerIndicator.MODE_EXACTLY);
|
||||
indicator.setLineHeight(UIUtil.dip2px(mContext, 1.5));
|
||||
indicator.setRoundRadius(UIUtil.dip2px(mContext, 1));
|
||||
indicator.setLineWidth(UIUtil.dip2px(mContext, 8));
|
||||
indicator.setColors(context.getResources().getColor(R.color.color_10ECD6));
|
||||
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
// lp.bottomMargin = mBottomMargin;
|
||||
indicator.setLayoutParams(lp);
|
||||
return indicator;
|
||||
}
|
||||
|
||||
public int getTextSize() {
|
||||
return textSize;
|
||||
}
|
||||
|
||||
public void setTextSize(int textSize) {
|
||||
this.textSize = textSize;
|
||||
}
|
||||
|
||||
public float getMinScale() {
|
||||
return minScale;
|
||||
}
|
||||
|
||||
public void setMinScale(float minScale) {
|
||||
this.minScale = minScale;
|
||||
}
|
||||
|
||||
public boolean isShowIndicator() {
|
||||
return showIndicator;
|
||||
}
|
||||
|
||||
public void setShowIndicator(boolean showIndicator) {
|
||||
this.showIndicator = showIndicator;
|
||||
}
|
||||
|
||||
public void setOnItemSelectListener(OnItemSelectListener onItemSelectListener) {
|
||||
mOnItemSelectListener = onItemSelectListener;
|
||||
}
|
||||
|
||||
public interface OnItemSelectListener {
|
||||
void onItemSelect(int position, TextView view);
|
||||
}
|
||||
}
|
@@ -1,15 +0,0 @@
|
||||
package com.chwl.app.avroom.adapter
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.chwl.app.R
|
||||
import com.chwl.core.room.game.bean.GameInfo
|
||||
|
||||
class SelectGameAdapter :
|
||||
BaseQuickAdapter<GameInfo, BaseViewHolder>(R.layout.item_room_select_game) {
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: GameInfo) {
|
||||
helper.setText(R.id.tv_name,item.name)
|
||||
}
|
||||
|
||||
}
|
@@ -72,14 +72,10 @@ class SingleAnchorMicroViewAdapter(context: Context?) : BaseMicroViewAdapter(con
|
||||
}
|
||||
}
|
||||
super.bind(info, position)
|
||||
tvNumber?.background = null
|
||||
tvNumber?.text = ""
|
||||
}
|
||||
|
||||
override fun setDefalutText(index: Int) {
|
||||
tvNick.text = ""
|
||||
tvNumber?.background = null
|
||||
tvNumber?.text = ""
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -8,17 +8,18 @@ import android.util.AttributeSet
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.PopupWindow
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.view.marginBottom
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import androidx.lifecycle.Observer
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil
|
||||
import com.netease.nim.uikit.common.util.sys.TimeUtil
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.activity.AVRoomActivity
|
||||
import com.chwl.app.common.widget.DragLayout
|
||||
import com.chwl.app.databinding.LayoutRoomPkBoardViewBinding
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils
|
||||
import com.chwl.core.im.custom.bean.RoomPkBean
|
||||
@@ -29,6 +30,9 @@ import com.chwl.core.utils.CurrentTimeUtils
|
||||
import com.chwl.core.utils.extension.subAndReplaceDot
|
||||
import com.chwl.library.rxbus.RxBus
|
||||
import com.chwl.library.utils.CommonUtils
|
||||
import com.chwl.library.utils.ResUtil
|
||||
import com.chwl.library.widget.drag.ViewDragLayout
|
||||
import com.example.lib_utils.UiUtils
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
@@ -36,7 +40,7 @@ import java.util.concurrent.TimeUnit
|
||||
|
||||
class RoomPKBoardView @JvmOverloads constructor(
|
||||
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
|
||||
) : DragLayout(context, attrs, defStyleAttr) {
|
||||
) : ViewDragLayout(context, attrs, defStyleAttr) {
|
||||
|
||||
private val binding = LayoutRoomPkBoardViewBinding.inflate(LayoutInflater.from(context))
|
||||
private val observer = Observer<RoomPkBean?> { updateView(it) }
|
||||
@@ -45,25 +49,34 @@ class RoomPKBoardView @JvmOverloads constructor(
|
||||
private var roomPkBean: RoomPkBean? = null
|
||||
|
||||
init {
|
||||
addView(binding.root, LayoutParams(ScreenUtil.dip2px(339f), ScreenUtil.dip2px(233f)))
|
||||
addView(
|
||||
binding.root,
|
||||
FrameLayout.LayoutParams(
|
||||
context.resources.getDimensionPixelOffset(R.dimen.dp_309),
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
).apply {
|
||||
this.gravity = Gravity.CENTER
|
||||
this.setMargins(0, 0, 0, UiUtils.dip2px(50f))
|
||||
}
|
||||
)
|
||||
//注意这里需要先改变Style,再订阅数据
|
||||
binding.viewRankListCharmLeft.showCharmStyle()
|
||||
binding.viewRankListCharmRight.showCharmStyle()
|
||||
AvRoomDataManager.get().roomPkLiveData.observeForever(observer)
|
||||
binding.ivDetails.setOnClickListener {
|
||||
if (CommonUtils.isFastDoubleClick(1000)) return@setOnClickListener
|
||||
if (CommonUtils.isFastDoubleClick(500)) return@setOnClickListener
|
||||
binding.groupRank.isVisible = !binding.groupRank.isVisible
|
||||
if (binding.groupRank.isVisible) {
|
||||
binding.clRoot.setBackgroundResource(R.drawable.bg_room_pk_board)
|
||||
binding.clRoot.updateLayoutParams<FrameLayout.LayoutParams> {
|
||||
width = ScreenUtil.dip2px(339f)
|
||||
height = ScreenUtil.dip2px(233f)
|
||||
binding.ivBg.setImageResource(R.drawable.room_pk_bg_full)
|
||||
binding.ivBg.updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||
width = ViewGroup.LayoutParams.MATCH_PARENT
|
||||
height = context.resources.getDimensionPixelOffset(R.dimen.dp_285)
|
||||
}
|
||||
} else {
|
||||
binding.clRoot.setBackgroundResource(R.drawable.bg_room_pk_board_small)
|
||||
binding.clRoot.updateLayoutParams<FrameLayout.LayoutParams> {
|
||||
width = ScreenUtil.dip2px(339f)
|
||||
height = ScreenUtil.dip2px(137f)
|
||||
binding.ivBg.setImageResource(R.drawable.room_pk_bg_small)
|
||||
binding.ivBg.updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||
width = ViewGroup.LayoutParams.MATCH_PARENT
|
||||
height = context.resources.getDimensionPixelOffset(R.dimen.dp_130)
|
||||
}
|
||||
}
|
||||
binding.ivDetails.animate().rotationBy(180f).start()
|
||||
@@ -122,11 +135,17 @@ class RoomPKBoardView @JvmOverloads constructor(
|
||||
)
|
||||
binding.viewRankListCharmRight.updateData(roomPkBean?.arRank)
|
||||
binding.viewRankListContributeRight.updateData(roomPkBean?.asRank)
|
||||
|
||||
binding.pbScore.progress = ((roomPkBean?.cPercent ?: 0.5f) * 100).toInt()
|
||||
val layoutParams = binding.svgaHot.layoutParams as ConstraintLayout.LayoutParams
|
||||
layoutParams.horizontalBias = roomPkBean?.cPercent ?: 0.5f
|
||||
binding.svgaHot.layoutParams = layoutParams
|
||||
binding.pbScore.post {
|
||||
val progress = binding.pbScore.width * (roomPkBean?.cPercent ?: 0.5f)
|
||||
var bias =
|
||||
(progress - binding.svgaHot.width / 2f) / (binding.pbScore.width - binding.svgaHot.width)
|
||||
val layoutParams = binding.svgaHot.layoutParams as ConstraintLayout.LayoutParams
|
||||
bias = 1f.coerceAtMost(bias)
|
||||
bias = 0f.coerceAtLeast(bias)
|
||||
layoutParams.horizontalBias = bias
|
||||
binding.svgaHot.layoutParams = layoutParams
|
||||
}
|
||||
|
||||
binding.tvScoreLeft.text = "${roomPkBean?.cAmount ?: 0}"
|
||||
binding.tvScoreRight.text = "${roomPkBean?.aAmount ?: 0}"
|
||||
@@ -134,13 +153,18 @@ class RoomPKBoardView @JvmOverloads constructor(
|
||||
disposable = Observable.interval(1, TimeUnit.SECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe { _ ->
|
||||
binding.tvTime.text = roomPkBean?.endTime?.let {
|
||||
roomPkBean?.endTime?.let {
|
||||
val remainTime = (it - CurrentTimeUtils.getCurrentTime()).toInt() / 1000
|
||||
binding.tvTime.setTextColor(Color.parseColor(if (remainTime <= 30) "#ff87a1" else "#fff600"))
|
||||
binding.tvTime.isVisible = remainTime > 0
|
||||
binding.tvEndHint.isVisible = remainTime <= 0
|
||||
TimeUtil.secToTime(remainTime)
|
||||
} ?: "00:00"
|
||||
binding.tvTime.setTextColor(Color.parseColor(if (remainTime <= 30) "#FFF17D" else "#ffffff"))
|
||||
if (remainTime > 0) {
|
||||
binding.tvTime.text = TimeUtil.secToTime(remainTime)
|
||||
} else {
|
||||
binding.tvTime.text =
|
||||
ResUtil.getString(R.string.layout_layout_room_pk_board_view_02)
|
||||
}
|
||||
} ?: let {
|
||||
binding.tvTime.text = "00:00"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +174,11 @@ class RoomPKBoardView @JvmOverloads constructor(
|
||||
contentView =
|
||||
LayoutInflater.from(context).inflate(R.layout.layout_room_pk_help_view, null)
|
||||
helpPopupWindow =
|
||||
PopupWindow(contentView, ScreenUtil.dip2px(244f), ScreenUtil.dip2px(177f))
|
||||
PopupWindow(
|
||||
contentView,
|
||||
resources.getDimensionPixelOffset(R.dimen.dp_209),
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
)
|
||||
helpPopupWindow.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
|
||||
helpPopupWindow.isOutsideTouchable = true
|
||||
helpPopupWindow.isFocusable = true
|
||||
@@ -158,10 +186,10 @@ class RoomPKBoardView @JvmOverloads constructor(
|
||||
|
||||
try {
|
||||
helpPopupWindow.showAsDropDown(
|
||||
binding.viewHelpAnchor,
|
||||
binding.ivHelp,
|
||||
0,
|
||||
0,
|
||||
Gravity.START or Gravity.BOTTOM
|
||||
ScreenUtil.dip2px(7f),
|
||||
Gravity.END or Gravity.BOTTOM
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
|
@@ -5,6 +5,8 @@ import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.FrameLayout
|
||||
import androidx.core.view.isGone
|
||||
import androidx.core.view.isInvisible
|
||||
import androidx.core.view.isVisible
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.databinding.LayoutRoomPkRankListViewBinding
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils
|
||||
@@ -19,7 +21,6 @@ class RoomPKRankListView @JvmOverloads constructor(
|
||||
private val binding = LayoutRoomPkRankListViewBinding.inflate(LayoutInflater.from(context))
|
||||
private val tvValues = arrayOf(binding.tvValue1, binding.tvValue2, binding.tvValue3)
|
||||
private val ivAvatars = arrayOf(binding.ivAvatar1, binding.ivAvatar2, binding.ivAvatar3)
|
||||
private var defaultAvatarRes = R.drawable.bg_room_pk_rank_contribute_default
|
||||
|
||||
init {
|
||||
addView(binding.root)
|
||||
@@ -36,13 +37,9 @@ class RoomPKRankListView @JvmOverloads constructor(
|
||||
binding.tvValue1.setBackgroundResource(R.drawable.bg_room_pk_charm)
|
||||
binding.tvValue2.setBackgroundResource(R.drawable.bg_room_pk_charm)
|
||||
binding.tvValue3.setBackgroundResource(R.drawable.bg_room_pk_charm)
|
||||
binding.viewBg1.setBackgroundResource(R.drawable.bg_room_pk_rank_charm1)
|
||||
binding.viewBg2.setBackgroundResource(R.drawable.bg_room_pk_rank_charm2)
|
||||
binding.viewBg3.setBackgroundResource(R.drawable.bg_room_pk_rank_charm2)
|
||||
binding.ivAvatar1.setImageResource(R.drawable.bg_room_pk_rank_charm_default)
|
||||
binding.ivAvatar2.setImageResource(R.drawable.bg_room_pk_rank_charm_default)
|
||||
binding.ivAvatar3.setImageResource(R.drawable.bg_room_pk_rank_charm_default)
|
||||
defaultAvatarRes = R.drawable.bg_room_pk_rank_charm_default
|
||||
binding.ivAvatarSeat1.setImageResource(R.drawable.room_pk_ic_seat_charm)
|
||||
binding.ivAvatarSeat2.setImageResource(R.drawable.room_pk_ic_seat_charm)
|
||||
binding.ivAvatarSeat3.setImageResource(R.drawable.room_pk_ic_seat_charm)
|
||||
}
|
||||
|
||||
fun updateData(data: List<RoomPkBean.RankBean>?) {
|
||||
@@ -50,12 +47,16 @@ class RoomPKRankListView @JvmOverloads constructor(
|
||||
val rankBean = data?.getOrNull(i)
|
||||
tvValues[i].text = rankBean?.amount ?: "0"
|
||||
tvValues[i].isGone = "0" == tvValues[i].text
|
||||
ImageLoadUtils.loadImage(
|
||||
context,
|
||||
rankBean?.avatar,
|
||||
ivAvatars[i],
|
||||
if (rankBean?.avatar.isNullOrEmpty()) defaultAvatarRes else R.drawable.default_avatar
|
||||
)
|
||||
if (rankBean?.avatar.isNullOrEmpty()) {
|
||||
ivAvatars[i].isInvisible = true
|
||||
} else {
|
||||
ivAvatars[i].isVisible = true
|
||||
ImageLoadUtils.loadImage(
|
||||
context,
|
||||
rankBean?.avatar,
|
||||
ivAvatars[i], R.drawable.default_avatar
|
||||
)
|
||||
}
|
||||
ivAvatars[i].tag = rankBean?.uid
|
||||
}
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ class RoomPKSearchAdapter :
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: SimpleRoomInfo) {
|
||||
helper.setText(R.id.tv_room_title,item.title.subAndReplaceDot(7))
|
||||
.setText(R.id.tv_room_id,"Molistar号:${item.erbanNo}")
|
||||
.setText(R.id.tv_room_id,"ID:${item.erbanNo}")
|
||||
.setChecked(R.id.check_box,item.checked)
|
||||
ImageLoadUtils.loadImage(mContext,item.avatar,helper.getView(R.id.iv_avatar))
|
||||
helper.addOnClickListener(R.id.iv_avatar,R.id.check_box)
|
||||
|
@@ -3,15 +3,14 @@ package com.chwl.app.avroom.anotherroompk
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.WindowManager
|
||||
import androidx.core.view.isVisible
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogRoomPkFinishBinding
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils
|
||||
import com.chwl.core.im.custom.bean.RoomPkBean
|
||||
import com.chwl.core.utils.extension.subAndReplaceDot
|
||||
|
||||
class RoomPkFinishDialog : BaseDialog<DialogRoomPkFinishBinding>() {
|
||||
class RoomPkFinishDialog : BaseDialogFragment<DialogRoomPkFinishBinding>() {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
@@ -30,10 +29,8 @@ class RoomPkFinishDialog : BaseDialog<DialogRoomPkFinishBinding>() {
|
||||
|
||||
@SuppressLint("CheckResult", "SetTextI18n")
|
||||
override fun init() {
|
||||
binding?.ivClose?.setOnClickListener { dismissAllowingStateLoss() }
|
||||
binding?.tvTitleRed?.text = roomPkBean.cTitle.subAndReplaceDot(7)
|
||||
binding?.tvValueRed?.text = "${roomPkBean.cAmount}"
|
||||
binding?.ivRedWin?.isVisible = roomPkBean.cUid == roomPkBean.winUid && roomPkBean.winUid != 0L
|
||||
ImageLoadUtils.loadImage(
|
||||
context,
|
||||
roomPkBean.cAvatar,
|
||||
@@ -43,8 +40,6 @@ class RoomPkFinishDialog : BaseDialog<DialogRoomPkFinishBinding>() {
|
||||
|
||||
binding?.tvTitleBlue?.text = roomPkBean.aTitle.subAndReplaceDot(7)
|
||||
binding?.tvValueBlue?.text = "${roomPkBean.aAmount}"
|
||||
binding?.ivBlueWin?.isVisible =
|
||||
roomPkBean.cUid != roomPkBean.winUid && roomPkBean.winUid != 0L
|
||||
ImageLoadUtils.loadImage(
|
||||
context,
|
||||
roomPkBean.aAvatar,
|
||||
@@ -53,8 +48,10 @@ class RoomPkFinishDialog : BaseDialog<DialogRoomPkFinishBinding>() {
|
||||
)
|
||||
|
||||
roomPkBean.csRank.getOrNull(0)?.let {
|
||||
binding?.tvNickContribute?.text = it.nick.subAndReplaceDot(7)
|
||||
binding?.tvValueContribute?.text = "神豪值:${it.amount}"
|
||||
binding?.tvNickContribute?.text = it.nick
|
||||
binding?.tvValueContribute?.text =
|
||||
context?.getString(R.string.layout_dialog_room_pk_finish_07, it.amount.toString())
|
||||
?: ""
|
||||
ImageLoadUtils.loadImage(
|
||||
context,
|
||||
it.avatar,
|
||||
@@ -64,8 +61,9 @@ class RoomPkFinishDialog : BaseDialog<DialogRoomPkFinishBinding>() {
|
||||
}
|
||||
|
||||
roomPkBean.crRank.getOrNull(0)?.let {
|
||||
binding?.tvNickCharm?.text = it.nick.subAndReplaceDot(7)
|
||||
binding?.tvValueCharm?.text = "魅力值:${it.amount}"
|
||||
binding?.tvNickCharm?.text = it.nick
|
||||
binding?.tvValueCharm?.text =
|
||||
context?.getString(R.string.layout_activity_jewel_09, it.amount?.toString()) ?: ""
|
||||
ImageLoadUtils.loadImage(
|
||||
context,
|
||||
it.avatar,
|
||||
@@ -76,25 +74,13 @@ class RoomPkFinishDialog : BaseDialog<DialogRoomPkFinishBinding>() {
|
||||
|
||||
when (roomPkBean.winUid) {
|
||||
0L -> {
|
||||
binding?.viewBg?.setBackgroundResource(R.drawable.bg_719cea_radius_10)
|
||||
binding?.clRoot?.setBackgroundResource(R.drawable.bg_room_pk_finish_deuce)
|
||||
binding?.viewContribute?.setBackgroundResource(R.drawable.bg_room_pk_finish_rank_deuce)
|
||||
binding?.viewCharm?.setBackgroundResource(R.drawable.bg_room_pk_finish_rank_deuce)
|
||||
binding?.ivClose?.setImageResource(R.drawable.ic_room_pk_finish_close_deuce)
|
||||
binding?.ivStatus?.setImageResource(R.drawable.room_pk_result_draw)
|
||||
}
|
||||
roomPkBean.cUid -> {
|
||||
binding?.viewBg?.setBackgroundResource(R.drawable.bg_edbf89_radius_10)
|
||||
binding?.clRoot?.setBackgroundResource(R.drawable.bg_room_pk_finish_win)
|
||||
binding?.viewContribute?.setBackgroundResource(R.drawable.bg_room_pk_finish_rank_win)
|
||||
binding?.viewCharm?.setBackgroundResource(R.drawable.bg_room_pk_finish_rank_win)
|
||||
binding?.ivClose?.setImageResource(R.drawable.ic_room_pk_finish_close_win)
|
||||
binding?.ivStatus?.setImageResource(R.drawable.room_pk_result_win)
|
||||
}
|
||||
else -> {
|
||||
binding?.viewBg?.setBackgroundResource(R.drawable.bg_bfabf6_radius_10)
|
||||
binding?.clRoot?.setBackgroundResource(R.drawable.bg_room_pk_finish_failed)
|
||||
binding?.viewContribute?.setBackgroundResource(R.drawable.bg_room_pk_finish_rank_failed)
|
||||
binding?.viewCharm?.setBackgroundResource(R.drawable.bg_room_pk_finish_rank_failed)
|
||||
binding?.ivClose?.setImageResource(R.drawable.ic_room_pk_finish_close_failed)
|
||||
binding?.ivStatus?.setImageResource(R.drawable.room_pk_result_fail)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -4,13 +4,13 @@ import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.WindowManager
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogRoomPkForceFinishBinding
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils
|
||||
import com.chwl.core.im.custom.bean.RoomPkBean
|
||||
import com.chwl.core.utils.extension.subAndReplaceDot
|
||||
|
||||
class RoomPkForceFinishDialog : BaseDialog<DialogRoomPkForceFinishBinding>() {
|
||||
class RoomPkForceFinishDialog : BaseDialogFragment<DialogRoomPkForceFinishBinding>() {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
|
@@ -3,12 +3,12 @@ package com.chwl.app.avroom.anotherroompk
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import androidx.core.view.isVisible
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogRoomPkReceivedBinding
|
||||
import com.chwl.core.im.custom.bean.RoomPkBean
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
import com.chwl.core.room.anotherroompk.RoomPKModel
|
||||
import com.chwl.core.utils.extension.ifNotNullOrEmpty
|
||||
import com.chwl.core.utils.extension.subAndReplaceDot
|
||||
import com.chwl.core.utils.extension.toast
|
||||
import io.reactivex.Observable
|
||||
@@ -16,7 +16,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class RoomPkReceivedDialog : BaseDialog<DialogRoomPkReceivedBinding>() {
|
||||
class RoomPkReceivedDialog : BaseDialogFragment<DialogRoomPkReceivedBinding>() {
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -36,12 +36,20 @@ class RoomPkReceivedDialog : BaseDialog<DialogRoomPkReceivedBinding>() {
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun init() {
|
||||
binding?.tvNick?.text = pkBean.inviteRoomTitle.subAndReplaceDot(7)
|
||||
binding?.tvTime?.text = "${pkBean.pkDuration}分鐘"
|
||||
pkBean.pkDesc.ifNotNullOrEmpty {
|
||||
binding?.tvDescTitle?.isVisible = true
|
||||
binding?.tvDesc?.isVisible = true
|
||||
binding?.tvDesc?.text = it
|
||||
binding?.tvNick?.text = pkBean.inviteRoomTitle
|
||||
binding?.tvTime?.text = "${pkBean.pkDuration}${getString(R.string.layout_activity_room_pk_create_010)}"
|
||||
val height: Int
|
||||
if (pkBean.pkDesc.isNullOrEmpty()) {
|
||||
binding?.groupDesc?.isVisible = false
|
||||
height = resources.getDimensionPixelOffset(R.dimen.dp_192)
|
||||
} else {
|
||||
binding?.tvDesc?.text = pkBean.pkDesc
|
||||
binding?.groupDesc?.isVisible = true
|
||||
height = resources.getDimensionPixelOffset(R.dimen.dp_211)
|
||||
}
|
||||
binding?.layoutContent?.let {
|
||||
it.layoutParams.height = height
|
||||
it.requestLayout()
|
||||
}
|
||||
disposable = Observable.intervalRange(0, 10, 0, 1, TimeUnit.SECONDS)
|
||||
.compose(bindToLifecycle())
|
||||
|
@@ -1,9 +1,9 @@
|
||||
package com.chwl.app.avroom.anotherroompk
|
||||
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogRoomPkRuleBinding
|
||||
|
||||
class RoomPkRuleDialog : BaseDialog<DialogRoomPkRuleBinding>() {
|
||||
class RoomPkRuleDialog : BaseDialogFragment<DialogRoomPkRuleBinding>() {
|
||||
|
||||
companion object {
|
||||
|
||||
|
@@ -0,0 +1,63 @@
|
||||
package com.chwl.app.avroom.bean
|
||||
|
||||
import androidx.annotation.Keep
|
||||
import com.chwl.app.avroom.dialog.RoomGameplayDialog
|
||||
import com.chwl.core.room.bean.RoomIcon
|
||||
import java.io.Serializable
|
||||
|
||||
@Keep
|
||||
interface RoomGameplayItem : Serializable {
|
||||
|
||||
fun getName(): String?
|
||||
|
||||
fun getIconUrl(): String?
|
||||
|
||||
fun getIconRes(): Int?
|
||||
|
||||
fun onItemClick(dialog: RoomGameplayDialog)
|
||||
|
||||
@Keep
|
||||
class RoomIconItem(
|
||||
private val roomIcon: RoomIcon,
|
||||
private val onClick: (RoomGameplayDialog, RoomIcon) -> Unit
|
||||
) : RoomGameplayItem {
|
||||
override fun getName(): String? {
|
||||
return roomIcon.name
|
||||
}
|
||||
|
||||
override fun getIconUrl(): String? {
|
||||
return roomIcon.icon
|
||||
}
|
||||
|
||||
override fun getIconRes(): Int? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun onItemClick(dialog: RoomGameplayDialog) {
|
||||
onClick.invoke(dialog, roomIcon)
|
||||
}
|
||||
}
|
||||
|
||||
@Keep
|
||||
class CustomItem(
|
||||
private val name: String,
|
||||
private val iconRes: Int,
|
||||
private val onClick: (RoomGameplayDialog, CustomItem) -> Unit
|
||||
) : RoomGameplayItem {
|
||||
override fun getName(): String {
|
||||
return name
|
||||
}
|
||||
|
||||
override fun getIconUrl(): String? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun getIconRes(): Int {
|
||||
return iconRes
|
||||
}
|
||||
|
||||
override fun onItemClick(dialog: RoomGameplayDialog) {
|
||||
onClick.invoke(dialog, this)
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,16 +0,0 @@
|
||||
package com.chwl.app.avroom.core
|
||||
|
||||
import com.chwl.core.support.room.RoomAbility
|
||||
import com.chwl.core.support.room.RoomContext
|
||||
|
||||
/**
|
||||
* Created by Max on 2023/10/26 15:41
|
||||
* Desc:语音房
|
||||
* @param roomId roomUid
|
||||
**/
|
||||
class AudioRoomContext(roomId: Long) : RoomContext(roomId) {
|
||||
|
||||
override fun loadAbility(list: MutableMap<String, RoomAbility>) {
|
||||
super.loadAbility(list)
|
||||
}
|
||||
}
|
@@ -6,7 +6,7 @@ import android.view.WindowManager
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.chwl.app.avroom.adapter.CreateRoomGameGuideAdapter
|
||||
import com.chwl.app.base.BaseActivity
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogCreateGameRoomBinding
|
||||
import com.chwl.app.home.helper.OpenRoomHelper
|
||||
import com.chwl.app.ui.utils.RVDelegate
|
||||
@@ -14,7 +14,7 @@ import com.chwl.core.room.bean.RoomInfo
|
||||
import com.chwl.core.room.game.bean.GameInfo
|
||||
import com.chwl.core.room.game.GameModel
|
||||
|
||||
class CreateGameRoomDialog : BaseDialog<DialogCreateGameRoomBinding>() {
|
||||
class CreateGameRoomDialog : BaseDialogFragment<DialogCreateGameRoomBinding>() {
|
||||
|
||||
private lateinit var rvDelegate: RVDelegate<GameInfo>
|
||||
private val gameAdapter = CreateRoomGameGuideAdapter()
|
||||
@@ -44,7 +44,7 @@ class CreateGameRoomDialog : BaseDialog<DialogCreateGameRoomBinding>() {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
GameModel.getGameList()
|
||||
GameModel.getGameList(null)
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe(
|
||||
{
|
||||
|
@@ -4,10 +4,12 @@ import android.annotation.SuppressLint
|
||||
import android.view.Gravity
|
||||
import android.view.WindowManager
|
||||
import androidx.core.view.isInvisible
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.adapter.CreateRoomGameAdapter
|
||||
import com.chwl.app.base.BaseActivity
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogCreateRoomBinding
|
||||
import com.chwl.app.home.helper.OpenRoomHelper
|
||||
import com.chwl.app.ui.utils.RVDelegate
|
||||
@@ -17,7 +19,7 @@ import com.chwl.core.room.game.GameModel
|
||||
import com.chwl.core.utils.extension.toast
|
||||
import com.chwl.library.utils.ResUtil
|
||||
|
||||
class CreateRoomDialog : BaseDialog<DialogCreateRoomBinding>() {
|
||||
class CreateRoomDialog : BaseDialogFragment<DialogCreateRoomBinding>() {
|
||||
|
||||
private lateinit var rvDelegate: RVDelegate<GameInfo>
|
||||
private val gameAdapter = CreateRoomGameAdapter()
|
||||
@@ -30,35 +32,35 @@ class CreateRoomDialog : BaseDialog<DialogCreateRoomBinding>() {
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun init() {
|
||||
// if(isHomeGame){
|
||||
// binding?.tvPlayType?.isVisible = false
|
||||
// binding?.rgType?.isVisible = false
|
||||
// binding?.rvGame?.isVisible = true
|
||||
// }
|
||||
// binding?.rvGame?.itemAnimator = null
|
||||
// rvDelegate = RVDelegate.Builder<GameInfo>()
|
||||
// .setAdapter(gameAdapter)
|
||||
// .setRecyclerView(binding?.rvGame)
|
||||
// .setLayoutManager(LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false))
|
||||
// .build()
|
||||
if(isHomeGame){
|
||||
binding?.tvPlayType?.isVisible = false
|
||||
binding?.rgType?.isVisible = false
|
||||
binding?.rvGame?.isVisible = true
|
||||
}
|
||||
binding?.rvGame?.itemAnimator = null
|
||||
rvDelegate = RVDelegate.Builder<GameInfo>()
|
||||
.setAdapter(gameAdapter)
|
||||
.setRecyclerView(binding?.rvGame)
|
||||
.setLayoutManager(LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false))
|
||||
.build()
|
||||
|
||||
// gameAdapter.setOnItemClickListener { _, _, position ->
|
||||
// if (selectIndex != -1) {
|
||||
// gameAdapter.data.getOrNull(selectIndex)?.isSelect = false
|
||||
// gameAdapter.notifyItemChanged(selectIndex)
|
||||
// }
|
||||
// selectIndex = position
|
||||
// gameAdapter.data.getOrNull(selectIndex)?.isSelect = true
|
||||
// gameAdapter.notifyItemChanged(selectIndex)
|
||||
// checkCreateEnable()
|
||||
// }
|
||||
gameAdapter.setOnItemClickListener { _, _, position ->
|
||||
if (selectIndex != -1) {
|
||||
gameAdapter.data.getOrNull(selectIndex)?.isSelect = false
|
||||
gameAdapter.notifyItemChanged(selectIndex)
|
||||
}
|
||||
selectIndex = position
|
||||
gameAdapter.data.getOrNull(selectIndex)?.isSelect = true
|
||||
gameAdapter.notifyItemChanged(selectIndex)
|
||||
checkCreateEnable()
|
||||
}
|
||||
|
||||
// binding?.rbGameRoom?.setOnCheckedChangeListener { _, isChecked ->
|
||||
// checkCreateEnable()
|
||||
// if (isChecked) {
|
||||
// binding?.rvGame?.isVisible = true
|
||||
// }
|
||||
// }
|
||||
binding?.rbGameRoom?.setOnCheckedChangeListener { _, isChecked ->
|
||||
checkCreateEnable()
|
||||
if (isChecked) {
|
||||
binding?.rvGame?.isVisible = true
|
||||
}
|
||||
}
|
||||
|
||||
binding?.rbPartyRoom?.setOnCheckedChangeListener { _, isChecked ->
|
||||
checkCreateEnable()
|
||||
@@ -86,7 +88,7 @@ class CreateRoomDialog : BaseDialog<DialogCreateRoomBinding>() {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
GameModel.getGameList()
|
||||
GameModel.getGameList(null)
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe(
|
||||
{
|
||||
|
@@ -25,6 +25,7 @@ import com.chwl.core.manager.AvRoomDataManager
|
||||
import com.chwl.core.room.model.AvRoomModel
|
||||
import com.chwl.library.annatation.ActLayoutRes
|
||||
import com.chwl.library.utils.ResUtil
|
||||
import com.example.lib_utils.UiUtils
|
||||
import io.reactivex.disposables.Disposable
|
||||
|
||||
|
||||
@@ -64,8 +65,11 @@ class ExitRoomPopupWindow(val avRoomActivity: AVRoomActivity) : PopupWindow() {
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
|
||||
animationStyle = R.style.style_anim_right_in_out
|
||||
if(UiUtils.isRtl(avRoomActivity)){
|
||||
animationStyle = R.style.style_anim_left_in_out
|
||||
}else{
|
||||
animationStyle = R.style.style_anim_right_in_out
|
||||
}
|
||||
setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
|
||||
|
||||
tvExitRoom.setOnClickListener {
|
||||
|
@@ -1,12 +1,12 @@
|
||||
package com.chwl.app.avroom.dialog
|
||||
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogNewUserGiftBinding
|
||||
import com.chwl.app.ui.utils.load
|
||||
import com.chwl.core.gift.bean.GiftInfo
|
||||
|
||||
class NewUserGiftDialog(val giftInfo: GiftInfo) :
|
||||
BaseDialog<DialogNewUserGiftBinding>() {
|
||||
BaseDialogFragment<DialogNewUserGiftBinding>() {
|
||||
|
||||
override fun init() {
|
||||
binding?.ivClose?.setOnClickListener {
|
||||
|
@@ -1,297 +0,0 @@
|
||||
package com.chwl.app.avroom.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.netease.nim.uikit.support.glide.GlideApp;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.common.widget.CircleImageView;
|
||||
import com.chwl.app.ui.widget.dialog.BaseDialog;
|
||||
import com.chwl.app.ui.widget.dialog.CommonTipDialog;
|
||||
import com.chwl.core.manager.AvRoomDataManager;
|
||||
import com.chwl.core.manager.IMNetEaseManager;
|
||||
import com.chwl.core.manager.RoomEvent;
|
||||
import com.chwl.core.room.pk.bean.PKMemberInfo;
|
||||
import com.chwl.core.room.pk.bean.PKTeamInfo;
|
||||
import com.chwl.core.room.pk.bean.PKTeamMember;
|
||||
import com.chwl.core.room.pk.bean.RoomPkData;
|
||||
import com.chwl.core.room.pk.event.PKDataUpdateEvent;
|
||||
import com.chwl.core.room.pk.event.PKTimeFinishEvent;
|
||||
import com.chwl.core.room.pk.event.PKTimeTickEvent;
|
||||
import com.chwl.core.room.pk.model.PkModel;
|
||||
import com.chwl.core.super_admin.util.SuperAdminUtil;
|
||||
import com.chwl.library.utils.FormatUtils;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.SingleObserver;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
/**
|
||||
* @author jack
|
||||
* @Description
|
||||
* @Date 2019/1/3
|
||||
*/
|
||||
public class PKScoreBoardDialog extends BaseDialog {
|
||||
|
||||
|
||||
private TextView tvPkVoteMode;
|
||||
private View tvClose;
|
||||
private ProgressBar pbScore;
|
||||
private TextView tvRedTeamScore;
|
||||
private TextView tvBlueTeamScore;
|
||||
private TextView tvPkTimer;
|
||||
private CircleImageView ivRedAvatar1;
|
||||
private CircleImageView ivRedAvatar2;
|
||||
private CircleImageView ivRedAvatar3;
|
||||
private CircleImageView ivRedAvatar4;
|
||||
private CircleImageView ivBlueAvatar1;
|
||||
private CircleImageView ivBlueAvatar2;
|
||||
private CircleImageView ivBlueAvatar3;
|
||||
private CircleImageView ivBlueAvatar4;
|
||||
private TextView tvRestart;
|
||||
|
||||
private final List<CircleImageView> redTeamAvatars = new ArrayList<>();
|
||||
|
||||
private final List<CircleImageView> blueTeamAvatars = new ArrayList<>();
|
||||
|
||||
private RoomPkData roomPkData;
|
||||
|
||||
private CompositeDisposable compositeDisposable;
|
||||
|
||||
public PKScoreBoardDialog(Context context) {
|
||||
super(context, R.style.easy_dialog_style);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setCanceledOnTouchOutside(true);
|
||||
setContentView(R.layout.dialog_pk_score_board);
|
||||
|
||||
tvPkVoteMode = (TextView) findViewById(R.id.tv_pk_vote_mode);
|
||||
tvClose = findViewById(R.id.tv_close);
|
||||
pbScore = (ProgressBar) findViewById(R.id.pb_score);
|
||||
tvRedTeamScore = (TextView) findViewById(R.id.tv_red_team_score);
|
||||
tvBlueTeamScore = (TextView) findViewById(R.id.tv_blue_team_score);
|
||||
tvPkTimer = (TextView) findViewById(R.id.tv_pk_timer);
|
||||
tvRestart = (TextView) findViewById(R.id.tv_restart);
|
||||
|
||||
ivRedAvatar1 = (CircleImageView) findViewById(R.id.iv_red_avatar_1);
|
||||
ivRedAvatar2 = (CircleImageView) findViewById(R.id.iv_red_avatar_2);
|
||||
ivRedAvatar3 = (CircleImageView) findViewById(R.id.iv_red_avatar_3);
|
||||
ivRedAvatar4 = (CircleImageView) findViewById(R.id.iv_red_avatar_4);
|
||||
|
||||
ivBlueAvatar1 = (CircleImageView) findViewById(R.id.iv_blue_avatar_1);
|
||||
ivBlueAvatar2 = (CircleImageView) findViewById(R.id.iv_blue_avatar_2);
|
||||
ivBlueAvatar3 = (CircleImageView) findViewById(R.id.iv_blue_avatar_3);
|
||||
ivBlueAvatar4 = (CircleImageView) findViewById(R.id.iv_blue_avatar_4);
|
||||
|
||||
redTeamAvatars.add(ivRedAvatar1);
|
||||
redTeamAvatars.add(ivRedAvatar2);
|
||||
redTeamAvatars.add(ivRedAvatar3);
|
||||
redTeamAvatars.add(ivRedAvatar4);
|
||||
|
||||
blueTeamAvatars.add(ivBlueAvatar1);
|
||||
blueTeamAvatars.add(ivBlueAvatar2);
|
||||
blueTeamAvatars.add(ivBlueAvatar3);
|
||||
blueTeamAvatars.add(ivBlueAvatar4);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
tvClose.setOnClickListener(v -> dismiss());
|
||||
roomPkData = PkModel.get().getCurPkInfo();
|
||||
if (roomPkData == null) {
|
||||
return;
|
||||
}
|
||||
if (roomPkData.getVoteMode() == RoomPkData.VOTE_MODE_GIFT) {
|
||||
tvPkVoteMode.setText(getContext().getResources().getString(R.string.vote_type_gift_value));
|
||||
} else if (roomPkData.getVoteMode() == RoomPkData.VOTE_MODE_PERSON) {
|
||||
tvPkVoteMode.setText(getContext().getResources().getString(R.string.vote_type_gift_member));
|
||||
}
|
||||
|
||||
PKTeamInfo redTeam = PkModel.get().findTeamByTeamId(PKTeamInfo.TEAM_RED);
|
||||
for (int i = 0; i < redTeamAvatars.size(); i++) {
|
||||
if (i < redTeam.getTeamMembers().size()) {
|
||||
redTeamAvatars.get(i).setVisibility(View.VISIBLE);
|
||||
PKTeamMember pkTeamMember = redTeam.getTeamMembers().get(i);
|
||||
PKMemberInfo pkMemberInfo = findPKMemberInfo(pkTeamMember.getUid());
|
||||
if (pkMemberInfo == null || pkMemberInfo.getUserInfo() == null) {
|
||||
continue;
|
||||
}
|
||||
GlideApp.with(redTeamAvatars.get(i))
|
||||
.load(pkMemberInfo.getUserInfo().getAvatar())
|
||||
.placeholder(R.drawable.default_avatar)
|
||||
.dontAnimate()
|
||||
.into(redTeamAvatars.get(i));
|
||||
} else {
|
||||
redTeamAvatars.get(i).setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
PKTeamInfo blueTeam = PkModel.get().findTeamByTeamId(PKTeamInfo.TEAM_BLUE);
|
||||
for (int i = 0; i < blueTeamAvatars.size(); i++) {
|
||||
if (i < blueTeam.getTeamMembers().size()) {
|
||||
blueTeamAvatars.get(i).setVisibility(View.VISIBLE);
|
||||
PKTeamMember pkTeamMember = blueTeam.getTeamMembers().get(i);
|
||||
PKMemberInfo pkMemberInfo = findPKMemberInfo(pkTeamMember.getUid());
|
||||
if (pkMemberInfo == null || pkMemberInfo.getUserInfo() == null) {
|
||||
continue;
|
||||
}
|
||||
GlideApp.with(blueTeamAvatars.get(i))
|
||||
.load(pkMemberInfo.getUserInfo().getAvatar())
|
||||
.placeholder(R.drawable.default_avatar)
|
||||
.dontAnimate()
|
||||
.into(blueTeamAvatars.get(i));
|
||||
|
||||
} else {
|
||||
blueTeamAvatars.get(i).setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
if (AvRoomDataManager.get().isManager() && !SuperAdminUtil.isSuperAdmin()) {
|
||||
tvRestart.setVisibility(View.VISIBLE);
|
||||
tvRestart.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (PkModel.get().getCurPkInfo() == null) {
|
||||
toast(ResUtil.getString(R.string.avroom_dialog_pkscoreboarddialog_01));
|
||||
dismiss();
|
||||
return;
|
||||
}
|
||||
if (PkModel.get().getCurPkInfo().getPkStatus() == RoomPkData.PK_STATUS_AFTER_PK) {
|
||||
toast(ResUtil.getString(R.string.avroom_dialog_pkscoreboarddialog_02));
|
||||
dismiss();
|
||||
return;
|
||||
}
|
||||
CommonTipDialog tipDialog = new CommonTipDialog(getContext());
|
||||
tipDialog.setTipMsg(ResUtil.getString(R.string.avroom_dialog_pkscoreboarddialog_03) +
|
||||
ResUtil.getString(R.string.avroom_dialog_pkscoreboarddialog_04));
|
||||
tipDialog.setOnActionListener(
|
||||
new CommonTipDialog.OnActionListener() {
|
||||
@Override
|
||||
public void onOk() {
|
||||
PkModel.get().toPKAgain().subscribe(new SingleObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
compositeDisposable.add(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(String s) {
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
toast(e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
tipDialog.show();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
tvRestart.setVisibility(View.GONE);
|
||||
tvRestart.setOnClickListener(null);
|
||||
}
|
||||
updateTime();
|
||||
onPKDataUpdateEvent(null);
|
||||
}
|
||||
|
||||
private PKMemberInfo findPKMemberInfo(String account) {
|
||||
for (PKMemberInfo pkMemberInfo : PkModel.get().getPkMemberInfoList()) {
|
||||
if (String.valueOf(pkMemberInfo.getUserInfo().getUid()).equals(account)) {
|
||||
return pkMemberInfo;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private void updateTime() {
|
||||
roomPkData = PkModel.get().getCurPkInfo();
|
||||
if (roomPkData == null) {
|
||||
return;
|
||||
}
|
||||
long pkTimeUntilEnd = roomPkData.getCurPkTimeUntilEnd();
|
||||
tvPkTimer.setText(String.format("%1$02d:%2$02d", pkTimeUntilEnd / 60, pkTimeUntilEnd % 60));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
EventBus.getDefault().register(this);
|
||||
compositeDisposable = new CompositeDisposable();
|
||||
compositeDisposable.add(IMNetEaseManager.get().getChatRoomEventObservable()
|
||||
.subscribe(this::onReceiveRoomEvent));
|
||||
}
|
||||
|
||||
private void onReceiveRoomEvent(RoomEvent roomEvent) {
|
||||
int event = roomEvent.getEvent();
|
||||
switch (event) {
|
||||
case RoomEvent.PK_INFO_UPDATE:
|
||||
roomPkData = PkModel.get().getCurPkInfo();
|
||||
if (roomPkData != null && (roomPkData.getPkStatus() == RoomPkData.PK_STATUS_BEFORE_PK ||
|
||||
roomPkData.getPkStatus() == RoomPkData.PK_STATUS_AFTER_PK)) {
|
||||
dismiss();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
EventBus.getDefault().unregister(this);
|
||||
compositeDisposable.dispose();
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onPKDataUpdateEvent(PKDataUpdateEvent event) {
|
||||
if (PkModel.get().getCurPkInfo() == null
|
||||
|| PkModel.get().getCurPkInfo().getPkStatus() == RoomPkData.PK_STATUS_AFTER_PK) {
|
||||
dismiss();
|
||||
return;
|
||||
}
|
||||
|
||||
PKTeamInfo redTeam = PkModel.get().findTeamByTeamId(PKTeamInfo.TEAM_RED);
|
||||
PKTeamInfo blueTeam = PkModel.get().findTeamByTeamId(PKTeamInfo.TEAM_BLUE);
|
||||
if (redTeam == null || blueTeam == null) {
|
||||
return;
|
||||
}
|
||||
long totalScore = redTeam.getScore() + blueTeam.getScore();
|
||||
if (totalScore > 0) {
|
||||
tvRedTeamScore.setText(FormatUtils.formatPKValue(redTeam.getScore()));
|
||||
tvBlueTeamScore.setText(FormatUtils.formatPKValue(blueTeam.getScore()));
|
||||
int percent = (int) ((float) redTeam.getScore() / (float) totalScore * 100.0f);
|
||||
pbScore.setProgress(percent);
|
||||
} else {
|
||||
pbScore.setProgress(50);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onPKTimeTickEvent(PKTimeTickEvent event) {
|
||||
updateTime();
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onPKTimeFinishEvent(PKTimeFinishEvent event) {
|
||||
tvPkTimer.setText("00:00");
|
||||
}
|
||||
}
|
@@ -95,7 +95,10 @@ public class PKSelectPeopleDialog extends BaseDialog implements View.OnClickList
|
||||
keys[i] = micQueue.keyAt(i);
|
||||
}
|
||||
Arrays.sort(keys);
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
for (int i = 0; i < micEntityList.size(); i++) {
|
||||
if (i >= micQueue.size()) {
|
||||
continue;
|
||||
}
|
||||
RoomQueueInfo roomQueueInfo = micQueue.get(keys[i]);
|
||||
MicMemberInfo chatRoomMember = roomQueueInfo.mChatRoomMember;
|
||||
if (chatRoomMember != null) {
|
||||
|
@@ -0,0 +1,236 @@
|
||||
package com.chwl.app.avroom.dialog
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleEventObserver
|
||||
import androidx.lifecycle.LifecycleObserver
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.adapter.RoomGameListAdapter
|
||||
import com.chwl.app.base.BaseActivity
|
||||
import com.chwl.app.common.widget.dialog.DialogManager
|
||||
import com.chwl.app.databinding.RoomGameplayDialogBinding
|
||||
import com.chwl.app.home.helper.OpenRoomHelper
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
import com.chwl.core.room.bean.RoomInfo
|
||||
import com.chwl.core.room.bean.RoomModeType
|
||||
import com.chwl.core.room.core.RoomDataService
|
||||
import com.chwl.core.room.game.GameModel.getGameList
|
||||
import com.chwl.core.room.game.bean.GameInfo
|
||||
import com.chwl.core.support.room.AudioRoomContext
|
||||
import com.chwl.library.utils.JavaUtil
|
||||
import com.chwl.library.utils.ResUtil
|
||||
import com.chwl.library.utils.SingleToastUtil
|
||||
import com.example.lib_utils.ktx.asLifecycle
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import com.unity3d.splash.services.core.lifecycle.LifecycleEvent
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
|
||||
class RoomGameListDialog :
|
||||
BottomSheetDialogFragment(), LifecycleObserver {
|
||||
private var binding: RoomGameplayDialogBinding? = null
|
||||
private var compositeDisposable: CompositeDisposable? = null
|
||||
private val adapter = RoomGameListAdapter()
|
||||
private var dialogManager: DialogManager? = null
|
||||
private lateinit var recycleView: RecyclerView
|
||||
override fun getTheme(): Int {
|
||||
return R.style.ErbanBottomSheetDialogDimFalse
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
binding = RoomGameplayDialogBinding.inflate(LayoutInflater.from(context))
|
||||
return binding?.root
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
return super.onCreateDialog(savedInstanceState).apply {
|
||||
this.setCanceledOnTouchOutside(true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
initView()
|
||||
val recyclerView: RecyclerView = view.findViewById(R.id.recyclerView)
|
||||
recycleView = recyclerView
|
||||
switchStatus(0)
|
||||
requestData()
|
||||
}
|
||||
|
||||
override fun onAttach(context: Context) {
|
||||
super.onAttach(context)
|
||||
val lifecycleObserver = object : LifecycleEventObserver {
|
||||
override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) {
|
||||
if (event == Lifecycle.Event.ON_DESTROY) {
|
||||
context.asLifecycle()?.removeObserver(this)
|
||||
try {
|
||||
this@RoomGameListDialog.dismissAllowingStateLoss()
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
context.asLifecycle()?.addObserver(lifecycleObserver)
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
adapter.setOnItemClickListener { _, view, position ->
|
||||
val item = adapter.getItem(position) as GameInfo
|
||||
switchGame(item)
|
||||
}
|
||||
binding?.recyclerView?.adapter = adapter
|
||||
}
|
||||
|
||||
private fun updateDialogHeight(count: Int) {
|
||||
if (count > 10) {
|
||||
val layoutParams = recycleView.layoutParams
|
||||
layoutParams.height = 600
|
||||
recycleView.layoutParams = layoutParams
|
||||
}
|
||||
}
|
||||
|
||||
private fun requestData() {
|
||||
val dataService =
|
||||
AudioRoomContext.get()
|
||||
?.findAbility<RoomDataService>(RoomDataService::class.java.simpleName)
|
||||
val cacheKey = "game_list#${parentFragment.hashCode()}"
|
||||
val list = dataService?.getData(cacheKey) as? List<GameInfo>
|
||||
if (!list.isNullOrEmpty()) {
|
||||
updateDialogHeight(list.size)
|
||||
loadData(list)
|
||||
return
|
||||
}
|
||||
val disposable = getGameList(AvRoomDataManager.get().roomUid)
|
||||
.doOnError {
|
||||
SingleToastUtil.showToast(it.message)
|
||||
switchStatus(-2)
|
||||
}
|
||||
.subscribe { it: List<GameInfo> ->
|
||||
dataService?.putData(cacheKey, it)
|
||||
updateDialogHeight(it.size)
|
||||
loadData(it)
|
||||
}
|
||||
getCompositeDisposable().add(disposable)
|
||||
}
|
||||
|
||||
private fun loadData(list: List<GameInfo>?) {
|
||||
if (list.isNullOrEmpty()) {
|
||||
switchStatus(-1)
|
||||
} else {
|
||||
adapter.setNewData(list)
|
||||
switchStatus(1)
|
||||
}
|
||||
}
|
||||
|
||||
private fun switchStatus(status: Int) {
|
||||
when (status) {
|
||||
// loading
|
||||
0 -> {
|
||||
binding?.recyclerView?.isVisible = false
|
||||
binding?.layoutStatus?.isVisible = true
|
||||
binding?.groupStatusLoading?.isVisible = true
|
||||
binding?.groupStatusText?.isVisible = false
|
||||
}
|
||||
|
||||
// 有数据
|
||||
1 -> {
|
||||
binding?.recyclerView?.isVisible = true
|
||||
binding?.layoutStatus?.isVisible = false
|
||||
}
|
||||
|
||||
// 空数据
|
||||
-1 -> {
|
||||
binding?.recyclerView?.isVisible = false
|
||||
binding?.layoutStatus?.isVisible = true
|
||||
binding?.groupStatusLoading?.isVisible = false
|
||||
binding?.groupStatusText?.isVisible = true
|
||||
binding?.tvStatus?.setText(R.string.avroom_presenter_roomnewbiehellowwordpresenter_01)
|
||||
}
|
||||
|
||||
// 失败
|
||||
else -> {
|
||||
binding?.recyclerView?.isVisible = false
|
||||
binding?.layoutStatus?.isVisible = true
|
||||
binding?.groupStatusLoading?.isVisible = false
|
||||
binding?.groupStatusText?.isVisible = true
|
||||
binding?.tvStatus?.setText(R.string.request_failed_again_later)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun switchGame(gameInfo: GameInfo) {
|
||||
if (AvRoomDataManager.get().isGamePlaying) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.room_switch_game_failed_in_game))
|
||||
return
|
||||
}
|
||||
if (!isShowChangeGame()) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_fragment_homepartyfragment_04))
|
||||
return
|
||||
}
|
||||
|
||||
if (dialogManager == null) {
|
||||
dialogManager = DialogManager(context)
|
||||
}
|
||||
dialogManager?.showOkCancelDialog(
|
||||
getString(R.string.room_switch_game_tips)
|
||||
) {
|
||||
if (gameInfo.isStandardRoom()) {
|
||||
OpenRoomHelper.updateRoomInfo(
|
||||
activity as BaseActivity,
|
||||
AvRoomDataManager.get().mCurrentRoomInfo,
|
||||
RoomInfo.ROOMTYPE_HOME_PARTY,
|
||||
0,
|
||||
false
|
||||
)
|
||||
} else {
|
||||
OpenRoomHelper.updateRoomInfo(
|
||||
activity as BaseActivity,
|
||||
AvRoomDataManager.get().mCurrentRoomInfo,
|
||||
RoomInfo.ROOMTYPE_GAME,
|
||||
JavaUtil.str2long(gameInfo.mgId),
|
||||
false
|
||||
)
|
||||
}
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
onUnbindContext()
|
||||
dialogManager?.dismissDialog()
|
||||
dialogManager = null
|
||||
}
|
||||
|
||||
private fun getCompositeDisposable(): CompositeDisposable {
|
||||
var disposable = compositeDisposable
|
||||
if (disposable == null) {
|
||||
disposable = CompositeDisposable()
|
||||
compositeDisposable = disposable
|
||||
}
|
||||
return disposable
|
||||
}
|
||||
|
||||
private fun onUnbindContext() {
|
||||
compositeDisposable?.dispose()
|
||||
compositeDisposable = null
|
||||
}
|
||||
|
||||
//这里的2和4是服务端定义的错误状态 关闭排麦模式和关闭PK模式!
|
||||
private fun isShowChangeGame(): Boolean {
|
||||
val currentRoomInfo = AvRoomDataManager.get().mCurrentRoomInfo
|
||||
return currentRoomInfo != null && currentRoomInfo.type != RoomInfo.ROOM_TYPE_SINGLE &&
|
||||
(currentRoomInfo.roomModeType == RoomModeType.NORMAL_MODE || currentRoomInfo.roomModeType == 2 || currentRoomInfo.roomModeType == 4)
|
||||
}
|
||||
}
|
@@ -0,0 +1,421 @@
|
||||
package com.chwl.app.avroom.dialog
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleEventObserver
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.activity.CreatePKActivity
|
||||
import com.chwl.app.avroom.adapter.RoomGameplayAdapter
|
||||
import com.chwl.app.avroom.anotherroompk.RoomPKCreateActivity
|
||||
import com.chwl.app.avroom.bean.RoomGameplayItem
|
||||
import com.chwl.app.avroom.singleroompk.SingleRoomPKCreateActivity
|
||||
import com.chwl.app.databinding.RoomGameplayDialogBinding
|
||||
import com.chwl.app.treasure_box.widget.GoldBoxHelper
|
||||
import com.chwl.app.ui.webview.CommonWebViewActivity
|
||||
import com.chwl.app.ui.webview.room_banner.RoomWebDialogActivity
|
||||
import com.chwl.app.utils.CommonJumpHelper
|
||||
import com.chwl.core.auth.AuthModel
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
import com.chwl.core.room.anotherroompk.SingleRoomPKModel
|
||||
import com.chwl.core.room.bean.RoomIcon
|
||||
import com.chwl.core.room.bean.RoomInfo
|
||||
import com.chwl.core.room.core.RoomDataService
|
||||
import com.chwl.core.room.game.bean.BaiShunGameConfig
|
||||
import com.chwl.core.room.model.AvRoomModel
|
||||
import com.chwl.core.super_admin.util.SuperAdminUtil
|
||||
import com.chwl.core.support.room.AudioRoomContext
|
||||
import com.chwl.core.utils.CurrentTimeUtils
|
||||
import com.chwl.library.utils.ResUtil
|
||||
import com.chwl.library.utils.SingleToastUtil
|
||||
import com.example.lib_utils.ktx.asLifecycle
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import com.google.gson.Gson
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
|
||||
class RoomGameplayDialog : BottomSheetDialogFragment() {
|
||||
|
||||
var isOnlyPK = false
|
||||
private lateinit var recycleView: RecyclerView
|
||||
|
||||
private var binding: RoomGameplayDialogBinding? = null
|
||||
private var compositeDisposable: CompositeDisposable? = null
|
||||
private val adapter = RoomGameplayAdapter()
|
||||
|
||||
var listener: RoomGameplayDialog.GameplayDialogListener? = null
|
||||
|
||||
override fun getTheme(): Int {
|
||||
return R.style.ErbanBottomSheetDialogDimFalse
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
binding = RoomGameplayDialogBinding.inflate(LayoutInflater.from(context))
|
||||
return binding?.root
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
return super.onCreateDialog(savedInstanceState).apply {
|
||||
this.setCanceledOnTouchOutside(true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
initView()
|
||||
|
||||
val recyclerView: RecyclerView = view.findViewById(R.id.recyclerView)
|
||||
recycleView = recyclerView
|
||||
|
||||
switchStatus(0)
|
||||
requestData()
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
adapter.setOnItemClickListener { _, view, position ->
|
||||
adapter.getItem(position)?.onItemClick(this)
|
||||
}
|
||||
binding?.recyclerView?.adapter = adapter
|
||||
}
|
||||
|
||||
override fun onAttach(context: Context) {
|
||||
super.onAttach(context)
|
||||
val lifecycleObserver = object : LifecycleEventObserver {
|
||||
override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) {
|
||||
if (event == Lifecycle.Event.ON_DESTROY) {
|
||||
context.asLifecycle()?.removeObserver(this)
|
||||
try {
|
||||
this@RoomGameplayDialog.dismissAllowingStateLoss()
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
context.asLifecycle()?.addObserver(lifecycleObserver)
|
||||
}
|
||||
|
||||
private fun requestData() {
|
||||
if (isOnlyPK) {
|
||||
loadSuccess(arrayListOf())
|
||||
} else {
|
||||
val dataService =
|
||||
AudioRoomContext.get()
|
||||
?.findAbility<RoomDataService>(RoomDataService::class.java.simpleName)
|
||||
val cacheKey = "gameplay_list#${parentFragment.hashCode()}"
|
||||
val list = dataService?.getData(cacheKey) as? List<RoomIcon>
|
||||
|
||||
if (!list.isNullOrEmpty()) {
|
||||
updateDialogHeight(list.size)
|
||||
loadSuccess(list)
|
||||
return
|
||||
}
|
||||
val disposable = AvRoomModel.get().roomGamePlayList
|
||||
.doOnError {
|
||||
loadFail(it)
|
||||
}
|
||||
.subscribe { it: List<RoomIcon> ->
|
||||
dataService?.putData(cacheKey, it)
|
||||
updateDialogHeight(it.size)
|
||||
loadSuccess(it)
|
||||
}
|
||||
getCompositeDisposable().add(disposable)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateDialogHeight(count: Int) {
|
||||
if (count > 10) {
|
||||
val layoutParams = recycleView.layoutParams
|
||||
layoutParams.height = 600
|
||||
recycleView.layoutParams = layoutParams
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadSuccess(list: List<RoomIcon>?) {
|
||||
var finalList = mutableListOf<RoomGameplayItem>()
|
||||
if (isOnlyPK) {
|
||||
finalList = getLocalList()
|
||||
}
|
||||
list?.let {
|
||||
finalList.addAll(list.map {
|
||||
RoomGameplayItem.RoomIconItem(it) { dialog, item ->
|
||||
jump(item)
|
||||
}
|
||||
})
|
||||
}
|
||||
if (finalList.isEmpty()) {
|
||||
switchStatus(-1)
|
||||
} else {
|
||||
adapter.setNewData(finalList)
|
||||
switchStatus(1)
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadFail(throwable: Throwable) {
|
||||
SingleToastUtil.showToast(throwable.message)
|
||||
val finalList = getLocalList()
|
||||
if (finalList.isEmpty()) {
|
||||
switchStatus(-2)
|
||||
} else {
|
||||
adapter.setNewData(finalList)
|
||||
switchStatus(1)
|
||||
}
|
||||
}
|
||||
|
||||
private fun switchStatus(status: Int) {
|
||||
when (status) {
|
||||
// loading
|
||||
0 -> {
|
||||
binding?.recyclerView?.isVisible = false
|
||||
binding?.layoutStatus?.isVisible = true
|
||||
binding?.groupStatusLoading?.isVisible = true
|
||||
binding?.groupStatusText?.isVisible = false
|
||||
}
|
||||
|
||||
// 有数据
|
||||
1 -> {
|
||||
binding?.recyclerView?.isVisible = true
|
||||
binding?.layoutStatus?.isVisible = false
|
||||
}
|
||||
|
||||
// 空数据
|
||||
-1 -> {
|
||||
binding?.recyclerView?.isVisible = false
|
||||
binding?.layoutStatus?.isVisible = true
|
||||
binding?.groupStatusLoading?.isVisible = false
|
||||
binding?.groupStatusText?.isVisible = true
|
||||
binding?.tvStatus?.setText(R.string.avroom_presenter_roomnewbiehellowwordpresenter_01)
|
||||
}
|
||||
|
||||
// 失败
|
||||
else -> {
|
||||
binding?.recyclerView?.isVisible = false
|
||||
binding?.layoutStatus?.isVisible = true
|
||||
binding?.groupStatusLoading?.isVisible = false
|
||||
binding?.groupStatusText?.isVisible = true
|
||||
binding?.tvStatus?.setText(R.string.request_failed_again_later)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun jump(data: RoomIcon) {
|
||||
dismissAllowingStateLoss()
|
||||
if (data.isFindLove()) {
|
||||
GoldBoxHelper.handleBoxClick(context)
|
||||
} else if (data.isBaiShunGame()) {
|
||||
jumpBaiShunGame(data)
|
||||
} else {
|
||||
val url = data.skipContent
|
||||
if (data.skipType == 3 && !url.isNullOrEmpty()) {
|
||||
if (data.showType == 2) {
|
||||
RoomWebDialogActivity.start(requireContext(), url, false)
|
||||
} else {
|
||||
CommonWebViewActivity.start(context, url)
|
||||
}
|
||||
} else {
|
||||
CommonJumpHelper.bannerJump(context, data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
onUnbindContext()
|
||||
}
|
||||
|
||||
private fun getCompositeDisposable(): CompositeDisposable {
|
||||
var disposable = compositeDisposable
|
||||
if (disposable == null) {
|
||||
disposable = CompositeDisposable()
|
||||
compositeDisposable = disposable
|
||||
}
|
||||
return disposable
|
||||
}
|
||||
|
||||
private fun onUnbindContext() {
|
||||
compositeDisposable?.dispose()
|
||||
compositeDisposable = null
|
||||
}
|
||||
|
||||
private fun jumpBaiShunGame(data: RoomIcon) {
|
||||
try {
|
||||
val url = data.skipContent
|
||||
val ruleValue = Gson().fromJson<RoomIcon.RuleValueBean>(
|
||||
data.ruleValue,
|
||||
RoomIcon.RuleValueBean::class.java
|
||||
)
|
||||
val config = Gson().fromJson<BaiShunGameConfig>(
|
||||
ruleValue.RESERVE,
|
||||
BaiShunGameConfig::class.java
|
||||
)
|
||||
if (config != null && url != null) {
|
||||
config.reloadDynamicParams()
|
||||
listener?.onShowBaiShunGame(url, config)
|
||||
// BaiShunGameWebActivity.start(requireContext(), url, config)
|
||||
} else {
|
||||
SingleToastUtil.showToast(R.string.manager_trtc_trtcengineadapter_042)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
private fun getLocalList(): MutableList<RoomGameplayItem> {
|
||||
val list = ArrayList<RoomGameplayItem>()
|
||||
getPkItem()?.let {
|
||||
list.add(it)
|
||||
}
|
||||
getRoomPkItem()?.let {
|
||||
list.add(it)
|
||||
}
|
||||
// getSingleRoomPkItem()?.let {
|
||||
// list.add(it)
|
||||
// }
|
||||
return list
|
||||
}
|
||||
|
||||
private fun getPkItem(): RoomGameplayItem? {
|
||||
val context = context ?: return null
|
||||
if (SuperAdminUtil.isSuperAdmin()) {
|
||||
return null
|
||||
}
|
||||
if (AvRoomDataManager.get().roomType != RoomInfo.ROOMTYPE_HOME_PARTY && AvRoomDataManager.get().roomType != RoomInfo.ROOMTYPE_PARTY && AvRoomDataManager.get().roomType != RoomInfo.ROOMTYPE_REVELRY) {
|
||||
return null
|
||||
}
|
||||
val roomInfo = AvRoomDataManager.get().mCurrentRoomInfo
|
||||
if (roomInfo == null) {
|
||||
return null
|
||||
}
|
||||
if (AvRoomDataManager.get().isManager && !AvRoomDataManager.get().isCpRoom) {
|
||||
val str =
|
||||
if (AvRoomDataManager.get().isOpenPKMode) context.resources.getString(R.string.room_was_in_PK) else context.resources.getString(
|
||||
R.string.room_PK_mode
|
||||
)
|
||||
val icon =
|
||||
if (AvRoomDataManager.get().isOpenPKMode) R.drawable.room_gameplay_ic_team_pk else R.drawable.room_gameplay_ic_team_pk
|
||||
return RoomGameplayItem.CustomItem(str, icon) { dialog, item ->
|
||||
if (AvRoomDataManager.get().isDatingMode) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_dialog_roomoperationdialog_01))
|
||||
return@CustomItem
|
||||
}
|
||||
if (AvRoomDataManager.get().isOpenAnotherPKMode) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_dialog_roomoperationdialog_02))
|
||||
return@CustomItem
|
||||
}
|
||||
dialog.dismissAllowingStateLoss()
|
||||
CreatePKActivity.start(context)
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
private fun getRoomPkItem(): RoomGameplayItem? {
|
||||
val context = context ?: return null
|
||||
if (SuperAdminUtil.isSuperAdmin()) {
|
||||
return null
|
||||
}
|
||||
if (AvRoomDataManager.get().roomType != RoomInfo.ROOMTYPE_HOME_PARTY && AvRoomDataManager.get().roomType != RoomInfo.ROOMTYPE_PARTY && AvRoomDataManager.get().roomType != RoomInfo.ROOMTYPE_REVELRY) {
|
||||
return null
|
||||
}
|
||||
val roomInfo = AvRoomDataManager.get().mCurrentRoomInfo
|
||||
if (roomInfo == null) {
|
||||
return null
|
||||
}
|
||||
if ((AvRoomDataManager.get().isRoomOwner || AvRoomDataManager.get().isSuperAdmin) &&
|
||||
!AvRoomDataManager.get().isCpRoom
|
||||
) {
|
||||
val str =
|
||||
if (AvRoomDataManager.get().isOpenAnotherPKMode) ResUtil.getString(R.string.avroom_dialog_roomoperationdialog_03) else ResUtil.getString(
|
||||
R.string.avroom_dialog_roomoperationdialog_04
|
||||
)
|
||||
val icon =
|
||||
if (AvRoomDataManager.get().isOpenAnotherPKMode) R.drawable.room_gameplay_ic_room_pk else R.drawable.room_gameplay_ic_room_pk
|
||||
return RoomGameplayItem.CustomItem(str, icon) { dialog, item ->
|
||||
if (AvRoomDataManager.get().isDatingMode) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_dialog_roomoperationdialog_05))
|
||||
return@CustomItem
|
||||
}
|
||||
if (AvRoomDataManager.get().isOpenPKMode) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_dialog_roomoperationdialog_06))
|
||||
return@CustomItem
|
||||
}
|
||||
if (AvRoomDataManager.get().isOpenAnotherPKMode) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_dialog_roomoperationdialog_07))
|
||||
return@CustomItem
|
||||
}
|
||||
dismissAllowingStateLoss()
|
||||
RoomPKCreateActivity.start(context)
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
private fun getSingleRoomPkItem(): RoomGameplayItem? {
|
||||
val context = context ?: return null
|
||||
if (SuperAdminUtil.isSuperAdmin()) {
|
||||
return null
|
||||
}
|
||||
if (AvRoomDataManager.get().isOpenGame) {
|
||||
return null
|
||||
}
|
||||
if (!AvRoomDataManager.get().isSingleRoom) {
|
||||
return null
|
||||
}
|
||||
val pkBean = AvRoomDataManager.get().roomPkLiveData.value
|
||||
if (AvRoomDataManager.get().isRoomOwner && !AvRoomDataManager.get().isCpRoom) {
|
||||
var str =
|
||||
if (AvRoomDataManager.get().isOpenAnotherPKMode) ResUtil.getString(R.string.avroom_dialog_roomoperationdialog_08) else ResUtil.getString(
|
||||
R.string.avroom_dialog_roomoperationdialog_09
|
||||
)
|
||||
if (pkBean != null) {
|
||||
if (pkBean.pkState == 2 &&
|
||||
(pkBean.winUid == 0L || pkBean.winUid == AuthModel.get().currentUid || pkBean.penaltyEndTime < CurrentTimeUtils.getCurrentTime())
|
||||
) {
|
||||
str = ResUtil.getString(R.string.avroom_dialog_roomoperationdialog_010)
|
||||
}
|
||||
}
|
||||
val icon =
|
||||
if (AvRoomDataManager.get().isOpenAnotherPKMode) R.drawable.ic_room_opt_single_pk_open else R.drawable.ic_room_opt_single_pk_in
|
||||
val finalStr = str
|
||||
return RoomGameplayItem.CustomItem(str, icon) { dialog, item ->
|
||||
if (pkBean != null && ResUtil.getString(R.string.avroom_dialog_roomoperationdialog_011) == finalStr) {
|
||||
SingleRoomPKModel.endSingleRoomPk(pkBean.roundId)
|
||||
.doOnSuccess { s: String? ->
|
||||
SingleToastUtil.showToast(
|
||||
ResUtil.getString(R.string.avroom_dialog_roomoperationdialog_012)
|
||||
)
|
||||
}
|
||||
.doOnError { throwable: Throwable ->
|
||||
SingleToastUtil.showToast(
|
||||
throwable.message
|
||||
)
|
||||
}
|
||||
.subscribe()
|
||||
dismissAllowingStateLoss()
|
||||
return@CustomItem
|
||||
}
|
||||
if (AvRoomDataManager.get().isOpenAnotherPKMode) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_dialog_roomoperationdialog_013))
|
||||
return@CustomItem
|
||||
}
|
||||
dismissAllowingStateLoss()
|
||||
SingleRoomPKCreateActivity.start(context)
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
interface GameplayDialogListener {
|
||||
fun onShowBaiShunGame(url: String, config: BaiShunGameConfig)
|
||||
}
|
||||
}
|
@@ -14,6 +14,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.chwl.app.avroom.activity.RoomTypeSwitchActivity;
|
||||
import com.coorchice.library.utils.LogUtils;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
@@ -115,22 +116,23 @@ public class RoomOperationDialog extends BottomSheetDialog {
|
||||
optAdapter = new OptAdapter(context, null);
|
||||
addRoomAlbum(optAdapter);
|
||||
addDatingAction(optAdapter);
|
||||
addPKAction(optAdapter);
|
||||
addRoomPKAction(optAdapter);
|
||||
// addPKAction(optAdapter);
|
||||
// addRoomPKAction(optAdapter);
|
||||
addSingleRoomPKAction(optAdapter);
|
||||
addSendBroadcastAction(optAdapter);
|
||||
// addInviteFansOptAdapter();
|
||||
addVipSendBroadcastAction(optAdapter);
|
||||
addRedPacketAction(optAdapter);
|
||||
// addRedPacketAction(optAdapter);
|
||||
addRoomSettingAction(optAdapter);
|
||||
addGiftEffectAction(optAdapter);
|
||||
addOpenOrClosePublicScreenAction(optAdapter);
|
||||
// addOpenOrClosePublicScreenAction(optAdapter);
|
||||
// addRedPackageSwitch();
|
||||
addCleanScreenAction(optAdapter);
|
||||
// addRoomLimit(optAdapter);
|
||||
addGiftValueAction(optAdapter);
|
||||
// addGiftValueAction(optAdapter);
|
||||
addSuperAdminAction(optAdapter);
|
||||
addShieldReportAction(optAdapter);
|
||||
addRoomTypeSwitchAction(optAdapter);
|
||||
rvOPtList.setAdapter(optAdapter);
|
||||
}
|
||||
|
||||
@@ -191,7 +193,7 @@ public class RoomOperationDialog extends BottomSheetDialog {
|
||||
return;
|
||||
}
|
||||
RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
|
||||
if (roomInfo == null || roomInfo.getIsPermitRoom() != 1) {
|
||||
if (roomInfo == null) {
|
||||
return;
|
||||
}
|
||||
if ((AvRoomDataManager.get().isRoomOwner() || AvRoomDataManager.get().isSuperAdmin()) &&
|
||||
@@ -286,10 +288,7 @@ public class RoomOperationDialog extends BottomSheetDialog {
|
||||
if (SuperAdminUtil.isSuperAdmin()) {
|
||||
return;
|
||||
}
|
||||
if (AvRoomDataManager.get().isOpenGame()) {
|
||||
return;
|
||||
}
|
||||
if (AvRoomDataManager.get().isSingleRoom()) {
|
||||
if (AvRoomDataManager.get().getRoomType() != RoomInfo.ROOMTYPE_HOME_PARTY) {
|
||||
return;
|
||||
}
|
||||
if (AvRoomDataManager.get().isManager() && !AvRoomDataManager.get().isCpRoom()) {
|
||||
@@ -556,6 +555,18 @@ public class RoomOperationDialog extends BottomSheetDialog {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 房间类型切换
|
||||
*
|
||||
* @param optAdapter
|
||||
*/
|
||||
private void addRoomTypeSwitchAction(OptAdapter optAdapter) {
|
||||
if (RoomTypeSwitchActivity.Companion.isCanSwitch()) {
|
||||
optAdapter.addData(new OptAction(R.drawable.icon_room_type_switch,
|
||||
getContext().getResources().getString(R.string.room_type), () -> RoomTypeSwitchActivity.Companion.start(getContext())));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 超管管理
|
||||
*/
|
||||
|
@@ -1,14 +1,13 @@
|
||||
package com.chwl.app.avroom.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -17,18 +16,16 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.netease.nim.uikit.support.glide.GlideApp;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.common.widget.CircleImageView;
|
||||
import com.chwl.app.databinding.RoomTeamPkResultDialogBinding;
|
||||
import com.chwl.app.ui.widget.dialog.BaseDialog;
|
||||
import com.chwl.library.common.util.Utils;
|
||||
import com.chwl.app.ui.widget.recyclerview.decoration.ColorDecoration;
|
||||
import com.chwl.core.auth.AuthModel;
|
||||
import com.chwl.core.room.pk.bean.PKTeamInfo;
|
||||
import com.chwl.core.room.pk.bean.PKTeamMember;
|
||||
import com.chwl.core.room.pk.bean.RoomPkData;
|
||||
import com.chwl.library.utils.FormatUtils;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.netease.nim.uikit.support.glide.GlideApp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -40,19 +37,14 @@ import lombok.Data;
|
||||
* @Description
|
||||
* @Date 2019/1/4
|
||||
*/
|
||||
public class PKResultDialog extends BaseDialog {
|
||||
public class RoomTeamPKResultDialog extends BaseDialog {
|
||||
private final static int TEAM_RED = PKTeamInfo.TEAM_RED;
|
||||
private final static int TEAM_BLUE = PKTeamInfo.TEAM_BLUE;
|
||||
|
||||
private final static int PK_RESULT_VICTORY = 1;
|
||||
private final static int PK_RESULT_FAIL = -1;
|
||||
private final static int PK_RESULT_TIE = 0;
|
||||
|
||||
private LinearLayout llGuardianName;
|
||||
private LinearLayout llGuardianValue;
|
||||
private LinearLayout llPkMember;
|
||||
private LinearLayout llScore;
|
||||
private ImageView ivResultBottom;
|
||||
private RoomTeamPkResultDialogBinding binding;
|
||||
private ImageView ivResultTop;
|
||||
private RecyclerView rvList;
|
||||
private TextView tvScore;
|
||||
@@ -60,9 +52,6 @@ public class PKResultDialog extends BaseDialog {
|
||||
private TextView tvGuardianValue;
|
||||
private TextView tvTeamStatus;
|
||||
private TextView tvSeeOtherTeam;
|
||||
private TextView tvTeamLose;
|
||||
private LinearLayout llResultTie;
|
||||
private TextView tvTieScore;
|
||||
|
||||
private int pkResult = PK_RESULT_TIE;
|
||||
private boolean isShowOpponent = false;//是否在显示对手
|
||||
@@ -70,8 +59,9 @@ public class PKResultDialog extends BaseDialog {
|
||||
private RoomPkData roomPkData;
|
||||
private PKTeamInfo teamInfo;
|
||||
|
||||
public PKResultDialog(Context context, RoomPkData roomPkData) {
|
||||
public RoomTeamPKResultDialog(Context context, RoomPkData roomPkData) {
|
||||
super(context, R.style.full_screen_dialog);
|
||||
binding = RoomTeamPkResultDialogBinding.inflate(LayoutInflater.from(getContext()));
|
||||
Window window = getWindow();
|
||||
if (window != null) {
|
||||
WindowManager.LayoutParams lps = window.getAttributes();
|
||||
@@ -87,31 +77,20 @@ public class PKResultDialog extends BaseDialog {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setCanceledOnTouchOutside(true);
|
||||
setContentView(R.layout.dialog_pk_result);
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
llPkMember = (LinearLayout) findViewById(R.id.ll_pk_member);
|
||||
llScore = (LinearLayout) findViewById(R.id.ll_score);
|
||||
|
||||
ivResultBottom = (ImageView) findViewById(R.id.iv_result_bottom);
|
||||
ivResultTop = (ImageView) findViewById(R.id.iv_result_top);
|
||||
rvList = (RecyclerView) findViewById(R.id.rv_list);
|
||||
rvList = (RecyclerView) findViewById(R.id.recycler_view);
|
||||
|
||||
tvScore = (TextView) findViewById(R.id.tv_score);
|
||||
llGuardianName = (LinearLayout) findViewById(R.id.ll_guardian_name);
|
||||
llGuardianValue = (LinearLayout) findViewById(R.id.ll_guardian_value);
|
||||
tvGuardianName = (TextView) findViewById(R.id.tv_guardian_name);
|
||||
tvGuardianValue = (TextView) findViewById(R.id.tv_guardian_value);
|
||||
tvTeamStatus = (TextView) findViewById(R.id.tv_team_status);
|
||||
tvSeeOtherTeam = (TextView) findViewById(R.id.tv_see_other_team);
|
||||
tvTeamLose = (TextView) findViewById(R.id.tv_team_lose);
|
||||
|
||||
llResultTie = (LinearLayout) findViewById(R.id.ll_result_tie);
|
||||
tvTieScore = (TextView) findViewById(R.id.tv_tie_score);
|
||||
|
||||
|
||||
adapter = new PkResultMemberAdapter(null);
|
||||
rvList.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false));
|
||||
rvList.addItemDecoration(new ColorDecoration(Color.TRANSPARENT, Utils.dip2px(getContext(), 10), 0, true));
|
||||
rvList.setAdapter(adapter);
|
||||
|
||||
tvSeeOtherTeam.setOnClickListener(v -> {
|
||||
@@ -130,28 +109,29 @@ public class PKResultDialog extends BaseDialog {
|
||||
return;
|
||||
}
|
||||
if (roomPkData.getVoteMode() == RoomPkData.VOTE_MODE_PERSON) {
|
||||
llGuardianName.setVisibility(View.GONE);
|
||||
llGuardianValue.setVisibility(View.GONE);
|
||||
binding.groupGuardianName.setVisibility(View.GONE);
|
||||
binding.groupGuardianValue.setVisibility(View.GONE);
|
||||
}
|
||||
int result = roomPkData.getResult();
|
||||
int teamId = findTeamIdByAccount(String.valueOf(AuthModel.get().getCurrentUid()));
|
||||
if (teamId == PKTeamInfo.TEAM_NONE) {
|
||||
//观众
|
||||
if (result == RoomPkData.PK_RESULT_DRAW) {
|
||||
teamInfo = findTeamByTeamId(PKTeamInfo.TEAM_RED);
|
||||
pkResult = PK_RESULT_TIE;
|
||||
tvTeamStatus.setText(ResUtil.getString(R.string.avroom_dialog_pkresultdialog_01));
|
||||
llPkMember.setVisibility(View.GONE);
|
||||
llScore.setVisibility(View.GONE);
|
||||
llGuardianName.setVisibility(View.GONE);
|
||||
llGuardianValue.setVisibility(View.GONE);
|
||||
llResultTie.setVisibility(View.VISIBLE);
|
||||
tvTieScore.setText(FormatUtils.formatPKValue(roomPkData.getTeams().get(0).getScore()));
|
||||
refreshBgByStatus();
|
||||
if (teamInfo != null) {
|
||||
tvScore.setText(teamInfo.getScore() + "");
|
||||
} else {
|
||||
tvScore.setText("0");
|
||||
}
|
||||
binding.groupGuardianName.setVisibility(View.GONE);
|
||||
binding.groupGuardianValue.setVisibility(View.GONE);
|
||||
refreshView(pkResult, teamInfo);
|
||||
} else {
|
||||
pkResult = PK_RESULT_VICTORY;
|
||||
teamInfo = findTeamByTeamId(result);
|
||||
refreshView(pkResult, teamInfo);
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -161,10 +141,13 @@ public class PKResultDialog extends BaseDialog {
|
||||
if (result == RoomPkData.PK_RESULT_DRAW) {
|
||||
pkResult = PK_RESULT_TIE;
|
||||
tvTeamStatus.setText(ResUtil.getString(R.string.avroom_dialog_pkresultdialog_02));
|
||||
tvScore.setText(teamInfo.getScore() + "");
|
||||
llGuardianName.setVisibility(View.GONE);
|
||||
llGuardianValue.setVisibility(View.GONE);
|
||||
tvTeamLose.setVisibility(View.GONE);
|
||||
if (teamInfo != null) {
|
||||
tvScore.setText(teamInfo.getScore() + "");
|
||||
} else {
|
||||
tvScore.setText("0");
|
||||
}
|
||||
binding.groupGuardianName.setVisibility(View.GONE);
|
||||
binding.groupGuardianValue.setVisibility(View.GONE);
|
||||
refreshView(pkResult, teamInfo);
|
||||
|
||||
} else {
|
||||
@@ -175,7 +158,7 @@ public class PKResultDialog extends BaseDialog {
|
||||
}
|
||||
|
||||
|
||||
private void showTeamMembers(PKTeamInfo teamInfo) {
|
||||
private void showTeamMembers(int pkResult, PKTeamInfo teamInfo) {
|
||||
List<PkResultMember> pkResultMembers = new ArrayList<>();
|
||||
for (PKTeamMember pkTeamMember : teamInfo.getTeamMembers()) {
|
||||
PkResultMember resultMember = new PkResultMember();
|
||||
@@ -184,22 +167,29 @@ public class PKResultDialog extends BaseDialog {
|
||||
resultMember.isMVP = pkTeamMember.getUid().equals(teamInfo.getMvp());
|
||||
pkResultMembers.add(resultMember);
|
||||
}
|
||||
if (pkResult == PK_RESULT_VICTORY) {
|
||||
adapter.setAvatarBg(R.drawable.room_team_pk_result_avatar_bg_win);
|
||||
} else if (pkResult == PK_RESULT_FAIL) {
|
||||
adapter.setAvatarBg(R.drawable.room_team_pk_result_avatar_bg_fail);
|
||||
} else {
|
||||
adapter.setAvatarBg(R.drawable.room_team_pk_result_avatar_bg_draw);
|
||||
}
|
||||
adapter.setNewData(pkResultMembers);
|
||||
}
|
||||
|
||||
private void showColorByTeam(PKTeamInfo pkTeamInfo) {
|
||||
if (pkTeamInfo.getTeam() == PKTeamInfo.TEAM_RED) {
|
||||
tvScore.setTextColor(getContext().getResources().getColor(R.color.color_FD4D72));
|
||||
tvGuardianName.setTextColor(getContext().getResources().getColor(R.color.color_FD4D72));
|
||||
tvGuardianValue.setTextColor(getContext().getResources().getColor(R.color.color_FD4D72));
|
||||
tvTeamStatus.setTextColor(getContext().getResources().getColor(R.color.color_FD4D72));
|
||||
tvSeeOtherTeam.setTextColor(getContext().getResources().getColor(R.color.color_59B9FB));
|
||||
tvScore.setTextColor(getContext().getResources().getColor(R.color.color_FF396F));
|
||||
tvGuardianName.setTextColor(getContext().getResources().getColor(R.color.color_FF396F));
|
||||
tvGuardianValue.setTextColor(getContext().getResources().getColor(R.color.color_FF396F));
|
||||
tvTeamStatus.setTextColor(getContext().getResources().getColor(R.color.color_FF4B81));
|
||||
tvSeeOtherTeam.setTextColor(getContext().getResources().getColor(R.color.color_73B8FF));
|
||||
} else if (pkTeamInfo.getTeam() == PKTeamInfo.TEAM_BLUE) {
|
||||
tvScore.setTextColor(getContext().getResources().getColor(R.color.color_59B9FB));
|
||||
tvGuardianName.setTextColor(getContext().getResources().getColor(R.color.color_59B9FB));
|
||||
tvGuardianValue.setTextColor(getContext().getResources().getColor(R.color.color_59B9FB));
|
||||
tvTeamStatus.setTextColor(getContext().getResources().getColor(R.color.color_59B9FB));
|
||||
tvSeeOtherTeam.setTextColor(getContext().getResources().getColor(R.color.color_FD4D72));
|
||||
tvScore.setTextColor(getContext().getResources().getColor(R.color.color_73B8FF));
|
||||
tvGuardianName.setTextColor(getContext().getResources().getColor(R.color.color_73B8FF));
|
||||
tvGuardianValue.setTextColor(getContext().getResources().getColor(R.color.color_73B8FF));
|
||||
tvTeamStatus.setTextColor(getContext().getResources().getColor(R.color.color_73B8FF));
|
||||
tvSeeOtherTeam.setTextColor(getContext().getResources().getColor(R.color.color_FF4B81));
|
||||
} else {
|
||||
//未知
|
||||
}
|
||||
@@ -207,14 +197,11 @@ public class PKResultDialog extends BaseDialog {
|
||||
|
||||
private void refreshBgByStatus() {
|
||||
if (pkResult == PK_RESULT_VICTORY) {
|
||||
ivResultTop.setImageResource(R.mipmap.pk_result_victory_top);
|
||||
ivResultBottom.setImageResource(R.mipmap.pk_result_victory_bottom);
|
||||
ivResultTop.setImageResource(R.drawable.room_team_pk_result_top_win);
|
||||
} else if (pkResult == PK_RESULT_FAIL) {
|
||||
ivResultTop.setImageResource(R.mipmap.pk_result_fail_top);
|
||||
ivResultBottom.setImageResource(R.mipmap.pk_result_fail_bottom);
|
||||
ivResultTop.setImageResource(R.drawable.room_team_pk_result_top_fail);
|
||||
} else if (pkResult == PK_RESULT_TIE) {
|
||||
ivResultTop.setImageResource(R.mipmap.pk_result_tie_top);
|
||||
ivResultBottom.setImageResource(R.mipmap.pk_result_tie_bottom);
|
||||
ivResultTop.setImageResource(R.drawable.room_team_pk_result_top_draw);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,7 +255,7 @@ public class PKResultDialog extends BaseDialog {
|
||||
|
||||
private void refreshView(int pkResult, PKTeamInfo teamInfo) {
|
||||
refreshBgByStatus();
|
||||
showTeamMembers(teamInfo);
|
||||
showTeamMembers(pkResult, teamInfo);
|
||||
showColorByTeam(teamInfo);
|
||||
|
||||
tvScore.setText(FormatUtils.formatPKValue(teamInfo.getScore()));
|
||||
@@ -291,7 +278,6 @@ public class PKResultDialog extends BaseDialog {
|
||||
if (pkResult == PK_RESULT_VICTORY) {
|
||||
tvTeamStatus.setText(ResUtil.getString(R.string.avroom_dialog_pkresultdialog_06));
|
||||
} else if (pkResult == PK_RESULT_FAIL) {
|
||||
tvTeamLose.setVisibility(View.VISIBLE);
|
||||
}
|
||||
tvSeeOtherTeam.setText(ResUtil.getString(R.string.avroom_dialog_pkresultdialog_07));
|
||||
} else {
|
||||
@@ -305,7 +291,6 @@ public class PKResultDialog extends BaseDialog {
|
||||
if (pkResult == PK_RESULT_VICTORY) {
|
||||
tvTeamStatus.setText(ResUtil.getString(R.string.avroom_dialog_pkresultdialog_011));
|
||||
} else if (pkResult == PK_RESULT_FAIL) {
|
||||
tvTeamLose.setVisibility(View.VISIBLE);
|
||||
}
|
||||
tvSeeOtherTeam.setText(ResUtil.getString(R.string.avroom_dialog_pkresultdialog_012));
|
||||
} else {
|
||||
@@ -327,20 +312,26 @@ public class PKResultDialog extends BaseDialog {
|
||||
|
||||
class PkResultMemberAdapter extends BaseQuickAdapter<PkResultMember, BaseViewHolder> {
|
||||
|
||||
private int avatarBgResId = R.drawable.room_team_pk_result_avatar_bg_win;
|
||||
|
||||
public void setAvatarBg(int redId) {
|
||||
this.avatarBgResId = redId;
|
||||
}
|
||||
|
||||
public PkResultMemberAdapter(@Nullable List<PkResultMember> data) {
|
||||
super(R.layout.item_pk_result_member_rv, data);
|
||||
super(R.layout.room_team_pk_result_item, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, PkResultMember item) {
|
||||
CircleImageView avatar = helper.getView(R.id.civ_avatar);
|
||||
ImageView avatarBg = helper.getView(R.id.iv_avatar_bg);
|
||||
avatarBg.setImageResource(avatarBgResId);
|
||||
ImageView avatar = helper.getView(R.id.iv_avatar);
|
||||
GlideApp.with(avatar)
|
||||
.load(item.avatar)
|
||||
.placeholder(R.drawable.default_avatar)
|
||||
.dontAnimate()
|
||||
.into(avatar);
|
||||
|
||||
helper.setVisible(R.id.iv_mvp_mark, item.isMVP);
|
||||
}
|
||||
}
|
||||
|
325
app/src/main/java/com/chwl/app/avroom/dialog/RoomTeamPkDialog.kt
Normal file
325
app/src/main/java/com/chwl/app/avroom/dialog/RoomTeamPkDialog.kt
Normal file
@@ -0,0 +1,325 @@
|
||||
package com.chwl.app.avroom.dialog
|
||||
|
||||
import android.text.TextUtils
|
||||
import android.view.WindowManager
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.view.isVisible
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.RoomTeamPkDialogBinding
|
||||
import com.chwl.app.ui.utils.loadAvatar
|
||||
import com.chwl.app.ui.widget.dialog.CommonTipDialog
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
import com.chwl.core.room.pk.bean.PKTeamInfo
|
||||
import com.chwl.core.room.pk.bean.RoomPKInvitedUpMicMember
|
||||
import com.chwl.core.room.pk.bean.RoomPkData
|
||||
import com.chwl.core.room.pk.event.PKDataUpdateEvent
|
||||
import com.chwl.core.room.pk.event.PKTimeFinishEvent
|
||||
import com.chwl.core.room.pk.event.PKTimeTickEvent
|
||||
import com.chwl.core.room.pk.model.PkModel
|
||||
import com.chwl.library.utils.FormatUtils
|
||||
import com.chwl.library.utils.ResUtil
|
||||
import com.chwl.library.utils.SingleToastUtil
|
||||
import io.reactivex.SingleObserver
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.disposables.Disposable
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
import java.util.Locale
|
||||
|
||||
class RoomTeamPkDialog : BaseDialogFragment<RoomTeamPkDialogBinding>() {
|
||||
|
||||
private var compositeDisposable: CompositeDisposable? = null
|
||||
|
||||
private var onActionListener: OnActionListener? = null
|
||||
|
||||
override var width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
|
||||
override fun init() {
|
||||
binding.layoutRoot.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
binding.userListBlue.showBlueStyle()
|
||||
binding.ivClose.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
binding.tvNext.setOnClickListener {
|
||||
if (PkModel.get().isFighting) {
|
||||
onRestartClick()
|
||||
} else {
|
||||
onStartClick()
|
||||
}
|
||||
}
|
||||
binding.ivAvatarRed.setOnClickListener {
|
||||
if (!PkModel.get().isFighting) {
|
||||
onSeatClick(PKTeamInfo.TEAM_RED)
|
||||
}
|
||||
}
|
||||
binding.ivAvatarBlue.setOnClickListener {
|
||||
if (!PkModel.get().isFighting) {
|
||||
onSeatClick(PKTeamInfo.TEAM_BLUE)
|
||||
}
|
||||
}
|
||||
binding.userListRed.setOnClickListener {
|
||||
if (!PkModel.get().isFighting) {
|
||||
onSeatClick(PKTeamInfo.TEAM_RED)
|
||||
}
|
||||
}
|
||||
binding.userListBlue.setOnClickListener {
|
||||
if (!PkModel.get().isFighting) {
|
||||
onSeatClick(PKTeamInfo.TEAM_BLUE)
|
||||
}
|
||||
}
|
||||
updateView()
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
EventBus.getDefault().register(this)
|
||||
compositeDisposable = CompositeDisposable()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
EventBus.getDefault().unregister(this)
|
||||
compositeDisposable?.dispose()
|
||||
}
|
||||
|
||||
fun setOnActionListener(onActionListener: OnActionListener?) {
|
||||
this.onActionListener = onActionListener
|
||||
}
|
||||
|
||||
fun updateView() {
|
||||
if (_binding == null) {
|
||||
return
|
||||
}
|
||||
updateTeamUserList()
|
||||
updateTime()
|
||||
updateProgress()
|
||||
if (PkModel.get().isFighting) {
|
||||
binding.tvNext.setText(R.string.pk_restart)
|
||||
} else {
|
||||
binding.tvNext.setText(R.string.start_pk)
|
||||
}
|
||||
updateManageButtonVisible(AvRoomDataManager.get().isManager)
|
||||
}
|
||||
|
||||
private fun updateTeamUserList() {
|
||||
val pkMemberInfoList = PkModel.get().pkMemberInfoList
|
||||
val redList =
|
||||
pkMemberInfoList.filter { it.teamId == PKTeamInfo.TEAM_RED }.take(4).mapNotNull {
|
||||
it.userInfo
|
||||
}
|
||||
val blueList =
|
||||
pkMemberInfoList.filter { it.teamId == PKTeamInfo.TEAM_BLUE }.take(4).mapNotNull {
|
||||
it.userInfo
|
||||
}
|
||||
binding.userListRed.updateData(redList.drop(1).map {
|
||||
it.avatar
|
||||
})
|
||||
binding.userListBlue.updateData(blueList.drop(1).map {
|
||||
it.avatar
|
||||
})
|
||||
binding.ivAvatarRed.loadAvatar(redList.firstOrNull()?.avatar)
|
||||
binding.ivAvatarBlue.loadAvatar(blueList.firstOrNull()?.avatar)
|
||||
}
|
||||
|
||||
private fun updateManageButtonVisible(isVisible: Boolean) {
|
||||
val dimensionRatio: String
|
||||
if (isVisible) {
|
||||
binding.ivBg.setImageResource(R.drawable.room_team_pk_bg)
|
||||
binding.tvNext.isVisible = true
|
||||
dimensionRatio = "309:379"
|
||||
} else {
|
||||
binding.ivBg.setImageResource(R.drawable.room_team_pk_bg_no_manage)
|
||||
binding.tvNext.isVisible = false
|
||||
dimensionRatio = "309:324"
|
||||
}
|
||||
val params = binding.layoutContent.layoutParams as ConstraintLayout.LayoutParams
|
||||
params.dimensionRatio = dimensionRatio
|
||||
binding.layoutContent.layoutParams = params
|
||||
}
|
||||
|
||||
private fun updateTime() {
|
||||
if (_binding == null) {
|
||||
return
|
||||
}
|
||||
val roomPkData = PkModel.get().curPkInfo
|
||||
val pkTimeUntilEnd: Long
|
||||
if (roomPkData?.pkStatus != RoomPkData.PK_STATUS_IN_PK) {
|
||||
pkTimeUntilEnd = roomPkData?.duration ?: 0
|
||||
} else {
|
||||
pkTimeUntilEnd = roomPkData.curPkTimeUntilEnd
|
||||
}
|
||||
binding.tvTime.text =
|
||||
String.format(Locale.ENGLISH, "%1$02d:%2$02d", pkTimeUntilEnd / 60, pkTimeUntilEnd % 60)
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onPKDataUpdateEvent(event: PKDataUpdateEvent) {
|
||||
updateProgress()
|
||||
if (event.type == PKDataUpdateEvent.TYPE_RESULT) {
|
||||
safeDismiss()
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateProgress() {
|
||||
if (_binding == null) {
|
||||
return
|
||||
}
|
||||
val roomPkData = PkModel.get().curPkInfo
|
||||
if (roomPkData?.pkStatus != RoomPkData.PK_STATUS_IN_PK) {
|
||||
updateProgress(0, 0)
|
||||
return
|
||||
}
|
||||
val redTeam = PkModel.get().findTeamByTeamId(PKTeamInfo.TEAM_RED)
|
||||
val blueTeam = PkModel.get().findTeamByTeamId(PKTeamInfo.TEAM_BLUE)
|
||||
if (redTeam == null || blueTeam == null) {
|
||||
updateProgress(0, 0)
|
||||
return
|
||||
}
|
||||
updateProgress(redTeam.score, blueTeam.score)
|
||||
}
|
||||
|
||||
private fun updateProgress(redScore: Long, blueScore: Long) {
|
||||
val totalScore = redScore + blueScore
|
||||
if (totalScore > 0) {
|
||||
binding.tvScoreRed.text = FormatUtils.formatPKValue(redScore)
|
||||
binding.tvScoreBlue.text = FormatUtils.formatPKValue(blueScore)
|
||||
updateProgress(redScore.toFloat() / totalScore.toFloat())
|
||||
} else {
|
||||
updateProgress(0.5f)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateProgress(percent: Float) {
|
||||
binding.pbScore.post {
|
||||
binding.pbScore.progress = (percent * 100).toInt()
|
||||
val progress = binding.pbScore.width * (percent)
|
||||
var bias =
|
||||
(progress - binding.svgaHot.width / 2f) / (binding.pbScore.width - binding.svgaHot.width)
|
||||
val layoutParams = binding.svgaHot.layoutParams as ConstraintLayout.LayoutParams
|
||||
bias = 1f.coerceAtMost(bias)
|
||||
bias = 0f.coerceAtLeast(bias)
|
||||
layoutParams.horizontalBias = bias
|
||||
binding.svgaHot.layoutParams = layoutParams
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onPKTimeTickEvent(event: PKTimeTickEvent?) {
|
||||
updateTime()
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onPKTimeFinishEvent(event: PKTimeFinishEvent?) {
|
||||
updateView()
|
||||
}
|
||||
|
||||
private fun onSeatClick(teamType: Int) {
|
||||
//不是管理员或者房主弹出排麦dialog
|
||||
if (!AvRoomDataManager.get().isManager) {
|
||||
//已经排麦不操作
|
||||
if (!PkModel.get().pkMemberInfoList.isNullOrEmpty() && AvRoomDataManager.get().myIsInQueue) {
|
||||
SingleToastUtil.showToastShort(ResUtil.getString(R.string.avroom_widget_pkboardview_03))
|
||||
return
|
||||
}
|
||||
onActionListener?.onShowPKMicQueueDialog()
|
||||
return
|
||||
}
|
||||
//添加红队人员
|
||||
val selectDialog =
|
||||
PKSelectPeopleDialog(context, teamType, PkModel.get().pkMemberInfoList)
|
||||
selectDialog.setOnSelectPeopleListener { micEntityList -> //更新队伍,麦序,显示头像
|
||||
val upMicMemberList: MutableList<RoomPKInvitedUpMicMember> =
|
||||
ArrayList()
|
||||
for (micEntity in micEntityList) {
|
||||
if (TextUtils.isEmpty(micEntity.uid)) {
|
||||
continue
|
||||
}
|
||||
val roomPKInvitedUpMicMember = RoomPKInvitedUpMicMember()
|
||||
if (micEntity.isSelect) {
|
||||
roomPKInvitedUpMicMember.groupType = teamType
|
||||
} else {
|
||||
if (TextUtils.isEmpty(micEntity.uid)) {
|
||||
roomPKInvitedUpMicMember.groupType = PKTeamInfo.TEAM_NONE
|
||||
} else {
|
||||
val teamId = PkModel.get().getTeamIdInPKMemberList(micEntity.uid)
|
||||
roomPKInvitedUpMicMember.groupType =
|
||||
if (teamId == teamType) PKTeamInfo.TEAM_NONE else teamId
|
||||
}
|
||||
}
|
||||
roomPKInvitedUpMicMember.uid = micEntity.uid
|
||||
roomPKInvitedUpMicMember.nick = micEntity.nick
|
||||
val micQueue = AvRoomDataManager.get().mMicQueueMemberMap
|
||||
//设置坑位的位置
|
||||
for (i in 0 until micQueue.size()) {
|
||||
val key = micQueue.keyAt(i)
|
||||
val roomQueueInfo = micQueue[key]
|
||||
if (roomQueueInfo.mChatRoomMember != null && roomQueueInfo.mChatRoomMember.account == micEntity.uid
|
||||
) {
|
||||
roomPKInvitedUpMicMember.position = key
|
||||
}
|
||||
}
|
||||
upMicMemberList.add(roomPKInvitedUpMicMember)
|
||||
}
|
||||
PkModel.get().inviteInTeam(upMicMemberList)
|
||||
.doOnError { throwable: Throwable ->
|
||||
SingleToastUtil.showToastShort(
|
||||
throwable.message
|
||||
)
|
||||
}
|
||||
.subscribe()
|
||||
}
|
||||
selectDialog.show()
|
||||
}
|
||||
|
||||
private fun onStartClick() {
|
||||
onActionListener?.onBeginPK()
|
||||
}
|
||||
|
||||
private fun onRestartClick() {
|
||||
if (PkModel.get().curPkInfo == null) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_dialog_pkscoreboarddialog_01))
|
||||
dismissAllowingStateLoss()
|
||||
return
|
||||
}
|
||||
if (PkModel.get().curPkInfo?.pkStatus == RoomPkData.PK_STATUS_AFTER_PK) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_dialog_pkscoreboarddialog_02))
|
||||
dismissAllowingStateLoss()
|
||||
return
|
||||
}
|
||||
val tipDialog = CommonTipDialog(context)
|
||||
tipDialog.setTipMsg(
|
||||
ResUtil.getString(R.string.avroom_dialog_pkscoreboarddialog_03) +
|
||||
ResUtil.getString(R.string.avroom_dialog_pkscoreboarddialog_04)
|
||||
)
|
||||
tipDialog.setOnActionListener(
|
||||
object : CommonTipDialog.OnActionListener {
|
||||
override fun onOk() {
|
||||
PkModel.get().toPKAgain().subscribe(object : SingleObserver<String?> {
|
||||
override fun onSubscribe(d: Disposable) {
|
||||
compositeDisposable?.add(d)
|
||||
}
|
||||
|
||||
override fun onSuccess(t: String) {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
SingleToastUtil.showToast(e.message)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
)
|
||||
tipDialog.show()
|
||||
}
|
||||
|
||||
interface OnActionListener {
|
||||
fun onBeginPK()
|
||||
fun onShowPKMicQueueDialog()
|
||||
}
|
||||
}
|
@@ -9,7 +9,7 @@ import android.view.WindowManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.chwl.app.avroom.adapter.SendBroadcastAdapter
|
||||
import com.chwl.app.base.BaseActivity
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogSendBroadcastBinding
|
||||
import com.chwl.app.ui.utils.RVDelegate
|
||||
import com.chwl.app.utils.SpannableBuilder
|
||||
@@ -24,7 +24,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class SendBroadcastDialog : BaseDialog<DialogSendBroadcastBinding>() {
|
||||
class SendBroadcastDialog : BaseDialogFragment<DialogSendBroadcastBinding>() {
|
||||
|
||||
private lateinit var rvDelegate: RVDelegate<String>
|
||||
private lateinit var adapter: SendBroadcastAdapter
|
||||
|
@@ -2,11 +2,11 @@ package com.chwl.app.avroom.dialog
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.view.WindowManager
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogSingleRoomTipBinding
|
||||
|
||||
class SingleRoomTipDialog :
|
||||
BaseDialog<DialogSingleRoomTipBinding>() {
|
||||
BaseDialogFragment<DialogSingleRoomTipBinding>() {
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
override fun init() {
|
||||
binding?.root?.setOnClickListener {
|
||||
|
@@ -14,34 +14,41 @@ import android.text.TextUtils
|
||||
import android.view.KeyEvent
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.ViewStub
|
||||
import android.widget.EditText
|
||||
import android.widget.ImageView
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.CallSuper
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.lifecycle.withResumed
|
||||
import com.netease.nim.uikit.common.antispam.AntiSpamEvent
|
||||
import com.netease.nimlib.sdk.StatusCode
|
||||
import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomKickOutEvent
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage
|
||||
import com.orhanobut.logger.Logger
|
||||
import com.tbruyelle.rxpermissions2.RxPermissions
|
||||
import com.trello.rxlifecycle3.android.FragmentEvent
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
import androidx.viewpager2.widget.ViewPager2.OnPageChangeCallback
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.BottomViewListenerWrapper
|
||||
import com.chwl.app.avroom.SoftKeyBoardListener
|
||||
import com.chwl.app.avroom.SoftKeyBoardListener.OnSoftKeyBoardChangeListener
|
||||
import com.chwl.app.avroom.activity.AVRoomActivity
|
||||
import com.chwl.app.avroom.activity.RoomInviteActivity
|
||||
import com.chwl.app.avroom.activity.RoomTitleEditActivity
|
||||
import com.chwl.app.avroom.adapter.OnMicroItemClickListener
|
||||
import com.chwl.app.avroom.adapter.RoomMessageIndicatorAdapter
|
||||
import com.chwl.app.avroom.dialog.AttentionHintDialog
|
||||
import com.chwl.app.avroom.dialog.DatingVipRuleDialog
|
||||
import com.chwl.app.avroom.dialog.RoomGameListDialog
|
||||
import com.chwl.app.avroom.dialog.RoomGameplayDialog
|
||||
import com.chwl.app.avroom.dialog.RoomOperationDialog
|
||||
import com.chwl.app.avroom.presenter.BaseRoomPresenter
|
||||
import com.chwl.app.avroom.public_chat.PublicChatRoomMessageWidget
|
||||
import com.chwl.app.avroom.room_album.RoomAlbumModel
|
||||
import com.chwl.app.avroom.view.IBaseRoomView
|
||||
import com.chwl.app.avroom.widget.BottomView
|
||||
@@ -52,21 +59,29 @@ import com.chwl.app.base.BaseMvpFragment
|
||||
import com.chwl.app.event.OpenRoomIntroEvent
|
||||
import com.chwl.app.friend.view.SelectFriendActivity
|
||||
import com.chwl.app.home.adapter.RoomActAdapter
|
||||
import com.chwl.app.music.widget.MusicPlayerView
|
||||
import com.chwl.app.public_chat.ui.message.HeadlineViewModel
|
||||
import com.chwl.app.room_chat.activity.RoomMsgActivity
|
||||
import com.chwl.app.ui.pay.ChargeActivity
|
||||
import com.chwl.app.ui.webview.CommonWebViewActivity
|
||||
import com.chwl.app.ui.webview.DialogWebViewActivity
|
||||
import com.chwl.app.ui.widget.ButtonItem
|
||||
import com.chwl.app.ui.widget.GiftDialog
|
||||
import com.chwl.app.ui.widget.GiftDialog.OnGiftDialogBtnClickListener
|
||||
import com.chwl.app.ui.widget.GiftDialog.SenGiftCallback
|
||||
import com.chwl.app.ui.widget.UserInfoDialog
|
||||
import com.chwl.app.ui.widget.dialog.CommonTipDialog
|
||||
import com.chwl.app.ui.widget.dynamicface.DynamicFaceDialog
|
||||
import com.chwl.app.ui.widget.magicindicator.MagicIndicator
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.commonnavigator.CommonNavigator
|
||||
import com.chwl.app.ui.widget.rollviewpager.RollPagerView
|
||||
import com.chwl.app.ui.widget.rollviewpager.Util
|
||||
import com.chwl.app.ui.widget.rollviewpager.hintview.ColorPointHintView
|
||||
import com.chwl.app.utils.KeyBoardUtils
|
||||
import com.chwl.app.music.widget.MusicPlayerView
|
||||
import com.chwl.app.room_chat.activity.RoomMsgActivity
|
||||
import com.chwl.core.XConstants
|
||||
import com.chwl.app.vip.dialog.SelectPayTypeDialog
|
||||
import com.chwl.core.Constants
|
||||
import com.chwl.core.UriProvider
|
||||
import com.chwl.core.auth.AuthModel
|
||||
import com.chwl.core.bean.RoomMicInfo
|
||||
import com.chwl.core.gift.GiftModel
|
||||
@@ -84,28 +99,44 @@ import com.chwl.core.manager.RoomEvent
|
||||
import com.chwl.core.mentoring_relationship.event.MentoringStopCountingEvent
|
||||
import com.chwl.core.room.anotherroompk.ShowGiftDialogEvent
|
||||
import com.chwl.core.room.anotherroompk.ShowUserInfoDialogEvent
|
||||
import com.chwl.core.room.bean.RightBottomIconConfig
|
||||
import com.chwl.core.room.bean.RoomIcon
|
||||
import com.chwl.core.room.bean.RoomInfo
|
||||
import com.chwl.core.room.event.RoomAtEvent
|
||||
import com.chwl.core.room.event.RoomClearScreenEvent
|
||||
import com.chwl.core.room.game.GameStatus
|
||||
import com.chwl.core.room.game.bean.BaiShunGameConfig
|
||||
import com.chwl.core.room.giftvalue.helper.GiftValueMrg
|
||||
import com.chwl.core.room.queue.bean.MicMemberInfo
|
||||
import com.chwl.core.share.bean.SessionType
|
||||
import com.chwl.core.super_admin.SaConstant
|
||||
import com.chwl.core.super_admin.model.SuperAdminModel
|
||||
import com.chwl.core.super_admin.util.SuperAdminUtil
|
||||
import com.chwl.core.support.room.AudioRoomContext
|
||||
import com.chwl.core.support.room.RoomContext
|
||||
import com.chwl.core.support.room.RoomView
|
||||
import com.chwl.core.support.room.RoomWidget
|
||||
import com.chwl.core.user.UserModel
|
||||
import com.chwl.core.user.bean.BaseInfo
|
||||
import com.chwl.core.user.bean.UserInfo
|
||||
import com.chwl.core.utils.net.BalanceNotEnoughExeption
|
||||
import com.chwl.core.utils.net.VipLevelNotEnoughException
|
||||
import com.chwl.library.common.util.LimitClickUtils
|
||||
import com.chwl.library.net.rxnet.utils.RxNetWorkUtils
|
||||
import com.chwl.library.rxbus.RxBus
|
||||
import com.chwl.library.utils.*
|
||||
import com.google.gson.Gson
|
||||
import com.netease.nim.uikit.common.antispam.AntiSpamEvent
|
||||
import com.netease.nimlib.sdk.StatusCode
|
||||
import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomKickOutEvent
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage
|
||||
import com.orhanobut.logger.Logger
|
||||
import com.tbruyelle.rxpermissions2.RxPermissions
|
||||
import com.trello.rxlifecycle3.android.FragmentEvent
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
@@ -119,16 +150,19 @@ import org.greenrobot.eventbus.ThreadMode
|
||||
* @author chenran
|
||||
* @date 2017/7/26
|
||||
*/
|
||||
open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
BaseMvpFragment<V?, P?>(),
|
||||
open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
|
||||
BaseMvpFragment<V?, P1?>(),
|
||||
View.OnClickListener, OnGiftDialogBtnClickListener, IBaseRoomView, OnMicroItemClickListener,
|
||||
RoomView {
|
||||
private var myUid: Long = 0
|
||||
protected lateinit var messagePager: ViewPager2
|
||||
protected lateinit var messageView: MessageView
|
||||
protected var publicChatMessageWidget: PublicChatRoomMessageWidget? = null
|
||||
protected lateinit var bottomView: BottomView
|
||||
protected lateinit var inputLayout: RelativeLayout
|
||||
protected lateinit var inputEdit: EditText
|
||||
protected lateinit var inputSend: ImageView
|
||||
protected lateinit var inputHeadlineSend: ImageView
|
||||
protected lateinit var microView: MicroView
|
||||
private var musicPlayerView: MusicPlayerView? = null
|
||||
private var mVsMusicPlayer: ViewStub? = null
|
||||
@@ -170,9 +204,11 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
// 房间小组件
|
||||
private var widgets: HashMap<String, RoomWidget> = HashMap()
|
||||
|
||||
private val headlineViewModel by activityViewModels<HeadlineViewModel>()
|
||||
|
||||
@CallSuper
|
||||
override fun onFindViews() {
|
||||
messageView = mView.findViewById(R.id.message_view)
|
||||
initMessageView()
|
||||
bottomView = mView.findViewById(R.id.bottom_view)
|
||||
inputLayout = mView.findViewById(R.id.input_layout)
|
||||
inputEdit = mView.findViewById(R.id.input_edit)
|
||||
@@ -185,6 +221,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
false
|
||||
}
|
||||
inputSend = mView.findViewById(R.id.input_send)
|
||||
inputHeadlineSend = mView.findViewById(R.id.input_headline_send)
|
||||
microView = mView.findViewById(R.id.micro_view)
|
||||
mVsMusicPlayer = mView.findViewById(R.id.vs_music_player)
|
||||
messageView.setClickConsumer {
|
||||
@@ -204,10 +241,80 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
})
|
||||
}
|
||||
|
||||
protected open fun initMessageView() {
|
||||
messagePager = mView.findViewById<ViewPager2>(R.id.message_pager)
|
||||
messageView = MessageView(context)
|
||||
publicChatMessageWidget = PublicChatRoomMessageWidget(requireContext())
|
||||
val tabList: MutableList<String> = java.util.ArrayList(2)
|
||||
tabList.add(getString(R.string.room))
|
||||
tabList.add(getString(R.string.public_chat))
|
||||
val messageIndicator = mView.findViewById<MagicIndicator>(R.id.message_indicator)
|
||||
messagePager.offscreenPageLimit = tabList.size
|
||||
messagePager.adapter = object : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
override fun onCreateViewHolder(
|
||||
parent: ViewGroup,
|
||||
viewType: Int
|
||||
): RecyclerView.ViewHolder {
|
||||
val view = if (viewType == 0) {
|
||||
messageView
|
||||
} else {
|
||||
publicChatMessageWidget
|
||||
}
|
||||
view?.layoutParams = ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
return BaseViewHolder(view)
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return tabList.size
|
||||
}
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
return position
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||
|
||||
}
|
||||
}
|
||||
val commonNavigator = CommonNavigator(context)
|
||||
commonNavigator.setTitleWrapContent(false)
|
||||
val magicIndicatorAdapter = RoomMessageIndicatorAdapter(context, tabList)
|
||||
magicIndicatorAdapter.setOnItemSelectListener { position: Int, view: TextView? ->
|
||||
messagePager.currentItem = position
|
||||
}
|
||||
commonNavigator.adapter = magicIndicatorAdapter
|
||||
messageIndicator.navigator = commonNavigator
|
||||
messagePager.registerOnPageChangeCallback(object : OnPageChangeCallback() {
|
||||
override fun onPageScrolled(
|
||||
position: Int,
|
||||
positionOffset: Float,
|
||||
positionOffsetPixels: Int
|
||||
) {
|
||||
messageIndicator.onPageScrolled(
|
||||
position,
|
||||
positionOffset,
|
||||
positionOffsetPixels
|
||||
)
|
||||
}
|
||||
|
||||
override fun onPageSelected(position: Int) {
|
||||
messageIndicator.onPageSelected(position)
|
||||
}
|
||||
|
||||
override fun onPageScrollStateChanged(state: Int) {
|
||||
messageIndicator.onPageScrollStateChanged(state)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
override fun onSetListener() {
|
||||
bottomView.setMagicBtnEnable(true)
|
||||
inputSend.setOnClickListener(this)
|
||||
inputHeadlineSend.setOnClickListener(this)
|
||||
inputLayout.setOnTouchListener { _: View?, _: MotionEvent? ->
|
||||
inputEdit.clearFocus()
|
||||
inputLayout.visibility = View.GONE
|
||||
@@ -271,6 +378,44 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
//获取免费礼物详情
|
||||
mvpPresenter?.queryFreeFlower()
|
||||
initRoomAlbum()
|
||||
initHeadline()
|
||||
}
|
||||
|
||||
private fun initHeadline() {
|
||||
headlineViewModel.loadingLiveData.observe(this) {
|
||||
if (it) dialogManager?.showProgressDialog(context)
|
||||
else dialogManager?.dismissDialog()
|
||||
}
|
||||
lifecycleScope.launch(Dispatchers.Main) {
|
||||
headlineViewModel.sendHeadlineFlow.collect {
|
||||
if (it.isSuccess) {
|
||||
SingleToastUtil.showToast(R.string.sent_success)
|
||||
inputEdit.setText("")
|
||||
KeyBoardUtils.hideKeyBoard(activity, inputEdit)
|
||||
} else {
|
||||
if (it.code == BalanceNotEnoughExeption.code) {
|
||||
showBalanceNotEnoughDialog()
|
||||
} else {
|
||||
SingleToastUtil.showToast(it.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
headlineViewModel.getHeadlinePayMoneyIsNull()
|
||||
}
|
||||
|
||||
private fun showBalanceNotEnoughDialog() {
|
||||
val tipDialog = CommonTipDialog(context)
|
||||
tipDialog.setTipMsg(ResUtil.getString(R.string.insufficient_balance_recharge_tips))
|
||||
tipDialog.setOkText(getString(R.string.charge))
|
||||
tipDialog.setOnActionListener(
|
||||
object : CommonTipDialog.OnActionListener {
|
||||
override fun onOk() {
|
||||
ChargeActivity.start(context)
|
||||
}
|
||||
}
|
||||
)
|
||||
tipDialog.show()
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
@@ -509,6 +654,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
open fun updateView() {
|
||||
// 更新底欄
|
||||
showBottomViewForDifRole()
|
||||
bottomView.notifyStateChanged()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -523,6 +669,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
bottomView.showHomePartyDownMicBottom()
|
||||
}
|
||||
bottomView.showInputOrIcon(isOnMic)
|
||||
bottomView.updateGameEntrance()
|
||||
// 更新聽筒消息
|
||||
bottomView.setRemoteMuteOpen(!AudioEngineManager.get().isRemoteMute)
|
||||
if (isOnMic) {
|
||||
@@ -560,10 +707,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
} else {
|
||||
val roomQueueInfo = AvRoomDataManager.get()
|
||||
.getRoomQueueMemberInfoByAccount(myUid.toString())
|
||||
if (roomQueueInfo?.mChatRoomMember?.isNoProhibitMic == true && roomQueueInfo.mRoomMicInfo?.isMicMute == false) {
|
||||
bottomView.setMicBtnEnable(true)
|
||||
bottomView.setMicBtnOpen(true)
|
||||
} else if (roomQueueInfo?.mChatRoomMember != null
|
||||
if (roomQueueInfo?.mChatRoomMember != null
|
||||
&& myUid.toString() == roomQueueInfo.mChatRoomMember.account
|
||||
&& roomQueueInfo.mRoomMicInfo?.isMicMute == true
|
||||
) {
|
||||
@@ -645,18 +789,119 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
messageView.clear()
|
||||
}
|
||||
|
||||
private fun isPublicMessageTab(): Boolean {
|
||||
return messagePager.currentItem == 1
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
override fun onClick(v: View) {
|
||||
if (mClickLimit.checkForTime(500)) return
|
||||
when (v.id) {
|
||||
R.id.iv_config_entrance -> {
|
||||
val roomInfo = AvRoomDataManager.get().mCurrentRoomInfo ?: return
|
||||
val configInfo = AvRoomDataManager.get().rightBottomIconConfig ?: return
|
||||
if (configInfo.skipType == 1) {
|
||||
playConfigWeb(configInfo.skipUrl)
|
||||
} else if (configInfo.skipType == 2) {
|
||||
playConfigBaishunGame(configInfo)
|
||||
}
|
||||
}
|
||||
R.id.iv_game -> {
|
||||
val dialog = RoomGameplayDialog()
|
||||
dialog.isOnlyPK = false
|
||||
dialog.listener = object : RoomGameplayDialog.GameplayDialogListener {
|
||||
override fun onShowBaiShunGame(url: String, config: BaiShunGameConfig) {
|
||||
(activity as? AVRoomActivity)?.showBaiShunGame(url, config)
|
||||
}
|
||||
}
|
||||
dialog.show(childFragmentManager, "ROOM_GAME_PLAY")
|
||||
}
|
||||
R.id.input_send -> {
|
||||
sendMsg()
|
||||
}
|
||||
R.id.input_headline_send -> {
|
||||
sendHeadline()
|
||||
}
|
||||
R.id.layout_room_rank -> {
|
||||
DialogWebViewActivity.start(mContext, UriProvider.getRoomRanking())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun playConfigWeb(url: String) {
|
||||
CommonWebViewActivity.start(mContext, url)
|
||||
}
|
||||
|
||||
private fun playConfigBaishunGame(configInfo: RightBottomIconConfig) {
|
||||
val roomIcon: RoomIcon = RoomIcon(
|
||||
skipContent = configInfo.skipUrl,
|
||||
skipType = 3,
|
||||
showType = 1,
|
||||
code = "BAISHUN",
|
||||
ruleValue = configInfo.reserve)
|
||||
try {
|
||||
val url = roomIcon.skipContent
|
||||
val ruleValue = Gson().fromJson<RoomIcon.RuleValueBean>(
|
||||
roomIcon.ruleValue,
|
||||
RoomIcon.RuleValueBean::class.java
|
||||
)
|
||||
val config = Gson().fromJson<BaiShunGameConfig>(
|
||||
ruleValue.RESERVE,
|
||||
BaiShunGameConfig::class.java
|
||||
)
|
||||
if (config != null && url != null) {
|
||||
config.reloadDynamicParams()
|
||||
(activity as? AVRoomActivity)?.showBaiShunGame(url, config)
|
||||
} else {
|
||||
SingleToastUtil.showToast(R.string.manager_trtc_trtcengineadapter_042)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
private fun sendMsg() {
|
||||
sendMsg(inputEdit.text.toString())
|
||||
val message = inputEdit.text.toString().trim()
|
||||
if (isPublicMessageTab()) {
|
||||
sendPublicChatMessage(message)
|
||||
} else {
|
||||
sendMsg(message)
|
||||
}
|
||||
}
|
||||
|
||||
private fun sendHeadline() {
|
||||
val message = inputEdit.text.toString().trim()
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_fragment_baseroomfragment_08))
|
||||
return
|
||||
}
|
||||
if (message.length > 100) {
|
||||
toast(R.string.headline_input_length_limit_tips)
|
||||
return
|
||||
}
|
||||
val money = headlineViewModel.headlinePayMoneyLiveData.value
|
||||
if (money != null) {
|
||||
showHeadlinePayDialog(money, message)
|
||||
} else {
|
||||
SingleToastUtil.showToast(R.string.ui_setting_modifypwdactivity_01)
|
||||
headlineViewModel.getHeadlinePayMoney()
|
||||
}
|
||||
}
|
||||
|
||||
private fun showHeadlinePayDialog(money: Long, message: String) {
|
||||
KeyBoardUtils.hideKeyBoard(activity, inputEdit)
|
||||
SelectPayTypeDialog.newInstance(
|
||||
money.toString(),
|
||||
money,
|
||||
false
|
||||
).apply {
|
||||
setOnDiamondChargeClick {
|
||||
headlineViewModel.sendHeadline(message)
|
||||
}
|
||||
setOnChargeClick {
|
||||
ChargeActivity.start(context)
|
||||
}
|
||||
}.show(context)
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
@@ -679,6 +924,20 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
inputEdit.setText("")
|
||||
}
|
||||
|
||||
private fun sendPublicChatMessage(message: String){
|
||||
if (!AuthModel.get().isImLogin) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_fragment_baseroomfragment_07))
|
||||
return
|
||||
}
|
||||
if (TextUtils.isEmpty(message)) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_fragment_baseroomfragment_08))
|
||||
return
|
||||
}
|
||||
mvpPresenter?.sendPublicChatTextMessage(message)
|
||||
publicChatMessageWidget?.getMessageView()?.setNeedAutoScroll(true) // 發送後自動滾動公屏列表
|
||||
inputEdit.setText("")
|
||||
}
|
||||
|
||||
/**
|
||||
* 軟鍵盤顯示與隱藏的監聽
|
||||
*/
|
||||
@@ -714,7 +973,12 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
.compose(bindUntilEvent(FragmentEvent.DESTROY))
|
||||
.doOnError {
|
||||
if (it is VipLevelNotEnoughException) {
|
||||
dialogManager.showOkDialog("尚未達到贈送${giftInfo.giftName}所需貴族等級,所需貴族等級:${giftInfo.giftVipInfo?.vipName}")
|
||||
val message = context?.getString(
|
||||
R.string.send_gift_vip_level_tips,
|
||||
giftInfo.giftName ?: "",
|
||||
giftInfo.giftVipInfo?.vipName ?: ""
|
||||
)
|
||||
dialogManager.showOkDialog(message)
|
||||
}
|
||||
}
|
||||
.subscribe { _, throwable ->
|
||||
@@ -813,7 +1077,13 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
}
|
||||
})
|
||||
val buttonItem4 =
|
||||
ButtonItem(ResUtil.getString(R.string.up_mic)) { toUpMicroPhone(micPosition, currentUid.toString() + "", false) }
|
||||
ButtonItem(ResUtil.getString(R.string.up_mic)) {
|
||||
toUpMicroPhone(
|
||||
micPosition,
|
||||
currentUid.toString() + "",
|
||||
false
|
||||
)
|
||||
}
|
||||
//別問為什麽,ui調整了順序
|
||||
//禁用超管的上麥和抱TA上麥
|
||||
if (!SuperAdminUtil.isSuperAdmin()) {
|
||||
@@ -979,6 +1249,12 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
KeyBoardUtils.hideKeyBoard(activity, inputEdit)
|
||||
}
|
||||
|
||||
override fun onSendPublicChatMsgSuccess(msg: ChatRoomMessage) {
|
||||
publicChatMessageWidget?.getMessageView()?.addMessages(msg)
|
||||
inputEdit.setText("")
|
||||
KeyBoardUtils.hideKeyBoard(activity, inputEdit)
|
||||
}
|
||||
|
||||
/**
|
||||
* 顯示資料卡片
|
||||
*/
|
||||
@@ -999,7 +1275,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
return
|
||||
}
|
||||
if (AvRoomDataManager.get().isSelfGamePlaying) {
|
||||
SingleToastUtil.showToast("遊戲中不可以換麥!")
|
||||
SingleToastUtil.showToast(R.string.avroom_presenter_baseroompresenter_01)
|
||||
return
|
||||
}
|
||||
UserModel.get().cacheLoginUserInfo?.gameStatus = GameStatus.STATUS_NOT_JOIN
|
||||
@@ -1008,9 +1284,13 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
if (result) {
|
||||
mvpPresenter?.upMicroPhone(micPosition, currentUid, b)
|
||||
} else {
|
||||
toast("請給予麥克風權限後再試!")
|
||||
toast(R.string.permission_mic_tips)
|
||||
}
|
||||
}, { _: Throwable? -> toast("發生一些異常,請稍後重試!") })
|
||||
}, { error: Throwable? ->
|
||||
error?.let {
|
||||
toast(it.message)
|
||||
} ?: toast(R.string.exception_try_again)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1074,7 +1354,9 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
}
|
||||
|
||||
override fun onFollowFail(msg: String?) {
|
||||
toast("關註失敗,請稍後重試")
|
||||
msg?.let {
|
||||
toast(msg)
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateMicView() {
|
||||
@@ -1099,8 +1381,8 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
private fun addOpenDatingTips() {
|
||||
if (AvRoomDataManager.get().isDatingMode && !isDatingMode && AvRoomDataManager.get().isManager) {
|
||||
val tipMessage =
|
||||
ChatRoomMessageBuilder.createTipMessage(XConstants.DATING_TIPS_OPEN)
|
||||
tipMessage.content = XConstants.DATING_TIPS_OPEN
|
||||
ChatRoomMessageBuilder.createTipMessage(ResUtil.getString(R.string.yizhuan_xchat_android_constants_xchatconstants_09))
|
||||
tipMessage.content = ResUtil.getString(R.string.yizhuan_xchat_android_constants_xchatconstants_09)
|
||||
IMNetEaseManager.get().addMessages(tipMessage)
|
||||
}
|
||||
}
|
||||
@@ -1204,6 +1486,21 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
override fun onRoomMessageClick() {
|
||||
RoomMsgActivity.start(mContext)
|
||||
}
|
||||
|
||||
override fun onRoomGameplayClick(isOnlyPK: Boolean) {
|
||||
if (isOnlyPK) {
|
||||
val dialog = RoomGameplayDialog()
|
||||
dialog.isOnlyPK = isOnlyPK
|
||||
dialog.listener = object : RoomGameplayDialog.GameplayDialogListener {
|
||||
override fun onShowBaiShunGame(url: String, config: BaiShunGameConfig) {
|
||||
(activity as? AVRoomActivity)?.showBaiShunGame(url, config)
|
||||
}
|
||||
}
|
||||
dialog.show(childFragmentManager, "ROOM_GAME_PLAY")
|
||||
} else {
|
||||
RoomGameListDialog().show(childFragmentManager, "GAME_LIST")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1228,8 +1525,26 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
return this
|
||||
}
|
||||
|
||||
open fun initWidget() {
|
||||
override fun getViewFragmentManager(): FragmentManager {
|
||||
return activity?.supportFragmentManager ?: childFragmentManager
|
||||
}
|
||||
|
||||
override fun findWidget(name: String): RoomWidget? {
|
||||
return widgets[name]
|
||||
}
|
||||
|
||||
override fun getRoomContext(): RoomContext? {
|
||||
return AudioRoomContext.get()
|
||||
}
|
||||
|
||||
override fun getRoomContextLiveData(): LiveData<out RoomContext?> {
|
||||
return AudioRoomContext.contextLiveData
|
||||
}
|
||||
|
||||
open fun initWidget() {
|
||||
publicChatMessageWidget?.let {
|
||||
registerWidget(PublicChatRoomMessageWidget::class.java.simpleName, it)
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
@@ -1247,6 +1562,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
* 打开公屏输入
|
||||
*/
|
||||
fun openMessageInput(text: String?) {
|
||||
inputHeadlineSend.isVisible = isPublicMessageTab()
|
||||
inputLayout.visibility = View.VISIBLE
|
||||
if (text != null) {
|
||||
inputEdit.setText(text)
|
||||
|
@@ -0,0 +1,281 @@
|
||||
package com.chwl.app.avroom.fragment
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.View.OnTouchListener
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.adapter.GameMicroViewAdapter
|
||||
import com.chwl.app.avroom.adapter.GameMiniMicroViewAdapter
|
||||
import com.chwl.app.avroom.adapter.OnMicroItemClickListener
|
||||
import com.chwl.app.avroom.game.GameDelegate
|
||||
import com.chwl.app.avroom.game.OnGameStatusChangeListener
|
||||
import com.chwl.app.avroom.headline.RoomHeadlineWidget
|
||||
import com.chwl.app.avroom.online.RoomOnlineWidget
|
||||
import com.chwl.app.avroom.presenter.GameRoomPresenter
|
||||
import com.chwl.app.avroom.rank.RoomRankNumberWidget
|
||||
import com.chwl.app.avroom.view.IGameRoomView
|
||||
import com.chwl.app.databinding.FragmentGameRoomBinding
|
||||
import com.chwl.app.home.helper.OpenRoomHelper
|
||||
import com.chwl.app.ui.webview.DialogWebViewActivity
|
||||
import com.chwl.app.ui.widget.GiftDialog.OnGiftDialogBtnClickListener
|
||||
import com.chwl.core.UriProvider
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
import com.chwl.core.music.model.PlayerModel
|
||||
import com.chwl.core.room.bean.RoomInfo
|
||||
import com.chwl.core.room.event.FinishAvRoomEvent
|
||||
import com.chwl.core.sud.model.GameViewInfoModel
|
||||
import com.chwl.library.base.factory.CreatePresenter
|
||||
import com.chwl.library.utils.SingleToastUtil
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
/**
|
||||
* 轰趴房间
|
||||
*
|
||||
* @author chenran
|
||||
* @date 2017/7/26
|
||||
*/
|
||||
@CreatePresenter(GameRoomPresenter::class)
|
||||
class GameRoomFragment : BaseRoomFragment<IGameRoomView?, GameRoomPresenter?>(),
|
||||
View.OnClickListener, OnGiftDialogBtnClickListener, IGameRoomView, OnMicroItemClickListener,
|
||||
OnGameStatusChangeListener {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun newInstance(): GameRoomFragment {
|
||||
val roomFragment = GameRoomFragment()
|
||||
val bundle = Bundle()
|
||||
roomFragment.arguments = bundle
|
||||
return roomFragment
|
||||
}
|
||||
}
|
||||
|
||||
private lateinit var gameBinding: FragmentGameRoomBinding
|
||||
private lateinit var gameDelegate: GameDelegate
|
||||
private var isShowMiniMic = false
|
||||
|
||||
override fun getRootLayoutId(): Int {
|
||||
return R.layout.fragment_game_room
|
||||
}
|
||||
|
||||
override fun onFindViews() {
|
||||
super.onFindViews()
|
||||
gameBinding = DataBindingUtil.bind(mView)!!
|
||||
gameBinding.lifecycleOwner = this
|
||||
gameBinding.click = this
|
||||
gameBinding.ktvModel = false
|
||||
gameDelegate = GameDelegate(
|
||||
requireActivity(),
|
||||
gameBinding.flGameContainer,
|
||||
AvRoomDataManager.get().mCurrentRoomInfo?.mgId
|
||||
)
|
||||
gameDelegate.setOnGameStatusChangeListener(this)
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun initiate() {
|
||||
gameBinding.microView.bindAdapter(GameMicroViewAdapter(context))
|
||||
resetGameViewRect()
|
||||
super.initiate()
|
||||
//游戏模式暂时不需要这个
|
||||
PlayerModel.get().stop()
|
||||
gameBinding.roomInfo = AvRoomDataManager.get().mCurrentRoomInfo
|
||||
gameBinding.tvShowMiniMic.setOnClickListener { showMiniMic() }
|
||||
gameBinding.ivShowMic.setOnClickListener { showMic() }
|
||||
gameBinding.headlineWidget.setOnClickListener {
|
||||
switchMessageLayoutHeight()
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
override fun initMessageView() {
|
||||
super.initMessageView()
|
||||
messageView.messageListView?.let {
|
||||
setMessagePagerAutoHeight(it)
|
||||
}
|
||||
publicChatMessageWidget?.getMessageView()?.messageListView?.let {
|
||||
setMessagePagerAutoHeight(it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClick(v: View) {
|
||||
super.onClick(v)
|
||||
when (v.id) {
|
||||
R.id.iv_back_room -> {
|
||||
if (AvRoomDataManager.get().isGamePlaying) {
|
||||
SingleToastUtil.showToast(getString(R.string.avroom_fragment_homepartyfragment_03))
|
||||
return
|
||||
}
|
||||
dialogManager.showOkCancelDialog(
|
||||
getString(R.string.room_switch_standard_room_tips)
|
||||
) {
|
||||
var type = AvRoomDataManager.get().mCurrentRoomInfo?.oldType
|
||||
if (type == null || type <= 0) {
|
||||
type = RoomInfo.ROOMTYPE_HOME_PARTY
|
||||
}
|
||||
OpenRoomHelper.updateRoomInfo(
|
||||
baseActivity,
|
||||
AvRoomDataManager.get().mCurrentRoomInfo,
|
||||
type,
|
||||
0,
|
||||
false
|
||||
)
|
||||
}
|
||||
}
|
||||
R.id.layout_hour_rank -> {
|
||||
DialogWebViewActivity.start(
|
||||
mContext,
|
||||
UriProvider.getRoomHourRankUrl(AvRoomDataManager.get().roomUid)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
private fun setMessagePagerAutoHeight(recyclerView: RecyclerView) {
|
||||
recyclerView.setOnTouchListener(OnTouchListener { v: View?, event: MotionEvent ->
|
||||
if (recyclerView.scrollState == RecyclerView.SCROLL_STATE_IDLE
|
||||
&& event.action == MotionEvent.ACTION_UP
|
||||
) {
|
||||
switchMessageLayoutHeight()
|
||||
}
|
||||
false
|
||||
})
|
||||
}
|
||||
|
||||
private fun switchMessageLayoutHeight() {
|
||||
val view = gameBinding.layoutMessage
|
||||
val layoutParams: ViewGroup.LayoutParams = view.layoutParams
|
||||
val bigHeight = ScreenUtil.dip2px(200f)
|
||||
val littleHeight = ScreenUtil.dip2px(80f)
|
||||
layoutParams.height =
|
||||
if (layoutParams.height == littleHeight) bigHeight else littleHeight
|
||||
view.layoutParams = layoutParams
|
||||
}
|
||||
|
||||
private fun showMiniMic() {
|
||||
if (isShowMiniMic) return
|
||||
isShowMiniMic = true
|
||||
gameBinding.microView.bindAdapter(GameMiniMicroViewAdapter(context).apply {
|
||||
setOnClick { showMic() }
|
||||
})
|
||||
gameBinding.tvShowMiniMic.isVisible = false
|
||||
gameBinding.microView.postDelayed({
|
||||
gameBinding.ivShowMic.isVisible = true
|
||||
gameBinding.llMicView.setBackgroundResource(R.drawable.bg_mini_mic_entrance)
|
||||
}, 100)
|
||||
}
|
||||
|
||||
private fun showMic() {
|
||||
if (!isShowMiniMic) return
|
||||
isShowMiniMic = false
|
||||
gameBinding.microView.bindAdapter(GameMicroViewAdapter(context))
|
||||
gameBinding.tvShowMiniMic.isVisible = true
|
||||
gameBinding.llMicView.background = null
|
||||
gameBinding.ivShowMic.isVisible = false
|
||||
}
|
||||
|
||||
override fun onSetListener() {
|
||||
super.onSetListener()
|
||||
bottomView.setBottomViewListener(BaseRoomBottomViewWrapper())
|
||||
}
|
||||
|
||||
override fun updateView() {
|
||||
super.updateView()
|
||||
gameDelegate.updateGame(AvRoomDataManager.get().mCurrentRoomInfo?.mgId)
|
||||
gameBinding.roomInfo = AvRoomDataManager.get().mCurrentRoomInfo
|
||||
// if (isSixMic()) {
|
||||
// gameBinding.tvShowMiniMic.isVisible = !isShowMiniMic
|
||||
// gameBinding.ivShowMic.isVisible = isShowMiniMic
|
||||
// } else {
|
||||
// showMic()
|
||||
// gameBinding.tvShowMiniMic.isInvisible = true
|
||||
// gameBinding.ivShowMic.isVisible = false
|
||||
// }
|
||||
gameBinding.microView.adapter.notifyDataSetChanged()
|
||||
if (AvRoomDataManager.get().mCurrentRoomInfo?.isPermitRoom == 1) {
|
||||
gameBinding.layoutHourRank.visibility = View.VISIBLE
|
||||
} else {
|
||||
gameBinding.layoutHourRank.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
private fun resetGameViewRect(){
|
||||
gameBinding.vGameRect.post {
|
||||
gameDelegate.gameViewRect = GameViewInfoModel.GameViewRectModel().apply {
|
||||
top = gameBinding.vGameRect.top
|
||||
bottom = gameBinding.layoutRoot.height - gameBinding.vGameRect.bottom
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onGameStart() {
|
||||
if (isSixMic()) {
|
||||
// showMiniMic()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onGameEnd() {
|
||||
if (isSixMic()) {
|
||||
showMic()
|
||||
}
|
||||
}
|
||||
|
||||
private fun isSixMic(): Boolean {
|
||||
return AvRoomDataManager.get().mgMicNum == AvRoomDataManager.GAME_DEF_MIC_COUNT
|
||||
}
|
||||
|
||||
override fun onSendMsgSuccess(msg: String?) {
|
||||
super.onSendMsgSuccess(msg)
|
||||
msg?.let {
|
||||
if (AvRoomDataManager.get().isSelfGamePlaying) {
|
||||
gameDelegate.hitTheMark(msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onFinishAvRoomEvent(event: FinishAvRoomEvent) {
|
||||
gameDelegate.exitGame()
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
gameDelegate.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
gameDelegate.onResume()
|
||||
}
|
||||
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
gameDelegate.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
gameDelegate.onStop()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
gameDelegate.onDestroy()
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
override fun initWidget() {
|
||||
super.initWidget()
|
||||
registerWidget(RoomOnlineWidget::class.java.simpleName, gameBinding.onlineWidget)
|
||||
registerWidget(RoomHeadlineWidget::class.java.simpleName, gameBinding.headlineWidget)
|
||||
registerWidget(RoomRankNumberWidget::class.java.simpleName, gameBinding.rankNumberWidget)
|
||||
}
|
||||
}
|
@@ -15,8 +15,15 @@ import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.chwl.app.avroom.activity.RoomTitleEditActivity;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtilsV2;
|
||||
import com.chwl.app.ui.widget.GiftDialog;
|
||||
import com.chwl.app.ui.widget.UserInfoDialog;
|
||||
import com.chwl.library.utils.JavaUtil;
|
||||
import com.example.lib_utils.UiUtils;
|
||||
import com.netease.nim.uikit.common.util.string.StringUtil;
|
||||
import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
|
||||
@@ -25,7 +32,6 @@ import com.opensource.svgaplayer.SVGAImageView;
|
||||
import com.trello.rxlifecycle3.android.FragmentEvent;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.avroom.activity.AVRoomActivity;
|
||||
import com.chwl.app.avroom.activity.RoomOnlineUserActivity;
|
||||
import com.chwl.app.avroom.dialog.ExitRoomPopupWindow;
|
||||
import com.chwl.app.avroom.widget.GiftV2View;
|
||||
import com.chwl.app.avroom.widget.RoomEffectView;
|
||||
@@ -107,12 +113,12 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
super.onNewIntent(intent);
|
||||
// clear views
|
||||
roomTitle.setText("");
|
||||
gameMainBinding.ivRoomCover.setImageResource(R.drawable.default_cover);
|
||||
setRoomId(0, 0);
|
||||
updateOnlineNumberView(0);
|
||||
if (roomFragment instanceof HomePartyRoomFragment) {
|
||||
((HomePartyRoomFragment) roomFragment).onNewIntent(intent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -188,10 +194,10 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
|
||||
@Override
|
||||
public void onSetListener() {
|
||||
gameMainBinding.ivRoomNotice.setOnClickListener(this);
|
||||
roomMore.setOnClickListener(this);
|
||||
ivFollowRoom.setOnClickListener(this);
|
||||
// ivRoomShare.setOnClickListener(this);
|
||||
gameMainBinding.llRoomInfo.setOnClickListener(this);
|
||||
gameMainBinding.ivBack.setOnClickListener(this);
|
||||
|
||||
mRoomEffectView.setOnPlayAnimCallback(new Function0<Boolean>() {
|
||||
@@ -214,7 +220,6 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
|
||||
public void setRoomBg(RoomInfo roomInfo) {
|
||||
if (svgaRoomBg == null) return;
|
||||
updateView(roomInfo);
|
||||
AVRoomActivity.setBackBg(mContext, roomInfo, svgaRoomBg, bgPicture);
|
||||
}
|
||||
|
||||
@@ -237,7 +242,6 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
addTipMsg();
|
||||
case RoomEvent.ROOM_INFO_UPDATE:
|
||||
updateView(AvRoomDataManager.get().mCurrentRoomInfo);
|
||||
setRoomBg(AvRoomDataManager.get().mCurrentRoomInfo);
|
||||
break;
|
||||
case RoomEvent.RECEIVE_NORMALE_GIFT:
|
||||
onReceiveGiftMsg(roomEvent.getGiftReceiveInfo());
|
||||
@@ -347,18 +351,28 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
|
||||
Fragment tempFragment = roomFragment;
|
||||
switch (currentRoomInfo.getType()) {
|
||||
// case RoomInfo.ROOMTYPE_GAME:
|
||||
// if (!(tempFragment instanceof GameRoomFragment)) {
|
||||
// tempFragment = GameRoomFragment.newInstance();
|
||||
// }
|
||||
// break;
|
||||
// case RoomInfo.ROOM_TYPE_SINGLE:
|
||||
// if (!(tempFragment instanceof SingleRoomFragment)) {
|
||||
// tempFragment = SingleRoomFragment.newInstance();
|
||||
// }
|
||||
// break;
|
||||
case RoomInfo.ROOMTYPE_GAME:
|
||||
if (!(tempFragment instanceof GameRoomFragment)) {
|
||||
tempFragment = GameRoomFragment.newInstance();
|
||||
}
|
||||
break;
|
||||
case RoomInfo.ROOM_TYPE_SINGLE:
|
||||
if (!(tempFragment instanceof SingleRoomFragment)) {
|
||||
tempFragment = SingleRoomFragment.newInstance();
|
||||
}
|
||||
break;
|
||||
case RoomInfo.ROOMTYPE_PARTY:
|
||||
if (!(tempFragment instanceof PartyRoomFragment)) {
|
||||
tempFragment = PartyRoomFragment.Companion.newInstance();
|
||||
}
|
||||
break;
|
||||
case RoomInfo.ROOMTYPE_REVELRY:
|
||||
if (!(tempFragment instanceof RevelryRoomFragment)) {
|
||||
tempFragment = RevelryRoomFragment.Companion.newInstance();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (!(tempFragment instanceof HomePartyRoomFragment)) {
|
||||
if (tempFragment == null || !(tempFragment.getClass().getSimpleName().equals(HomePartyRoomFragment.class.getSimpleName()))) {
|
||||
tempFragment = HomePartyRoomFragment.newInstance();
|
||||
}
|
||||
break;
|
||||
@@ -370,10 +384,11 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
.replace(R.id.container, roomFragment)
|
||||
.commitAllowingStateLoss();
|
||||
}
|
||||
|
||||
setRoomBg(currentRoomInfo);
|
||||
gameMainBinding.setRoomInfo(currentRoomInfo);
|
||||
updateHasAnimationEffect();
|
||||
roomTitle.setText(RegexUtil.getPrintableString(currentRoomInfo.getTitle()));
|
||||
ImageLoadUtilsV2.loadImage(gameMainBinding.ivRoomCover, currentRoomInfo.getAvatar());
|
||||
if (!StringUtil.isEmpty(currentRoomInfo.getRoomPwd())) {
|
||||
roomTitle.setCompoundDrawablesWithIntrinsicBounds(null, null,
|
||||
getResources().getDrawable(R.drawable.icon_room_lock), null);
|
||||
@@ -387,6 +402,12 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
ivFollowRoom.setImageResource(AvRoomDataManager.get().isRoomFans ? R.drawable.room_ic_collect_yes : R.drawable.room_ic_collect_no);
|
||||
|
||||
setIdOnlineData();
|
||||
|
||||
if (AvRoomDataManager.get().getRoomType() != RoomInfo.ROOMTYPE_GAME) {
|
||||
gameMainBinding.ivRoomNotice.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
gameMainBinding.ivRoomNotice.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -408,12 +429,16 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.room_more:
|
||||
ExitRoomPopupWindow.newInstance((AVRoomActivity) requireActivity())
|
||||
.showAtLocation(gameMainBinding.getRoot(), Gravity.END, 0, 0);
|
||||
case R.id.iv_room_notice:
|
||||
showRoomIntroduction(AvRoomDataManager.get().isRoomOwner() || AvRoomDataManager.get().isRoomAdmin());
|
||||
break;
|
||||
case R.id.ll_room_info:
|
||||
RoomOnlineUserActivity.start(getActivity());
|
||||
case R.id.room_more:
|
||||
int gravity = Gravity.END;
|
||||
if(UiUtils.INSTANCE.isRtl(requireContext())){
|
||||
gravity = Gravity.START;
|
||||
}
|
||||
ExitRoomPopupWindow.newInstance((AVRoomActivity) requireActivity())
|
||||
.showAtLocation(gameMainBinding.getRoot(), gravity, 0, 0);
|
||||
break;
|
||||
case R.id.iv_follow_room:
|
||||
followRoom();
|
||||
@@ -549,7 +574,41 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
onlineNumber = 1;
|
||||
}
|
||||
}
|
||||
gameMainBinding.roomNums.setText(ResUtil.getString(R.string.avroom_fragment_homepartyfragment_013) + onlineNumber);
|
||||
// gameMainBinding.roomNums.setText(ResUtil.getString(R.string.avroom_fragment_homepartyfragment_013) + onlineNumber);
|
||||
}
|
||||
|
||||
public void showUserCardDialog(String uid){
|
||||
long id = JavaUtil.str2long(uid);
|
||||
if (id == 0) {
|
||||
return;
|
||||
}
|
||||
if (roomFragment instanceof GiftDialog.OnGiftDialogBtnClickListener) {
|
||||
UserInfoDialog.showNewUserInfoDialog(
|
||||
mContext,
|
||||
id,
|
||||
true,
|
||||
true,
|
||||
true, (GiftDialog.OnGiftDialogBtnClickListener) roomFragment
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void showRoomIntroduction(Boolean modify) {
|
||||
var isModify = modify;
|
||||
RoomInfo info = AvRoomDataManager.get().mCurrentRoomInfo;
|
||||
if (info == null) {
|
||||
return;
|
||||
}
|
||||
if (SuperAdminUtil.isSuperAdmin()) {
|
||||
isModify = false;
|
||||
}
|
||||
if (isModify) {
|
||||
RoomTitleEditActivity.startForResult(getActivity(), info.getRoomDesc(), info.getIntroduction());
|
||||
} else {
|
||||
DialogFragment dialogFragment =
|
||||
RoomTitleDialogFragment.getInstance(info.getRoomDesc(), info.getIntroduction());
|
||||
dialogFragment.show(requireActivity().getSupportFragmentManager(), "roomTitle");
|
||||
}
|
||||
}
|
||||
}
|
@@ -4,11 +4,24 @@ import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
|
||||
import com.chwl.app.avroom.dialog.RoomTeamPKResultDialog;
|
||||
import com.chwl.app.avroom.dialog.RoomTeamPkDialog;
|
||||
import com.chwl.app.avroom.headline.RoomHeadlineWidget;
|
||||
import com.chwl.app.avroom.online.RoomOnlineWidget;
|
||||
import com.chwl.app.avroom.rank.RoomRankNumberWidget;
|
||||
import com.chwl.app.music.widget.MusicPlayerView;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils;
|
||||
import com.chwl.app.ui.webview.DialogWebViewActivity;
|
||||
import com.chwl.core.room.bean.RightBottomIconConfig;
|
||||
import com.chwl.core.room.bean.RoomIcon;
|
||||
import com.chwl.core.room.core.RoomDataService;
|
||||
import com.chwl.core.room.pk.event.PKDataUpdateEvent;
|
||||
import com.chwl.core.support.room.AudioRoomContext;
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
import com.trello.rxlifecycle3.android.FragmentEvent;
|
||||
import com.chwl.app.R;
|
||||
@@ -22,12 +35,9 @@ import com.chwl.app.avroom.anotherroompk.RoomPkForceFinishDialog;
|
||||
import com.chwl.app.avroom.anotherroompk.RoomPkReceivedDialog;
|
||||
import com.chwl.app.avroom.dialog.MicQueueDialog;
|
||||
import com.chwl.app.avroom.dialog.PKMicQueueDialog;
|
||||
import com.chwl.app.avroom.dialog.PKResultDialog;
|
||||
import com.chwl.app.avroom.dialog.PKScoreBoardDialog;
|
||||
import com.chwl.app.avroom.giftvalue.GiftValueDialogUiHelper;
|
||||
import com.chwl.app.avroom.presenter.HomePartyPresenter;
|
||||
import com.chwl.app.avroom.view.IHomePartyView;
|
||||
import com.chwl.app.avroom.widget.PKBoardView;
|
||||
import com.chwl.app.base.BaseMvpActivity;
|
||||
import com.chwl.app.common.widget.dialog.DialogManager;
|
||||
import com.chwl.app.databinding.FragmentAvRoomGameBinding;
|
||||
@@ -75,6 +85,7 @@ import io.reactivex.Single;
|
||||
import io.reactivex.SingleObserver;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.functions.Consumer;
|
||||
|
||||
/**
|
||||
* 轰趴房间
|
||||
@@ -84,10 +95,10 @@ import io.reactivex.disposables.Disposable;
|
||||
*/
|
||||
@CreatePresenter(HomePartyPresenter.class)
|
||||
public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, HomePartyPresenter> implements
|
||||
IHomePartyView, PKBoardView.OnActionListener {
|
||||
IHomePartyView, RoomTeamPkDialog.OnActionListener {
|
||||
|
||||
private long myUid;
|
||||
private PKBoardView pkBoardView;
|
||||
private RoomTeamPkDialog teamPkDialog;
|
||||
private Disposable mDisposable;
|
||||
private FragmentAvRoomGameBinding gameBinding;
|
||||
/**
|
||||
@@ -97,6 +108,8 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
private PKMicQueueDialog pkMicQueueDialog;
|
||||
private Disposable roomPkOrderDisposable;
|
||||
|
||||
private boolean hasBaishunGames;
|
||||
|
||||
public static HomePartyRoomFragment newInstance() {
|
||||
HomePartyRoomFragment roomFragment = new HomePartyRoomFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
@@ -118,8 +131,7 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
gameBinding.setKtvModel(false);
|
||||
gameBinding.playTogether.setVisibility(View.GONE);
|
||||
microView = mView.findViewById(R.id.micro_view);
|
||||
pkBoardView = mView.findViewById(R.id.layout_pk_board);
|
||||
pkBoardView.setOnActionListener(this);
|
||||
gameBinding.ivTeamPk.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -131,6 +143,9 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
@Override
|
||||
public void initWidget() {
|
||||
super.initWidget();
|
||||
registerWidget(RoomOnlineWidget.class.getSimpleName(), gameBinding.onlineWidget);
|
||||
registerWidget(RoomHeadlineWidget.class.getSimpleName(), gameBinding.headlineWidget);
|
||||
registerWidget(RoomRankNumberWidget.class.getSimpleName(), gameBinding.rankNumberWidget);
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
@@ -143,6 +158,28 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
updateQueuingMicBtn();
|
||||
updatePkScoreBoard();
|
||||
initRoomPkOrder(AvRoomDataManager.get().showPkBeginTime, AvRoomDataManager.get().pkBeginTime);
|
||||
requestData();
|
||||
}
|
||||
|
||||
private void requestData() {
|
||||
RoomDataService dataService = (RoomDataService) AudioRoomContext.Companion.get().findAbility(RoomDataService.class.getSimpleName());
|
||||
String cacheKey = "gameplay_list#" + hashCode();
|
||||
Disposable disposable = AvRoomModel.get().getRoomGamePlayList().doOnError(new Consumer<Throwable>() {
|
||||
@Override
|
||||
public void accept(Throwable throwable) throws Exception {
|
||||
hasBaishunGames = false;
|
||||
updateConfigButtonArea();
|
||||
}
|
||||
}).subscribe(new Consumer<List<RoomIcon>>() {
|
||||
@Override
|
||||
public void accept(List<RoomIcon> roomIcons) throws Exception {
|
||||
if (dataService != null) {
|
||||
dataService.putData(cacheKey, roomIcons);
|
||||
}
|
||||
hasBaishunGames = roomIcons.size() > 0;
|
||||
updateConfigButtonArea();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -191,6 +228,7 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
gameBinding.setRoomInfo(AvRoomDataManager.get().mCurrentRoomInfo);
|
||||
updateQueuingMicBtn();
|
||||
updatePkScoreBoard();
|
||||
updateConfigButtonArea();
|
||||
getMvpPresenter().updateLeaveMode();
|
||||
break;
|
||||
case RoomEvent.ENTER_ROOM:
|
||||
@@ -252,8 +290,12 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
//PK 开始弹出大记分板
|
||||
if (PkModel.get().getCurPkInfo() != null
|
||||
&& PkModel.get().getCurPkInfo().getPkStatus() == RoomPkData.PK_STATUS_IN_PK) {
|
||||
PKScoreBoardDialog pkScoreBoardDialog = new PKScoreBoardDialog(getContext());
|
||||
pkScoreBoardDialog.show();
|
||||
showTeamPkDialog();
|
||||
}
|
||||
break;
|
||||
case RoomEvent.PK_CREATE:
|
||||
if (PkModel.get().getCurPkInfo() != null) {
|
||||
showTeamPkDialog();
|
||||
}
|
||||
break;
|
||||
case RoomEvent.ROOM_PK_INVITE:
|
||||
@@ -340,14 +382,14 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
private void updatePkScoreBoard() {
|
||||
if (AvRoomDataManager.get().isOpenPKMode()) {
|
||||
|
||||
if (pkBoardView.getVisibility() == View.GONE) {
|
||||
if (gameBinding.ivTeamPk.getVisibility() == View.GONE) {
|
||||
// 通知更新背景
|
||||
PKStateEvent pkStateEvent = new PKStateEvent();
|
||||
pkStateEvent.setCreate(true);
|
||||
EventBus.getDefault().post(pkStateEvent);
|
||||
showTeamPkDialog();
|
||||
}
|
||||
|
||||
pkBoardView.setVisibility(View.VISIBLE);
|
||||
gameBinding.ivTeamPk.setVisibility(View.VISIBLE);
|
||||
//这里通过接口获取PK 详情 更新pk 记分板
|
||||
if (PkModel.get().getCurPkInfo() == null) {
|
||||
PkModel.get().loadPKDataByRoomId(
|
||||
@@ -361,7 +403,9 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
|
||||
@Override
|
||||
public void onSuccess(RoomPkData roomPkData) {
|
||||
pkBoardView.updateView();
|
||||
if (teamPkDialog != null) {
|
||||
teamPkDialog.updateView();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -370,7 +414,9 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
}
|
||||
});
|
||||
} else {
|
||||
pkBoardView.updateView();
|
||||
if (teamPkDialog != null) {
|
||||
teamPkDialog.updateView();
|
||||
}
|
||||
}
|
||||
//取消掉正在进行的龙珠
|
||||
if (AvRoomDataManager.get().haveStartDragon) {
|
||||
@@ -382,23 +428,41 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
}
|
||||
|
||||
} else {
|
||||
if (pkBoardView.getVisibility() == View.VISIBLE) {
|
||||
if (gameBinding.ivTeamPk.getVisibility() == View.VISIBLE) {
|
||||
// 通知更新bg
|
||||
PKStateEvent pkStateEvent = new PKStateEvent();
|
||||
pkStateEvent.setCreate(false);
|
||||
EventBus.getDefault().post(pkStateEvent);
|
||||
}
|
||||
pkBoardView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (SuperAdminUtil.isSuperAdmin()) {
|
||||
pkBoardView.setVisibility(View.GONE);
|
||||
gameBinding.ivTeamPk.setVisibility(View.GONE);
|
||||
dismissTeamPkDialog();
|
||||
}
|
||||
|
||||
//龙珠相关界面设置
|
||||
setDragonView();
|
||||
}
|
||||
|
||||
private void showTeamPkDialog() {
|
||||
if (getActivity() == null) {
|
||||
return;
|
||||
}
|
||||
if (teamPkDialog != null) {
|
||||
if (teamPkDialog.isResumed()) {
|
||||
return;
|
||||
}
|
||||
dismissTeamPkDialog();
|
||||
}
|
||||
teamPkDialog = new RoomTeamPkDialog();
|
||||
teamPkDialog.setOnActionListener(this);
|
||||
teamPkDialog.safeShow(requireActivity().getSupportFragmentManager(), this, null);
|
||||
}
|
||||
|
||||
private void dismissTeamPkDialog() {
|
||||
if (teamPkDialog != null) {
|
||||
teamPkDialog.safeDismiss();
|
||||
teamPkDialog = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void cleanDragonBar() {
|
||||
LogUtil.e("cleanDragonBar");
|
||||
@@ -435,6 +499,13 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
gameBinding.ivQueuingMicro.setVisibility(View.GONE);
|
||||
gameBinding.bottomView.updateQueuingMicButton();
|
||||
}
|
||||
updateMicroView();
|
||||
changeModelShowView();
|
||||
refreshDatingNextStatus();
|
||||
// updateConfigButtonArea();
|
||||
}
|
||||
|
||||
protected void updateMicroView(){
|
||||
String microType = microView.getAdapter() == null ? BaseMicroViewAdapter.MICRO_TYPE_NULL : microView.getAdapter().microType();
|
||||
if (AvRoomDataManager.get().isCpRoom()) {
|
||||
if (!microType.equals(BaseMicroViewAdapter.MICRO_TYPE_CP)) {
|
||||
@@ -452,16 +523,41 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
if (microView.getAdapter() != null) {
|
||||
microView.getAdapter().notifyDataSetChanged();
|
||||
}
|
||||
changeModelShowView();
|
||||
refreshDatingNextStatus();
|
||||
}
|
||||
|
||||
|
||||
public void updateMicBtn() {
|
||||
super.updateMicBtn();
|
||||
refreshDatingNextStatus();
|
||||
}
|
||||
|
||||
public void updateConfigButtonArea() {
|
||||
RightBottomIconConfig configModel = AvRoomDataManager.get().rightBottomIconConfig;
|
||||
if (configModel == null) {
|
||||
gameBinding.ivConfigEntrance.setVisibility(View.GONE);
|
||||
} else {
|
||||
if (configModel.getIcon1Url() == null) {
|
||||
gameBinding.ivConfigEntrance.setVisibility(View.GONE);
|
||||
} else {
|
||||
ImageLoadUtils.loadAvatar(configModel.getIcon1Url(), gameBinding.ivConfigEntrance);
|
||||
gameBinding.ivConfigEntrance.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
if (configModel.getIcon2Url() != null) {
|
||||
ImageLoadUtils.loadAvatar(configModel.getIcon2Url(), gameBinding.ivGame);
|
||||
}
|
||||
}
|
||||
|
||||
if (AvRoomDataManager.get().isDatingMode()) {
|
||||
gameBinding.ivGame.setVisibility(View.GONE);
|
||||
} else {
|
||||
if (hasBaishunGames) {
|
||||
gameBinding.ivGame.setVisibility(View.VISIBLE);
|
||||
}else {
|
||||
gameBinding.ivGame.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateQueuingMicBtn() {
|
||||
if (AvRoomDataManager.get().mCurrentRoomInfo != null) {
|
||||
bottomView.updateQueuingMicButton();
|
||||
@@ -520,10 +616,10 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
mDisposable.dispose();
|
||||
mDisposable = null;
|
||||
}
|
||||
dismissTeamPkDialog();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onDatingSelectUserEvent(DatingSelectUserEvent event) {
|
||||
if (getMvpPresenter() != null) {
|
||||
@@ -555,6 +651,9 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
public void onClick(View v) {
|
||||
super.onClick(v);
|
||||
switch (v.getId()) {
|
||||
case R.id.iv_team_pk:
|
||||
showTeamPkDialog();
|
||||
break;
|
||||
case R.id.play_together:
|
||||
if (!DynamicFaceModel.get().isShowingFace()) {
|
||||
FaceInfo faceInfo = DynamicFaceModel.get().getPlayTogetherFace();
|
||||
@@ -584,6 +683,12 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
getMvpPresenter().cancelDragon();
|
||||
});
|
||||
break;
|
||||
case R.id.layout_hour_rank:
|
||||
DialogWebViewActivity.start(
|
||||
mContext,
|
||||
UriProvider.getRoomHourRankUrl(AvRoomDataManager.get().getRoomUid())
|
||||
);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -674,12 +779,6 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEndPK() {
|
||||
PKResultDialog pkResultDialog = new PKResultDialog(getContext(), PkModel.get().getCurPkInfo());
|
||||
pkResultDialog.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShowPKMicQueueDialog() {
|
||||
if (PkModel.get().isFighting()) {
|
||||
@@ -772,6 +871,11 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
if (AvRoomDataManager.get().mCurrentRoomInfo == null) {
|
||||
return;
|
||||
}
|
||||
if (AvRoomDataManager.get().mCurrentRoomInfo.getIsPermitRoom() == 1) {
|
||||
gameBinding.layoutHourRank.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
gameBinding.layoutHourRank.setVisibility(View.GONE);
|
||||
}
|
||||
setDragonView();
|
||||
}
|
||||
|
||||
@@ -1003,4 +1107,16 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
super.onInitMusicPlayerView(view);
|
||||
view.linkIconView(gameBinding.ivMusic, gameBinding.ivMusic);
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onPKDataUpdateEvent(PKDataUpdateEvent event) {
|
||||
RoomPkData data = PkModel.get().getCurPkInfo();
|
||||
if (data == null) {
|
||||
return;
|
||||
}
|
||||
if (event.getType() == PKDataUpdateEvent.TYPE_RESULT && data.getPkStatus() == RoomPkData.PK_STATUS_AFTER_PK) {
|
||||
RoomTeamPKResultDialog teamPkResultDialog = new RoomTeamPKResultDialog(getContext(), PkModel.get().getCurPkInfo());
|
||||
teamPkResultDialog.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -6,11 +6,13 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chwl.core.room.bean.RoomOnlineUserBean;
|
||||
import com.netease.nim.uikit.common.util.sys.NetworkUtil;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMember;
|
||||
import com.orhanobut.logger.Logger;
|
||||
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadmoreListener;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.avroom.adapter.OnlineUserAdapter;
|
||||
@@ -44,7 +46,6 @@ public class OnlineUserFragment extends BaseMvpFragment<IHomePartyUserListView,
|
||||
private SmartRefreshLayout mRefreshLayout;
|
||||
|
||||
private OnlineUserAdapter mOnlineUserAdapter;
|
||||
private int mPage = Constants.PAGE_START;
|
||||
private boolean isShowToUser = false;
|
||||
|
||||
@Override
|
||||
@@ -58,25 +59,12 @@ public class OnlineUserFragment extends BaseMvpFragment<IHomePartyUserListView,
|
||||
public void onFindViews() {
|
||||
mRecyclerView = mView.findViewById(R.id.recycler_view);
|
||||
mRefreshLayout = mView.findViewById(R.id.refresh_layout);
|
||||
mRefreshLayout.setEnableLoadmore(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetListener() {
|
||||
mRefreshLayout.setOnRefreshLoadmoreListener(new OnRefreshLoadmoreListener() {
|
||||
@Override
|
||||
public void onLoadmore(RefreshLayout refreshLayout) {
|
||||
if (!NetworkUtil.isNetAvailable(mContext)) {
|
||||
mRefreshLayout.finishLoadmore();
|
||||
return;
|
||||
}
|
||||
List<OnlineChatMember> data = mOnlineUserAdapter.getData();
|
||||
if (ListUtils.isListEmpty(data)) {
|
||||
mRefreshLayout.finishLoadmore();
|
||||
return;
|
||||
}
|
||||
loadData(data.get(data.size() - 1).chatRoomMember.getEnterTime());
|
||||
}
|
||||
|
||||
mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh(RefreshLayout refreshLayout) {
|
||||
if (!NetworkUtil.isNetAvailable(mContext)) {
|
||||
@@ -106,53 +94,24 @@ public class OnlineUserFragment extends BaseMvpFragment<IHomePartyUserListView,
|
||||
|
||||
|
||||
public void firstLoad() {
|
||||
mPage = Constants.PAGE_START;
|
||||
loadData(0);
|
||||
loadData();
|
||||
}
|
||||
|
||||
private void loadData(long time) {
|
||||
getMvpPresenter().requestChatMemberByPage(mPage, time,
|
||||
mOnlineUserAdapter == null ? null : mOnlineUserAdapter.getData());
|
||||
private void loadData() {
|
||||
getMvpPresenter().requestRoomOnlineList(AvRoomDataManager.get().getRoomUid());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onRequestChatMemberByPageSuccess(List<OnlineChatMember> chatRoomMemberList, int page) {
|
||||
mPage = page;
|
||||
if (!ListUtils.isListEmpty(chatRoomMemberList)) {
|
||||
//超管不显示
|
||||
Iterator<OnlineChatMember> iterator = chatRoomMemberList.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
OnlineChatMember member = iterator.next();
|
||||
if (member != null && SuperAdminUtil.isSuperAdmin(member.chatRoomMember)) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
mOnlineUserAdapter.setNewData(chatRoomMemberList);
|
||||
if (mPage == Constants.PAGE_START) {
|
||||
mRefreshLayout.finishRefresh();
|
||||
} else {
|
||||
mRefreshLayout.finishLoadmore(0);
|
||||
}
|
||||
mPage++;
|
||||
} else {
|
||||
if (mPage == Constants.PAGE_START) {
|
||||
mRefreshLayout.finishRefresh();
|
||||
} else {
|
||||
mRefreshLayout.finishLoadmore(0);
|
||||
}
|
||||
}
|
||||
public void onRequestRoomOnlineListSuccess(List<RoomOnlineUserBean> chatRoomMemberList) {
|
||||
mOnlineUserAdapter.setNewData(chatRoomMemberList);
|
||||
mRefreshLayout.finishRefresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestChatMemberByPageFail(String errorStr, int page) {
|
||||
Logger.i(ResUtil.getString(R.string.avroom_fragment_onlineuserfragment_01) + page);
|
||||
mPage = page;
|
||||
if (mPage == Constants.PAGE_START) {
|
||||
mRefreshLayout.finishRefresh();
|
||||
} else {
|
||||
mRefreshLayout.finishLoadmore(0);
|
||||
}
|
||||
mRefreshLayout.finishRefresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -166,16 +125,15 @@ public class OnlineUserFragment extends BaseMvpFragment<IHomePartyUserListView,
|
||||
public void onItemClick(BaseQuickAdapter baseQuickAdapter, View view, int position) {
|
||||
RoomInfo currentRoom = AvRoomDataManager.get().mCurrentRoomInfo;
|
||||
if (currentRoom != null) {
|
||||
List<OnlineChatMember> chatRoomMembers = mOnlineUserAdapter.getData();
|
||||
List<RoomOnlineUserBean> chatRoomMembers = mOnlineUserAdapter.getData();
|
||||
if (ListUtils.isListEmpty(chatRoomMembers)) return;
|
||||
OnlineChatMember onlineChatMember = chatRoomMembers.get(position);
|
||||
ChatRoomMember chatRoomMember = onlineChatMember.chatRoomMember;
|
||||
if (chatRoomMember != null) {
|
||||
RoomOnlineUserBean onlineChatMember = chatRoomMembers.get(position);
|
||||
if (onlineChatMember != null) {
|
||||
if (onlineChatMember.getItemType() == OnlineChatMember.NOBLE) {
|
||||
return;
|
||||
}
|
||||
UserInfoDialog.showNewUserInfoDialog(mContext,
|
||||
JavaUtil.str2long(chatRoomMember.getAccount()),
|
||||
onlineChatMember.getUid(),
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
@@ -185,28 +143,24 @@ public class OnlineUserFragment extends BaseMvpFragment<IHomePartyUserListView,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMemberIn(String account, List<OnlineChatMember> dataList) {
|
||||
public void onMemberIn(String account) {
|
||||
// if (!isResumed()) return;
|
||||
// getMvpPresenter().onMemberInRefreshData(account, dataList, mPage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMemberExit(String account, List<OnlineChatMember> dataList) {
|
||||
public void onMemberExit(String account) {
|
||||
// if (!isResumed()) return;
|
||||
// if (!isShowToUser()) return;
|
||||
// firstLoad();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMemberDownUpMic(String account, boolean isUpMic, List<OnlineChatMember> dataList) {
|
||||
if (!isResumed()) return;
|
||||
getMvpPresenter().onMemberDownUpMic(account, isUpMic, dataList, mPage);
|
||||
public void onMemberDownUpMic(String account, boolean isUpMic) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateMemberManager(String account, boolean isRemoveManager, List<OnlineChatMember> dataList) {
|
||||
if (!isResumed()) return;
|
||||
getMvpPresenter().onUpdateMemberManager(account, dataList, isRemoveManager, mPage);
|
||||
public void onUpdateMemberManager(String account, boolean isRemoveManager) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -0,0 +1,34 @@
|
||||
package com.chwl.app.avroom.fragment
|
||||
|
||||
import com.chwl.app.avroom.adapter.BaseMicroViewAdapter
|
||||
import com.chwl.app.avroom.adapter.PartyMicroViewAdapter
|
||||
import com.example.lib_utils.UiUtils
|
||||
import com.example.lib_utils.ktx.setMargin
|
||||
|
||||
/**
|
||||
* 聚会房
|
||||
*/
|
||||
class PartyRoomFragment : HomePartyRoomFragment() {
|
||||
|
||||
companion object {
|
||||
fun newInstance(): PartyRoomFragment {
|
||||
return PartyRoomFragment()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFindViews() {
|
||||
super.onFindViews()
|
||||
microView.setMargin(0,UiUtils.dip2px(30f),0,0)
|
||||
}
|
||||
|
||||
override fun updateMicroView() {
|
||||
val microType =
|
||||
if (microView.adapter == null) BaseMicroViewAdapter.MICRO_TYPE_NULL else microView.adapter.microType()
|
||||
if (microType != BaseMicroViewAdapter.MICRO_TYPE_PARTY) {
|
||||
microView.bindAdapter(PartyMicroViewAdapter(mContext))
|
||||
}
|
||||
if (microView.adapter != null) {
|
||||
microView.adapter.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
package com.chwl.app.avroom.fragment
|
||||
|
||||
import com.chwl.app.avroom.adapter.BaseMicroViewAdapter
|
||||
import com.chwl.app.avroom.adapter.RevelryMicroViewAdapter
|
||||
import com.example.lib_utils.UiUtils
|
||||
import com.example.lib_utils.ktx.setMargin
|
||||
|
||||
/**
|
||||
* 狂欢房
|
||||
*/
|
||||
class RevelryRoomFragment : HomePartyRoomFragment() {
|
||||
|
||||
companion object {
|
||||
fun newInstance(): RevelryRoomFragment {
|
||||
return RevelryRoomFragment()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFindViews() {
|
||||
super.onFindViews()
|
||||
microView.setMargin(0, UiUtils.dip2px(30f),0,0)
|
||||
}
|
||||
|
||||
override fun updateMicroView() {
|
||||
val microType =
|
||||
if (microView.adapter == null) BaseMicroViewAdapter.MICRO_TYPE_NULL else microView.adapter.microType()
|
||||
if (microType != BaseMicroViewAdapter.MICRO_TYPE_REVELRY) {
|
||||
microView.bindAdapter(RevelryMicroViewAdapter(mContext))
|
||||
}
|
||||
if (microView.adapter != null) {
|
||||
microView.adapter.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
}
|
@@ -3,6 +3,7 @@ package com.chwl.app.avroom.fragment;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.avroom.adapter.CommonVPAdapter;
|
||||
import com.chwl.app.avroom.adapter.RoomContributeListAdapter;
|
||||
import com.chwl.app.avroom.widget.RankNavigatorAdapter;
|
||||
import com.chwl.app.base.BaseBindingFragment;
|
||||
@@ -26,7 +27,7 @@ public class RoomCharmListFragment extends BaseBindingFragment<FragmentRoomCharm
|
||||
ArrayList<Fragment> fragments = new ArrayList<>(2);
|
||||
fragments.add(RoomCharmRankingListFragment.newInstance(RoomContributeDataInfo.TYPE_ROOM_DAY_RANKING));
|
||||
fragments.add(RoomCharmRankingListFragment.newInstance(RoomContributeDataInfo.TYPE_ROOM_WEEK_RANKING));
|
||||
mBinding.vpCharmRankings.setAdapter(new RoomContributeListAdapter(getChildFragmentManager(), fragments));
|
||||
mBinding.vpCharmRankings.setAdapter(new CommonVPAdapter(getChildFragmentManager(), getLifecycle(),fragments));
|
||||
CommonNavigator commonNavigator = new CommonNavigator(getActivity());
|
||||
commonNavigator.setAdjustMode(false);
|
||||
|
||||
|
@@ -2,8 +2,10 @@ package com.chwl.app.avroom.fragment;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.avroom.adapter.CommonVPAdapter;
|
||||
import com.chwl.app.avroom.adapter.RoomContributeListAdapter;
|
||||
import com.chwl.app.avroom.widget.RankNavigatorAdapter;
|
||||
import com.chwl.app.base.BaseMvpFragment;
|
||||
@@ -21,7 +23,7 @@ import java.util.ArrayList;
|
||||
*/
|
||||
public class RoomContributeListFragment extends BaseMvpFragment implements IMvpBaseView {
|
||||
|
||||
private ViewPager viewPager;
|
||||
private ViewPager2 viewPager;
|
||||
private MagicIndicator viewIndicator;
|
||||
|
||||
@Override
|
||||
@@ -43,7 +45,7 @@ public class RoomContributeListFragment extends BaseMvpFragment implements IMvpB
|
||||
if (AvRoomDataManager.get().isDatingMode()) {
|
||||
fragments.add(RoomContributeFragment.newInstance(RoomContributeDataInfo.TYPE_ROOM_MONTH_RANKING));
|
||||
}
|
||||
viewPager.setAdapter(new RoomContributeListAdapter(getChildFragmentManager(), fragments));
|
||||
viewPager.setAdapter(new CommonVPAdapter(getChildFragmentManager(),getLifecycle(), fragments));
|
||||
CommonNavigator commonNavigator = new CommonNavigator(getActivity());
|
||||
commonNavigator.setAdjustMode(false);
|
||||
RankNavigatorAdapter indicator = new RankNavigatorAdapter(AvRoomDataManager.get().isDatingMode());
|
||||
|
@@ -5,6 +5,7 @@ import android.view.View;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.avroom.adapter.CommonVPAdapter;
|
||||
import com.chwl.app.avroom.adapter.RoomContributeListAdapter;
|
||||
import com.chwl.app.avroom.widget.RoomRankNavigatorAdapter;
|
||||
import com.chwl.app.base.BaseBindingFragment;
|
||||
@@ -29,7 +30,7 @@ public class RoomRankListFragment extends BaseBindingFragment<FragmentRoomRankLi
|
||||
List<Fragment> list = new ArrayList<>(2);
|
||||
list.add(new RoomContributeListFragment());
|
||||
list.add(RoomCharmListFragment.newInstance());
|
||||
mBinding.viewPager.setAdapter(new RoomContributeListAdapter(getChildFragmentManager(), list));
|
||||
mBinding.viewPager.setAdapter(new CommonVPAdapter(getChildFragmentManager(), getLifecycle(), list));
|
||||
|
||||
CommonNavigator commonNavigator = new CommonNavigator(getActivity());
|
||||
commonNavigator.setAdjustMode(true);
|
||||
|
@@ -0,0 +1,249 @@
|
||||
package com.chwl.app.avroom.fragment
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.viewModels
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.adapter.OnMicroItemClickListener
|
||||
import com.chwl.app.avroom.adapter.SingleAnchorMicroViewAdapter
|
||||
import com.chwl.app.avroom.adapter.SingleRoomPKMicroViewAdapter
|
||||
import com.chwl.app.avroom.dialog.RequestUpMicDialog
|
||||
import com.chwl.app.avroom.headline.RoomHeadlineWidget
|
||||
import com.chwl.app.avroom.online.RoomOnlineWidget
|
||||
import com.chwl.app.avroom.presenter.SingleRoomPresenter
|
||||
import com.chwl.app.avroom.rank.RoomRankNumberWidget
|
||||
import com.chwl.app.avroom.singleroompk.SingleRoomPkFinishDialog
|
||||
import com.chwl.app.avroom.singleroompk.SingleRoomPkForceFinishDialog
|
||||
import com.chwl.app.avroom.singleroompk.SingleRoomPkReceivedDialog
|
||||
import com.chwl.app.avroom.view.ISingleRoomView
|
||||
import com.chwl.app.databinding.FragmentSingleRoomBinding
|
||||
import com.chwl.app.fansteam.FansTeamJoinActivity
|
||||
import com.chwl.app.fansteam.FansTeamJoinedActivity
|
||||
import com.chwl.app.fansteam.FansTeamViewModel
|
||||
import com.chwl.app.music.widget.MusicPlayerView
|
||||
import com.chwl.app.ui.webview.CommonWebViewActivity
|
||||
import com.chwl.app.ui.webview.DialogWebViewActivity
|
||||
import com.chwl.core.UriProvider
|
||||
import com.chwl.core.auth.AuthModel
|
||||
import com.chwl.core.fansteam.bean.FansTeamInitInfo
|
||||
import com.chwl.core.im.custom.bean.FansTeamMsgAttachment
|
||||
import com.chwl.core.im.custom.bean.RequestUpmicAttachment
|
||||
import com.chwl.core.im.custom.bean.RoomPKAttachment
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
import com.chwl.core.manager.RoomEvent
|
||||
import com.chwl.core.user.bean.UserInfo
|
||||
import com.chwl.library.base.factory.CreatePresenter
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil
|
||||
|
||||
/**
|
||||
* 個播房間
|
||||
*
|
||||
* @author chenran
|
||||
* @date 2017/7/26
|
||||
*/
|
||||
@CreatePresenter(SingleRoomPresenter::class)
|
||||
class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresenter?>(),
|
||||
ISingleRoomView, OnMicroItemClickListener {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun newInstance(): SingleRoomFragment {
|
||||
val roomFragment = SingleRoomFragment()
|
||||
val bundle = Bundle()
|
||||
roomFragment.arguments = bundle
|
||||
return roomFragment
|
||||
}
|
||||
}
|
||||
|
||||
private lateinit var gameBinding: FragmentSingleRoomBinding
|
||||
private lateinit var upMicDialog: RequestUpMicDialog
|
||||
|
||||
private val fansTeamViewModel: FansTeamViewModel by viewModels()
|
||||
override fun getRootLayoutId(): Int {
|
||||
return R.layout.fragment_single_room
|
||||
}
|
||||
|
||||
override fun onFindViews() {
|
||||
super.onFindViews()
|
||||
gameBinding = DataBindingUtil.bind(mView)!!
|
||||
gameBinding.lifecycleOwner = this
|
||||
gameBinding.click = this
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun initiate() {
|
||||
super.initiate()
|
||||
gameBinding.layoutHourRank.setOnClickListener {
|
||||
DialogWebViewActivity.start(
|
||||
mContext,
|
||||
UriProvider.getSingleRoomHourRankUrl(AvRoomDataManager.get().roomUid)
|
||||
)
|
||||
}
|
||||
fansTeamViewModel.loadFansTeamInitInfo()
|
||||
|
||||
fansTeamViewModel.fansTeamInitInfoLiveData.observe(viewLifecycleOwner) {
|
||||
it?.let {
|
||||
updateFansTeamInfo(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onReceiveRoomEvent(roomEvent: RoomEvent?) {
|
||||
super.onReceiveRoomEvent(roomEvent)
|
||||
if (roomEvent == null) return
|
||||
when (roomEvent.event) {
|
||||
RoomEvent.REQUEST_UP_MIC -> {
|
||||
(roomEvent.chatRoomMessage?.attachment as? RequestUpmicAttachment)?.userInfo?.let {
|
||||
showInviteDialog(it)
|
||||
}
|
||||
}
|
||||
RoomEvent.ROOM_PK_INVITE ->
|
||||
SingleRoomPkReceivedDialog.newInstance((roomEvent.chatRoomMessage.attachment as RoomPKAttachment).roomPkBean)
|
||||
.show(mContext)
|
||||
RoomEvent.ROOM_PK_FINISH -> {
|
||||
val roomPkBean =
|
||||
(roomEvent.chatRoomMessage.attachment as RoomPKAttachment).roomPkBean
|
||||
if (roomPkBean.isForce) {
|
||||
SingleRoomPkForceFinishDialog.newInstance(roomPkBean).show(mContext)
|
||||
} else {
|
||||
SingleRoomPkFinishDialog.newInstance(roomPkBean).show(mContext)
|
||||
}
|
||||
gameBinding.microView.adapter?.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
RoomEvent.FANS_TEAM_OPEN_SUCCESS,
|
||||
RoomEvent.FANS_TEAM_OPEN_FAILED,
|
||||
RoomEvent.FANS_TEAM_JOIN,
|
||||
RoomEvent.FANS_TEAM_EXIT -> {
|
||||
(roomEvent.chatRoomMessage?.attachment as? FansTeamMsgAttachment)?.fansTeamMsgInfo?.let {
|
||||
val currFansTeamInitInfo = fansTeamViewModel.fansTeamInitInfoLiveData.value
|
||||
updateFansTeamInfo(
|
||||
FansTeamInitInfo(
|
||||
it.count,
|
||||
currFansTeamInitInfo?.fansLevelSeq ?: 1,
|
||||
roomEvent.event != RoomEvent.FANS_TEAM_OPEN_FAILED,
|
||||
if (AuthModel.get().currentUid == it.uid) {
|
||||
roomEvent.event == RoomEvent.FANS_TEAM_JOIN
|
||||
} else {
|
||||
currFansTeamInitInfo?.isAnchorFans ?: false
|
||||
},
|
||||
AvRoomDataManager.get().isRoomOwner,
|
||||
roomEvent.event == RoomEvent.FANS_TEAM_OPEN_FAILED
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun updateFansTeamInfo(initInfo: FansTeamInitInfo) {
|
||||
var clickListener: View.OnClickListener? = null
|
||||
if (initInfo.hasFansTeamCurrentRoom) {
|
||||
if (AvRoomDataManager.get().isRoomOwner) {
|
||||
gameBinding.flFansTeamJoinTip.isVisible = false
|
||||
gameBinding.tvFansTeamOpt.isVisible = true
|
||||
gameBinding.tvFansTeamOpt.text = String.format(getString(R.string.fans_team_4),"${initInfo.anchorFansNum}")
|
||||
clickListener = View.OnClickListener {
|
||||
DialogWebViewActivity.start(
|
||||
requireContext(),
|
||||
UriProvider.getFansTeamMyFansUrl(AvRoomDataManager.get().roomUid)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
if (initInfo.isAnchorFans) {
|
||||
gameBinding.flFansTeamJoinTip.isVisible = false
|
||||
gameBinding.tvFansTeamOpt.isVisible = true
|
||||
val level = if (initInfo.fansLevelSeq == 0) 1 else initInfo.fansLevelSeq
|
||||
val levelStr =
|
||||
String.format(requireContext().getString(R.string.fans_team_5), level.toString())
|
||||
gameBinding.tvFansTeamOpt.text = levelStr
|
||||
clickListener = View.OnClickListener {
|
||||
FansTeamJoinedActivity.start(requireContext())
|
||||
}
|
||||
} else {
|
||||
gameBinding.flFansTeamJoinTip.isVisible = true
|
||||
gameBinding.tvFansTeamOpt.isVisible = false
|
||||
clickListener = View.OnClickListener {
|
||||
FansTeamJoinActivity.start(requireContext())
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (AvRoomDataManager.get().isRoomOwner) {
|
||||
gameBinding.flFansTeamJoinTip.isVisible = false
|
||||
gameBinding.tvFansTeamOpt.isVisible = true
|
||||
gameBinding.tvFansTeamOpt.text = getString(R.string.fans_team_6)
|
||||
clickListener = View.OnClickListener {
|
||||
CommonWebViewActivity.start(
|
||||
requireContext(),
|
||||
UriProvider.getFansTeamOpenUrl(AvRoomDataManager.get().roomUid)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
gameBinding.flFansTeamJoinTip.isVisible = false
|
||||
gameBinding.tvFansTeamOpt.isVisible = true
|
||||
gameBinding.tvFansTeamOpt.text = getString(R.string.layout_fragment_single_room_03)
|
||||
}
|
||||
}
|
||||
gameBinding.flFansTeam.setOnClickListener(clickListener)
|
||||
}
|
||||
|
||||
//顯示請求上麥彈窗
|
||||
private fun showInviteDialog(userInfo: UserInfo) {
|
||||
if (!this::upMicDialog.isInitialized) {
|
||||
upMicDialog = RequestUpMicDialog(requireContext())
|
||||
}
|
||||
if (!upMicDialog.isShowing) {
|
||||
upMicDialog.openDialog()
|
||||
upMicDialog.setUser(userInfo)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSetListener() {
|
||||
super.onSetListener()
|
||||
bottomView.setBottomViewListener(BaseRoomBottomViewWrapper())
|
||||
}
|
||||
|
||||
override fun onEnterRoom() {
|
||||
super.onEnterRoom()
|
||||
fansTeamViewModel.loadFansTeamInitInfo()
|
||||
}
|
||||
|
||||
override fun updateView() {
|
||||
super.updateView()
|
||||
if (AvRoomDataManager.get().isOpenAnotherPKMode && gameBinding.microView.adapter !is SingleRoomPKMicroViewAdapter) {
|
||||
gameBinding.microView.bindAdapter(SingleRoomPKMicroViewAdapter(context))
|
||||
gameBinding.viewPkBoard.isVisible = true
|
||||
gameBinding.microView.updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||
topMargin = ScreenUtil.dip2px(140f)
|
||||
}
|
||||
} else if (!AvRoomDataManager.get().isOpenAnotherPKMode && gameBinding.microView.adapter !is SingleAnchorMicroViewAdapter) {
|
||||
gameBinding.microView.bindAdapter(SingleAnchorMicroViewAdapter(context))
|
||||
gameBinding.viewPkBoard.isVisible = false
|
||||
gameBinding.microView.updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||
topMargin = ScreenUtil.dip2px(110f)
|
||||
}
|
||||
} else {
|
||||
gameBinding.microView.adapter?.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
override fun initWidget() {
|
||||
super.initWidget()
|
||||
registerWidget(RoomOnlineWidget::class.java.simpleName, gameBinding.onlineWidget)
|
||||
registerWidget(RoomHeadlineWidget::class.java.simpleName, gameBinding.headlineWidget)
|
||||
registerWidget(RoomRankNumberWidget::class.java.simpleName, gameBinding.rankNumberWidget)
|
||||
}
|
||||
|
||||
override fun onInitMusicPlayerView(view: MusicPlayerView) {
|
||||
super.onInitMusicPlayerView(view)
|
||||
view.linkIconView(gameBinding.ivMusic, gameBinding.ivMusic)
|
||||
}
|
||||
}
|
16
app/src/main/java/com/chwl/app/avroom/game/AppConfig.java
Normal file
16
app/src/main/java/com/chwl/app/avroom/game/AppConfig.java
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
Copyright © Sud.Tech
|
||||
https://sud.tech
|
||||
*/
|
||||
package com.chwl.app.avroom.game;
|
||||
|
||||
|
||||
import com.chwl.app.BuildConfig;
|
||||
|
||||
public class AppConfig {
|
||||
|
||||
public static final String APP_ID = "1578948593831571457";
|
||||
public static final String APP_KEY = "J9lHOXvFWkAZiTfl4SK7IGt0wDnW3fWd";
|
||||
public static boolean isTestEnv = BuildConfig.DEBUG;
|
||||
|
||||
}
|
715
app/src/main/java/com/chwl/app/avroom/game/GameDelegate.kt
Normal file
715
app/src/main/java/com/chwl/app/avroom/game/GameDelegate.kt
Normal file
@@ -0,0 +1,715 @@
|
||||
package com.chwl.app.avroom.game
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.view.ViewTreeObserver.OnGlobalLayoutListener
|
||||
import android.widget.FrameLayout
|
||||
import com.google.gson.Gson
|
||||
import com.chwl.app.R
|
||||
import com.chwl.core.auth.AuthModel
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
import com.chwl.core.room.game.bean.GameCfg
|
||||
import com.chwl.core.room.game.GameModel
|
||||
import com.chwl.core.room.game.GameStatus
|
||||
import com.chwl.core.room.model.HomePartyModel
|
||||
import com.chwl.core.sud.model.GameViewInfoModel.GameViewRectModel
|
||||
import com.chwl.core.sud.state.SudMGPAPPState
|
||||
import com.chwl.core.sud.state.SudMGPMGState
|
||||
import com.chwl.core.user.UserModel
|
||||
import com.chwl.core.utils.LogUtils
|
||||
import com.chwl.core.utils.net.RxHelper
|
||||
import com.chwl.library.language.LanguageHelper
|
||||
import com.chwl.library.net.rxnet.callback.CallBack
|
||||
import com.chwl.library.utils.ResUtil
|
||||
import com.chwl.library.utils.SingleToastUtil
|
||||
import okhttp3.*
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
import tech.sud.mgp.core.*
|
||||
import java.util.*
|
||||
|
||||
class GameDelegate(val activity: Activity, val container: FrameLayout, var mgId: Long?) {
|
||||
|
||||
private val TAG = "GameDelegate"
|
||||
private var APP_CODE = ""
|
||||
|
||||
private val mRoomID :String get() = AvRoomDataManager.get().roomUid.toString()
|
||||
private var mLanguage = "zh-TW" //語言
|
||||
|
||||
//調用遊戲SDK的接口,成功加載遊戲後可用:
|
||||
private var iSudFSTAPP: ISudFSTAPP? = null
|
||||
|
||||
private val gson = Gson()
|
||||
|
||||
//小遊戲ID
|
||||
private var mMGID = 0L
|
||||
|
||||
//通用狀態-遊戲,關鍵詞
|
||||
private var mKeyWord: String? = null
|
||||
private val mUid = AuthModel.get().currentUid.toString()
|
||||
|
||||
private val homePartyModel = HomePartyModel()
|
||||
|
||||
private var onGameStatusChangeListener: OnGameStatusChangeListener? = null
|
||||
|
||||
var gameViewRect: GameViewRectModel? = null
|
||||
|
||||
fun setOnGameStatusChangeListener(onGameStatusChangeListener: OnGameStatusChangeListener) {
|
||||
this.onGameStatusChangeListener = onGameStatusChangeListener
|
||||
}
|
||||
|
||||
private val loginCallback: AppLoginListener =
|
||||
object : AppLoginListener {
|
||||
override fun onLoginFailure(err: String?) {
|
||||
SingleToastUtil.showToast(err)
|
||||
}
|
||||
|
||||
override fun onLoginSuccess(new_code: String, expire_Date: Long) {
|
||||
APP_CODE = new_code
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
//初始化遊戲SDK
|
||||
initGameSDK(
|
||||
activity,
|
||||
AppConfig.APP_ID,
|
||||
AppConfig.APP_KEY,
|
||||
AppConfig.isTestEnv
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
init {
|
||||
mMGID = mgId ?: 0L
|
||||
mLanguage = getGameLanguage()
|
||||
login(loginCallback)
|
||||
}
|
||||
|
||||
fun updateGame(mgId: Long?) {
|
||||
if (mgId == null || mgId == 0L) return
|
||||
if (mgId == mMGID && iSudFSTAPP != null) {
|
||||
return
|
||||
}
|
||||
mMGID = mgId
|
||||
updateMyMicQueue(GameStatus.STATUS_NOT_JOIN)
|
||||
loadMG(activity, mUid, mRoomID, APP_CODE, mMGID, mLanguage)
|
||||
}
|
||||
|
||||
fun exitGame() {
|
||||
UserModel.get().cacheLoginUserInfo?.gameStatus = GameStatus.STATUS_NOT_JOIN
|
||||
notifySelfPlayingState(false)
|
||||
notifySelfInState(false)
|
||||
}
|
||||
|
||||
/**
|
||||
* 例如"你畫我猜"遊戲的文字命中
|
||||
*/
|
||||
fun hitTheMark(msg: String) {
|
||||
mKeyWord?.let {
|
||||
if (msg.contains(it)) {
|
||||
notifySelfTextHit(it, msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* "接入方客戶端"登陸接口, 從"接入方服務端"獲得Code
|
||||
* "接入方服務端"是通過"服務端接入SDK"獲得Code來返回給"接入方客戶端"的
|
||||
* @param listener
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
private fun login(listener: AppLoginListener) {
|
||||
GameModel.getGameCode()
|
||||
.compose(RxHelper.bindContext(activity))
|
||||
.subscribe({
|
||||
listener.onLoginSuccess(it.code, it.expireDate)
|
||||
}, {
|
||||
listener.onLoginFailure(it.message)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 1,初始化遊戲SDK
|
||||
*
|
||||
* @param context 上下文
|
||||
* @param appID appID
|
||||
* @param appKey appKey
|
||||
* @param isTestEnv 是否是測試環境,true:測試環境,false:正式環境
|
||||
*/
|
||||
private fun initGameSDK(context: Context, appID: String, appKey: String, isTestEnv: Boolean) {
|
||||
SudMGP.initSDK(context, appID, appKey, isTestEnv, object : ISudListenerInitSDK {
|
||||
override fun onSuccess() {
|
||||
loadMG(activity, mUid, mRoomID, APP_CODE, mMGID, mLanguage)
|
||||
}
|
||||
|
||||
override fun onFailure(code: Int, errInfo: String) {
|
||||
val msg = context.getString(R.string.game_failed_tips).format("$code-${errInfo}")
|
||||
showToast(msg)
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 2,加載遊戲
|
||||
*
|
||||
* @param activity 上下文Activity
|
||||
* @param userID 用戶ID,業務系統保證每個用戶擁有唯一ID
|
||||
* @param roomID 房間ID,進入同一房間內的
|
||||
* @param code 令牌
|
||||
* @param mgID 小遊戲ID
|
||||
* @param language 遊戲語言 現支持,簡體:zh-CN 繁體:zh-TW 英語:en-US 馬來語:ms-MY
|
||||
*/
|
||||
private fun loadMG(
|
||||
activity: Activity,
|
||||
userID: String,
|
||||
roomID: String,
|
||||
code: String,
|
||||
mgID: Long,
|
||||
language: String
|
||||
) {
|
||||
iSudFSTAPP?.destroyMG()
|
||||
iSudFSTAPP = SudMGP.loadMG(activity, userID, roomID, code, mgID, language, mISudFSMMG)
|
||||
iSudFSTAPP?.apply {
|
||||
addGameView(gameView)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 3,將遊戲view添加到我們的布局當中
|
||||
*
|
||||
* @param gameView
|
||||
*/
|
||||
private fun addGameView(gameView: View) {
|
||||
container.removeAllViews()
|
||||
container.addView(gameView)
|
||||
}
|
||||
|
||||
private fun showToast(content: String?) {
|
||||
SingleToastUtil.showToast(content)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通知"文字命中狀態"到遊戲端
|
||||
*
|
||||
* @param iSudFSTAPP
|
||||
* @param keyWord
|
||||
*/
|
||||
private fun notifySelfTextHit(keyWord: String?, msg: String) {
|
||||
LogUtils.d("notifySelfTextHit")
|
||||
try {
|
||||
//狀態名稱
|
||||
val state: String = SudMGPAPPState.APP_COMMON_SELF_TEXT_HIT
|
||||
|
||||
//狀態數據
|
||||
val jsonObject = JSONObject()
|
||||
jsonObject.put("isHit", true) // true 命中,false 未命中
|
||||
jsonObject.put("keyWord", keyWord) // true 命中,false 未命中
|
||||
jsonObject.put("text", msg) // 聊天原始內容,這裏的值只是一個示例,意指內容當中包含關鍵詞則命中,具體按業務規則定。
|
||||
val dataJson = jsonObject.toString()
|
||||
//調用接口
|
||||
iSudFSTAPP?.notifyStateChange(state, dataJson, null)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 設置當前關鍵詞
|
||||
*
|
||||
* @param keyWord
|
||||
*/
|
||||
private fun setKeyWord(keyWord: String?) {
|
||||
mKeyWord = keyWord
|
||||
}
|
||||
|
||||
private fun getGameLanguage(): String {
|
||||
return when (LanguageHelper.getCurrentLanguageType()) {
|
||||
LanguageHelper.ZH -> {
|
||||
"zh-TW"
|
||||
}
|
||||
|
||||
LanguageHelper.AR -> {
|
||||
"ar-SA"
|
||||
}
|
||||
|
||||
else -> {
|
||||
"en-US"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 遊戲SDK調用app的接口
|
||||
*/
|
||||
private val mISudFSMMG: ISudFSMMG = object : ISudFSMMG {
|
||||
|
||||
override fun onGameLog(p0: String?) {
|
||||
LogUtils.d(p0)
|
||||
}
|
||||
|
||||
override fun onGameLoadingProgress(p0: Int, p1: Int, p2: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onGameStarted() {
|
||||
}
|
||||
|
||||
override fun onGameDestroyed() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 回調此方法,表示令牌過期,此時需要刷新令牌並使用ISudFSMStateHandle回調
|
||||
* @param handle
|
||||
* @param dataJson
|
||||
*/
|
||||
override fun onExpireCode(handle: ISudFSMStateHandle, dataJson: String) {
|
||||
login(object : AppLoginListener {
|
||||
override fun onLoginFailure(err: String?) {
|
||||
|
||||
}
|
||||
|
||||
override fun onLoginSuccess(new_code: String, expire_Date: Long) {
|
||||
APP_CODE = new_code
|
||||
try {
|
||||
val jsonObject = JSONObject()
|
||||
jsonObject.put("ret_code", 0)
|
||||
jsonObject.put("ret_msg", "success")
|
||||
handle.success(jsonObject.toString())
|
||||
} catch (e: JSONException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
iSudFSTAPP?.updateCode(APP_CODE, null)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 處理獲取遊戲視圖信息
|
||||
* @param handle
|
||||
* @param dataJson
|
||||
*/
|
||||
override fun onGetGameViewInfo(handle: ISudFSMStateHandle, dataJson: String) {
|
||||
//拿到遊戲View的寬高
|
||||
val gameViewWidth = container.measuredWidth
|
||||
val gameViewHeight = container.measuredHeight
|
||||
if (gameViewWidth > 0 && gameViewHeight > 0) {
|
||||
notifyGameViewInfo(handle, gameViewWidth, gameViewHeight)
|
||||
return
|
||||
}
|
||||
|
||||
//如果遊戲View未加載完成,則監聽加載完成時回調
|
||||
container.viewTreeObserver.addOnGlobalLayoutListener(object : OnGlobalLayoutListener {
|
||||
override fun onGlobalLayout() {
|
||||
container.viewTreeObserver.removeOnGlobalLayoutListener(this)
|
||||
val width = container.measuredWidth
|
||||
val height = container.measuredHeight
|
||||
notifyGameViewInfo(handle, width, height)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onGetGameCfg(handle: ISudFSMStateHandle?, p1: String?) {
|
||||
handle?.success(gson.toJson(GameCfg()))
|
||||
}
|
||||
|
||||
/**
|
||||
* 通知遊戲,遊戲視圖信息
|
||||
* @param handle
|
||||
* @param gameViewWidth
|
||||
* @param gameViewHeight
|
||||
*/
|
||||
private fun notifyGameViewInfo(
|
||||
handle: ISudFSMStateHandle,
|
||||
gameViewWidth: Int,
|
||||
gameViewHeight: Int
|
||||
) {
|
||||
try {
|
||||
val jsonObject = JSONObject()
|
||||
jsonObject.put("ret_code", 0)
|
||||
jsonObject.put("ret_msg", "success")
|
||||
|
||||
//遊戲View大小
|
||||
val viewSize = JSONObject()
|
||||
viewSize.put("width", gameViewWidth)
|
||||
viewSize.put("height", gameViewHeight)
|
||||
jsonObject.put("view_size", viewSize)
|
||||
|
||||
//遊戲安全操作區域
|
||||
val viewGameRect = JSONObject()
|
||||
val viewRect = gameViewRect
|
||||
if (viewRect != null) {
|
||||
Log.d(TAG,"notifyGameViewInfo top:${viewRect.top} viewRect:${viewRect.bottom}")
|
||||
viewGameRect.put("left", viewRect.left)
|
||||
viewGameRect.put("top", viewRect.top)
|
||||
viewGameRect.put("right", viewRect.right)
|
||||
viewGameRect.put("bottom", viewRect.bottom)
|
||||
} else {
|
||||
viewGameRect.put("left", 0)
|
||||
viewGameRect.put(
|
||||
"top",
|
||||
container.context.resources.getDimensionPixelOffset(R.dimen.dp_185)
|
||||
)
|
||||
viewGameRect.put("right", 0)
|
||||
viewGameRect.put(
|
||||
"bottom",
|
||||
container.context.resources.getDimensionPixelOffset(R.dimen.dp_180)
|
||||
)
|
||||
}
|
||||
jsonObject.put("view_game_rect", viewGameRect)
|
||||
//通知遊戲
|
||||
val json = jsonObject.toString()
|
||||
Log.d(TAG, "notifyGameViewInfo:$json")
|
||||
handle.success(json)
|
||||
} catch (e: JSONException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 遊戲狀態變化
|
||||
* @param handle
|
||||
* @param state 狀態名
|
||||
* @param dataJson 狀態數據,json字符串
|
||||
*/
|
||||
override fun onGameStateChange(
|
||||
handle: ISudFSMStateHandle,
|
||||
state: String,
|
||||
dataJson: String
|
||||
) {
|
||||
Log.d(TAG, "onGameStateChange state:$state--dataJson:$dataJson")
|
||||
when (state) {
|
||||
//SudMGPMGState.MG_COMMON_PUBLIC_MESSAGE -> showToast("遊戲:公屏消息")
|
||||
SudMGPMGState.MG_COMMON_KEY_WORD_TO_HIT -> {
|
||||
if (TextUtils.isEmpty(dataJson)) {
|
||||
setKeyWord(null)
|
||||
} else {
|
||||
try {
|
||||
val jsonObject = JSONObject(dataJson)
|
||||
if (jsonObject.isNull("word")) {
|
||||
setKeyWord(null)
|
||||
} else {
|
||||
val keyWord = jsonObject.getString("word")
|
||||
setKeyWord(keyWord)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
SudMGPMGState.MG_COMMON_SELF_CLICK_JOIN_BTN -> {
|
||||
|
||||
try {
|
||||
val jsonObject = JSONObject(dataJson)
|
||||
val seatIndex = jsonObject.optInt("seatIndex", -1)
|
||||
updateMyMicQueue(GameStatus.STATUS_NOT_READY, true, seatIndex)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
}
|
||||
SudMGPMGState.MG_COMMON_SELF_CLICK_START_BTN -> {
|
||||
notifySelfPlayingState(true)
|
||||
}
|
||||
SudMGPMGState.MG_COMMON_GAME_STATE -> handleGameState(dataJson)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 玩家狀態變化
|
||||
* @param handle
|
||||
* @param userId 玩家用戶ID
|
||||
* @param state 狀態名
|
||||
* @param dataJson 狀態數據,json字符串。參考文檔
|
||||
*/
|
||||
override fun onPlayerStateChange(
|
||||
handle: ISudFSMStateHandle,
|
||||
userId: String,
|
||||
state: String,
|
||||
dataJson: String
|
||||
) {
|
||||
Log.d(TAG, "onPlayerStateChange userId:$userId--state:$state--dataJson:$dataJson")
|
||||
when (state) {
|
||||
SudMGPMGState.MG_COMMON_PLAYER_IN -> handlePlayerIn(userId, dataJson)
|
||||
SudMGPMGState.MG_COMMON_PLAYER_READY -> handlePlayerReady(userId, dataJson)
|
||||
SudMGPMGState.MG_COMMON_PLAYER_CAPTAIN -> handlePlayerCaptain(dataJson)
|
||||
SudMGPMGState.MG_COMMON_PLAYER_PLAYING -> handlePlayerPlaying(userId, dataJson)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun handlePlayerIn(userId: String, dataJson: String) {
|
||||
if (userId != mUid) return
|
||||
try {
|
||||
val jsonObject = JSONObject(dataJson)
|
||||
val retCode = jsonObject.getInt("retCode")
|
||||
val isIn = jsonObject.getBoolean("isIn")
|
||||
if (retCode != 0) {
|
||||
return
|
||||
}
|
||||
if (isIn) { // 已加入
|
||||
if (AvRoomDataManager.get().isRoomOwner) {
|
||||
notifySelfCaptainState(mUid)
|
||||
}
|
||||
} else { // 未加入
|
||||
var reason = 0
|
||||
if (jsonObject.has("reason")) {
|
||||
reason = jsonObject.getInt("reason")
|
||||
}
|
||||
if (reason == 0) {
|
||||
updateMyMicQueue(GameStatus.STATUS_NOT_JOIN)
|
||||
} else if (reason == 1) {
|
||||
updateMyMicQueue(GameStatus.STATUS_NOT_JOIN)
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateMyMicQueue(gameStatus: Int, isJoin: Boolean = false, seatIndex: Int = -1) {
|
||||
UserModel.get().cacheLoginUserInfo?.gameStatus = gameStatus
|
||||
val position = AvRoomDataManager.get().getMicPosition(mUid)
|
||||
if (position != AvRoomDataManager.POSITON_NOT_ON_MIC) {
|
||||
if (isJoin) notifySelfInState(true, seatIndex)
|
||||
homePartyModel.updateMyMicQueue(
|
||||
position,
|
||||
AvRoomDataManager.get().roomId.toString(),
|
||||
UserModel.get().cacheLoginUserInfo
|
||||
).subscribe()
|
||||
} else if (isJoin) {
|
||||
val upPosition = AvRoomDataManager.get().findGamePosition()
|
||||
if (upPosition == Int.MIN_VALUE) {
|
||||
showToast(ResUtil.getString(R.string.room_game_number_full))
|
||||
} else {
|
||||
UserModel.get().cacheLoginUserInfo?.gameStatus = 1
|
||||
homePartyModel.upMicroPhone(upPosition,
|
||||
mUid,
|
||||
AvRoomDataManager.get().roomId.toString(),
|
||||
false, object : CallBack<String> {
|
||||
override fun onSuccess(data: String?) {
|
||||
notifySelfInState(true, seatIndex)
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, error: String?) {
|
||||
showToast(error)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun handlePlayerReady(userId: String, dataJson: String) {
|
||||
if (userId != mUid) return
|
||||
try {
|
||||
val jsonObject = JSONObject(dataJson)
|
||||
val retCode = jsonObject.getInt("retCode")
|
||||
val isReady = jsonObject.getBoolean("isReady")
|
||||
if (retCode != 0) {
|
||||
return
|
||||
}
|
||||
updateMyMicQueue(if (isReady) GameStatus.STATUS_READY else GameStatus.STATUS_NOT_READY)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
private fun handlePlayerCaptain(dataJson: String) {
|
||||
try {
|
||||
val jsonObject = JSONObject(dataJson)
|
||||
val retCode = jsonObject.getInt("retCode")
|
||||
if (retCode != 0) {
|
||||
return
|
||||
}
|
||||
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleGameState(dataJson: String) {
|
||||
try {
|
||||
val jsonObject = JSONObject(dataJson)
|
||||
val gameState = jsonObject.getInt("gameState")
|
||||
if (gameState == 0) {
|
||||
onGameStatusChangeListener?.onGameEnd()
|
||||
} else if (gameState == 2) {
|
||||
onGameStatusChangeListener?.onGameStart()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
private fun handlePlayerPlaying(userId: String, dataJson: String) {
|
||||
if (userId != mUid) return
|
||||
try {
|
||||
val jsonObject = JSONObject(dataJson)
|
||||
val retCode = jsonObject.getInt("retCode")
|
||||
if (retCode != 0) {
|
||||
return
|
||||
}
|
||||
val isPlaying = jsonObject.getBoolean("isPlaying")
|
||||
if (isPlaying) {
|
||||
updateMyMicQueue(GameStatus.STATUS_PLAYING)
|
||||
} else {
|
||||
updateMyMicQueue(GameStatus.STATUS_NOT_READY)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
private fun notifySelfInState(isIn: Boolean, seatIndex: Int = -1) {
|
||||
try {
|
||||
if (!isIn) {
|
||||
notifySelfReadyState(false)
|
||||
}
|
||||
//狀態名稱
|
||||
val state = SudMGPAPPState.APP_COMMON_SELF_IN
|
||||
//狀態數據
|
||||
val jsonObject = JSONObject()
|
||||
jsonObject.put("isIn", isIn) // true 加入遊戲,false 退出遊戲
|
||||
if (seatIndex != -1) {
|
||||
jsonObject.put("seatIndex", seatIndex)
|
||||
}
|
||||
jsonObject.put("teamId", 1) //哪一隊伍(2v2,4v4)
|
||||
val dataJson = jsonObject.toString()
|
||||
|
||||
//調用接口
|
||||
iSudFSTAPP?.notifyStateChange(state, dataJson, null)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
private fun notifySelfReadyState(isReady: Boolean) {
|
||||
try {
|
||||
//狀態名稱
|
||||
val state = SudMGPAPPState.APP_COMMON_SELF_READY
|
||||
|
||||
//狀態數據
|
||||
val jsonObject = JSONObject()
|
||||
jsonObject.put("isReady", isReady) // true 準備,false 取消準備
|
||||
val dataJson = jsonObject.toString()
|
||||
|
||||
//調用接口
|
||||
iSudFSTAPP?.notifyStateChange(state, dataJson, null)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
private fun notifySelfPlayingState(isPlaying: Boolean) {
|
||||
try {
|
||||
//狀態名稱
|
||||
val state = SudMGPAPPState.APP_COMMON_SELF_PLAYING
|
||||
|
||||
//狀態數據
|
||||
val jsonObject = JSONObject()
|
||||
jsonObject.put("isPlaying", isPlaying) // true 開始遊戲,false 結束遊戲
|
||||
val dataJson = jsonObject.toString()
|
||||
|
||||
//調用接口
|
||||
iSudFSTAPP?.notifyStateChange(state, dataJson, null)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
private fun notifySelfCaptainState(uid: String) {
|
||||
try {
|
||||
//狀態名稱
|
||||
val state = SudMGPAPPState.APP_COMMON_SELF_CAPTAIN
|
||||
|
||||
//狀態數據
|
||||
val jsonObject = JSONObject()
|
||||
jsonObject.put("curCaptainUID", uid) // 必填,指定隊長uid
|
||||
val dataJson = jsonObject.toString()
|
||||
|
||||
//調用接口
|
||||
iSudFSTAPP?.notifyStateChange(state, dataJson, null)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
private fun notifySelfKickState(uid: String) {
|
||||
try {
|
||||
//狀態名稱
|
||||
val state = SudMGPAPPState.APP_COMMON_SELF_KICK
|
||||
|
||||
//狀態數據
|
||||
val jsonObject = JSONObject()
|
||||
jsonObject.put("kickedUID", uid) // 被踢用戶uid
|
||||
val dataJson = jsonObject.toString()
|
||||
|
||||
//調用接口
|
||||
iSudFSTAPP?.notifyStateChange(state, dataJson, null)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
private fun notifySelfEndState() {
|
||||
try {
|
||||
//狀態名稱
|
||||
val state = SudMGPAPPState.APP_COMMON_SELF_END
|
||||
|
||||
//狀態數據
|
||||
val jsonObject = JSONObject()
|
||||
val dataJson = jsonObject.toString()
|
||||
|
||||
//調用接口
|
||||
iSudFSTAPP?.notifyStateChange(state, dataJson, null)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
fun onStart() {
|
||||
iSudFSTAPP?.startMG() //啟動遊戲
|
||||
}
|
||||
|
||||
fun onResume() {
|
||||
iSudFSTAPP?.playMG() //開始遊戲
|
||||
}
|
||||
|
||||
fun onPause() {
|
||||
iSudFSTAPP?.pauseMG() //暫停遊戲
|
||||
}
|
||||
|
||||
fun onStop() {
|
||||
iSudFSTAPP?.stopMG() //停止遊戲
|
||||
}
|
||||
|
||||
fun onDestroy() {
|
||||
updateMyMicQueue(GameStatus.STATUS_NOT_JOIN)
|
||||
iSudFSTAPP?.destroyMG()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal interface AppLoginListener {
|
||||
/**
|
||||
* App Server 登陸失敗, App Server 不能返回CODE
|
||||
*/
|
||||
fun onLoginFailure(err: String?)
|
||||
|
||||
/**
|
||||
* App Server 登陸成功, App Server調用服務端接入SDK的API獲取Code 返回給 App
|
||||
* App 就要用CODE和自己生成的UserID去調用SDK的初始化函數,登陸小遊戲
|
||||
* 小遊戲登陸成功後,其UserID,就是App傳的UserID
|
||||
*/
|
||||
fun onLoginSuccess(new_code: String, expire_Date: Long)
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
package com.chwl.app.avroom.game
|
||||
|
||||
interface OnGameStatusChangeListener {
|
||||
/**
|
||||
* 游戏开始
|
||||
*/
|
||||
fun onGameStart()
|
||||
|
||||
/**
|
||||
* 游戏结束
|
||||
*/
|
||||
fun onGameEnd()
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
package com.chwl.app.avroom.gameplay
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
||||
|
||||
class GameplayRecyclerView : RecyclerView {
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleAttr
|
||||
)
|
||||
|
||||
override fun onInterceptTouchEvent(e: MotionEvent?): Boolean {
|
||||
parent.requestDisallowInterceptTouchEvent(true)
|
||||
return super.onInterceptTouchEvent(e)
|
||||
}
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
package com.chwl.app.avroom.gameplay
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewConfiguration
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import com.chwl.core.support.room.FrameLayoutRoomWidget
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.databinding.RoomGameplayListWidgetBinding
|
||||
import com.chwl.core.room.bean.RoomIcon
|
||||
|
||||
class RoomGameplayListWidget : FrameLayoutRoomWidget {
|
||||
private val adapter = RoomPlayListAdapter()
|
||||
private val binding: RoomGameplayListWidgetBinding =
|
||||
DataBindingUtil.inflate(
|
||||
LayoutInflater.from(
|
||||
context
|
||||
), R.layout.room_gameplay_list_widget, this, true
|
||||
)
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleAttr
|
||||
)
|
||||
|
||||
constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet?,
|
||||
defStyleAttr: Int,
|
||||
defStyleRes: Int
|
||||
) : super(context, attrs, defStyleAttr, defStyleRes)
|
||||
|
||||
init {
|
||||
binding.recyclerView.adapter = adapter
|
||||
binding.ivSwitch.setOnClickListener {
|
||||
getGameplayIconWidget()?.switchUI(false)
|
||||
}
|
||||
adapter.setOnItemClickListener { adapter, view, position ->
|
||||
(adapter.getItem(position) as? RoomIcon)?.let {
|
||||
getGameplayIconWidget()?.jump(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getGameplayIconWidget(): RoomGameplayWidget? {
|
||||
return roomView?.findWidget(
|
||||
RoomGameplayWidget::class.simpleName ?: ""
|
||||
) as? RoomGameplayWidget
|
||||
}
|
||||
|
||||
fun loadData(list: List<RoomIcon>) {
|
||||
adapter.setNewData(list)
|
||||
if (list.size > 6) {
|
||||
binding.recyclerView.isScrollbarFadingEnabled = false
|
||||
binding.recyclerView.scrollBarFadeDuration = 0
|
||||
} else {
|
||||
binding.recyclerView.isScrollbarFadingEnabled = true
|
||||
binding.recyclerView.scrollBarFadeDuration =
|
||||
ViewConfiguration.getScrollBarFadeDuration()
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,119 @@
|
||||
package com.chwl.app.avroom.gameplay
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.databinding.RoomGameplayWidgetBinding
|
||||
import com.chwl.app.treasure_box.widget.GoldBoxHelper
|
||||
import com.chwl.app.ui.utils.load
|
||||
import com.chwl.app.ui.webview.CommonWebViewActivity
|
||||
import com.chwl.app.ui.webview.room_banner.RoomWebDialogActivity
|
||||
import com.chwl.app.utils.CommonJumpHelper
|
||||
import com.chwl.core.room.bean.RoomIcon
|
||||
import com.chwl.core.room.model.AvRoomModel
|
||||
import com.chwl.core.support.room.FrameLayoutRoomWidget
|
||||
import com.chwl.core.support.room.RoomContext
|
||||
import com.chwl.core.support.room.RoomView
|
||||
import com.example.lib_utils.ktx.singleClick
|
||||
|
||||
|
||||
class RoomGameplayWidget : FrameLayoutRoomWidget {
|
||||
private val binding: RoomGameplayWidgetBinding =
|
||||
DataBindingUtil.inflate(
|
||||
LayoutInflater.from(
|
||||
context
|
||||
), R.layout.room_gameplay_widget, this, true
|
||||
)
|
||||
|
||||
private var isOpened = false
|
||||
|
||||
private var list: List<RoomIcon>? = null
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleAttr
|
||||
)
|
||||
|
||||
constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet?,
|
||||
defStyleAttr: Int,
|
||||
defStyleRes: Int
|
||||
) : super(context, attrs, defStyleAttr, defStyleRes)
|
||||
|
||||
init {
|
||||
binding.ivSwitch.setOnClickListener {
|
||||
switchUI(!isOpened)
|
||||
}
|
||||
binding.ivIcon.singleClick {
|
||||
list?.getOrNull(0)?.let {
|
||||
jump(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onInitialize(roomView: RoomView, roomContext: RoomContext) {
|
||||
super.onInitialize(roomView, roomContext)
|
||||
refreshData()
|
||||
}
|
||||
|
||||
private fun refreshData() {
|
||||
val disposable = AvRoomModel.get().roomGamePlayList
|
||||
.subscribe { list: List<RoomIcon> ->
|
||||
loadData(list)
|
||||
}
|
||||
getCompositeDisposable().add(disposable)
|
||||
}
|
||||
|
||||
fun switchUI(openListWidget: Boolean) {
|
||||
this.isOpened = openListWidget
|
||||
if (openListWidget) {
|
||||
this.visibility = View.INVISIBLE
|
||||
getGameplayListWidget()?.visibility = View.VISIBLE
|
||||
} else {
|
||||
this.visibility = View.VISIBLE
|
||||
getGameplayListWidget()?.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadData(list: List<RoomIcon>) {
|
||||
this.list = list
|
||||
this.isVisible = list.isNotEmpty()
|
||||
val listWidget = getGameplayListWidget()
|
||||
if (list.isEmpty()) {
|
||||
listWidget?.isVisible = false
|
||||
}
|
||||
listWidget?.loadData(list)
|
||||
binding.ivIcon.load(list.firstOrNull()?.icon)
|
||||
}
|
||||
|
||||
fun jump(data: RoomIcon) {
|
||||
if (data.isFindLove()) {
|
||||
GoldBoxHelper.handleBoxClick(context)
|
||||
} else {
|
||||
val url = data.skipContent
|
||||
if (data.skipType == 3 && !url.isNullOrEmpty()) {
|
||||
if (data.showType == 2) {
|
||||
RoomWebDialogActivity.start(context, url, false)
|
||||
} else {
|
||||
CommonWebViewActivity.start(context, url)
|
||||
}
|
||||
} else {
|
||||
CommonJumpHelper.bannerJump(context, data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getGameplayListWidget(): RoomGameplayListWidget? {
|
||||
return roomView?.findWidget(
|
||||
RoomGameplayListWidget::class.simpleName ?: ""
|
||||
) as? RoomGameplayListWidget
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
package com.chwl.app.avroom.gameplay
|
||||
|
||||
import android.widget.ImageView
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.ui.utils.load
|
||||
import com.chwl.core.room.bean.RoomIcon
|
||||
|
||||
|
||||
class RoomPlayListAdapter :
|
||||
BaseQuickAdapter<RoomIcon, BaseViewHolder>(R.layout.room_gameplay_item) {
|
||||
override fun convert(helper: BaseViewHolder, item: RoomIcon?) {
|
||||
helper.getView<ImageView>(R.id.iv_icon).load(item?.icon)
|
||||
}
|
||||
}
|
@@ -0,0 +1,113 @@
|
||||
package com.chwl.app.avroom.headline
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.databinding.RoomHeadlineWidgetBinding
|
||||
import com.chwl.app.public_chat.core.ChatRoomClient
|
||||
import com.chwl.app.public_chat.core.ChatRoomClientManager
|
||||
import com.chwl.app.ui.utils.loadAvatar
|
||||
import com.chwl.core.im.custom.bean.CustomAttachment
|
||||
import com.chwl.core.im.custom.bean.HeadlineChangedAttachment
|
||||
import com.chwl.core.public_chat_hall.bean.HeadlineBean
|
||||
import com.chwl.core.public_chat_hall.model.PublicChatModel
|
||||
import com.chwl.core.support.room.FrameLayoutRoomWidget
|
||||
import com.chwl.core.support.room.RoomView
|
||||
import com.example.lib_utils.AppUtils
|
||||
import com.example.lib_utils.UiUtils
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage
|
||||
import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum
|
||||
|
||||
class RoomHeadlineWidget : FrameLayoutRoomWidget {
|
||||
|
||||
private val binding: RoomHeadlineWidgetBinding =
|
||||
DataBindingUtil.inflate(
|
||||
LayoutInflater.from(
|
||||
context
|
||||
), R.layout.room_headline_widget, this, true
|
||||
)
|
||||
|
||||
private var chatRoomClient: ChatRoomClient? = null
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleAttr
|
||||
)
|
||||
|
||||
constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet?,
|
||||
defStyleAttr: Int,
|
||||
defStyleRes: Int
|
||||
) : super(context, attrs, defStyleAttr, defStyleRes)
|
||||
|
||||
init {
|
||||
if (UiUtils.isRtl(AppUtils.getApp())) {
|
||||
binding.tvHeadlineContent.gravity = Gravity.RIGHT
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStart(roomView: RoomView) {
|
||||
super.onStart(roomView)
|
||||
if (!isInEditMode) {
|
||||
updateHeadline(null)
|
||||
}
|
||||
chatRoomClient = ChatRoomClientManager.getPublicChatClient()
|
||||
chatRoomClient?.let {
|
||||
initChatRoom(it)
|
||||
}
|
||||
requestCurrentHeadline()
|
||||
}
|
||||
|
||||
private fun onReceiveMessage(message: ChatRoomMessage) {
|
||||
if (message.msgType == MsgTypeEnum.custom) {
|
||||
val attachment: CustomAttachment = (message.attachment as? CustomAttachment) ?: return
|
||||
when (attachment.first) {
|
||||
CustomAttachment.CUSTOM_MSG_HEADLINE_CHANGED -> {
|
||||
when (attachment.second) {
|
||||
CustomAttachment.CUSTOM_MSG_HEADLINE_CHANGED_SUB -> {
|
||||
val data = (attachment as? HeadlineChangedAttachment) ?: return
|
||||
updateHeadline(data.headlineData)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun initChatRoom(chatRoomClient: ChatRoomClient) {
|
||||
// 登录流程:在PublicChatRoomMessageWidget中已经执行了
|
||||
getCompositeDisposable().add(chatRoomClient.messageObservable.subscribe {
|
||||
it.forEach { message ->
|
||||
onReceiveMessage(message)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun requestCurrentHeadline() {
|
||||
safeLaunch {
|
||||
val data = PublicChatModel.getCurrentHeadline()
|
||||
updateHeadline(data)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateHeadline(data: HeadlineBean?) {
|
||||
binding.tvHeadlineContent.text = data?.content ?: ""
|
||||
binding.ivAvatar.loadAvatar(data?.avatar)
|
||||
binding.tvName.text = "${data?.nick ?: ""} :"
|
||||
binding.tvMoney.text = data?.payMoneyNum?.toString() ?: "0"
|
||||
this.isVisible = data?.isValid() == true && !data.content.isNullOrEmpty()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
chatRoomClient = null
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
package com.chwl.app.avroom.online
|
||||
|
||||
import android.widget.ImageView
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.chad.library.adapter.base.diff.BaseQuickDiffCallback
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.ui.utils.loadAvatar
|
||||
|
||||
class RoomOnlineAvatarAdapter :
|
||||
BaseQuickAdapter<Pair<String, String?>, BaseViewHolder>(R.layout.room_online_widget_item_avatar) {
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: Pair<String, String?>?) {
|
||||
val avatarView = helper.getView<ImageView>(R.id.iv_avatar)
|
||||
avatarView.loadAvatar(item?.second)
|
||||
}
|
||||
|
||||
fun updateData(list: List<Pair<String, String?>>?) {
|
||||
val newList = ArrayList<Pair<String, String?>>()
|
||||
if (list != null) {
|
||||
newList.addAll(list)
|
||||
}
|
||||
setNewDiffData(object : BaseQuickDiffCallback<Pair<String, String?>>(newList) {
|
||||
override fun areItemsTheSame(
|
||||
oldItem: Pair<String, String?>,
|
||||
newItem: Pair<String, String?>
|
||||
): Boolean {
|
||||
return newItem.first == oldItem.first
|
||||
}
|
||||
|
||||
override fun areContentsTheSame(
|
||||
oldItem: Pair<String, String?>,
|
||||
newItem: Pair<String, String?>
|
||||
): Boolean {
|
||||
return newItem.second == oldItem.second
|
||||
}
|
||||
}, true)
|
||||
}
|
||||
}
|
220
app/src/main/java/com/chwl/app/avroom/online/RoomOnlineWidget.kt
Normal file
220
app/src/main/java/com/chwl/app/avroom/online/RoomOnlineWidget.kt
Normal file
@@ -0,0 +1,220 @@
|
||||
package com.chwl.app.avroom.online
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Outline
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewOutlineProvider
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.activity.RoomOnlineUserActivity
|
||||
import com.chwl.app.databinding.RoomOnlineWidgetBinding
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil
|
||||
import com.chwl.app.ui.widget.recyclerview.decoration.VerticalDecoration
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
import com.chwl.core.manager.IMNetEaseManager
|
||||
import com.chwl.core.manager.RoomEvent
|
||||
import com.chwl.core.room.core.RoomDataService
|
||||
import com.chwl.core.room.model.AvRoomModel
|
||||
import com.chwl.core.support.room.FrameLayoutRoomWidget
|
||||
import com.chwl.core.support.room.RoomContext
|
||||
import com.chwl.core.support.room.RoomView
|
||||
import com.chwl.core.support.room.RoomWidget
|
||||
import com.example.lib_utils.UiUtils
|
||||
import com.example.lib_utils.ktx.singleClick
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessageExtension
|
||||
import io.reactivex.Observable
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class RoomOnlineWidget : FrameLayoutRoomWidget, RoomWidget {
|
||||
|
||||
companion object {
|
||||
const val MAX_DISPLAY_COUNT = 3
|
||||
private const val ONLINE_DISPLAY_LIST = "online_display_list"
|
||||
private const val ONLINE_NUMBER = "online_number"
|
||||
}
|
||||
|
||||
private val binding: RoomOnlineWidgetBinding =
|
||||
DataBindingUtil.inflate(
|
||||
LayoutInflater.from(
|
||||
context
|
||||
), R.layout.room_online_widget, this, true
|
||||
)
|
||||
|
||||
private val adapter = RoomOnlineAvatarAdapter()
|
||||
|
||||
private var dataList: MutableList<Pair<String, String?>>? = null
|
||||
|
||||
private val dataService: RoomDataService?
|
||||
get() = roomContext?.findAbility<RoomDataService>(
|
||||
RoomDataService::class.java.simpleName
|
||||
)
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleAttr
|
||||
)
|
||||
|
||||
constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet?,
|
||||
defStyleAttr: Int,
|
||||
defStyleRes: Int
|
||||
) : super(context, attrs, defStyleAttr, defStyleRes)
|
||||
|
||||
init {
|
||||
if (!isInEditMode) {
|
||||
this.singleClick {
|
||||
RoomOnlineUserActivity.start(context)
|
||||
}
|
||||
adapter.setOnItemClickListener { adapter, view, position ->
|
||||
RoomOnlineUserActivity.start(context)
|
||||
}
|
||||
binding.recyclerView.adapter = adapter
|
||||
binding.recyclerView.addItemDecoration(
|
||||
VerticalDecoration(
|
||||
UIUtil.dip2px(context, 4.5),
|
||||
false,
|
||||
false
|
||||
)
|
||||
)
|
||||
val isRTL = UiUtils.isRtl(context)
|
||||
binding.recyclerView.outlineProvider = object : ViewOutlineProvider() {
|
||||
override fun getOutline(view: View?, outline: Outline?) {
|
||||
if (isRTL) {
|
||||
outline?.setRect(
|
||||
UiUtils.dip2px(9f),
|
||||
0,
|
||||
(view?.width ?: 0),
|
||||
(view?.height ?: 0),
|
||||
)
|
||||
} else {
|
||||
outline?.setRect(
|
||||
0,
|
||||
0,
|
||||
(view?.width ?: 0) - UiUtils.dip2px(9f),
|
||||
(view?.height ?: 0),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
binding.recyclerView.clipToOutline = true
|
||||
}
|
||||
}
|
||||
|
||||
override fun onInitialize(roomView: RoomView, roomContext: RoomContext) {
|
||||
super.onInitialize(roomView, roomContext)
|
||||
(dataService?.getData(ONLINE_NUMBER) as? Int)?.let {
|
||||
updateCount(it)
|
||||
}
|
||||
(dataService?.getData(ONLINE_DISPLAY_LIST) as? MutableList<Pair<String, String?>>)?.let {
|
||||
updateList(it)
|
||||
}
|
||||
startUpdateOnlineTask()
|
||||
registerMemberChangedListener()
|
||||
}
|
||||
|
||||
override fun onUnbindContext() {
|
||||
super.onUnbindContext()
|
||||
updateList(null)
|
||||
updateCount(0)
|
||||
}
|
||||
|
||||
private fun refreshData() {
|
||||
val disposable = AvRoomModel.get()
|
||||
.getRoomOnlineList(AvRoomDataManager.get().roomUid)
|
||||
.subscribe({
|
||||
updateList(it.take(MAX_DISPLAY_COUNT).map {
|
||||
Pair<String, String?>(it.uid.toString(), it.avatar)
|
||||
}.toMutableList())
|
||||
updateCount(it.size)
|
||||
}, {
|
||||
it.printStackTrace()
|
||||
})
|
||||
getCompositeDisposable().add(disposable)
|
||||
}
|
||||
|
||||
private fun updateCount(count: Int) {
|
||||
dataService?.putData(ONLINE_NUMBER, count)
|
||||
binding.tvNumber.text = count.toString()
|
||||
}
|
||||
|
||||
private fun updateList(list: MutableList<Pair<String, String?>>?) {
|
||||
dataService?.putData(ONLINE_DISPLAY_LIST, list)
|
||||
this.dataList = list
|
||||
adapter.updateData(list)
|
||||
}
|
||||
|
||||
private fun startUpdateOnlineTask() {
|
||||
getCompositeDisposable().add(Observable.interval(
|
||||
0, 30, TimeUnit.SECONDS
|
||||
).subscribe {
|
||||
refreshData()
|
||||
})
|
||||
}
|
||||
|
||||
private fun registerMemberChangedListener() {
|
||||
getCompositeDisposable().add(IMNetEaseManager.get().chatRoomEventObservable.subscribe {
|
||||
when (it.event) {
|
||||
RoomEvent.ROOM_MEMBER_IN -> {
|
||||
updateOnlineCount(1)
|
||||
toItem(it.account, it.chatRoomMessage)?.let {
|
||||
tryUpdateList(it, true)
|
||||
}
|
||||
}
|
||||
|
||||
RoomEvent.ROOM_MEMBER_EXIT -> {
|
||||
updateOnlineCount(-1)
|
||||
toItem(it.account, it.chatRoomMessage)?.let {
|
||||
tryUpdateList(it, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun toItem(account: String?, message: ChatRoomMessage?): Pair<String, String?>? {
|
||||
if (account == null) {
|
||||
return null
|
||||
}
|
||||
if (message == null) {
|
||||
return Pair(account, null)
|
||||
}
|
||||
val messageExtension: ChatRoomMessageExtension = message.chatRoomMessageExtension
|
||||
var avatar = messageExtension.senderAvatar
|
||||
val extensionData = messageExtension.senderExtension.get(account) as? Map<String, Any>
|
||||
avatar = (extensionData?.getOrElse("avatar") {
|
||||
avatar
|
||||
} as? String) ?: avatar
|
||||
return Pair(account, avatar)
|
||||
}
|
||||
|
||||
private fun tryUpdateList(item: Pair<String, String?>, enterOrExit: Boolean) {
|
||||
val index = dataList?.indexOfFirst {
|
||||
it.first == item.first
|
||||
} ?: -1
|
||||
if (enterOrExit) {
|
||||
if (index < 0 && (dataList?.size ?: 0) < MAX_DISPLAY_COUNT) {
|
||||
dataList?.add(item)
|
||||
updateList(dataList)
|
||||
}
|
||||
} else {
|
||||
if (index >= 0) {
|
||||
dataList?.removeAt(index)
|
||||
updateList(dataList)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateOnlineCount(addCount: Int) {
|
||||
val number = binding.tvNumber.text.toString().toIntOrNull()
|
||||
if (number != null) {
|
||||
binding.tvNumber.text = (number + addCount).toString()
|
||||
}
|
||||
}
|
||||
}
|
@@ -9,6 +9,8 @@ import android.util.SparseArray;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.chwl.core.manager.RoomMicQueueModel;
|
||||
import com.chwl.core.support.room.AudioRoomContext;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
@@ -20,8 +22,6 @@ import com.netease.nimlib.sdk.chatroom.model.EnterChatRoomResultData;
|
||||
import com.netease.nimlib.sdk.util.Entry;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.avroom.activity.AVRoomActivity;
|
||||
import com.chwl.app.avroom.core.AudioRoomContext;
|
||||
import com.chwl.core.support.room.RoomContext;
|
||||
import com.chwl.app.avroom.view.IAvRoomView;
|
||||
import com.chwl.app.base.BaseMvpPresenter;
|
||||
import com.chwl.core.Constants;
|
||||
@@ -122,11 +122,11 @@ public class AvRoomPresenter extends BaseMvpPresenter<IAvRoomView> {
|
||||
AvRoomDataManager.get().updateServiceRoomInfo(roomInfo);
|
||||
mAvRoomModel.enterRoom(roomInfo.getRoomId(), 3, fromType, fromNick, fromUid)
|
||||
.flatMap(this::dealServerMicInfo)
|
||||
.map(this::dealMicMemberFromIMNet)
|
||||
.flatMap(this::dealMicChatRoomMemberFromIMNet)
|
||||
.flatMap((Function<SparseArray<RoomQueueInfo>, ObservableSource<SparseArray<RoomQueueInfo>>>) roomQueue -> RoomMicQueueModel.INSTANCE.queueMicQueue(roomInfo.getRoomId(),roomQueue))
|
||||
.compose(bindUntilEvent(PresenterEvent.DESTROY))
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(roomQueueInfoSparseArray -> {
|
||||
AvRoomDataManager.get().replaceMicQueue(roomQueueInfoSparseArray);
|
||||
long uid = AuthModel.get().getCurrentUid();
|
||||
AudioEngineManager.get().startRtcEngine(uid, roomInfo.getAudioSdkType());
|
||||
// TODO 临时方案:后续逐步完善整个房间的RoomContext替换计划
|
||||
@@ -155,6 +155,9 @@ public class AvRoomPresenter extends BaseMvpPresenter<IAvRoomView> {
|
||||
AvRoomDataManager.get().roomPkLiveData.setValue(roomPkBean);
|
||||
if (AvRoomDataManager.get().isSingleRoom()){
|
||||
AudioEngineManager.get().setRemoteMute(roomPkBean.getAUid(), roomPkBean.getAMicStatus() == 0);
|
||||
if (AvRoomDataManager.get().isRoomOwner()) {
|
||||
AudioEngineManager.get().connectOtherRoom(String.valueOf(roomPkBean.getARoomId()), roomPkBean.getAUid());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -218,52 +221,12 @@ public class AvRoomPresenter extends BaseMvpPresenter<IAvRoomView> {
|
||||
IMNetEaseManager.get().getChatRoomEventObservable().onNext(new RoomEvent().setEvent(RoomEvent.ROOM_EXIT));
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理网易云信队列上人员的信息
|
||||
*/
|
||||
private Observable<SparseArray<RoomQueueInfo>> dealMicChatRoomMemberFromIMNet(List<String> accounts) {
|
||||
if (ListUtils.isListEmpty(accounts))
|
||||
return Observable.just(AvRoomDataManager.get().mMicQueueMemberMap);
|
||||
return IMNetEaseManager.get().fetchRoomMembersByIds(accounts).observeOn(AndroidSchedulers.mainThread())
|
||||
.flatMap(chatRoomMembers -> {
|
||||
for (ChatRoomMember chatRoomMember : chatRoomMembers) {
|
||||
AvRoomDataManager.get().updateQueueChatRoomMemberExtension(chatRoomMember);
|
||||
}
|
||||
return Single.just(AvRoomDataManager.get().mMicQueueMemberMap);
|
||||
}).toObservable();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理网易云信坑位信息
|
||||
*/
|
||||
private List<String> dealMicMemberFromIMNet(List<Entry<String, String>> entries) {
|
||||
List<String> accounts = new ArrayList<>();
|
||||
if (!ListUtils.isListEmpty(entries)) {
|
||||
JsonParser jsonParser = new JsonParser();
|
||||
MicMemberInfo chatRoomMember;
|
||||
for (Entry<String, String> entry : entries) {
|
||||
RoomQueueInfo roomQueueInfo = AvRoomDataManager.get().mMicQueueMemberMap.get(Integer.parseInt(entry.key));
|
||||
if (roomQueueInfo != null) {
|
||||
JsonObject valueJsonObj = jsonParser.parse(entry.value).getAsJsonObject();
|
||||
if (valueJsonObj != null) {
|
||||
chatRoomMember = mGson.fromJson(valueJsonObj, MicMemberInfo.class);
|
||||
accounts.add(chatRoomMember.getAccount());
|
||||
roomQueueInfo.mChatRoomMember = chatRoomMember;
|
||||
}
|
||||
AvRoomDataManager.get().mMicQueueMemberMap.put(Integer.valueOf(entry.key), roomQueueInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
return accounts;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理服务端坑位信息
|
||||
*/
|
||||
@Nullable
|
||||
private ObservableSource<List<Entry<String, String>>> dealServerMicInfo(EnterChatRoomResultData enterChatRoomResultData) {
|
||||
private ObservableSource<SparseArray<RoomQueueInfo>> dealServerMicInfo(EnterChatRoomResultData enterChatRoomResultData) {
|
||||
AvRoomDataManager.get().mEnterChatRoomResultData = enterChatRoomResultData;
|
||||
if (enterChatRoomResultData == null)
|
||||
return Observable.error(new Throwable(GET_ROOM_FROM_IMNET_ERROR));
|
||||
@@ -293,11 +256,12 @@ public class AvRoomPresenter extends BaseMvpPresenter<IAvRoomView> {
|
||||
//初始化所有坑位
|
||||
Map<String, String> micMapStr = mGson.fromJson(roomMicStr, new TypeToken<Map<String, String>>() {
|
||||
}.getType());
|
||||
SparseArray<RoomQueueInfo> queue = new SparseArray<>();
|
||||
for (Map.Entry<String, String> entry : micMapStr.entrySet()) {
|
||||
AvRoomDataManager.get().mMicQueueMemberMap.put(Integer.valueOf(entry.getKey()),
|
||||
queue.put(Integer.valueOf(entry.getKey()),
|
||||
new RoomQueueInfo(mGson.fromJson(entry.getValue(), RoomMicInfo.class), null));
|
||||
}
|
||||
return mAvRoomModel.queryRoomMicInfo(roomInfo.getRoomId());
|
||||
return Observable.just(queue);
|
||||
}
|
||||
}
|
||||
return Observable.error(new Throwable(GET_ROOM_FROM_IMNET_ERROR));
|
||||
|
@@ -6,6 +6,9 @@ import android.util.Log;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.chwl.app.public_chat.core.ChatRoomClient;
|
||||
import com.chwl.app.public_chat.core.ChatRoomClientManager;
|
||||
import com.chwl.core.initial.InitialModel;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
@@ -26,7 +29,6 @@ import com.chwl.core.im.custom.bean.RoomInfoAttachment;
|
||||
import com.chwl.core.manager.AvRoomDataManager;
|
||||
import com.chwl.core.manager.IMNetEaseManager;
|
||||
import com.chwl.core.praise.PraiseModel;
|
||||
import com.chwl.core.room.bean.RoomContributeDataInfo;
|
||||
import com.chwl.core.room.bean.RoomInfo;
|
||||
import com.chwl.core.room.exception.AntiSpamHitException;
|
||||
import com.chwl.core.room.game.GameStatus;
|
||||
@@ -34,7 +36,6 @@ import com.chwl.core.room.giftvalue.helper.GiftValueMrg;
|
||||
import com.chwl.core.room.model.AvRoomModel;
|
||||
import com.chwl.core.room.model.HomePartyModel;
|
||||
import com.chwl.core.room.model.RoomBaseModel;
|
||||
import com.chwl.core.room.model.RoomContributeListModel;
|
||||
import com.chwl.core.room.queue.bean.MicMemberInfo;
|
||||
import com.chwl.core.super_admin.model.SuperAdminModel;
|
||||
import com.chwl.core.super_admin.util.SuperAdminUtil;
|
||||
@@ -52,7 +53,6 @@ import com.chwl.library.utils.SingleToastUtil;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.functions.BiConsumer;
|
||||
@@ -562,4 +562,24 @@ public class BaseRoomPresenter<V extends IBaseRoomView> extends BaseMvpPresenter
|
||||
.subscribe();
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
public void sendPublicChatTextMessage(String message) {
|
||||
if (TextUtils.isEmpty(message)) return;
|
||||
ChatRoomClient client = ChatRoomClientManager.INSTANCE.getPublicChatClient();
|
||||
if (client == null) {
|
||||
SingleToastUtil.showToast(R.string.public_chat_not_found);
|
||||
return;
|
||||
}
|
||||
ChatRoomMessage textMessage = ChatRoomMessageBuilder.createChatRoomTextMessage(client.getSessionId(), message);
|
||||
client.sendMessage(textMessage).compose(bindToLifecycle()).subscribe(new BiConsumer<Object, Throwable>() {
|
||||
@Override
|
||||
public void accept(Object o, Throwable throwable) throws Exception {
|
||||
if (throwable != null) {
|
||||
SingleToastUtil.showToast(throwable.getMessage());
|
||||
} else {
|
||||
getMvpView().onSendPublicChatMsgSuccess(textMessage);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -2,15 +2,9 @@ package com.chwl.app.avroom.presenter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
|
||||
import com.orhanobut.logger.Logger;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.avroom.view.IHomePartyUserListView;
|
||||
import com.chwl.app.base.BaseMvpPresenter;
|
||||
import com.chwl.core.room.bean.OnlineChatMember;
|
||||
import com.chwl.core.room.model.HomePartyUserListModel;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
|
||||
import java.util.List;
|
||||
import com.chwl.core.room.model.AvRoomModel;
|
||||
|
||||
/**
|
||||
* <p> </p>
|
||||
@@ -20,55 +14,20 @@ import java.util.List;
|
||||
*/
|
||||
public class HomePartyUserListPresenter extends BaseMvpPresenter<IHomePartyUserListView> {
|
||||
|
||||
private final HomePartyUserListModel mHomePartyUserListMode;
|
||||
|
||||
public HomePartyUserListPresenter() {
|
||||
mHomePartyUserListMode = new HomePartyUserListModel();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页获取房间成员:第一页包含队列成员,固定成员,游客50人,之后每一页获取游客50人
|
||||
*
|
||||
* @param page 页数
|
||||
* @param time 固定成员列表用updateTime,
|
||||
* 游客列表用进入enterTime,
|
||||
* 填0会使用当前服务器最新时间开始查询,即第一页,单位毫秒
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
public void requestChatMemberByPage(final int page, long time, List<OnlineChatMember> oldList) {
|
||||
mHomePartyUserListMode.getOnLinePageMembers(page, time, oldList)
|
||||
.subscribe(onlineChatMembers -> {
|
||||
Logger.i(ResUtil.getString(R.string.avroom_presenter_homepartyuserlistpresenter_01), page, onlineChatMembers.size());
|
||||
if (getMvpView() != null) {
|
||||
getMvpView().onRequestChatMemberByPageSuccess(onlineChatMembers, page);
|
||||
}
|
||||
}, throwable -> {
|
||||
throwable.printStackTrace();
|
||||
Logger.i(ResUtil.getString(R.string.avroom_presenter_homepartyuserlistpresenter_02), page, throwable.getMessage());
|
||||
if (getMvpView() != null) {
|
||||
getMvpView().onRequestChatMemberByPageFail(throwable.getMessage(), page);
|
||||
}
|
||||
});
|
||||
public void requestRoomOnlineList(long roomUid){
|
||||
AvRoomModel.get().getRoomOnlineList(roomUid).compose(bindToLifecycle()).subscribe((data, throwable) -> {
|
||||
if (getMvpView() != null) {
|
||||
if (data != null) {
|
||||
getMvpView().onRequestRoomOnlineListSuccess(data);
|
||||
} else {
|
||||
getMvpView().onRequestChatMemberByPageFail(throwable.getMessage(), 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onMemberDownUpMic(String account, boolean isUpMic, List<OnlineChatMember> dataList,
|
||||
final int page) {
|
||||
mHomePartyUserListMode.onMemberDownUpMic(account, isUpMic, dataList)
|
||||
.subscribe(onlineChatMembers -> {
|
||||
if (getMvpView() != null)
|
||||
getMvpView().onRequestChatMemberByPageSuccess(onlineChatMembers, page);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void onUpdateMemberManager(String account, List<OnlineChatMember> dataList,
|
||||
boolean isRemoveManager, final int page) {
|
||||
mHomePartyUserListMode.onUpdateMemberManager(account, isRemoveManager, dataList)
|
||||
.subscribe(onlineChatMembers -> {
|
||||
if (getMvpView() != null)
|
||||
getMvpView().onRequestChatMemberByPageSuccess(onlineChatMembers, page);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,884 @@
|
||||
package com.chwl.app.avroom.public_chat;
|
||||
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.Spannable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.text.style.ImageSpan;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.content.res.ResourcesCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.SimpleItemAnimator;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.UIHelper;
|
||||
import com.chwl.app.avroom.activity.AVRoomActivity;
|
||||
import com.chwl.app.avroom.dialog.RoomTeamPKResultDialog;
|
||||
import com.chwl.app.avroom.widget.OnMsgLongClickListener;
|
||||
import com.chwl.app.avroom.widget.TemplateMessageAdapter;
|
||||
import com.chwl.app.common.widget.CustomImageSpan;
|
||||
import com.chwl.app.common.widget.OriginalDrawStatusClickSpan;
|
||||
import com.chwl.app.photo.BigPhotoActivity;
|
||||
import com.chwl.app.photo.PagerOption;
|
||||
import com.chwl.app.public_chat.core.viewholder.ChatRoomMessageViewHolderThumbBase;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtilsV2;
|
||||
import com.chwl.app.ui.widget.DividerItemDecoration;
|
||||
import com.chwl.app.ui.widget.MyItemAnimator;
|
||||
import com.chwl.app.ui.widget.RecyclerViewNoViewpagerScroll;
|
||||
import com.chwl.app.ui.widget.TextSpannableBuilder;
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.chwl.app.utils.ObjectTypeHelper;
|
||||
import com.chwl.app.utils.RegexUtil;
|
||||
import com.chwl.core.DemoCache;
|
||||
import com.chwl.core.auth.AuthModel;
|
||||
import com.chwl.core.bean.attachmsg.RoomQueueMsgAttachment;
|
||||
import com.chwl.core.decoration.car.bean.CarInfo;
|
||||
import com.chwl.core.home.event.FollowRoomEvent;
|
||||
import com.chwl.core.home.model.CollectionRoomModel;
|
||||
import com.chwl.core.im.custom.bean.CustomAttachment;
|
||||
import com.chwl.core.im.custom.bean.HeadlineChangedAttachment;
|
||||
import com.chwl.core.im.custom.bean.MonsterHuntingResultAttachment;
|
||||
import com.chwl.core.im.custom.bean.MonsterStatusAttachment;
|
||||
import com.chwl.core.im.custom.bean.RoomBoxPrizeAttachment;
|
||||
import com.chwl.core.im.custom.bean.RoomFollowOwnerAttachment2;
|
||||
import com.chwl.core.im.custom.bean.RoomTipAttachment;
|
||||
import com.chwl.core.im.custom.bean.TarotAttachment;
|
||||
import com.chwl.core.level.UserLevelResourceType;
|
||||
import com.chwl.core.manager.AvRoomDataManager;
|
||||
import com.chwl.core.monsterhunting.bean.MonsterDataBean;
|
||||
import com.chwl.core.monsterhunting.bean.MonsterHuntingResult;
|
||||
import com.chwl.core.noble.NobleUtil;
|
||||
import com.chwl.core.praise.PraiseModel;
|
||||
import com.chwl.core.public_chat_hall.bean.HeadlineBean;
|
||||
import com.chwl.core.room.bean.RoomInfo;
|
||||
import com.chwl.core.room.pk.attachment.RoomPkAttachment;
|
||||
import com.chwl.core.user.bean.UserInfo;
|
||||
import com.chwl.core.utils.ExtensionUtil;
|
||||
import com.chwl.library.common.util.Utils;
|
||||
import com.chwl.library.utils.JavaUtil;
|
||||
import com.chwl.library.utils.ListUtils;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
import com.chwl.library.utils.SizeUtils;
|
||||
import com.example.lib_utils.UiUtils;
|
||||
import com.example.lib_utils.spannable.SpannableTextBuilder;
|
||||
import com.netease.nim.uikit.business.session.emoji.MoonUtil;
|
||||
import com.netease.nim.uikit.common.util.media.ImageUtil;
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessageExtension;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomNotificationAttachment;
|
||||
import com.netease.nimlib.sdk.msg.attachment.ImageAttachment;
|
||||
import com.netease.nimlib.sdk.msg.attachment.MsgAttachment;
|
||||
import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum;
|
||||
import com.netease.nimlib.sdk.msg.constant.NotificationType;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
|
||||
/**
|
||||
* 直播間消息界面
|
||||
*
|
||||
* @author xiaoyu
|
||||
*/
|
||||
public class PublicChatMessageView extends FrameLayout {
|
||||
|
||||
private static final String TAG = "PublicChatMessageView";
|
||||
private final static int MAX_MESSAGE_SIZE = 100;//公屏最多展示條數
|
||||
private final static int BLOCK_MAX_MESSAGE_SIZE = MAX_MESSAGE_SIZE * 3 / 2;//在查看消息停住的時候 最多消息條數.
|
||||
private final List<ChatRoomMessage> atMessages = new ArrayList<>();
|
||||
private final List<ChatRoomMessage> chatRoomMessages = new LinkedList<>();
|
||||
private RecyclerView messageListView;
|
||||
private TextView tvBottomTip;
|
||||
private TextView tvAtTip;
|
||||
private MessageAdapter mMessageAdapter;
|
||||
private LinearLayoutManager layoutManger;
|
||||
private int paddingWidth;
|
||||
private int paddingHeight;
|
||||
private int whiteColor;
|
||||
private int greyColor;
|
||||
private int roomTipColor;
|
||||
private int badgeWidth;
|
||||
private int badgeHeight;
|
||||
private int expLevelHeight;
|
||||
private int defTextSize = 12;
|
||||
private volatile boolean needAutoScroll = true;//是否自動滾動到底部
|
||||
private Consumer<String> clickConsumer;
|
||||
private OnClick onClick;
|
||||
|
||||
private OnMsgLongClickListener onLongClickListener;
|
||||
private TemplateMessageAdapter templateMessageAdapter;
|
||||
|
||||
public PublicChatMessageView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public PublicChatMessageView(Context context, AttributeSet attr) {
|
||||
this(context, attr, 0);
|
||||
}
|
||||
|
||||
public PublicChatMessageView(Context context, AttributeSet attr, int i) {
|
||||
super(context, attr, i);
|
||||
init(context);
|
||||
}
|
||||
|
||||
public void setOnLongClickListener(OnMsgLongClickListener onLongClickListener) {
|
||||
this.onLongClickListener = onLongClickListener;
|
||||
}
|
||||
|
||||
public void setClickConsumer(Consumer<String> clickConsumer) {
|
||||
this.clickConsumer = clickConsumer;
|
||||
}
|
||||
|
||||
public void setOnClick(OnClick onClick) {
|
||||
this.onClick = onClick;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
private void init(Context context) {
|
||||
whiteColor = ContextCompat.getColor(context, R.color.white);
|
||||
greyColor = ContextCompat.getColor(context, R.color.white_transparent_50);
|
||||
roomTipColor = ContextCompat.getColor(context, R.color.color_FEE057);
|
||||
paddingWidth = Utils.dip2px(context, 11);
|
||||
paddingHeight = Utils.dip2px(context, 6);
|
||||
badgeWidth = Utils.dip2px(context, 15);
|
||||
badgeHeight = Utils.dip2px(context, 15);
|
||||
//經驗等級圖片後臺已經更換尺寸了,公屏同步下,尺寸是36:18
|
||||
expLevelHeight = Utils.dip2px(context, 18);
|
||||
// 內容區域
|
||||
layoutManger = new LinearLayoutManager(context, RecyclerView.VERTICAL, false);
|
||||
LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
messageListView = new RecyclerViewNoViewpagerScroll(context);
|
||||
messageListView.setLayoutParams(params);
|
||||
messageListView.setFadingEdgeLength(60);
|
||||
messageListView.setVerticalFadingEdgeEnabled(true);
|
||||
messageListView.setOverScrollMode(OVER_SCROLL_NEVER);
|
||||
messageListView.setHorizontalScrollBarEnabled(false);
|
||||
addView(messageListView);
|
||||
messageListView.setLayoutManager(layoutManger);
|
||||
messageListView.addItemDecoration(new DividerItemDecoration(context, layoutManger.getOrientation(), 16, R.color.transparent));
|
||||
mMessageAdapter = new MessageAdapter(getContext());
|
||||
mMessageAdapter.setData(chatRoomMessages);
|
||||
messageListView.setAdapter(mMessageAdapter);
|
||||
messageListView.setItemAnimator(new MyItemAnimator());
|
||||
messageListView.getItemAnimator().setAddDuration(0);
|
||||
messageListView.getItemAnimator().setChangeDuration(0);
|
||||
messageListView.getItemAnimator().setMoveDuration(0);
|
||||
messageListView.getItemAnimator().setRemoveDuration(0);
|
||||
((SimpleItemAnimator) messageListView.getItemAnimator()).setSupportsChangeAnimations(false);
|
||||
|
||||
// 底部有新消息
|
||||
tvBottomTip = new TextView(context);
|
||||
LayoutParams params1 = new LayoutParams(
|
||||
Utils.dip2px(context, 115F), Utils.dip2px(context, 27));
|
||||
params1.gravity = Gravity.BOTTOM;
|
||||
params1.leftMargin = UIUtil.getScreenWidth(context) / 2 - UIUtil.dip2px(context, 115 / 2);
|
||||
tvBottomTip.setBackgroundResource(R.drawable.bg_messge_view_bottom_tip);
|
||||
tvBottomTip.setGravity(Gravity.CENTER);
|
||||
tvBottomTip.setText(context.getString(R.string.message_view_bottom_tip));
|
||||
tvBottomTip.setTextColor(context.getResources().getColor(R.color.appColor));
|
||||
tvBottomTip.setLayoutParams(params1);
|
||||
tvBottomTip.setVisibility(GONE);
|
||||
tvBottomTip.setOnClickListener(v -> {
|
||||
tvBottomTip.setVisibility(GONE);
|
||||
needAutoScroll = true;
|
||||
if (mMessageAdapter.getItemCount() > 0) {
|
||||
messageListView.smoothScrollToPosition(mMessageAdapter.getItemCount() - 1);
|
||||
}
|
||||
});
|
||||
addView(tvBottomTip);
|
||||
|
||||
//有人@我
|
||||
tvAtTip = new TextView(context);
|
||||
LayoutParams params2 = new LayoutParams(
|
||||
Utils.dip2px(context, 115F), Utils.dip2px(context, 27));
|
||||
params2.gravity = Gravity.BOTTOM;
|
||||
params2.leftMargin = UIUtil.getScreenWidth(context) / 2 - UIUtil.dip2px(context, 115 / 2);
|
||||
tvAtTip.setBackgroundResource(R.drawable.bg_messge_view_bottom_tip);
|
||||
tvAtTip.setGravity(Gravity.CENTER);
|
||||
tvAtTip.setText(context.getString(R.string.message_view_bottom_tip));
|
||||
tvAtTip.setTextColor(context.getResources().getColor(R.color.color_FD85C9));
|
||||
tvAtTip.setLayoutParams(params2);
|
||||
tvAtTip.setVisibility(GONE);
|
||||
tvAtTip.setOnClickListener(v -> {
|
||||
if (!atMessages.isEmpty()) {
|
||||
int scrollIndex = chatRoomMessages.indexOf(atMessages.remove(0));
|
||||
if (scrollIndex != -1 && scrollIndex < mMessageAdapter.getItemCount()) {
|
||||
messageListView.smoothScrollToPosition(scrollIndex);
|
||||
}
|
||||
}
|
||||
needAutoScroll = false;
|
||||
checkShowAtTip();
|
||||
});
|
||||
addView(tvAtTip);
|
||||
|
||||
messageListView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScrollStateChanged(final RecyclerView recyclerView, int newState) {
|
||||
super.onScrollStateChanged(recyclerView, newState);
|
||||
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
|
||||
// Logger.e(TAG, "onScrollStateChanged: SCROLL_STATE_DRAGGING");
|
||||
needAutoScroll = false;
|
||||
}
|
||||
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
|
||||
// Logger.e(TAG, "onScrollStateChanged: SCROLL_STATE_IDLE");
|
||||
|
||||
int lastVisibleItemPosition = layoutManger.findLastVisibleItemPosition();
|
||||
|
||||
if (lastVisibleItemPosition == RecyclerView.NO_POSITION) {
|
||||
// Logger.e(TAG, "lastCompletelyVisibleItemPosition : RecyclerView.NO_POSITION");
|
||||
needAutoScroll = true;
|
||||
} else if (!atMessages.isEmpty() && atMessages.remove(chatRoomMessages.get(lastVisibleItemPosition))) {
|
||||
checkShowAtTip();
|
||||
}
|
||||
// Log.e(TAG, "lastVisibleItemPosition:" + lastVisibleItemPosition
|
||||
// + " mMessageAdapter.getItemCount()-1:" + (recyclerView.getAdapter().getItemCount()-1)
|
||||
// + " dis:"+ (lastVisibleItemPosition-(recyclerView.getAdapter().getItemCount()-1)));
|
||||
if (lastVisibleItemPosition >= recyclerView.getAdapter().getItemCount() - 3) {
|
||||
//最後一個顯示出來了
|
||||
// Logger.e(TAG, ResUtil.getString(R.string.avroom_widget_messageview_01));
|
||||
needAutoScroll = true;
|
||||
tvBottomTip.setVisibility(GONE);
|
||||
keepSizeUnderLimit();
|
||||
} else {
|
||||
// Logger.e(TAG, ResUtil.getString(R.string.avroom_widget_messageview_02));
|
||||
// needAutoScroll = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private TemplateMessageAdapter getTemplateMessageAdapter() {
|
||||
if (templateMessageAdapter == null) {
|
||||
templateMessageAdapter = new TemplateMessageAdapter(uid -> {
|
||||
if (clickConsumer != null) {
|
||||
Single.just(String.valueOf(uid)).subscribe(clickConsumer);
|
||||
}
|
||||
});
|
||||
}
|
||||
return templateMessageAdapter;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加公屏消息請使用 {@link AvRoomDataManager#addChatRoomMessage(ChatRoomMessage)}
|
||||
*/
|
||||
public void addMessages(ChatRoomMessage msg) {
|
||||
if (msg == null) return;
|
||||
chatRoomMessages.add(msg);
|
||||
//通知adapter 刷新
|
||||
mMessageAdapter.notifyItemInserted(mMessageAdapter.getItemCount() - 1);
|
||||
showTipsOrScrollToBottom();
|
||||
checkAtMe(msg, false);
|
||||
}
|
||||
|
||||
public void addMessages(List<ChatRoomMessage> messages) {
|
||||
if (messages == null) return;
|
||||
chatRoomMessages.addAll(messages);
|
||||
//通知adapter 刷新
|
||||
mMessageAdapter.notifyDataSetChanged();
|
||||
showTipsOrScrollToBottom();
|
||||
for (ChatRoomMessage message : messages) {
|
||||
checkAtMe(message, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void addHistoryMessages(List<ChatRoomMessage> messages) {
|
||||
chatRoomMessages.addAll(0, messages);
|
||||
mMessageAdapter.notifyDataSetChanged();
|
||||
messageListView.scrollToPosition(mMessageAdapter.getItemCount() - 1);
|
||||
for (ChatRoomMessage message : messages) {
|
||||
checkAtMe(message, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void keepSizeUnderLimit() {
|
||||
while (chatRoomMessages.size() > MAX_MESSAGE_SIZE) {
|
||||
Log.i("keepSizeUnderLimit", "size" + chatRoomMessages.size());
|
||||
ChatRoomMessage message = chatRoomMessages.remove(0);
|
||||
if (atMessages.remove(message)) {
|
||||
checkShowAtTip();
|
||||
}
|
||||
mMessageAdapter.notifyItemRemoved(0);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkShowAtTip() {
|
||||
tvAtTip.setText(getContext().getString(R.string.message_at_tip, atMessages.size()));
|
||||
tvAtTip.setVisibility(atMessages.size() == 0 ? GONE : VISIBLE);
|
||||
}
|
||||
|
||||
private void checkAtMe(ChatRoomMessage msg, boolean history) {
|
||||
if (msg.getMsgType() != MsgTypeEnum.text) return;
|
||||
List<String> atUids = ExtensionUtil.getListExtension(msg, UserInfo.AT_UIDS);
|
||||
List<String> atNames = ExtensionUtil.getListExtension(msg, UserInfo.AT_NAMES);
|
||||
if (!ListUtils.isListEmpty(atUids) && !ListUtils.isListEmpty(atNames)) {
|
||||
for (int i = 0; i < atUids.size(); i++) {
|
||||
String uid = atUids.get(i);
|
||||
// 只有當被 @ 人的數組中包含自己的時候才會去變色
|
||||
if (Objects.equals(uid, String.valueOf(AuthModel.get().getCurrentUid()))) {
|
||||
Map<String, Long> atMap = DemoCache.readAtMsgUuid();
|
||||
if (atMap == null || !atMap.containsKey(msg.getUuid())) {
|
||||
if (!atMessages.contains(msg) && (!needAutoScroll || history)) {
|
||||
atMessages.add(msg);
|
||||
checkShowAtTip();
|
||||
}
|
||||
DemoCache.saveAtMsgUuid(msg.getUuid());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void showTipsOrScrollToBottom() {
|
||||
if (!needAutoScroll) {
|
||||
tvBottomTip.setVisibility(VISIBLE);
|
||||
//超過某值後自動滾動下去
|
||||
if (mMessageAdapter.getItemCount() > BLOCK_MAX_MESSAGE_SIZE) {
|
||||
if (mMessageAdapter.getItemCount() > 0) {
|
||||
messageListView.smoothScrollToPosition(mMessageAdapter.getItemCount() - 1);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void release() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void clear() {
|
||||
if (mMessageAdapter != null) {
|
||||
chatRoomMessages.clear();
|
||||
mMessageAdapter.notifyDataSetChanged();
|
||||
}
|
||||
if (tvBottomTip != null) {
|
||||
needAutoScroll = true;
|
||||
tvBottomTip.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public void setNeedAutoScroll(boolean needAutoScroll) {
|
||||
this.needAutoScroll = needAutoScroll;
|
||||
}
|
||||
|
||||
public RecyclerView getMessageListView(){
|
||||
return messageListView;
|
||||
}
|
||||
|
||||
public interface OnClick {
|
||||
/**
|
||||
* 公屏查看公告
|
||||
*/
|
||||
void onShowRoomIntroduction();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private class MessageAdapter extends RecyclerView.Adapter<MessageAdapter.MessageViewHolder> implements OnClickListener,Function1<Drawable, ImageSpan> {
|
||||
|
||||
private Context mContext;
|
||||
private List<ChatRoomMessage> data;
|
||||
|
||||
private int ITEM_TYPE_IMAGE = 1;
|
||||
|
||||
public MessageAdapter(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
public void setData(List<ChatRoomMessage> data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
ChatRoomMessage chatRoomMessage = data.get(position);
|
||||
if (chatRoomMessage.getMsgType() == MsgTypeEnum.image) {
|
||||
return ITEM_TYPE_IMAGE;
|
||||
}
|
||||
|
||||
return super.getItemViewType(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
if (viewType == ITEM_TYPE_IMAGE) {
|
||||
return new MessageAdapter.MessageViewHolder(LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.list_item_chatroom_msg_image, parent, false));
|
||||
|
||||
}
|
||||
return new MessageViewHolder(LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.list_item_chatrrom_msg, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(MessageViewHolder holder, int position) {
|
||||
if (getItemViewType(position) == ITEM_TYPE_IMAGE) {
|
||||
convertImage(holder, data.get(position));
|
||||
} else {
|
||||
convert(holder, data.get(position));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return data.size();
|
||||
}
|
||||
|
||||
protected void convertImage(MessageViewHolder baseViewHolder, ChatRoomMessage chatRoomMessage) {
|
||||
TextView tvContent = baseViewHolder.tvContent;
|
||||
tvContent.setLineSpacing(0, 1);
|
||||
tvContent.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
|
||||
tvContent.setOnClickListener(this);
|
||||
tvContent.setTag(chatRoomMessage);
|
||||
if (UiUtils.INSTANCE.isRtl(tvContent.getContext())) {
|
||||
tvContent.setTextDirection(View.TEXT_DIRECTION_RTL);
|
||||
}
|
||||
try {
|
||||
setVIPMessageBackground(chatRoomMessage, baseViewHolder.itemView);
|
||||
ChatRoomMessageExtension extension = chatRoomMessage.getChatRoomMessageExtension();
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent);
|
||||
addCommonTag(chatRoomMessage, text, tvContent);
|
||||
String nickName = extension == null ? ResUtil.getString(R.string.avroom_widget_messageview_0116) : RegexUtil.getPrintableString(extension.getSenderNick());
|
||||
text.append(nickName, new ForegroundColorSpan(greyColor));
|
||||
tvContent.setText(text.build());
|
||||
|
||||
ImageView imageView = baseViewHolder.itemView.findViewById(R.id.iv_image);
|
||||
ImageAttachment msgAttachment = (ImageAttachment) chatRoomMessage.getAttachment();
|
||||
String path = msgAttachment.getThumbPath();
|
||||
if (TextUtils.isEmpty(path)) {
|
||||
path = msgAttachment.getPath();
|
||||
}
|
||||
if (TextUtils.isEmpty(path)) {
|
||||
path = "";
|
||||
}
|
||||
ImageLoadUtilsV2.loadImage(imageView, path);
|
||||
int[] bounds = new int[]{msgAttachment.getWidth(), msgAttachment.getHeight()};
|
||||
ImageUtil.ImageSize imageSize = ImageUtil.getThumbnailDisplaySize(bounds[0], bounds[1], ChatRoomMessageViewHolderThumbBase.getImageMaxEdge(), ChatRoomMessageViewHolderThumbBase.getImageMinEdge());
|
||||
ViewGroup.LayoutParams maskParams = imageView.getLayoutParams();
|
||||
maskParams.width = imageSize.width;
|
||||
maskParams.height = imageSize.height;
|
||||
imageView.setLayoutParams(maskParams);
|
||||
String finalPath = path;
|
||||
imageView.setOnClickListener(v -> {
|
||||
BigPhotoActivity.start((Activity) mContext, ObjectTypeHelper.pathToCustomItems(finalPath),
|
||||
0, new PagerOption());
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
protected void convert(MessageViewHolder baseViewHolder, ChatRoomMessage chatRoomMessage) {
|
||||
if (chatRoomMessage == null) return;
|
||||
TextView tvContent = baseViewHolder.tvContent;
|
||||
tvContent.setLineSpacing(0, 1);
|
||||
tvContent.setTextColor(Color.WHITE);
|
||||
tvContent.setTextSize(defTextSize);
|
||||
tvContent.setOnClickListener(this);
|
||||
tvContent.setOnLongClickListener(null);
|
||||
tvContent.setTag(chatRoomMessage);
|
||||
tvContent.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
|
||||
if (UiUtils.INSTANCE.isRtl(tvContent.getContext())) {
|
||||
tvContent.setTextDirection(View.TEXT_DIRECTION_RTL);
|
||||
}
|
||||
clearBackground(tvContent);
|
||||
try {
|
||||
if (chatRoomMessage.getMsgType() == MsgTypeEnum.tip) {
|
||||
// 房間通告
|
||||
tvContent.setTextColor(ContextCompat.getColor(mContext, R.color.color_white));
|
||||
tvContent.setText(chatRoomMessage.getContent());
|
||||
tvContent.setBackgroundResource(R.drawable.shape_room_message_tip_bg);
|
||||
} else if (chatRoomMessage.getMsgType() == MsgTypeEnum.text) {
|
||||
setMsgText(chatRoomMessage, tvContent);
|
||||
setVIPMessageBackground(chatRoomMessage, tvContent);
|
||||
} else if (chatRoomMessage.getMsgType() == MsgTypeEnum.notification) {
|
||||
// 加上勛章
|
||||
setMsgNotification(chatRoomMessage, tvContent, baseViewHolder.getAdapterPosition());
|
||||
setVIPMessageBackground(chatRoomMessage, tvContent);
|
||||
} else if (chatRoomMessage.getMsgType() == MsgTypeEnum.custom) {
|
||||
if (chatRoomMessage.getAttachment() != null && chatRoomMessage.getAttachment() instanceof CustomAttachment) {
|
||||
CustomAttachment attachment = (CustomAttachment) chatRoomMessage.getAttachment();
|
||||
int first = attachment.getFirst();
|
||||
int second = attachment.getSecond();
|
||||
if (first == CustomAttachment.CUSTOM_MSG_HEADLINE_CHANGED) {
|
||||
if (second == CustomAttachment.CUSTOM_MSG_HEADLINE_CHANGED_SUB) {
|
||||
setHeadlineMsg(chatRoomMessage, tvContent, attachment);
|
||||
}
|
||||
} else {
|
||||
tvContent.setTextColor(Color.WHITE);
|
||||
tvContent.setText(tvContent.getResources().getText(R.string.not_support_message_tip));
|
||||
}
|
||||
} else {
|
||||
tvContent.setText("");
|
||||
}
|
||||
}
|
||||
} catch (UnsupportedOperationException e) {
|
||||
e.printStackTrace();
|
||||
clearBackground(tvContent);
|
||||
tvContent.setTextColor(Color.WHITE);
|
||||
tvContent.setText(tvContent.getResources().getText(R.string.not_support_message_tip));
|
||||
} catch (Exception e) {
|
||||
clearBackground(tvContent);
|
||||
tvContent.setText("");
|
||||
}
|
||||
}
|
||||
|
||||
private void clearBackground(TextView textView) {
|
||||
// 清除文字
|
||||
textView.setText("");
|
||||
// 清除聊天氣泡
|
||||
textView.setBackgroundResource(R.drawable.shape_room_message_bg);
|
||||
textView.setPadding(paddingWidth, paddingHeight, paddingWidth, paddingHeight);
|
||||
}
|
||||
|
||||
private void setNullBackground(TextView textView) {
|
||||
// 清除聊天氣泡
|
||||
textView.setBackground(null);
|
||||
textView.setPadding(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
public void setVIPMessageBackground(ChatRoomMessage chatRoomMessage, View view) {
|
||||
String androidBubbleUrl = NobleUtil.getResource(UserInfo.BUBBLE_URL_ANDROID, chatRoomMessage);
|
||||
if (TextUtils.isEmpty(androidBubbleUrl)) return;
|
||||
view.setPadding(paddingWidth, ScreenUtil.dip2px(10), paddingWidth, ScreenUtil.dip2px(10));
|
||||
ImageLoadUtils.loadNinePatchBg(view, androidBubbleUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* {badge}{level}xxx: 文字內容
|
||||
*
|
||||
* @param chatRoomMessage -
|
||||
* @param tvContent -
|
||||
*/
|
||||
private void setMsgText(ChatRoomMessage chatRoomMessage, TextView tvContent) {
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent);
|
||||
addCommonTag(chatRoomMessage, text, tvContent);
|
||||
String nickName;
|
||||
if (chatRoomMessage.getFromAccount() != null && chatRoomMessage.getFromAccount().equals(AuthModel.get().getCurrentUid() + "")) {
|
||||
nickName = ResUtil.getString(R.string.avroom_widget_messageview_0116);
|
||||
} else {
|
||||
nickName = NobleUtil.getNamePlate(UserInfo.NICK, chatRoomMessage);
|
||||
}
|
||||
text.append(nickName, new ForegroundColorSpan(greyColor));
|
||||
text.append(": " + chatRoomMessage.getContent(), new ForegroundColorSpan(getResources().getColor(R.color.white)));
|
||||
List<String> atUids = ExtensionUtil.getListExtension(chatRoomMessage, UserInfo.AT_UIDS);
|
||||
List<String> atNames = ExtensionUtil.getListExtension(chatRoomMessage, UserInfo.AT_NAMES);
|
||||
if (!ListUtils.isListEmpty(atUids) && !ListUtils.isListEmpty(atNames)) {
|
||||
for (int i = 0; i < atUids.size(); i++) {
|
||||
String name = atNames.get(i);
|
||||
String uid = atUids.get(i);
|
||||
// 只有當被 @ 人的數組中包含自己的時候才會去變色
|
||||
if (Objects.equals(uid, String.valueOf(AuthModel.get().getCurrentUid()))) {
|
||||
Pattern pattern = Pattern.compile(Pattern.quote(name));
|
||||
Matcher matcher = pattern.matcher(text.build().toString());
|
||||
while (matcher.find()) {
|
||||
int start = matcher.start();
|
||||
int end = matcher.end();
|
||||
text.build().setSpan(new ForegroundColorSpan(getContext().getResources().getColor(R.color.color_FD85C9)),
|
||||
start, end, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Objects.equals(chatRoomMessage.getFromAccount(), String.valueOf(AuthModel.get().getCurrentUid()))) {
|
||||
tvContent.setOnLongClickListener(null);
|
||||
} else {
|
||||
tvContent.setOnLongClickListener(v -> {
|
||||
if (onLongClickListener != null) {
|
||||
onLongClickListener.onLongClick(v, chatRoomMessage.getFromAccount(), nickName);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
MoonUtil.replaceEmoticons(getContext(), text.builder.toString(), text.builder, this);
|
||||
tvContent.setText(text.build());
|
||||
}
|
||||
|
||||
private void addCommonTag(ChatRoomMessage chatRoomMessage, @NonNull TextSpannableBuilder builder, TextView tvContent) {
|
||||
ChatRoomMessageExtension extension = chatRoomMessage.getChatRoomMessageExtension();
|
||||
String userLevel = NobleUtil.getLevel(UserLevelResourceType.EXPER_URL, chatRoomMessage);
|
||||
boolean isOfficial = NobleUtil.getIsOfficial(UserInfo.IS_OFFICIAL, chatRoomMessage);
|
||||
String vipIcon = NobleUtil.getResource(UserInfo.VIP_ICON, chatRoomMessage);
|
||||
builder.append(vipIcon, expLevelHeight)
|
||||
.append(isOfficial ? ResourcesCompat.getDrawable(getResources(),
|
||||
R.mipmap.ic_user_official_13dp, null) : null,
|
||||
badgeWidth, badgeHeight)
|
||||
.append(getNewUserDrawable(chatRoomMessage), badgeWidth, badgeHeight)
|
||||
.append(AvRoomDataManager.get().isSuperAdmin(chatRoomMessage.getFromAccount()) ? ResourcesCompat.getDrawable(getResources(),
|
||||
R.drawable.ic_room_super_admin, null) : null,
|
||||
SizeUtils.dp2px(tvContent.getContext(), 23), expLevelHeight);
|
||||
|
||||
// 官方主播認證
|
||||
String tvOfficialMask = NobleUtil.getLevel(UserInfo.OAC_NAME, chatRoomMessage).trim();
|
||||
String ivOfficialMask = NobleUtil.getLevel(UserInfo.OAC_ICON, chatRoomMessage);
|
||||
if (!TextUtils.isEmpty(tvOfficialMask) && !TextUtils.isEmpty(ivOfficialMask) && extension != null) { // extension != null 表示自己
|
||||
builder.appendBgAndContent(ivOfficialMask, tvOfficialMask);
|
||||
} else if (!TextUtils.isEmpty(ivOfficialMask)) {
|
||||
builder.append(ivOfficialMask, SizeUtils.dp2px(tvContent.getContext(), 62), expLevelHeight);
|
||||
}
|
||||
//等級
|
||||
builder.append(userLevel, expLevelHeight);
|
||||
//銘牌
|
||||
String tvNamePlate = NobleUtil.getNamePlate(UserInfo.NAMEPLATE_WORD, chatRoomMessage).trim();
|
||||
String ivNamePlate = NobleUtil.getNamePlate(UserInfo.NAMEPLATE_PIC, chatRoomMessage);
|
||||
if (!TextUtils.isEmpty(tvNamePlate) && !TextUtils.isEmpty(ivNamePlate)) { // extension != null 表示自己
|
||||
builder.appendBgAndContent(ivNamePlate, tvNamePlate);
|
||||
} else if (!TextUtils.isEmpty(ivNamePlate)) {
|
||||
builder.append(ivNamePlate, expLevelHeight);
|
||||
}
|
||||
}
|
||||
|
||||
private void setHeadlineMsg(ChatRoomMessage chatRoomMessage, TextView tvContent, CustomAttachment attachment) {
|
||||
HeadlineChangedAttachment headlineAttachment = (HeadlineChangedAttachment) attachment;
|
||||
SpannableTextBuilder builder = new SpannableTextBuilder(tvContent);
|
||||
if (attachment.getSecond() == CustomAttachment.CUSTOM_MSG_HEADLINE_CHANGED_SUB) {
|
||||
HeadlineBean data = headlineAttachment.getHeadlineData();
|
||||
String nick = null;
|
||||
if (data != null) {
|
||||
nick = data.getNick();
|
||||
}
|
||||
if (nick == null) {
|
||||
nick = "";
|
||||
}
|
||||
builder.appendText(String.format(ResUtil.getString(R.string.headline_message_format), nick), null, null, null, null, null, null);
|
||||
builder.setTextStyle(nick, ContextCompat.getColor(getContext(), R.color.color_DE3446), null, null, null, null, null);
|
||||
}
|
||||
tvContent.setText(builder.build());
|
||||
tvContent.setTextSize(11);
|
||||
setNullBackground(tvContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* {badge}xxx來了
|
||||
*
|
||||
* @param chatRoomMessage -
|
||||
* @param tvContent -
|
||||
*/
|
||||
private void setMsgNotification(ChatRoomMessage chatRoomMessage, TextView tvContent, int position) {
|
||||
int fromType = 0;
|
||||
String fromNick = "";
|
||||
String fromUid = "";
|
||||
Map<String, Object> remoteExtension = chatRoomMessage.getRemoteExtension();
|
||||
if (remoteExtension != null) {
|
||||
fromType = (int) remoteExtension.get("fromType");
|
||||
fromNick = (String) remoteExtension.get("fromNick");
|
||||
fromUid = (String) remoteExtension.get("fromUid");
|
||||
}
|
||||
ChatRoomNotificationAttachment attachment = (ChatRoomNotificationAttachment) chatRoomMessage.getAttachment();
|
||||
String senderNick = "";
|
||||
List<String> nicks = attachment.getTargetNicks();
|
||||
if (nicks != null && nicks.size() > 0)
|
||||
senderNick = RegexUtil.getPrintableString(attachment.getTargetNicks().get(0));
|
||||
if (attachment.getType() != NotificationType.ChatRoomMemberIn) return;
|
||||
|
||||
// 座駕
|
||||
String carName = NobleUtil.getCarName(CarInfo.CAR_NAME, chatRoomMessage);
|
||||
carName = TextUtils.isEmpty(carName) ? "" : "\"" + carName + "\"";
|
||||
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent);
|
||||
addCommonTag(chatRoomMessage, text, tvContent);
|
||||
text.append(senderNick, new ForegroundColorSpan(roomTipColor),
|
||||
new OriginalDrawStatusClickSpan() {
|
||||
@Override
|
||||
public void onClick(@NonNull View view) {
|
||||
if (clickConsumer != null) {
|
||||
Single.just(chatRoomMessage.getFromAccount())
|
||||
.doOnSuccess(clickConsumer).subscribe();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
text.append(TextUtils.isEmpty(carName) ? "" : ResUtil.getString(R.string.avroom_widget_messageview_0150), new ForegroundColorSpan(greyColor))
|
||||
.append(carName, new ForegroundColorSpan(roomTipColor));
|
||||
String enterText = ResUtil.getString(R.string.avroom_widget_messageview_0151);
|
||||
if (fromType == AVRoomActivity.FROM_TYPE_RECOMMEND) {
|
||||
enterText = ResUtil.getString(R.string.avroom_widget_messageview_0152);
|
||||
}
|
||||
if (fromType == AVRoomActivity.FROM_TYPE_USER || fromType == AVRoomActivity.FROM_TYPE_HELLO) {
|
||||
String finalFromUid = fromUid;
|
||||
text.append(ResUtil.getString(R.string.avroom_widget_messageview_0153), new ForegroundColorSpan(whiteColor))
|
||||
.append(fromNick, new ForegroundColorSpan(roomTipColor),
|
||||
new OriginalDrawStatusClickSpan() {
|
||||
@Override
|
||||
public void onClick(@NonNull View view) {
|
||||
if (clickConsumer != null) {
|
||||
Single.just(finalFromUid).doOnSuccess(clickConsumer).subscribe();
|
||||
}
|
||||
}
|
||||
});
|
||||
enterText = ResUtil.getString(R.string.avroom_widget_messageview_0154);
|
||||
}
|
||||
|
||||
if (fromType == AVRoomActivity.FROM_TYPE_GAME_RECOMMEND) {
|
||||
String finalFromUid = fromUid;
|
||||
text.append(ResUtil.getString(R.string.avroom_widget_messageview_0155), new ForegroundColorSpan(whiteColor))
|
||||
.append(fromNick, new ForegroundColorSpan(roomTipColor),
|
||||
new OriginalDrawStatusClickSpan() {
|
||||
@Override
|
||||
public void onClick(@NonNull View view) {
|
||||
if (clickConsumer != null) {
|
||||
Single.just(finalFromUid).doOnSuccess(clickConsumer).subscribe();
|
||||
}
|
||||
}
|
||||
});
|
||||
enterText = ResUtil.getString(R.string.avroom_widget_messageview_0156);
|
||||
}
|
||||
|
||||
text.append(enterText, new ForegroundColorSpan(whiteColor));
|
||||
tvContent.setText(text.build());
|
||||
tvContent.setOnClickListener(null);
|
||||
tvContent.setMovementMethod(new LinkMovementMethod());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Drawable getNewUserDrawable(ChatRoomMessage chatRoomMessage) {
|
||||
boolean newUser = NobleUtil.getIsNewUser(UserInfo.IS_NEW_USER, chatRoomMessage);
|
||||
boolean isHelloUser = NobleUtil.getIsNewUser(UserInfo.IS_FROM_SAY_HELLO_CHANNEL, chatRoomMessage);
|
||||
if (newUser) {
|
||||
return ResourcesCompat.getDrawable(getResources(),
|
||||
isHelloUser ? R.drawable.ic_new_user_hello : R.drawable.ic_new_user,
|
||||
null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String account = "";
|
||||
ChatRoomMessage chatRoomMessage = (ChatRoomMessage) v.getTag();
|
||||
if (chatRoomMessage.getMsgType() != MsgTypeEnum.tip) {
|
||||
if (chatRoomMessage.getMsgType() == MsgTypeEnum.text) {
|
||||
account = chatRoomMessage.getFromAccount();
|
||||
} else if (chatRoomMessage.getMsgType() == MsgTypeEnum.notification) {
|
||||
account = chatRoomMessage.getFromAccount();
|
||||
} else if (chatRoomMessage.getMsgType() == MsgTypeEnum.custom) {
|
||||
CustomAttachment attachment = (CustomAttachment) chatRoomMessage.getAttachment();
|
||||
if (attachment.getFirst() == CustomAttachment.CUSTOM_MSG_HEADER_TYPE_ROOM_TIP) {
|
||||
account = ((RoomTipAttachment) attachment).getUid() + "";
|
||||
} else if (attachment.getFirst() == CustomAttachment.CUSTOM_MSG_BOX) {
|
||||
account = String.valueOf(((RoomBoxPrizeAttachment) attachment).getUid());
|
||||
} else if (attachment.getFirst() == CustomAttachment.CUSTOM_MSG_HEADER_TYPE_QUEUE) {
|
||||
long handleUid = ((RoomQueueMsgAttachment) attachment).handleUid;
|
||||
if (handleUid > 0) {
|
||||
account = ((RoomQueueMsgAttachment) attachment).handleUid + "";
|
||||
} else {
|
||||
//ios沒用handleUid,導致iOS發的自定義消息,拿不到uid
|
||||
account = chatRoomMessage.getFromAccount();
|
||||
}
|
||||
} else if (attachment.getFirst() == CustomAttachment.CUSTOM_MSG_HEADER_TYPE_MONSTER_HUNTING) {
|
||||
switch (attachment.getSecond()) {
|
||||
case CustomAttachment.CUSTOM_MSG_SUB_TYPE_MONSTER_HUNTING:
|
||||
MonsterDataBean dataBean = ((MonsterStatusAttachment) attachment).getDataBean();
|
||||
RoomInfo mCurrentRoomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
|
||||
if (!Objects.equals(mCurrentRoomInfo.getUid(), dataBean.getAppearRoomUid())) {
|
||||
AVRoomActivity.start(getContext(), dataBean.getAppearRoomUid());
|
||||
} else {
|
||||
SingleToastUtil.showToast("你已經在怪獸房間內");
|
||||
}
|
||||
break;
|
||||
|
||||
case CustomAttachment.CUSTOM_NOTI_SUB_GAME_RESULT:
|
||||
MonsterHuntingResult result = ((MonsterHuntingResultAttachment) attachment).getResult();
|
||||
UIHelper.showMonsterResult(getContext(), String.valueOf(result.getMonster().getMonsterId()));
|
||||
break;
|
||||
}
|
||||
} else if (attachment.getFirst() == CustomAttachment.CUSTOM_MESS_HEAD_ROOM_PK) {
|
||||
if (attachment.getSecond() == CustomAttachment.CUSTOM_MESS_SUB_ROOM_PK_RESULT) {
|
||||
RoomTeamPKResultDialog pkResultDialog = new RoomTeamPKResultDialog(getContext(), ((RoomPkAttachment) attachment).getRoomPkData());
|
||||
pkResultDialog.show();
|
||||
}
|
||||
} else if (attachment instanceof RoomFollowOwnerAttachment2 && !AvRoomDataManager.get().isRoomFans) {
|
||||
CollectionRoomModel.get().followRoom("1", ((RoomFollowOwnerAttachment2) attachment).getOwnerUid())
|
||||
.subscribe(s -> {
|
||||
AvRoomDataManager.get().isRoomFans = true;
|
||||
SingleToastUtil.showToast("收藏成功!");
|
||||
EventBus.getDefault().post(new FollowRoomEvent());
|
||||
PraiseModel.get().setFollowRoomSuccessRoomTip(JavaUtil.str2long(chatRoomMessage.getFromAccount()));
|
||||
});
|
||||
} else if (attachment.getFirst() == CustomAttachment.CUSTOM_MESS_TAROT) {
|
||||
if (attachment instanceof TarotAttachment) {
|
||||
account = ((TarotAttachment) attachment).getTarotMsgBean().getUid() + "";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (TextUtils.isEmpty(account)) return;
|
||||
if (clickConsumer != null) {
|
||||
Single.just(account).subscribe(clickConsumer);
|
||||
}
|
||||
} else {
|
||||
String content = chatRoomMessage.getContent();
|
||||
if (!TextUtils.isEmpty(content) && content.equals(ResUtil.getString(R.string.yizhuan_xchat_android_constants_xchatconstants_08)))
|
||||
if (onClick != null) {
|
||||
onClick.onShowRoomIntroduction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImageSpan invoke(Drawable drawable) {
|
||||
return new CustomImageSpan(drawable);
|
||||
}
|
||||
|
||||
class MessageViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView tvContent;
|
||||
|
||||
public MessageViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
tvContent = itemView.findViewById(R.id.tv_content);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,111 @@
|
||||
package com.chwl.app.avroom.public_chat
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.public_chat.core.ChatRoomClient
|
||||
import com.chwl.app.public_chat.core.ChatRoomClientManager
|
||||
import com.chwl.core.im.custom.bean.HeadlineChangedAttachment
|
||||
import com.chwl.core.support.room.FrameLayoutRoomWidget
|
||||
import com.chwl.core.support.room.RoomView
|
||||
import com.chwl.library.utils.SingleToastUtil
|
||||
import com.netease.nim.uikit.api.model.NimException
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage
|
||||
import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum
|
||||
import com.netease.nimlib.sdk.msg.model.QueryDirectionEnum
|
||||
|
||||
class PublicChatRoomMessageWidget : FrameLayoutRoomWidget {
|
||||
|
||||
private val messageView: PublicChatMessageView = PublicChatMessageView(context)
|
||||
|
||||
private var chatRoomClient: ChatRoomClient? = null
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleAttr
|
||||
)
|
||||
|
||||
constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet?,
|
||||
defStyleAttr: Int,
|
||||
defStyleRes: Int
|
||||
) : super(context, attrs, defStyleAttr, defStyleRes)
|
||||
|
||||
init {
|
||||
addView(messageView, LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT))
|
||||
}
|
||||
|
||||
override fun onStart(roomView: RoomView) {
|
||||
super.onStart(roomView)
|
||||
chatRoomClient = ChatRoomClientManager.getPublicChatClient()
|
||||
if (chatRoomClient == null) {
|
||||
SingleToastUtil.showToast(R.string.public_chat_not_found)
|
||||
}
|
||||
chatRoomClient?.let {
|
||||
initChatRoom(it)
|
||||
}
|
||||
}
|
||||
|
||||
private fun onReceiveMessage(message: ChatRoomMessage) {
|
||||
if (!filterMessageForMessageList(message)) {
|
||||
messageView.addMessages(message)
|
||||
}
|
||||
}
|
||||
|
||||
private fun initChatRoom(chatRoomClient: ChatRoomClient) {
|
||||
getCompositeDisposable().add(
|
||||
chatRoomClient.enterChatRoom()
|
||||
.subscribe({ requestHistory(chatRoomClient) },
|
||||
{
|
||||
if (it is NimException) {
|
||||
SingleToastUtil.showToast(context.getString(R.string.avroom_fragment_homepartyroomfragment_011) + "(${it.code})")
|
||||
} else {
|
||||
SingleToastUtil.showToast(R.string.avroom_fragment_homepartyroomfragment_011)
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
getCompositeDisposable().add(chatRoomClient.messageObservable.subscribe {
|
||||
it.forEach { message ->
|
||||
onReceiveMessage(message)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun requestHistory(chatRoomClient: ChatRoomClient) {
|
||||
val typeEnums = arrayOf(MsgTypeEnum.text, MsgTypeEnum.image)
|
||||
getCompositeDisposable().add(
|
||||
chatRoomClient.requestRemoteMessageType(
|
||||
0,
|
||||
50,
|
||||
QueryDirectionEnum.QUERY_OLD,
|
||||
typeEnums
|
||||
).subscribe({
|
||||
messageView.addHistoryMessages(it.reversed())
|
||||
}, {
|
||||
it.printStackTrace()
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
private fun filterMessageForMessageList(message: ChatRoomMessage): Boolean {
|
||||
if (message.msgType == MsgTypeEnum.custom && message.attachment is HeadlineChangedAttachment) {
|
||||
val data = (message.attachment as HeadlineChangedAttachment).headlineData
|
||||
if (data == null || !data.isValid()) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fun getMessageView() = messageView
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
chatRoomClient = null
|
||||
}
|
||||
}
|
@@ -0,0 +1,92 @@
|
||||
package com.chwl.app.avroom.rank
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import com.chwl.core.support.room.FrameLayoutRoomWidget
|
||||
import com.chwl.core.support.room.RoomWidget
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.databinding.RoomRankNumberWidgetBinding
|
||||
import com.chwl.app.ui.webview.DialogWebViewActivity
|
||||
import com.chwl.core.UriProvider
|
||||
import com.chwl.core.im.custom.bean.RoomSerialValueChangedAttachment
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
import com.chwl.core.manager.IMNetEaseManager
|
||||
import com.chwl.core.manager.RoomEvent
|
||||
import com.chwl.core.support.room.RoomContext
|
||||
import com.chwl.core.support.room.RoomView
|
||||
import com.chwl.library.utils.FormatUtils
|
||||
import com.example.lib_utils.ktx.singleClick
|
||||
|
||||
/**
|
||||
* 房间榜单入口
|
||||
*/
|
||||
class RoomRankNumberWidget : FrameLayoutRoomWidget, RoomWidget {
|
||||
|
||||
private val binding: RoomRankNumberWidgetBinding =
|
||||
DataBindingUtil.inflate(
|
||||
LayoutInflater.from(
|
||||
context
|
||||
), R.layout.room_rank_number_widget, this, true
|
||||
)
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleAttr
|
||||
)
|
||||
|
||||
constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet?,
|
||||
defStyleAttr: Int,
|
||||
defStyleRes: Int
|
||||
) : super(context, attrs, defStyleAttr, defStyleRes)
|
||||
|
||||
init {
|
||||
this.singleClick {
|
||||
DialogWebViewActivity.start(context, UriProvider.getRoomRanking())
|
||||
}
|
||||
}
|
||||
|
||||
override fun onInitialize(roomView: RoomView, roomContext: RoomContext) {
|
||||
super.onInitialize(roomView, roomContext)
|
||||
refreshData()
|
||||
registerMemberChangedListener()
|
||||
}
|
||||
|
||||
override fun onUnbindContext() {
|
||||
super.onUnbindContext()
|
||||
updateView(null)
|
||||
}
|
||||
|
||||
private fun registerMemberChangedListener() {
|
||||
getCompositeDisposable().add(IMNetEaseManager.get().chatRoomEventObservable.subscribe {
|
||||
when (it.event) {
|
||||
RoomEvent.SERIAL_VALUE_CHANGED -> {
|
||||
val attachment =
|
||||
it.chatRoomMessage.attachment as? RoomSerialValueChangedAttachment
|
||||
attachment?.serialValue?.let {
|
||||
updateView(attachment.serialValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun refreshData() {
|
||||
val value = AvRoomDataManager.get().serialValue
|
||||
updateView(value)
|
||||
}
|
||||
|
||||
private fun updateView(value: Double?) {
|
||||
if (value == null || value <= 0) {
|
||||
binding.tvNumber.text = "0"
|
||||
} else {
|
||||
binding.tvNumber.text = FormatUtils.formatToShortKMHalfUp(value)
|
||||
}
|
||||
}
|
||||
}
|
94
app/src/main/java/com/chwl/app/avroom/rank/RoomRankWidget.kt
Normal file
94
app/src/main/java/com/chwl/app/avroom/rank/RoomRankWidget.kt
Normal file
@@ -0,0 +1,94 @@
|
||||
package com.chwl.app.avroom.rank
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import com.chwl.core.support.room.FrameLayoutRoomWidget
|
||||
import com.chwl.core.support.room.RoomWidget
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.databinding.RoomRankWidgetBinding
|
||||
import com.chwl.app.ui.utils.loadAvatar
|
||||
import com.chwl.app.ui.webview.DialogWebViewActivity
|
||||
import com.chwl.core.UriProvider
|
||||
import com.chwl.core.room.bean.RoomContributeDataInfo
|
||||
import com.chwl.core.room.bean.RoomContributeUserInfo
|
||||
import com.chwl.core.room.model.RoomContributeListModel
|
||||
import com.chwl.core.support.room.RoomContext
|
||||
import com.chwl.core.support.room.RoomView
|
||||
import com.chwl.core.utils.net.RxHelper
|
||||
import com.example.lib_utils.ktx.singleClick
|
||||
|
||||
/**
|
||||
* 房间榜单入口
|
||||
*/
|
||||
class RoomRankWidget : FrameLayoutRoomWidget, RoomWidget {
|
||||
|
||||
private val binding: RoomRankWidgetBinding =
|
||||
DataBindingUtil.inflate(
|
||||
LayoutInflater.from(
|
||||
context
|
||||
), R.layout.room_rank_widget, this, true
|
||||
)
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleAttr
|
||||
)
|
||||
|
||||
constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet?,
|
||||
defStyleAttr: Int,
|
||||
defStyleRes: Int
|
||||
) : super(context, attrs, defStyleAttr, defStyleRes)
|
||||
|
||||
init {
|
||||
this.singleClick {
|
||||
DialogWebViewActivity.start(context, UriProvider.getRoomRanking())
|
||||
refreshData()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onInitialize(roomView: RoomView, roomContext: RoomContext) {
|
||||
super.onInitialize(roomView, roomContext)
|
||||
refreshData()
|
||||
}
|
||||
|
||||
override fun onUnbindContext() {
|
||||
super.onUnbindContext()
|
||||
updateView(null)
|
||||
}
|
||||
|
||||
private fun refreshData() {
|
||||
val disposable = RoomContributeListModel.get()
|
||||
.getSingleRoomRanking(1, RoomContributeDataInfo.TYPE_ROOM_DAY_RANKING)
|
||||
.compose(RxHelper.handleBeanData())
|
||||
.subscribe { roomContributeDataInfo: RoomContributeDataInfo ->
|
||||
updateView(roomContributeDataInfo.rankings)
|
||||
}
|
||||
getCompositeDisposable().add(disposable)
|
||||
}
|
||||
|
||||
private fun updateView(list: List<RoomContributeUserInfo>?) {
|
||||
arrayListOf(
|
||||
binding.ivRank0, binding.ivRank1, binding.ivRank2
|
||||
).forEachIndexed { index, imageView ->
|
||||
val url = list?.getOrNull(index)?.avatar
|
||||
if (url.isNullOrEmpty()) {
|
||||
imageView.isVisible = false
|
||||
} else {
|
||||
imageView.loadAvatar(url)
|
||||
imageView.isVisible = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setContentBackgroundResource(resId: Int) {
|
||||
binding.layoutRoot.setBackgroundResource(resId)
|
||||
}
|
||||
}
|
@@ -9,6 +9,7 @@ import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.avroom.adapter.CommonVPAdapter;
|
||||
import com.chwl.app.base.BaseViewBindingActivity;
|
||||
import com.chwl.app.base.TitleBar;
|
||||
import com.chwl.app.databinding.ActivityMyRecommendCardBinding;
|
||||
@@ -49,7 +50,7 @@ public class MyRecommendCardActivity extends BaseViewBindingActivity<ActivityMyR
|
||||
fragmentList.add(RecommendCardFragment.newInstance(RcmdCardType.HAS_USED));
|
||||
//已失效
|
||||
fragmentList.add(RecommendCardFragment.newInstance(RcmdCardType.INVALID));
|
||||
binding.viewPager.setAdapter(new CardPagerAdapter(getSupportFragmentManager()));
|
||||
binding.viewPager.setAdapter(new CommonVPAdapter(getSupportFragmentManager() ,getLifecycle(), fragmentList));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -82,21 +83,4 @@ public class MyRecommendCardActivity extends BaseViewBindingActivity<ActivityMyR
|
||||
ViewPagerHelper.bind(binding.indicator, binding.viewPager);
|
||||
|
||||
}
|
||||
|
||||
class CardPagerAdapter extends FragmentStatePagerAdapter {
|
||||
|
||||
public CardPagerAdapter(FragmentManager fm) {
|
||||
super(fm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
return fragmentList.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return fragmentList.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.text.style.AbsoluteSizeSpan;
|
||||
import android.view.View;
|
||||
|
||||
import com.chwl.app.ui.widget.TextSpannableBuilder;
|
||||
import com.coorchice.library.SuperTextView;
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
|
||||
import com.chwl.app.R;
|
||||
@@ -34,7 +35,7 @@ public class RecommendCardListAdapter extends CommonAdapter<RecommendCard, BaseV
|
||||
protected void convert(BaseViewHolder holder, RecommendCard item) {
|
||||
holder.setText(R.id.tv_time_title, item.getCardName());
|
||||
|
||||
MessageView.SpannableBuilder builder = new MessageView.SpannableBuilder(null);
|
||||
TextSpannableBuilder builder = new TextSpannableBuilder(null);
|
||||
builder.append("X", new AbsoluteSizeSpan(ScreenUtil.sp2px(12)))
|
||||
.append(String.valueOf(item.getCount()));
|
||||
holder.setText(R.id.tv_card_count, builder.build());
|
||||
|
@@ -3,13 +3,13 @@ package com.chwl.app.avroom.room_album
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import com.hjq.toast.ToastUtils
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogLockRoomAlbumPhotoBinding
|
||||
import com.chwl.app.ui.utils.ImageLoadUtilsV2
|
||||
import com.chwl.core.gift.bean.GiftReceiveInfo
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
|
||||
class UnlockRoomAlbumPhotoDialog : BaseDialog<DialogLockRoomAlbumPhotoBinding>(){
|
||||
class UnlockRoomAlbumPhotoDialog : BaseDialogFragment<DialogLockRoomAlbumPhotoBinding>(){
|
||||
|
||||
var onUnlockRoomPhotoListener: OnUnlockRoomPhotoListener? = null
|
||||
|
||||
|
@@ -251,7 +251,7 @@ class UploadRoomAlbumDialogFragment : BottomSheetDialogFragment() {
|
||||
}
|
||||
if (requestCode == 200) {
|
||||
PhotoProvider.getResultPathListAsync(data) {
|
||||
it?.let { paths ->
|
||||
it?.mapNotNull { it.path }?.let { paths ->
|
||||
compressPhotos(paths.toMutableList())
|
||||
}
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@ class SingleRoomPKSearchAdapter :
|
||||
tvSelect.text = ResUtil.getString(R.string.offline)
|
||||
tvSelect.setTextColor("#80C6C6E9".toColorInt())
|
||||
} else if (item.crossPking) {
|
||||
tvSelect.text = "PK中"
|
||||
tvSelect.text = tvSelect.context.getString(R.string.layout_item_home_tab_map_02)
|
||||
tvSelect.setTextColor("#80C6C6E9".toColorInt())
|
||||
} else {
|
||||
tvSelect.text = ResUtil.getString(R.string.select)
|
||||
|
@@ -5,7 +5,7 @@ import android.os.Bundle
|
||||
import android.view.WindowManager
|
||||
import androidx.core.view.isVisible
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogSingleRoomPkFinishBinding
|
||||
import com.chwl.app.ui.utils.load
|
||||
import com.chwl.core.im.custom.bean.RoomPkBean
|
||||
@@ -14,7 +14,7 @@ import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class SingleRoomPkFinishDialog : BaseDialog<DialogSingleRoomPkFinishBinding>() {
|
||||
class SingleRoomPkFinishDialog : BaseDialogFragment<DialogSingleRoomPkFinishBinding>() {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
|
@@ -4,13 +4,13 @@ import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.WindowManager
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogSingleRoomPkForceFinishBinding
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils
|
||||
import com.chwl.core.im.custom.bean.RoomPkBean
|
||||
import com.chwl.core.utils.extension.subAndReplaceDot
|
||||
|
||||
class SingleRoomPkForceFinishDialog : BaseDialog<DialogSingleRoomPkForceFinishBinding>() {
|
||||
class SingleRoomPkForceFinishDialog : BaseDialogFragment<DialogSingleRoomPkForceFinishBinding>() {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
|
@@ -3,7 +3,8 @@ package com.chwl.app.avroom.singleroompk
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import androidx.core.view.isVisible
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogSingleRoomPkReceivedBinding
|
||||
import com.chwl.core.im.custom.bean.RoomPkBean
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
@@ -16,7 +17,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class SingleRoomPkReceivedDialog : BaseDialog<DialogSingleRoomPkReceivedBinding>() {
|
||||
class SingleRoomPkReceivedDialog : BaseDialogFragment<DialogSingleRoomPkReceivedBinding>() {
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -37,7 +38,7 @@ class SingleRoomPkReceivedDialog : BaseDialog<DialogSingleRoomPkReceivedBinding>
|
||||
@SuppressLint("CheckResult")
|
||||
override fun init() {
|
||||
binding?.tvNick?.text = pkBean.inviteRoomTitle.subAndReplaceDot(7)
|
||||
binding?.tvTime?.text = "${pkBean.pkDuration}分鐘"
|
||||
binding?.tvTime?.text = "${pkBean.pkDuration}${getString(R.string.layout_activity_room_pk_create_010)}"
|
||||
pkBean.pkDesc.ifNotNullOrEmpty {
|
||||
binding?.tvDescTitle?.isVisible = true
|
||||
binding?.tvDesc?.isVisible = true
|
||||
|
@@ -1,12 +1,12 @@
|
||||
package com.chwl.app.avroom.singleroompk
|
||||
|
||||
import android.text.method.ScrollingMovementMethod
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.base.BaseDialogFragment
|
||||
import com.chwl.app.databinding.DialogSingleRoomPkRuleBinding
|
||||
import com.chwl.core.room.anotherroompk.SingleRoomPKModel
|
||||
import com.chwl.core.utils.extension.toast
|
||||
|
||||
class SingleRoomPkRuleDialog : BaseDialog<DialogSingleRoomPkRuleBinding>() {
|
||||
class SingleRoomPkRuleDialog : BaseDialogFragment<DialogSingleRoomPkRuleBinding>() {
|
||||
|
||||
companion object {
|
||||
|
||||
|
@@ -3,6 +3,7 @@ package com.chwl.app.avroom.view
|
||||
import com.chwl.core.bean.RoomMicInfo
|
||||
import com.chwl.core.room.bean.RoomContributeUserInfo
|
||||
import com.chwl.library.base.IMvpBaseView
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -32,6 +33,7 @@ interface IBaseRoomView : IMvpBaseView {
|
||||
fun chatRoomReConnectView()
|
||||
fun showToast(msg: String?)
|
||||
fun onSendMsgSuccess(msg: String?)
|
||||
fun onSendPublicChatMsgSuccess(msg: ChatRoomMessage)
|
||||
|
||||
/**
|
||||
* 上麦请求
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user